Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create slices for meshery ui #851

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
49 changes: 49 additions & 0 deletions src/redux-toolkit/slices/anonymousPerfResultsSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import type { MesheryRootState } from '../store';
export interface AnonymousPerfResultsState {
value: boolean;
}

const initialState: AnonymousPerfResultsState = { value: false };

const anonymousPerfResultsSlice = createSlice({
name: 'anonymousPerfResults',
initialState,
reducers: {
setAnonymousPerfResults: (state, action: PayloadAction<AnonymousPerfResultsState>) => {
return action.payload;
},
updateResultsSelection: (state: AnonymousPerfResultsState, action: PayloadAction<any>) => {

Check failure on line 16 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (16)

'action' is defined but never used

Check failure on line 16 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (16)

Unexpected any. Specify a different type

Check failure on line 16 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (18)

'action' is defined but never used

Check failure on line 16 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unexpected any. Specify a different type

Check failure on line 16 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (20)

'action' is defined but never used

Check failure on line 16 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
// TODO: Implement reducer logic for UPDATE_RESULTS_SELECTION
return state;
},
clearResultsSelection: (state: AnonymousPerfResultsState, action: PayloadAction<any>) => {

Check failure on line 20 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (16)

'action' is defined but never used

Check failure on line 20 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (16)

Unexpected any. Specify a different type

Check failure on line 20 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (18)

'action' is defined but never used

Check failure on line 20 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unexpected any. Specify a different type

Check failure on line 20 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (20)

'action' is defined but never used

Check failure on line 20 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
// TODO: Implement reducer logic for CLEAR_RESULTS_SELECTION
return state;
},
updateAnonymousUsageStats: (state: AnonymousPerfResultsState, action: PayloadAction<any>) => {

Check failure on line 24 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (16)

'action' is defined but never used

Check failure on line 24 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (16)

Unexpected any. Specify a different type

Check failure on line 24 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (18)

'action' is defined but never used

Check failure on line 24 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unexpected any. Specify a different type

Check failure on line 24 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (20)

'action' is defined but never used

Check failure on line 24 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
// TODO: Implement reducer logic for UPDATE_ANONYMOUS_USAGE_STATS
return state;
},
updateAnonymousPerformanceResults: (
state: AnonymousPerfResultsState,
action: PayloadAction<any>

Check failure on line 30 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (16)

'action' is defined but never used

Check failure on line 30 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (16)

Unexpected any. Specify a different type

Check failure on line 30 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (18)

'action' is defined but never used

Check failure on line 30 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unexpected any. Specify a different type

Check failure on line 30 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (20)

'action' is defined but never used

Check failure on line 30 in src/redux-toolkit/slices/anonymousPerfResultsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
) => {
// 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;
45 changes: 45 additions & 0 deletions src/redux-toolkit/slices/anonymousUsageStatsSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import type { MesheryReduxAppDispatch, MesheryRootState } from '../store';

export interface AnonymousUsageStatsState {
value: boolean;
}

const initialState: AnonymousUsageStatsState = { value: false };

const anonymousUsageStatsSlice = createSlice({
name: 'anonymousUsageStats',
initialState,
reducers: {
setAnonymousUsageStats: (state, action: PayloadAction<AnonymousUsageStatsState>) => {
return action.payload;
},
updateAnonymousUsageStats: (state: AnonymousUsageStatsState, action: PayloadAction<any>) => {

Check failure on line 17 in src/redux-toolkit/slices/anonymousUsageStatsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (16)

'action' is defined but never used

Check failure on line 17 in src/redux-toolkit/slices/anonymousUsageStatsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (16)

Unexpected any. Specify a different type

Check failure on line 17 in src/redux-toolkit/slices/anonymousUsageStatsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (18)

'action' is defined but never used

Check failure on line 17 in src/redux-toolkit/slices/anonymousUsageStatsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Unexpected any. Specify a different type

Check failure on line 17 in src/redux-toolkit/slices/anonymousUsageStatsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (20)

'action' is defined but never used

Check failure on line 17 in src/redux-toolkit/slices/anonymousUsageStatsSlice.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
// TODO: Implement reducer logic for UPDATE_ANONYMOUS_USAGE_STATS
return state;
},
updateAnonymousPerformanceResults: (
state: AnonymousUsageStatsState,
action: PayloadAction<any>
) => {
// TODO: Implement reducer logic for UPDATE_ANONYMOUS_PERFORMANCE_RESULTS
return state;
}
}
});
// Actions
export const {
setAnonymousUsageStats,
// 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;
23 changes: 23 additions & 0 deletions src/redux-toolkit/slices/cSlice.ts
Original file line number Diff line number Diff line change
@@ -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<CState>) => {
return action.payload;
}
}
});
// Actions
export const { setC } = cSlice.actions;
// Selectors
export const selectC = (state: MesheryRootState) => state.c;
export default cSlice.reducer;
30 changes: 30 additions & 0 deletions src/redux-toolkit/slices/capabilitiesRegistrySlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import type { MesheryRootState } from '../store';

export interface CapabilitiesRegistryState {
value: any;
}

const initialState: CapabilitiesRegistryState = { value: null };

const capabilitiesRegistrySlice = createSlice({
name: 'capabilitiesRegistry',
initialState,
reducers: {
setCapabilitiesRegistry: (state, action: PayloadAction<CapabilitiesRegistryState>) => {
return action.payload;
},
updateCapabilityRegistry: (state: CapabilitiesRegistryState, action: PayloadAction<any>) => {
// 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;
28 changes: 28 additions & 0 deletions src/redux-toolkit/slices/catalogVisibilitySlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import type { MesheryRootState } from '../store';
export interface CatalogVisibilityState {
value: boolean;
}

const initialState: CatalogVisibilityState = { value: false };

const catalogVisibilitySlice = createSlice({
name: 'catalogVisibility',
initialState,
reducers: {
setCatalogVisibility: (state, action: PayloadAction<CatalogVisibilityState>) => {
return action.payload;
},
setCatalogContent: (state: CatalogVisibilityState, action: PayloadAction<any>) => {
// 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;
43 changes: 43 additions & 0 deletions src/redux-toolkit/slices/connectionMetadataStateSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import type { MesheryRootState } from '../store';

export interface ConnectionMetadataStateState {
value: any;
}

const initialState: ConnectionMetadataStateState = { value: null };

const connectionMetadataStateSlice = createSlice({
name: 'connectionMetadataState',
initialState,
reducers: {
setConnectionMetadataState: (state, action: PayloadAction<ConnectionMetadataStateState>) => {
return action.payload;
},
updateLoadTestData: (state: ConnectionMetadataStateState, action: PayloadAction<any>) => {
// TODO: Implement reducer logic for UPDATE_LOAD_TEST_DATA
return state;
},
setControllerState: (state: ConnectionMetadataStateState, action: PayloadAction<any>) => {
// TODO: Implement reducer logic for SET_CONTROLLER_STATE
return state;
},
setConnectionMetadata: (state: ConnectionMetadataStateState, action: PayloadAction<any>) => {
// 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;
30 changes: 30 additions & 0 deletions src/redux-toolkit/slices/controllerStateSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import type { MesheryRootState } from '../store';
export interface ControllerStateState {
value: any;
}

const initialState: ControllerStateState = { value: null };

const controllerStateSlice = createSlice({
name: 'controllerState',
initialState,
reducers: {
setControllerState: (state, action: PayloadAction<ControllerStateState>) => {
return action.payload;
}
/*
setControllerState: (state: ControllerStateState, action: PayloadAction<any>) => {
// TODO: Implement reducer logic for SET_CONTROLLER_STATE
return state;
}
*/
}
});

// Actions
export const { setControllerState } = controllerStateSlice.actions;

// Selectors
export const selectControllerState = (state: MesheryRootState) => state.controllerState;
export default controllerStateSlice.reducer;
25 changes: 25 additions & 0 deletions src/redux-toolkit/slices/eventsSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import type { MesheryRootState } from '../store';

export interface EventsState {
items: any[];
}

const initialState: EventsState = { items: [] };

const eventsSlice = createSlice({
name: 'events',
initialState,
reducers: {
setEvents: (state, action: PayloadAction<EventsState>) => {
return action.payload;
}
}
});

// Actions
export const { setEvents } = eventsSlice.actions;

// Selectors
export const selectEvents = (state: MesheryRootState) => state.events;
export default eventsSlice.reducer;
35 changes: 35 additions & 0 deletions src/redux-toolkit/slices/extensionTypeSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import type { MesheryReduxAppDispatch, MesheryRootState } from '../store';

export interface ExtensionTypeState {
value: string;
}

const initialState: ExtensionTypeState = { value: '' };

const extensionTypeSlice = createSlice({
name: 'extensionType',
initialState,
reducers: {
setExtensionType: (state, action: PayloadAction<ExtensionTypeState>) => {
return action.payload;
},
updateExtensionType: (state: ExtensionTypeState, action: PayloadAction<any>) => {
// TODO: Implement reducer logic for UPDATE_EXTENSION_TYPE
return state;
}
}
});

// 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;
Loading
Loading