Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol-designer): bring back deck setup drag & drop #17477

Merged
merged 160 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
c45938d
chore(release): v8.3.0-alpha.1 release notes (#17188)
y3rsh Jan 6, 2025
8c2474d
fix(api): properly handle non-labware jsons in sim (#17198)
sfoster1 Jan 7, 2025
696d2e4
fix(app): Fix gantry not homing when no labware in gripper jaws durin…
mjhuff Jan 7, 2025
eeb7a02
fix(robot-server): Better errors for bad wpa2 pass (#17203)
sfoster1 Jan 7, 2025
0395804
fix(shared-data): Add back missing parent labwares for auto sealing l…
CaseyBatten Jan 7, 2025
cff47c9
fix(app-shell): Fix flaky file system test (#17212)
mjhuff Jan 8, 2025
b565fea
chore(app-shell): pass team id via env var only (#17210)
sfoster1 Jan 8, 2025
63cba42
fix(hardware-testing): add oem argument to pipette load in lld test p…
ryanthecoder Jan 8, 2025
0fa2cfc
fix(app): Fix gripper calibration copy during exit (#17220)
mjhuff Jan 8, 2025
5f869ea
docs(robot-server): Exclude `/labwareOffsets` endpoints from docs (#1…
SyntaxColoring Jan 8, 2025
7e1d4a3
chore(translation): sync locize repo (#17207)
y3rsh Jan 8, 2025
18690a6
chore(build): update to actions/*-artifact v4 (#17231)
sfoster1 Jan 9, 2025
cf940fe
fix(app): fix terminal banner render state (#17240)
mjhuff Jan 10, 2025
b13cd27
fix(app): Fix gripper recovery loop (#17241)
mjhuff Jan 10, 2025
02b6a42
chore(hardware): Add some logging around what I think is causing some…
ryanthecoder Jan 10, 2025
3a46ebe
fix(app): Fix persistent "run in progress" settings banner after run …
mjhuff Jan 10, 2025
ec49410
fix(app): Inject labware definitions into Error Recovery (#17248)
mjhuff Jan 10, 2025
871aa94
feat(app): Block evotips labware from appearing in labware tab (#17251)
smb2268 Jan 14, 2025
271ad58
fix(api): Fix Pydantic error when parsing commands that did not succe…
SyntaxColoring Jan 14, 2025
061ab89
test(analyses): add refactored 8.2 smoke test (#17214)
y3rsh Jan 14, 2025
453410e
refactor(app): refactor ODD protocol card copy when run data is not "…
mjhuff Jan 15, 2025
3778b65
fix(shared-data): flex a3 needs mating surface (#17281)
sfoster1 Jan 15, 2025
7bc38f8
fix(app): fix manual move to location with module (#17283)
mjhuff Jan 15, 2025
bb78046
fix(api): Fix liquid getting homed into pipette after certain protoco…
SyntaxColoring Jan 16, 2025
27d2dc8
fix(shared-data): fix getPipetteSpecsV2 finding PEEK pipette specs (#…
smb2268 Jan 17, 2025
9c70751
refactor(app): Fix copy/CSS for stall/collision recovery DQA (#17298)
mjhuff Jan 21, 2025
0da7b99
fix(app): Fix double drop tip prompting after Error Recovery cancel a…
mjhuff Jan 21, 2025
4940eb7
chore(app): locize fuzzy tags removed (#17305)
y3rsh Jan 22, 2025
1e47fe3
fix(app): various odd modal width fixes under i18n (#17307)
sfoster1 Jan 22, 2025
8cea8e5
chore(api): fix tests after #17285 (#17313)
sfoster1 Jan 22, 2025
25cc087
fix(app): Localization DQA Fixes (#17341)
smb2268 Jan 24, 2025
a2b35d5
feat(api): inner well geometry unit tests (#17082) (#17311)
ryanthecoder Jan 27, 2025
f54a193
fix(api):show plate reader files in run log (#17369)
TamarZanzouri Jan 28, 2025
c048e5b
feat(shared-data, api): Add evo tips definition and restrictions on l…
Laura-Danielle Jan 28, 2025
13a1c85
fix(shared-data): Fixup some values for the new pipette (#17371)
ryanthecoder Jan 28, 2025
5b91727
fix(api,shared-data): FlexStacker fixes and improvements to enable AB…
vegano1 Jan 29, 2025
fd2533d
feat(api): Add FlexStacker functionality to enable stallguard + add a…
vegano1 Jan 29, 2025
2661488
fix(api): Use the latest information when estimating liquid height (#…
ryanthecoder Jan 29, 2025
16bd893
feat(protocol-designer): timeline scrubber to the overview page (#17301)
jerader Jan 29, 2025
5303a3b
refactor(api): Express labware offset locations as sequences (#17363)
sfoster1 Jan 29, 2025
6123b81
feat(api): remove liquid classes feature flag, gate liquid classes be…
sanni-t Jan 29, 2025
8004d59
feat(app): Stub out flex stacker in deck config (#17381)
smb2268 Jan 29, 2025
e22bde1
fix(shared-data): add D3 as provided addressable area to the flexStac…
vegano1 Jan 29, 2025
2451026
docs(api): Update listed pipette flow rates (#17367)
jwwojak Jan 29, 2025
ac70ce0
fix(api): tune store_labware motion parameters and current to increas…
vegano1 Jan 30, 2025
b1684cb
refactor(step-generation, protocol-designer, app): touchTip to emit f…
jerader Jan 30, 2025
85c4e96
fix(api): Over pressure while probing should trigger ER (#17379)
TamarZanzouri Jan 30, 2025
18da739
fix(app): App support for new lid commands and fix lid error boundary…
smb2268 Jan 30, 2025
253c300
fix(api): use smaller of max pipette volume and max tip volume for sp…
sanni-t Jan 30, 2025
a79e873
feat(protocol-designer): add python field to commands and timeline (#…
ddcc4 Jan 30, 2025
3c23793
feat(api): fix InstrumentContext.name for Flex and update LiquidClass…
sanni-t Jan 30, 2025
3d78c1f
feat(api): Addition of Evotip specific commands (#17351)
CaseyBatten Jan 30, 2025
9b963ac
fix(api): fix the test_deck_configuration_provider unit test for the …
vegano1 Jan 31, 2025
58c9f45
feat(app): Add missing usp hub port to a few module display locations…
smb2268 Jan 31, 2025
e5c8d27
refactor(app): support fullscreen styling for LPC flows on the ODD (#…
mjhuff Jan 31, 2025
a667e62
feat(app): Add new evotips command support to run log (#17402)
smb2268 Jan 31, 2025
f4921c6
feat(protocol-designer): create Export python feature flag (#17404)
jerader Feb 3, 2025
c841986
feat(app): Enable labware views for LPC Redesign (#17384)
mjhuff Feb 3, 2025
82995e7
feat(protocol-designer): add submerge for aspirate and dispense (#17368)
syao1226 Feb 3, 2025
3bab4df
feat(protocol-designer): introduce LiquidEntities and update ingredie…
jerader Feb 3, 2025
b4831cf
feat(api): add new user-facing helper functions for static liquid tra…
caila-marashaj Feb 3, 2025
b72288f
Merge branch 'chore_release-8.3.0' of https://github.com/Opentrons/op…
jbleon95 Feb 3, 2025
932000d
import fixes, correction volume for evotip dispense, and stray merge …
jbleon95 Feb 3, 2025
73ca674
stray format fix
jbleon95 Feb 3, 2025
b3b2e1e
command schema 12 update
jbleon95 Feb 3, 2025
307f745
lint fixes
jbleon95 Feb 3, 2025
222d4a0
fix(analyses-snapshot-testing): heal mergeback_chore_release_830_into…
github-actions[bot] Feb 3, 2025
dd148b6
update 8.3.0 release notes for stable release (#17407)
emilyburghardt Feb 3, 2025
0855b9b
fix(ci): update and streamline PD workflow (#17406)
y3rsh Feb 4, 2025
2b87a7a
chore: merge 8.3.0 alpha 4 into edge
jbleon95 Feb 4, 2025
19a94a6
chore(release): internal release notes 2.4.0-alpha.0 (#17405)
y3rsh Feb 4, 2025
d1cfe80
feat(robot-server): handle new offset locations in /labwareOffsets (#…
sfoster1 Feb 4, 2025
cffab4e
chore(app): reorder parameters in ODD protocol setup (#17416)
TamarZanzouri Feb 4, 2025
643cf15
test(shared-data): Continue testing other labware if one test fails (…
SyntaxColoring Feb 4, 2025
d3e189d
fix(shared-data): Pre-sort innerLabwareGeometry sections (#17426)
SyntaxColoring Feb 5, 2025
f9e3f04
test(shared-data): Fix schema 3 labware definitions not being tested …
SyntaxColoring Feb 5, 2025
d0ff21c
fix(shared-data): tc lids are schema v2 now (#17427)
sfoster1 Feb 5, 2025
9d28971
feat(protocol-designer): introduce new -locationUpdates (#17414)
jerader Feb 5, 2025
476c0a3
feat(protocol-designer): utility functions for Python generation (#17…
ddcc4 Feb 5, 2025
f16f6a0
feat(protocol-designer): add designerApplication labware, pipettes, m…
jerader Feb 5, 2025
0ceaefd
chore(app): change default labware view to map (#17422)
TamarZanzouri Feb 5, 2025
926b5cd
chore: update ubuntu version in workflows of frontend (#17445)
koji Feb 6, 2025
a693b6c
fix(api): correctionVolume can be negative (#17413)
andySigler Feb 6, 2025
aae2bfa
fix(protocol-designer, step-generation): update prewet behavior in PD…
ncdiehl11 Feb 6, 2025
ba07963
feat(robot-server): Allow adding multiple labware offsets in a single…
SyntaxColoring Feb 6, 2025
30f65d9
refactor(api): Move the plunger position starting position after an e…
Laura-Danielle Feb 6, 2025
ff9f365
API 2.22 docs versioning update (#17400)
emilyburghardt Feb 6, 2025
73b70f4
chore(ci): adjust codecov settings and update step-generation workflo…
y3rsh Feb 6, 2025
cdb7802
docs(robot-server): Include `/labwareOffsets` endpoints in docs again…
SyntaxColoring Feb 6, 2025
71bfaf6
fix(shared-data): evotips v1 are schema 2 now (#17428)
sfoster1 Feb 6, 2025
94bd0e9
docs(api): clarify in docs that Well.has_tip checks only for unused t…
sanni-t Feb 6, 2025
741382d
fix(app): fix multi-location tip selection during error recovery (#17…
mjhuff Feb 6, 2025
163a297
docs(api): clarify in docs that Well.has_tip checks only for unused t…
sanni-t Feb 6, 2025
db4640f
feat(app): Implement LPC Redesign Header on ODD (#17449)
mjhuff Feb 6, 2025
193993f
chore(hardware-testing): Pipette assembly QC script uses default OT3A…
andySigler Feb 7, 2025
f0ec5e5
chore(shared-data,app): Block evotips labware from PD, LL, and Quick …
smb2268 Feb 7, 2025
08d9dd2
fix(hardware): correct duration calculation from the change in z-rais…
ryanthecoder Feb 7, 2025
18865c5
chore: 🤖 update ubuntu version (#17461)
koji Feb 7, 2025
f8a5436
feat(protocol-designer): start wiring up "Export Python" button to ge…
ddcc4 Feb 7, 2025
5ae252e
trying to add back drag drop to deck setup
jerader Feb 7, 2025
f687a3a
feat(protocol-designer, step-generation, app): introduce pythonName t…
jerader Feb 7, 2025
f8473bf
refactor(shared-data): Normalize "\u00b5" to "µ" (#17469)
SyntaxColoring Feb 7, 2025
d16cbaf
fix(app): translate close button text for ODD toasts (#17459)
smb2268 Feb 7, 2025
26125dd
fix(protocol-designer): fix createFile() test and delete unused `ot2R…
ddcc4 Feb 7, 2025
2ec42e1
feat(protocol-designer): generate `requirements` section of Python fi…
ddcc4 Feb 7, 2025
2799f8e
add back adapter, labware, slot controls
jerader Feb 8, 2025
e358006
feat(protocol-designer): deck setup drag & drop
jerader Feb 10, 2025
4fdd39c
save type
jerader Feb 10, 2025
9ec832f
fix cypress
jerader Feb 10, 2025
5da85c3
docs(app): add quick transfer doc to keep track of versioning (#17473)
smb2268 Feb 10, 2025
369a096
fix bug with swapping labware on an adapter
jerader Feb 10, 2025
a8c1f16
fix(shared-data): Restore "lid" display category missing from labware…
SyntaxColoring Feb 10, 2025
455774e
feat(protocol-designer): add declaration for `def run()` to generated…
ddcc4 Feb 10, 2025
48ac4e6
feat(api): return location sequences from commands (#17435)
sfoster1 Feb 10, 2025
875346d
feat(protocol-designer): load module in python file (#17483)
jerader Feb 11, 2025
98f7175
chore(ci): update deprecated GitHub actions tools (#17494)
y3rsh Feb 11, 2025
024b4e9
feat(protocol-designer): loadAdapter and loadLabware python file (#17…
jerader Feb 11, 2025
4c2e213
fix(api): recover from stall and an overpressure when dropping tip (#…
TamarZanzouri Feb 11, 2025
831c4ae
feat(protocol-designer): add placeholder for step commands to generat…
ddcc4 Feb 11, 2025
4b054ad
test(protocol-designer): start of cypress happy path test for mix set…
skowalski08 Feb 11, 2025
89b3f14
refactor(protocol-designer): initial refactoring of MoveLiquidTools (…
koji Feb 11, 2025
731fb9e
feat(protocol-designer): add TextAreaField component to protocol-desi…
koji Feb 11, 2025
44cfe58
refactor(shared-data): Clean up Python types for labware definitions …
SyntaxColoring Feb 12, 2025
79caa44
Merge branch 'chore_release-pd-8.4.1' into pd_bring-back-drag-drop
jerader Feb 12, 2025
d57e910
refactor(protocol-designer): remove undefined variable in delay.test.…
ddcc4 Feb 12, 2025
0917742
merge conflicts
TamarZanzouri Feb 12, 2025
7b079d4
Merge branch 'chore_release-pd-8.4.0' into mergeback_release-pd-840_i…
ncdiehl11 Feb 12, 2025
7d3f505
edge changes for pd build overflow
TamarZanzouri Feb 12, 2025
3ad2cae
test(pd): enable parameters for steps (#17442)
y3rsh Feb 12, 2025
b52fc8e
change labware def import from shared data
TamarZanzouri Feb 12, 2025
947c9e4
feat(protocol-designer, components): introduce release notes & update…
jerader Feb 12, 2025
31bc576
fix(shared-data): Fix schema version of opentrons_tough_pcr_auto_seal…
SyntaxColoring Feb 12, 2025
1ee1c99
Merge branch 'chore_release-8.3.0' into chore_mergeback
TamarZanzouri Feb 12, 2025
726b58e
fix e2e tests
ncdiehl11 Feb 12, 2025
b6ad90b
Merge branch 'edge' into mergeback_release-pd-840_into_edge-2
ncdiehl11 Feb 12, 2025
ec5cc7a
get chore code changes and fixed import for LabwareDef
TamarZanzouri Feb 12, 2025
0d75872
feat(protocol-designer): Python generation for the Pause step (#17509)
ddcc4 Feb 12, 2025
23828a3
fix tests
ncdiehl11 Feb 12, 2025
a33414b
set yaml file changes to edge
ncdiehl11 Feb 12, 2025
48c79be
fix(analyses-snapshot-testing): heal chore_mergeback snapshots (#17510)
github-actions[bot] Feb 12, 2025
0e9e2db
change designs for BlockedSlot
jerader Feb 12, 2025
8872f47
Merge branch 'mergeback_release-pd-840_into_edge-2' into edge
ncdiehl11 Feb 12, 2025
49f9b42
feat(protocol-designer): python instrument and liquid load commands (…
jerader Feb 12, 2025
aeb64ff
Merge branch 'edge' into chore_mergeback
TamarZanzouri Feb 12, 2025
297cedb
fix(shared-data): Fix well shapes in corning_384_wellplate_112ul_flat…
SyntaxColoring Feb 13, 2025
f5cdb6b
refactor(protocol-designer): add label, namespace, version args to lo…
jerader Feb 13, 2025
f2daae8
feat(api): add GCodes and to interface with the Time-Of-Flight sensor…
vegano1 Feb 13, 2025
a24763f
updating latest apilevel in docs to 2.22 (#17519)
emilyburghardt Feb 13, 2025
4242f4d
feat(engine): `consolidate_liquid` engine core implementation (#17458)
jbleon95 Feb 13, 2025
f0518c1
refactor: Delete empty .py files (#17518)
SyntaxColoring Feb 13, 2025
5dc9521
refactor to address designs
jerader Feb 14, 2025
9f3435e
clean up logic and pulled shared values into a util
jerader Feb 14, 2025
e4b1716
feat(api): allow moving labware with lids (#17513)
sfoster1 Feb 14, 2025
066f0b4
normalize cursor
jerader Feb 14, 2025
c87e3e0
feat (abr-testing): Low Volume 96ch Protocols + Full Liquid Set up Pr…
rclarke0 Feb 14, 2025
2f45bc3
leave comment about cursor bug
jerader Feb 14, 2025
83028a7
Merge branch 'edge' into pd_bring-back-drag-drop
jerader Feb 14, 2025
036acb0
Revert "Merge branch 'edge' into pd_bring-back-drag-drop"
jerader Feb 14, 2025
9e7cd83
block slot for trash abd waste chute
jerader Feb 14, 2025
ad85716
fix cypress tests
jerader Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions components/src/hardware-sim/Deck/RobotCoordsForeignDiv.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface RobotCoordsForeignDivProps {
innerDivProps?: ComponentProps<typeof Box>
transformWithSVG?: boolean
extraTransform?: string
/** optional data-testid to test foreignObjects in cypress */
dataTestId?: string
}

export const RobotCoordsForeignDiv = (
Expand All @@ -27,11 +29,13 @@ export const RobotCoordsForeignDiv = (
innerDivProps,
transformWithSVG = false,
extraTransform = '',
dataTestId = '',
} = props

const transform = `scale(1, -1) ${extraTransform}`
return (
<foreignObject
data-testid={dataTestId}
{...{ x, y, height, width, ...outerProps }}
transform={transformWithSVG ? transform : extraTransform}
>
Expand Down
45 changes: 19 additions & 26 deletions protocol-designer/cypress/support/SetupSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export enum SetupContent {
ModulePageH = 'Add your modules',
ModulePageB = 'Select modules to use in your protocol.',
EditProtocol = 'Edit protocol',
EditSlot = 'Edit slot',
EditLabware = 'Edit labware',
AddLabwareToDeck = 'Add hardware/labware',
EditHardwareLabwareOnDeck = 'Edit hardware/labware',
LabwareH = 'Labware',
Expand All @@ -126,6 +126,10 @@ export enum SetupContent {
Save = 'Save',
}

export const RegexSetupContent = {
slotText: /Edit (slot|labware)/i,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depending on if the hover is on a slot/module or labware/adapter, the copy is different. this was actually always the case so not sure why cypress is mad at it now. Figured a regex to fluctuate between both options was the easiest @alexjoel42 @y3rsh

}

export enum SetupLocators {
Confirm = 'button:contains("Confirm")',
GoBack = 'button:contains("Go back")',
Expand All @@ -149,7 +153,7 @@ export enum SetupLocators {
TempdeckTempInput = 'input[name="targetTemperature"]',
}

const chooseDeckSlot = (
export const chooseDeckSlot = (
slot: string
): Cypress.Chainable<JQuery<HTMLElement>> => {
const deckSlots: Record<
Expand All @@ -167,29 +171,18 @@ const chooseDeckSlot = (
| 'D3',
() => Cypress.Chainable<JQuery<HTMLElement>>
> = {
A1: () =>
cy.contains('foreignObject[x="0"][y="321"]', SetupContent.EditSlot),
A2: () =>
cy.contains('foreignObject[x="164"][y="321"]', SetupContent.EditSlot),
A3: () =>
cy.contains('foreignObject[x="328"][y="321"]', SetupContent.EditSlot),
B1: () =>
cy.contains('foreignObject[x="0"][y="214"]', SetupContent.EditSlot),
B2: () =>
cy.contains('foreignObject[x="164"][y="214"]', SetupContent.EditSlot),
B3: () =>
cy.contains('foreignObject[x="328"][y="214"]', SetupContent.EditSlot),
C1: () =>
cy.contains('foreignObject[x="0"][y="107"]', SetupContent.EditSlot),
C2: () =>
cy.contains('foreignObject[x="164"][y="107"]', SetupContent.EditSlot),
C3: () =>
cy.contains('foreignObject[x="328"][y="107"]', SetupContent.EditSlot),
D1: () => cy.contains('foreignObject[x="0"][y="0"]', SetupContent.EditSlot),
D2: () =>
cy.contains('foreignObject[x="164"][y="0"]', SetupContent.EditSlot),
D3: () =>
cy.contains('foreignObject[x="328"][y="0"]', SetupContent.EditSlot),
A1: () => cy.contains('[data-testid="A1"]', RegexSetupContent.slotText),
A2: () => cy.contains('[data-testid="A2"]', RegexSetupContent.slotText),
A3: () => cy.contains('[data-testid="A3"]', RegexSetupContent.slotText),
B1: () => cy.contains('[data-testid="B1"]', RegexSetupContent.slotText),
B2: () => cy.contains('[data-testid="B2"]', RegexSetupContent.slotText),
B3: () => cy.contains('[data-testid="B3"]', RegexSetupContent.slotText),
C1: () => cy.contains('[data-testid="C1"]', RegexSetupContent.slotText),
C2: () => cy.contains('[data-testid="C2"]', RegexSetupContent.slotText),
C3: () => cy.contains('[data-testid="C3"]', RegexSetupContent.slotText),
D1: () => cy.contains('[data-testid="D1"]', RegexSetupContent.slotText),
D2: () => cy.contains('[data-testid="D2"]', RegexSetupContent.slotText),
D3: () => cy.contains('[data-testid="D3"]', RegexSetupContent.slotText),
}

const slotAction = deckSlots[slot as keyof typeof deckSlots]
Expand Down Expand Up @@ -335,7 +328,7 @@ export const executeSetupSteps = (action: SetupActions): void => {
chooseDeckSlot('C2')
.find('.Box-sc-8ozbhb-0.kIDovv')
.find('a[role="button"]')
.contains(SetupContent.EditSlot)
.contains(SetupContent.EditLabware)
.click({ force: true })
break
case SetupActions.SelectArmadillo96WellPlate: // New case for selecting Armadillo plate
Expand Down
24 changes: 2 additions & 22 deletions protocol-designer/src/assets/localization/en/deck.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,14 @@
"MODULE_INCOMPATIBLE_LABWARE_SWAP": "Swapping labware not possible due to module incompatibility",
"LABWARE_INCOMPATIBLE_WITH_ADAPTER": "Labware incompatible with this adapter"
},
"header": {
"end": "Click on labware to inspect the result of your protocol"
},
"off_deck": {
"slideout_title": "Off-deck labware",
"slideout_empty_state": "There is currently no off-deck labware in this step of the protocol"
},
"overlay": {
"name_labware": {
"nickname_placeholder": "Add a nickname?",
"add_liquids": "Add Liquids",
"leave_empty": "Leave Empty"
},
"edit": {
"name_and_liquids": "Name & Liquids",
"duplicate": "Duplicate",
"delete": "Delete"
},
"browse": {
"view_liquids": "View Liquids"
},
"slot": {
"add_labware": "Add Labware",
"drag_to_new_slot": "Drag To New Slot",
"place_here": "Place Here",
"add_adapter_or_labware": "Add Labware or Adapter",
"add_adapter": "Add adapter"
"place_here": "Place here"
}
},
"inactive_deck": "hover on a step to see deck state"
}
}
185 changes: 185 additions & 0 deletions protocol-designer/src/pages/Designer/DeckSetup/AdapterControls.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
import { useDispatch, useSelector } from 'react-redux'
import { useTranslation } from 'react-i18next'
import { useRef } from 'react'
import { useDrop } from 'react-dnd'
import {
ALIGN_CENTER,
Flex,
JUSTIFY_CENTER,
Link,
RobotCoordsForeignDiv,
StyledText,
} from '@opentrons/components'
import { getLabwareEntities } from '../../../step-forms/selectors'
import { DND_TYPES } from '../../../constants'
import { getLabwareIsCustom } from '../../../utils/labwareModuleCompatibility'
import { moveDeckItem } from '../../../labware-ingred/actions'
import { selectors as labwareDefSelectors } from '../../../labware-defs'
import { BlockedSlot } from './BlockedSlot'
import { DECK_CONTROLS_STYLE } from './constants'

import type { DropTargetMonitor } from 'react-dnd'
import type { Dimensions } from '@opentrons/shared-data'
import type { SharedControlsType, DroppedItem } from './types'

interface AdapterControlsProps extends SharedControlsType {
slotBoundingBox: Dimensions
// the adapter's labwareId
labwareId: string
onDeck: boolean
handleDragHover?: () => void
}

export const AdapterControls = (
props: AdapterControlsProps
): JSX.Element | null => {
const {
slotPosition,
slotBoundingBox,
labwareId,
onDeck,
handleDragHover,
hover,
setHover,
setShowMenuListForId,
itemId,
isSelected,
tab,
} = props
const { t } = useTranslation(['deck', 'starting_deck_state'])
const customLabwareDefs = useSelector(
labwareDefSelectors.getCustomLabwareDefsByURI
)
const labwareEntities = useSelector(getLabwareEntities)
const adapterLoadName = labwareEntities[labwareId]?.def.parameters.loadName

if (adapterLoadName == null) {
console.error(
`expected to find the adapter loadname from labwareId ${labwareId} but could not`
)
}

const ref = useRef(null)
const dispatch = useDispatch()

const [{ itemType, draggedItem, isOver }, drop] = useDrop(
() => ({
accept: DND_TYPES.LABWARE,
canDrop: (item: DroppedItem) => {
const draggedDef = item.labwareOnDeck?.def
console.assert(
draggedDef,
'no labware def of dragged item, expected it on drop'
)

if (draggedDef != null) {
const isCustomLabware = getLabwareIsCustom(
customLabwareDefs,
item.labwareOnDeck
)
const adapterLabwareIsMatch =
draggedDef.stackingOffsetWithLabware?.[adapterLoadName] != null

return adapterLabwareIsMatch || isCustomLabware
}
return true
},
drop: (item: DroppedItem) => {
const droppedLabware = item
if (droppedLabware.labwareOnDeck != null) {
const droppedSlot = droppedLabware.labwareOnDeck.slot
dispatch(moveDeckItem(droppedSlot, labwareId))
}
},
hover: () => {
if (handleDragHover != null) {
handleDragHover()
}
},
collect: (monitor: DropTargetMonitor) => ({
itemType: monitor.getItemType(),
isOver: !!monitor.isOver(),
draggedItem: monitor.getItem() as DroppedItem,
}),
}),
[]
)

if (
(itemType !== DND_TYPES.LABWARE && itemType !== null) ||
tab === 'protocolSteps' ||
isSelected ||
slotPosition == null
) {
return null
}

const draggedDef = draggedItem?.labwareOnDeck?.def
const isCustomLabware = draggedItem
? getLabwareIsCustom(customLabwareDefs, draggedItem.labwareOnDeck)
: false

const isSlotBlocked =
isOver &&
draggedDef != null &&
draggedDef.stackingOffsetWithLabware?.[adapterLoadName] == null &&
!isCustomLabware

drop(ref)

const hoverOpacity = (hover != null && hover === itemId) || isOver ? '1' : '0'

return (
<g ref={ref}>
{isSlotBlocked ? (
<BlockedSlot
x={slotPosition[0]}
y={slotPosition[1]}
width={slotBoundingBox.xDimension}
height={slotBoundingBox.yDimension}
message="LABWARE_INCOMPATIBLE_WITH_ADAPTER"
/>
) : (
<RobotCoordsForeignDiv
dataTestId={itemId}
x={onDeck ? slotPosition[0] : 0}
y={onDeck ? slotPosition[1] : 0}
width={slotBoundingBox.xDimension}
height={slotBoundingBox.yDimension}
innerDivProps={{
style: {
opacity: hoverOpacity,
...DECK_CONTROLS_STYLE,
},
onMouseEnter: () => {
setHover(itemId)
},
onMouseLeave: () => {
setHover(null)
},
onClick: () => {
if (!isOver) {
setShowMenuListForId(itemId)
}
},
}}
>
<Flex
width={slotBoundingBox.xDimension}
height={slotBoundingBox.yDimension}
alignItems={ALIGN_CENTER}
justifyContent={JUSTIFY_CENTER}
>
<Link role="button">
<StyledText desktopStyle="bodyDefaultSemiBold">
{isOver
? t('overlay.slot.place_here')
: t('starting_deck_state:edit_labware')}
</StyledText>
</Link>
</Flex>
</RobotCoordsForeignDiv>
)}
</g>
)
}
54 changes: 54 additions & 0 deletions protocol-designer/src/pages/Designer/DeckSetup/BlockedSlot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { useTranslation } from 'react-i18next'
import { css } from 'styled-components'
import { COLORS, RobotCoordsForeignDiv } from '@opentrons/components'

type BlockedSlotMessage =
| 'MODULE_INCOMPATIBLE_SINGLE_LABWARE'
| 'MODULE_INCOMPATIBLE_LABWARE_SWAP'
| 'LABWARE_INCOMPATIBLE_WITH_ADAPTER'

interface BlockedSlotProps {
x: number
y: number
width: number
height: number
message: BlockedSlotMessage
}

export const BlockedSlot = (props: BlockedSlotProps): JSX.Element => {
const { t } = useTranslation('deck')
const { x, y, width, height, message } = props
// TODO: get design feedback on this
return (
<g>
<rect
x={x}
y={y}
width={width}
height={height}
css={css`
fill: rgba(200, 115, 0, 0.75);
stroke: var(--c-red);
rx: 6;
`}
/>
<RobotCoordsForeignDiv
x={x}
y={y}
width={width}
height={height}
innerDivProps={{
style: {
height: '100%',
fontSize: '12px',
color: COLORS.white,
margin: '-1.5rem 0.5rem',
transform: 'rotate(180deg) scaleX(-1)',
},
}}
>
{t(`blocked_slot.${message}`)}
</RobotCoordsForeignDiv>
</g>
)
}
Loading
Loading