-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(app): Refactor display name utils (#16537)
Closes EXEC-773 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 commit 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.
- Loading branch information
Showing
103 changed files
with
433 additions
and
334 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
app/src/local-resources/commands/hooks/useCommandTextString/utils/getLiquidDisplayName.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { Liquid } from '@opentrons/shared-data' | ||
|
||
export function getLiquidDisplayName( | ||
liquids: Liquid[], | ||
liquidId: string | ||
): string { | ||
const liquidDisplayName = liquids.find(liquid => liquid.id === liquidId) | ||
?.displayName | ||
return liquidDisplayName ?? '' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ToAddressabelAreaForDropTipCommandText.ts → ...ToAddressabelAreaForDropTipCommandText.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ls/getMoveToAddressableAreaCommandText.ts → ...ls/getMoveToAddressableAreaCommandText.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/src/local-resources/commands/hooks/useCommandTextString/utils/getPipetteNameOnMount.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { getLoadedPipette } from '/app/local-resources/instruments' | ||
|
||
import type { PipetteName } from '@opentrons/shared-data' | ||
import type { LoadedPipettes } from '/app/local-resources/instruments/types' | ||
|
||
export function getPipetteNameOnMount( | ||
loadedPipettes: LoadedPipettes, | ||
mount: string | ||
): PipetteName | null { | ||
const loadedPipette = getLoadedPipette(loadedPipettes, mount) | ||
return loadedPipette != null ? loadedPipette.pipetteName : null | ||
} |
Oops, something went wrong.