Skip to content

Commit

Permalink
feat(protocol-designer): update React DnD to version 16.0.1
Browse files Browse the repository at this point in the history
closes RAUT-964
  • Loading branch information
jerader committed Feb 13, 2024
1 parent 5620e19 commit f7a40fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ interface Props {
swapBlocked: boolean
}

interface DroppedItem {
labwareOnDeck: LabwareOnDeck
}
export const EditLabware = (props: Props): JSX.Element | null => {

Check warning on line 31 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L31

Added line #L31 was not covered by tests
const {
labwareOnDeck,
Expand Down Expand Up @@ -59,30 +62,30 @@ export const EditLabware = (props: Props): JSX.Element | null => {

const [{ draggedLabware, isOver }, drop] = useDrop(() => ({

Check warning on line 63 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L63

Added line #L63 was not covered by tests
accept: DND_TYPES.LABWARE,
canDrop: (monitor: DropTargetMonitor) => {
const draggedItem: any = monitor.getItem()
canDrop: (item: any) => {
const draggedItem = item?.labwareOnDeck
const draggedLabware = draggedItem?.labwareOnDeck

Check warning on line 67 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L66-L67

Added lines #L66 - L67 were not covered by tests
const isDifferentSlot =
draggedLabware && draggedLabware.slot !== props.labwareOnDeck.slot
return isDifferentSlot && !props.swapBlocked
draggedLabware && draggedLabware.slot !== labwareOnDeck.slot
return isDifferentSlot && !swapBlocked
},
drop: (monitor: DropTargetMonitor) => {
const draggedItem: any = monitor.getItem()
drop: (item: any) => {
const draggedItem = item?.labwareOnDeck

Check warning on line 73 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L73

Added line #L73 was not covered by tests
if (draggedItem) {
dispatch(

Check warning on line 75 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L75

Added line #L75 was not covered by tests
moveDeckItem(draggedItem.labwareOnDeck.slot, props.labwareOnDeck.slot)
moveDeckItem(draggedItem.labwareOnDeck.slot, labwareOnDeck.slot)
)
}
},

hover: (monitor: DropTargetMonitor) => {
if (monitor.canDrop()) {
props.setHoveredLabware(labwareOnDeck)
setHoveredLabware(labwareOnDeck)

Check warning on line 83 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L83

Added line #L83 was not covered by tests
}
},
collect: (monitor: DropTargetMonitor) => ({

Check warning on line 86 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L86

Added line #L86 was not covered by tests
isOver: monitor.isOver(),
draggedLabware: monitor.getItem() as any,
draggedLabware: monitor.getItem() as DroppedItem,
}),
}))

Expand All @@ -94,7 +97,8 @@ export const EditLabware = (props: Props): JSX.Element | null => {
/>
)
} else {
const isBeingDragged = draggedLabware?.slot === labwareOnDeck.slot
const isBeingDragged =
draggedLabware?.labwareOnDeck.slot === labwareOnDeck.slot

Check warning on line 101 in protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/components/DeckSetup/LabwareOverlays/EditLabware.tsx#L101

Added line #L101 was not covered by tests

let contents: React.ReactNode | null = null

Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/containers/ConnectedStepItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const ConnectedStepItem = (
props: ConnectedStepItemProps
): JSX.Element => {
const { stepId, stepNumber } = props

const step = useSelector(stepFormSelectors.getSavedStepForms)[stepId]
const argsAndErrors = useSelector(stepFormSelectors.getArgsAndErrorsByStepId)[
stepId
Expand Down

0 comments on commit f7a40fb

Please sign in to comment.