From 73ee626ab5a14ea94ee20a87d111a7173b63b91b Mon Sep 17 00:00:00 2001 From: Brian Cooper Date: Fri, 19 Apr 2024 16:44:50 -0400 Subject: [PATCH] start maintenance run after altering deck config --- .../ModuleWizardFlows/BeforeBeginning.tsx | 35 ++---------------- .../ModuleWizardFlows/PlaceAdapter.tsx | 24 ++++++++++++ app/src/organisms/ModuleWizardFlows/index.tsx | 13 ++----- .../hardware-sim/DeckConfigurator/index.tsx | 37 +++++++++---------- 4 files changed, 49 insertions(+), 60 deletions(-) diff --git a/app/src/organisms/ModuleWizardFlows/BeforeBeginning.tsx b/app/src/organisms/ModuleWizardFlows/BeforeBeginning.tsx index bd899457b21..a4a18a2f3f3 100644 --- a/app/src/organisms/ModuleWizardFlows/BeforeBeginning.tsx +++ b/app/src/organisms/ModuleWizardFlows/BeforeBeginning.tsx @@ -1,5 +1,4 @@ import * as React from 'react' -import { UseMutateFunction } from 'react-query' import { Trans, useTranslation } from 'react-i18next' import { @@ -12,12 +11,7 @@ import { StyledText } from '@opentrons/components' import { GenericWizardTile } from '../../molecules/GenericWizardTile' import { WizardRequiredEquipmentList } from '../../molecules/WizardRequiredEquipmentList' -import type { - CreateMaintenanceRunData, - MaintenanceRun, - AttachedModule, -} from '@opentrons/api-client' -import type { AxiosError } from 'axios' +import type { AttachedModule } from '@opentrons/api-client' import type { ModuleCalibrationWizardStepProps } from './types' interface EqipmentItem { @@ -26,34 +20,14 @@ interface EqipmentItem { subtitle?: string } -interface BeforeBeginningProps extends ModuleCalibrationWizardStepProps { - createMaintenanceRun: UseMutateFunction< - MaintenanceRun, - AxiosError, - CreateMaintenanceRunData, - unknown - > - isCreateLoading: boolean - createdMaintenanceRunId: string | null -} +type BeforeBeginningProps = ModuleCalibrationWizardStepProps export const BeforeBeginning = ( props: BeforeBeginningProps ): JSX.Element | null => { - const { - proceed, - createMaintenanceRun, - isCreateLoading, - attachedModule, - maintenanceRunId, - createdMaintenanceRunId, - } = props + const { proceed, attachedModule } = props const { t } = useTranslation(['module_wizard_flows', 'shared']) - React.useEffect(() => { - if (createdMaintenanceRunId == null) { - createMaintenanceRun({}) - } - }, []) + const moduleDisplayName = getModuleDisplayName(attachedModule.moduleModel) let adapterLoadname: string @@ -109,7 +83,6 @@ export const BeforeBeginning = ( /> } proceedButtonText={t('start_setup')} - proceedIsDisabled={isCreateLoading || maintenanceRunId == null} proceed={proceed} /> ) diff --git a/app/src/organisms/ModuleWizardFlows/PlaceAdapter.tsx b/app/src/organisms/ModuleWizardFlows/PlaceAdapter.tsx index d0424523008..b5d5e5cf80d 100644 --- a/app/src/organisms/ModuleWizardFlows/PlaceAdapter.tsx +++ b/app/src/organisms/ModuleWizardFlows/PlaceAdapter.tsx @@ -33,10 +33,24 @@ import { LEFT_SLOTS } from './constants' import type { DeckConfiguration, CreateCommand } from '@opentrons/shared-data' import type { ModuleCalibrationWizardStepProps } from './types' +import type { AxiosError } from 'axios' +import type { UseMutateFunction } from 'react-query' +import type { + CreateMaintenanceRunData, + MaintenanceRun, +} from '@opentrons/api-client' interface PlaceAdapterProps extends ModuleCalibrationWizardStepProps { deckConfig: DeckConfiguration setCreatedAdapterId: (adapterId: string) => void + createMaintenanceRun: UseMutateFunction< + MaintenanceRun, + AxiosError, + CreateMaintenanceRunData, + unknown + > + isCreateLoading: boolean + createdMaintenanceRunId: string | null } export const BODY_STYLE = css` @@ -59,8 +73,17 @@ export const PlaceAdapter = (props: PlaceAdapterProps): JSX.Element | null => { setCreatedAdapterId, attachedPipette, isRobotMoving, + maintenanceRunId, + createMaintenanceRun, + isCreateLoading, + createdMaintenanceRunId, } = props const { t } = useTranslation('module_wizard_flows') + React.useEffect(() => { + if (createdMaintenanceRunId == null) { + createMaintenanceRun({}) + } + }, []) const mount = attachedPipette.mount const cutoutId = deckConfig.find( cc => @@ -208,6 +231,7 @@ export const PlaceAdapter = (props: PlaceAdapterProps): JSX.Element | null => { bodyText={bodyText} proceedButtonText={t('confirm_placement')} proceed={handleOnClick} + proceedIsDisabled={isCreateLoading || maintenanceRunId == null} back={goBack} /> ) diff --git a/app/src/organisms/ModuleWizardFlows/index.tsx b/app/src/organisms/ModuleWizardFlows/index.tsx index 24b5453fa3e..3e0977a4f23 100644 --- a/app/src/organisms/ModuleWizardFlows/index.tsx +++ b/app/src/organisms/ModuleWizardFlows/index.tsx @@ -300,15 +300,7 @@ export const ModuleWizardFlows = ( } else if (isExiting) { modalContent = } else if (currentStep.section === SECTIONS.BEFORE_BEGINNING) { - modalContent = ( - - ) + modalContent = } else if (currentStep.section === SECTIONS.SELECT_LOCATION) { modalContent = ( ) } else if (currentStep.section === SECTIONS.ATTACH_PROBE) { diff --git a/components/src/hardware-sim/DeckConfigurator/index.tsx b/components/src/hardware-sim/DeckConfigurator/index.tsx index 6d31e69bfee..8de6ba4da70 100644 --- a/components/src/hardware-sim/DeckConfigurator/index.tsx +++ b/components/src/hardware-sim/DeckConfigurator/index.tsx @@ -66,45 +66,42 @@ export function DeckConfigurator(props: DeckConfiguratorProps): JSX.Element { } = props const deckDef = getDeckDefFromRobotType(FLEX_ROBOT_TYPE) - const configurableDeckConfig = deckConfig.filter(({ cutoutId }) => - editableCutoutIds.includes(cutoutId) - ) - - const stagingAreaFixtures = configurableDeckConfig.filter( + const stagingAreaFixtures = deckConfig.filter( ({ cutoutFixtureId }) => cutoutFixtureId === STAGING_AREA_RIGHT_SLOT_FIXTURE ) - const wasteChuteFixtures = configurableDeckConfig.filter( + const wasteChuteFixtures = deckConfig.filter( ({ cutoutFixtureId }) => cutoutFixtureId != null && WASTE_CHUTE_ONLY_FIXTURES.includes(cutoutFixtureId) ) - const wasteChuteStagingAreaFixtures = configurableDeckConfig.filter( + const wasteChuteStagingAreaFixtures = deckConfig.filter( ({ cutoutFixtureId }) => cutoutFixtureId != null && WASTE_CHUTE_STAGING_AREA_FIXTURES.includes(cutoutFixtureId) ) - const emptyCutouts = configurableDeckConfig.filter( - ({ cutoutFixtureId }) => - cutoutFixtureId != null && SINGLE_SLOT_FIXTURES.includes(cutoutFixtureId) + const emptyCutouts = deckConfig.filter( + ({ cutoutFixtureId, cutoutId }) => + editableCutoutIds.includes(cutoutId) && + cutoutFixtureId != null && + SINGLE_SLOT_FIXTURES.includes(cutoutFixtureId) ) - const trashBinFixtures = configurableDeckConfig.filter( + const trashBinFixtures = deckConfig.filter( ({ cutoutFixtureId }) => cutoutFixtureId === TRASH_BIN_ADAPTER_FIXTURE ) - const thermocyclerFixtures = configurableDeckConfig.filter( + const thermocyclerFixtures = deckConfig.filter( ({ cutoutFixtureId }) => cutoutFixtureId === THERMOCYCLER_V2_FRONT_FIXTURE ) - const heaterShakerFixtures = configurableDeckConfig.filter( + const heaterShakerFixtures = deckConfig.filter( ({ cutoutFixtureId }) => cutoutFixtureId === HEATERSHAKER_MODULE_V1_FIXTURE ) - const temperatureModuleFixtures = configurableDeckConfig.filter( + const temperatureModuleFixtures = deckConfig.filter( ({ cutoutFixtureId }) => cutoutFixtureId === TEMPERATURE_MODULE_V2_FIXTURE ) - const magneticBlockFixtures = configurableDeckConfig.filter( - ({ cutoutFixtureId }) => - ([ - MAGNETIC_BLOCK_V1_FIXTURE, - STAGING_AREA_SLOT_WITH_MAGNETIC_BLOCK_V1_FIXTURE, - ] as CutoutFixtureId[]).includes(cutoutFixtureId) + const magneticBlockFixtures = deckConfig.filter(({ cutoutFixtureId }) => + ([ + MAGNETIC_BLOCK_V1_FIXTURE, + STAGING_AREA_SLOT_WITH_MAGNETIC_BLOCK_V1_FIXTURE, + ] as CutoutFixtureId[]).includes(cutoutFixtureId) ) return (