-
Notifications
You must be signed in to change notification settings - Fork 914
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 2.x] [VisBuilder] Adds UIState to vis, adds index patterns …
…to embeddable, bug fixes (#3874) * [VisBuilder] Adds UIState to vis, adds index patterns to embeddable, bug fixes (#3751) * adds uiActions to visBuilder * prevents multiple errors on load * fixes visbuilder type errors * fixes save * adds ui state to vis builder * fixes tests * Adds support in embeddables for multiple indices * Moves ui state to separate slice * Adds changelog Signed-off-by: Ashwin P Chandran <[email protected]> --------- Signed-off-by: Ashwin P Chandran <[email protected]> Co-authored-by: Josh Romero <[email protected]> (cherry picked from commit ee32d20) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md * add changelog Signed-off-by: Josh Romero <[email protected]> --------- Signed-off-by: Josh Romero <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Josh Romero <[email protected]>
- Loading branch information
1 parent
7447079
commit 0ae76d2
Showing
20 changed files
with
207 additions
and
60 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
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
63 changes: 41 additions & 22 deletions
63
src/plugins/vis_builder/public/application/utils/schema.json
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 |
---|---|---|
@@ -1,28 +1,47 @@ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"styleState": { | ||
"type": "object" | ||
}, | ||
"visualizationState": { | ||
"type": "object", | ||
"properties": { | ||
"activeVisualization": { | ||
"type": "object", | ||
"properties": { | ||
"name": { "type": "string" }, | ||
"aggConfigParams": { "type": "array" } | ||
"type": "object", | ||
"properties": { | ||
"styleState": { | ||
"type": "object" | ||
}, | ||
"visualizationState": { | ||
"type": "object", | ||
"properties": { | ||
"activeVisualization": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"required": ["name", "aggConfigParams"], | ||
"additionalProperties": false | ||
"aggConfigParams": { | ||
"type": "array" | ||
} | ||
}, | ||
"indexPattern": { "type": "string" }, | ||
"searchField": { "type": "string" } | ||
"required": [ | ||
"name", | ||
"aggConfigParams" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"required": ["searchField"], | ||
"additionalProperties": false | ||
} | ||
"indexPattern": { | ||
"type": "string" | ||
}, | ||
"searchField": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"searchField" | ||
], | ||
"additionalProperties": false | ||
}, | ||
"required": ["styleState", "visualizationState"], | ||
"additionalProperties": false | ||
"uiState": { | ||
"type": "object" | ||
} | ||
}, | ||
"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
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
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
42 changes: 42 additions & 0 deletions
42
src/plugins/vis_builder/public/application/utils/state_management/ui_state_slice.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,42 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
import { VisBuilderServices } from '../../../types'; | ||
|
||
export type UIStateState<T = any> = T; | ||
|
||
const initialState = {} as UIStateState; | ||
|
||
export const getPreloadedState = async ({ | ||
types, | ||
data, | ||
}: VisBuilderServices): Promise<UIStateState> => { | ||
return initialState; | ||
}; | ||
|
||
export const uiStateSlice = createSlice({ | ||
name: 'ui', | ||
initialState, | ||
reducers: { | ||
setState<T>(state: T, action: PayloadAction<UIStateState<T>>) { | ||
return action.payload; | ||
}, | ||
updateState<T>(state: T, action: PayloadAction<Partial<UIStateState<T>>>) { | ||
state = { | ||
...state, | ||
...action.payload, | ||
}; | ||
}, | ||
}, | ||
}); | ||
|
||
// Exposing the state functions as generics | ||
export const setState = uiStateSlice.actions.setState as <T>(payload: T) => PayloadAction<T>; | ||
export const updateState = uiStateSlice.actions.updateState as <T>( | ||
payload: Partial<T> | ||
) => PayloadAction<Partial<T>>; | ||
|
||
export const { reducer } = uiStateSlice; |
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
Oops, something went wrong.