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

Story 233061: Clean up frontend #88

Merged
merged 13 commits into from
Feb 17, 2025
Merged

Conversation

NoraKri
Copy link
Contributor

@NoraKri NoraKri commented Feb 11, 2025

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

  • Bug fix
  • Refactor
  • New feature
  • Breaking change
  • This change requires a documentation update

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

  • Added TODOs in all files that can be removed when the new format and API is complete.

# 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
@markus-ap
Copy link
Contributor

markus-ap commented Feb 11, 2025

🎉 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)

Copy link
Contributor

@eoye eoye left a 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:

  1. In NodeTable.tsx, the property activePackage does not exist on the type
  2. In CommissioningPackageDispatchContext.ts, there is an error on PackageAction, as CommissioningPackageContextProvide does not export PackageAction

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 😄

@NoraKri NoraKri merged commit ec72dcf into main Feb 17, 2025
6 checks passed
@NoraKri NoraKri deleted the story/233061-clean-up-frontend branch February 17, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants