Skip to content

Commit

Permalink
fix(app): App delete quick transfer desktop (#16052)
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 authored Aug 19, 2024
1 parent f71c99e commit 104b461
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
39 changes: 35 additions & 4 deletions app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import {
useModulesQuery,
useDoorQuery,
useDeleteRunMutation,
useHost,
useRunCommandErrors,
} from '@opentrons/react-api-client'
Expand Down Expand Up @@ -158,6 +159,7 @@ export function ProtocolRunHeader({
displayName,
protocolKey,
isProtocolAnalyzing,
isQuickTransfer,
} = useProtocolDetailsForRun(runId)
const storedProtocol = useSelector((state: State) =>
getStoredProtocol(state, protocolKey)
Expand All @@ -168,6 +170,7 @@ export function ProtocolRunHeader({
const robotAnalyticsData = useRobotAnalyticsData(robotName)
const isRobotViewable = useIsRobotViewable(robotName)
const runStatus = useRunStatus(runId)
const { deleteRun } = useDeleteRunMutation()
const { analysisErrors } = useProtocolAnalysisErrors(runId)
const isRunCurrent = Boolean(
useNotifyRunQuery(runId, { refetchInterval: CURRENT_RUN_POLL_MS })?.data
Expand Down Expand Up @@ -251,7 +254,14 @@ export function ProtocolRunHeader({
mount: aPipetteWithTip?.mount,
robotType,
onSkipAndHome: () => {
closeCurrentRun()
closeCurrentRun({
onSettled: () => {
if (isQuickTransfer) {
deleteRun(runId)
navigate(`/devices/${robotName}`)
}
},
})
},
})

Expand Down Expand Up @@ -302,7 +312,14 @@ export function ProtocolRunHeader({
// Close the run if no tips are attached after running tip check at least once.
// This marks the robot as "not busy" as soon as a run is cancelled if drop tip CTAs are unnecessary.
if (initialPipettesWithTipsCount === 0 && !enteredER) {
closeCurrentRun()
closeCurrentRun({
onSettled: () => {
if (isQuickTransfer) {
deleteRun(runId)
navigate(`/devices/${robotName}`)
}
},
})
}
}
}, [runStatus, isRunCurrent, runId, enteredER])
Expand Down Expand Up @@ -351,7 +368,14 @@ export function ProtocolRunHeader({
name: ANALYTICS_PROTOCOL_RUN_ACTION.FINISH,
properties: robotAnalyticsData ?? undefined,
})
closeCurrentRun()
closeCurrentRun({
onSettled: () => {
if (isQuickTransfer) {
deleteRun(runId)
navigate(`/devices/${robotName}`)
}
},
})
}

return (
Expand Down Expand Up @@ -543,7 +567,14 @@ export function ProtocolRunHeader({
} else {
void setTipStatusResolved(() => {
toggleDTWiz()
closeCurrentRun()
closeCurrentRun({
onSettled: () => {
if (isQuickTransfer) {
deleteRun(runId)
navigate(`/devices/${robotName}`)
}
},
})
}, toggleDTWiz)
}
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
useModulesQuery,
usePipettesQuery,
useDismissCurrentRunMutation,
useDeleteRunMutation,
useEstopQuery,
useDoorQuery,
useInstrumentsQuery,
Expand Down Expand Up @@ -187,6 +188,7 @@ const PROTOCOL_DETAILS = {
protocolKey: PROTOCOL_KEY,
isProtocolAnalyzing: false,
robotType: 'OT-2 Standard' as const,
isQuickTransfer: false,
}

const RUN_COMMAND_ERRORS = {
Expand Down Expand Up @@ -284,6 +286,9 @@ describe('ProtocolRunHeader', () => {
vi.mocked(useModulesQuery).mockReturnValue({
data: { data: [] },
} as any)
vi.mocked(useDeleteRunMutation).mockReturnValue({
deleteRun: vi.fn(),
} as any)
vi.mocked(usePipettesQuery).mockReturnValue({
data: {
data: {
Expand Down Expand Up @@ -477,6 +482,7 @@ describe('ProtocolRunHeader', () => {
protocolKey: null,
isProtocolAnalyzing: true,
robotType: 'OT-2 Standard',
isQuickTransfer: false,
})

render()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('useProtocolDetailsForRun hook', () => {
protocolKey: null,
isProtocolAnalyzing: false,
robotType: 'OT-3 Standard',
isQuickTransfer: false,
})
})

Expand Down Expand Up @@ -95,6 +96,7 @@ describe('useProtocolDetailsForRun hook', () => {
protocolKey: 'fakeProtocolKey',
isProtocolAnalyzing: false,
robotType: 'OT-2 Standard',
isQuickTransfer: false,
})
})
})
2 changes: 2 additions & 0 deletions app/src/organisms/Devices/hooks/useProtocolDetailsForRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface ProtocolDetails {
protocolKey: string | null
isProtocolAnalyzing?: boolean
robotType: RobotType
isQuickTransfer: boolean
}

export function useProtocolDetailsForRun(
Expand Down Expand Up @@ -67,5 +68,6 @@ export function useProtocolDetailsForRun(
(mostRecentAnalysis?.status === 'completed'
? mostRecentAnalysis?.robotType ?? FLEX_ROBOT_TYPE
: FLEX_ROBOT_TYPE),
isQuickTransfer: protocolRecord?.data.protocolKind === 'quick-transfer',
}
}
11 changes: 9 additions & 2 deletions app/src/pages/RunSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ export function RunSummary(): JSX.Element {
const { t } = useTranslation('run_details')
const navigate = useNavigate()
const host = useHost()
const { data: runRecord } = useNotifyRunQuery(runId, { staleTime: Infinity })
const { data: runRecord } = useNotifyRunQuery(runId, {
staleTime: Infinity,
onError: () => {
// in case the run is remotely deleted by a desktop app, navigate to the dash
navigate('/')
},
})
const isRunCurrent = Boolean(
useNotifyRunQuery(runId, { refetchInterval: CURRENT_RUN_POLL_MS })?.data
?.data?.current
Expand Down Expand Up @@ -231,14 +237,15 @@ export function RunSummary(): JSX.Element {
const returnToQuickTransfer = (): void => {
if (!isRunCurrent) {
deleteRun(runId)
navigate('/quick-transfer')
} else {
closeCurrentRun({
onSuccess: () => {
deleteRun(runId)
navigate('/quick-transfer')
},
})
}
navigate('/quick-transfer')
}

// TODO(jh, 05-30-24): EXEC-487. Refactor reset() so we can redirect to the setup page, showing the shimmer skeleton instead.
Expand Down

0 comments on commit 104b461

Please sign in to comment.