Skip to content

Commit

Permalink
fix(protocol-designer): fix issues in select pipette screen (#16404)
Browse files Browse the repository at this point in the history
* fix(protocol-designer): fix issues in select pipette screen
  • Loading branch information
koji authored Oct 8, 2024
1 parent d1de808 commit a9b219e
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"show_tips": "Show incompatible tips",
"slots_limit_reached": "Slots limit reached",
"stagingArea": "Staging area",
"swap": "Swap pipettes",
"swap_pipettes": "Swap pipettes",
"tell_us": "Tell us about your protocol",
"trash_required": "A trash entity is required",
"trashBin": "Trash Bin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"delete": "Delete step",
"dispensed": "Dispensed",
"duplicate": "Duplicate step",
"engage_height": "Engage height",
"edit_step": "Edit step",
"engage_height": "Engage height",
"final_deck_state": "Final deck state",
"from": "from",
"heater_shaker_settings": "Heater-shaker settings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ export function EditInstrumentsModal(
leftInfo != null ? (
<PipetteInfoItem
mount="left"
pipetteOnDeck={pipettesOnDeck}
pipetteName={leftPip.name}
tiprackDefURIs={leftPip.tiprackDefURI}
editClick={() => {
Expand Down Expand Up @@ -277,7 +276,6 @@ export function EditInstrumentsModal(
rightInfo != null ? (
<PipetteInfoItem
mount="right"
pipetteOnDeck={pipettesOnDeck}
pipetteName={rightPip.name}
tiprackDefURIs={rightPip.tiprackDefURI}
editClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ describe('PipetteInfoItem', () => {
tiprackDefURIs: ['mockDefUri'],
pipetteName: 'p1000_single',
mount: 'left',
formPipettesByMount: {
left: { pipetteName: 'p1000_single' },
right: { pipetteName: 'p50_single' },
},
}

vi.mocked(getLabwareDefsByURI).mockReturnValue({
Expand All @@ -45,4 +41,19 @@ describe('PipetteInfoItem', () => {
fireEvent.click(screen.getByText('Remove'))
expect(props.cleanForm).toHaveBeenCalled()
})

it('renders pipette with edit and remove buttons right pipette', () => {
props = {
...props,
mount: 'right',
}
render(props)
screen.getByText('P1000 Single-Channel GEN1')
screen.getByText('Right pipette')
screen.getByText('mock display name')
fireEvent.click(screen.getByText('Edit'))
expect(props.editClick).toHaveBeenCalled()
fireEvent.click(screen.getByText('Remove'))
expect(props.cleanForm).toHaveBeenCalled()
})
})
44 changes: 15 additions & 29 deletions protocol-designer/src/organisms/PipetteInfoItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,18 @@ import { getPipetteSpecsV2 } from '@opentrons/shared-data'
import { BUTTON_LINK_STYLE } from '../../atoms'
import { getLabwareDefsByURI } from '../../labware-defs/selectors'
import type { PipetteMount, PipetteName } from '@opentrons/shared-data'
import type { FormPipettesByMount, PipetteOnDeck } from '../../step-forms'

interface PipetteInfoItemProps {
mount: PipetteMount
pipetteName: PipetteName
tiprackDefURIs: string[]
editClick: () => void
cleanForm: () => void
formPipettesByMount?: FormPipettesByMount
pipetteOnDeck?: PipetteOnDeck[]
}

export function PipetteInfoItem(props: PipetteInfoItemProps): JSX.Element {
const {
mount,
pipetteName,
tiprackDefURIs,
editClick,
cleanForm,
formPipettesByMount,
pipetteOnDeck,
} = props
const { mount, pipetteName, tiprackDefURIs, editClick, cleanForm } = props
const { t, i18n } = useTranslation('create_new_protocol')
const oppositeMount = mount === 'left' ? 'right' : 'left'
const allLabware = useSelector(getLabwareDefsByURI)
const is96Channel = pipetteName === 'p1000_96'
return (
Expand Down Expand Up @@ -73,33 +61,31 @@ export function PipetteInfoItem(props: PipetteInfoItemProps): JSX.Element {
</Flex>
</Flex>
<Flex
gridGap={SPACING.spacing20}
gridGap={SPACING.spacing16}
textDecoration={TYPOGRAPHY.textDecorationUnderline}
>
<Btn
onClick={editClick}
textDecoration={TYPOGRAPHY.textDecorationUnderline}
css={BUTTON_LINK_STYLE}
padding={SPACING.spacing4}
>
<StyledText desktopStyle="bodyDefaultRegular">
{t('edit')}
</StyledText>
</Btn>
{(formPipettesByMount != null &&
formPipettesByMount[oppositeMount].pipetteName == null) ||
(pipetteOnDeck != null && pipetteOnDeck.length === 1) ? null : (
<Btn
onClick={() => {
cleanForm()
}}
textDecoration={TYPOGRAPHY.textDecorationUnderline}
css={BUTTON_LINK_STYLE}
>
<StyledText desktopStyle="bodyDefaultRegular">
{t('remove')}
</StyledText>
</Btn>
)}
<Btn
onClick={() => {
cleanForm()
}}
textDecoration={TYPOGRAPHY.textDecorationUnderline}
css={BUTTON_LINK_STYLE}
padding={SPACING.spacing4}
>
<StyledText desktopStyle="bodyDefaultRegular">
{t('remove')}
</StyledText>
</Btn>
</Flex>
</Flex>
</ListItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import without from 'lodash/without'
import { useLocation } from 'react-router-dom'

import {
Flex,
SPACING,
Expand All @@ -16,6 +18,7 @@ import type { WizardTileProps } from './types'
export function SelectGripper(props: WizardTileProps): JSX.Element | null {
const { goBack, setValue, proceed, watch } = props
const { t } = useTranslation(['create_new_protocol', 'shared'])
const location = useLocation()
const [gripperStatus, setGripperStatus] = useState<'yes' | 'no' | null>(null)
const additionalEquipment = watch('additionalEquipment')

Expand Down Expand Up @@ -44,6 +47,7 @@ export function SelectGripper(props: WizardTileProps): JSX.Element | null {
header={t('add_gripper')}
disabled={gripperStatus == null}
goBack={() => {
location.state = 'gripper'
goBack(1)
}}
proceed={handleProceed}
Expand Down
Loading

0 comments on commit a9b219e

Please sign in to comment.