Skip to content

Commit b19ace5

Browse files
authored
feat(protocol-designer, step-generation): wire up hover labware and remove duplicate btn (#13289)
closes RQA-1273 and RQA-1272
1 parent e7ed61b commit b19ace5

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

protocol-designer/src/components/steplist/ContextMenu.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { actions as steplistActions } from '../../steplist'
1111
import { Portal } from '../portals/TopPortal'
1212
import styles from './StepItem.css'
1313
import { StepIdType } from '../../form-types'
14+
import { getSavedStepForms } from '../../step-forms/selectors'
1415

1516
const MENU_OFFSET_PX = 5
1617

@@ -47,6 +48,9 @@ export const ContextMenu = (props: Props): JSX.Element => {
4748
const menuRoot = React.useRef<HTMLDivElement | null>(null)
4849

4950
const isMultiSelectMode = useSelector(getIsMultiSelectMode)
51+
const allSavedSteps = useSelector(getSavedStepForms)
52+
const isMoveLabwareStepType =
53+
stepId != null ? allSavedSteps[stepId].stepType === 'moveLabware' : null
5054

5155
React.useEffect(() => {
5256
global.addEventListener('click', handleClick)
@@ -78,7 +82,6 @@ export const ContextMenu = (props: Props): JSX.Element => {
7882
setStepId(stepId)
7983
setPosition({ left, top })
8084
}
81-
8285
const handleClick = (event: MouseEvent): void => {
8386
const wasOutside = !(
8487
event.target instanceof Node && menuRoot.current?.contains(event.target)
@@ -128,24 +131,24 @@ export const ContextMenu = (props: Props): JSX.Element => {
128131
})}
129132
{!showDeleteConfirmation && visible && (
130133
<Portal>
131-
<React.Fragment>
132-
<div
133-
ref={menuRoot}
134-
// @ts-expect-error(sa, 2021-7-5): position cannot be null, cast to undefined
135-
style={{ left: position.left, top: position.top }}
136-
className={styles.context_menu}
137-
>
134+
<div
135+
ref={menuRoot}
136+
// @ts-expect-error(sa, 2021-7-5): position cannot be null, cast to undefined
137+
style={{ left: position.left, top: position.top }}
138+
className={styles.context_menu}
139+
>
140+
{isMoveLabwareStepType ? null : (
138141
<div
139142
onClick={handleDuplicate}
140143
className={styles.context_menu_item}
141144
>
142145
{i18n.t('context_menu.step.duplicate')}
143146
</div>
144-
<div onClick={confirmDelete} className={styles.context_menu_item}>
145-
{i18n.t('context_menu.step.delete')}
146-
</div>
147+
)}
148+
<div onClick={confirmDelete} className={styles.context_menu_item}>
149+
{i18n.t('context_menu.step.delete')}
147150
</div>
148-
</React.Fragment>
151+
</div>
149152
</Portal>
150153
)}
151154
</div>

protocol-designer/src/ui/steps/selectors.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ export const getHoveredStepLabware: Selector<string[]> = createSelector(
143143
return labware ? [labware.id] : []
144144
}
145145

146+
if (stepArgs.commandCreatorFnName === 'moveLabware') {
147+
const src = stepArgs.labware
148+
return [src]
149+
}
150+
146151
// step types that have no labware that gets highlighted
147152
if (!(stepArgs.commandCreatorFnName === 'delay')) {
148153
// TODO Ian 2018-05-08 use assert here

protocol-designer/src/ui/steps/test/selectors.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function createArgsForStepId(
4040
const hoveredStepId = 'hoveredStepId'
4141
const labware = 'well plate'
4242
const mixCommand = 'mix'
43+
const moveLabwareCommand = 'moveLabware'
4344
describe('getHoveredStepLabware', () => {
4445
let initialDeckState: any
4546
beforeEach(() => {
@@ -132,6 +133,22 @@ describe('getHoveredStepLabware', () => {
132133
expect(result).toEqual([labware])
133134
})
134135

136+
it('correct labware is returned when command is moveLabware', () => {
137+
const stepArgs = {
138+
commandCreatorFnName: moveLabwareCommand,
139+
labware,
140+
}
141+
const argsByStepId = createArgsForStepId(hoveredStepId, stepArgs)
142+
// @ts-expect-error(sa, 2021-6-15): resultFunc not part of Selector type
143+
const result = getHoveredStepLabware.resultFunc(
144+
argsByStepId,
145+
hoveredStepId,
146+
initialDeckState
147+
)
148+
149+
expect(result).toEqual([labware])
150+
})
151+
135152
describe('modules', () => {
136153
const type = TEMPERATURE_MODULE_TYPE
137154
const setTempCommand = 'setTemperature'

step-generation/src/commandCreators/atomic/moveLabware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const moveLabware: CommandCreator<MoveLabwareArgs> = (
4343
) {
4444
errors.push(errorCreators.thermocyclerLidClosed())
4545
} else if (initialModuleState.type === HEATERSHAKER_MODULE_TYPE) {
46-
if (initialModuleState.latchOpen === false) {
46+
if (initialModuleState.latchOpen !== true) {
4747
errors.push(errorCreators.heaterShakerLatchClosed())
4848
} else if (initialModuleState.targetSpeed !== null) {
4949
errors.push(errorCreators.heaterShakerIsShaking())

0 commit comments

Comments
 (0)