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

refactor(protocol-designer): ot-2 slot map is now a normal size #14518

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
15 changes: 2 additions & 13 deletions components/src/slotmap/SlotMap.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react'
import cx from 'classnames'
import { FLEX_ROBOT_TYPE, RobotType } from '@opentrons/shared-data'
import { Icon } from '../icons'
import styles from './styles.css'

Expand All @@ -14,7 +13,6 @@
collisionSlots?: string[]
/** Optional error styling */
isError?: boolean
robotType?: RobotType
}

const OT2_SLOT_MAP_SLOTS = [
Expand All @@ -24,24 +22,15 @@
['1', '2', '3'],
]

const FLEX_SLOT_MAP_SLOTS = [
['A1', 'A2', 'A3'],
['B1', 'B2', 'B3'],
['C1', 'C2', 'C3'],
['D1', 'D2', 'D3'],
]

const slotWidth = 33
const slotHeight = 23
const iconSize = 20
const numRows = 4
const numCols = 3

export function SlotMap(props: SlotMapProps): JSX.Element {
const { collisionSlots, occupiedSlots, isError, robotType } = props
const slots =
robotType === FLEX_ROBOT_TYPE ? FLEX_SLOT_MAP_SLOTS : OT2_SLOT_MAP_SLOTS

const { collisionSlots, occupiedSlots, isError } = props
const slots = OT2_SLOT_MAP_SLOTS

Check warning on line 33 in components/src/slotmap/SlotMap.tsx

View check run for this annotation

Codecov / codecov/patch

components/src/slotmap/SlotMap.tsx#L32-L33

Added lines #L32 - L33 were not covered by tests
return (
<svg
viewBox={`-1,-1,${slotWidth * numCols + 2}, ${slotHeight * numRows + 2}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export const WellSelectionField = (props: Props): JSX.Element => {
const stepId = useSelector(getSelectedStepId)
const pipetteEntities = useSelector(stepFormSelectors.getPipetteEntities)
const wellSelectionLabwareKey = useSelector(getWellSelectionLabwareKey)
const primaryWellCount = Array.isArray(selectedWells)
? selectedWells.length.toString()
: undefined
const primaryWellCount =
Array.isArray(selectedWells) && selectedWells.length > 0
? selectedWells.length.toString()
: undefined
Comment on lines +43 to +46
Copy link
Collaborator Author

@jerader jerader Feb 16, 2024

Choose a reason for hiding this comment

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

unrelated to the bug but this fixed another small bug i found that was introduced by my PR that refactored class components into functional components 😬

const pipette = pipetteId != null ? pipetteEntities[pipetteId] : null
const is8Channel = pipette != null ? pipette.spec.channels === 8 : false

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,3 @@
.button_margin {
margin-left: 1rem;
}

.slot_map_container {
flex: 0 1 13rem;
padding: 0 3rem 0;
}

.slot_map_container_modal {
display: flex;
height: 16rem;
margin-bottom: 1rem;
margin-top: 1rem;
justify-content: center;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import { getRobotType } from '../../../../file-data/selectors'
import { getInitialDeckSetup } from '../../../../step-forms/selectors'
import { getLabwareIsCompatible } from '../../../../utils/labwareModuleCompatibility'
import { getDisableModuleRestrictions } from '../../../../feature-flags/selectors'
import { ConnectedSlotMap } from '../ConnectedSlotMap'
import { EditModulesModal } from '../index'
import type { ModuleOnDeck } from '../../../../step-forms'

jest.mock('../ConnectedSlotMap')
jest.mock('../../../../file-data/selectors')
jest.mock('../../../../step-forms/selectors')
jest.mock('../../../../utils/labwareModuleCompatibility')
Expand All @@ -39,9 +37,6 @@ const mockGetLabwareIsCompatible = getLabwareIsCompatible as jest.MockedFunction
const mockGetDisableModuleRestrictions = getDisableModuleRestrictions as jest.MockedFunction<
typeof getDisableModuleRestrictions
>
const mockConnectedSlotMap = ConnectedSlotMap as jest.MockedFunction<
typeof ConnectedSlotMap
>
const mockSlotMap = SlotMap as jest.MockedFunction<typeof SlotMap>
const render = (props: React.ComponentProps<typeof EditModulesModal>) => {
return renderWithProviders(<EditModulesModal {...props} />, {
Expand Down Expand Up @@ -97,7 +92,6 @@ describe('Edit Modules Modal', () => {
mockGetLabwareIsCompatible.mockReturnValue(true)
mockGetDisableModuleRestrictions.mockReturnValue(false)
mockDeckLocationSelect.mockReturnValue(<div>mock DeckLocationSelect</div>)
mockConnectedSlotMap.mockReturnValue(<div>mock ConnectedSlotMap</div>)
mockSlotMap.mockReturnValue(<div>mock SlotMap</div>)
})
it('renders the edit modules modal for a temp on a flex', () => {
Expand All @@ -112,7 +106,7 @@ describe('Edit Modules Modal', () => {
mockGetRobotType.mockReturnValue(OT2_ROBOT_TYPE)
render(props)
screen.getByText('Temperature module')
screen.getByText('mock ConnectedSlotMap')
screen.getByText('mock SlotMap')
fireEvent.click(screen.getByRole('button', { name: 'cancel' }))
expect(props.onCloseClick).toHaveBeenCalled()
screen.getByRole('button', { name: 'save' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ import { PDAlert } from '../../alerts/PDAlert'
import { isModuleWithCollisionIssue } from '../../modules'
import { ModelDropdown } from './ModelDropdown'
import { SlotDropdown } from './SlotDropdown'
import { ConnectedSlotMap } from './ConnectedSlotMap'
import styles from './EditModules.css'

import type { ModuleOnDeck } from '../../../step-forms/types'
Expand Down Expand Up @@ -407,24 +406,23 @@ const EditModulesModalComponent = (
<Controller
name="selectedSlot"
control={control}
render={({ field, fieldState }) =>
moduleType === THERMOCYCLER_MODULE_TYPE ? (
<Flex
height="16rem"
justifyContent={JUSTIFY_CENTER}
paddingY={SPACING.spacing16}
>
render={({ field, fieldState }) => (
<Flex
height="16rem"
justifyContent={JUSTIFY_CENTER}
paddingY={SPACING.spacing16}
>
{moduleType === THERMOCYCLER_MODULE_TYPE ? (
<SlotMap occupiedSlots={['7', '8', '10', '11']} />
</Flex>
) : (
<ConnectedSlotMap
robotType={OT2_ROBOT_TYPE}
field={field}
hasFieldError={!fieldState.error}
/>
)
}
></Controller>
) : (
<SlotMap
occupiedSlots={[`${field.value}`]}
isError={!fieldState.error}
/>
)}
</Flex>
)}
/>
) : (
<Flex height="20rem" justifyContent={JUSTIFY_CENTER}>
<DeckLocationSelect
Expand Down
1 change: 0 additions & 1 deletion protocol-designer/src/components/modules/ModuleRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ export function ModuleRow(props: Props): JSX.Element {
<SlotMap
occupiedSlots={occupiedSlotsForMap}
collisionSlots={collisionSlots}
robotType={robotType}
/>
</div>
))}
Expand Down
Loading