-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add gripper requirement to protocol and run requirements (#…
…12747) Co-authored-by: Shlok Amin <[email protected]> closes RLAB-154
- Loading branch information
Showing
31 changed files
with
436 additions
and
156 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
app/src/molecules/WizardRequiredEquipmentList/equipmentImages.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
app/src/organisms/Devices/ProtocolRun/SetupGripperCalibrationItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { | ||
Flex, | ||
ALIGN_CENTER, | ||
DIRECTION_ROW, | ||
SPACING, | ||
JUSTIFY_FLEX_END, | ||
WRAP, | ||
} from '@opentrons/components' | ||
import { GripperModel, getGripperDisplayName } from '@opentrons/shared-data' | ||
import { TertiaryButton } from '../../../atoms/buttons' | ||
import { SetupCalibrationItem } from './SetupCalibrationItem' | ||
import { GripperWizardFlows } from '../../GripperWizardFlows' | ||
|
||
import type { GripperData } from '@opentrons/api-client' | ||
import type { GripperWizardFlowType } from '../../GripperWizardFlows/types' | ||
import { GRIPPER_FLOW_TYPES } from '../../GripperWizardFlows/constants' | ||
|
||
interface SetupGripperCalibrationItemProps { | ||
gripperData: GripperData | null | ||
runId: string | ||
} | ||
|
||
export function SetupGripperCalibrationItem({ | ||
gripperData, | ||
runId, | ||
}: SetupGripperCalibrationItemProps): JSX.Element | null { | ||
const { t } = useTranslation('protocol_setup') | ||
const [ | ||
openWizardFlowType, | ||
setOpenWizardFlowType, | ||
] = React.useState<GripperWizardFlowType | null>(null) | ||
|
||
const gripperCalLastModified = | ||
gripperData != null | ||
? gripperData.data.calibratedOffset?.last_modified ?? null | ||
: null | ||
|
||
let button: JSX.Element | undefined | ||
|
||
if (gripperData == null) { | ||
button = ( | ||
<Flex flexDirection={DIRECTION_ROW} alignItems={ALIGN_CENTER}> | ||
<TertiaryButton | ||
onClick={() => { | ||
setOpenWizardFlowType(GRIPPER_FLOW_TYPES.ATTACH) | ||
}} | ||
> | ||
{t('attach_gripper')} | ||
</TertiaryButton> | ||
</Flex> | ||
) | ||
} else if (gripperCalLastModified == null) { | ||
button = ( | ||
<Flex | ||
alignItems={ALIGN_CENTER} | ||
marginLeft={SPACING.spacing16} | ||
flexWrap={WRAP} | ||
justifyContent={JUSTIFY_FLEX_END} | ||
gridGap={SPACING.spacing8} | ||
> | ||
<TertiaryButton | ||
onClick={() => { | ||
setOpenWizardFlowType(GRIPPER_FLOW_TYPES.RECALIBRATE) | ||
}} | ||
> | ||
{t('calibrate_now_cta')} | ||
</TertiaryButton> | ||
</Flex> | ||
) | ||
} | ||
|
||
return ( | ||
<> | ||
<SetupCalibrationItem | ||
button={button} | ||
calibratedDate={ | ||
gripperData != null | ||
? gripperData.data.calibratedOffset?.last_modified ?? null | ||
: null | ||
} | ||
label={t('extension_mount')} | ||
title={ | ||
gripperData != null | ||
? getGripperDisplayName(gripperData.instrumentModel as GripperModel) | ||
: '' | ||
} | ||
runId={runId} | ||
/> | ||
{openWizardFlowType != null ? ( | ||
<GripperWizardFlows | ||
flowType={openWizardFlowType} | ||
attachedGripper={gripperData} | ||
closeFlow={() => setOpenWizardFlowType(null)} | ||
/> | ||
) : null} | ||
</> | ||
) | ||
} |
76 changes: 76 additions & 0 deletions
76
app/src/organisms/Devices/ProtocolRun/SetupInstrumentCalibration.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { | ||
Flex, | ||
DIRECTION_COLUMN, | ||
COLORS, | ||
SPACING, | ||
TYPOGRAPHY, | ||
} from '@opentrons/components' | ||
|
||
import { StyledText } from '../../../atoms/text' | ||
import * as PipetteConstants from '../../../redux/pipettes/constants' | ||
import { useRunPipetteInfoByMount, useStoredProtocolAnalysis } from '../hooks' | ||
import { SetupPipetteCalibrationItem } from './SetupPipetteCalibrationItem' | ||
import { SetupGripperCalibrationItem } from './SetupGripperCalibrationItem' | ||
import { useMostRecentCompletedAnalysis } from '../../LabwarePositionCheck/useMostRecentCompletedAnalysis' | ||
import { useInstrumentsQuery } from '@opentrons/react-api-client' | ||
import { isGripperInCommands } from '../../../resources/protocols/utils' | ||
|
||
import type { GripperData } from '@opentrons/api-client' | ||
import { i18n } from '../../../i18n' | ||
|
||
interface SetupInstrumentCalibrationProps { | ||
robotName: string | ||
runId: string | ||
} | ||
|
||
export function SetupInstrumentCalibration({ | ||
robotName, | ||
runId, | ||
}: SetupInstrumentCalibrationProps): JSX.Element { | ||
const { t } = useTranslation('protocol_setup') | ||
const runPipetteInfoByMount = useRunPipetteInfoByMount(runId) | ||
|
||
const { data: instrumentsQueryData } = useInstrumentsQuery() | ||
const mostRecentAnalysis = useMostRecentCompletedAnalysis(runId) | ||
const storedProtocolAnalysis = useStoredProtocolAnalysis(runId) | ||
const usesGripper = isGripperInCommands( | ||
mostRecentAnalysis?.commands ?? storedProtocolAnalysis?.commands ?? [] | ||
) | ||
const attachedGripperMatch = usesGripper | ||
? (instrumentsQueryData?.data ?? []).find( | ||
(i): i is GripperData => i.instrumentType === 'gripper' | ||
) ?? null | ||
: null | ||
return ( | ||
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing8}> | ||
<StyledText | ||
color={COLORS.black} | ||
css={TYPOGRAPHY.pSemiBold} | ||
id="PipetteCalibration_requiredPipettesTitle" | ||
> | ||
{i18n.format(t('required_instrument_calibrations'), 'titleCase')} | ||
</StyledText> | ||
{PipetteConstants.PIPETTE_MOUNTS.map((mount, index) => { | ||
const pipetteInfo = runPipetteInfoByMount[mount] | ||
return pipetteInfo != null ? ( | ||
<SetupPipetteCalibrationItem | ||
key={index} | ||
pipetteInfo={pipetteInfo} | ||
mount={mount} | ||
robotName={robotName} | ||
runId={runId} | ||
/> | ||
) : null | ||
})} | ||
{usesGripper ? ( | ||
<SetupGripperCalibrationItem | ||
gripperData={attachedGripperMatch} | ||
runId={runId} | ||
/> | ||
) : null} | ||
</Flex> | ||
) | ||
} |
53 changes: 0 additions & 53 deletions
53
app/src/organisms/Devices/ProtocolRun/SetupPipetteCalibration.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.