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

refactor(app): Refactor display name utils #16537

Merged
merged 2 commits into from
Oct 18, 2024
Merged

Conversation

mjhuff
Copy link
Contributor

@mjhuff mjhuff commented Oct 18, 2024

Closes EXEC-773

Overview

Now that we have a definitive locations for general app utils, all general utilities should now be imported through places like local-resources and not from the internals of component directories. One of the biggest culprits of violating this rule is Commands. We use a lot of these utilities elsewhere.

This PR serves as a general refactor for display name utils, which entails:

  • Migrating them to local-resources
  • Tightening the interfaces. More specifically, instead of passing all of protocolAnalysis, pass only what we need.
  • The above has the added benefit of highlighting potential problem parameters, ie, commands. I actually caught a couple more unnecessary cases of iterating through protocolAnalysis, so this refactor reduces TC by O(2n) in some spots.
  • The above also enforces stricter typing - there are actually a couple spots that could cause whitescreens on older protocols, because we weren't properly typechecking protocolAnalysis before attempting to iterate through modules or labware when it could in fact be an object and not an array. I guess in practice, this probably doesn't happen much, since I've personally never seen any tickets about this.

04b6ad3 Contains the functional changes.

d350e0d is just a million lint/test fixes.

Test Plan and Hands on Testing

  • Smoke tested runs. Everything looks good.

Risk assessment

lowish-medium.

@mjhuff mjhuff requested a review from a team as a code owner October 18, 2024 18:17
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know we're in a good place when we're using Array.isArray

Good finds on removing more command iteration!

@@ -1,4 +1,5 @@
import { getAllDefinitions } from '@opentrons/shared-data'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added by mistake?

Copy link
Contributor Author

@mjhuff mjhuff Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's intentional.

This is documented somewhere on confluence, but generally we have a pattern in the monorepo for js import order:

  1. Global imports
  2. Top-level monorepo imports
  3. Local imports
  4. Types

These should be separated by a space.

Copy link
Contributor

@TamarZanzouri TamarZanzouri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WOW! so much better! 1 unintentional change but besides that looks great

@mjhuff mjhuff merged commit dc1e40b into edge Oct 18, 2024
36 checks passed
@mjhuff mjhuff deleted the app_move-display-utils branch October 18, 2024 19:14
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