summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuchita Lad2025-03-25 11:11:49 +0530
committerSuchita Lad2025-03-25 15:19:21 +0530
commite1a7e3fa2d77c8d3d2e658fd3a0e5f75441ee876 (patch)
treea022dbd66d451c99fe8ef08189df2d4e6fbf1c6c
parent6a29c484e21bf1aff7cbf090ccba0e7381100fcd (diff)
downloadCommon-Interface-Project-e1a7e3fa2d77c8d3d2e658fd3a0e5f75441ee876.tar.gz
Common-Interface-Project-e1a7e3fa2d77c8d3d2e658fd3a0e5f75441ee876.tar.bz2
Common-Interface-Project-e1a7e3fa2d77c8d3d2e658fd3a0e5f75441ee876.zip
Updated redux toolkit files
-rw-r--r--blocks/eda-frontend/package-lock.json51
-rw-r--r--blocks/eda-frontend/package.json1
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/SimulationProperties.js11
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js9
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js3
-rw-r--r--blocks/eda-frontend/src/redux/actions/index.js1
-rw-r--r--blocks/eda-frontend/src/redux/actions/simulationActions.js50
-rw-r--r--blocks/eda-frontend/src/redux/reducers/simulationReducer.js55
-rw-r--r--blocks/eda-frontend/src/redux/simulationSlice.js47
-rw-r--r--blocks/eda-frontend/src/redux/store.js16
10 files changed, 125 insertions, 119 deletions
diff --git a/blocks/eda-frontend/package-lock.json b/blocks/eda-frontend/package-lock.json
index 51765163..04155da6 100644
--- a/blocks/eda-frontend/package-lock.json
+++ b/blocks/eda-frontend/package-lock.json
@@ -11,6 +11,7 @@
"@material-ui/core": "^4.9.11",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.52",
+ "@reduxjs/toolkit": "^2.6.1",
"axios": "^1.8.3",
"canvg": "^4.0.3",
"file-saver": "^2.0.5",
@@ -3528,6 +3529,51 @@
"url": "https://opencollective.com/webpack"
}
},
+ "node_modules/@reduxjs/toolkit": {
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.6.1.tgz",
+ "integrity": "sha512-SSlIqZNYhqm/oMkXbtofwZSt9lrncblzo6YcZ9zoX+zLngRBrCOjK4lNLdkNucJF58RHOWrD9txT3bT3piH7Zw==",
+ "dependencies": {
+ "immer": "^10.0.3",
+ "redux": "^5.0.1",
+ "redux-thunk": "^3.1.0",
+ "reselect": "^5.1.0"
+ },
+ "peerDependencies": {
+ "react": "^16.9.0 || ^17.0.0 || ^18 || ^19",
+ "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0"
+ },
+ "peerDependenciesMeta": {
+ "react": {
+ "optional": true
+ },
+ "react-redux": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@reduxjs/toolkit/node_modules/immer": {
+ "version": "10.1.1",
+ "resolved": "https://registry.npmjs.org/immer/-/immer-10.1.1.tgz",
+ "integrity": "sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/immer"
+ }
+ },
+ "node_modules/@reduxjs/toolkit/node_modules/redux": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
+ "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w=="
+ },
+ "node_modules/@reduxjs/toolkit/node_modules/redux-thunk": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz",
+ "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==",
+ "peerDependencies": {
+ "redux": "^5.0.0"
+ }
+ },
"node_modules/@rollup/plugin-babel": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz",
@@ -17016,6 +17062,11 @@
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",
"dev": true
},
+ "node_modules/reselect": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz",
+ "integrity": "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w=="
+ },
"node_modules/resolve": {
"version": "1.22.8",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz",
diff --git a/blocks/eda-frontend/package.json b/blocks/eda-frontend/package.json
index 9d38b910..664b701b 100644
--- a/blocks/eda-frontend/package.json
+++ b/blocks/eda-frontend/package.json
@@ -7,6 +7,7 @@
"@material-ui/core": "^4.9.11",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.52",
+ "@reduxjs/toolkit": "^2.6.1",
"axios": "^1.8.3",
"canvg": "^4.0.3",
"file-saver": "^2.0.5",
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/SimulationProperties.js b/blocks/eda-frontend/src/components/SchematicEditor/SimulationProperties.js
index 05216811..30384440 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/SimulationProperties.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/SimulationProperties.js
@@ -15,10 +15,17 @@ import ExpandMoreIcon from '@material-ui/icons/ExpandMore'
import { makeStyles } from '@material-ui/core/styles'
import { useSelector, useDispatch } from 'react-redux'
-import { setResultTitle, setResultTaskId } from '../../redux/actions/index'
+// import { setResultTitle, setResultTaskId } from '../../redux/actions/index'
import { saveXml } from './Helper/ToolbarTools'
import SimulationScreen, { setGraphStatusClosed } from './SimulationScreen'
import api from '../../utils/Api'
+import {
+ setResultTitle,
+ setResultGraph,
+ setResultText,
+ setResultTaskId,
+ setScriptTaskId
+} from '../../redux/simulationSlice'
const useStyles = makeStyles((theme) => ({
toolbar: {
@@ -43,7 +50,7 @@ const useStyles = makeStyles((theme) => ({
export default function SimulationProperties () {
const title = useSelector(state => state.netlistReducer.title)
- const isSimRes = useSelector(state => state.simulationReducer.isSimRes)
+ const isSimRes = useSelector(state => state.simulation.isSimRes)
const dispatch = useDispatch()
const classes = useStyles()
const [transientAnalysisControlLine, setTransientAnalysisControlLine] = useState({
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js b/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js
index e9323e00..e2553512 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/SimulationScreen.js
@@ -7,7 +7,8 @@ import CloseIcon from '@material-ui/icons/Close'
import { useSelector, useDispatch } from 'react-redux'
import Graph, { setStatusDone, setStatusClosed } from '../Shared/Graph'
-import { setResultGraph } from '../../redux/actions/index'
+// import { setResultGraph } from '../../redux/actions/index'
+import { setResultGraph } from '../../redux/simulationSlice'
import api from '../../utils/Api'
let sse = null
@@ -112,10 +113,10 @@ export function setGraphStatusClosed () {
export default function SimulationScreen ({ open, close }) {
const classes = useStyles()
const dispatch = useDispatch()
- const isGraph = useSelector(state => state.simulationReducer.isGraph)
- const rtitle = useSelector(state => state.simulationReducer.title)
+ const isGraph = useSelector(state => state.simulation.isGraph)
+ const rtitle = useSelector(state => state.simulation.title)
const stitle = useSelector(state => state.netlistReducer.title)
- const taskId = useSelector(state => state.simulationReducer.taskId)
+ const taskId = useSelector(state => state.simulation.taskId)
const [isResult, setIsResult] = useState(false)
const graphsRef = useRef([])
const datapointsRef = useRef([])
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js b/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js
index 4cf64bf6..a336eade 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/ToolbarExtension.js
@@ -36,7 +36,8 @@ import {
import { makeStyles } from '@material-ui/core/styles'
import CloseIcon from '@material-ui/icons/Close'
import { useSelector, useDispatch } from 'react-redux'
-import { fetchSchematics, fetchSchematic, fetchDiagram, fetchGallery, setSchScriptDump, setScriptTaskId } from '../../redux/actions/index'
+import { fetchSchematics, fetchSchematic, fetchDiagram, fetchGallery, setSchScriptDump /* setScriptTaskId */ } from '../../redux/actions/index'
+import { setScriptTaskId } from '../../redux/simulationSlice'
import { blue } from '@material-ui/core/colors'
import { getDateTime as getDate, getUppercaseInitial, saveToFile } from '../../utils/GalleryUtils'
import api from '../../utils/Api'
diff --git a/blocks/eda-frontend/src/redux/actions/index.js b/blocks/eda-frontend/src/redux/actions/index.js
index b13059d3..dcbfcaf5 100644
--- a/blocks/eda-frontend/src/redux/actions/index.js
+++ b/blocks/eda-frontend/src/redux/actions/index.js
@@ -2,7 +2,6 @@
export * from './schematicEditorActions'
export * from './componentPropertiesActions'
export * from './netlistActions'
-export * from './simulationActions'
export * from './authActions'
export * from './saveSchematicActions'
export * from './dashboardActions'
diff --git a/blocks/eda-frontend/src/redux/actions/simulationActions.js b/blocks/eda-frontend/src/redux/actions/simulationActions.js
deleted file mode 100644
index 06a603b8..00000000
--- a/blocks/eda-frontend/src/redux/actions/simulationActions.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import * as actions from './actions'
-
-// Actions to update title for simulation result screen
-export const setResultTitle = (title) => (dispatch) => {
- dispatch({
- type: actions.SET_RESULT_TITLE,
- payload: {
- title
- }
- })
-}
-
-// Action to update store with graphical result points
-export const setResultGraph = (graph) => (dispatch) => {
- dispatch({
- type: actions.SET_RESULT_GRAPH,
- payload: {
- graph
- }
- })
-}
-
-// Action to update store with simulation result text
-export const setResultText = (text) => (dispatch) => {
- dispatch({
- type: actions.SET_RESULT_TEXT,
- payload: {
- text
- }
- })
-}
-
-// Actions to update task id for simulation result screen
-export const setResultTaskId = (taskId) => (dispatch) => {
- dispatch({
- type: actions.SET_RESULT_TASK_ID,
- payload: {
- taskId
- }
- })
-}
-
-export const setScriptTaskId = (scriptTaskId) => (dispatch) => {
- dispatch({
- type: actions.SET_SCRIPT_TASK_ID,
- payload: {
- scriptTaskId
- }
- })
-}
diff --git a/blocks/eda-frontend/src/redux/reducers/simulationReducer.js b/blocks/eda-frontend/src/redux/reducers/simulationReducer.js
deleted file mode 100644
index 08b3c2d2..00000000
--- a/blocks/eda-frontend/src/redux/reducers/simulationReducer.js
+++ /dev/null
@@ -1,55 +0,0 @@
-import * as actions from '../actions/actions'
-
-const initialState = {
- title: '',
- isGraph: 'false',
- text: [],
- graph: {},
- isSimRes: false,
- taskId: ''
-}
-
-export default function (state = initialState, action) {
- switch (action.type) {
- case actions.SET_RESULT_TITLE: {
- return {
- ...state,
- title: action.payload.title
- }
- }
- case actions.SET_RESULT_GRAPH: {
- return {
- ...state,
- isSimRes: true,
- isGraph: 'true',
- graph: action.payload.graph
- }
- }
-
- case actions.SET_RESULT_TEXT: {
- return {
- ...state,
- isSimRes: true,
- isGraph: 'false',
- text: action.payload.text
- }
- }
-
- case actions.SET_RESULT_TASK_ID: {
- return {
- ...state,
- taskId: action.payload.taskId
- }
- }
-
- case actions.SET_SCRIPT_TASK_ID: {
- return {
- ...state,
- scriptTaskId: action.payload.taskId
- }
- }
-
- default:
- return state
- }
-}
diff --git a/blocks/eda-frontend/src/redux/simulationSlice.js b/blocks/eda-frontend/src/redux/simulationSlice.js
new file mode 100644
index 00000000..e7b6a174
--- /dev/null
+++ b/blocks/eda-frontend/src/redux/simulationSlice.js
@@ -0,0 +1,47 @@
+import { createSlice } from "@reduxjs/toolkit";
+
+const initialState = {
+ title: "",
+ isGraph: false,
+ text: [],
+ graph: {},
+ isSimRes: false,
+ taskId: "",
+ scriptTaskId: "",
+};
+
+const simulationSlice = createSlice({
+ name: "simulation",
+ initialState,
+ reducers: {
+ setResultTitle: (state, action) => {
+ state.title = action.payload;
+ },
+ setResultGraph: (state, action) => {
+ state.isSimRes = true;
+ state.isGraph = true;
+ state.graph = action.payload;
+ },
+ setResultText: (state, action) => {
+ state.isSimRes = true;
+ state.isGraph = false;
+ state.text = action.payload;
+ },
+ setResultTaskId: (state, action) => {
+ state.taskId = action.payload;
+ },
+ setScriptTaskId: (state, action) => {
+ state.scriptTaskId = action.payload;
+ },
+ },
+});
+
+export const {
+ setResultTitle,
+ setResultGraph,
+ setResultText,
+ setResultTaskId,
+ setScriptTaskId,
+} = simulationSlice.actions;
+
+export default simulationSlice.reducer;
diff --git a/blocks/eda-frontend/src/redux/store.js b/blocks/eda-frontend/src/redux/store.js
index 1ca6ceda..c3131239 100644
--- a/blocks/eda-frontend/src/redux/store.js
+++ b/blocks/eda-frontend/src/redux/store.js
@@ -1,8 +1,12 @@
-// Initialize Redux store which holds the whole state tree of application.
-import reducer from './reducers/index'
-import { createStore, applyMiddleware } from 'redux'
-import reduxThunk from 'redux-thunk'
-const createStoreWithMiddleware = applyMiddleware(reduxThunk)(createStore)
-const store = createStoreWithMiddleware(reducer)
+import { configureStore } from '@reduxjs/toolkit'
+import simulationReducer from './simulationSlice'
+import thunk from 'redux-thunk'
+
+const store = configureStore({
+ reducer: {
+ simulation: simulationReducer
+ },
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(thunk)
+})
export default store