Skip to content

Commit

Permalink
fix(components,-protocol-designer): preselect useGripper in moveLabwa…
Browse files Browse the repository at this point in the history
…re form if attached

Update createPresavedStepForm with new patch to pre-select useGripper to true for a moveLabware step form if a gripper is included in additional equipment entities. Fix minor style bugs in Checkbox component.

Closes AUTH-1371
  • Loading branch information
ncdiehl11 committed Jan 27, 2025
1 parent c6f0f79 commit 52f8cd7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
11 changes: 8 additions & 3 deletions components/src/atoms/Checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Icon } from '../../icons'
import {
ALIGN_CENTER,
CURSOR_AUTO,
CURSOR_DEFAULT,
CURSOR_POINTER,
DIRECTION_ROW,
FLEX_MAX_CONTENT,
Expand Down Expand Up @@ -66,8 +67,12 @@ export function Checkbox(props: CheckboxProps): JSX.Element {
outline-offset: 2px;
}
&:disabled {
background-color: ${COLORS.grey35};
color: ${COLORS.grey50};
background-color: ${COLORS.grey30};
color: ${COLORS.grey40};
cursor: ${CURSOR_DEFAULT};
}
&:disabled:hover {
background-color: ${COLORS.grey30}; /* Prevent hover from overriding */
}
&:hover {
background-color: ${isChecked ? COLORS.blue55 : COLORS.blue35};
Expand All @@ -93,7 +98,7 @@ export function Checkbox(props: CheckboxProps): JSX.Element {
<StyledText desktopStyle="bodyDefaultRegular" oddStyle="bodyTextSemiBold">
{labelText}
</StyledText>
<Check isChecked={isChecked} />
<Check isChecked={isChecked} disabled={disabled} />
</Flex>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,14 @@ describe('createPresavedStepForm', () => {
})
})
})
it('should default movdLabware form useGripper value to `true` if gripper is added', () => {
const args = {
...defaultArgs,
additionalEquipmentEntities: {
gripperId: { name: 'gripper', id: 'gripperId' },
},
stepType: 'moveLabware',
}
expect(createPresavedStepForm(args)).toHaveProperty('useGripper', true)
})
})
21 changes: 21 additions & 0 deletions protocol-designer/src/step-forms/utils/createPresavedStepForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,21 @@ const _patchThermocyclerFields = (args: {
}
}

const _patchMoveLabwareFields = (args: {
additionalEquipmentEntities: AdditionalEquipmentEntities
stepType: StepType
}): FormUpdater => () => {
const { additionalEquipmentEntities, stepType } = args
const isMoveLabware = stepType === 'moveLabware'
const hasGripper = Object.values(additionalEquipmentEntities).some(
({ name }) => name === 'gripper'
)
if (isMoveLabware && hasGripper) {
return { useGripper: true }
}
return null
}

export const createPresavedStepForm = ({
initialDeckSetup,
labwareEntities,
Expand Down Expand Up @@ -449,6 +464,11 @@ export const createPresavedStepForm = ({
robotStateTimeline,
})

const updateMoveLabwareFields = _patchMoveLabwareFields({
additionalEquipmentEntities,
stepType,
})

// finally, compose and apply all the updaters in order,
// passing the applied result from one updater as the input of the next
return [
Expand All @@ -460,6 +480,7 @@ export const createPresavedStepForm = ({
updateMagneticModuleId,
updateAbsorbanceReaderModuleId,
updateDefaultLabwareLocations,
updateMoveLabwareFields,
].reduce<FormData>(
(acc, updater: FormUpdater) => {
const updates = updater(acc)
Expand Down

0 comments on commit 52f8cd7

Please sign in to comment.