Skip to content

Commit 97da85c

Browse files
authored
fix(app): wait for maintenance run deletion before closing flows (#15201)
fix RABR-290
1 parent ecd6ab0 commit 97da85c

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

app/src/organisms/GripperWizardFlows/index.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as React from 'react'
22
import { createPortal } from 'react-dom'
33
import { useTranslation } from 'react-i18next'
44
import { useSelector } from 'react-redux'
5-
import { UseMutateFunction } from 'react-query'
65
import {
76
useConditionalConfirm,
87
Flex,
@@ -35,6 +34,7 @@ import { UnmountGripper } from './UnmountGripper'
3534
import { Success } from './Success'
3635
import { ExitConfirmation } from './ExitConfirmation'
3736

37+
import type { UseMutateFunction } from 'react-query'
3838
import type { GripperWizardFlowType } from './types'
3939
import type { AxiosError } from 'axios'
4040
import type {
@@ -120,11 +120,18 @@ export function GripperWizardFlows(
120120
if (props?.onComplete != null) props.onComplete()
121121
if (maintenanceRunData != null) {
122122
deleteMaintenanceRun(maintenanceRunData?.data.id)
123+
} else {
124+
closeFlow()
123125
}
124-
closeFlow()
125126
}
126127

127-
const { deleteMaintenanceRun } = useDeleteMaintenanceRunMutation({})
128+
const {
129+
deleteMaintenanceRun,
130+
isLoading: isDeleteLoading,
131+
} = useDeleteMaintenanceRunMutation({
132+
onSuccess: () => closeFlow(),
133+
onError: () => closeFlow(),
134+
})
128135

129136
const handleCleanUpAndClose = (): void => {
130137
if (maintenanceRunData?.data.id == null) handleClose()
@@ -153,7 +160,10 @@ export function GripperWizardFlows(
153160
createMaintenanceRun={createTargetedMaintenanceRun}
154161
isCreateLoading={isCreateLoading}
155162
isRobotMoving={
156-
isChainCommandMutationLoading || isCommandLoading || isExiting
163+
isChainCommandMutationLoading ||
164+
isCommandLoading ||
165+
isExiting ||
166+
isDeleteLoading
157167
}
158168
handleCleanUpAndClose={handleCleanUpAndClose}
159169
handleClose={handleClose}

app/src/organisms/PipetteWizardFlows/index.tsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ import { useTranslation } from 'react-i18next'
55
import NiceModal, { useModal } from '@ebay/nice-modal-react'
66

77
import { useConditionalConfirm, COLORS } from '@opentrons/components'
8-
import {
9-
LEFT,
10-
NINETY_SIX_CHANNEL,
11-
RIGHT,
12-
LoadedPipette,
13-
CreateCommand,
14-
} from '@opentrons/shared-data'
8+
import { LEFT, NINETY_SIX_CHANNEL, RIGHT } from '@opentrons/shared-data'
159
import {
1610
useHost,
1711
useDeleteMaintenanceRunMutation,
@@ -28,6 +22,7 @@ import { getTopPortalEl } from '../../App/portal'
2822
import { WizardHeader } from '../../molecules/WizardHeader'
2923
import { FirmwareUpdateModal } from '../FirmwareUpdateModal'
3024
import { getIsOnDevice } from '../../redux/config'
25+
import { SimpleWizardBody } from '../../molecules/SimpleWizardBody'
3126
import { useAttachedPipettesFromInstrumentsQuery } from '../Devices/hooks'
3227
import { usePipetteFlowWizardHeaderText } from './hooks'
3328
import { getPipetteWizardSteps } from './getPipetteWizardSteps'
@@ -44,10 +39,13 @@ import { Carriage } from './Carriage'
4439
import { MountingPlate } from './MountingPlate'
4540
import { UnskippableModal } from './UnskippableModal'
4641

47-
import type { PipetteMount } from '@opentrons/shared-data'
42+
import type {
43+
LoadedPipette,
44+
CreateCommand,
45+
PipetteMount,
46+
} from '@opentrons/shared-data'
4847
import type { CommandData, HostConfig } from '@opentrons/api-client'
4948
import type { PipetteWizardFlow, SelectablePipettes } from './types'
50-
import { SimpleWizardBody } from '../../molecules/SimpleWizardBody'
5149

5250
const RUN_REFETCH_INTERVAL = 5000
5351

@@ -185,11 +183,18 @@ export const PipetteWizardFlows = (
185183
if (onComplete != null) onComplete()
186184
if (maintenanceRunData != null) {
187185
deleteMaintenanceRun(maintenanceRunData?.data.id)
186+
} else {
187+
closeFlow()
188188
}
189-
closeFlow()
190189
}
191190

192-
const { deleteMaintenanceRun } = useDeleteMaintenanceRunMutation({})
191+
const {
192+
deleteMaintenanceRun,
193+
isLoading: isDeleteLoading,
194+
} = useDeleteMaintenanceRunMutation({
195+
onSuccess: () => closeFlow(),
196+
onError: () => closeFlow(),
197+
})
193198

194199
const handleCleanUpAndClose = (): void => {
195200
if (maintenanceRunData?.data.id == null) handleClose()
@@ -234,7 +239,7 @@ export const PipetteWizardFlows = (
234239
: undefined
235240
const calibrateBaseProps = {
236241
chainRunCommands: chainMaintenanceRunCommands,
237-
isRobotMoving: isCommandMutationLoading,
242+
isRobotMoving: isCommandMutationLoading || isDeleteLoading,
238243
proceed,
239244
maintenanceRunId,
240245
goBack,
@@ -255,11 +260,11 @@ export const PipetteWizardFlows = (
255260
proceed={handleCleanUpAndClose}
256261
goBack={cancelExit}
257262
isOnDevice={isOnDevice}
258-
isRobotMoving={isCommandMutationLoading}
263+
isRobotMoving={isCommandMutationLoading || isDeleteLoading}
259264
/>
260265
) : (
261266
<ExitModal
262-
isRobotMoving={isCommandMutationLoading}
267+
isRobotMoving={isCommandMutationLoading || isDeleteLoading}
263268
goBack={cancelExit}
264269
proceed={handleCleanUpAndClose}
265270
flowType={flowType}
@@ -383,7 +388,7 @@ export const PipetteWizardFlows = (
383388
}
384389

385390
let exitWizardButton = onExit
386-
if (isCommandMutationLoading) {
391+
if (isCommandMutationLoading || isDeleteLoading) {
387392
exitWizardButton = undefined
388393
} else if (errorMessage != null && isExiting) {
389394
exitWizardButton = handleClose

0 commit comments

Comments
 (0)