Skip to content

Commit

Permalink
remove staging changes from odd protocol setup add fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
b-cooper committed May 16, 2024
1 parent 7c3a8c6 commit 80b2cb4
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ const Template: Story<React.ComponentProps<typeof AddFixtureModal>> = args => (
export const Default = Template.bind({})
Default.args = {
fixtureLocation: 'cutoutD3',
setShowAddFixtureModal: () => {},
closeModal: () => {},
isOnDevice: true,
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ export function AddFixtureModal({
)?.usbPort.port
)}
buttonText={t('add')}
onClickHandler={() => { handleAddFixture(cutoutConfigs) }}
onClickHandler={() => {
handleAddFixture(cutoutConfigs)
}}
isOnDevice={isOnDevice}
/>
))
Expand All @@ -315,9 +317,7 @@ export function AddFixtureModal({
<Modal
header={modalHeader}
onOutsideClick={() =>
providedFixtureOptions != null
? null
: closeModal()
providedFixtureOptions != null ? null : closeModal()
}
>
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing32}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type { Modules } from '@opentrons/api-client'
vi.mock('@opentrons/react-api-client')
vi.mock('../../../resources/deck_configuration')

const mockSetShowAddFixtureModal = vi.fn()
const mockCloseModal = vi.fn()
const mockUpdateDeckConfiguration = vi.fn()
const mockSetCurrentDeckConfig = vi.fn()

Expand All @@ -39,8 +39,7 @@ describe('Touchscreen AddFixtureModal', () => {
beforeEach(() => {
props = {
cutoutId: 'cutoutD3',
setShowAddFixtureModal: mockSetShowAddFixtureModal,
setCurrentDeckConfig: mockSetCurrentDeckConfig,
closeModal: mockCloseModal,
isOnDevice: true,
}
vi.mocked(useUpdateDeckConfigurationMutation).mockReturnValue({
Expand Down Expand Up @@ -96,7 +95,7 @@ describe('Desktop AddFixtureModal', () => {
beforeEach(() => {
props = {
cutoutId: 'cutoutD3',
setShowAddFixtureModal: mockSetShowAddFixtureModal,
closeModal: mockCloseModal,
}
vi.mocked(useUpdateDeckConfigurationMutation).mockReturnValue({
updateDeckConfiguration: mockUpdateDeckConfiguration,
Expand Down
5 changes: 4 additions & 1 deletion app/src/organisms/DeviceDetailsDeckConfiguration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ import { Banner } from '../../atoms/Banner'
import { DeckFixtureSetupInstructionsModal } from './DeckFixtureSetupInstructionsModal'
import { useIsRobotViewable, useRunStatuses } from '../Devices/hooks'
import { useIsEstopNotDisengaged } from '../../resources/devices/hooks/useIsEstopNotDisengaged'
import { useDeckConfigurationEditingTools, useNotifyDeckConfigurationQuery } from '../../resources/deck_configuration'
import {
useDeckConfigurationEditingTools,
useNotifyDeckConfigurationQuery,
} from '../../resources/deck_configuration'

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

Expand Down
13 changes: 3 additions & 10 deletions app/src/organisms/ProtocolSetupDeckConfiguration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ export function ProtocolSetupDeckConfiguration({
: config
)

const [
currentDeckConfig,
setCurrentDeckConfig,
] = React.useState<DeckConfiguration>(mergedDeckConfig)
const modulesOnDeck = currentDeckConfig.reduce<ModuleOnDeck[]>(
const modulesOnDeck = mergedDeckConfig.reduce<ModuleOnDeck[]>(
(acc, cutoutConfig) => {
const matchingFixtureIdsAndModel = Object.entries(
MODULE_FIXTURES_BY_MODEL
Expand Down Expand Up @@ -117,9 +113,7 @@ export function ProtocolSetupDeckConfiguration({
[]
)

const { updateDeckConfiguration } = useUpdateDeckConfigurationMutation()
const handleClickConfirm = (): void => {
updateDeckConfiguration(currentDeckConfig)
setSetupScreen('modules')
}

Expand All @@ -135,9 +129,8 @@ export function ProtocolSetupDeckConfiguration({
{showConfigurationModal && cutoutId != null ? (
<AddFixtureModal
cutoutId={cutoutId}
setShowAddFixtureModal={setShowConfigurationModal}
closeModal={() => setShowConfigurationModal(false)}
providedFixtureOptions={providedFixtureOptions}
setCurrentDeckConfig={setCurrentDeckConfig}
isOnDevice
/>
) : null}
Expand All @@ -158,7 +151,7 @@ export function ProtocolSetupDeckConfiguration({
height="28.4375rem"
>
<BaseDeck
deckConfig={currentDeckConfig}
deckConfig={mergedDeckConfig}
robotType={FLEX_ROBOT_TYPE}
modulesOnDeck={modulesOnDeck}
/>
Expand Down
5 changes: 4 additions & 1 deletion app/src/pages/DeckConfiguration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { ChildNavigation } from '../../organisms/ChildNavigation'
import { DeckFixtureSetupInstructionsModal } from '../../organisms/DeviceDetailsDeckConfiguration/DeckFixtureSetupInstructionsModal'
import { DeckConfigurationDiscardChangesModal } from '../../organisms/DeviceDetailsDeckConfiguration/DeckConfigurationDiscardChangesModal'
import { getTopPortalEl } from '../../App/portal'
import { useDeckConfigurationEditingTools, useNotifyDeckConfigurationQuery } from '../../resources/deck_configuration'
import {
useDeckConfigurationEditingTools,
useNotifyDeckConfigurationQuery,
} from '../../resources/deck_configuration'

export function DeckConfigurationEditor(): JSX.Element {
const { t, i18n } = useTranslation([
Expand Down
50 changes: 28 additions & 22 deletions app/src/resources/deck_configuration/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,23 @@ export function useDeckConfigurationCompatibility(
// get the on-deck labware name for a missing single-slot addressable area
const missingSingleSlotLabware =
cutoutFixtureId != null &&
// fixture mismatch
!compatibleCutoutFixtureIds.includes(cutoutFixtureId) &&
compatibleCutoutFixtureIds[0] != null &&
// compatible fixture is single-slot
SINGLE_SLOT_FIXTURES.includes(compatibleCutoutFixtureIds[0])
// fixture mismatch
!compatibleCutoutFixtureIds.includes(cutoutFixtureId) &&
compatibleCutoutFixtureIds[0] != null &&
// compatible fixture is single-slot
SINGLE_SLOT_FIXTURES.includes(compatibleCutoutFixtureIds[0])
? labwareInSlots.find(
({ location }) =>
// match the addressable area to an on-deck labware
requiredAddressableAreasForCutoutId[0] === location.slotName
)
({ location }) =>
// match the addressable area to an on-deck labware
requiredAddressableAreasForCutoutId[0] === location.slotName
)
: null

const missingLabwareDisplayName =
missingSingleSlotLabware != null
? missingSingleSlotLabware.labwareNickName ??
getLabwareDisplayName(missingSingleSlotLabware.labwareDef) ??
null
getLabwareDisplayName(missingSingleSlotLabware.labwareDef) ??
null
: null

return [
Expand All @@ -110,12 +110,17 @@ export function useDeckConfigurationCompatibility(
)
}

interface DeckConfigurationEditingTools {
addFixtureToCutout: (cutoutId: CutoutId) => void,
removeFixtureFromCutout: (cutoutId: CutoutId, cutoutFixtureId: CutoutFixtureId) => void
interface DeckConfigurationEditingTools {
addFixtureToCutout: (cutoutId: CutoutId) => void
removeFixtureFromCutout: (
cutoutId: CutoutId,
cutoutFixtureId: CutoutFixtureId
) => void
addFixtureModal: React.ReactNode
}
export function useDeckConfigurationEditingTools(isOnDevice: boolean): DeckConfigurationEditingTools {
export function useDeckConfigurationEditingTools(
isOnDevice: boolean
): DeckConfigurationEditingTools {
const deckDef = getDeckDefFromRobotType(FLEX_ROBOT_TYPE)
const deckConfig =
useNotifyDeckConfigurationQuery({
Expand Down Expand Up @@ -182,12 +187,13 @@ export function useDeckConfigurationEditingTools(isOnDevice: boolean): DeckConfi
return {
addFixtureToCutout,
removeFixtureFromCutout,
addFixtureModal: targetCutoutId != null ? (
<AddFixtureModal
cutoutId={targetCutoutId}
closeModal={() => setTargetCutoutId(null)}
isOnDevice={isOnDevice}
/>
) : null
addFixtureModal:
targetCutoutId != null ? (
<AddFixtureModal
cutoutId={targetCutoutId}
closeModal={() => setTargetCutoutId(null)}
isOnDevice={isOnDevice}
/>
) : null,
}
}

0 comments on commit 80b2cb4

Please sign in to comment.