From dc1e40bdda6729eda77b6e5f14e2e3706f269864 Mon Sep 17 00:00:00 2001 From: Jamey Huffnagle Date: Fri, 18 Oct 2024 15:14:20 -0400 Subject: [PATCH] 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. --- .../commands}/hooks/index.ts | 0 .../hooks/useCommandTextString/index.tsx | 2 +- .../__tests__/getFinalLabwareLocation.test.ts | 0 .../utils/getAbsorbanceReaderCommandText.ts | 0 .../utils/getAddressableAreaDisplayName.ts | 3 +- .../utils/getCommentCommandText.ts | 0 .../utils/getConfigureForVolumeCommandText.ts | 0 .../getConfigureNozzleLayoutCommandText.ts | 0 .../utils/getCustomCommandText.ts | 0 .../utils/getDelayCommandText.ts | 0 .../utils/getDirectTranslationCommandText.ts | 0 .../utils/getFinalLabwareLocation.ts | 0 .../utils/getHSShakeSpeedCommandText.ts | 0 .../utils/getLiquidDisplayName.ts | 10 +++ .../utils/getLiquidProbeCommandText.ts | 31 ++++---- .../utils/getLoadCommandText.ts | 43 ++++++++--- .../utils/getMoveLabwareCommandText.ts | 65 ++++++++-------- .../utils/getMoveRelativeCommandText.ts | 0 ...eToAddressabelAreaForDropTipCommandText.ts | 2 +- .../getMoveToAddressableAreaCommandText.ts | 2 +- .../utils/getMoveToCoordinatesCommandText.ts | 0 .../utils/getMoveToSlotCommandText.ts | 0 .../utils/getMoveToWellCommandText.ts | 33 ++++---- .../utils/getPipetteNameOnMount.ts | 12 +++ .../utils/getPipettingCommandText.ts | 75 +++++++++++++------ .../utils/getPrepareToAspirateCommandText.ts | 0 .../utils/getRailLightsCommandText.ts | 0 .../getTCRunExtendedProfileCommandText.ts | 0 .../utils/getTCRunProfileCommandText.ts | 0 .../utils/getTemperatureCommandText.ts | 0 .../utils/getUnknownCommandText.ts | 0 .../utils/getWaitForDurationCommandText.ts | 0 .../utils/getWaitForResumeCommandText.ts | 0 .../utils/getWellRange.ts | 0 .../hooks/useCommandTextString/utils/index.ts | 0 .../hooks/useCommandTextString/utils/types.ts | 0 app/src/local-resources/commands/index.ts | 4 + .../commands}/types.ts | 0 .../commands}/utils/getCommandTextData.ts | 2 +- .../local-resources/commands/utils/index.ts | 1 + app/src/local-resources/instruments/types.ts | 3 + app/src/local-resources/instruments/utils.ts | 13 ++++ app/src/local-resources/labware/types.ts | 3 + .../labware/utils/getAllDefinitions.ts | 7 +- .../labware/utils/getAllDefs.ts | 1 + .../getLabwareDefinitionsFromCommands.ts | 4 +- .../utils/getLabwareDisplayLocation.ts | 61 ++++++++++----- .../labware}/utils/getLabwareName.ts | 31 +++++--- .../labware/utils/getLoadedLabware.ts | 12 +++ .../local-resources/labware/utils/index.ts | 5 ++ app/src/local-resources/modules/index.ts | 5 +- app/src/local-resources/modules/types.ts | 3 + .../__tests__/getModuleImage.test.ts | 0 .../modules/utils/getLoadedModule.ts | 12 +++ .../modules/utils/getModuleDisplayLocation.ts | 11 +++ .../modules/{ => utils}/getModuleImage.ts | 0 .../modules/utils/getModuleModel.ts | 12 +++ .../{ => utils}/getModulePrepCommands.ts | 0 .../local-resources/modules/utils/index.ts | 5 ++ app/src/molecules/Command/Command.tsx | 13 ++-- .../molecules/Command/CommandText.stories.tsx | 6 ++ app/src/molecules/Command/CommandText.tsx | 6 +- .../molecules/Command/__fixtures__/index.ts | 2 +- .../Command/__tests__/CommandText.test.tsx | 2 +- app/src/molecules/Command/index.ts | 3 - app/src/molecules/Command/utils/accessors.ts | 39 ---------- .../Command/utils/getLiquidDisplayName.ts | 11 --- .../Command/utils/getModuleDisplayLocation.ts | 11 --- .../molecules/Command/utils/getModuleModel.ts | 12 --- .../Command/utils/getPipetteNameOnMount.ts | 12 --- app/src/molecules/Command/utils/index.ts | 10 --- .../CategorizedStepContent.tsx | 3 +- .../__tests__/ApplyHistoricOffsets.test.tsx | 4 +- .../organisms/ApplyHistoricOffsets/index.tsx | 2 +- .../CurrentOffsetsTable.tsx | 2 +- .../Desktop/Devices/RunPreview/index.tsx | 7 +- .../ProtocolDetails/AnnotatedSteps.tsx | 7 +- .../ProtocolTimelineScrubber/CommandItem.tsx | 2 +- .../ProtocolTimelineScrubber/index.tsx | 2 +- .../hooks/useRunProgressCopy.tsx | 9 +-- .../__tests__/ErrorRecoveryFlows.test.tsx | 4 +- .../__tests__/useFailedLabwareUtils.test.ts | 2 +- .../__tests__/useRecoveryToasts.test.tsx | 4 +- .../hooks/useFailedLabwareUtils.ts | 55 +++++++------- .../hooks/useRecoveryToasts.ts | 4 +- .../organisms/ErrorRecoveryFlows/index.tsx | 2 +- .../MoveLabwareInterventionContent.tsx | 16 ++-- .../utils/getLabwareNameFromRunData.ts | 8 +- .../getModuleDisplayLocationFromRunData.ts | 4 +- .../utils/getModuleModelFromRunData.ts | 4 +- .../LabwarePositionCheck/CheckItem.tsx | 2 +- .../IntroScreen/index.tsx | 2 +- .../LabwarePositionCheck/PickUpTip.tsx | 2 +- .../LabwarePositionCheck/ResultsSummary.tsx | 2 +- .../LabwarePositionCheck/ReturnTip.tsx | 2 +- .../LabwarePositionCheck/useLaunchLPC.tsx | 2 +- .../utils/getProbeBasedLPCSteps.ts | 2 +- .../utils/getTipBasedLPCSteps.ts | 2 +- .../LabwarePositionCheck/utils/labware.ts | 2 +- .../ProtocolSetupOffsets/index.tsx | 2 +- .../CurrentRunningProtocolCommand.tsx | 2 +- .../RunningProtocolCommandList.tsx | 2 +- app/src/pages/ODD/RunningProtocol/index.tsx | 2 +- 103 files changed, 433 insertions(+), 334 deletions(-) rename app/src/{molecules/Command => local-resources/commands}/hooks/index.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/index.tsx (99%) rename app/src/{molecules/Command => local-resources/commands/hooks/useCommandTextString}/utils/__tests__/getFinalLabwareLocation.test.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getAbsorbanceReaderCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands/hooks/useCommandTextString}/utils/getAddressableAreaDisplayName.ts (95%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getCommentCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getConfigureForVolumeCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getConfigureNozzleLayoutCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getCustomCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getDelayCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getDirectTranslationCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands/hooks/useCommandTextString}/utils/getFinalLabwareLocation.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getHSShakeSpeedCommandText.ts (100%) create mode 100644 app/src/local-resources/commands/hooks/useCommandTextString/utils/getLiquidDisplayName.ts rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getLiquidProbeCommandText.ts (70%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getLoadCommandText.ts (81%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getMoveLabwareCommandText.ts (58%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getMoveRelativeCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getMoveToAddressabelAreaForDropTipCommandText.ts (87%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getMoveToAddressableAreaCommandText.ts (87%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getMoveToCoordinatesCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getMoveToSlotCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getMoveToWellCommandText.ts (63%) create mode 100644 app/src/local-resources/commands/hooks/useCommandTextString/utils/getPipetteNameOnMount.ts rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getPipettingCommandText.ts (72%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getPrepareToAspirateCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getRailLightsCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getTCRunExtendedProfileCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getTCRunProfileCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getTemperatureCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getUnknownCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getWaitForDurationCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/getWaitForResumeCommandText.ts (100%) rename app/src/{molecules/Command => local-resources/commands/hooks/useCommandTextString}/utils/getWellRange.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/index.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/hooks/useCommandTextString/utils/types.ts (100%) create mode 100644 app/src/local-resources/commands/index.ts rename app/src/{molecules/Command => local-resources/commands}/types.ts (100%) rename app/src/{molecules/Command => local-resources/commands}/utils/getCommandTextData.ts (88%) create mode 100644 app/src/local-resources/commands/utils/index.ts create mode 100644 app/src/local-resources/instruments/types.ts rename app/src/{molecules/Command => local-resources/labware}/utils/getLabwareDefinitionsFromCommands.ts (94%) rename app/src/{molecules/Command => local-resources/labware}/utils/getLabwareDisplayLocation.ts (70%) rename app/src/{molecules/Command => local-resources/labware}/utils/getLabwareName.ts (50%) create mode 100644 app/src/local-resources/labware/utils/getLoadedLabware.ts create mode 100644 app/src/local-resources/modules/types.ts rename app/src/local-resources/modules/{ => utils}/__tests__/getModuleImage.test.ts (100%) create mode 100644 app/src/local-resources/modules/utils/getLoadedModule.ts create mode 100644 app/src/local-resources/modules/utils/getModuleDisplayLocation.ts rename app/src/local-resources/modules/{ => utils}/getModuleImage.ts (100%) create mode 100644 app/src/local-resources/modules/utils/getModuleModel.ts rename app/src/local-resources/modules/{ => utils}/getModulePrepCommands.ts (100%) create mode 100644 app/src/local-resources/modules/utils/index.ts delete mode 100644 app/src/molecules/Command/utils/accessors.ts delete mode 100644 app/src/molecules/Command/utils/getLiquidDisplayName.ts delete mode 100644 app/src/molecules/Command/utils/getModuleDisplayLocation.ts delete mode 100644 app/src/molecules/Command/utils/getModuleModel.ts delete mode 100644 app/src/molecules/Command/utils/getPipetteNameOnMount.ts delete mode 100644 app/src/molecules/Command/utils/index.ts diff --git a/app/src/molecules/Command/hooks/index.ts b/app/src/local-resources/commands/hooks/index.ts similarity index 100% rename from app/src/molecules/Command/hooks/index.ts rename to app/src/local-resources/commands/hooks/index.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/index.tsx b/app/src/local-resources/commands/hooks/useCommandTextString/index.tsx similarity index 99% rename from app/src/molecules/Command/hooks/useCommandTextString/index.tsx rename to app/src/local-resources/commands/hooks/useCommandTextString/index.tsx index d203595e112..3966a1bc7f4 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/index.tsx +++ b/app/src/local-resources/commands/hooks/useCommandTextString/index.tsx @@ -7,12 +7,12 @@ import type { RobotType, LabwareDefinition2, } from '@opentrons/shared-data' -import type { CommandTextData } from '../../types' import type { GetDirectTranslationCommandText } from './utils/getDirectTranslationCommandText' import type { TCProfileStepText, TCProfileCycleText, } from './utils/getTCRunExtendedProfileCommandText' +import type { CommandTextData } from '/app/local-resources/commands/types' export interface UseCommandTextStringParams { command: RunTimeCommand | null diff --git a/app/src/molecules/Command/utils/__tests__/getFinalLabwareLocation.test.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/__tests__/getFinalLabwareLocation.test.ts similarity index 100% rename from app/src/molecules/Command/utils/__tests__/getFinalLabwareLocation.test.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/__tests__/getFinalLabwareLocation.test.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getAbsorbanceReaderCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getAbsorbanceReaderCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getAbsorbanceReaderCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getAbsorbanceReaderCommandText.ts diff --git a/app/src/molecules/Command/utils/getAddressableAreaDisplayName.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getAddressableAreaDisplayName.ts similarity index 95% rename from app/src/molecules/Command/utils/getAddressableAreaDisplayName.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getAddressableAreaDisplayName.ts index 6bfdd2fc850..20d7c6cca07 100644 --- a/app/src/molecules/Command/utils/getAddressableAreaDisplayName.ts +++ b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getAddressableAreaDisplayName.ts @@ -3,7 +3,8 @@ import type { MoveToAddressableAreaParams, } from '@opentrons/shared-data' import type { TFunction } from 'i18next' -import type { CommandTextData } from '../types' + +import type { CommandTextData } from '/app/local-resources/commands' export function getAddressableAreaDisplayName( commandTextData: CommandTextData, diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getCommentCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getCommentCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getCommentCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getCommentCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getConfigureForVolumeCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getConfigureForVolumeCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getConfigureForVolumeCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getConfigureForVolumeCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getConfigureNozzleLayoutCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getConfigureNozzleLayoutCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getConfigureNozzleLayoutCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getConfigureNozzleLayoutCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getCustomCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getCustomCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getCustomCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getCustomCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getDelayCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getDelayCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getDelayCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getDelayCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getDirectTranslationCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getDirectTranslationCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getDirectTranslationCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getDirectTranslationCommandText.ts diff --git a/app/src/molecules/Command/utils/getFinalLabwareLocation.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getFinalLabwareLocation.ts similarity index 100% rename from app/src/molecules/Command/utils/getFinalLabwareLocation.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getFinalLabwareLocation.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getHSShakeSpeedCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getHSShakeSpeedCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getHSShakeSpeedCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getHSShakeSpeedCommandText.ts diff --git a/app/src/local-resources/commands/hooks/useCommandTextString/utils/getLiquidDisplayName.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getLiquidDisplayName.ts new file mode 100644 index 00000000000..2fcec940a55 --- /dev/null +++ b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getLiquidDisplayName.ts @@ -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 ?? '' +} diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getLiquidProbeCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getLiquidProbeCommandText.ts similarity index 70% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getLiquidProbeCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getLiquidProbeCommandText.ts index 7a08695b34f..171667012fe 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/utils/getLiquidProbeCommandText.ts +++ b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getLiquidProbeCommandText.ts @@ -1,8 +1,8 @@ import { - getFinalLabwareLocation, - getLabwareDisplayLocation, getLabwareName, -} from '../../../utils' + getLabwareDisplayLocation, +} from '/app/local-resources/labware' +import { getFinalLabwareLocation } from './getFinalLabwareLocation' import type { LiquidProbeRunTimeCommand, @@ -10,7 +10,6 @@ import type { TryLiquidProbeRunTimeCommand, } from '@opentrons/shared-data' import type { HandlesCommands } from './types' -import type { TFunction } from 'i18next' type LiquidProbeRunTimeCommands = | LiquidProbeRunTimeCommand @@ -38,20 +37,22 @@ export function getLiquidProbeCommandText({ ) : null - const displayLocation = - labwareLocation != null && commandTextData != null - ? getLabwareDisplayLocation( - commandTextData, - allRunDefs, - labwareLocation, - t as TFunction, - robotType - ) - : '' + const displayLocation = getLabwareDisplayLocation({ + loadedLabwares: commandTextData?.labware ?? [], + location: labwareLocation, + robotType, + allRunDefs, + loadedModules: commandTextData?.modules ?? [], + t, + }) const labware = commandTextData != null - ? getLabwareName(commandTextData, labwareId as string) + ? getLabwareName({ + loadedLabwares: commandTextData?.labware ?? [], + labwareId, + allRunDefs, + }) : null return t('detect_liquid_presence', { diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getLoadCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getLoadCommandText.ts similarity index 81% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getLoadCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getLoadCommandText.ts index e28d52f3959..d8ab8736e08 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/utils/getLoadCommandText.ts +++ b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getLoadCommandText.ts @@ -5,13 +5,14 @@ import { getPipetteSpecsV2, } from '@opentrons/shared-data' +import { getPipetteNameOnMount } from './getPipetteNameOnMount' +import { getLiquidDisplayName } from './getLiquidDisplayName' + +import { getLabwareName } from '/app/local-resources/labware' import { - getLabwareName, - getPipetteNameOnMount, getModuleModel, getModuleDisplayLocation, - getLiquidDisplayName, -} from '../../../utils' +} from '/app/local-resources/modules' import type { LoadLabwareRunTimeCommand } from '@opentrons/shared-data' import type { GetCommandText } from '..' @@ -21,12 +22,16 @@ export const getLoadCommandText = ({ commandTextData, robotType, t, + allRunDefs, }: GetCommandText): string => { switch (command?.commandType) { case 'loadPipette': { const pipetteModel = commandTextData != null - ? getPipetteNameOnMount(commandTextData, command.params.mount) + ? getPipetteNameOnMount( + commandTextData.pipettes, + command.params.mount + ) : null return t('load_pipette_protocol_setup', { pipette_name: @@ -54,7 +59,10 @@ export const getLoadCommandText = ({ ) { const moduleModel = commandTextData != null - ? getModuleModel(commandTextData, command.params.location.moduleId) + ? getModuleModel( + commandTextData.modules ?? [], + command.params.location.moduleId + ) : null const moduleName = moduleModel != null ? getModuleDisplayName(moduleModel) : '' @@ -71,7 +79,7 @@ export const getLoadCommandText = ({ slot_name: commandTextData != null ? getModuleDisplayLocation( - commandTextData, + commandTextData.modules ?? [], command.params.location.moduleId ) : null, @@ -105,7 +113,10 @@ export const getLoadCommandText = ({ } else if (adapterLoc != null && 'moduleId' in adapterLoc) { const moduleModel = commandTextData != null - ? getModuleModel(commandTextData, adapterLoc?.moduleId ?? '') + ? getModuleModel( + commandTextData.modules ?? [], + adapterLoc?.moduleId ?? '' + ) : null const moduleName = moduleModel != null ? getModuleDisplayName(moduleModel) : '' @@ -116,7 +127,7 @@ export const getLoadCommandText = ({ slot_name: commandTextData != null ? getModuleDisplayLocation( - commandTextData, + commandTextData.modules ?? [], adapterLoc?.moduleId ?? '' ) : null, @@ -144,7 +155,11 @@ export const getLoadCommandText = ({ const { labwareId } = command.params const labware = commandTextData != null - ? getLabwareName(commandTextData, labwareId) + ? getLabwareName({ + loadedLabwares: commandTextData?.labware ?? [], + labwareId, + allRunDefs, + }) : null return t('reloading_labware', { labware }) } @@ -153,11 +168,15 @@ export const getLoadCommandText = ({ return t('load_liquids_info_protocol_setup', { liquid: commandTextData != null - ? getLiquidDisplayName(commandTextData, liquidId) + ? getLiquidDisplayName(commandTextData.liquids ?? [], liquidId) : null, labware: commandTextData != null - ? getLabwareName(commandTextData, labwareId) + ? getLabwareName({ + loadedLabwares: commandTextData?.labware ?? [], + labwareId, + allRunDefs, + }) : null, }) } diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveLabwareCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveLabwareCommandText.ts similarity index 58% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveLabwareCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveLabwareCommandText.ts index 84468cf2776..67fe3d52aaf 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveLabwareCommandText.ts +++ b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveLabwareCommandText.ts @@ -1,10 +1,10 @@ import { GRIPPER_WASTE_CHUTE_ADDRESSABLE_AREA } from '@opentrons/shared-data' +import { getFinalLabwareLocation } from './getFinalLabwareLocation' import { getLabwareName, getLabwareDisplayLocation, - getFinalLabwareLocation, -} from '../../../utils' +} from '/app/local-resources/labware' import type { MoveLabwareRunTimeCommand } from '@opentrons/shared-data' import type { HandlesCommands } from './types' @@ -26,16 +26,23 @@ export function getMoveLabwareCommandText({ allPreviousCommands != null ? getFinalLabwareLocation(labwareId, allPreviousCommands) : null - const newDisplayLocation = - commandTextData != null - ? getLabwareDisplayLocation( - commandTextData, - allRunDefs, - newLocation, - t, - robotType - ) - : null + + const oldDisplayLocation = getLabwareDisplayLocation({ + location: oldLocation, + robotType, + allRunDefs, + loadedLabwares: commandTextData?.labware ?? [], + loadedModules: commandTextData?.modules ?? [], + t, + }) + const newDisplayLocation = getLabwareDisplayLocation({ + location: newLocation, + robotType, + allRunDefs, + loadedLabwares: commandTextData?.labware ?? [], + loadedModules: commandTextData?.modules ?? [], + t, + }) const location = newDisplayLocation?.includes( GRIPPER_WASTE_CHUTE_ADDRESSABLE_AREA @@ -47,35 +54,25 @@ export function getMoveLabwareCommandText({ ? t('move_labware_using_gripper', { labware: commandTextData != null - ? getLabwareName(commandTextData, labwareId) - : null, - old_location: - oldLocation != null && commandTextData != null - ? getLabwareDisplayLocation( - commandTextData, + ? getLabwareName({ allRunDefs, - oldLocation, - t, - robotType - ) - : '', + loadedLabwares: commandTextData.labware ?? [], + labwareId, + }) + : null, + old_location: oldDisplayLocation, new_location: location, }) : t('move_labware_manually', { labware: commandTextData != null - ? getLabwareName(commandTextData, labwareId) - : null, - old_location: - oldLocation != null && commandTextData != null - ? getLabwareDisplayLocation( - commandTextData, + ? getLabwareName({ allRunDefs, - oldLocation, - t, - robotType - ) - : '', + loadedLabwares: commandTextData.labware ?? [], + labwareId, + }) + : null, + old_location: oldDisplayLocation, new_location: location, }) } diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveRelativeCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveRelativeCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveRelativeCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveRelativeCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToAddressabelAreaForDropTipCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToAddressabelAreaForDropTipCommandText.ts similarity index 87% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToAddressabelAreaForDropTipCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToAddressabelAreaForDropTipCommandText.ts index 5788fbbdf62..f7cc0f42e1f 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToAddressabelAreaForDropTipCommandText.ts +++ b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToAddressabelAreaForDropTipCommandText.ts @@ -1,4 +1,4 @@ -import { getAddressableAreaDisplayName } from '../../../utils' +import { getAddressableAreaDisplayName } from './getAddressableAreaDisplayName' import type { MoveToAddressableAreaForDropTipRunTimeCommand } from '@opentrons/shared-data/command' import type { HandlesCommands } from './types' diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToAddressableAreaCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToAddressableAreaCommandText.ts similarity index 87% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToAddressableAreaCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToAddressableAreaCommandText.ts index e8366120a23..749ef30f451 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToAddressableAreaCommandText.ts +++ b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToAddressableAreaCommandText.ts @@ -1,4 +1,4 @@ -import { getAddressableAreaDisplayName } from '../../../utils' +import { getAddressableAreaDisplayName } from './getAddressableAreaDisplayName' import type { MoveToAddressableAreaRunTimeCommand } from '@opentrons/shared-data/command' import type { HandlesCommands } from './types' diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToCoordinatesCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToCoordinatesCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToCoordinatesCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToCoordinatesCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToSlotCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToSlotCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToSlotCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToSlotCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToWellCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToWellCommandText.ts similarity index 63% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToWellCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToWellCommandText.ts index c91d8431744..e3c8d6223be 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/utils/getMoveToWellCommandText.ts +++ b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getMoveToWellCommandText.ts @@ -1,10 +1,10 @@ import { - getFinalLabwareLocation, - getLabwareDisplayLocation, getLabwareName, -} from '../../../utils' + getLabwareDisplayLocation, +} from '/app/local-resources/labware' + +import { getFinalLabwareLocation } from './getFinalLabwareLocation' -import type { TFunction } from 'i18next' import type { MoveToWellRunTimeCommand } from '@opentrons/shared-data/command' import type { HandlesCommands } from './types' @@ -24,22 +24,25 @@ export function getMoveToWellCommandText({ allPreviousCommands != null ? getFinalLabwareLocation(labwareId, allPreviousCommands) : null - const displayLocation = - labwareLocation != null && commandTextData != null - ? getLabwareDisplayLocation( - commandTextData, - allRunDefs, - labwareLocation, - t as TFunction, - robotType - ) - : '' + + const displayLocation = getLabwareDisplayLocation({ + location: labwareLocation, + robotType, + allRunDefs, + loadedLabwares: commandTextData?.labware ?? [], + loadedModules: commandTextData?.modules ?? [], + t, + }) return t('move_to_well', { well_name: wellName, labware: commandTextData != null - ? getLabwareName(commandTextData, labwareId) + ? getLabwareName({ + loadedLabwares: commandTextData.labware ?? [], + labwareId, + allRunDefs, + }) : null, labware_location: displayLocation, }) diff --git a/app/src/local-resources/commands/hooks/useCommandTextString/utils/getPipetteNameOnMount.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getPipetteNameOnMount.ts new file mode 100644 index 00000000000..e4ae2519374 --- /dev/null +++ b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getPipetteNameOnMount.ts @@ -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 +} diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getPipettingCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getPipettingCommandText.ts similarity index 72% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getPipettingCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getPipettingCommandText.ts index 27402ab148f..34ad5eae3a3 100644 --- a/app/src/molecules/Command/hooks/useCommandTextString/utils/getPipettingCommandText.ts +++ b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getPipettingCommandText.ts @@ -1,16 +1,16 @@ import { getLabwareDefURI } from '@opentrons/shared-data' -import { getLoadedLabware } from '../../../utils/accessors' +import { getFinalLabwareLocation } from './getFinalLabwareLocation' +import { getWellRange } from './getWellRange' + import { + getLabwareDefinitionsFromCommands, getLabwareName, + getLoadedLabware, getLabwareDisplayLocation, - getFinalLabwareLocation, - getWellRange, - getLabwareDefinitionsFromCommands, -} from '../../../utils' +} from '/app/local-resources/labware' import type { PipetteName, RunTimeCommand } from '@opentrons/shared-data' -import type { TFunction } from 'i18next' import type { GetCommandText } from '..' export const getPipettingCommandText = ({ @@ -40,16 +40,15 @@ export const getPipettingCommandText = ({ allPreviousCommands as RunTimeCommand[] ) : null - const displayLocation = - labwareLocation != null && commandTextData != null - ? getLabwareDisplayLocation( - commandTextData, - allRunDefs, - labwareLocation, - t as TFunction, - robotType - ) - : '' + + const displayLocation = getLabwareDisplayLocation({ + location: labwareLocation, + robotType, + allRunDefs, + loadedLabwares: commandTextData?.labware ?? [], + loadedModules: commandTextData?.modules ?? [], + t, + }) switch (command?.commandType) { case 'aspirate': { @@ -58,7 +57,11 @@ export const getPipettingCommandText = ({ well_name: wellName, labware: commandTextData != null - ? getLabwareName(commandTextData, labwareId) + ? getLabwareName({ + loadedLabwares: commandTextData.labware ?? [], + labwareId, + allRunDefs, + }) : null, labware_location: displayLocation, volume, @@ -72,7 +75,11 @@ export const getPipettingCommandText = ({ well_name: wellName, labware: commandTextData != null - ? getLabwareName(commandTextData, labwareId) + ? getLabwareName({ + loadedLabwares: commandTextData.labware ?? [], + labwareId, + allRunDefs, + }) : null, labware_location: displayLocation, volume, @@ -83,7 +90,11 @@ export const getPipettingCommandText = ({ well_name: wellName, labware: commandTextData != null - ? getLabwareName(commandTextData, labwareId) + ? getLabwareName({ + loadedLabwares: commandTextData.labware ?? [], + labwareId, + allRunDefs, + }) : null, labware_location: displayLocation, volume, @@ -96,7 +107,11 @@ export const getPipettingCommandText = ({ well_name: wellName, labware: commandTextData != null - ? getLabwareName(commandTextData, labwareId) + ? getLabwareName({ + loadedLabwares: commandTextData.labware ?? [], + labwareId, + allRunDefs, + }) : null, labware_location: displayLocation, flow_rate: flowRate, @@ -105,7 +120,7 @@ export const getPipettingCommandText = ({ case 'dropTip': { const loadedLabware = commandTextData != null - ? getLoadedLabware(commandTextData, labwareId) + ? getLoadedLabware(commandTextData.labware ?? [], labwareId) : null const labwareDefinitions = commandTextData != null @@ -121,7 +136,11 @@ export const getPipettingCommandText = ({ well_name: wellName, labware: commandTextData != null - ? getLabwareName(commandTextData, labwareId) + ? getLabwareName({ + loadedLabwares: commandTextData.labware ?? [], + labwareId, + allRunDefs, + }) : null, labware_location: displayLocation, }) @@ -129,7 +148,11 @@ export const getPipettingCommandText = ({ well_name: wellName, labware: commandTextData != null - ? getLabwareName(commandTextData, labwareId) + ? getLabwareName({ + loadedLabwares: commandTextData.labware ?? [], + labwareId, + allRunDefs, + }) : null, }) } @@ -153,7 +176,11 @@ export const getPipettingCommandText = ({ : null, labware: commandTextData != null - ? getLabwareName(commandTextData, labwareId) + ? getLabwareName({ + loadedLabwares: commandTextData.labware ?? [], + labwareId, + allRunDefs, + }) : null, labware_location: displayLocation, }) diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getPrepareToAspirateCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getPrepareToAspirateCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getPrepareToAspirateCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getPrepareToAspirateCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getRailLightsCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getRailLightsCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getRailLightsCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getRailLightsCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getTCRunExtendedProfileCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getTCRunExtendedProfileCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getTCRunExtendedProfileCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getTCRunExtendedProfileCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getTCRunProfileCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getTCRunProfileCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getTCRunProfileCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getTCRunProfileCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getTemperatureCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getTemperatureCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getTemperatureCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getTemperatureCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getUnknownCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getUnknownCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getUnknownCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getUnknownCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getWaitForDurationCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getWaitForDurationCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getWaitForDurationCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getWaitForDurationCommandText.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/getWaitForResumeCommandText.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getWaitForResumeCommandText.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/getWaitForResumeCommandText.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getWaitForResumeCommandText.ts diff --git a/app/src/molecules/Command/utils/getWellRange.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/getWellRange.ts similarity index 100% rename from app/src/molecules/Command/utils/getWellRange.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/getWellRange.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/index.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/index.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/index.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/index.ts diff --git a/app/src/molecules/Command/hooks/useCommandTextString/utils/types.ts b/app/src/local-resources/commands/hooks/useCommandTextString/utils/types.ts similarity index 100% rename from app/src/molecules/Command/hooks/useCommandTextString/utils/types.ts rename to app/src/local-resources/commands/hooks/useCommandTextString/utils/types.ts diff --git a/app/src/local-resources/commands/index.ts b/app/src/local-resources/commands/index.ts new file mode 100644 index 00000000000..02b71828cfa --- /dev/null +++ b/app/src/local-resources/commands/index.ts @@ -0,0 +1,4 @@ +export * from './hooks' +export * from './utils' + +export * from './types' diff --git a/app/src/molecules/Command/types.ts b/app/src/local-resources/commands/types.ts similarity index 100% rename from app/src/molecules/Command/types.ts rename to app/src/local-resources/commands/types.ts diff --git a/app/src/molecules/Command/utils/getCommandTextData.ts b/app/src/local-resources/commands/utils/getCommandTextData.ts similarity index 88% rename from app/src/molecules/Command/utils/getCommandTextData.ts rename to app/src/local-resources/commands/utils/getCommandTextData.ts index cfa8c6961ee..2750cd0d074 100644 --- a/app/src/molecules/Command/utils/getCommandTextData.ts +++ b/app/src/local-resources/commands/utils/getCommandTextData.ts @@ -4,7 +4,7 @@ import type { ProtocolAnalysisOutput, RunTimeCommand, } from '@opentrons/shared-data' -import type { CommandTextData } from '../types' +import type { CommandTextData } from '/app/local-resources/commands/types' export function getCommandTextData( protocolData: diff --git a/app/src/local-resources/commands/utils/index.ts b/app/src/local-resources/commands/utils/index.ts new file mode 100644 index 00000000000..7aa84d14de5 --- /dev/null +++ b/app/src/local-resources/commands/utils/index.ts @@ -0,0 +1 @@ +export * from './getCommandTextData' diff --git a/app/src/local-resources/instruments/types.ts b/app/src/local-resources/instruments/types.ts new file mode 100644 index 00000000000..3c4a313f9e5 --- /dev/null +++ b/app/src/local-resources/instruments/types.ts @@ -0,0 +1,3 @@ +import type { LoadedPipette } from '@opentrons/shared-data' + +export type LoadedPipettes = LoadedPipette[] | Record diff --git a/app/src/local-resources/instruments/utils.ts b/app/src/local-resources/instruments/utils.ts index ef92e580725..c93ad39b078 100644 --- a/app/src/local-resources/instruments/utils.ts +++ b/app/src/local-resources/instruments/utils.ts @@ -1,3 +1,6 @@ +import type { LoadedPipette } from '@opentrons/shared-data' +import type { LoadedPipettes } from '/app/local-resources/instruments/types' + export interface IsPartialTipConfigParams { channel: 1 | 8 | 96 activeNozzleCount: number @@ -16,3 +19,13 @@ export function isPartialTipConfig({ return activeNozzleCount !== 96 } } + +export function getLoadedPipette( + loadedPipettes: LoadedPipettes, + mount: string +): LoadedPipette | undefined { + // NOTE: old analysis contains a object dictionary of pipette entities by id, this case is supported for backwards compatibility purposes + return Array.isArray(loadedPipettes) + ? loadedPipettes.find(l => l.mount === mount) + : loadedPipettes[mount] +} diff --git a/app/src/local-resources/labware/types.ts b/app/src/local-resources/labware/types.ts index 99ea299573d..da55c9d7004 100644 --- a/app/src/local-resources/labware/types.ts +++ b/app/src/local-resources/labware/types.ts @@ -3,6 +3,7 @@ import type { LabwareWellShapeProperties, LabwareWellGroupMetadata, LabwareBrand, + LoadedLabware, } from '@opentrons/shared-data' export interface LabwareDefAndDate { @@ -35,3 +36,5 @@ export interface LabwareWellGroupProperties { metadata: LabwareWellGroupMetadata brand: LabwareBrand | null } + +export type LoadedLabwares = LoadedLabware[] | Record diff --git a/app/src/local-resources/labware/utils/getAllDefinitions.ts b/app/src/local-resources/labware/utils/getAllDefinitions.ts index db25fde06a1..24a28ef44e1 100644 --- a/app/src/local-resources/labware/utils/getAllDefinitions.ts +++ b/app/src/local-resources/labware/utils/getAllDefinitions.ts @@ -1,9 +1,12 @@ import groupBy from 'lodash/groupBy' + import { LABWAREV2_DO_NOT_LIST } from '@opentrons/shared-data' -import type { LabwareDefinition2 } from '@opentrons/shared-data' + import { getAllDefs } from './getAllDefs' -export const getOnlyLatestDefs = ( +import type { LabwareDefinition2 } from '@opentrons/shared-data' + +const getOnlyLatestDefs = ( labwareList: LabwareDefinition2[] ): LabwareDefinition2[] => { // group by namespace + loadName diff --git a/app/src/local-resources/labware/utils/getAllDefs.ts b/app/src/local-resources/labware/utils/getAllDefs.ts index 58ccbae8b74..307cb18b014 100644 --- a/app/src/local-resources/labware/utils/getAllDefs.ts +++ b/app/src/local-resources/labware/utils/getAllDefs.ts @@ -1,4 +1,5 @@ import { getAllDefinitions } from '@opentrons/shared-data' + import type { LabwareDefinition2 } from '@opentrons/shared-data' export function getAllDefs(): LabwareDefinition2[] { diff --git a/app/src/molecules/Command/utils/getLabwareDefinitionsFromCommands.ts b/app/src/local-resources/labware/utils/getLabwareDefinitionsFromCommands.ts similarity index 94% rename from app/src/molecules/Command/utils/getLabwareDefinitionsFromCommands.ts rename to app/src/local-resources/labware/utils/getLabwareDefinitionsFromCommands.ts index 238302e78e5..6016b0c5dd8 100644 --- a/app/src/molecules/Command/utils/getLabwareDefinitionsFromCommands.ts +++ b/app/src/local-resources/labware/utils/getLabwareDefinitionsFromCommands.ts @@ -1,6 +1,8 @@ -import type { LabwareDefinition2, RunTimeCommand } from '@opentrons/shared-data' import { getLabwareDefURI } from '@opentrons/shared-data' +import type { LabwareDefinition2, RunTimeCommand } from '@opentrons/shared-data' + +// Note: This is an O(n) operation. export function getLabwareDefinitionsFromCommands( commands: RunTimeCommand[] ): LabwareDefinition2[] { diff --git a/app/src/molecules/Command/utils/getLabwareDisplayLocation.ts b/app/src/local-resources/labware/utils/getLabwareDisplayLocation.ts similarity index 70% rename from app/src/molecules/Command/utils/getLabwareDisplayLocation.ts rename to app/src/local-resources/labware/utils/getLabwareDisplayLocation.ts index 60b03609c79..3f56eb165b1 100644 --- a/app/src/molecules/Command/utils/getLabwareDisplayLocation.ts +++ b/app/src/local-resources/labware/utils/getLabwareDisplayLocation.ts @@ -6,8 +6,10 @@ import { getOccludedSlotCountForModule, } from '@opentrons/shared-data' -import { getModuleDisplayLocation } from './getModuleDisplayLocation' -import { getModuleModel } from './getModuleModel' +import { + getModuleModel, + getModuleDisplayLocation, +} from '/app/local-resources/modules' import type { TFunction } from 'i18next' import type { @@ -15,17 +17,32 @@ import type { LabwareLocation, LabwareDefinition2, } from '@opentrons/shared-data' -import type { CommandTextData } from '../types' +import type { LoadedModules } from '/app/local-resources/modules' +import type { LoadedLabwares } from '/app/local-resources/labware' -// TODO(jh, 10-14-24): Refactor this util and related copy utils out of Command. -export function getLabwareDisplayLocation( - commandTextData: Omit, - allRunDefs: LabwareDefinition2[], - location: LabwareLocation, - t: TFunction, - robotType: RobotType, +export interface UseLabwareDisplayLocationProps { + location: LabwareLocation | null + loadedModules: LoadedModules + loadedLabwares: LoadedLabwares + allRunDefs: LabwareDefinition2[] + robotType: RobotType + t: TFunction isOnDevice?: boolean -): string { +} + +export function getLabwareDisplayLocation({ + loadedLabwares, + loadedModules, + allRunDefs, + location, + robotType, + t, + isOnDevice = false, +}: UseLabwareDisplayLocationProps): string { + if (location == null) { + console.warn('Cannot get labware display location. No location provided.') + return '' + } if (location === 'offDeck') { return t('off_deck') } else if ('slotName' in location) { @@ -37,13 +54,13 @@ export function getLabwareDisplayLocation( ? location.addressableAreaName : t('slot', { slot_name: location.addressableAreaName }) } else if ('moduleId' in location) { - const moduleModel = getModuleModel(commandTextData, location.moduleId) + const moduleModel = getModuleModel(loadedModules, location.moduleId) if (moduleModel == null) { console.warn('labware is located on an unknown module model') return '' } else { const slotName = getModuleDisplayLocation( - commandTextData, + loadedModules, location.moduleId ) return isOnDevice @@ -58,9 +75,11 @@ export function getLabwareDisplayLocation( }) } } else if ('labwareId' in location) { - const adapter = commandTextData.labware.find( - lw => lw.id === location.labwareId - ) + if (!Array.isArray(loadedLabwares)) { + console.warn('Cannot get display location from loaded labwares object') + return '' + } + const adapter = loadedLabwares.find(lw => lw.id === location.labwareId) const adapterDef = allRunDefs.find( def => getLabwareDefURI(def) === adapter?.definitionUri ) @@ -84,7 +103,13 @@ export function getLabwareDisplayLocation( }) } else if ('moduleId' in adapter.location) { const moduleIdUnderAdapter = adapter.location.moduleId - const moduleModel = commandTextData.modules.find( + + if (!Array.isArray(loadedModules)) { + console.warn('Cannot get display location from loaded labwares object') + return '' + } + + const moduleModel = loadedModules.find( module => module.id === moduleIdUnderAdapter )?.model if (moduleModel == null) { @@ -92,7 +117,7 @@ export function getLabwareDisplayLocation( return '' } const slotName = getModuleDisplayLocation( - commandTextData, + loadedModules, adapter.location.moduleId ) return t('adapter_in_mod_in_slot', { diff --git a/app/src/molecules/Command/utils/getLabwareName.ts b/app/src/local-resources/labware/utils/getLabwareName.ts similarity index 50% rename from app/src/molecules/Command/utils/getLabwareName.ts rename to app/src/local-resources/labware/utils/getLabwareName.ts index 03c6feb1367..af51fbc5fbc 100644 --- a/app/src/molecules/Command/utils/getLabwareName.ts +++ b/app/src/local-resources/labware/utils/getLabwareName.ts @@ -1,19 +1,28 @@ -import { getLoadedLabware } from './accessors' - import { getLabwareDefURI, getLabwareDisplayName } from '@opentrons/shared-data' -import { getLabwareDefinitionsFromCommands } from './getLabwareDefinitionsFromCommands' -import type { CommandTextData } from '../types' + +import { getLoadedLabware } from './getLoadedLabware' + +import type { LabwareDefinition2 } from '@opentrons/shared-data' +import type { LoadedLabwares } from '/app/local-resources/labware' const FIXED_TRASH_DEF_URIS = [ 'opentrons/opentrons_1_trash_850ml_fixed/1', 'opentrons/opentrons_1_trash_1100ml_fixed/1', 'opentrons/opentrons_1_trash_3200ml_fixed/1', ] -export function getLabwareName( - commandTextData: CommandTextData, + +export interface GetLabwareNameParams { + allRunDefs: LabwareDefinition2[] + loadedLabwares: LoadedLabwares labwareId: string -): string { - const loadedLabware = getLoadedLabware(commandTextData, labwareId) +} + +export function getLabwareName({ + allRunDefs, + loadedLabwares, + labwareId, +}: GetLabwareNameParams): string { + const loadedLabware = getLoadedLabware(loadedLabwares, labwareId) if (loadedLabware == null) { return '' } else if (FIXED_TRASH_DEF_URIS.includes(loadedLabware.definitionUri)) { @@ -21,9 +30,9 @@ export function getLabwareName( } else if (loadedLabware.displayName != null) { return loadedLabware.displayName } else { - const labwareDef = getLabwareDefinitionsFromCommands( - commandTextData.commands - ).find(def => getLabwareDefURI(def) === loadedLabware.definitionUri) + const labwareDef = allRunDefs.find( + def => getLabwareDefURI(def) === loadedLabware.definitionUri + ) return labwareDef != null ? getLabwareDisplayName(labwareDef) : '' } } diff --git a/app/src/local-resources/labware/utils/getLoadedLabware.ts b/app/src/local-resources/labware/utils/getLoadedLabware.ts new file mode 100644 index 00000000000..efd6981837a --- /dev/null +++ b/app/src/local-resources/labware/utils/getLoadedLabware.ts @@ -0,0 +1,12 @@ +import type { LoadedLabware } from '@opentrons/shared-data' +import type { LoadedLabwares } from '/app/local-resources/labware' + +export function getLoadedLabware( + loadedLabware: LoadedLabwares, + labwareId: string +): LoadedLabware | undefined { + // NOTE: old analysis contains a object dictionary of labware entities by id, this case is supported for backwards compatibility purposes + return Array.isArray(loadedLabware) + ? loadedLabware.find(l => l.id === labwareId) + : loadedLabware[labwareId] +} diff --git a/app/src/local-resources/labware/utils/index.ts b/app/src/local-resources/labware/utils/index.ts index 310ed3f065a..73879e0956b 100644 --- a/app/src/local-resources/labware/utils/index.ts +++ b/app/src/local-resources/labware/utils/index.ts @@ -1,2 +1,7 @@ export * from './getAllDefinitions' export * from './labwareImages' +export * from './getAllDefs' +export * from './getLabwareDefinitionsFromCommands' +export * from './getLabwareName' +export * from './getLoadedLabware' +export * from './getLabwareDisplayLocation' diff --git a/app/src/local-resources/modules/index.ts b/app/src/local-resources/modules/index.ts index e508be48e92..85dcaa20ea5 100644 --- a/app/src/local-resources/modules/index.ts +++ b/app/src/local-resources/modules/index.ts @@ -1,2 +1,3 @@ -export * from './getModulePrepCommands' -export * from './getModuleImage' +export * from './utils' + +export * from './types' diff --git a/app/src/local-resources/modules/types.ts b/app/src/local-resources/modules/types.ts new file mode 100644 index 00000000000..8317beac7e8 --- /dev/null +++ b/app/src/local-resources/modules/types.ts @@ -0,0 +1,3 @@ +import type { LoadedModule } from '@opentrons/shared-data' + +export type LoadedModules = LoadedModule[] | Record diff --git a/app/src/local-resources/modules/__tests__/getModuleImage.test.ts b/app/src/local-resources/modules/utils/__tests__/getModuleImage.test.ts similarity index 100% rename from app/src/local-resources/modules/__tests__/getModuleImage.test.ts rename to app/src/local-resources/modules/utils/__tests__/getModuleImage.test.ts diff --git a/app/src/local-resources/modules/utils/getLoadedModule.ts b/app/src/local-resources/modules/utils/getLoadedModule.ts new file mode 100644 index 00000000000..70047e095e6 --- /dev/null +++ b/app/src/local-resources/modules/utils/getLoadedModule.ts @@ -0,0 +1,12 @@ +import type { LoadedModule } from '@opentrons/shared-data' +import type { LoadedModules } from '/app/local-resources/modules/types' + +export function getLoadedModule( + loadedModules: LoadedModules, + moduleId: string +): LoadedModule | undefined { + // NOTE: old analysis contains a object dictionary of module entities by id, this case is supported for backwards compatibility purposes + return Array.isArray(loadedModules) + ? loadedModules.find(l => l.id === moduleId) + : loadedModules[moduleId] +} diff --git a/app/src/local-resources/modules/utils/getModuleDisplayLocation.ts b/app/src/local-resources/modules/utils/getModuleDisplayLocation.ts new file mode 100644 index 00000000000..665e31d8975 --- /dev/null +++ b/app/src/local-resources/modules/utils/getModuleDisplayLocation.ts @@ -0,0 +1,11 @@ +import { getLoadedModule } from './getLoadedModule' + +import type { LoadedModules } from '../types' + +export function getModuleDisplayLocation( + loadedModules: LoadedModules, + moduleId: string +): string { + const loadedModule = getLoadedModule(loadedModules, moduleId) + return loadedModule != null ? loadedModule.location.slotName : '' +} diff --git a/app/src/local-resources/modules/getModuleImage.ts b/app/src/local-resources/modules/utils/getModuleImage.ts similarity index 100% rename from app/src/local-resources/modules/getModuleImage.ts rename to app/src/local-resources/modules/utils/getModuleImage.ts diff --git a/app/src/local-resources/modules/utils/getModuleModel.ts b/app/src/local-resources/modules/utils/getModuleModel.ts new file mode 100644 index 00000000000..18302253499 --- /dev/null +++ b/app/src/local-resources/modules/utils/getModuleModel.ts @@ -0,0 +1,12 @@ +import { getLoadedModule } from './getLoadedModule' + +import type { ModuleModel } from '@opentrons/shared-data' +import type { LoadedModules } from '/app/local-resources/modules/types' + +export function getModuleModel( + loadedModules: LoadedModules, + moduleId: string +): ModuleModel | null { + const loadedModule = getLoadedModule(loadedModules, moduleId) + return loadedModule != null ? loadedModule.model : null +} diff --git a/app/src/local-resources/modules/getModulePrepCommands.ts b/app/src/local-resources/modules/utils/getModulePrepCommands.ts similarity index 100% rename from app/src/local-resources/modules/getModulePrepCommands.ts rename to app/src/local-resources/modules/utils/getModulePrepCommands.ts diff --git a/app/src/local-resources/modules/utils/index.ts b/app/src/local-resources/modules/utils/index.ts new file mode 100644 index 00000000000..7f3f558738d --- /dev/null +++ b/app/src/local-resources/modules/utils/index.ts @@ -0,0 +1,5 @@ +export * from './getLoadedModule' +export * from './getModuleDisplayLocation' +export * from './getModuleImage' +export * from './getModuleModel' +export * from './getModulePrepCommands' diff --git a/app/src/molecules/Command/Command.tsx b/app/src/molecules/Command/Command.tsx index 3b09498ca00..e71757313a4 100644 --- a/app/src/molecules/Command/Command.tsx +++ b/app/src/molecules/Command/Command.tsx @@ -1,3 +1,5 @@ +import { omit } from 'lodash' + import { Flex, JUSTIFY_CENTER, @@ -8,17 +10,18 @@ import { SPACING, RESPONSIVENESS, } from '@opentrons/components' + +import { CommandText } from './CommandText' +import { CommandIcon } from './CommandIcon' +import { Skeleton } from '/app/atoms/Skeleton' + import type { LabwareDefinition2, RobotType, RunTimeCommand, } from '@opentrons/shared-data' -import { CommandText } from './CommandText' -import { CommandIcon } from './CommandIcon' -import type { CommandTextData } from './types' -import { Skeleton } from '/app/atoms/Skeleton' +import type { CommandTextData } from '/app/local-resources/commands' import type { StyleProps } from '@opentrons/components' -import { omit } from 'lodash' export type CommandState = NonSkeletonCommandState | 'loading' export type NonSkeletonCommandState = 'current' | 'failed' | 'future' diff --git a/app/src/molecules/Command/CommandText.stories.tsx b/app/src/molecules/Command/CommandText.stories.tsx index f6b40e0a4e4..a76acd5fa92 100644 --- a/app/src/molecules/Command/CommandText.stories.tsx +++ b/app/src/molecules/Command/CommandText.stories.tsx @@ -2,6 +2,7 @@ import { Box } from '@opentrons/components' import { CommandText as CommandTextComponent } from '.' import type { RobotType } from '@opentrons/shared-data' import * as Fixtures from './__fixtures__' +import { getLabwareDefinitionsFromCommands } from '../../local-resources/labware' import type { Meta, StoryObj } from '@storybook/react' @@ -12,6 +13,10 @@ interface StorybookArgs { } function Wrapper(props: StorybookArgs): JSX.Element { + const allRunDefs = getLabwareDefinitionsFromCommands( + Fixtures.mockDoItAllTextData.commands + ) + return ( ) diff --git a/app/src/molecules/Command/CommandText.tsx b/app/src/molecules/Command/CommandText.tsx index 3e8b27d2522..e690115a88b 100644 --- a/app/src/molecules/Command/CommandText.tsx +++ b/app/src/molecules/Command/CommandText.tsx @@ -11,7 +11,7 @@ import { RESPONSIVENESS, } from '@opentrons/components' -import { useCommandTextString } from './hooks' +import { useCommandTextString } from '/app/local-resources/commands' import type { LabwareDefinition2, @@ -19,11 +19,11 @@ import type { RunTimeCommand, } from '@opentrons/shared-data' import type { StyleProps } from '@opentrons/components' -import type { CommandTextData } from './types' import type { GetTCRunExtendedProfileCommandTextResult, GetTCRunProfileCommandTextResult, -} from './hooks' + CommandTextData, +} from '/app/local-resources/commands' interface LegacySTProps { as?: React.ComponentProps['as'] diff --git a/app/src/molecules/Command/__fixtures__/index.ts b/app/src/molecules/Command/__fixtures__/index.ts index ba988a5197a..894208e8e68 100644 --- a/app/src/molecules/Command/__fixtures__/index.ts +++ b/app/src/molecules/Command/__fixtures__/index.ts @@ -2,7 +2,7 @@ import robotSideAnalysis from './mockRobotSideAnalysis.json' import doItAllAnalysis from './doItAllV10.json' import qiaseqAnalysis from './analysis_QIAseqFX24xv4_8.json' import type { CompletedProtocolAnalysis } from '@opentrons/shared-data' -import type { CommandTextData } from '../types' +import type { CommandTextData } from '/app/local-resources/commands' export const mockRobotSideAnalysis: CompletedProtocolAnalysis = robotSideAnalysis as CompletedProtocolAnalysis export const mockDoItAllAnalysis: CompletedProtocolAnalysis = doItAllAnalysis as CompletedProtocolAnalysis diff --git a/app/src/molecules/Command/__tests__/CommandText.test.tsx b/app/src/molecules/Command/__tests__/CommandText.test.tsx index 621208af0a9..6999063be38 100644 --- a/app/src/molecules/Command/__tests__/CommandText.test.tsx +++ b/app/src/molecules/Command/__tests__/CommandText.test.tsx @@ -10,7 +10,7 @@ import { renderWithProviders } from '/app/__testing-utils__' import { i18n } from '/app/i18n' import { CommandText } from '../CommandText' import { mockCommandTextData } from '../__fixtures__' -import { getCommandTextData } from '../utils/getCommandTextData' +import { getCommandTextData } from '/app/local-resources/commands/utils' import type { AspirateInPlaceRunTimeCommand, diff --git a/app/src/molecules/Command/index.ts b/app/src/molecules/Command/index.ts index b4223d82beb..9fc833953c8 100644 --- a/app/src/molecules/Command/index.ts +++ b/app/src/molecules/Command/index.ts @@ -2,6 +2,3 @@ export * from './CommandText' export * from './Command' export * from './CommandIcon' export * from './CommandIndex' -export * from './utils' -export * from './types' -export * from './hooks' diff --git a/app/src/molecules/Command/utils/accessors.ts b/app/src/molecules/Command/utils/accessors.ts deleted file mode 100644 index 651fb15769e..00000000000 --- a/app/src/molecules/Command/utils/accessors.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type { RunData } from '@opentrons/api-client' -import type { - CompletedProtocolAnalysis, - LoadedLabware, - LoadedModule, - LoadedPipette, -} from '@opentrons/shared-data' -import type { CommandTextData } from '../types' - -export function getLoadedLabware( - commandTextData: CompletedProtocolAnalysis | RunData | CommandTextData, - labwareId: string -): LoadedLabware | undefined { - // NOTE: old analysis contains a object dictionary of labware entities by id, this case is supported for backwards compatibility purposes - return Array.isArray(commandTextData.labware) - ? commandTextData.labware.find(l => l.id === labwareId) - : commandTextData.labware[labwareId] -} -export function getLoadedPipette( - commandTextData: CommandTextData, - mount: string -): LoadedPipette | undefined { - // NOTE: old analysis contains a object dictionary of pipette entities by id, this case is supported for backwards compatibility purposes - return Array.isArray(commandTextData.pipettes) - ? commandTextData.pipettes.find(l => l.mount === mount) - : commandTextData.pipettes[mount] -} -export function getLoadedModule( - commandTextData: - | CompletedProtocolAnalysis - | RunData - | Omit, - moduleId: string -): LoadedModule | undefined { - // NOTE: old analysis contains a object dictionary of module entities by id, this case is supported for backwards compatibility purposes - return Array.isArray(commandTextData.modules) - ? commandTextData.modules.find(l => l.id === moduleId) - : commandTextData.modules[moduleId] -} diff --git a/app/src/molecules/Command/utils/getLiquidDisplayName.ts b/app/src/molecules/Command/utils/getLiquidDisplayName.ts deleted file mode 100644 index 1b4b15a854b..00000000000 --- a/app/src/molecules/Command/utils/getLiquidDisplayName.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { CommandTextData } from '../types' - -export function getLiquidDisplayName( - commandTextData: CommandTextData, - liquidId: string -): CommandTextData['liquids'][number]['displayName'] { - const liquidDisplayName = (commandTextData?.liquids ?? []).find( - liquid => liquid.id === liquidId - )?.displayName - return liquidDisplayName ?? '' -} diff --git a/app/src/molecules/Command/utils/getModuleDisplayLocation.ts b/app/src/molecules/Command/utils/getModuleDisplayLocation.ts deleted file mode 100644 index fa5e527d218..00000000000 --- a/app/src/molecules/Command/utils/getModuleDisplayLocation.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { getLoadedModule } from './accessors' - -import type { CommandTextData } from '../types' - -export function getModuleDisplayLocation( - commandTextData: Omit, - moduleId: string -): string { - const loadedModule = getLoadedModule(commandTextData, moduleId) - return loadedModule != null ? loadedModule.location.slotName : '' -} diff --git a/app/src/molecules/Command/utils/getModuleModel.ts b/app/src/molecules/Command/utils/getModuleModel.ts deleted file mode 100644 index fdac4850331..00000000000 --- a/app/src/molecules/Command/utils/getModuleModel.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { getLoadedModule } from './accessors' - -import type { ModuleModel } from '@opentrons/shared-data' -import type { CommandTextData } from '../types' - -export function getModuleModel( - commandTextData: Omit, - moduleId: string -): ModuleModel | null { - const loadedModule = getLoadedModule(commandTextData, moduleId) - return loadedModule != null ? loadedModule.model : null -} diff --git a/app/src/molecules/Command/utils/getPipetteNameOnMount.ts b/app/src/molecules/Command/utils/getPipetteNameOnMount.ts deleted file mode 100644 index f1c09d73caf..00000000000 --- a/app/src/molecules/Command/utils/getPipetteNameOnMount.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { getLoadedPipette } from './accessors' - -import type { PipetteName } from '@opentrons/shared-data' -import type { CommandTextData } from '../types' - -export function getPipetteNameOnMount( - commandTextData: CommandTextData, - mount: string -): PipetteName | null { - const loadedPipette = getLoadedPipette(commandTextData, mount) - return loadedPipette != null ? loadedPipette.pipetteName : null -} diff --git a/app/src/molecules/Command/utils/index.ts b/app/src/molecules/Command/utils/index.ts deleted file mode 100644 index 8e8bbfd9119..00000000000 --- a/app/src/molecules/Command/utils/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from './getAddressableAreaDisplayName' -export * from './getLabwareName' -export * from './getPipetteNameOnMount' -export * from './getModuleModel' -export * from './getModuleDisplayLocation' -export * from './getLiquidDisplayName' -export * from './getLabwareDisplayLocation' -export * from './getFinalLabwareLocation' -export * from './getWellRange' -export * from './getLabwareDefinitionsFromCommands' diff --git a/app/src/molecules/InterventionModal/CategorizedStepContent.tsx b/app/src/molecules/InterventionModal/CategorizedStepContent.tsx index f1c0835d396..3f7352a27fe 100644 --- a/app/src/molecules/InterventionModal/CategorizedStepContent.tsx +++ b/app/src/molecules/InterventionModal/CategorizedStepContent.tsx @@ -11,7 +11,8 @@ import { import { Command, CommandIndex } from '../Command' -import type { NonSkeletonCommandState, CommandTextData } from '../Command' +import type { CommandTextData } from '/app/local-resources/commands' +import type { NonSkeletonCommandState } from '../Command' import type { LabwareDefinition2, RobotType, diff --git a/app/src/organisms/ApplyHistoricOffsets/__tests__/ApplyHistoricOffsets.test.tsx b/app/src/organisms/ApplyHistoricOffsets/__tests__/ApplyHistoricOffsets.test.tsx index 30508bc0565..74f77291834 100644 --- a/app/src/organisms/ApplyHistoricOffsets/__tests__/ApplyHistoricOffsets.test.tsx +++ b/app/src/organisms/ApplyHistoricOffsets/__tests__/ApplyHistoricOffsets.test.tsx @@ -7,7 +7,7 @@ import { opentrons96PcrAdapterV1, fixture96Plate } from '@opentrons/shared-data' import { i18n } from '/app/i18n' import { renderWithProviders } from '/app/__testing-utils__' import { getIsLabwareOffsetCodeSnippetsOn } from '/app/redux/config' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import { ApplyHistoricOffsets } from '..' import type { LabwareDefinition2 } from '@opentrons/shared-data' @@ -15,7 +15,7 @@ import type { OffsetCandidate } from '../hooks/useOffsetCandidatesForAnalysis' vi.mock('/app/redux/config') vi.mock('/app/organisms/LabwarePositionCheck/utils/labware') -vi.mock('/app/molecules/Command/utils/getLabwareDefinitionsFromCommands') +vi.mock('/app/local-resources/labware') const mockLabwareDef = fixture96Plate as LabwareDefinition2 const mockAdapterDef = opentrons96PcrAdapterV1 as LabwareDefinition2 diff --git a/app/src/organisms/ApplyHistoricOffsets/index.tsx b/app/src/organisms/ApplyHistoricOffsets/index.tsx index 240afa960b2..6925145c012 100644 --- a/app/src/organisms/ApplyHistoricOffsets/index.tsx +++ b/app/src/organisms/ApplyHistoricOffsets/index.tsx @@ -22,7 +22,7 @@ import { getTopPortalEl } from '/app/App/portal' import { ExternalLink } from '/app/atoms/Link/ExternalLink' import { PythonLabwareOffsetSnippet } from '/app/molecules/PythonLabwareOffsetSnippet' import { LabwareOffsetTabs } from '/app/organisms/LabwareOffsetTabs' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import { LabwareOffsetTable } from './LabwareOffsetTable' import { getIsLabwareOffsetCodeSnippetsOn } from '/app/redux/config' import type { LabwareOffset } from '@opentrons/api-client' diff --git a/app/src/organisms/Desktop/Devices/ProtocolRun/SetupLabwarePositionCheck/CurrentOffsetsTable.tsx b/app/src/organisms/Desktop/Devices/ProtocolRun/SetupLabwarePositionCheck/CurrentOffsetsTable.tsx index 849464deee4..e86166b0c9b 100644 --- a/app/src/organisms/Desktop/Devices/ProtocolRun/SetupLabwarePositionCheck/CurrentOffsetsTable.tsx +++ b/app/src/organisms/Desktop/Devices/ProtocolRun/SetupLabwarePositionCheck/CurrentOffsetsTable.tsx @@ -23,7 +23,7 @@ import { LabwareOffsetTabs } from '/app/organisms/LabwareOffsetTabs' import { OffsetVector } from '/app/molecules/OffsetVector' import { PythonLabwareOffsetSnippet } from '/app/molecules/PythonLabwareOffsetSnippet' import { getDisplayLocation } from '/app/organisms/LabwarePositionCheck/utils/getDisplayLocation' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import type { LabwareOffset } from '@opentrons/api-client' import type { RunTimeCommand, diff --git a/app/src/organisms/Desktop/Devices/RunPreview/index.tsx b/app/src/organisms/Desktop/Devices/RunPreview/index.tsx index dd6c0e7beab..c2a48aba59a 100644 --- a/app/src/organisms/Desktop/Devices/RunPreview/index.tsx +++ b/app/src/organisms/Desktop/Devices/RunPreview/index.tsx @@ -28,13 +28,10 @@ import { useMostRecentCompletedAnalysis, useLastRunCommand, } from '/app/resources/runs' -import { - CommandText, - CommandIcon, - getLabwareDefinitionsFromCommands, -} from '/app/molecules/Command' +import { CommandText, CommandIcon } from '/app/molecules/Command' import { Divider } from '/app/atoms/structure' import { NAV_BAR_WIDTH } from '/app/App/constants' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import type { RunStatus } from '@opentrons/api-client' import type { RobotType } from '@opentrons/shared-data' diff --git a/app/src/organisms/Desktop/ProtocolDetails/AnnotatedSteps.tsx b/app/src/organisms/Desktop/ProtocolDetails/AnnotatedSteps.tsx index 5af6922afce..52837338fca 100644 --- a/app/src/organisms/Desktop/ProtocolDetails/AnnotatedSteps.tsx +++ b/app/src/organisms/Desktop/ProtocolDetails/AnnotatedSteps.tsx @@ -14,11 +14,8 @@ import { OVERFLOW_AUTO, } from '@opentrons/components' -import { - CommandIcon, - CommandText, - getLabwareDefinitionsFromCommands, -} from '/app/molecules/Command' +import { CommandIcon, CommandText } from '/app/molecules/Command' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import type { CompletedProtocolAnalysis, diff --git a/app/src/organisms/Desktop/ProtocolTimelineScrubber/CommandItem.tsx b/app/src/organisms/Desktop/ProtocolTimelineScrubber/CommandItem.tsx index 573893f096f..e97d30df767 100644 --- a/app/src/organisms/Desktop/ProtocolTimelineScrubber/CommandItem.tsx +++ b/app/src/organisms/Desktop/ProtocolTimelineScrubber/CommandItem.tsx @@ -8,7 +8,7 @@ import { LegacyStyledText, OVERFLOW_SCROLL, } from '@opentrons/components' -import { getCommandTextData } from '/app/molecules/Command/utils/getCommandTextData' +import { getCommandTextData } from '/app/local-resources/commands' import { CommandText } from '/app/molecules/Command' import { COMMAND_WIDTH_PX } from './index' diff --git a/app/src/organisms/Desktop/ProtocolTimelineScrubber/index.tsx b/app/src/organisms/Desktop/ProtocolTimelineScrubber/index.tsx index d92bc62e695..49be035e944 100644 --- a/app/src/organisms/Desktop/ProtocolTimelineScrubber/index.tsx +++ b/app/src/organisms/Desktop/ProtocolTimelineScrubber/index.tsx @@ -27,7 +27,7 @@ import { wellFillFromWellContents, } from './utils' import { CommandItem } from './CommandItem' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import type { ComponentProps } from 'react' import type { ViewportListRef } from 'react-viewport-list' diff --git a/app/src/organisms/Desktop/RunProgressMeter/hooks/useRunProgressCopy.tsx b/app/src/organisms/Desktop/RunProgressMeter/hooks/useRunProgressCopy.tsx index e9db153498b..8c522b4ff22 100644 --- a/app/src/organisms/Desktop/RunProgressMeter/hooks/useRunProgressCopy.tsx +++ b/app/src/organisms/Desktop/RunProgressMeter/hooks/useRunProgressCopy.tsx @@ -6,12 +6,11 @@ import { } from '@opentrons/api-client' import type * as React from 'react' import { useTranslation } from 'react-i18next' -import { getCommandTextData } from '/app/molecules/Command/utils/getCommandTextData' + +import { getCommandTextData } from '/app/local-resources/commands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import { LegacyStyledText } from '@opentrons/components' -import { - CommandText, - getLabwareDefinitionsFromCommands, -} from '/app/molecules/Command' +import { CommandText } from '/app/molecules/Command' import { TERMINAL_RUN_STATUSES } from '../constants' import type { CommandDetail, RunStatus } from '@opentrons/api-client' diff --git a/app/src/organisms/ErrorRecoveryFlows/__tests__/ErrorRecoveryFlows.test.tsx b/app/src/organisms/ErrorRecoveryFlows/__tests__/ErrorRecoveryFlows.test.tsx index b4fda69bd13..a00335f6475 100644 --- a/app/src/organisms/ErrorRecoveryFlows/__tests__/ErrorRecoveryFlows.test.tsx +++ b/app/src/organisms/ErrorRecoveryFlows/__tests__/ErrorRecoveryFlows.test.tsx @@ -8,7 +8,7 @@ import { RUN_STATUS_RUNNING, RUN_STATUS_STOP_REQUESTED, } from '@opentrons/api-client' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import { renderWithProviders } from '/app/__testing-utils__' import { i18n } from '/app/i18n' @@ -33,7 +33,7 @@ vi.mock('/app/redux/config') vi.mock('../RecoverySplash') vi.mock('/app/redux-resources/analytics') vi.mock('@opentrons/react-api-client') -vi.mock('/app/molecules/Command') +vi.mock('/app/local-resources/labware') vi.mock('react-redux', async () => { const actual = await vi.importActual('react-redux') return { diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useFailedLabwareUtils.test.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useFailedLabwareUtils.test.ts index a98818b6efd..ea5ca7c365a 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useFailedLabwareUtils.test.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useFailedLabwareUtils.test.ts @@ -206,7 +206,7 @@ describe('useRelevantFailedLwLocations', () => { expect(result.current).toEqual({ currentLoc: '', - newLoc: '', + newLoc: null, }) }) }) diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryToasts.test.tsx b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryToasts.test.tsx index 7c6b3b74065..c572618bbcc 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryToasts.test.tsx +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/__tests__/useRecoveryToasts.test.tsx @@ -14,13 +14,13 @@ import { } from '../useRecoveryToasts' import { RECOVERY_MAP } from '../../constants' import { useToaster } from '../../../ToasterOven' -import { useCommandTextString } from '/app/molecules/Command' +import { useCommandTextString } from '/app/local-resources/commands' import type { Mock } from 'vitest' import type { BuildToast } from '../useRecoveryToasts' vi.mock('../../../ToasterOven') -vi.mock('/app/molecules/Command') +vi.mock('/app/local-resources/commands') const TEST_COMMAND = 'test command' const TC_COMMAND = diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useFailedLabwareUtils.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useFailedLabwareUtils.ts index ba86e77c553..c1925a752c3 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/useFailedLabwareUtils.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/useFailedLabwareUtils.ts @@ -11,10 +11,11 @@ import { import { ERROR_KINDS } from '../constants' import { getErrorKind } from '../utils' -import { getLoadedLabware } from '/app/molecules/Command/utils/accessors' -import { getLabwareDisplayLocation } from '/app/molecules/Command' +import { + getLoadedLabware, + getLabwareDisplayLocation, +} from '/app/local-resources/labware' -import type { TFunction } from 'i18next' import type { WellGroup } from '@opentrons/components' import type { CommandsData, PipetteData, Run } from '@opentrons/api-client' import type { @@ -281,7 +282,7 @@ export function getFailedCmdRelevantLabware( const labwareNickname = protocolAnalysis != null ? getLoadedLabware( - protocolAnalysis, + protocolAnalysis.labware, recentRelevantFailedLabwareCmd?.params.labwareId || '' )?.displayName ?? null : null @@ -350,39 +351,37 @@ export function useRelevantFailedLwLocations({ allRunDefs, }: GetRelevantLwLocationsParams): RelevantFailedLabwareLocations { const { t } = useTranslation('protocol_command_text') - const canGetDisplayLocation = - protocolAnalysis != null && failedLabware != null - - const buildLocationCopy = useMemo(() => { - return (location: LabwareLocation | undefined): string | null => { - return canGetDisplayLocation && location != null - ? getLabwareDisplayLocation( - protocolAnalysis, - allRunDefs, - location, - t as TFunction, - FLEX_ROBOT_TYPE, - false // Always return the "full" copy, which is the desktop copy. - ) - : null - } - }, [canGetDisplayLocation, allRunDefs]) - const currentLocation = useMemo(() => { - return buildLocationCopy(failedLabware?.location) ?? '' - }, [canGetDisplayLocation]) + const currentLocation = getLabwareDisplayLocation({ + loadedLabwares: protocolAnalysis?.labware ?? [], + loadedModules: protocolAnalysis?.modules ?? [], + location: failedLabware?.location ?? null, + allRunDefs, + robotType: FLEX_ROBOT_TYPE, + t, + }) - const newLocation = useMemo(() => { + const getNewLocation = (): LabwareLocation | null => { switch (failedCommandByRunRecord?.commandType) { case 'moveLabware': - return buildLocationCopy(failedCommandByRunRecord.params.newLocation) + return failedCommandByRunRecord.params.newLocation default: return null } - }, [canGetDisplayLocation, failedCommandByRunRecord?.key]) + } + + const newLocationByDisplayName = getLabwareDisplayLocation({ + loadedLabwares: protocolAnalysis?.labware ?? [], + loadedModules: protocolAnalysis?.modules ?? [], + location: getNewLocation(), + allRunDefs, + robotType: FLEX_ROBOT_TYPE, + t, + }) return { currentLoc: currentLocation, - newLoc: newLocation, + newLoc: + newLocationByDisplayName.length === 0 ? null : newLocationByDisplayName, } } diff --git a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryToasts.ts b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryToasts.ts index ed5aaaeaae5..2edf732bfdd 100644 --- a/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryToasts.ts +++ b/app/src/organisms/ErrorRecoveryFlows/hooks/useRecoveryToasts.ts @@ -2,11 +2,11 @@ import { useTranslation } from 'react-i18next' import { useToaster } from '../../ToasterOven' import { RECOVERY_MAP } from '../constants' -import { useCommandTextString } from '/app/molecules/Command' +import { useCommandTextString } from '/app/local-resources/commands' import type { StepCounts } from '/app/resources/protocols/hooks' import type { CurrentRecoveryOptionUtils } from './useRecoveryRouting' -import type { UseCommandTextStringParams } from '/app/molecules/Command' +import type { UseCommandTextStringParams } from '/app/local-resources/commands' export type BuildToast = Omit & { isOnDevice: boolean diff --git a/app/src/organisms/ErrorRecoveryFlows/index.tsx b/app/src/organisms/ErrorRecoveryFlows/index.tsx index a447df2dafe..2bd26beb747 100644 --- a/app/src/organisms/ErrorRecoveryFlows/index.tsx +++ b/app/src/organisms/ErrorRecoveryFlows/index.tsx @@ -17,6 +17,7 @@ import { OT2_ROBOT_TYPE } from '@opentrons/shared-data' import { useHost } from '@opentrons/react-api-client' import { getIsOnDevice } from '/app/redux/config' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import { ErrorRecoveryWizard, useERWizard } from './ErrorRecoveryWizard' import { RecoverySplash, useRecoverySplash } from './RecoverySplash' import { RecoveryTakeover } from './RecoveryTakeover' @@ -30,7 +31,6 @@ import { import type { RunStatus } from '@opentrons/api-client' import type { CompletedProtocolAnalysis } from '@opentrons/shared-data' import type { FailedCommand } from './types' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command' const VALID_ER_RUN_STATUSES: RunStatus[] = [ RUN_STATUS_AWAITING_RECOVERY, diff --git a/app/src/organisms/InterventionModal/MoveLabwareInterventionContent.tsx b/app/src/organisms/InterventionModal/MoveLabwareInterventionContent.tsx index d44a96ecfa8..af561b6c15d 100644 --- a/app/src/organisms/InterventionModal/MoveLabwareInterventionContent.tsx +++ b/app/src/organisms/InterventionModal/MoveLabwareInterventionContent.tsx @@ -38,10 +38,8 @@ import { getModuleModelFromRunData, } from './utils' import { Divider } from '/app/atoms/structure' -import { - getLoadedLabware, - getLoadedModule, -} from '/app/molecules/Command/utils/accessors' +import { getLoadedModule } from '/app/local-resources/modules' +import { getLoadedLabware } from '/app/local-resources/labware' import { useNotifyDeckConfigurationQuery } from '/app/resources/deck_configuration' import type { @@ -135,7 +133,7 @@ export function MoveLabwareInterventionContent({ deckDef ) const oldLabwareLocation = - getLoadedLabware(run, command.params.labwareId)?.location ?? null + getLoadedLabware(run.labware, command.params.labwareId)?.location ?? null const labwareName = getLabwareNameFromRunData( run, @@ -275,8 +273,8 @@ function LabwareDisplayLocation( console.warn('labware is located on an unknown module model') } else { const slotName = - getLoadedModule(protocolData, location.moduleId)?.location?.slotName ?? - '' + getLoadedModule(protocolData.modules, location.moduleId)?.location + ?.slotName ?? '' const isModuleUnderAdapterThermocycler = getModuleType(moduleModel) === THERMOCYCLER_MODULE_TYPE if (isModuleUnderAdapterThermocycler) { @@ -309,8 +307,8 @@ function LabwareDisplayLocation( console.warn('labware is located on an adapter on an unknown module') } else { const slotName = - getLoadedModule(protocolData, adapter.location.moduleId)?.location - ?.slotName ?? '' + getLoadedModule(protocolData.modules, adapter.location.moduleId) + ?.location?.slotName ?? '' const isModuleUnderAdapterThermocycler = getModuleType(moduleModel) === THERMOCYCLER_MODULE_TYPE if (isModuleUnderAdapterThermocycler) { diff --git a/app/src/organisms/InterventionModal/utils/getLabwareNameFromRunData.ts b/app/src/organisms/InterventionModal/utils/getLabwareNameFromRunData.ts index b6671a32a3b..55b48efee29 100644 --- a/app/src/organisms/InterventionModal/utils/getLabwareNameFromRunData.ts +++ b/app/src/organisms/InterventionModal/utils/getLabwareNameFromRunData.ts @@ -1,6 +1,8 @@ import { getLabwareDefURI, getLabwareDisplayName } from '@opentrons/shared-data' -import { getLoadedLabware } from '/app/molecules/Command/utils/accessors' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { + getLoadedLabware, + getLabwareDefinitionsFromCommands, +} from '/app/local-resources/labware' import type { RunTimeCommand } from '@opentrons/shared-data' import type { RunData } from '@opentrons/api-client' @@ -15,7 +17,7 @@ export function getLabwareNameFromRunData( labwareId: string, commands: RunTimeCommand[] ): string { - const loadedLabware = getLoadedLabware(protocolData, labwareId) + const loadedLabware = getLoadedLabware(protocolData.labware, labwareId) if (loadedLabware == null) { return '' } else if (FIXED_TRASH_DEF_URIS.includes(loadedLabware.definitionUri)) { diff --git a/app/src/organisms/InterventionModal/utils/getModuleDisplayLocationFromRunData.ts b/app/src/organisms/InterventionModal/utils/getModuleDisplayLocationFromRunData.ts index 3301cb6c77c..0b96641e9e5 100644 --- a/app/src/organisms/InterventionModal/utils/getModuleDisplayLocationFromRunData.ts +++ b/app/src/organisms/InterventionModal/utils/getModuleDisplayLocationFromRunData.ts @@ -1,4 +1,4 @@ -import { getLoadedModule } from '/app/molecules/Command/utils/accessors' +import { getLoadedModule } from '/app/local-resources/modules' import type { RunData } from '@opentrons/api-client' @@ -6,6 +6,6 @@ export function getModuleDisplayLocationFromRunData( protocolData: RunData, moduleId: string ): string { - const loadedModule = getLoadedModule(protocolData, moduleId) + const loadedModule = getLoadedModule(protocolData.modules, moduleId) return loadedModule != null ? loadedModule.location.slotName : '' } diff --git a/app/src/organisms/InterventionModal/utils/getModuleModelFromRunData.ts b/app/src/organisms/InterventionModal/utils/getModuleModelFromRunData.ts index c709e5b9ab4..e22c1895918 100644 --- a/app/src/organisms/InterventionModal/utils/getModuleModelFromRunData.ts +++ b/app/src/organisms/InterventionModal/utils/getModuleModelFromRunData.ts @@ -1,4 +1,4 @@ -import { getLoadedModule } from '/app/molecules/Command/utils/accessors' +import { getLoadedModule } from '/app/local-resources/modules' import type { RunData } from '@opentrons/api-client' import type { ModuleModel } from '@opentrons/shared-data' @@ -7,6 +7,6 @@ export function getModuleModelFromRunData( protocolData: RunData, moduleId: string ): ModuleModel | null { - const loadedModule = getLoadedModule(protocolData, moduleId) + const loadedModule = getLoadedModule(protocolData.modules, moduleId) return loadedModule != null ? loadedModule.model : null } diff --git a/app/src/organisms/LabwarePositionCheck/CheckItem.tsx b/app/src/organisms/LabwarePositionCheck/CheckItem.tsx index 9659319d24d..c9050b5dd3f 100644 --- a/app/src/organisms/LabwarePositionCheck/CheckItem.tsx +++ b/app/src/organisms/LabwarePositionCheck/CheckItem.tsx @@ -23,7 +23,7 @@ import { } from '@opentrons/shared-data' import { useSelector } from 'react-redux' import { getLabwareDef } from './utils/labware' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import { UnorderedList } from '/app/molecules/UnorderedList' import { getCurrentOffsetForLabwareInLocation } from '/app/transformations/analysis' import { getIsOnDevice } from '/app/redux/config' diff --git a/app/src/organisms/LabwarePositionCheck/IntroScreen/index.tsx b/app/src/organisms/LabwarePositionCheck/IntroScreen/index.tsx index 8c372750b78..dbaa5970c6c 100644 --- a/app/src/organisms/LabwarePositionCheck/IntroScreen/index.tsx +++ b/app/src/organisms/LabwarePositionCheck/IntroScreen/index.tsx @@ -30,7 +30,7 @@ import { getTopPortalEl } from '/app/App/portal' import { SmallButton } from '/app/atoms/buttons' import { CALIBRATION_PROBE } from '/app/organisms/PipetteWizardFlows/constants' import { TerseOffsetTable } from '../ResultsSummary' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import type { LabwareOffset } from '@opentrons/api-client' import type { diff --git a/app/src/organisms/LabwarePositionCheck/PickUpTip.tsx b/app/src/organisms/LabwarePositionCheck/PickUpTip.tsx index f93d2febe1b..c7505a13d92 100644 --- a/app/src/organisms/LabwarePositionCheck/PickUpTip.tsx +++ b/app/src/organisms/LabwarePositionCheck/PickUpTip.tsx @@ -22,7 +22,7 @@ import { UnorderedList } from '/app/molecules/UnorderedList' import { getCurrentOffsetForLabwareInLocation } from '/app/transformations/analysis' import { TipConfirmation } from './TipConfirmation' import { getLabwareDef } from './utils/labware' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import { getDisplayLocation } from './utils/getDisplayLocation' import { useSelector } from 'react-redux' import { getIsOnDevice } from '/app/redux/config' diff --git a/app/src/organisms/LabwarePositionCheck/ResultsSummary.tsx b/app/src/organisms/LabwarePositionCheck/ResultsSummary.tsx index e4489cea914..98f88fac2bd 100644 --- a/app/src/organisms/LabwarePositionCheck/ResultsSummary.tsx +++ b/app/src/organisms/LabwarePositionCheck/ResultsSummary.tsx @@ -38,7 +38,7 @@ import { import { SmallButton } from '/app/atoms/buttons' import { LabwareOffsetTabs } from '/app/organisms/LabwareOffsetTabs' import { getCurrentOffsetForLabwareInLocation } from '/app/transformations/analysis' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import { getDisplayLocation } from './utils/getDisplayLocation' import type { diff --git a/app/src/organisms/LabwarePositionCheck/ReturnTip.tsx b/app/src/organisms/LabwarePositionCheck/ReturnTip.tsx index 8ba2f78d125..fce1f443829 100644 --- a/app/src/organisms/LabwarePositionCheck/ReturnTip.tsx +++ b/app/src/organisms/LabwarePositionCheck/ReturnTip.tsx @@ -13,7 +13,7 @@ import { } from '@opentrons/shared-data' import { UnorderedList } from '/app/molecules/UnorderedList' import { getLabwareDef } from './utils/labware' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import { getDisplayLocation } from './utils/getDisplayLocation' import { RobotMotionLoader } from './RobotMotionLoader' import { PrepareSpace } from './PrepareSpace' diff --git a/app/src/organisms/LabwarePositionCheck/useLaunchLPC.tsx b/app/src/organisms/LabwarePositionCheck/useLaunchLPC.tsx index fad314f7af3..18c906d2998 100644 --- a/app/src/organisms/LabwarePositionCheck/useLaunchLPC.tsx +++ b/app/src/organisms/LabwarePositionCheck/useLaunchLPC.tsx @@ -11,7 +11,7 @@ import { useMostRecentCompletedAnalysis, } from '/app/resources/runs' import { LabwarePositionCheck } from '.' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import type { RobotType } from '@opentrons/shared-data' diff --git a/app/src/organisms/LabwarePositionCheck/utils/getProbeBasedLPCSteps.ts b/app/src/organisms/LabwarePositionCheck/utils/getProbeBasedLPCSteps.ts index 0f03ad0e92b..f5e4ed86f0b 100644 --- a/app/src/organisms/LabwarePositionCheck/utils/getProbeBasedLPCSteps.ts +++ b/app/src/organisms/LabwarePositionCheck/utils/getProbeBasedLPCSteps.ts @@ -2,7 +2,7 @@ import { isEqual } from 'lodash' import { SECTIONS } from '../constants' import { getLabwareDefURI, getPipetteNameSpecs } from '@opentrons/shared-data' import { getLabwareLocationCombos } from '../../ApplyHistoricOffsets/hooks/getLabwareLocationCombos' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import type { CompletedProtocolAnalysis, diff --git a/app/src/organisms/LabwarePositionCheck/utils/getTipBasedLPCSteps.ts b/app/src/organisms/LabwarePositionCheck/utils/getTipBasedLPCSteps.ts index c03660a6f20..47c30424e95 100644 --- a/app/src/organisms/LabwarePositionCheck/utils/getTipBasedLPCSteps.ts +++ b/app/src/organisms/LabwarePositionCheck/utils/getTipBasedLPCSteps.ts @@ -1,6 +1,6 @@ import { isEqual } from 'lodash' import { SECTIONS } from '../constants' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import { getLabwareDefURI, getIsTiprack, diff --git a/app/src/organisms/LabwarePositionCheck/utils/labware.ts b/app/src/organisms/LabwarePositionCheck/utils/labware.ts index 2fd03ccc0c0..70096061c33 100644 --- a/app/src/organisms/LabwarePositionCheck/utils/labware.ts +++ b/app/src/organisms/LabwarePositionCheck/utils/labware.ts @@ -5,7 +5,7 @@ import { getLabwareDefURI, } from '@opentrons/shared-data' import { getModuleInitialLoadInfo } from '/app/transformations/commands' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import type { CompletedProtocolAnalysis, LabwareDefinition2, diff --git a/app/src/organisms/ODD/ProtocolSetup/ProtocolSetupOffsets/index.tsx b/app/src/organisms/ODD/ProtocolSetup/ProtocolSetupOffsets/index.tsx index 3f287ea80e6..3082df45a2a 100644 --- a/app/src/organisms/ODD/ProtocolSetup/ProtocolSetupOffsets/index.tsx +++ b/app/src/organisms/ODD/ProtocolSetup/ProtocolSetupOffsets/index.tsx @@ -17,7 +17,7 @@ import { ODDBackButton } from '/app/molecules/ODDBackButton' import { FloatingActionButton, SmallButton } from '/app/atoms/buttons' import type { SetupScreens } from '../types' import { TerseOffsetTable } from '/app/organisms/LabwarePositionCheck/ResultsSummary' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command/utils/getLabwareDefinitionsFromCommands' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import { useNotifyRunQuery, useMostRecentCompletedAnalysis, diff --git a/app/src/organisms/ODD/RunningProtocol/CurrentRunningProtocolCommand.tsx b/app/src/organisms/ODD/RunningProtocol/CurrentRunningProtocolCommand.tsx index f87f7cd71e9..be9e5e25cbb 100644 --- a/app/src/organisms/ODD/RunningProtocol/CurrentRunningProtocolCommand.tsx +++ b/app/src/organisms/ODD/RunningProtocol/CurrentRunningProtocolCommand.tsx @@ -21,7 +21,7 @@ import { RUN_STATUS_RUNNING, RUN_STATUS_IDLE } from '@opentrons/api-client' import { CommandText } from '/app/molecules/Command' import { RunTimer } from '/app/molecules/RunTimer' -import { getCommandTextData } from '/app/molecules/Command/utils/getCommandTextData' +import { getCommandTextData } from '/app/local-resources/commands' import { PlayPauseButton } from './PlayPauseButton' import { StopButton } from './StopButton' import { ANALYTICS_PROTOCOL_RUN_ACTION } from '/app/redux/analytics' diff --git a/app/src/organisms/ODD/RunningProtocol/RunningProtocolCommandList.tsx b/app/src/organisms/ODD/RunningProtocol/RunningProtocolCommandList.tsx index 3e928ed88b4..e49b725ab35 100644 --- a/app/src/organisms/ODD/RunningProtocol/RunningProtocolCommandList.tsx +++ b/app/src/organisms/ODD/RunningProtocol/RunningProtocolCommandList.tsx @@ -23,7 +23,7 @@ import { import { RUN_STATUS_RUNNING, RUN_STATUS_IDLE } from '@opentrons/api-client' import { CommandText, CommandIcon } from '/app/molecules/Command' -import { getCommandTextData } from '/app/molecules/Command/utils/getCommandTextData' +import { getCommandTextData } from '/app/local-resources/commands' import { PlayPauseButton } from './PlayPauseButton' import { StopButton } from './StopButton' import { ANALYTICS_PROTOCOL_RUN_ACTION } from '/app/redux/analytics' diff --git a/app/src/pages/ODD/RunningProtocol/index.tsx b/app/src/pages/ODD/RunningProtocol/index.tsx index b75284386b8..4c63302564e 100644 --- a/app/src/pages/ODD/RunningProtocol/index.tsx +++ b/app/src/pages/ODD/RunningProtocol/index.tsx @@ -57,7 +57,7 @@ import { useErrorRecoveryFlows, ErrorRecoveryFlows, } from '/app/organisms/ErrorRecoveryFlows' -import { getLabwareDefinitionsFromCommands } from '/app/molecules/Command' +import { getLabwareDefinitionsFromCommands } from '/app/local-resources/labware' import type { OnDeviceRouteParams } from '/app/App/types'