-
Notifications
You must be signed in to change notification settings - Fork 0
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
Story 233061: Clean up frontend #88
Conversation
…story/233061-clean-up-frontend
# Conflicts: # www/src/components/diagram/CenterLine.tsx # www/src/components/diagram/Equipment.tsx # www/src/components/diagram/LinesGraphicalDataExample.tsx # www/src/components/diagram/PandIdGraphicalDataExample.tsx # www/src/components/diagram/SymbolGraphicalDataExample.tsx # www/src/components/editor/Editor.tsx # www/src/components/editor/EditorSidebar.tsx
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) ✅ code/snyk check is complete. No issues have been found. (View Details) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really great cleanup!🤩 Thanks for adding TODO's for code we can remove when we have the new graphical format implemented! I found two errors when building the project:
- In
NodeTable.tsx
, the propertyactivePackage
does not exist on the type - In
CommissioningPackageDispatchContext.ts
, there is an error onPackageAction
, asCommissioningPackageContextProvide
does not exportPackageAction
I tried running the demo and clicked around testing a couple of thing, and it all worked with out any errors! So everything seems to work 😄
Aim of the PR
This PR fixes AB#233061
This PR aims to clean up the frontend code a bit.
Implementation
New context: The old commissioning package context has been replaced with a new context that uses a reducer. This is nice because a lot of the time, we want to make updates both to the active package and to the commissioning package list. The reducer is a function that takes in the current commissioning package state, and an action, and returns the new state. This way, instead of making sure we update the correct parts of the context everywhere in the app, the reducer takes care of it for us.
New context hook: We have a new hook, useCommissioningPackages, that returns the context and a dispatch. For read actions, we use the context, and for write actions, we use the dispatch.
CommissioningPackageActions: These are functions that both call the API and dispatch a reducer function. Use these in components when possible.
Helper functions: Some new helper functions are created to avoid duplicating so much code.
Type of change
If the changes impact any dependent services then provide details.
How Has This Been Tested?
Please describe the tests that you ran to verify that your changes works as expected.
Additional Changes