Skip to content

Commit

Permalink
fix(app): add new text to updatebanner for module card (#14237)
Browse files Browse the repository at this point in the history
* fix(app): add new text to updatebanner for module card
  • Loading branch information
koji authored and ncdiehl11 committed Dec 20, 2023
1 parent f94a921 commit e408a70
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/src/assets/localization/en/device_details.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"missing_module": "missing {{num}} module",
"module_actions_unavailable": "Module actions unavailable while protocol is running",
"module_calibration_required_no_pipette_attached": "Module calibration required. Attach a pipette before running module calibration.",
"module_calibration_required_no_pipette_calibrated": "Module calibration required. Calibrate pipette before running module calibration. ",
"module_calibration_required_update_pipette_FW": "Update pipette firmware before proceeding with required module calibration.",
"module_calibration_required": "Module calibration required.",
"module_controls": "Module Controls",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ describe('Module Update Banner', () => {
render(props)
expect(screen.queryByText('Calibrate now')).not.toBeInTheDocument()
})
it('should not render a calibrate link if pipette calibration is required', () => {
props = {
...props,
calibratePipetteRequired: true,
}
const { queryByText } = render(props)
expect(queryByText('Calibrate now')).not.toBeInTheDocument()
})
it('should not render a calibrate link if pipette firmware update is required', () => {
props = {
...props,
Expand All @@ -96,6 +104,7 @@ describe('Module Update Banner', () => {
...props,
updateType: 'firmware',
attachPipetteRequired: true,
calibratePipetteRequired: true,
updatePipetteFWRequired: true,
}
render(props)
Expand Down
9 changes: 8 additions & 1 deletion app/src/molecules/UpdateBanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface UpdateBannerProps {
serialNumber: string
isTooHot?: boolean
attachPipetteRequired?: boolean
calibratePipetteRequired?: boolean
updatePipetteFWRequired?: boolean
}

Expand All @@ -33,6 +34,7 @@ export const UpdateBanner = ({
setShowBanner,
handleUpdateClick,
attachPipetteRequired,
calibratePipetteRequired,
updatePipetteFWRequired,
isTooHot,
}: UpdateBannerProps): JSX.Element | null => {
Expand All @@ -48,11 +50,16 @@ export const UpdateBanner = ({
closeButtonRendered = false
if (attachPipetteRequired)
bannerMessage = t('module_calibration_required_no_pipette_attached')
else if (calibratePipetteRequired)
bannerMessage = t('module_calibration_required_no_pipette_calibrated')
else if (updatePipetteFWRequired)
bannerMessage = t('module_calibration_required_update_pipette_FW')
else bannerMessage = t('module_calibration_required')
hyperlinkText =
!attachPipetteRequired && !updatePipetteFWRequired && !isTooHot
!attachPipetteRequired &&
!updatePipetteFWRequired &&
!isTooHot &&
!calibratePipetteRequired
? t('calibrate_now')
: ''
} else {
Expand Down
4 changes: 4 additions & 0 deletions app/src/organisms/Devices/InstrumentsAndModules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export function InstrumentsAndModules({
attachedPipettes?.left ?? null
)
const attachPipetteRequired =
attachedLeftPipette == null && attachedRightPipette == null
const calibratePipetteRequired =
attachedLeftPipette?.data?.calibratedOffset?.last_modified == null &&
attachedRightPipette?.data?.calibratedOffset?.last_modified == null
const updatePipetteFWRequired =
Expand Down Expand Up @@ -240,6 +242,7 @@ export function InstrumentsAndModules({
module={module}
isLoadedInRun={false}
attachPipetteRequired={attachPipetteRequired}
calibratePipetteRequired={calibratePipetteRequired}
updatePipetteFWRequired={updatePipetteFWRequired}
/>
))}
Expand Down Expand Up @@ -281,6 +284,7 @@ export function InstrumentsAndModules({
module={module}
isLoadedInRun={false}
attachPipetteRequired={attachPipetteRequired}
calibratePipetteRequired={calibratePipetteRequired}
updatePipetteFWRequired={updatePipetteFWRequired}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { BadPipette, PipetteData } from '@opentrons/api-client'

interface PipetteStatus {
attachPipetteRequired: boolean
calibratePipetteRequired: boolean
updatePipetteFWRequired: boolean
}

Expand Down Expand Up @@ -51,9 +52,16 @@ const usePipetteIsReady = (): PipetteStatus => {

const attachPipetteRequired =
attachedLeftPipette == null && attachedRightPipette == null
const calibratePipetteRequired =
attachedLeftPipette?.data.calibratedOffset?.last_modified == null &&
attachedRightPipette?.data.calibratedOffset?.last_modified == null
const updatePipetteFWRequired =
leftPipetteRequiresFWUpdate != null || rightPipetteFWRequired != null
return { attachPipetteRequired, updatePipetteFWRequired }
return {
attachPipetteRequired,
calibratePipetteRequired,
updatePipetteFWRequired,
}
}

interface ProtocolRunModuleControlsProps {
Expand All @@ -67,7 +75,11 @@ export const ProtocolRunModuleControls = ({
}: ProtocolRunModuleControlsProps): JSX.Element => {
const { t } = useTranslation('protocol_details')

const { attachPipetteRequired, updatePipetteFWRequired } = usePipetteIsReady()
const {
attachPipetteRequired,
calibratePipetteRequired,
updatePipetteFWRequired,
} = usePipetteIsReady()

const moduleRenderInfoForProtocolById = useModuleRenderInfoForProtocolById(
runId
Expand Down Expand Up @@ -115,6 +127,7 @@ export const ProtocolRunModuleControls = ({
slotName={module.slotName}
isLoadedInRun={true}
attachPipetteRequired={attachPipetteRequired}
calibratePipetteRequired={calibratePipetteRequired}
updatePipetteFWRequired={updatePipetteFWRequired}
/>
) : null
Expand All @@ -135,6 +148,7 @@ export const ProtocolRunModuleControls = ({
slotName={module.slotName}
isLoadedInRun={true}
attachPipetteRequired={attachPipetteRequired}
calibratePipetteRequired={calibratePipetteRequired}
updatePipetteFWRequired={updatePipetteFWRequired}
/>
) : null
Expand Down
1 change: 1 addition & 0 deletions app/src/organisms/ModuleCard/__tests__/ModuleCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ describe('ModuleCard', () => {
robotName: mockRobot.name,
isLoadedInRun: false,
attachPipetteRequired: false,
calibratePipetteRequired: false,
updatePipetteFWRequired: false,
}

Expand Down
8 changes: 7 additions & 1 deletion app/src/organisms/ModuleCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ interface ModuleCardProps {
robotName: string
isLoadedInRun: boolean
attachPipetteRequired: boolean
calibratePipetteRequired: boolean
updatePipetteFWRequired: boolean
runId?: string
slotName?: string
Expand All @@ -93,6 +94,7 @@ export const ModuleCard = (props: ModuleCardProps): JSX.Element | null => {
runId,
slotName,
attachPipetteRequired,
calibratePipetteRequired,
updatePipetteFWRequired,
} = props
const dispatch = useDispatch<Dispatch>()
Expand Down Expand Up @@ -125,7 +127,9 @@ export const ModuleCard = (props: ModuleCardProps): JSX.Element | null => {
})
const requireModuleCalibration = module.moduleOffset?.last_modified == null
const isPipetteReady =
(!attachPipetteRequired ?? false) && (!updatePipetteFWRequired ?? false)
(!attachPipetteRequired ?? false) &&
(!calibratePipetteRequired ?? false) &&
(!updatePipetteFWRequired ?? false)
const latestRequestId = last(requestIds)
const latestRequest = useSelector<State, RequestState | null>(state =>
latestRequestId ? getRequestById(state, latestRequestId) : null
Expand Down Expand Up @@ -303,6 +307,7 @@ export const ModuleCard = (props: ModuleCardProps): JSX.Element | null => {
/>
)}
{attachPipetteRequired != null &&
calibratePipetteRequired != null &&
updatePipetteFWRequired != null &&
requireModuleCalibration &&
!isPending ? (
Expand All @@ -313,6 +318,7 @@ export const ModuleCard = (props: ModuleCardProps): JSX.Element | null => {
setShowBanner={() => null}
handleUpdateClick={handleCalibrateClick}
attachPipetteRequired={attachPipetteRequired}
calibratePipetteRequired={calibratePipetteRequired}
updatePipetteFWRequired={updatePipetteFWRequired}
isTooHot={isTooHot}
/>
Expand Down

0 comments on commit e408a70

Please sign in to comment.