Skip to content

Commit

Permalink
fix up lint and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
b-cooper committed Nov 9, 2023
1 parent 93cc17c commit 3359a3b
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 55 deletions.
6 changes: 5 additions & 1 deletion components/src/hardware-sim/BaseDeck/SingleSlotFixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import * as React from 'react'
import { SlotBase } from './SlotBase'
import { SlotClip } from './SlotClip'

import type { CutoutId, DeckDefinition, ModuleType } from '@opentrons/shared-data'
import type {
CutoutId,
DeckDefinition,
ModuleType,
} from '@opentrons/shared-data'

interface SingleSlotFixtureProps extends React.SVGProps<SVGGElement> {
cutoutId: CutoutId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { shallow } from 'enzyme'
import fixture_96_plate from '@opentrons/shared-data/labware/fixtures/2/fixture_96_plate.json'
import {
CoordinateTuple,
DeckSlot,
LabwareDefinition2,
MAGNETIC_MODULE_TYPE,
} from '@opentrons/shared-data'
Expand Down
118 changes: 65 additions & 53 deletions protocol-designer/src/components/DeckSetup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
DeckDefinition,
RobotType,
FLEX_ROBOT_TYPE,
Cutout,
TRASH_BIN_LOAD_NAME,
STAGING_AREA_LOAD_NAME,
WASTE_CHUTE_CUTOUT,
Expand Down Expand Up @@ -71,7 +70,6 @@ import {
import { FlexModuleTag } from './FlexModuleTag'
import { Ot2ModuleTag } from './Ot2ModuleTag'
import { SlotLabels } from './SlotLabels'
import { DEFAULT_SLOTS } from './constants'
import { getHasGen1MultiChannelPipette, getSwapBlocked } from './utils'

import styles from './DeckSetup.css'
Expand Down Expand Up @@ -158,21 +156,21 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => {
// NOTE: naively hard-coded to show warning north of slots 1 or 3 when occupied by any module
const multichannelWarningSlotIds: AddressableAreaName[] = showGen1MultichannelCollisionWarnings
? compact([
allModules.some(
moduleOnDeck =>
moduleOnDeck.slot === '1' &&
MODULES_WITH_COLLISION_ISSUES.includes(moduleOnDeck.model)
)
? deckDef.locations.addressableAreas.find(s => s.id === '4')?.id
: null,
allModules.some(
moduleOnDeck =>
moduleOnDeck.slot === '3' &&
MODULES_WITH_COLLISION_ISSUES.includes(moduleOnDeck.model)
)
? deckDef.locations.addressableAreas.find(s => s.id === '6')?.id
: null,
])
allModules.some(
moduleOnDeck =>
moduleOnDeck.slot === '1' &&
MODULES_WITH_COLLISION_ISSUES.includes(moduleOnDeck.model)
)
? deckDef.locations.addressableAreas.find(s => s.id === '4')?.id
: null,
allModules.some(
moduleOnDeck =>
moduleOnDeck.slot === '3' &&
MODULES_WITH_COLLISION_ISSUES.includes(moduleOnDeck.model)
)
? deckDef.locations.addressableAreas.find(s => s.id === '6')?.id
: null,
])
: []

return (
Expand Down Expand Up @@ -257,6 +255,7 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => {
labwareOnDeck={labwareLoadedOnModule}
/>
{isAdapter ? (
// @ts-expect-error
<AdapterControls
allLabware={allLabware}
onDeck={false}
Expand Down Expand Up @@ -285,8 +284,9 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => {
) : null}

{labwareLoadedOnModule == null &&
!shouldHideChildren &&
!isAdapter ? (
!shouldHideChildren &&
!isAdapter ? (
// @ts-expect-error
<SlotControls
key={moduleOnDeck.slot}
slotPosition={[0, 0, 0]} // Module Component already handles nested positioning
Expand Down Expand Up @@ -342,6 +342,7 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => {
)
.map(addressableArea => {
return (
// @ts-expect-error
<SlotControls
key={addressableArea.id}
slotPosition={getPositionFromSlotId(addressableArea.id, deckDef)}
Expand All @@ -367,7 +368,6 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => {
return null

const slotPosition = getPositionFromSlotId(labware.slot, deckDef)
console.log('labawre', labware.slot)
const slotBoundingBox = getAddressableAreaFromSlotId(
labware.slot,
deckDef
Expand All @@ -387,6 +387,7 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => {
/>
<g>
{labwareIsAdapter ? (
// @ts-expect-error
<AdapterControls
allLabware={allLabware}
onDeck={true}
Expand Down Expand Up @@ -507,7 +508,13 @@ export const DeckSetup = (): JSX.Element => {
const trashBinFixtures = [
{
fixtureId: trash?.id,
fixtureLocation: trash?.slot != null ? getCutoutIdForAddressableArea(trash?.slot as AddressableAreaName, deckDef.cutoutFixtures) : null,
fixtureLocation:
trash?.slot != null
? getCutoutIdForAddressableArea(
trash?.slot as AddressableAreaName,
deckDef.cutoutFixtures
)
: null,
loadName: TRASH_BIN_LOAD_NAME,
},
]
Expand All @@ -518,8 +525,9 @@ export const DeckSetup = (): JSX.Element => {
activeDeckSetup.additionalEquipmentOnDeck
).filter(aE => aE.name === STAGING_AREA_LOAD_NAME)

const filteredAddressableAreas = deckDef.locations.addressableAreas.filter(aa => isAddressableAreaStandardSlot(aa.id))

const filteredAddressableAreas = deckDef.locations.addressableAreas.filter(
aa => isAddressableAreaStandardSlot(aa.id)
)

return (
<div className={styles.deck_row}>
Expand All @@ -537,15 +545,19 @@ export const DeckSetup = (): JSX.Element => {
) : (
<>
{filteredAddressableAreas.map(addressableArea => {
const cutoutId = getCutoutIdForAddressableArea(addressableArea.id, deckDef.cutoutFixtures)
return cutoutId != null ? (<SingleSlotFixture
key={addressableArea.id}
cutoutId={cutoutId}
deckDefinition={deckDef}
slotClipColor={darkFill}
showExpansion={cutoutId === 'cutoutA1'}
fixtureBaseColor={lightFill}
/>
const cutoutId = getCutoutIdForAddressableArea(
addressableArea.id,
deckDef.cutoutFixtures
)
return cutoutId != null ? (
<SingleSlotFixture
key={addressableArea.id}
cutoutId={cutoutId}
deckDefinition={deckDef}
slotClipColor={darkFill}
showExpansion={cutoutId === 'cutoutA1'}
fixtureBaseColor={lightFill}
/>
) : null
})}
{stagingAreaFixtures.map(fixture => (
Expand All @@ -558,26 +570,26 @@ export const DeckSetup = (): JSX.Element => {
/>
))}
{trash != null
? trashBinFixtures.map(fixture => (
fixture.fixtureLocation != null ? (
<React.Fragment key={fixture.fixtureId}>
<SingleSlotFixture
cutoutId={fixture.fixtureLocation}
deckDefinition={deckDef}
slotClipColor={COLORS.transparent}
fixtureBaseColor={lightFill}
/>
<FlexTrash
robotType={robotType}
trashIconColor={lightFill}
trashLocation={
fixture.fixtureLocation as TrashLocation
}
backgroundColor={darkFill}
/>
</React.Fragment>
) : null
))
? trashBinFixtures.map(fixture =>
fixture.fixtureLocation != null ? (
<React.Fragment key={fixture.fixtureId}>
<SingleSlotFixture
cutoutId={fixture.fixtureLocation}
deckDefinition={deckDef}
slotClipColor={COLORS.transparent}
fixtureBaseColor={lightFill}
/>
<FlexTrash
robotType={robotType}
trashIconColor={lightFill}
trashLocation={
fixture.fixtureLocation as TrashLocation
}
backgroundColor={darkFill}
/>
</React.Fragment>
) : null
)
: null}
{wasteChuteFixtures.map(fixture => (
<WasteChuteFixture
Expand Down Expand Up @@ -626,4 +638,4 @@ function getCutoutIdForAddressableArea(
) ?? []
return (cutoutId as CutoutId) ?? acc
}, null)
}
}

0 comments on commit 3359a3b

Please sign in to comment.