Skip to content

Commit

Permalink
fix(app): disable instrument card controls when run is active (#13601)
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 authored and sfoster1 committed Sep 28, 2023
1 parent 885b04b commit b538156
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 29 deletions.
3 changes: 3 additions & 0 deletions app/src/organisms/Devices/InstrumentsAndModules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export function InstrumentsAndModules({
pipetteIs96Channel={is96ChannelAttached}
pipetteIsBad={badLeftPipette != null}
updatePipette={() => setSubsystemToUpdate('pipette_left')}
isRunActive={currentRunId != null && !isRunTerminal}
/>
{isOT3 && (
<GripperCard
Expand All @@ -223,6 +224,7 @@ export function InstrumentsAndModules({
null
}
setSubsystemToUpdate={setSubsystemToUpdate}
isRunActive={currentRunId != null && !isRunTerminal}
/>
)}
{leftColumnModules.map((module, index) => (
Expand Down Expand Up @@ -263,6 +265,7 @@ export function InstrumentsAndModules({
pipetteIs96Channel={false}
pipetteIsBad={badRightPipette != null}
updatePipette={() => setSubsystemToUpdate('pipette_right')}
isRunActive={currentRunId != null && !isRunTerminal}
/>
)}
{rightColumnModules.map((module, index) => (
Expand Down
5 changes: 5 additions & 0 deletions app/src/organisms/Devices/PipetteCard/PipetteOverflowMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface PipetteOverflowMenuProps {
handleAboutSlideout: () => void
handleSettingsSlideout: () => void
isPipetteCalibrated: boolean
isRunActive: boolean
}

export const PipetteOverflowMenu = (
Expand All @@ -47,6 +48,7 @@ export const PipetteOverflowMenu = (
handleAboutSlideout,
handleSettingsSlideout,
isPipetteCalibrated,
isRunActive,
} = props

const pipetteName =
Expand All @@ -72,6 +74,7 @@ export const PipetteOverflowMenu = (
<MenuItem
key={`${String(pipetteDisplayName)}_${mount}_attach_pipette`}
onClick={() => handleChangePipette()}
disabled={isRunActive}
data-testid={`pipetteOverflowMenu_attach_pipette_btn_${String(
pipetteDisplayName
)}_${mount}`}
Expand All @@ -84,6 +87,7 @@ export const PipetteOverflowMenu = (
<MenuItem
key={`${pipetteDisplayName}_${mount}_calibrate_offset`}
onClick={() => handleCalibrate()}
disabled={isRunActive}
data-testid={`pipetteOverflowMenu_calibrate_offset_btn_${pipetteDisplayName}_${mount}`}
>
{t(
Expand All @@ -96,6 +100,7 @@ export const PipetteOverflowMenu = (
<MenuItem
key={`${String(pipetteDisplayName)}_${mount}_detach`}
onClick={() => handleChangePipette()}
disabled={isRunActive}
data-testid={`pipetteOverflowMenu_detach_pipette_btn_${String(
pipetteDisplayName
)}_${mount}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ describe('PipetteCard', () => {
isPipetteCalibrated: false,
pipetteIsBad: false,
updatePipette: jest.fn(),
isRunActive: false,
}
when(mockUseIsOT3).calledWith(mockRobotName).mockReturnValue(false)
when(mockAboutPipettesSlideout).mockReturnValue(
Expand Down Expand Up @@ -131,6 +132,7 @@ describe('PipetteCard', () => {
isPipetteCalibrated: false,
pipetteIsBad: false,
updatePipette: jest.fn(),
isRunActive: false,
}
const { getByText } = render(props)
getByText('left Mount')
Expand All @@ -146,6 +148,7 @@ describe('PipetteCard', () => {
isPipetteCalibrated: false,
pipetteIsBad: false,
updatePipette: jest.fn(),
isRunActive: false,
}
const { getByText, getByRole } = render(props)
getByText('Both Mounts')
Expand All @@ -166,6 +169,7 @@ describe('PipetteCard', () => {
isPipetteCalibrated: false,
pipetteIsBad: false,
updatePipette: jest.fn(),
isRunActive: false,
}
const { getByText } = render(props)
getByText('right Mount')
Expand All @@ -180,6 +184,7 @@ describe('PipetteCard', () => {
isPipetteCalibrated: false,
pipetteIsBad: false,
updatePipette: jest.fn(),
isRunActive: false,
}
const { getByText } = render(props)
getByText('right Mount')
Expand All @@ -194,6 +199,7 @@ describe('PipetteCard', () => {
isPipetteCalibrated: false,
pipetteIsBad: false,
updatePipette: jest.fn(),
isRunActive: false,
}
const { getByText } = render(props)
getByText('left Mount')
Expand All @@ -209,6 +215,7 @@ describe('PipetteCard', () => {
isPipetteCalibrated: false,
pipetteIsBad: false,
updatePipette: jest.fn(),
isRunActive: false,
}
const { queryByText } = render(props)
expect(queryByText('Calibrate now')).toBeNull()
Expand All @@ -223,6 +230,7 @@ describe('PipetteCard', () => {
isPipetteCalibrated: false,
pipetteIsBad: false,
updatePipette: jest.fn(),
isRunActive: false,
}
const { getByText } = render(props)
getByText('Calibrate now')
Expand All @@ -236,6 +244,7 @@ describe('PipetteCard', () => {
isPipetteCalibrated: false,
pipetteIsBad: false,
updatePipette: jest.fn(),
isRunActive: false,
}
const { getByRole, getByText, queryByText } = render(props)

Expand All @@ -258,6 +267,7 @@ describe('PipetteCard', () => {
isPipetteCalibrated: false,
pipetteIsBad: true,
updatePipette: jest.fn(),
isRunActive: false,
}
const { getByText } = render(props)
getByText('Right mount')
Expand All @@ -278,6 +288,7 @@ describe('PipetteCard', () => {
isPipetteCalibrated: false,
pipetteIsBad: true,
updatePipette: jest.fn(),
isRunActive: false,
}
const { getByText } = render(props)
getByText('Right mount')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('PipetteOverflowMenu', () => {
handleAboutSlideout: jest.fn(),
handleSettingsSlideout: jest.fn(),
isPipetteCalibrated: false,
isRunActive: false,
}
})
afterEach(() => {
Expand Down
3 changes: 3 additions & 0 deletions app/src/organisms/Devices/PipetteCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface PipetteCardProps {
pipetteIsBad: boolean
updatePipette: () => void
pipetteId?: AttachedPipette['id'] | null
isRunActive: boolean
}
const BANNER_LINK_STYLE = css`
text-decoration: underline;
Expand Down Expand Up @@ -92,6 +93,7 @@ export const PipetteCard = (props: PipetteCardProps): JSX.Element => {
pipetteIs96Channel,
pipetteIsBad,
updatePipette,
isRunActive,
} = props
const {
menuOverlay,
Expand Down Expand Up @@ -351,6 +353,7 @@ export const PipetteCard = (props: PipetteCardProps): JSX.Element => {
handleCalibrate={handleCalibrate}
isPipetteCalibrated={isPipetteCalibrated}
pipetteSettings={settings}
isRunActive={isRunActive}
/>
</Box>
{menuOverlay}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ function SuccessOrError({ errorMessage }: SuccessOrErrorProps): JSX.Element {
let renderedImg: JSX.Element
if (!errorMessage)
renderedImg = (
<img alt={IMAGE_ALT} src={successIcon} height="50%" width="50%" />
<img alt={IMAGE_ALT} src={successIcon} height="208px" width="250px" />
)
else
renderedImg = (
<Icon name="alert-circle" size="25%" color={COLORS.errorEnabled} />
<Icon
name="alert-circle"
height="40px"
color={COLORS.errorEnabled}
margin={SPACING.spacing24}
/>
)

return (
Expand Down Expand Up @@ -104,6 +109,7 @@ function RobotUpdateProgressFooter({
onClick={installUpdate}
marginRight={SPACING.spacing8}
css={FOOTER_BUTTON_STYLE}
border="none"
>
{t('try_again')}
</NewSecondaryBtn>
Expand Down Expand Up @@ -218,26 +224,26 @@ export function RobotUpdateProgressModal({
) : null
}
>
<Flex
flexDirection={DIRECTION_COLUMN}
alignItems={ALIGN_CENTER}
padding={SPACING.spacing48}
>
{completedUpdating ? (
{completedUpdating ? (
<Flex flexDirection={DIRECTION_COLUMN} alignItems={ALIGN_CENTER}>
<SuccessOrError errorMessage={error} />
) : (
<>
<StyledText>{modalBodyText}</StyledText>
<ProgressBar
percentComplete={progressPercent.current}
outerStyles={UPDATE_PROGRESS_BAR_STYLE}
/>
<StyledText css={dontTurnOffMessage}>
{t('do_not_turn_off')}
</StyledText>
</>
)}
</Flex>
</Flex>
) : (
<Flex
flexDirection={DIRECTION_COLUMN}
alignItems={ALIGN_CENTER}
padding={SPACING.spacing48}
>
<StyledText>{modalBodyText}</StyledText>
<ProgressBar
percentComplete={progressPercent.current}
outerStyles={UPDATE_PROGRESS_BAR_STYLE}
/>
<StyledText css={dontTurnOffMessage}>
{t('do_not_turn_off')}
</StyledText>
</Flex>
)}
</LegacyModal>
)
}
5 changes: 5 additions & 0 deletions app/src/organisms/GripperCard/__tests__/GripperCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('GripperCard', () => {
} as GripperData,
isCalibrated: true,
setSubsystemToUpdate: jest.fn(),
isRunActive: false,
}
mockGripperWizardFlows.mockReturnValue(<>wizard flow launched</>)
mockAboutGripperSlideout.mockReturnValue(<>about gripper</>)
Expand Down Expand Up @@ -87,6 +88,7 @@ describe('GripperCard', () => {
} as GripperData,
isCalibrated: false,
setSubsystemToUpdate: jest.fn(),
isRunActive: false,
}

const { getByText } = render(props)
Expand Down Expand Up @@ -127,6 +129,7 @@ describe('GripperCard', () => {
attachedGripper: null,
isCalibrated: false,
setSubsystemToUpdate: jest.fn(),
isRunActive: false,
}
const { getByText, getByRole } = render(props)
const overflowButton = getByRole('button', {
Expand All @@ -144,6 +147,7 @@ describe('GripperCard', () => {
} as any,
isCalibrated: false,
setSubsystemToUpdate: jest.fn(),
isRunActive: false,
}
const { getByText } = render(props)
getByText('Extension mount')
Expand All @@ -162,6 +166,7 @@ describe('GripperCard', () => {
} as any,
isCalibrated: true,
setSubsystemToUpdate: jest.fn(),
isRunActive: false,
}
const { getByText } = render(props)
getByText('Extension mount')
Expand Down
8 changes: 5 additions & 3 deletions app/src/organisms/GripperCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface GripperCardProps {
attachedGripper: GripperData | BadGripper | null
isCalibrated: boolean
setSubsystemToUpdate: (subsystem: Subsystem | null) => void
isRunActive: boolean
}
const BANNER_LINK_CSS = css`
text-decoration: underline;
Expand All @@ -40,6 +41,7 @@ export function GripperCard({
attachedGripper,
isCalibrated,
setSubsystemToUpdate,
isRunActive,
}: GripperCardProps): JSX.Element {
const { t, i18n } = useTranslation(['device_details', 'shared'])
const [
Expand Down Expand Up @@ -73,7 +75,7 @@ export function GripperCard({
? [
{
label: t('attach_gripper'),
disabled: attachedGripper != null,
disabled: attachedGripper != null || isRunActive,
onClick: handleAttach,
},
]
Expand All @@ -83,12 +85,12 @@ export function GripperCard({
attachedGripper.data.calibratedOffset?.last_modified != null
? t('recalibrate_gripper')
: t('calibrate_gripper'),
disabled: attachedGripper == null,
disabled: attachedGripper == null || isRunActive,
onClick: handleCalibrate,
},
{
label: t('detach_gripper'),
disabled: attachedGripper == null,
disabled: attachedGripper == null || isRunActive,
onClick: handleDetach,
},
{
Expand Down
17 changes: 12 additions & 5 deletions app/src/organisms/ModuleWizardFlows/Success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { css } from 'styled-components'
import { getModuleDisplayName } from '@opentrons/shared-data'
import {
COLORS,
JUSTIFY_FLEX_END,
PrimaryButton,
RESPONSIVENESS,
TYPOGRAPHY,
} from '@opentrons/components'

import { SmallButton } from '../../atoms/buttons'
import { SimpleWizardBody } from '../../molecules/SimpleWizardBody'
import type { ModuleCalibrationWizardStepProps } from './types'

Expand All @@ -24,24 +25,30 @@ export const BODY_STYLE = css`
export const Success = (
props: ModuleCalibrationWizardStepProps
): JSX.Element | null => {
const { proceed, attachedModule, isRobotMoving } = props
const { proceed, attachedModule, isRobotMoving, isOnDevice } = props

Check warning on line 28 in app/src/organisms/ModuleWizardFlows/Success.tsx

View check run for this annotation

Codecov / codecov/patch

app/src/organisms/ModuleWizardFlows/Success.tsx#L28

Added line #L28 was not covered by tests
const { t } = useTranslation('module_wizard_flows')
const moduleDisplayName = getModuleDisplayName(attachedModule.moduleModel)

const handleOnClick = (): void => {
proceed()
}
const button = isOnDevice ? (
<SmallButton onClick={handleOnClick} buttonText={t('exit')} />
) : (
<PrimaryButton disabled={isRobotMoving} onClick={handleOnClick}>
{t('exit')}
</PrimaryButton>
)

return (
<SimpleWizardBody
header={t('successfully_calibrated', { module: moduleDisplayName })}
// TODO: iconColor unused, change SimpleWizardBody props interface
iconColor={COLORS.errorEnabled}
isSuccess
justifyContentForOddButton={JUSTIFY_FLEX_END}
>
<PrimaryButton disabled={isRobotMoving} onClick={handleOnClick}>
{t('exit')}
</PrimaryButton>
{button}
</SimpleWizardBody>
)
}

0 comments on commit b538156

Please sign in to comment.