Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): wait for maintenance run deletion before closing flows #15201

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading