-
Notifications
You must be signed in to change notification settings - Fork 918
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[D&D] Adds autosave while editing aggregation (#1953)
* fest: Adds autosave while editing agg Signed-off-by: Ashwin Pc <[email protected]> * fix: autosave order Signed-off-by: Ashwin Pc <[email protected]> * fix: spelling Co-authored-by: Josh Romero <[email protected]> Co-authored-by: Josh Romero <[email protected]>
- Loading branch information
1 parent
d544148
commit 67d5f75
Showing
8 changed files
with
97 additions
and
25 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
48 changes: 48 additions & 0 deletions
48
src/plugins/wizard/public/application/utils/state_management/metadata_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,48 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
import { WizardServices } from '../../../types'; | ||
|
||
export interface MetadataState { | ||
editorState: { | ||
valid: { | ||
// Validity for each section in the editor | ||
[key: string]: boolean; | ||
}; | ||
}; | ||
} | ||
|
||
const initialState: MetadataState = { | ||
editorState: { | ||
valid: {}, | ||
}, | ||
}; | ||
|
||
export const getPreloadedState = async ({ | ||
types, | ||
data, | ||
}: WizardServices): Promise<MetadataState> => { | ||
const preloadedState = { ...initialState }; | ||
|
||
return preloadedState; | ||
}; | ||
|
||
export const slice = createSlice({ | ||
name: 'metadata', | ||
initialState, | ||
reducers: { | ||
setValid: (state, action: PayloadAction<{ key: string; valid: boolean }>) => { | ||
const { key, valid } = action.payload; | ||
state.editorState.valid[key] = valid; | ||
}, | ||
setState: (_state, action: PayloadAction<MetadataState>) => { | ||
return action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { reducer } = slice; | ||
export const { setValid, setState } = slice.actions; |
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