Skip to content

Commit

Permalink
fix(app): disable run again button when old run is being dismissed (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
shlokamin authored Sep 19, 2024
1 parent a7dea54 commit 6293e07
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ export function ProtocolRunHeader({
isFixtureMismatch={isFixtureMismatch}
isResetRunLoadingRef={isResetRunLoadingRef}
missingSetupSteps={missingSetupSteps}
isClosingCurrentRun={isClosingCurrentRun}
/>
</Flex>
</Box>
Expand Down Expand Up @@ -668,6 +669,7 @@ interface ActionButtonProps {
isFixtureMismatch: boolean
isResetRunLoadingRef: React.MutableRefObject<boolean>
missingSetupSteps: string[]
isClosingCurrentRun: boolean
}

// TODO(jh, 04-22-2024): Refactor switch cases into separate factories to increase readability and testability.
Expand All @@ -681,6 +683,7 @@ function ActionButton(props: ActionButtonProps): JSX.Element {
isFixtureMismatch,
isResetRunLoadingRef,
missingSetupSteps,
isClosingCurrentRun,
} = props
const navigate = useNavigate()
const { t } = useTranslation(['run_details', 'shared'])
Expand Down Expand Up @@ -737,6 +740,7 @@ function ActionButton(props: ActionButtonProps): JSX.Element {
isPlayRunActionLoading ||
isPauseRunActionLoading ||
isResetRunLoading ||
isClosingCurrentRun ||
isOtherRunCurrent ||
isProtocolAnalyzing ||
isFixtureMismatch ||
Expand Down Expand Up @@ -814,6 +818,8 @@ function ActionButton(props: ActionButtonProps): JSX.Element {
START_RUN_STATUSES.includes(runStatus)
) {
disableReason = t('close_door')
} else if (isClosingCurrentRun) {
disableReason = t('shared:robot_is_busy')
}

const shouldShowHSConfirm =
Expand All @@ -824,6 +830,9 @@ function ActionButton(props: ActionButtonProps): JSX.Element {
if (isProtocolAnalyzing) {
buttonIconName = 'ot-spinner'
buttonText = t('analyzing_on_robot')
} else if (isClosingCurrentRun) {
buttonIconName = 'ot-spinner'
buttonText = t('canceling_run')
} else if (
runStatus === RUN_STATUS_RUNNING ||
(runStatus != null && RECOVERY_STATUSES.includes(runStatus))
Expand Down Expand Up @@ -903,7 +912,8 @@ function ActionButton(props: ActionButtonProps): JSX.Element {
spin={
isProtocolAnalyzing ||
runStatus === RUN_STATUS_STOP_REQUESTED ||
isResetRunLoading
isResetRunLoading ||
isClosingCurrentRun
}
/>
) : null}
Expand Down

0 comments on commit 6293e07

Please sign in to comment.