forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds initial type service (opensearch-project#1260)
Signed-off-by: Ashwin Pc <[email protected]>
- Loading branch information
Showing
16 changed files
with
396 additions
and
51 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
22 changes: 22 additions & 0 deletions
22
src/plugins/wizard/public/application/utils/state_management/preload.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,22 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { PreloadedState } from '@reduxjs/toolkit'; | ||
import { WizardServices } from '../../..'; | ||
import { getPreloadedState as getPreloadedDatasourceState } from './datasource_slice'; | ||
import { getPreloadedState as getPreloadedVisualizationState } from './visualization_slice'; | ||
import { RootState } from './store'; | ||
|
||
export const getPreloadedState = async ( | ||
services: WizardServices | ||
): Promise<PreloadedState<RootState>> => { | ||
const dataSourceState = await getPreloadedDatasourceState(services); | ||
const visualizationState = await getPreloadedVisualizationState(services); | ||
|
||
return { | ||
dataSource: dataSourceState, | ||
visualization: visualizationState, | ||
}; | ||
}; |
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
39 changes: 39 additions & 0 deletions
39
src/plugins/wizard/public/application/utils/state_management/visualization_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,39 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
import { WizardServices } from '../../../types'; | ||
|
||
interface VisualizationState { | ||
activeVisualization: string | null; | ||
} | ||
|
||
const initialState: VisualizationState = { | ||
activeVisualization: null, | ||
}; | ||
|
||
export const getPreloadedState = async ({ types }: WizardServices): Promise<VisualizationState> => { | ||
const preloadedState = { ...initialState }; | ||
|
||
const defaultVisualization = types.all()[0]; | ||
if (defaultVisualization) { | ||
preloadedState.activeVisualization = defaultVisualization.name; | ||
} | ||
|
||
return preloadedState; | ||
}; | ||
|
||
export const slice = createSlice({ | ||
name: 'visualization', | ||
initialState, | ||
reducers: { | ||
setActiveVisualization: (state, action: PayloadAction<string>) => { | ||
state.activeVisualization = action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { reducer } = slice; | ||
export const { setActiveVisualization } = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export * from './type_service'; |
Oops, something went wrong.