-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into md-legacy-client
- Loading branch information
Showing
7 changed files
with
125 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"styleState": { | ||
"type": "object" | ||
}, | ||
"visualizationState": { | ||
"type": "object", | ||
"properties": { | ||
"activeVisualization": { | ||
"type": "object", | ||
"properties": { | ||
"name": { "type": "string" }, | ||
"aggConfigParams": { "type": "array" } | ||
}, | ||
"required": ["name", "aggConfigParams"], | ||
"additionalProperties": false | ||
}, | ||
"indexPattern": { "type": "string" }, | ||
"searchField": { "type": "string" } | ||
}, | ||
"required": ["searchField"], | ||
"additionalProperties": false | ||
} | ||
}, | ||
"required": ["styleState", "visualizationState"], | ||
"additionalProperties": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/plugins/wizard/public/application/utils/wizard_state_validation.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { validateWizardState } from './wizard_state_validation'; | ||
|
||
describe('wizard state validation', () => { | ||
const validStyleState = { | ||
addLegend: true, | ||
addTooltip: true, | ||
legendPosition: '', | ||
type: 'metric', | ||
}; | ||
const validVisualizationState = { | ||
activeVisualization: { | ||
name: 'metric', | ||
aggConfigParams: [], | ||
}, | ||
indexPattern: '', | ||
searchField: '', | ||
}; | ||
describe('correct return when validation suceeds', () => { | ||
test('with correct wizard state', () => { | ||
const validationResult = validateWizardState({ | ||
styleState: validStyleState, | ||
visualizationState: validVisualizationState, | ||
}); | ||
expect(validationResult.valid).toBeTruthy(); | ||
expect(validationResult.errors).toBeNull(); | ||
}); | ||
}); | ||
describe('correct return with errors when validation fails', () => { | ||
test('with non object type styleStyle', () => { | ||
const validationResult = validateWizardState({ | ||
styleState: [], | ||
visualizationState: validVisualizationState, | ||
}); | ||
expect(validationResult.valid).toBeFalsy(); | ||
expect(validationResult.errors).toBeDefined(); | ||
}); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
src/plugins/wizard/public/application/utils/wizard_state_validation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import Ajv from 'ajv'; | ||
import wizardStateSchema from './schema.json'; | ||
|
||
const ajv = new Ajv(); | ||
const validateState = ajv.compile(wizardStateSchema); | ||
|
||
export const validateWizardState = (wizardState) => { | ||
const isWizardStateValid = validateState(wizardState); | ||
|
||
return { | ||
valid: isWizardStateValid, | ||
errors: validateState.errors, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4368,7 +4368,7 @@ ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.11.0, ajv@^6.12.3, ajv@^6.12.4, ajv | |
json-schema-traverse "^0.4.1" | ||
uri-js "^4.2.2" | ||
|
||
ajv@^8.0.1, ajv@^8.6.2: | ||
ajv@^8.0.1, ajv@^8.11.0, ajv@^8.6.2: | ||
version "8.11.0" | ||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.11.0.tgz#977e91dd96ca669f54a11e23e378e33b884a565f" | ||
integrity sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg== | ||
|
@@ -11911,10 +11911,10 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/leaflet-responsive-popup/-/leaflet-responsive-popup-0.6.4.tgz#b93d9368ef9f96d6dc911cf5b96d90e08601c6b3" | ||
integrity sha512-2D8G9aQA6NHkulDBPN9kqbUCkCpWQQ6dF0xFL11AuEIWIbsL4UC/ZPP5m8GYM0dpU6YTlmyyCh1Tz+cls5Q4dg== | ||
|
||
"leaflet-vega@npm:@amoo-miki/[email protected].7": | ||
version "0.8.7" | ||
resolved "https://registry.yarnpkg.com/@amoo-miki/leaflet-vega/-/leaflet-vega-0.8.7.tgz#8faca1b4b8e2ef7d48667ac6faad9204f4da7153" | ||
integrity sha512-T4M5yziwj3Fi9Adsbce+cdWqPjON0BRwEjwqLlPMoirU1vhifA6YKrlZkVzJrK0IIm+hdfMCLkBz33gD8fdxzQ== | ||
"leaflet-vega@npm:@amoo-miki/[email protected].8": | ||
version "0.8.8" | ||
resolved "https://registry.yarnpkg.com/@amoo-miki/leaflet-vega/-/leaflet-vega-0.8.8.tgz#675abf37d72fbea859755e982f4fd19dea776557" | ||
integrity sha512-W2gGgFDxzy/XUx+fQJfz0NYVXsKl7V+G6QywiMcOV5NEodDId9c60up7NNf+cfM7ggpo+5BuLqrKmosuGO1CsA== | ||
dependencies: | ||
vega-spec-injector "^0.0.2" | ||
|
||
|
@@ -18353,10 +18353,10 @@ vega-hierarchy@~4.1.0: | |
vega-dataflow "^5.7.3" | ||
vega-util "^1.15.2" | ||
|
||
"vega-interpreter@npm:@amoo-miki/[email protected].5": | ||
version "1.0.5" | ||
resolved "https://registry.yarnpkg.com/@amoo-miki/vega-forced-csp-compliant-interpreter/-/vega-forced-csp-compliant-interpreter-1.0.5.tgz#49970be9b00ca7e45ced0617fbf373c77a28aab4" | ||
integrity sha512-lfeU77lVoUbSCC6N1ywdKg+I6K08xpkd82TLon+LebtKyC8aLCe7P5Dd/89zAPyFwRyobKftHu8z0xpV7R7a4Q== | ||
"vega-interpreter@npm:@amoo-miki/[email protected].6": | ||
version "1.0.6" | ||
resolved "https://registry.yarnpkg.com/@amoo-miki/vega-forced-csp-compliant-interpreter/-/vega-forced-csp-compliant-interpreter-1.0.6.tgz#5cffdf12b7fe12dc936194edd9e8519506c38716" | ||
integrity sha512-9S5nTTVd8JVKobcWp5iwirIeePiamwH1J9uSZPuG5kcF0TUBvGu++ERKjNdst5Qck7e4R6/7vjx2wVf58XUarg== | ||
|
||
vega-label@~1.2.0: | ||
version "1.2.0" | ||
|