From 45ddea3fcc7cc0dfaa2b8fa2a44cf7dfb5a0614a Mon Sep 17 00:00:00 2001 From: Antonette Caldwell <134739862+nebula-aac@users.noreply.github.com> Date: Sat, 14 Dec 2024 23:23:39 +0000 Subject: [PATCH 1/2] feat: create slices for meshery ui Signed-off-by: Antonette Caldwell <134739862+nebula-aac@users.noreply.github.com> --- package-lock.json | 18 +-- package.json | 3 +- .../slices/anonymousPerfResultsSlice.ts | 48 +++++++ .../slices/anonymousUsageStatsSlice.ts | 38 ++++++ src/redux-toolkit/slices/cSlice.ts | 23 ++++ .../slices/capabilitiesRegistrySlice.ts | 28 ++++ .../slices/catalogVisibilitySlice.ts | 27 ++++ .../slices/connectionMetadataStateSlice.ts | 41 ++++++ .../slices/controllerStateSlice.ts | 27 ++++ src/redux-toolkit/slices/eventsSlice.ts | 23 ++++ .../slices/extensionTypeSlice.ts | 27 ++++ src/redux-toolkit/slices/genSlice.ts | 27 ++++ .../slices/grafanaAPIKeySlice.ts | 27 ++++ .../slices/grafanaBoardSearchSlice.ts | 32 +++++ .../slices/grafanaBoardsSlice.ts | 32 +++++ src/redux-toolkit/slices/grafanaSlice.ts | 27 ++++ src/redux-toolkit/slices/grafanaURLSlice.ts | 27 ++++ src/redux-toolkit/slices/isBetaSlice.ts | 27 ++++ .../slices/isDrawerCollapsedSlice.ts | 27 ++++ src/redux-toolkit/slices/k8sConfigSlice.ts | 56 ++++++++ src/redux-toolkit/slices/keysSlice.ts | 29 +++++ src/redux-toolkit/slices/loadTestPrefSlice.ts | 38 ++++++ src/redux-toolkit/slices/loadTestSlice.ts | 39 ++++++ src/redux-toolkit/slices/meshAdaptersSlice.ts | 31 +++++ .../slices/meshAdapterstsSlice.ts | 31 +++++ src/redux-toolkit/slices/meshNameSlice.ts | 23 ++++ .../slices/meshSyncStateSlice.ts | 32 +++++ .../slices/notificationCenterSlice.ts | 26 ++++ src/redux-toolkit/slices/openEventIdSlice.ts | 23 ++++ .../slices/operatorStateSlice.ts | 32 +++++ src/redux-toolkit/slices/organizationSlice.ts | 29 +++++ src/redux-toolkit/slices/pageSlice.ts | 32 +++++ src/redux-toolkit/slices/pathSlice.ts | 23 ++++ src/redux-toolkit/slices/prometheusSlice.ts | 27 ++++ .../slices/prometheusURLSlice.ts | 27 ++++ src/redux-toolkit/slices/qpsSlice.ts | 23 ++++ src/redux-toolkit/slices/resultSlice.ts | 23 ++++ src/redux-toolkit/slices/resultsSlice.ts | 40 ++++++ .../slices/results_selectionSlice.ts | 43 +++++++ .../slices/selectedAdapterSlice.ts | 27 ++++ .../slices/selectedBoardsConfigsSlice.ts | 50 ++++++++ .../slices/selectedK8sContextsSlice.ts | 28 ++++ .../selectedPrometheusBoardsConfigsSlice.ts | 70 ++++++++++ .../slices/showFullNotificationCenterSlice.ts | 27 ++++ src/redux-toolkit/slices/showProgressSlice.ts | 27 ++++ src/redux-toolkit/slices/startKeySlice.ts | 23 ++++ .../staticPrometheusBoardConfigSlice.ts | 60 +++++++++ src/redux-toolkit/slices/tSlice.ts | 23 ++++ .../slices/telemetryURLsSlice.ts | 30 +++++ src/redux-toolkit/slices/testNameSlice.ts | 27 ++++ src/redux-toolkit/slices/titleSlice.ts | 27 ++++ src/redux-toolkit/slices/tsSlice.ts | 23 ++++ src/redux-toolkit/slices/urlSlice.ts | 23 ++++ src/redux-toolkit/slices/userSlice.ts | 28 ++++ src/redux-toolkit/slices/workspaceSlice.ts | 30 +++++ src/redux-toolkit/store.ts | 120 ++++++++++++++++++ 56 files changed, 1790 insertions(+), 9 deletions(-) create mode 100644 src/redux-toolkit/slices/anonymousPerfResultsSlice.ts create mode 100644 src/redux-toolkit/slices/anonymousUsageStatsSlice.ts create mode 100644 src/redux-toolkit/slices/cSlice.ts create mode 100644 src/redux-toolkit/slices/capabilitiesRegistrySlice.ts create mode 100644 src/redux-toolkit/slices/catalogVisibilitySlice.ts create mode 100644 src/redux-toolkit/slices/connectionMetadataStateSlice.ts create mode 100644 src/redux-toolkit/slices/controllerStateSlice.ts create mode 100644 src/redux-toolkit/slices/eventsSlice.ts create mode 100644 src/redux-toolkit/slices/extensionTypeSlice.ts create mode 100644 src/redux-toolkit/slices/genSlice.ts create mode 100644 src/redux-toolkit/slices/grafanaAPIKeySlice.ts create mode 100644 src/redux-toolkit/slices/grafanaBoardSearchSlice.ts create mode 100644 src/redux-toolkit/slices/grafanaBoardsSlice.ts create mode 100644 src/redux-toolkit/slices/grafanaSlice.ts create mode 100644 src/redux-toolkit/slices/grafanaURLSlice.ts create mode 100644 src/redux-toolkit/slices/isBetaSlice.ts create mode 100644 src/redux-toolkit/slices/isDrawerCollapsedSlice.ts create mode 100644 src/redux-toolkit/slices/k8sConfigSlice.ts create mode 100644 src/redux-toolkit/slices/keysSlice.ts create mode 100644 src/redux-toolkit/slices/loadTestPrefSlice.ts create mode 100644 src/redux-toolkit/slices/loadTestSlice.ts create mode 100644 src/redux-toolkit/slices/meshAdaptersSlice.ts create mode 100644 src/redux-toolkit/slices/meshAdapterstsSlice.ts create mode 100644 src/redux-toolkit/slices/meshNameSlice.ts create mode 100644 src/redux-toolkit/slices/meshSyncStateSlice.ts create mode 100644 src/redux-toolkit/slices/notificationCenterSlice.ts create mode 100644 src/redux-toolkit/slices/openEventIdSlice.ts create mode 100644 src/redux-toolkit/slices/operatorStateSlice.ts create mode 100644 src/redux-toolkit/slices/organizationSlice.ts create mode 100644 src/redux-toolkit/slices/pageSlice.ts create mode 100644 src/redux-toolkit/slices/pathSlice.ts create mode 100644 src/redux-toolkit/slices/prometheusSlice.ts create mode 100644 src/redux-toolkit/slices/prometheusURLSlice.ts create mode 100644 src/redux-toolkit/slices/qpsSlice.ts create mode 100644 src/redux-toolkit/slices/resultSlice.ts create mode 100644 src/redux-toolkit/slices/resultsSlice.ts create mode 100644 src/redux-toolkit/slices/results_selectionSlice.ts create mode 100644 src/redux-toolkit/slices/selectedAdapterSlice.ts create mode 100644 src/redux-toolkit/slices/selectedBoardsConfigsSlice.ts create mode 100644 src/redux-toolkit/slices/selectedK8sContextsSlice.ts create mode 100644 src/redux-toolkit/slices/selectedPrometheusBoardsConfigsSlice.ts create mode 100644 src/redux-toolkit/slices/showFullNotificationCenterSlice.ts create mode 100644 src/redux-toolkit/slices/showProgressSlice.ts create mode 100644 src/redux-toolkit/slices/startKeySlice.ts create mode 100644 src/redux-toolkit/slices/staticPrometheusBoardConfigSlice.ts create mode 100644 src/redux-toolkit/slices/tSlice.ts create mode 100644 src/redux-toolkit/slices/telemetryURLsSlice.ts create mode 100644 src/redux-toolkit/slices/testNameSlice.ts create mode 100644 src/redux-toolkit/slices/titleSlice.ts create mode 100644 src/redux-toolkit/slices/tsSlice.ts create mode 100644 src/redux-toolkit/slices/urlSlice.ts create mode 100644 src/redux-toolkit/slices/userSlice.ts create mode 100644 src/redux-toolkit/slices/workspaceSlice.ts create mode 100644 src/redux-toolkit/store.ts diff --git a/package-lock.json b/package-lock.json index 0034a390..632a5233 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@commitlint/cli": "^17.7.2", "@commitlint/config-conventional": "^17.7.0", "@mui/icons-material": "^5.15.11", - "@reduxjs/toolkit": "^2.2.5", + "@reduxjs/toolkit": "*", "@testing-library/react": "^14.1.2", "@types/jest": "^29.5.11", "@types/lodash": "^4.17.7", @@ -54,6 +54,7 @@ "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", "@mui/material": "^5.15.11", + "@reduxjs/toolkit": "^2.5.0", "@types/mui-datatables": "*", "@xstate/react": "^4.1.1", "lodash": "^4.17.21", @@ -2645,10 +2646,11 @@ "dev": true }, "node_modules/@reduxjs/toolkit": { - "version": "2.2.5", - "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.2.5.tgz", - "integrity": "sha512-aeFA/s5NCG7NoJe/MhmwREJxRkDs0ZaSqt0MxhWUrwCf1UQXpwR87RROJEql0uAkLI6U7snBOYOcKw83ew3FPg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.5.0.tgz", + "integrity": "sha512-awNe2oTodsZ6LmRqmkFhtb/KH03hUhxOamEQy411m3Njj3BbFvoBovxo4Q1cBWnV1ErprVj9MlF0UPXkng0eyg==", "dev": true, + "license": "MIT", "dependencies": { "immer": "^10.0.3", "redux": "^5.0.1", @@ -2656,7 +2658,7 @@ "reselect": "^5.1.0" }, "peerDependencies": { - "react": "^16.9.0 || ^17.0.0 || ^18", + "react": "^16.9.0 || ^17.0.0 || ^18 || ^19", "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" }, "peerDependenciesMeta": { @@ -16064,9 +16066,9 @@ "dev": true }, "@reduxjs/toolkit": { - "version": "2.2.5", - "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.2.5.tgz", - "integrity": "sha512-aeFA/s5NCG7NoJe/MhmwREJxRkDs0ZaSqt0MxhWUrwCf1UQXpwR87RROJEql0uAkLI6U7snBOYOcKw83ew3FPg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.5.0.tgz", + "integrity": "sha512-awNe2oTodsZ6LmRqmkFhtb/KH03hUhxOamEQy411m3Njj3BbFvoBovxo4Q1cBWnV1ErprVj9MlF0UPXkng0eyg==", "dev": true, "requires": { "immer": "^10.0.3", diff --git a/package.json b/package.json index 04cee394..a0a04654 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@commitlint/cli": "^17.7.2", "@commitlint/config-conventional": "^17.7.0", "@mui/icons-material": "^5.15.11", - "@reduxjs/toolkit": "^2.2.5", + "@reduxjs/toolkit": "*", "@testing-library/react": "^14.1.2", "@types/jest": "^29.5.11", "@types/lodash": "^4.17.7", @@ -81,6 +81,7 @@ "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", "@mui/material": "^5.15.11", + "@reduxjs/toolkit": "^2.5.0", "@types/mui-datatables": "*", "@xstate/react": "^4.1.1", "lodash": "^4.17.21", diff --git a/src/redux-toolkit/slices/anonymousPerfResultsSlice.ts b/src/redux-toolkit/slices/anonymousPerfResultsSlice.ts new file mode 100644 index 00000000..7712d828 --- /dev/null +++ b/src/redux-toolkit/slices/anonymousPerfResultsSlice.ts @@ -0,0 +1,48 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface AnonymousPerfResultsState { + [key: string]: any; +} +// Initial state +const initialState: AnonymousPerfResultsState = true; +// Slice +const anonymousPerfResultsSlice = createSlice({ + name: 'anonymousPerfResults', + initialState, + reducers: { + setAnonymousPerfResults: (state, action: PayloadAction) => { + return action.payload; + }, + updateResultsSelection: (state: AnonymousPerfResultsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_RESULTS_SELECTION + return state; + }, + clearResultsSelection: (state: AnonymousPerfResultsState, action: PayloadAction) => { + // TODO: Implement reducer logic for CLEAR_RESULTS_SELECTION + return state; + }, + updateAnonymousUsageStats: (state: AnonymousPerfResultsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_ANONYMOUS_USAGE_STATS + return state; + }, + updateAnonymousPerformanceResults: ( + state: AnonymousPerfResultsState, + action: PayloadAction + ) => { + // TODO: Implement reducer logic for UPDATE_ANONYMOUS_PERFORMANCE_RESULTS + return state; + } + } +}); +// Actions +export const { + setAnonymousPerfResults, + updateResultsSelection, + clearResultsSelection, + updateAnonymousUsageStats, + updateAnonymousPerformanceResults +} = anonymousPerfResultsSlice.actions; +// Selectors +export const selectAnonymousPerfResults = (state: MesheryRootState) => state.anonymousPerfResults; +export default anonymousPerfResultsSlice.reducer; diff --git a/src/redux-toolkit/slices/anonymousUsageStatsSlice.ts b/src/redux-toolkit/slices/anonymousUsageStatsSlice.ts new file mode 100644 index 00000000..2ea1a8f3 --- /dev/null +++ b/src/redux-toolkit/slices/anonymousUsageStatsSlice.ts @@ -0,0 +1,38 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface AnonymousUsageStatsState { + [key: string]: any; +} +// Initial state +const initialState: AnonymousUsageStatsState = true; +// Slice +const anonymousUsageStatsSlice = createSlice({ + name: 'anonymousUsageStats', + initialState, + reducers: { + setAnonymousUsageStats: (state, action: PayloadAction) => { + return action.payload; + }, + updateAnonymousUsageStats: (state: AnonymousUsageStatsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_ANONYMOUS_USAGE_STATS + return state; + }, + updateAnonymousPerformanceResults: ( + state: AnonymousUsageStatsState, + action: PayloadAction + ) => { + // TODO: Implement reducer logic for UPDATE_ANONYMOUS_PERFORMANCE_RESULTS + return state; + } + } +}); +// Actions +export const { + setAnonymousUsageStats, + updateAnonymousUsageStats, + updateAnonymousPerformanceResults +} = anonymousUsageStatsSlice.actions; +// Selectors +export const selectAnonymousUsageStats = (state: MesheryRootState) => state.anonymousUsageStats; +export default anonymousUsageStatsSlice.reducer; diff --git a/src/redux-toolkit/slices/cSlice.ts b/src/redux-toolkit/slices/cSlice.ts new file mode 100644 index 00000000..c0a994ba --- /dev/null +++ b/src/redux-toolkit/slices/cSlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface CState { + [key: string]: any; +} +// Initial state +const initialState: CState = 0; +// Slice +const cSlice = createSlice({ + name: 'c', + initialState, + reducers: { + setC: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setC } = cSlice.actions; +// Selectors +export const selectC = (state: MesheryRootState) => state.c; +export default cSlice.reducer; diff --git a/src/redux-toolkit/slices/capabilitiesRegistrySlice.ts b/src/redux-toolkit/slices/capabilitiesRegistrySlice.ts new file mode 100644 index 00000000..de52e68a --- /dev/null +++ b/src/redux-toolkit/slices/capabilitiesRegistrySlice.ts @@ -0,0 +1,28 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface CapabilitiesRegistryState { + [key: string]: any; +} +// Initial state +const initialState: CapabilitiesRegistryState = null; +// Slice +const capabilitiesRegistrySlice = createSlice({ + name: 'capabilitiesRegistry', + initialState, + reducers: { + setCapabilitiesRegistry: (state, action: PayloadAction) => { + return action.payload; + }, + updateCapabilityRegistry: (state: CapabilitiesRegistryState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_CAPABILITY_REGISTRY + return state; + } + } +}); +// Actions +export const { setCapabilitiesRegistry, updateCapabilityRegistry } = + capabilitiesRegistrySlice.actions; +// Selectors +export const selectCapabilitiesRegistry = (state: MesheryRootState) => state.capabilitiesRegistry; +export default capabilitiesRegistrySlice.reducer; diff --git a/src/redux-toolkit/slices/catalogVisibilitySlice.ts b/src/redux-toolkit/slices/catalogVisibilitySlice.ts new file mode 100644 index 00000000..39c0fd71 --- /dev/null +++ b/src/redux-toolkit/slices/catalogVisibilitySlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface CatalogVisibilityState { + [key: string]: any; +} +// Initial state +const initialState: CatalogVisibilityState = true; +// Slice +const catalogVisibilitySlice = createSlice({ + name: 'catalogVisibility', + initialState, + reducers: { + setCatalogVisibility: (state, action: PayloadAction) => { + return action.payload; + }, + setCatalogContent: (state: CatalogVisibilityState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_CATALOG_CONTENT + return state; + } + } +}); +// Actions +export const { setCatalogVisibility, setCatalogContent } = catalogVisibilitySlice.actions; +// Selectors +export const selectCatalogVisibility = (state: MesheryRootState) => state.catalogVisibility; +export default catalogVisibilitySlice.reducer; diff --git a/src/redux-toolkit/slices/connectionMetadataStateSlice.ts b/src/redux-toolkit/slices/connectionMetadataStateSlice.ts new file mode 100644 index 00000000..07d0c8d5 --- /dev/null +++ b/src/redux-toolkit/slices/connectionMetadataStateSlice.ts @@ -0,0 +1,41 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface ConnectionMetadataStateState { + [key: string]: any; +} +// Initial state +const initialState: ConnectionMetadataStateState = null; +// Slice +const connectionMetadataStateSlice = createSlice({ + name: 'connectionMetadataState', + initialState, + reducers: { + setConnectionMetadataState: (state, action: PayloadAction) => { + return action.payload; + }, + updateLoadTestData: (state: ConnectionMetadataStateState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_LOAD_TEST_DATA + return state; + }, + setControllerState: (state: ConnectionMetadataStateState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_CONTROLLER_STATE + return state; + }, + setConnectionMetadata: (state: ConnectionMetadataStateState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_CONNECTION_METADATA + return state; + } + } +}); +// Actions +export const { + setConnectionMetadataState, + updateLoadTestData, + setControllerState, + setConnectionMetadata +} = connectionMetadataStateSlice.actions; +// Selectors +export const selectConnectionMetadataState = (state: MesheryRootState) => + state.connectionMetadataState; +export default connectionMetadataStateSlice.reducer; diff --git a/src/redux-toolkit/slices/controllerStateSlice.ts b/src/redux-toolkit/slices/controllerStateSlice.ts new file mode 100644 index 00000000..45b8eae1 --- /dev/null +++ b/src/redux-toolkit/slices/controllerStateSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface ControllerStateState { + [key: string]: any; +} +// Initial state +const initialState: ControllerStateState = null; +// Slice +const controllerStateSlice = createSlice({ + name: 'controllerState', + initialState, + reducers: { + setControllerState: (state, action: PayloadAction) => { + return action.payload; + }, + setControllerState: (state: ControllerStateState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_CONTROLLER_STATE + return state; + } + } +}); +// Actions +export const { setControllerState, setControllerState1 } = controllerStateSlice.actions; +// Selectors +export const selectControllerState = (state: MesheryRootState) => state.controllerState; +export default controllerStateSlice.reducer; diff --git a/src/redux-toolkit/slices/eventsSlice.ts b/src/redux-toolkit/slices/eventsSlice.ts new file mode 100644 index 00000000..56df6e2d --- /dev/null +++ b/src/redux-toolkit/slices/eventsSlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface EventsState { + [key: string]: any; +} +// Initial state +const initialState: EventsState = []; +// Slice +const eventsSlice = createSlice({ + name: 'events', + initialState, + reducers: { + setEvents: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setEvents } = eventsSlice.actions; +// Selectors +export const selectEvents = (state: MesheryRootState) => state.events; +export default eventsSlice.reducer; diff --git a/src/redux-toolkit/slices/extensionTypeSlice.ts b/src/redux-toolkit/slices/extensionTypeSlice.ts new file mode 100644 index 00000000..d805493e --- /dev/null +++ b/src/redux-toolkit/slices/extensionTypeSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface ExtensionTypeState { + [key: string]: any; +} +// Initial state +const initialState: ExtensionTypeState = ''; +// Slice +const extensionTypeSlice = createSlice({ + name: 'extensionType', + initialState, + reducers: { + setExtensionType: (state, action: PayloadAction) => { + return action.payload; + }, + updateExtensionType: (state: ExtensionTypeState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_EXTENSION_TYPE + return state; + } + } +}); +// Actions +export const { setExtensionType, updateExtensionType } = extensionTypeSlice.actions; +// Selectors +export const selectExtensionType = (state: MesheryRootState) => state.extensionType; +export default extensionTypeSlice.reducer; diff --git a/src/redux-toolkit/slices/genSlice.ts b/src/redux-toolkit/slices/genSlice.ts new file mode 100644 index 00000000..1d096814 --- /dev/null +++ b/src/redux-toolkit/slices/genSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface GenState { + [key: string]: any; +} +// Initial state +const initialState: GenState = 'fortio'; +// Slice +const genSlice = createSlice({ + name: 'gen', + initialState, + reducers: { + setGen: (state, action: PayloadAction) => { + return action.payload; + }, + updateLoadGenConfig: (state: GenState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_LOAD_GEN_CONFIG + return state; + } + } +}); +// Actions +export const { setGen, updateLoadGenConfig } = genSlice.actions; +// Selectors +export const selectGen = (state: MesheryRootState) => state.gen; +export default genSlice.reducer; diff --git a/src/redux-toolkit/slices/grafanaAPIKeySlice.ts b/src/redux-toolkit/slices/grafanaAPIKeySlice.ts new file mode 100644 index 00000000..a74bcb41 --- /dev/null +++ b/src/redux-toolkit/slices/grafanaAPIKeySlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface GrafanaAPIKeyState { + [key: string]: any; +} +// Initial state +const initialState: GrafanaAPIKeyState = ''; +// Slice +const grafanaAPIKeySlice = createSlice({ + name: 'grafanaAPIKey', + initialState, + reducers: { + setGrafanaAPIKey: (state, action: PayloadAction) => { + return action.payload; + }, + updateGrafanaConfig: (state: GrafanaAPIKeyState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_GRAFANA_CONFIG + return state; + } + } +}); +// Actions +export const { setGrafanaAPIKey, updateGrafanaConfig } = grafanaAPIKeySlice.actions; +// Selectors +export const selectGrafanaAPIKey = (state: MesheryRootState) => state.grafanaAPIKey; +export default grafanaAPIKeySlice.reducer; diff --git a/src/redux-toolkit/slices/grafanaBoardSearchSlice.ts b/src/redux-toolkit/slices/grafanaBoardSearchSlice.ts new file mode 100644 index 00000000..c1c34e88 --- /dev/null +++ b/src/redux-toolkit/slices/grafanaBoardSearchSlice.ts @@ -0,0 +1,32 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface GrafanaBoardSearchState { + [key: string]: any; +} +// Initial state +const initialState: GrafanaBoardSearchState = ''; +// Slice +const grafanaBoardSearchSlice = createSlice({ + name: 'grafanaBoardSearch', + initialState, + reducers: { + setGrafanaBoardSearch: (state, action: PayloadAction) => { + return action.payload; + }, + updateGrafanaConfig: (state: GrafanaBoardSearchState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_GRAFANA_CONFIG + return state; + }, + updateStaticBoardConfig: (state: GrafanaBoardSearchState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_STATIC_BOARD_CONFIG + return state; + } + } +}); +// Actions +export const { setGrafanaBoardSearch, updateGrafanaConfig, updateStaticBoardConfig } = + grafanaBoardSearchSlice.actions; +// Selectors +export const selectGrafanaBoardSearch = (state: MesheryRootState) => state.grafanaBoardSearch; +export default grafanaBoardSearchSlice.reducer; diff --git a/src/redux-toolkit/slices/grafanaBoardsSlice.ts b/src/redux-toolkit/slices/grafanaBoardsSlice.ts new file mode 100644 index 00000000..9ec9e85b --- /dev/null +++ b/src/redux-toolkit/slices/grafanaBoardsSlice.ts @@ -0,0 +1,32 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface GrafanaBoardsState { + [key: string]: any; +} +// Initial state +const initialState: GrafanaBoardsState = []; +// Slice +const grafanaBoardsSlice = createSlice({ + name: 'grafanaBoards', + initialState, + reducers: { + setGrafanaBoards: (state, action: PayloadAction) => { + return action.payload; + }, + updateGrafanaConfig: (state: GrafanaBoardsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_GRAFANA_CONFIG + return state; + }, + updateStaticBoardConfig: (state: GrafanaBoardsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_STATIC_BOARD_CONFIG + return state; + } + } +}); +// Actions +export const { setGrafanaBoards, updateGrafanaConfig, updateStaticBoardConfig } = + grafanaBoardsSlice.actions; +// Selectors +export const selectGrafanaBoards = (state: MesheryRootState) => state.grafanaBoards; +export default grafanaBoardsSlice.reducer; diff --git a/src/redux-toolkit/slices/grafanaSlice.ts b/src/redux-toolkit/slices/grafanaSlice.ts new file mode 100644 index 00000000..28ebedd0 --- /dev/null +++ b/src/redux-toolkit/slices/grafanaSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface GrafanaState { + [key: string]: any; +} +// Initial state +const initialState: GrafanaState = []; +// Slice +const grafanaSlice = createSlice({ + name: 'grafana', + initialState, + reducers: { + setGrafana: (state, action: PayloadAction) => { + return action.payload; + }, + updateGrafanaConfig: (state: GrafanaState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_GRAFANA_CONFIG + return state; + } + } +}); +// Actions +export const { setGrafana, updateGrafanaConfig } = grafanaSlice.actions; +// Selectors +export const selectGrafana = (state: MesheryRootState) => state.grafana; +export default grafanaSlice.reducer; diff --git a/src/redux-toolkit/slices/grafanaURLSlice.ts b/src/redux-toolkit/slices/grafanaURLSlice.ts new file mode 100644 index 00000000..aba5e4b2 --- /dev/null +++ b/src/redux-toolkit/slices/grafanaURLSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface GrafanaURLState { + [key: string]: any; +} +// Initial state +const initialState: GrafanaURLState = ''; +// Slice +const grafanaURLSlice = createSlice({ + name: 'grafanaURL', + initialState, + reducers: { + setGrafanaURL: (state, action: PayloadAction) => { + return action.payload; + }, + updateGrafanaConfig: (state: GrafanaURLState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_GRAFANA_CONFIG + return state; + } + } +}); +// Actions +export const { setGrafanaURL, updateGrafanaConfig } = grafanaURLSlice.actions; +// Selectors +export const selectGrafanaURL = (state: MesheryRootState) => state.grafanaURL; +export default grafanaURLSlice.reducer; diff --git a/src/redux-toolkit/slices/isBetaSlice.ts b/src/redux-toolkit/slices/isBetaSlice.ts new file mode 100644 index 00000000..19b26da4 --- /dev/null +++ b/src/redux-toolkit/slices/isBetaSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface IsBetaState { + [key: string]: any; +} +// Initial state +const initialState: IsBetaState = false; +// Slice +const isBetaSlice = createSlice({ + name: 'isBeta', + initialState, + reducers: { + setIsBeta: (state, action: PayloadAction) => { + return action.payload; + }, + updateBetaBadge: (state: IsBetaState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_BETA_BADGE + return state; + } + } +}); +// Actions +export const { setIsBeta, updateBetaBadge } = isBetaSlice.actions; +// Selectors +export const selectIsBeta = (state: MesheryRootState) => state.isBeta; +export default isBetaSlice.reducer; diff --git a/src/redux-toolkit/slices/isDrawerCollapsedSlice.ts b/src/redux-toolkit/slices/isDrawerCollapsedSlice.ts new file mode 100644 index 00000000..8fcad7e6 --- /dev/null +++ b/src/redux-toolkit/slices/isDrawerCollapsedSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface IsDrawerCollapsedState { + [key: string]: any; +} +// Initial state +const initialState: IsDrawerCollapsedState = false; +// Slice +const isDrawerCollapsedSlice = createSlice({ + name: 'isDrawerCollapsed', + initialState, + reducers: { + setIsDrawerCollapsed: (state, action: PayloadAction) => { + return action.payload; + }, + toogleDrawer: (state: IsDrawerCollapsedState, action: PayloadAction) => { + // TODO: Implement reducer logic for TOOGLE_DRAWER + return state; + } + } +}); +// Actions +export const { setIsDrawerCollapsed, toogleDrawer } = isDrawerCollapsedSlice.actions; +// Selectors +export const selectIsDrawerCollapsed = (state: MesheryRootState) => state.isDrawerCollapsed; +export default isDrawerCollapsedSlice.reducer; diff --git a/src/redux-toolkit/slices/k8sConfigSlice.ts b/src/redux-toolkit/slices/k8sConfigSlice.ts new file mode 100644 index 00000000..be4f1421 --- /dev/null +++ b/src/redux-toolkit/slices/k8sConfigSlice.ts @@ -0,0 +1,56 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; + +export interface K8sConfigState { + [key: string]: any; +} + +const initialState: K8sConfigState = []; + +const k8sConfigSlice = createSlice({ + name: 'k8sConfig', + initialState, + reducers: { + setK8sConfig: (state, action: PayloadAction) => { + return action.payload; + }, + updateClusterConfig: (state: K8sConfigState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_CLUSTER_CONFIG + return state; + }, + setK8sContext: (state: K8sConfigState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_K8S_CONTEXT + return state; + }, + updateGrafanaConfig: (state: K8sConfigState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_GRAFANA_CONFIG + return state; + }, + updatePrometheusConfig: (state: K8sConfigState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_PROMETHEUS_CONFIG + return state; + }, + updateStaticBoardConfig: (state: K8sConfigState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_STATIC_BOARD_CONFIG + return state; + }, + updateLoadGenConfig: (state: K8sConfigState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_LOAD_GEN_CONFIG + return state; + } + } +}); + +export const { + setK8sConfig, + updateClusterConfig, + setK8sContext, + updateGrafanaConfig, + updatePrometheusConfig, + updateStaticBoardConfig, + updateLoadGenConfig +} = k8sConfigSlice.actions; + +// Selectors +export const selectK8sConfig = (state: MesheryRootState) => state.k8sConfig; +export default k8sConfigSlice.reducer; diff --git a/src/redux-toolkit/slices/keysSlice.ts b/src/redux-toolkit/slices/keysSlice.ts new file mode 100644 index 00000000..817c852b --- /dev/null +++ b/src/redux-toolkit/slices/keysSlice.ts @@ -0,0 +1,29 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface KeysState { + [key: string]: any; +} +// Initial state +const initialState: KeysState = null; +// Slice +const keysSlice = createSlice({ + name: 'keys', + initialState, + reducers: { + /* + setKeys: (state, action: PayloadAction) => { + return action.payload; + }, + */ + setKeys: (state: KeysState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_KEYS + return state; + } + } +}); +// Actions +export const { setKeys } = keysSlice.actions; +// Selectors +export const selectKeys = (state: MesheryRootState) => state.keys; +export default keysSlice.reducer; diff --git a/src/redux-toolkit/slices/loadTestPrefSlice.ts b/src/redux-toolkit/slices/loadTestPrefSlice.ts new file mode 100644 index 00000000..f416b35e --- /dev/null +++ b/src/redux-toolkit/slices/loadTestPrefSlice.ts @@ -0,0 +1,38 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface LoadTestPrefState { + [key: string]: any; +} +// Initial state +const initialState: LoadTestPrefState = { + qps: 0, + t: '30s', + c: 0, + gen: 'fortio', + ts: new Date() +}; +// Slice +const loadTestPrefSlice = createSlice({ + name: 'loadTestPref', + initialState, + reducers: { + setLoadTestPref: (state, action: PayloadAction) => { + return action.payload; + }, + updateLoadTestData: (state: LoadTestPrefState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_LOAD_TEST_DATA + return state; + }, + updateLoadGenConfig: (state: LoadTestPrefState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_LOAD_GEN_CONFIG + return state; + } + } +}); +// Actions +export const { setLoadTestPref, updateLoadTestData, updateLoadGenConfig } = + loadTestPrefSlice.actions; +// Selectors +export const selectLoadTestPref = (state: MesheryRootState) => state.loadTestPref; +export default loadTestPrefSlice.reducer; diff --git a/src/redux-toolkit/slices/loadTestSlice.ts b/src/redux-toolkit/slices/loadTestSlice.ts new file mode 100644 index 00000000..adcb0e80 --- /dev/null +++ b/src/redux-toolkit/slices/loadTestSlice.ts @@ -0,0 +1,39 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface LoadTestState { + [key: string]: any; +} +// Initial state +const initialState: LoadTestState = { + testName: '', + meshName: '', + url: '', + qps: 0, + c: 0, + t: '30s', + result: {} +}; +// Slice +const loadTestSlice = createSlice({ + name: 'loadTest', + initialState, + reducers: { + setLoadTest: (state, action: PayloadAction) => { + return action.payload; + }, + updateLoadTestData: (state: LoadTestState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_LOAD_TEST_DATA + return state; + }, + updateLoadGenConfig: (state: LoadTestState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_LOAD_GEN_CONFIG + return state; + } + } +}); +// Actions +export const { setLoadTest, updateLoadTestData, updateLoadGenConfig } = loadTestSlice.actions; +// Selectors +export const selectLoadTest = (state: MesheryRootState) => state.loadTest; +export default loadTestSlice.reducer; diff --git a/src/redux-toolkit/slices/meshAdaptersSlice.ts b/src/redux-toolkit/slices/meshAdaptersSlice.ts new file mode 100644 index 00000000..8125b1c9 --- /dev/null +++ b/src/redux-toolkit/slices/meshAdaptersSlice.ts @@ -0,0 +1,31 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface MeshAdaptersState { + [key: string]: any; +} +// Initial state +const initialState: MeshAdaptersState = []; +// Slice +const meshAdaptersSlice = createSlice({ + name: 'meshAdapters', + initialState, + reducers: { + setMeshAdapters: (state, action: PayloadAction) => { + return action.payload; + }, + updateAdaptersInfo: (state: MeshAdaptersState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_ADAPTERS_INFO + return state; + }, + setAdapter: (state: MeshAdaptersState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_ADAPTER + return state; + } + } +}); +// Actions +export const { setMeshAdapters, updateAdaptersInfo, setAdapter } = meshAdaptersSlice.actions; +// Selectors +export const selectMeshAdapters = (state: MesheryRootState) => state.meshAdapters; +export default meshAdaptersSlice.reducer; diff --git a/src/redux-toolkit/slices/meshAdapterstsSlice.ts b/src/redux-toolkit/slices/meshAdapterstsSlice.ts new file mode 100644 index 00000000..b1bab927 --- /dev/null +++ b/src/redux-toolkit/slices/meshAdapterstsSlice.ts @@ -0,0 +1,31 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface MeshAdapterstsState { + [key: string]: any; +} +// Initial state +const initialState: MeshAdapterstsState = new Date(); +// Slice +const meshAdapterstsSlice = createSlice({ + name: 'meshAdaptersts', + initialState, + reducers: { + setMeshAdaptersts: (state, action: PayloadAction) => { + return action.payload; + }, + updateAdaptersInfo: (state: MeshAdapterstsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_ADAPTERS_INFO + return state; + }, + setAdapter: (state: MeshAdapterstsState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_ADAPTER + return state; + } + } +}); +// Actions +export const { setMeshAdaptersts, updateAdaptersInfo, setAdapter } = meshAdapterstsSlice.actions; +// Selectors +export const selectMeshAdaptersts = (state: MesheryRootState) => state.meshAdaptersts; +export default meshAdapterstsSlice.reducer; diff --git a/src/redux-toolkit/slices/meshNameSlice.ts b/src/redux-toolkit/slices/meshNameSlice.ts new file mode 100644 index 00000000..c257b151 --- /dev/null +++ b/src/redux-toolkit/slices/meshNameSlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface MeshNameState { + [key: string]: any; +} +// Initial state +const initialState: MeshNameState = ''; +// Slice +const meshNameSlice = createSlice({ + name: 'meshName', + initialState, + reducers: { + setMeshName: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setMeshName } = meshNameSlice.actions; +// Selectors +export const selectMeshName = (state: MesheryRootState) => state.meshName; +export default meshNameSlice.reducer; diff --git a/src/redux-toolkit/slices/meshSyncStateSlice.ts b/src/redux-toolkit/slices/meshSyncStateSlice.ts new file mode 100644 index 00000000..7fe44da1 --- /dev/null +++ b/src/redux-toolkit/slices/meshSyncStateSlice.ts @@ -0,0 +1,32 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface MeshSyncStateState { + [key: string]: any; +} +// Initial state +const initialState: MeshSyncStateState = null; +// Slice +const meshSyncStateSlice = createSlice({ + name: 'meshSyncState', + initialState, + reducers: { + setMeshSyncState: (state, action: PayloadAction) => { + return action.payload; + }, + setControllerState: (state: MeshSyncStateState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_CONTROLLER_STATE + return state; + }, + setMeshsyncSubscription: (state: MeshSyncStateState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_MESHSYNC_SUBSCRIPTION + return state; + } + } +}); +// Actions +export const { setMeshSyncState, setControllerState, setMeshsyncSubscription } = + meshSyncStateSlice.actions; +// Selectors +export const selectMeshSyncState = (state: MesheryRootState) => state.meshSyncState; +export default meshSyncStateSlice.reducer; diff --git a/src/redux-toolkit/slices/notificationCenterSlice.ts b/src/redux-toolkit/slices/notificationCenterSlice.ts new file mode 100644 index 00000000..efe84c7b --- /dev/null +++ b/src/redux-toolkit/slices/notificationCenterSlice.ts @@ -0,0 +1,26 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface NotificationCenterState { + [key: string]: any; +} +// Initial state +const initialState: NotificationCenterState = { + openEventId: null, + showFullNotificationCenter: false +}; +// Slice +const notificationCenterSlice = createSlice({ + name: 'notificationCenter', + initialState, + reducers: { + setNotificationCenter: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setNotificationCenter } = notificationCenterSlice.actions; +// Selectors +export const selectNotificationCenter = (state: MesheryRootState) => state.notificationCenter; +export default notificationCenterSlice.reducer; diff --git a/src/redux-toolkit/slices/openEventIdSlice.ts b/src/redux-toolkit/slices/openEventIdSlice.ts new file mode 100644 index 00000000..889de010 --- /dev/null +++ b/src/redux-toolkit/slices/openEventIdSlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface OpenEventIdState { + [key: string]: any; +} +// Initial state +const initialState: OpenEventIdState = null; +// Slice +const openEventIdSlice = createSlice({ + name: 'openEventId', + initialState, + reducers: { + setOpenEventId: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setOpenEventId } = openEventIdSlice.actions; +// Selectors +export const selectOpenEventId = (state: MesheryRootState) => state.openEventId; +export default openEventIdSlice.reducer; diff --git a/src/redux-toolkit/slices/operatorStateSlice.ts b/src/redux-toolkit/slices/operatorStateSlice.ts new file mode 100644 index 00000000..6efae94f --- /dev/null +++ b/src/redux-toolkit/slices/operatorStateSlice.ts @@ -0,0 +1,32 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface OperatorStateState { + [key: string]: any; +} +// Initial state +const initialState: OperatorStateState = null; +// Slice +const operatorStateSlice = createSlice({ + name: 'operatorState', + initialState, + reducers: { + setOperatorState: (state, action: PayloadAction) => { + return action.payload; + }, + setOperatorSubscription: (state: OperatorStateState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_OPERATOR_SUBSCRIPTION + return state; + }, + setControllerState: (state: OperatorStateState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_CONTROLLER_STATE + return state; + } + } +}); +// Actions +export const { setOperatorState, setOperatorSubscription, setControllerState } = + operatorStateSlice.actions; +// Selectors +export const selectOperatorState = (state: MesheryRootState) => state.operatorState; +export default operatorStateSlice.reducer; diff --git a/src/redux-toolkit/slices/organizationSlice.ts b/src/redux-toolkit/slices/organizationSlice.ts new file mode 100644 index 00000000..cb250c2a --- /dev/null +++ b/src/redux-toolkit/slices/organizationSlice.ts @@ -0,0 +1,29 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface OrganizationState { + [key: string]: any; +} +// Initial state +const initialState: OrganizationState = null; +// Slice +const organizationSlice = createSlice({ + name: 'organization', + initialState, + reducers: { + /* + setOrganization: (state, action: PayloadAction) => { + return action.payload; + }, + */ + setOrganization: (state: OrganizationState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_ORGANIZATION + return state; + } + } +}); +// Actions +export const { setOrganization } = organizationSlice.actions; +// Selectors +export const selectOrganization = (state: MesheryRootState) => state.organization; +export default organizationSlice.reducer; diff --git a/src/redux-toolkit/slices/pageSlice.ts b/src/redux-toolkit/slices/pageSlice.ts new file mode 100644 index 00000000..3217282e --- /dev/null +++ b/src/redux-toolkit/slices/pageSlice.ts @@ -0,0 +1,32 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; + +export interface PageState { + [key: string]: any; +} + +const initialState: PageState = { + path: '', + title: '', + isBeta: false +}; + +const pageSlice = createSlice({ + name: 'page', + initialState, + reducers: { + setPage: (state, action: PayloadAction) => { + return action.payload; + }, + updatePage: (state: PageState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_PAGE + return state; + } + } +}); + +export const { setPage, updatePage } = pageSlice.actions; + +// Selectors +export const selectPage = (state: MesheryRootState) => state.page; +export default pageSlice.reducer; diff --git a/src/redux-toolkit/slices/pathSlice.ts b/src/redux-toolkit/slices/pathSlice.ts new file mode 100644 index 00000000..4f1b7ed8 --- /dev/null +++ b/src/redux-toolkit/slices/pathSlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface PathState { + [key: string]: any; +} +// Initial state +const initialState: PathState = ''; +// Slice +const pathSlice = createSlice({ + name: 'path', + initialState, + reducers: { + setPath: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setPath } = pathSlice.actions; +// Selectors +export const selectPath = (state: MesheryRootState) => state.path; +export default pathSlice.reducer; diff --git a/src/redux-toolkit/slices/prometheusSlice.ts b/src/redux-toolkit/slices/prometheusSlice.ts new file mode 100644 index 00000000..c0c3d93f --- /dev/null +++ b/src/redux-toolkit/slices/prometheusSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface PrometheusState { + [key: string]: any; +} +// Initial state +const initialState: PrometheusState = []; +// Slice +const prometheusSlice = createSlice({ + name: 'prometheus', + initialState, + reducers: { + setPrometheus: (state, action: PayloadAction) => { + return action.payload; + }, + updatePrometheusConfig: (state: PrometheusState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_PROMETHEUS_CONFIG + return state; + } + } +}); +// Actions +export const { setPrometheus, updatePrometheusConfig } = prometheusSlice.actions; +// Selectors +export const selectPrometheus = (state: MesheryRootState) => state.prometheus; +export default prometheusSlice.reducer; diff --git a/src/redux-toolkit/slices/prometheusURLSlice.ts b/src/redux-toolkit/slices/prometheusURLSlice.ts new file mode 100644 index 00000000..b4980001 --- /dev/null +++ b/src/redux-toolkit/slices/prometheusURLSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface PrometheusURLState { + [key: string]: any; +} +// Initial state +const initialState: PrometheusURLState = ''; +// Slice +const prometheusURLSlice = createSlice({ + name: 'prometheusURL', + initialState, + reducers: { + setPrometheusURL: (state, action: PayloadAction) => { + return action.payload; + }, + updatePrometheusConfig: (state: PrometheusURLState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_PROMETHEUS_CONFIG + return state; + } + } +}); +// Actions +export const { setPrometheusURL, updatePrometheusConfig } = prometheusURLSlice.actions; +// Selectors +export const selectPrometheusURL = (state: MesheryRootState) => state.prometheusURL; +export default prometheusURLSlice.reducer; diff --git a/src/redux-toolkit/slices/qpsSlice.ts b/src/redux-toolkit/slices/qpsSlice.ts new file mode 100644 index 00000000..2a0fd8a8 --- /dev/null +++ b/src/redux-toolkit/slices/qpsSlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface QpsState { + [key: string]: any; +} +// Initial state +const initialState: QpsState = 0; +// Slice +const qpsSlice = createSlice({ + name: 'qps', + initialState, + reducers: { + setQps: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setQps } = qpsSlice.actions; +// Selectors +export const selectQps = (state: MesheryRootState) => state.qps; +export default qpsSlice.reducer; diff --git a/src/redux-toolkit/slices/resultSlice.ts b/src/redux-toolkit/slices/resultSlice.ts new file mode 100644 index 00000000..8af67ea0 --- /dev/null +++ b/src/redux-toolkit/slices/resultSlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface ResultState { + [key: string]: any; +} +// Initial state +const initialState: ResultState = {}; +// Slice +const resultSlice = createSlice({ + name: 'result', + initialState, + reducers: { + setResult: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setResult } = resultSlice.actions; +// Selectors +export const selectResult = (state: MesheryRootState) => state.result; +export default resultSlice.reducer; diff --git a/src/redux-toolkit/slices/resultsSlice.ts b/src/redux-toolkit/slices/resultsSlice.ts new file mode 100644 index 00000000..5923e5cc --- /dev/null +++ b/src/redux-toolkit/slices/resultsSlice.ts @@ -0,0 +1,40 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface ResultsState { + [key: string]: any; +} +// Initial state +const initialState: ResultsState = []; +// Slice +const resultsSlice = createSlice({ + name: 'results', + initialState, + reducers: { + setResults: (state, action: PayloadAction) => { + return action.payload; + }, + updateResultsSelection: (state: ResultsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_RESULTS_SELECTION + return state; + }, + clearResultsSelection: (state: ResultsState, action: PayloadAction) => { + // TODO: Implement reducer logic for CLEAR_RESULTS_SELECTION + return state; + }, + updateAnonymousPerformanceResults: (state: ResultsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_ANONYMOUS_PERFORMANCE_RESULTS + return state; + } + } +}); +// Actions +export const { + setResults, + updateResultsSelection, + clearResultsSelection, + updateAnonymousPerformanceResults +} = resultsSlice.actions; +// Selectors +export const selectResults = (state: MesheryRootState) => state.results; +export default resultsSlice.reducer; diff --git a/src/redux-toolkit/slices/results_selectionSlice.ts b/src/redux-toolkit/slices/results_selectionSlice.ts new file mode 100644 index 00000000..79f50012 --- /dev/null +++ b/src/redux-toolkit/slices/results_selectionSlice.ts @@ -0,0 +1,43 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface Results_selectionState { + [key: string]: any; +} +// Initial state +const initialState: Results_selectionState = {}; +// Slice +const results_selectionSlice = createSlice({ + name: 'results_selection', + initialState, + reducers: { + setResults_selection: (state, action: PayloadAction) => { + return action.payload; + }, + updateResultsSelection: (state: Results_selectionState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_RESULTS_SELECTION + return state; + }, + clearResultsSelection: (state: Results_selectionState, action: PayloadAction) => { + // TODO: Implement reducer logic for CLEAR_RESULTS_SELECTION + return state; + }, + updateAnonymousPerformanceResults: ( + state: Results_selectionState, + action: PayloadAction + ) => { + // TODO: Implement reducer logic for UPDATE_ANONYMOUS_PERFORMANCE_RESULTS + return state; + } + } +}); +// Actions +export const { + setResults_selection, + updateResultsSelection, + clearResultsSelection, + updateAnonymousPerformanceResults +} = results_selectionSlice.actions; +// Selectors +export const selectResults_selection = (state: MesheryRootState) => state.results_selection; +export default results_selectionSlice.reducer; diff --git a/src/redux-toolkit/slices/selectedAdapterSlice.ts b/src/redux-toolkit/slices/selectedAdapterSlice.ts new file mode 100644 index 00000000..ffe53d9f --- /dev/null +++ b/src/redux-toolkit/slices/selectedAdapterSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface SelectedAdapterState { + [key: string]: any; +} +// Initial state +const initialState: SelectedAdapterState = ''; +// Slice +const selectedAdapterSlice = createSlice({ + name: 'selectedAdapter', + initialState, + reducers: { + setSelectedAdapter: (state, action: PayloadAction) => { + return action.payload; + }, + setAdapter: (state: SelectedAdapterState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_ADAPTER + return state; + } + } +}); +// Actions +export const { setSelectedAdapter, setAdapter } = selectedAdapterSlice.actions; +// Selectors +export const selectSelectedAdapter = (state: MesheryRootState) => state.selectedAdapter; +export default selectedAdapterSlice.reducer; diff --git a/src/redux-toolkit/slices/selectedBoardsConfigsSlice.ts b/src/redux-toolkit/slices/selectedBoardsConfigsSlice.ts new file mode 100644 index 00000000..1d3ee33a --- /dev/null +++ b/src/redux-toolkit/slices/selectedBoardsConfigsSlice.ts @@ -0,0 +1,50 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface SelectedBoardsConfigsState { + [key: string]: any; +} +// Initial state +const initialState: SelectedBoardsConfigsState = []; +// Slice +const selectedBoardsConfigsSlice = createSlice({ + name: 'selectedBoardsConfigs', + initialState, + reducers: { + setSelectedBoardsConfigs: (state, action: PayloadAction) => { + return action.payload; + }, + updateClusterConfig: (state: SelectedBoardsConfigsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_CLUSTER_CONFIG + return state; + }, + updateGrafanaConfig: (state: SelectedBoardsConfigsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_GRAFANA_CONFIG + return state; + }, + updatePrometheusConfig: (state: SelectedBoardsConfigsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_PROMETHEUS_CONFIG + return state; + }, + updateStaticBoardConfig: (state: SelectedBoardsConfigsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_STATIC_BOARD_CONFIG + return state; + }, + updateLoadGenConfig: (state: SelectedBoardsConfigsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_LOAD_GEN_CONFIG + return state; + } + } +}); +// Actions +export const { + setSelectedBoardsConfigs, + updateClusterConfig, + updateGrafanaConfig, + updatePrometheusConfig, + updateStaticBoardConfig, + updateLoadGenConfig +} = selectedBoardsConfigsSlice.actions; +// Selectors +export const selectSelectedBoardsConfigs = (state: MesheryRootState) => state.selectedBoardsConfigs; +export default selectedBoardsConfigsSlice.reducer; diff --git a/src/redux-toolkit/slices/selectedK8sContextsSlice.ts b/src/redux-toolkit/slices/selectedK8sContextsSlice.ts new file mode 100644 index 00000000..1a7d3804 --- /dev/null +++ b/src/redux-toolkit/slices/selectedK8sContextsSlice.ts @@ -0,0 +1,28 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; + +export interface SelectedK8sContextsState { + [key: string]: any; +} + +const initialState: SelectedK8sContextsState = ['all']; +// Slice +const selectedK8sContextsSlice = createSlice({ + name: 'selectedK8sContexts', + initialState, + reducers: { + setSelectedK8sContexts: (state, action: PayloadAction) => { + return action.payload; + }, + setK8sContext: (state: SelectedK8sContextsState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_K8S_CONTEXT + return state; + } + } +}); + +export const { setSelectedK8sContexts, setK8sContext } = selectedK8sContextsSlice.actions; + +// Selectors +export const selectSelectedK8sContexts = (state: MesheryRootState) => state.selectedK8sContexts; +export default selectedK8sContextsSlice.reducer; diff --git a/src/redux-toolkit/slices/selectedPrometheusBoardsConfigsSlice.ts b/src/redux-toolkit/slices/selectedPrometheusBoardsConfigsSlice.ts new file mode 100644 index 00000000..a98279df --- /dev/null +++ b/src/redux-toolkit/slices/selectedPrometheusBoardsConfigsSlice.ts @@ -0,0 +1,70 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; + +export interface SelectedPrometheusBoardsConfigsState { + [key: string]: any; +} + +const initialState: SelectedPrometheusBoardsConfigsState = []; + +const selectedPrometheusBoardsConfigsSlice = createSlice({ + name: 'selectedPrometheusBoardsConfigs', + initialState, + reducers: { + setSelectedPrometheusBoardsConfigs: ( + state, + action: PayloadAction + ) => { + return action.payload; + }, + updateClusterConfig: ( + state: SelectedPrometheusBoardsConfigsState, + action: PayloadAction + ) => { + // TODO: Implement reducer logic for UPDATE_CLUSTER_CONFIG + return state; + }, + updateGrafanaConfig: ( + state: SelectedPrometheusBoardsConfigsState, + action: PayloadAction + ) => { + // TODO: Implement reducer logic for UPDATE_GRAFANA_CONFIG + return state; + }, + updatePrometheusConfig: ( + state: SelectedPrometheusBoardsConfigsState, + action: PayloadAction + ) => { + // TODO: Implement reducer logic for UPDATE_PROMETHEUS_CONFIG + return state; + }, + updateStaticBoardConfig: ( + state: SelectedPrometheusBoardsConfigsState, + action: PayloadAction + ) => { + // TODO: Implement reducer logic for UPDATE_STATIC_BOARD_CONFIG + return state; + }, + updateLoadGenConfig: ( + state: SelectedPrometheusBoardsConfigsState, + action: PayloadAction + ) => { + // TODO: Implement reducer logic for UPDATE_LOAD_GEN_CONFIG + return state; + } + } +}); + +export const { + setSelectedPrometheusBoardsConfigs, + updateClusterConfig, + updateGrafanaConfig, + updatePrometheusConfig, + updateStaticBoardConfig, + updateLoadGenConfig +} = selectedPrometheusBoardsConfigsSlice.actions; + +// Selectors +export const selectSelectedPrometheusBoardsConfigs = (state: MesheryRootState) => + state.selectedPrometheusBoardsConfigs; +export default selectedPrometheusBoardsConfigsSlice.reducer; diff --git a/src/redux-toolkit/slices/showFullNotificationCenterSlice.ts b/src/redux-toolkit/slices/showFullNotificationCenterSlice.ts new file mode 100644 index 00000000..f0ca8218 --- /dev/null +++ b/src/redux-toolkit/slices/showFullNotificationCenterSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface ShowFullNotificationCenterState { + [key: string]: any; +} +// Initial state +const initialState: ShowFullNotificationCenterState = false; +// Slice +const showFullNotificationCenterSlice = createSlice({ + name: 'showFullNotificationCenter', + initialState, + reducers: { + setShowFullNotificationCenter: ( + state, + action: PayloadAction + ) => { + return action.payload; + } + } +}); +// Actions +export const { setShowFullNotificationCenter } = showFullNotificationCenterSlice.actions; +// Selectors +export const selectShowFullNotificationCenter = (state: MesheryRootState) => + state.showFullNotificationCenter; +export default showFullNotificationCenterSlice.reducer; diff --git a/src/redux-toolkit/slices/showProgressSlice.ts b/src/redux-toolkit/slices/showProgressSlice.ts new file mode 100644 index 00000000..cfb41271 --- /dev/null +++ b/src/redux-toolkit/slices/showProgressSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface ShowProgressState { + [key: string]: any; +} +// Initial state +const initialState: ShowProgressState = false; +// Slice +const showProgressSlice = createSlice({ + name: 'showProgress', + initialState, + reducers: { + setShowProgress: (state, action: PayloadAction) => { + return action.payload; + }, + updateProgress: (state: ShowProgressState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_PROGRESS + return state; + } + } +}); +// Actions +export const { setShowProgress, updateProgress } = showProgressSlice.actions; +// Selectors +export const selectShowProgress = (state: MesheryRootState) => state.showProgress; +export default showProgressSlice.reducer; diff --git a/src/redux-toolkit/slices/startKeySlice.ts b/src/redux-toolkit/slices/startKeySlice.ts new file mode 100644 index 00000000..e0eb5bcc --- /dev/null +++ b/src/redux-toolkit/slices/startKeySlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface StartKeyState { + [key: string]: any; +} +// Initial state +const initialState: StartKeyState = ''; +// Slice +const startKeySlice = createSlice({ + name: 'startKey', + initialState, + reducers: { + setStartKey: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setStartKey } = startKeySlice.actions; +// Selectors +export const selectStartKey = (state: MesheryRootState) => state.startKey; +export default startKeySlice.reducer; diff --git a/src/redux-toolkit/slices/staticPrometheusBoardConfigSlice.ts b/src/redux-toolkit/slices/staticPrometheusBoardConfigSlice.ts new file mode 100644 index 00000000..ea355a1d --- /dev/null +++ b/src/redux-toolkit/slices/staticPrometheusBoardConfigSlice.ts @@ -0,0 +1,60 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface StaticPrometheusBoardConfigState { + [key: string]: any; +} +// Initial state +const initialState: StaticPrometheusBoardConfigState = {}; +// Slice +const staticPrometheusBoardConfigSlice = createSlice({ + name: 'staticPrometheusBoardConfig', + initialState, + reducers: { + setStaticPrometheusBoardConfig: ( + state, + action: PayloadAction + ) => { + return action.payload; + }, + updateClusterConfig: (state: StaticPrometheusBoardConfigState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_CLUSTER_CONFIG + return state; + }, + updateGrafanaConfig: (state: StaticPrometheusBoardConfigState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_GRAFANA_CONFIG + return state; + }, + updatePrometheusConfig: ( + state: StaticPrometheusBoardConfigState, + action: PayloadAction + ) => { + // TODO: Implement reducer logic for UPDATE_PROMETHEUS_CONFIG + return state; + }, + updateStaticBoardConfig: ( + state: StaticPrometheusBoardConfigState, + action: PayloadAction + ) => { + // TODO: Implement reducer logic for UPDATE_STATIC_BOARD_CONFIG + return state; + }, + updateLoadGenConfig: (state: StaticPrometheusBoardConfigState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_LOAD_GEN_CONFIG + return state; + } + } +}); +// Actions +export const { + setStaticPrometheusBoardConfig, + updateClusterConfig, + updateGrafanaConfig, + updatePrometheusConfig, + updateStaticBoardConfig, + updateLoadGenConfig +} = staticPrometheusBoardConfigSlice.actions; +// Selectors +export const selectStaticPrometheusBoardConfig = (state: MesheryRootState) => + state.staticPrometheusBoardConfig; +export default staticPrometheusBoardConfigSlice.reducer; diff --git a/src/redux-toolkit/slices/tSlice.ts b/src/redux-toolkit/slices/tSlice.ts new file mode 100644 index 00000000..b7818a79 --- /dev/null +++ b/src/redux-toolkit/slices/tSlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface TState { + [key: string]: any; +} +// Initial state +const initialState: TState = '30s'; +// Slice +const tSlice = createSlice({ + name: 't', + initialState, + reducers: { + setT: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setT } = tSlice.actions; +// Selectors +export const selectT = (state: MesheryRootState) => state.t; +export default tSlice.reducer; diff --git a/src/redux-toolkit/slices/telemetryURLsSlice.ts b/src/redux-toolkit/slices/telemetryURLsSlice.ts new file mode 100644 index 00000000..0c051c2c --- /dev/null +++ b/src/redux-toolkit/slices/telemetryURLsSlice.ts @@ -0,0 +1,30 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface TelemetryURLsState { + [key: string]: any; +} +// Initial state +const initialState: TelemetryURLsState = { + grafana: [], + prometheus: [] +}; +// Slice +const telemetryURLsSlice = createSlice({ + name: 'telemetryURLs', + initialState, + reducers: { + setTelemetryURLs: (state, action: PayloadAction) => { + return action.payload; + }, + updateTelemetryUrls: (state: TelemetryURLsState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_TELEMETRY_URLS + return state; + } + } +}); +// Actions +export const { setTelemetryURLs, updateTelemetryUrls } = telemetryURLsSlice.actions; +// Selectors +export const selectTelemetryURLs = (state: MesheryRootState) => state.telemetryURLs; +export default telemetryURLsSlice.reducer; diff --git a/src/redux-toolkit/slices/testNameSlice.ts b/src/redux-toolkit/slices/testNameSlice.ts new file mode 100644 index 00000000..01c24611 --- /dev/null +++ b/src/redux-toolkit/slices/testNameSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface TestNameState { + [key: string]: any; +} +// Initial state +const initialState: TestNameState = ''; +// Slice +const testNameSlice = createSlice({ + name: 'testName', + initialState, + reducers: { + setTestName: (state, action: PayloadAction) => { + return action.payload; + }, + updateLoadTestData: (state: TestNameState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_LOAD_TEST_DATA + return state; + } + } +}); +// Actions +export const { setTestName, updateLoadTestData } = testNameSlice.actions; +// Selectors +export const selectTestName = (state: MesheryRootState) => state.testName; +export default testNameSlice.reducer; diff --git a/src/redux-toolkit/slices/titleSlice.ts b/src/redux-toolkit/slices/titleSlice.ts new file mode 100644 index 00000000..9331977d --- /dev/null +++ b/src/redux-toolkit/slices/titleSlice.ts @@ -0,0 +1,27 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface TitleState { + [key: string]: any; +} +// Initial state +const initialState: TitleState = ''; +// Slice +const titleSlice = createSlice({ + name: 'title', + initialState, + reducers: { + setTitle: (state, action: PayloadAction) => { + return action.payload; + }, + updateTitle: (state: TitleState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_TITLE + return state; + } + } +}); +// Actions +export const { setTitle, updateTitle } = titleSlice.actions; +// Selectors +export const selectTitle = (state: MesheryRootState) => state.title; +export default titleSlice.reducer; diff --git a/src/redux-toolkit/slices/tsSlice.ts b/src/redux-toolkit/slices/tsSlice.ts new file mode 100644 index 00000000..2bcbbdcd --- /dev/null +++ b/src/redux-toolkit/slices/tsSlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface TsState { + [key: string]: any; +} +// Initial state +const initialState: TsState = new Date(-8640000000000000); +// Slice +const tsSlice = createSlice({ + name: 'ts', + initialState, + reducers: { + setTs: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setTs } = tsSlice.actions; +// Selectors +export const selectTs = (state: MesheryRootState) => state.ts; +export default tsSlice.reducer; diff --git a/src/redux-toolkit/slices/urlSlice.ts b/src/redux-toolkit/slices/urlSlice.ts new file mode 100644 index 00000000..9fc28624 --- /dev/null +++ b/src/redux-toolkit/slices/urlSlice.ts @@ -0,0 +1,23 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; +// State interface +export interface UrlState { + [key: string]: any; +} +// Initial state +const initialState: UrlState = ''; +// Slice +const urlSlice = createSlice({ + name: 'url', + initialState, + reducers: { + setUrl: (state, action: PayloadAction) => { + return action.payload; + } + } +}); +// Actions +export const { setUrl } = urlSlice.actions; +// Selectors +export const selectUrl = (state: MesheryRootState) => state.url; +export default urlSlice.reducer; diff --git a/src/redux-toolkit/slices/userSlice.ts b/src/redux-toolkit/slices/userSlice.ts new file mode 100644 index 00000000..fa7928cd --- /dev/null +++ b/src/redux-toolkit/slices/userSlice.ts @@ -0,0 +1,28 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; + +export interface UserState { + [key: string]: any; +} + +const initialState: UserState = {}; + +const userSlice = createSlice({ + name: 'user', + initialState, + reducers: { + setUser: (state, action: PayloadAction) => { + return action.payload; + }, + updateUser: (state: UserState, action: PayloadAction) => { + // TODO: Implement reducer logic for UPDATE_USER + return state; + } + } +}); + +export const { setUser, updateUser } = userSlice.actions; + +// Selectors +export const selectUser = (state: MesheryRootState) => state.user; +export default userSlice.reducer; diff --git a/src/redux-toolkit/slices/workspaceSlice.ts b/src/redux-toolkit/slices/workspaceSlice.ts new file mode 100644 index 00000000..93a7807b --- /dev/null +++ b/src/redux-toolkit/slices/workspaceSlice.ts @@ -0,0 +1,30 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +import type { MesheryRootState } from '../store'; + +export interface WorkspaceState { + [key: string]: any; +} + +const initialState: WorkspaceState = null; + +const workspaceSlice = createSlice({ + name: 'workspace', + initialState, + reducers: { + /* + setWorkspace: (state, action: PayloadAction) => { + return action.payload; + }, + */ + setWorkspace: (state: WorkspaceState, action: PayloadAction) => { + // TODO: Implement reducer logic for SET_WORKSPACE + return state; + } + } +}); + +export const { setWorkspace } = workspaceSlice.actions; + +// Selectors +export const selectWorkspace = (state: MesheryRootState) => state.workspace; +export default workspaceSlice.reducer; diff --git a/src/redux-toolkit/store.ts b/src/redux-toolkit/store.ts new file mode 100644 index 00000000..dff8a67c --- /dev/null +++ b/src/redux-toolkit/store.ts @@ -0,0 +1,120 @@ +import { configureStore } from '@reduxjs/toolkit'; +import anonymousPerfResultsReducer from './slices/anonymousPerfResultsSlice'; +import anonymousUsageStatsReducer from './slices/anonymousUsageStatsSlice'; +import cReducer from './slices/cSlice'; +import capabilitiesRegistryReducer from './slices/capabilitiesRegistrySlice'; +import catalogVisibilityReducer from './slices/catalogVisibilitySlice'; +import connectionMetadataStateReducer from './slices/connectionMetadataStateSlice'; +import controllerStateReducer from './slices/controllerStateSlice'; +import eventsReducer from './slices/eventsSlice'; +import extensionTypeReducer from './slices/extensionTypeSlice'; +import genReducer from './slices/genSlice'; +import grafanaAPIKeyReducer from './slices/grafanaAPIKeySlice'; +import grafanaBoardSearchReducer from './slices/grafanaBoardSearchSlice'; +import grafanaBoardsReducer from './slices/grafanaBoardsSlice'; +import grafanaReducer from './slices/grafanaSlice'; +import grafanaURLReducer from './slices/grafanaURLSlice'; +import isBetaReducer from './slices/isBetaSlice'; +import isDrawerCollapsedReducer from './slices/isDrawerCollapsedSlice'; +import k8sConfigReducer from './slices/k8sConfigSlice'; +import keysReducer from './slices/keysSlice'; +import loadTestPrefReducer from './slices/loadTestPrefSlice'; +import loadTestReducer from './slices/loadTestSlice'; +import meshAdaptersReducer from './slices/meshAdaptersSlice'; +import meshAdapterstsReducer from './slices/meshAdapterstsSlice'; +import meshNameReducer from './slices/meshNameSlice'; +import meshSyncStateReducer from './slices/meshSyncStateSlice'; +import notificationCenterReducer from './slices/notificationCenterSlice'; +import openEventIdReducer from './slices/openEventIdSlice'; +import operatorStateReducer from './slices/operatorStateSlice'; +import organizationReducer from './slices/organizationSlice'; +import pageReducer from './slices/pageSlice'; +import pathReducer from './slices/pathSlice'; +import prometheusReducer from './slices/prometheusSlice'; +import prometheusURLReducer from './slices/prometheusURLSlice'; +import qpsReducer from './slices/qpsSlice'; +import resultReducer from './slices/resultSlice'; +import resultsReducer from './slices/resultsSlice'; +import results_selectionReducer from './slices/results_selectionSlice'; +import selectedAdapterReducer from './slices/selectedAdapterSlice'; +import selectedBoardsConfigsReducer from './slices/selectedBoardsConfigsSlice'; +import selectedK8sContextsReducer from './slices/selectedK8sContextsSlice'; +import selectedPrometheusBoardsConfigsReducer from './slices/selectedPrometheusBoardsConfigsSlice'; +import showFullNotificationCenterReducer from './slices/showFullNotificationCenterSlice'; +import showProgressReducer from './slices/showProgressSlice'; +import startKeyReducer from './slices/startKeySlice'; +import staticPrometheusBoardConfigReducer from './slices/staticPrometheusBoardConfigSlice'; +import tReducer from './slices/tSlice'; +import telemetryURLsReducer from './slices/telemetryURLsSlice'; +import testNameReducer from './slices/testNameSlice'; +import titleReducer from './slices/titleSlice'; +import tsReducer from './slices/tsSlice'; +import urlReducer from './slices/urlSlice'; +import userReducer from './slices/userSlice'; +import workspaceReducer from './slices/workspaceSlice'; + +export const mesheryReduxStore = configureStore({ + reducer: { + page: pageReducer, + user: userReducer, + k8sConfig: k8sConfigReducer, + selectedK8sContexts: selectedK8sContextsReducer, + loadTest: loadTestReducer, + loadTestPref: loadTestPrefReducer, + meshAdapters: meshAdaptersReducer, + meshAdaptersts: meshAdapterstsReducer, + results: resultsReducer, + results_selection: results_selectionReducer, + grafana: grafanaReducer, + prometheus: prometheusReducer, + staticPrometheusBoardConfig: staticPrometheusBoardConfigReducer, + anonymousUsageStats: anonymousUsageStatsReducer, + anonymousPerfResults: anonymousPerfResultsReducer, + showProgress: showProgressReducer, + isDrawerCollapsed: isDrawerCollapsedReducer, + selectedAdapter: selectedAdapterReducer, + events: eventsReducer, + notificationCenter: notificationCenterReducer, + catalogVisibility: catalogVisibilityReducer, + extensionType: extensionTypeReducer, + capabilitiesRegistry: capabilitiesRegistryReducer, + telemetryURLs: telemetryURLsReducer, + operatorState: operatorStateReducer, + controllerState: controllerStateReducer, + meshSyncState: meshSyncStateReducer, + connectionMetadataState: connectionMetadataStateReducer, + organization: organizationReducer, + workspace: workspaceReducer, + keys: keysReducer, + path: pathReducer, + title: titleReducer, + isBeta: isBetaReducer, + testName: testNameReducer, + meshName: meshNameReducer, + url: urlReducer, + qps: qpsReducer, + c: cReducer, + t: tReducer, + result: resultReducer, + gen: genReducer, + ts: tsReducer, + startKey: startKeyReducer, + grafanaURL: grafanaURLReducer, + grafanaAPIKey: grafanaAPIKeyReducer, + grafanaBoardSearch: grafanaBoardSearchReducer, + grafanaBoards: grafanaBoardsReducer, + selectedBoardsConfigs: selectedBoardsConfigsReducer, + prometheusURL: prometheusURLReducer, + selectedPrometheusBoardsConfigs: selectedPrometheusBoardsConfigsReducer, + openEventId: openEventIdReducer, + showFullNotificationCenter: showFullNotificationCenterReducer + }, + middleware: (getDefaultMiddleware) => + getDefaultMiddleware({ + serializableCheck: false, + immutableCheck: false + }) +}); + +export type MesheryRootState = ReturnType; +export type MesheryReduxAppDispatch = typeof mesheryReduxStore.dispatch; From e5d54caa763c7ce75d3f0faf08670800c4d0ba2d Mon Sep 17 00:00:00 2001 From: Antonette Caldwell <134739862+nebula-aac@users.noreply.github.com> Date: Sun, 15 Dec 2024 05:29:59 +0000 Subject: [PATCH 2/2] fix: revise slices with thunk action creators Signed-off-by: Antonette Caldwell <134739862+nebula-aac@users.noreply.github.com> --- .../slices/anonymousPerfResultsSlice.ts | 11 ++++---- .../slices/anonymousUsageStatsSlice.ts | 21 ++++++++++----- .../slices/capabilitiesRegistrySlice.ts | 12 +++++---- .../slices/catalogVisibilitySlice.ts | 11 ++++---- .../slices/connectionMetadataStateSlice.ts | 12 +++++---- .../slices/controllerStateSlice.ts | 17 +++++++----- src/redux-toolkit/slices/eventsSlice.ts | 12 +++++---- .../slices/extensionTypeSlice.ts | 22 +++++++++++----- .../slices/grafanaBoardsSlice.ts | 8 +++--- src/redux-toolkit/slices/grafanaSlice.ts | 15 ++++++++--- src/redux-toolkit/slices/grafanaURLSlice.ts | 8 +++--- src/redux-toolkit/slices/isBetaSlice.ts | 8 +++--- .../slices/isDrawerCollapsedSlice.ts | 8 +++--- src/redux-toolkit/slices/k8sConfigSlice.ts | 7 ++++- src/redux-toolkit/slices/keysSlice.ts | 15 ++++++++--- src/redux-toolkit/slices/loadTestPrefSlice.ts | 16 +++++++++--- src/redux-toolkit/slices/loadTestSlice.ts | 23 ++++++++++++---- src/redux-toolkit/slices/meshAdaptersSlice.ts | 12 +++++---- .../slices/meshAdapterstsSlice.ts | 12 +++++---- .../slices/meshSyncStateSlice.ts | 12 +++++---- .../slices/notificationCenterSlice.ts | 19 ++++++++++---- src/redux-toolkit/slices/openEventIdSlice.ts | 8 +++--- .../slices/operatorStateSlice.ts | 12 +++++---- src/redux-toolkit/slices/organizationSlice.ts | 11 ++++---- src/redux-toolkit/slices/pageSlice.ts | 13 +++++++--- src/redux-toolkit/slices/prometheusSlice.ts | 26 ++++++++++++++----- src/redux-toolkit/slices/resultsSlice.ts | 23 +++++++++++----- .../staticPrometheusBoardConfigSlice.ts | 20 +++++++++----- .../slices/telemetryURLsSlice.ts | 19 ++++++++++---- src/redux-toolkit/slices/userSlice.ts | 13 ++++++---- src/redux-toolkit/slices/workspaceSlice.ts | 19 +++++++++----- 31 files changed, 297 insertions(+), 148 deletions(-) diff --git a/src/redux-toolkit/slices/anonymousPerfResultsSlice.ts b/src/redux-toolkit/slices/anonymousPerfResultsSlice.ts index 7712d828..73de5860 100644 --- a/src/redux-toolkit/slices/anonymousPerfResultsSlice.ts +++ b/src/redux-toolkit/slices/anonymousPerfResultsSlice.ts @@ -1,12 +1,11 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface export interface AnonymousPerfResultsState { - [key: string]: any; + value: boolean; } -// Initial state -const initialState: AnonymousPerfResultsState = true; -// Slice + +const initialState: AnonymousPerfResultsState = { value: false }; + const anonymousPerfResultsSlice = createSlice({ name: 'anonymousPerfResults', initialState, @@ -35,6 +34,7 @@ const anonymousPerfResultsSlice = createSlice({ } } }); + // Actions export const { setAnonymousPerfResults, @@ -43,6 +43,7 @@ export const { updateAnonymousUsageStats, updateAnonymousPerformanceResults } = anonymousPerfResultsSlice.actions; + // Selectors export const selectAnonymousPerfResults = (state: MesheryRootState) => state.anonymousPerfResults; export default anonymousPerfResultsSlice.reducer; diff --git a/src/redux-toolkit/slices/anonymousUsageStatsSlice.ts b/src/redux-toolkit/slices/anonymousUsageStatsSlice.ts index 2ea1a8f3..4959f2e6 100644 --- a/src/redux-toolkit/slices/anonymousUsageStatsSlice.ts +++ b/src/redux-toolkit/slices/anonymousUsageStatsSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; -// State interface +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; + export interface AnonymousUsageStatsState { - [key: string]: any; + value: boolean; } -// Initial state -const initialState: AnonymousUsageStatsState = true; -// Slice + +const initialState: AnonymousUsageStatsState = { value: false }; + const anonymousUsageStatsSlice = createSlice({ name: 'anonymousUsageStats', initialState, @@ -30,9 +30,16 @@ const anonymousUsageStatsSlice = createSlice({ // Actions export const { setAnonymousUsageStats, - updateAnonymousUsageStats, + // updateAnonymousUsageStats, updateAnonymousPerformanceResults } = anonymousUsageStatsSlice.actions; + +// Thunk action creator +export const updateAnonymousUsageStats = + (payload: AnonymousUsageStatsState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setAnonymousUsageStats(payload)); + }; + // Selectors export const selectAnonymousUsageStats = (state: MesheryRootState) => state.anonymousUsageStats; export default anonymousUsageStatsSlice.reducer; diff --git a/src/redux-toolkit/slices/capabilitiesRegistrySlice.ts b/src/redux-toolkit/slices/capabilitiesRegistrySlice.ts index de52e68a..ca1f9309 100644 --- a/src/redux-toolkit/slices/capabilitiesRegistrySlice.ts +++ b/src/redux-toolkit/slices/capabilitiesRegistrySlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface CapabilitiesRegistryState { - [key: string]: any; + value: any; } -// Initial state -const initialState: CapabilitiesRegistryState = null; -// Slice + +const initialState: CapabilitiesRegistryState = { value: null }; + const capabilitiesRegistrySlice = createSlice({ name: 'capabilitiesRegistry', initialState, @@ -20,9 +20,11 @@ const capabilitiesRegistrySlice = createSlice({ } } }); + // Actions export const { setCapabilitiesRegistry, updateCapabilityRegistry } = capabilitiesRegistrySlice.actions; + // Selectors export const selectCapabilitiesRegistry = (state: MesheryRootState) => state.capabilitiesRegistry; export default capabilitiesRegistrySlice.reducer; diff --git a/src/redux-toolkit/slices/catalogVisibilitySlice.ts b/src/redux-toolkit/slices/catalogVisibilitySlice.ts index 39c0fd71..2c7948b5 100644 --- a/src/redux-toolkit/slices/catalogVisibilitySlice.ts +++ b/src/redux-toolkit/slices/catalogVisibilitySlice.ts @@ -1,12 +1,11 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface export interface CatalogVisibilityState { - [key: string]: any; + value: boolean; } -// Initial state -const initialState: CatalogVisibilityState = true; -// Slice + +const initialState: CatalogVisibilityState = { value: false }; + const catalogVisibilitySlice = createSlice({ name: 'catalogVisibility', initialState, @@ -20,8 +19,10 @@ const catalogVisibilitySlice = createSlice({ } } }); + // Actions export const { setCatalogVisibility, setCatalogContent } = catalogVisibilitySlice.actions; + // Selectors export const selectCatalogVisibility = (state: MesheryRootState) => state.catalogVisibility; export default catalogVisibilitySlice.reducer; diff --git a/src/redux-toolkit/slices/connectionMetadataStateSlice.ts b/src/redux-toolkit/slices/connectionMetadataStateSlice.ts index 07d0c8d5..b42aba93 100644 --- a/src/redux-toolkit/slices/connectionMetadataStateSlice.ts +++ b/src/redux-toolkit/slices/connectionMetadataStateSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface ConnectionMetadataStateState { - [key: string]: any; + value: any; } -// Initial state -const initialState: ConnectionMetadataStateState = null; -// Slice + +const initialState: ConnectionMetadataStateState = { value: null }; + const connectionMetadataStateSlice = createSlice({ name: 'connectionMetadataState', initialState, @@ -28,6 +28,7 @@ const connectionMetadataStateSlice = createSlice({ } } }); + // Actions export const { setConnectionMetadataState, @@ -35,6 +36,7 @@ export const { setControllerState, setConnectionMetadata } = connectionMetadataStateSlice.actions; + // Selectors export const selectConnectionMetadataState = (state: MesheryRootState) => state.connectionMetadataState; diff --git a/src/redux-toolkit/slices/controllerStateSlice.ts b/src/redux-toolkit/slices/controllerStateSlice.ts index 45b8eae1..7be47f39 100644 --- a/src/redux-toolkit/slices/controllerStateSlice.ts +++ b/src/redux-toolkit/slices/controllerStateSlice.ts @@ -1,27 +1,30 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface export interface ControllerStateState { - [key: string]: any; + value: any; } -// Initial state -const initialState: ControllerStateState = null; -// Slice + +const initialState: ControllerStateState = { value: null }; + const controllerStateSlice = createSlice({ name: 'controllerState', initialState, reducers: { setControllerState: (state, action: PayloadAction) => { return action.payload; - }, + } + /* setControllerState: (state: ControllerStateState, action: PayloadAction) => { // TODO: Implement reducer logic for SET_CONTROLLER_STATE return state; } + */ } }); + // Actions -export const { setControllerState, setControllerState1 } = controllerStateSlice.actions; +export const { setControllerState } = controllerStateSlice.actions; + // Selectors export const selectControllerState = (state: MesheryRootState) => state.controllerState; export default controllerStateSlice.reducer; diff --git a/src/redux-toolkit/slices/eventsSlice.ts b/src/redux-toolkit/slices/eventsSlice.ts index 56df6e2d..ec61c997 100644 --- a/src/redux-toolkit/slices/eventsSlice.ts +++ b/src/redux-toolkit/slices/eventsSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface EventsState { - [key: string]: any; + items: any[]; } -// Initial state -const initialState: EventsState = []; -// Slice + +const initialState: EventsState = { items: [] }; + const eventsSlice = createSlice({ name: 'events', initialState, @@ -16,8 +16,10 @@ const eventsSlice = createSlice({ } } }); + // Actions export const { setEvents } = eventsSlice.actions; + // Selectors export const selectEvents = (state: MesheryRootState) => state.events; export default eventsSlice.reducer; diff --git a/src/redux-toolkit/slices/extensionTypeSlice.ts b/src/redux-toolkit/slices/extensionTypeSlice.ts index d805493e..183bba44 100644 --- a/src/redux-toolkit/slices/extensionTypeSlice.ts +++ b/src/redux-toolkit/slices/extensionTypeSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; -// State interface +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; + export interface ExtensionTypeState { - [key: string]: any; + value: string; } -// Initial state -const initialState: ExtensionTypeState = ''; -// Slice + +const initialState: ExtensionTypeState = { value: '' }; + const extensionTypeSlice = createSlice({ name: 'extensionType', initialState, @@ -20,8 +20,16 @@ const extensionTypeSlice = createSlice({ } } }); + // Actions -export const { setExtensionType, updateExtensionType } = extensionTypeSlice.actions; +export const { setExtensionType } = extensionTypeSlice.actions; + +// Thunk action creator +export const updateExtensionType = + (payload: ExtensionTypeState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setExtensionType(payload)); + }; + // Selectors export const selectExtensionType = (state: MesheryRootState) => state.extensionType; export default extensionTypeSlice.reducer; diff --git a/src/redux-toolkit/slices/grafanaBoardsSlice.ts b/src/redux-toolkit/slices/grafanaBoardsSlice.ts index 9ec9e85b..7959d700 100644 --- a/src/redux-toolkit/slices/grafanaBoardsSlice.ts +++ b/src/redux-toolkit/slices/grafanaBoardsSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface GrafanaBoardsState { [key: string]: any; } -// Initial state + const initialState: GrafanaBoardsState = []; -// Slice + const grafanaBoardsSlice = createSlice({ name: 'grafanaBoards', initialState, @@ -24,9 +24,11 @@ const grafanaBoardsSlice = createSlice({ } } }); + // Actions export const { setGrafanaBoards, updateGrafanaConfig, updateStaticBoardConfig } = grafanaBoardsSlice.actions; + // Selectors export const selectGrafanaBoards = (state: MesheryRootState) => state.grafanaBoards; export default grafanaBoardsSlice.reducer; diff --git a/src/redux-toolkit/slices/grafanaSlice.ts b/src/redux-toolkit/slices/grafanaSlice.ts index 28ebedd0..6b76d116 100644 --- a/src/redux-toolkit/slices/grafanaSlice.ts +++ b/src/redux-toolkit/slices/grafanaSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; -// State interface +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; + export interface GrafanaState { [key: string]: any; } -// Initial state + const initialState: GrafanaState = []; -// Slice + const grafanaSlice = createSlice({ name: 'grafana', initialState, @@ -20,8 +20,15 @@ const grafanaSlice = createSlice({ } } }); + // Actions export const { setGrafana, updateGrafanaConfig } = grafanaSlice.actions; + +// Thunk action creator +export const updateGrafana = (payload: GrafanaState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setGrafana(payload)); +}; + // Selectors export const selectGrafana = (state: MesheryRootState) => state.grafana; export default grafanaSlice.reducer; diff --git a/src/redux-toolkit/slices/grafanaURLSlice.ts b/src/redux-toolkit/slices/grafanaURLSlice.ts index aba5e4b2..7066d480 100644 --- a/src/redux-toolkit/slices/grafanaURLSlice.ts +++ b/src/redux-toolkit/slices/grafanaURLSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface GrafanaURLState { [key: string]: any; } -// Initial state + const initialState: GrafanaURLState = ''; -// Slice + const grafanaURLSlice = createSlice({ name: 'grafanaURL', initialState, @@ -20,8 +20,10 @@ const grafanaURLSlice = createSlice({ } } }); + // Actions export const { setGrafanaURL, updateGrafanaConfig } = grafanaURLSlice.actions; + // Selectors export const selectGrafanaURL = (state: MesheryRootState) => state.grafanaURL; export default grafanaURLSlice.reducer; diff --git a/src/redux-toolkit/slices/isBetaSlice.ts b/src/redux-toolkit/slices/isBetaSlice.ts index 19b26da4..a0ebd484 100644 --- a/src/redux-toolkit/slices/isBetaSlice.ts +++ b/src/redux-toolkit/slices/isBetaSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface IsBetaState { [key: string]: any; } -// Initial state + const initialState: IsBetaState = false; -// Slice + const isBetaSlice = createSlice({ name: 'isBeta', initialState, @@ -20,8 +20,10 @@ const isBetaSlice = createSlice({ } } }); + // Actions export const { setIsBeta, updateBetaBadge } = isBetaSlice.actions; + // Selectors export const selectIsBeta = (state: MesheryRootState) => state.isBeta; export default isBetaSlice.reducer; diff --git a/src/redux-toolkit/slices/isDrawerCollapsedSlice.ts b/src/redux-toolkit/slices/isDrawerCollapsedSlice.ts index 8fcad7e6..dfbd4a1c 100644 --- a/src/redux-toolkit/slices/isDrawerCollapsedSlice.ts +++ b/src/redux-toolkit/slices/isDrawerCollapsedSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface IsDrawerCollapsedState { [key: string]: any; } -// Initial state + const initialState: IsDrawerCollapsedState = false; -// Slice + const isDrawerCollapsedSlice = createSlice({ name: 'isDrawerCollapsed', initialState, @@ -20,8 +20,10 @@ const isDrawerCollapsedSlice = createSlice({ } } }); + // Actions export const { setIsDrawerCollapsed, toogleDrawer } = isDrawerCollapsedSlice.actions; + // Selectors export const selectIsDrawerCollapsed = (state: MesheryRootState) => state.isDrawerCollapsed; export default isDrawerCollapsedSlice.reducer; diff --git a/src/redux-toolkit/slices/k8sConfigSlice.ts b/src/redux-toolkit/slices/k8sConfigSlice.ts index be4f1421..d1e4e2cd 100644 --- a/src/redux-toolkit/slices/k8sConfigSlice.ts +++ b/src/redux-toolkit/slices/k8sConfigSlice.ts @@ -1,5 +1,5 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; export interface K8sConfigState { [key: string]: any; @@ -51,6 +51,11 @@ export const { updateLoadGenConfig } = k8sConfigSlice.actions; +// Thunk action creator +export const updateK8sConfig = (payload: K8sConfigState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setK8sConfig(payload)); +}; + // Selectors export const selectK8sConfig = (state: MesheryRootState) => state.k8sConfig; export default k8sConfigSlice.reducer; diff --git a/src/redux-toolkit/slices/keysSlice.ts b/src/redux-toolkit/slices/keysSlice.ts index 817c852b..881fea5f 100644 --- a/src/redux-toolkit/slices/keysSlice.ts +++ b/src/redux-toolkit/slices/keysSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; -// State interface +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; + export interface KeysState { [key: string]: any; } -// Initial state + const initialState: KeysState = null; -// Slice + const keysSlice = createSlice({ name: 'keys', initialState, @@ -22,8 +22,15 @@ const keysSlice = createSlice({ } } }); + // Actions export const { setKeys } = keysSlice.actions; + +// Thunk action creator +export const updateKeys = (payload: KeysState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setKeys(payload)); +}; + // Selectors export const selectKeys = (state: MesheryRootState) => state.keys; export default keysSlice.reducer; diff --git a/src/redux-toolkit/slices/loadTestPrefSlice.ts b/src/redux-toolkit/slices/loadTestPrefSlice.ts index f416b35e..1f761427 100644 --- a/src/redux-toolkit/slices/loadTestPrefSlice.ts +++ b/src/redux-toolkit/slices/loadTestPrefSlice.ts @@ -1,10 +1,10 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; -// State interface +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; + export interface LoadTestPrefState { [key: string]: any; } -// Initial state + const initialState: LoadTestPrefState = { qps: 0, t: '30s', @@ -12,7 +12,7 @@ const initialState: LoadTestPrefState = { gen: 'fortio', ts: new Date() }; -// Slice + const loadTestPrefSlice = createSlice({ name: 'loadTestPref', initialState, @@ -30,9 +30,17 @@ const loadTestPrefSlice = createSlice({ } } }); + // Actions export const { setLoadTestPref, updateLoadTestData, updateLoadGenConfig } = loadTestPrefSlice.actions; + +// Thunk action creator +export const updateLoadTestPref = + (payload: LoadTestPrefState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setLoadTestPref(payload)); + }; + // Selectors export const selectLoadTestPref = (state: MesheryRootState) => state.loadTestPref; export default loadTestPrefSlice.reducer; diff --git a/src/redux-toolkit/slices/loadTestSlice.ts b/src/redux-toolkit/slices/loadTestSlice.ts index adcb0e80..27a09008 100644 --- a/src/redux-toolkit/slices/loadTestSlice.ts +++ b/src/redux-toolkit/slices/loadTestSlice.ts @@ -1,10 +1,16 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; -// State interface +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; + export interface LoadTestState { - [key: string]: any; + testName: string; + meshName: string; + url: string; + qps: number; + c: number; + t: string; + result: {}; } -// Initial state + const initialState: LoadTestState = { testName: '', meshName: '', @@ -14,7 +20,7 @@ const initialState: LoadTestState = { t: '30s', result: {} }; -// Slice + const loadTestSlice = createSlice({ name: 'loadTest', initialState, @@ -32,8 +38,15 @@ const loadTestSlice = createSlice({ } } }); + // Actions export const { setLoadTest, updateLoadTestData, updateLoadGenConfig } = loadTestSlice.actions; + +// Thunk action creator +export const updateLoadTest = (payload: LoadTestState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setLoadTest(payload)); +}; + // Selectors export const selectLoadTest = (state: MesheryRootState) => state.loadTest; export default loadTestSlice.reducer; diff --git a/src/redux-toolkit/slices/meshAdaptersSlice.ts b/src/redux-toolkit/slices/meshAdaptersSlice.ts index 8125b1c9..04623cd2 100644 --- a/src/redux-toolkit/slices/meshAdaptersSlice.ts +++ b/src/redux-toolkit/slices/meshAdaptersSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface MeshAdaptersState { - [key: string]: any; + items: any[]; } -// Initial state -const initialState: MeshAdaptersState = []; -// Slice + +const initialState: MeshAdaptersState = { items: [] }; + const meshAdaptersSlice = createSlice({ name: 'meshAdapters', initialState, @@ -24,8 +24,10 @@ const meshAdaptersSlice = createSlice({ } } }); + // Actions export const { setMeshAdapters, updateAdaptersInfo, setAdapter } = meshAdaptersSlice.actions; + // Selectors export const selectMeshAdapters = (state: MesheryRootState) => state.meshAdapters; export default meshAdaptersSlice.reducer; diff --git a/src/redux-toolkit/slices/meshAdapterstsSlice.ts b/src/redux-toolkit/slices/meshAdapterstsSlice.ts index b1bab927..2d510530 100644 --- a/src/redux-toolkit/slices/meshAdapterstsSlice.ts +++ b/src/redux-toolkit/slices/meshAdapterstsSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface MeshAdapterstsState { - [key: string]: any; + value: Date; } -// Initial state -const initialState: MeshAdapterstsState = new Date(); -// Slice + +const initialState: MeshAdapterstsState = { value: new Date() }; + const meshAdapterstsSlice = createSlice({ name: 'meshAdaptersts', initialState, @@ -24,8 +24,10 @@ const meshAdapterstsSlice = createSlice({ } } }); + // Actions export const { setMeshAdaptersts, updateAdaptersInfo, setAdapter } = meshAdapterstsSlice.actions; + // Selectors export const selectMeshAdaptersts = (state: MesheryRootState) => state.meshAdaptersts; export default meshAdapterstsSlice.reducer; diff --git a/src/redux-toolkit/slices/meshSyncStateSlice.ts b/src/redux-toolkit/slices/meshSyncStateSlice.ts index 7fe44da1..54964b20 100644 --- a/src/redux-toolkit/slices/meshSyncStateSlice.ts +++ b/src/redux-toolkit/slices/meshSyncStateSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface MeshSyncStateState { - [key: string]: any; + value: any; } -// Initial state -const initialState: MeshSyncStateState = null; -// Slice + +const initialState: MeshSyncStateState = { value: null }; + const meshSyncStateSlice = createSlice({ name: 'meshSyncState', initialState, @@ -24,9 +24,11 @@ const meshSyncStateSlice = createSlice({ } } }); + // Actions export const { setMeshSyncState, setControllerState, setMeshsyncSubscription } = meshSyncStateSlice.actions; + // Selectors export const selectMeshSyncState = (state: MesheryRootState) => state.meshSyncState; export default meshSyncStateSlice.reducer; diff --git a/src/redux-toolkit/slices/notificationCenterSlice.ts b/src/redux-toolkit/slices/notificationCenterSlice.ts index efe84c7b..138f1d94 100644 --- a/src/redux-toolkit/slices/notificationCenterSlice.ts +++ b/src/redux-toolkit/slices/notificationCenterSlice.ts @@ -1,15 +1,16 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; -// State interface +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; + export interface NotificationCenterState { - [key: string]: any; + openEventId: any; + showFullNotificationCenter: boolean; } -// Initial state + const initialState: NotificationCenterState = { openEventId: null, showFullNotificationCenter: false }; -// Slice + const notificationCenterSlice = createSlice({ name: 'notificationCenter', initialState, @@ -19,8 +20,16 @@ const notificationCenterSlice = createSlice({ } } }); + // Actions export const { setNotificationCenter } = notificationCenterSlice.actions; + +// Thunk action creator +export const updateNotificationCenter = + (payload: NotificationCenterState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setNotificationCenter(payload)); + }; + // Selectors export const selectNotificationCenter = (state: MesheryRootState) => state.notificationCenter; export default notificationCenterSlice.reducer; diff --git a/src/redux-toolkit/slices/openEventIdSlice.ts b/src/redux-toolkit/slices/openEventIdSlice.ts index 889de010..ec01c21d 100644 --- a/src/redux-toolkit/slices/openEventIdSlice.ts +++ b/src/redux-toolkit/slices/openEventIdSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface OpenEventIdState { [key: string]: any; } -// Initial state + const initialState: OpenEventIdState = null; -// Slice + const openEventIdSlice = createSlice({ name: 'openEventId', initialState, @@ -16,8 +16,10 @@ const openEventIdSlice = createSlice({ } } }); + // Actions export const { setOpenEventId } = openEventIdSlice.actions; + // Selectors export const selectOpenEventId = (state: MesheryRootState) => state.openEventId; export default openEventIdSlice.reducer; diff --git a/src/redux-toolkit/slices/operatorStateSlice.ts b/src/redux-toolkit/slices/operatorStateSlice.ts index 6efae94f..98fc65c6 100644 --- a/src/redux-toolkit/slices/operatorStateSlice.ts +++ b/src/redux-toolkit/slices/operatorStateSlice.ts @@ -1,12 +1,12 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface + export interface OperatorStateState { - [key: string]: any; + value: any; } -// Initial state -const initialState: OperatorStateState = null; -// Slice + +const initialState: OperatorStateState = { value: null }; + const operatorStateSlice = createSlice({ name: 'operatorState', initialState, @@ -24,9 +24,11 @@ const operatorStateSlice = createSlice({ } } }); + // Actions export const { setOperatorState, setOperatorSubscription, setControllerState } = operatorStateSlice.actions; + // Selectors export const selectOperatorState = (state: MesheryRootState) => state.operatorState; export default operatorStateSlice.reducer; diff --git a/src/redux-toolkit/slices/organizationSlice.ts b/src/redux-toolkit/slices/organizationSlice.ts index cb250c2a..3fd47add 100644 --- a/src/redux-toolkit/slices/organizationSlice.ts +++ b/src/redux-toolkit/slices/organizationSlice.ts @@ -1,12 +1,11 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import type { MesheryRootState } from '../store'; -// State interface export interface OrganizationState { - [key: string]: any; + value: any; } -// Initial state -const initialState: OrganizationState = null; -// Slice + +const initialState: OrganizationState = { value: null }; + const organizationSlice = createSlice({ name: 'organization', initialState, @@ -22,8 +21,10 @@ const organizationSlice = createSlice({ } } }); + // Actions export const { setOrganization } = organizationSlice.actions; + // Selectors export const selectOrganization = (state: MesheryRootState) => state.organization; export default organizationSlice.reducer; diff --git a/src/redux-toolkit/slices/pageSlice.ts b/src/redux-toolkit/slices/pageSlice.ts index 3217282e..4761ff5a 100644 --- a/src/redux-toolkit/slices/pageSlice.ts +++ b/src/redux-toolkit/slices/pageSlice.ts @@ -1,8 +1,10 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; export interface PageState { - [key: string]: any; + path: string; + title: string; + isBeta: boolean; } const initialState: PageState = { @@ -25,7 +27,12 @@ const pageSlice = createSlice({ } }); -export const { setPage, updatePage } = pageSlice.actions; +export const { setPage } = pageSlice.actions; + +// Thunk action creator +export const updatePage = (payload: PageState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setPage(payload)); +}; // Selectors export const selectPage = (state: MesheryRootState) => state.page; diff --git a/src/redux-toolkit/slices/prometheusSlice.ts b/src/redux-toolkit/slices/prometheusSlice.ts index c0c3d93f..9483eb18 100644 --- a/src/redux-toolkit/slices/prometheusSlice.ts +++ b/src/redux-toolkit/slices/prometheusSlice.ts @@ -1,12 +1,18 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; -// State interface +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; + export interface PrometheusState { - [key: string]: any; + prometheusURL: string; + selectedPrometheusBoardsConfigs: any[]; + ts: Date; } -// Initial state -const initialState: PrometheusState = []; -// Slice + +const initialState: PrometheusState = { + prometheusURL: '', + selectedPrometheusBoardsConfigs: [], + ts: new Date() +}; + const prometheusSlice = createSlice({ name: 'prometheus', initialState, @@ -20,8 +26,16 @@ const prometheusSlice = createSlice({ } } }); + // Actions export const { setPrometheus, updatePrometheusConfig } = prometheusSlice.actions; + +// Thunk action creator +export const updatePrometheus = + (payload: PrometheusState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setPrometheus(payload)); + }; + // Selectors export const selectPrometheus = (state: MesheryRootState) => state.prometheus; export default prometheusSlice.reducer; diff --git a/src/redux-toolkit/slices/resultsSlice.ts b/src/redux-toolkit/slices/resultsSlice.ts index 5923e5cc..98b2b0c6 100644 --- a/src/redux-toolkit/slices/resultsSlice.ts +++ b/src/redux-toolkit/slices/resultsSlice.ts @@ -1,12 +1,16 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; -// State interface +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; + export interface ResultsState { - [key: string]: any; + startKey: string; + results: any[]; } -// Initial state -const initialState: ResultsState = []; -// Slice + +const initialState: ResultsState = { + startKey: '', + results: [] +}; + const resultsSlice = createSlice({ name: 'results', initialState, @@ -28,6 +32,7 @@ const resultsSlice = createSlice({ } } }); + // Actions export const { setResults, @@ -35,6 +40,12 @@ export const { clearResultsSelection, updateAnonymousPerformanceResults } = resultsSlice.actions; + +// Thunk action creator +export const updateResults = (payload: ResultsState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setResults(payload)); +}; + // Selectors export const selectResults = (state: MesheryRootState) => state.results; export default resultsSlice.reducer; diff --git a/src/redux-toolkit/slices/staticPrometheusBoardConfigSlice.ts b/src/redux-toolkit/slices/staticPrometheusBoardConfigSlice.ts index ea355a1d..1dd79248 100644 --- a/src/redux-toolkit/slices/staticPrometheusBoardConfigSlice.ts +++ b/src/redux-toolkit/slices/staticPrometheusBoardConfigSlice.ts @@ -1,12 +1,10 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; -// State interface -export interface StaticPrometheusBoardConfigState { - [key: string]: any; -} -// Initial state +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; + +export interface StaticPrometheusBoardConfigState {} + const initialState: StaticPrometheusBoardConfigState = {}; -// Slice + const staticPrometheusBoardConfigSlice = createSlice({ name: 'staticPrometheusBoardConfig', initialState, @@ -45,6 +43,7 @@ const staticPrometheusBoardConfigSlice = createSlice({ } } }); + // Actions export const { setStaticPrometheusBoardConfig, @@ -54,6 +53,13 @@ export const { updateStaticBoardConfig, updateLoadGenConfig } = staticPrometheusBoardConfigSlice.actions; + +// Thunk action creator +export const updateStaticPrometheusBoardConfig = + (payload: StaticPrometheusBoardConfigState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setStaticPrometheusBoardConfig(payload)); + }; + // Selectors export const selectStaticPrometheusBoardConfig = (state: MesheryRootState) => state.staticPrometheusBoardConfig; diff --git a/src/redux-toolkit/slices/telemetryURLsSlice.ts b/src/redux-toolkit/slices/telemetryURLsSlice.ts index 0c051c2c..48cb1789 100644 --- a/src/redux-toolkit/slices/telemetryURLsSlice.ts +++ b/src/redux-toolkit/slices/telemetryURLsSlice.ts @@ -1,15 +1,16 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; -// State interface +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; + export interface TelemetryURLsState { - [key: string]: any; + grafana: any[]; + prometheus: any[]; } -// Initial state + const initialState: TelemetryURLsState = { grafana: [], prometheus: [] }; -// Slice + const telemetryURLsSlice = createSlice({ name: 'telemetryURLs', initialState, @@ -23,8 +24,16 @@ const telemetryURLsSlice = createSlice({ } } }); + // Actions export const { setTelemetryURLs, updateTelemetryUrls } = telemetryURLsSlice.actions; + +// Thunk action creator +export const updateTelemetryURLs = + (payload: TelemetryURLsState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setTelemetryURLs(payload)); + }; + // Selectors export const selectTelemetryURLs = (state: MesheryRootState) => state.telemetryURLs; export default telemetryURLsSlice.reducer; diff --git a/src/redux-toolkit/slices/userSlice.ts b/src/redux-toolkit/slices/userSlice.ts index fa7928cd..43c2d569 100644 --- a/src/redux-toolkit/slices/userSlice.ts +++ b/src/redux-toolkit/slices/userSlice.ts @@ -1,9 +1,7 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; -export interface UserState { - [key: string]: any; -} +export interface UserState {} const initialState: UserState = {}; @@ -21,7 +19,12 @@ const userSlice = createSlice({ } }); -export const { setUser, updateUser } = userSlice.actions; +export const { setUser } = userSlice.actions; + +// Thunk action creator +export const updateUser = (payload: UserState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setUser(payload)); +}; // Selectors export const selectUser = (state: MesheryRootState) => state.user; diff --git a/src/redux-toolkit/slices/workspaceSlice.ts b/src/redux-toolkit/slices/workspaceSlice.ts index 93a7807b..c096e2d7 100644 --- a/src/redux-toolkit/slices/workspaceSlice.ts +++ b/src/redux-toolkit/slices/workspaceSlice.ts @@ -1,30 +1,35 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'; -import type { MesheryRootState } from '../store'; +import type { MesheryReduxAppDispatch, MesheryRootState } from '../store'; export interface WorkspaceState { - [key: string]: any; + value: any; } -const initialState: WorkspaceState = null; +const initialState: WorkspaceState = { value: null }; const workspaceSlice = createSlice({ name: 'workspace', initialState, reducers: { + setWorkspace: (state, action: PayloadAction) => { + return action.payload; + } /* - setWorkspace: (state, action: PayloadAction) => { - return action.payload; - }, - */ setWorkspace: (state: WorkspaceState, action: PayloadAction) => { // TODO: Implement reducer logic for SET_WORKSPACE return state; } + */ } }); export const { setWorkspace } = workspaceSlice.actions; +// Thunk action creator +export const updateWorkspace = (payload: WorkspaceState) => (dispatch: MesheryReduxAppDispatch) => { + dispatch(setWorkspace(payload)); +}; + // Selectors export const selectWorkspace = (state: MesheryRootState) => state.workspace; export default workspaceSlice.reducer;