Skip to content

Commit

Permalink
feat(app): setup advanced settings/tip management state for quick tra…
Browse files Browse the repository at this point in the history
…nsfer

fix PLAT-227
  • Loading branch information
smb2268 committed May 15, 2024
1 parent 643a9dd commit f798a95
Show file tree
Hide file tree
Showing 16 changed files with 398 additions and 46 deletions.
14 changes: 7 additions & 7 deletions app/src/organisms/QuickTransferFlow/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
import { ListItem } from '../../atoms/ListItem'
import { CONSOLIDATE, DISTRIBUTE } from './constants'

import type { QuickTransferSetupState } from './types'
import type { QuickTransferSummaryState } from './types'

interface OverviewProps {
state: QuickTransferSetupState
state: QuickTransferSummaryState
}

export function Overview(props: OverviewProps): JSX.Element | null {
Expand All @@ -33,18 +33,18 @@ export function Overview(props: OverviewProps): JSX.Element | null {
const displayItems = [
{
option: t('pipette'),
value: state.pipette?.displayName,
value: state.pipette.displayName,
},
{
option: t('source_labware'),
value: state.source?.metadata.displayName,
value: state.sourceLabware.metadata.displayName,
},
{
option: t('destination_labware'),
value:
state.destination === 'source'
? state.source?.metadata.displayName
: state.destination?.metadata.displayName,
state.destinationLabware === 'source'
? state.sourceLabware.metadata.displayName
: state.destinationLabware.metadata.displayName,
},
{
option: transferCopy,
Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/QuickTransferFlow/SelectDestLabware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import type { LabwareDefinition2 } from '@opentrons/shared-data'
import type { SmallButton } from '../../atoms/buttons'
import type { LabwareFilter } from '../../pages/Labware/types'
import type {
QuickTransferSetupState,
QuickTransferWizardState,
QuickTransferWizardAction,
} from './types'

interface SelectDestLabwareProps {
onNext: () => void
onBack: () => void
exitButtonProps: React.ComponentProps<typeof SmallButton>
state: QuickTransferSetupState
state: QuickTransferWizardState
dispatch: React.Dispatch<QuickTransferWizardAction>
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/QuickTransferFlow/SelectDestWells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { ChildNavigation } from '../ChildNavigation'

import type { SmallButton } from '../../atoms/buttons'
import type {
QuickTransferSetupState,
QuickTransferWizardState,
QuickTransferWizardAction,
} from './types'

interface SelectDestWellsProps {
onNext: () => void
onBack: () => void
exitButtonProps: React.ComponentProps<typeof SmallButton>
state: QuickTransferSetupState
state: QuickTransferWizardState
dispatch: React.Dispatch<QuickTransferWizardAction>
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/QuickTransferFlow/SelectPipette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import { ChildNavigation } from '../ChildNavigation'
import type { PipetteData, Mount } from '@opentrons/api-client'
import type { SmallButton } from '../../atoms/buttons'
import type {
QuickTransferSetupState,
QuickTransferWizardState,
QuickTransferWizardAction,
} from './types'

interface SelectPipetteProps {
onNext: () => void
onBack: () => void
exitButtonProps: React.ComponentProps<typeof SmallButton>
state: QuickTransferSetupState
state: QuickTransferWizardState
dispatch: React.Dispatch<QuickTransferWizardAction>
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/QuickTransferFlow/SelectSourceLabware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import type { LabwareDefinition2 } from '@opentrons/shared-data'
import type { SmallButton } from '../../atoms/buttons'
import type { LabwareFilter } from '../../pages/Labware/types'
import type {
QuickTransferSetupState,
QuickTransferWizardState,
QuickTransferWizardAction,
} from './types'

interface SelectSourceLabwareProps {
onNext: () => void
onBack: () => void
exitButtonProps: React.ComponentProps<typeof SmallButton>
state: QuickTransferSetupState
state: QuickTransferWizardState
dispatch: React.Dispatch<QuickTransferWizardAction>
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/QuickTransferFlow/SelectSourceWells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { ChildNavigation } from '../ChildNavigation'

import type { SmallButton } from '../../atoms/buttons'
import type {
QuickTransferSetupState,
QuickTransferWizardState,
QuickTransferWizardAction,
} from './types'

interface SelectSourceWellsProps {
onNext: () => void
onBack: () => void
exitButtonProps: React.ComponentProps<typeof SmallButton>
state: QuickTransferSetupState
state: QuickTransferWizardState
dispatch: React.Dispatch<QuickTransferWizardAction>
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/QuickTransferFlow/SelectTipRack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { ChildNavigation } from '../ChildNavigation'
import type { LabwareDefinition2 } from '@opentrons/shared-data'
import type { SmallButton } from '../../atoms/buttons'
import type {
QuickTransferSetupState,
QuickTransferWizardState,
QuickTransferWizardAction,
} from './types'

interface SelectTipRackProps {
onNext: () => void
onBack: () => void
exitButtonProps: React.ComponentProps<typeof SmallButton>
state: QuickTransferSetupState
state: QuickTransferWizardState
dispatch: React.Dispatch<QuickTransferWizardAction>
}

Expand Down
20 changes: 16 additions & 4 deletions app/src/organisms/QuickTransferFlow/SummaryAndSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ import {
import { TabbedButton } from '../../atoms/buttons'
import { ChildNavigation } from '../ChildNavigation'
import { Overview } from './Overview'
import { getInitialSummaryState, quickTransferSummaryReducer } from './utils'

import type { SmallButton } from '../../atoms/buttons'
import type { QuickTransferSetupState } from './types'
import type { QuickTransferWizardState } from './types'

interface SummaryAndSettingsProps {
onNext: () => void
exitButtonProps: React.ComponentProps<typeof SmallButton>
state: QuickTransferSetupState
state: QuickTransferWizardState
}

export function SummaryAndSettings(
props: SummaryAndSettingsProps
): JSX.Element | null {
const { onNext, exitButtonProps, state } = props
const { onNext, exitButtonProps, state: wizardFlowState } = props
const { t } = useTranslation(['quick_transfer', 'shared'])
const displayCategory: string[] = [
'overview',
Expand All @@ -36,11 +37,22 @@ export function SummaryAndSettings(
const [selectedCategory, setSelectedCategory] = React.useState<string>(
'overview'
)
// if any value from the wizard flow hasn't been set, return null
// this should never happen but allows us to strictly type summary state
// @ts-expect-error figure out how to make this type non-null
const initialSummaryState = getInitialSummaryState(wizardFlowState)
const [state] = React.useReducer(
quickTransferSummaryReducer,
initialSummaryState
)
if (Object.values(wizardFlowState).some(value => value == null)) {
return null
}

return (
<Flex>
<ChildNavigation
header={t('quick_transfer_volume', { volume: state.volume })}
header={t('quick_transfer_volume', { volume: wizardFlowState.volume })}
buttonText={t('create_transfer')}
onClickButton={onNext}
secondaryButtonProps={exitButtonProps}
Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/QuickTransferFlow/VolumeEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import { CONSOLIDATE, DISTRIBUTE } from './constants'

import type { SmallButton } from '../../atoms/buttons'
import type {
QuickTransferSetupState,
QuickTransferWizardState,
QuickTransferWizardAction,
} from './types'

interface VolumeEntryProps {
onNext: () => void
onBack: () => void
exitButtonProps: React.ComponentProps<typeof SmallButton>
state: QuickTransferSetupState
state: QuickTransferWizardState
dispatch: React.Dispatch<QuickTransferWizardAction>
}

Expand Down
18 changes: 9 additions & 9 deletions app/src/organisms/QuickTransferFlow/__tests__/Overview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ describe('Overview', () => {
pipette: {
displayName: 'Pipette display name',
} as any,
source: {
sourceLabware: {
metadata: {
displayName: 'Source labware name',
},
} as any,
destination: {
destinationLabware: {
metadata: {
displayName: 'Destination labware name',
},
} as any,
transferType: 'transfer',
volume: 25,
},
} as any,
}
})
afterEach(() => {
Expand All @@ -57,19 +57,19 @@ describe('Overview', () => {
pipette: {
displayName: 'Pipette display name',
} as any,
source: {
sourceLabware: {
metadata: {
displayName: 'Source labware name',
},
} as any,
destination: {
destinationLabware: {
metadata: {
displayName: 'Destination labware name',
},
} as any,
transferType: 'consolidate',
volume: 25,
},
} as any,
}
render(props)
screen.getByText('Aspirate volume per well')
Expand All @@ -80,19 +80,19 @@ describe('Overview', () => {
pipette: {
displayName: 'Pipette display name',
} as any,
source: {
sourceLabware: {
metadata: {
displayName: 'Source labware name',
},
} as any,
destination: {
destinationLabware: {
metadata: {
displayName: 'Destination labware name',
},
} as any,
transferType: 'distribute',
volume: 25,
},
} as any,
}
render(props)
screen.getByText('Dispense volume per well')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import { SummaryAndSettings } from '../SummaryAndSettings'
import { Overview } from '../Overview'

vi.mock('../Overview')
vi.mock('../utils', async () => {
const actual = await vi.importActual('../utils')
return {
...actual,
getInitialSummaryState: vi.fn(),
}
})

const render = (props: React.ComponentProps<typeof SummaryAndSettings>) => {
return renderWithProviders(<SummaryAndSettings {...props} />, {
Expand All @@ -27,6 +34,14 @@ describe('SummaryAndSettings', () => {
onClick: vi.fn(),
},
state: {
pipette: {} as any,
mount: 'left',
tipRack: {} as any,
source: {} as any,
sourceWells: ['A1'],
destination: {} as any,
destinationWells: ['A1'],
transferType: 'transfer',
volume: 25,
},
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/QuickTransferFlow/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
NINETY_SIX_CHANNEL_COMPATIBLE_LABWARE,
} from '../constants'

import type { QuickTransferSetupState } from '../types'
import type { QuickTransferWizardState } from '../types'

describe('getVolumeLimits', () => {
const state: QuickTransferSetupState = {
const state: QuickTransferWizardState = {
pipette: {
liquids: [
{
Expand Down
18 changes: 18 additions & 0 deletions app/src/organisms/QuickTransferFlow/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ export const ACTIONS = {
SET_DEST_LABWARE: 'SET_DEST_LABWARE',
SET_DEST_WELLS: 'SET_DEST_WELLS',
SET_VOLUME: 'SET_VOLUME',
SUMMARY_SETUP: 'SUMMARY_SETUP',
SET_ASPIRATE_FLOW_RATE: 'SET_ASPIRATE_FLOW_RATE',
SET_DISPENSE_FLOW_RATE: 'SET_DISPENSE_FLOW_RATE',
SET_PIPETTE_PATH: 'SET_PIPETTE_PATH',
SET_ASPIRATE_TIP_POSITION: 'SET_ASPIRATE_TIP_POSITION',
SET_PRE_WET_TIP: 'SET_PRE_WET_TIP',
SET_MIX_ON_ASPIRATE: 'SET_MIX_ON_ASPIRATE',
SET_DELAY_ASPIRATE: 'SET_DELAY_ASPIRATE',
SET_TOUCH_TIP_ASPIRATE: 'SET_TOUCH_TIP_ASPIRATE',
SET_AIR_GAP_ASPIRATE: 'SET_AIR_GAP_ASPIRATE',
SET_DISPENSE_TIP_POSITION: 'SET_DISPENSE_TIP_POSITION',
SET_MIX_ON_DISPENSE: 'SET_MIX_ON_DISPENSE',
SET_DELAY_DISPENSE: 'SET_DELAY_DISPENSE',
SET_TOUCH_TIP_DISPENSE: 'SET_TOUCH_TIP_DISPENSE',
SET_BLOW_OUT: 'SET_BLOW_OUT',
SET_AIR_GAP_DISPENSE: 'SET_AIR_GAP_DISPENSE',
SET_CHANGE_TIP: 'SET_CHANGE_TIP',
SET_DROP_TIP_LOCATION: 'SET_DROP_TIP_LOCATION',
} as const

export const DISTRIBUTE = 'distribute'
Expand Down
8 changes: 4 additions & 4 deletions app/src/organisms/QuickTransferFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ import { SelectDestLabware } from './SelectDestLabware'
import { SelectDestWells } from './SelectDestWells'
import { VolumeEntry } from './VolumeEntry'
import { SummaryAndSettings } from './SummaryAndSettings'
import { quickTransferReducer } from './utils'
import { quickTransferWizardReducer } from './utils'

import type { SmallButton } from '../../atoms/buttons'
import type { QuickTransferSetupState } from './types'
import type { QuickTransferWizardState } from './types'

const QUICK_TRANSFER_WIZARD_STEPS = 8
const initialQuickTransferState: QuickTransferSetupState = {}
const initialQuickTransferState: QuickTransferWizardState = {}

export const QuickTransferFlow = (): JSX.Element => {
const history = useHistory()
const { i18n, t } = useTranslation(['quick_transfer', 'shared'])
const [state, dispatch] = React.useReducer(
quickTransferReducer,
quickTransferWizardReducer,
initialQuickTransferState
)
const [currentStep, setCurrentStep] = React.useState(0)
Expand Down
Loading

0 comments on commit f798a95

Please sign in to comment.