Skip to content

Commit

Permalink
fix(app): wait for maintenance run deletion before closing flows (#15201
Browse files Browse the repository at this point in the history
)

fix RABR-290
  • Loading branch information
smb2268 authored May 16, 2024
1 parent ecd6ab0 commit 97da85c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 19 deletions.
18 changes: 14 additions & 4 deletions app/src/organisms/GripperWizardFlows/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react'
import { createPortal } from 'react-dom'
import { useTranslation } from 'react-i18next'
import { useSelector } from 'react-redux'
import { UseMutateFunction } from 'react-query'
import {
useConditionalConfirm,
Flex,
Expand Down Expand Up @@ -35,6 +34,7 @@ import { UnmountGripper } from './UnmountGripper'
import { Success } from './Success'
import { ExitConfirmation } from './ExitConfirmation'

import type { UseMutateFunction } from 'react-query'
import type { GripperWizardFlowType } from './types'
import type { AxiosError } from 'axios'
import type {
Expand Down Expand Up @@ -120,11 +120,18 @@ export function GripperWizardFlows(
if (props?.onComplete != null) props.onComplete()
if (maintenanceRunData != null) {
deleteMaintenanceRun(maintenanceRunData?.data.id)
} else {
closeFlow()
}
closeFlow()
}

const { deleteMaintenanceRun } = useDeleteMaintenanceRunMutation({})
const {
deleteMaintenanceRun,
isLoading: isDeleteLoading,
} = useDeleteMaintenanceRunMutation({
onSuccess: () => closeFlow(),
onError: () => closeFlow(),
})

const handleCleanUpAndClose = (): void => {
if (maintenanceRunData?.data.id == null) handleClose()
Expand Down Expand Up @@ -153,7 +160,10 @@ export function GripperWizardFlows(
createMaintenanceRun={createTargetedMaintenanceRun}
isCreateLoading={isCreateLoading}
isRobotMoving={
isChainCommandMutationLoading || isCommandLoading || isExiting
isChainCommandMutationLoading ||
isCommandLoading ||
isExiting ||
isDeleteLoading
}
handleCleanUpAndClose={handleCleanUpAndClose}
handleClose={handleClose}
Expand Down
35 changes: 20 additions & 15 deletions app/src/organisms/PipetteWizardFlows/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ import { useTranslation } from 'react-i18next'
import NiceModal, { useModal } from '@ebay/nice-modal-react'

import { useConditionalConfirm, COLORS } from '@opentrons/components'
import {
LEFT,
NINETY_SIX_CHANNEL,
RIGHT,
LoadedPipette,
CreateCommand,
} from '@opentrons/shared-data'
import { LEFT, NINETY_SIX_CHANNEL, RIGHT } from '@opentrons/shared-data'
import {
useHost,
useDeleteMaintenanceRunMutation,
Expand All @@ -28,6 +22,7 @@ import { getTopPortalEl } from '../../App/portal'
import { WizardHeader } from '../../molecules/WizardHeader'
import { FirmwareUpdateModal } from '../FirmwareUpdateModal'
import { getIsOnDevice } from '../../redux/config'
import { SimpleWizardBody } from '../../molecules/SimpleWizardBody'
import { useAttachedPipettesFromInstrumentsQuery } from '../Devices/hooks'
import { usePipetteFlowWizardHeaderText } from './hooks'
import { getPipetteWizardSteps } from './getPipetteWizardSteps'
Expand All @@ -44,10 +39,13 @@ import { Carriage } from './Carriage'
import { MountingPlate } from './MountingPlate'
import { UnskippableModal } from './UnskippableModal'

import type { PipetteMount } from '@opentrons/shared-data'
import type {
LoadedPipette,
CreateCommand,
PipetteMount,
} from '@opentrons/shared-data'
import type { CommandData, HostConfig } from '@opentrons/api-client'
import type { PipetteWizardFlow, SelectablePipettes } from './types'
import { SimpleWizardBody } from '../../molecules/SimpleWizardBody'

const RUN_REFETCH_INTERVAL = 5000

Expand Down Expand Up @@ -185,11 +183,18 @@ export const PipetteWizardFlows = (
if (onComplete != null) onComplete()
if (maintenanceRunData != null) {
deleteMaintenanceRun(maintenanceRunData?.data.id)
} else {
closeFlow()
}
closeFlow()
}

const { deleteMaintenanceRun } = useDeleteMaintenanceRunMutation({})
const {
deleteMaintenanceRun,
isLoading: isDeleteLoading,
} = useDeleteMaintenanceRunMutation({
onSuccess: () => closeFlow(),
onError: () => closeFlow(),
})

const handleCleanUpAndClose = (): void => {
if (maintenanceRunData?.data.id == null) handleClose()
Expand Down Expand Up @@ -234,7 +239,7 @@ export const PipetteWizardFlows = (
: undefined
const calibrateBaseProps = {
chainRunCommands: chainMaintenanceRunCommands,
isRobotMoving: isCommandMutationLoading,
isRobotMoving: isCommandMutationLoading || isDeleteLoading,
proceed,
maintenanceRunId,
goBack,
Expand All @@ -255,11 +260,11 @@ export const PipetteWizardFlows = (
proceed={handleCleanUpAndClose}
goBack={cancelExit}
isOnDevice={isOnDevice}
isRobotMoving={isCommandMutationLoading}
isRobotMoving={isCommandMutationLoading || isDeleteLoading}
/>
) : (
<ExitModal
isRobotMoving={isCommandMutationLoading}
isRobotMoving={isCommandMutationLoading || isDeleteLoading}
goBack={cancelExit}
proceed={handleCleanUpAndClose}
flowType={flowType}
Expand Down Expand Up @@ -383,7 +388,7 @@ export const PipetteWizardFlows = (
}

let exitWizardButton = onExit
if (isCommandMutationLoading) {
if (isCommandMutationLoading || isDeleteLoading) {
exitWizardButton = undefined
} else if (errorMessage != null && isExiting) {
exitWizardButton = handleClose
Expand Down

0 comments on commit 97da85c

Please sign in to comment.