Refactor Redux for Files in reducers,actions and components etc #3398
+306
−381
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2042
Changes:
This pull request improves Redux state management by removing outdated ActionTypes from client/constants.js and replacing their usage with direct action creators from createSlice. It ensures that Redux state handling aligns with best practices from @reduxjs/toolkit, making the codebase more maintainable, modular, and efficient.
After reviewing referenced pull requests (#3121 - #3127), I found that Redux modernization was not fully applied in the base creation of slices. Some files still relied on ActionTypes, leading to inconsistencies in state management. This PR standardizes Redux implementation, removes unnecessary boilerplate, and optimizes the flow of state updates.
Key Changes & Improvements
Removed Outdated ActionTypes from client/constants.js
Eliminated unused Redux action type constants that were previously used for defining actions.
Replaced all occurrences of ActionTypes in various files with actions from createSlice.
Ensured that all Redux logic now uses a structured slice-based approach instead of manually handling action types.
Refactored Core Redux-Dependent Files
The following files were updated to remove direct usage of ActionTypes and replace them with Redux slice actions:
client/modules/IDE/components/FileNode.jsx
Replaced connect and mapStateToProps with useSelector and useDispatch.
Updated all Redux state updates to use slice-based action dispatching.
Improved component readability by reducing dependency on Redux constants.
client/modules/IDE/components/FileNode.unit.test.jsx
Refactored unit tests to work with the new Redux slice-based state management.
Removed direct dispatch of ActionTypes and replaced them with properly imported action creators.
Verified that existing test cases pass successfully after migration.
client/modules/IDE/actions/project.js
Refactored all Redux action creators to use createSlice instead of manually returning action objects.
Ensured that the project-related state management aligns with Redux Toolkit standards.
Removed redundant logic that was previously required for handling raw action types.
client/modules/IDE/actions/files.js
Migrated all file-related Redux actions to use slice reducers and actions.
Improved code organization by consolidating related logic within slices.
Ensured seamless integration with components that depend on file actions.
Refactored State Management for Maintainability
Simplified the logic for dispatching actions by using slice-based reducers.
Ensured consistency across files that interact with Redux state.
Removed redundant Redux boilerplate, reducing unnecessary complexity.
I have verified that this pull request:
npm run lint
)npm run test
)develop
branch.Fixes #123