Skip to content

Commit

Permalink
fix(app): Various quick transfer fixes (#15904)
Browse files Browse the repository at this point in the history
  • Loading branch information
smb2268 authored Aug 6, 2024
1 parent e2d48dc commit d3eac90
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 41 deletions.
1 change: 0 additions & 1 deletion app/src/assets/localization/en/app_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"__dev_internal__protocolStats": "Protocol Stats",
"__dev_internal__protocolTimeline": "Protocol Timeline",
"__dev_internal__enableRunNotes": "Display Notes During a Protocol Run",
"__dev_internal__enableQuickTransfer": "Enable Quick Transfer",
"__dev_internal__enableLabwareCreator": "Enable App Labware Creator",
"add_folder_button": "Add labware source folder",
"add_ip_button": "Add",
Expand Down
4 changes: 3 additions & 1 deletion app/src/assets/localization/en/quick_transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"deleted_transfer": "Deleted quick transfer",
"destination": "Destination",
"destination_labware": "Destination labware",
"disabled": "Disabled",
"dispense_flow_rate": "Dispense flow rate",
"dispense_flow_rate_µL": "Dispense flow rate (µL/s)",
"dispense_settings": "Dispense Settings",
Expand Down Expand Up @@ -90,7 +91,8 @@
"pipette_currently_attached": "Quick transfer options depend on the pipettes currently attached to your robot.",
"pipette_path": "Pipette path",
"pipette_path_multi_aspirate": "Multi-aspirate",
"pipette_path_multi_dispense": "Multi-dispense, {{volume}} disposal volume, blowout into {{blowOutLocation}}",
"pipette_path_multi_dispense": "Multi-dispense",
"pipette_path_multi_dispense_volume_blowout": "Multi-dispense, {{volume}} disposal volume, blowout into {{blowOutLocation}}",
"pipette_path_single": "Single transfers",
"pre_wet_tip": "Pre-wet tip",
"quick_transfer": "Quick transfer",
Expand Down
15 changes: 3 additions & 12 deletions app/src/organisms/Navigation/__tests__/Navigation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ import * as React from 'react'
import { MemoryRouter } from 'react-router-dom'
import { fireEvent, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { when } from 'vitest-when'

import { renderWithProviders } from '../../../__testing-utils__'
import { i18n } from '../../../i18n'
import { getLocalRobot } from '../../../redux/discovery'
import { mockConnectedRobot } from '../../../redux/discovery/__fixtures__'
import { useFeatureFlag } from '../../../redux/config'
import { useNetworkConnection } from '../../../resources/networking/hooks/useNetworkConnection'
import { NavigationMenu } from '../NavigationMenu'
import { Navigation } from '..'

vi.mock('../../../resources/networking/hooks/useNetworkConnection')
vi.mock('../../../redux/discovery')
vi.mock('../../../redux/config')
vi.mock('../NavigationMenu')

mockConnectedRobot.name = '12345678901234567'
Expand Down Expand Up @@ -66,6 +63,9 @@ describe('Navigation', () => {
const allProtocols = screen.getByRole('link', { name: 'Protocols' })
expect(allProtocols).toHaveAttribute('href', '/protocols')

const quickTransfer = screen.getByRole('link', { name: 'Quick Transfer' })
expect(quickTransfer).toHaveAttribute('href', '/quick-transfer')

const instruments = screen.getByRole('link', { name: 'Instruments' })
expect(instruments).toHaveAttribute('href', '/instruments')

Expand All @@ -75,15 +75,6 @@ describe('Navigation', () => {
expect(screen.queryByText('Get started')).not.toBeInTheDocument()
expect(screen.queryByLabelText('network icon')).not.toBeInTheDocument()
})
it('should render quick transfer tab if feature flag is on', () => {
when(vi.mocked(useFeatureFlag))
.calledWith('enableQuickTransfer')
.thenReturn(true)
render(props)
screen.getByRole('link', { name: '123456789012...' }) // because of the truncate function
const quickTransfer = screen.getByRole('link', { name: 'Quick Transfer' })
expect(quickTransfer).toHaveAttribute('href', '/quick-transfer')
})
it('should render a network icon', () => {
vi.mocked(useNetworkConnection).mockReturnValue({
isEthernetConnected: false,
Expand Down
13 changes: 2 additions & 11 deletions app/src/organisms/Navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import { ODD_FOCUS_VISIBLE } from '../../atoms/buttons/constants'

import { useNetworkConnection } from '../../resources/networking/hooks/useNetworkConnection'
import { getLocalRobot } from '../../redux/discovery'
import { useFeatureFlag } from '../../redux/config'
import { NavigationMenu } from './NavigationMenu'
import type { ON_DEVICE_DISPLAY_PATHS } from '../../App/OnDeviceDisplayApp'

let NAV_LINKS: Array<typeof ON_DEVICE_DISPLAY_PATHS[number]> = [
const NAV_LINKS: Array<typeof ON_DEVICE_DISPLAY_PATHS[number]> = [
'/protocols',
'/quick-transfer',
'/instruments',
'/robot-settings',
]
Expand Down Expand Up @@ -68,15 +68,6 @@ export function Navigation(props: NavigationProps): JSX.Element {
const localRobot = useSelector(getLocalRobot)
const [showNavMenu, setShowNavMenu] = React.useState<boolean>(false)
const robotName = localRobot?.name != null ? localRobot.name : 'no name'
const enableQuickTransferFF = useFeatureFlag('enableQuickTransfer')
if (enableQuickTransferFF) {
NAV_LINKS = [
'/protocols',
'/quick-transfer',
'/instruments',
'/robot-settings',
]
}

// We need to display an icon for what type of network connection (if any)
// is active next to the robot's name. The designs call for it to change color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export function Mix(props: MixProps): JSX.Element {
type: mixAction,
mixSettings: undefined,
})
onBack()
} else {
setCurrentStep(2)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function QuickTransferAdvancedSettings(
} else if (state.path === 'multiAspirate') {
pipettePathValue = t('pipette_path_multi_aspirate')
} else if (state.path === 'multiDispense') {
pipettePathValue = t('pipette_path_multi_dispense', {
pipettePathValue = t('pipette_path_multi_dispense_volume_blowout', {
volume: state.disposalVolume,
blowOutLocation: getBlowoutValueCopy(),
})
Expand Down Expand Up @@ -160,7 +160,10 @@ export function QuickTransferAdvancedSettings(
state.transferType === 'transfer' ||
state.transferType === 'distribute',
onClick: () => {
if (state.transferType === 'transfer') {
if (
state.transferType === 'transfer' ||
state.transferType === 'distribute'
) {
setSelectedSetting('aspirate_mix')
} else {
makeSnackbar(t('advanced_setting_disabled') as string)
Expand Down Expand Up @@ -240,7 +243,10 @@ export function QuickTransferAdvancedSettings(
state.transferType === 'transfer' ||
state.transferType === 'consolidate',
onClick: () => {
if (state.transferType === 'transfer') {
if (
state.transferType === 'transfer' ||
state.transferType === 'consolidate'
) {
setSelectedSetting('dispense_mix')
} else {
makeSnackbar(t('advanced_setting_disabled') as string)
Expand Down Expand Up @@ -293,7 +299,10 @@ export function QuickTransferAdvancedSettings(
{
option: 'dispense_blow_out',
copy: t('blow_out'),
value: i18n.format(getBlowoutValueCopy(), 'capitalize'),
value:
state.transferType === 'distribute'
? t('disabled')
: i18n.format(getBlowoutValueCopy(), 'capitalize'),
enabled: state.transferType !== 'distribute',
onClick: () => {
if (state.transferType === 'distribute') {
Expand Down
25 changes: 17 additions & 8 deletions app/src/organisms/QuickTransferFlow/SelectDestWells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ import {
LegacyStyledText,
JUSTIFY_CENTER,
} from '@opentrons/components'
import { getAllDefinitions } from '@opentrons/shared-data'

import { getTopPortalEl } from '../../App/portal'
import { Modal } from '../../molecules/Modal'
import { ChildNavigation } from '../../organisms/ChildNavigation'
import { useToaster } from '../../organisms/ToasterOven'
import { WellSelection } from '../../organisms/WellSelection'
import {
CIRCULAR_WELL_96_PLATE_DEFINITION_URI,
RECTANGULAR_WELL_96_PLATE_DEFINITION_URI,
} from './SelectSourceWells'

import type { SmallButton } from '../../atoms/buttons'
import type { ModalHeaderBaseProps } from '../../molecules/Modal/types'
Expand Down Expand Up @@ -107,9 +112,17 @@ export function SelectDestWells(props: SelectDestWellsProps): JSX.Element {
setSelectedWells({})
},
}
const labwareDefinition =
let labwareDefinition =
state.destination === 'source' ? state.source : state.destination

if (labwareDefinition?.parameters.format === '96Standard') {
const allDefinitions = getAllDefinitions()
if (Object.values(labwareDefinition.wells)[0].shape === 'circular') {
labwareDefinition = allDefinitions[CIRCULAR_WELL_96_PLATE_DEFINITION_URI]
} else {
labwareDefinition =
allDefinitions[RECTANGULAR_WELL_96_PLATE_DEFINITION_URI]
}
}
return (
<>
{createPortal(
Expand Down Expand Up @@ -143,7 +156,7 @@ export function SelectDestWells(props: SelectDestWellsProps): JSX.Element {
left="0"
width="100%"
>
{state.destination != null && state.source != null ? (
{labwareDefinition != null ? (
<Flex
width={
labwareDefinition?.parameters.format === '384Standard'
Expand All @@ -152,11 +165,7 @@ export function SelectDestWells(props: SelectDestWellsProps): JSX.Element {
}
>
<WellSelection
definition={
state.destination === 'source'
? state.source
: state.destination
}
definition={labwareDefinition}
deselectWells={(wells: string[]) => {
setSelectedWells(prevWells =>
without(Object.keys(prevWells), ...wells).reduce(
Expand Down
21 changes: 19 additions & 2 deletions app/src/organisms/QuickTransferFlow/SelectSourceWells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
POSITION_FIXED,
SPACING,
} from '@opentrons/components'
import { getAllDefinitions } from '@opentrons/shared-data'

import { ChildNavigation } from '../../organisms/ChildNavigation'
import { WellSelection } from '../../organisms/WellSelection'
Expand All @@ -24,6 +25,11 @@ interface SelectSourceWellsProps {
dispatch: React.Dispatch<QuickTransferWizardAction>
}

export const CIRCULAR_WELL_96_PLATE_DEFINITION_URI =
'opentrons/thermoscientificnunc_96_wellplate_2000ul/1'
export const RECTANGULAR_WELL_96_PLATE_DEFINITION_URI =
'opentrons/usascientific_96_wellplate_2.4ml_deep/1'

export function SelectSourceWells(props: SelectSourceWellsProps): JSX.Element {
const { onNext, onBack, state, dispatch } = props
const { i18n, t } = useTranslation(['quick_transfer', 'shared'])
Expand All @@ -50,6 +56,17 @@ export function SelectSourceWells(props: SelectSourceWellsProps): JSX.Element {
setSelectedWells({})
},
}
let displayLabwareDefinition = state.source
if (state.source?.parameters.format === '96Standard') {
const allDefinitions = getAllDefinitions()
if (Object.values(state.source.wells)[0].shape === 'circular') {
displayLabwareDefinition =
allDefinitions[CIRCULAR_WELL_96_PLATE_DEFINITION_URI]
} else {
displayLabwareDefinition =
allDefinitions[RECTANGULAR_WELL_96_PLATE_DEFINITION_URI]
}
}

return (
<>
Expand All @@ -71,14 +88,14 @@ export function SelectSourceWells(props: SelectSourceWellsProps): JSX.Element {
left="0"
width="100%"
>
{state.source != null ? (
{state.source != null && displayLabwareDefinition != null ? (
<Flex
width={
state.source.parameters.format === '384Standard' ? '100%' : '75%'
}
>
<WellSelection
definition={state.source}
definition={displayLabwareDefinition}
deselectWells={(wells: string[]) => {
setSelectedWells(prevWells =>
without(Object.keys(prevWells), ...wells).reduce(
Expand Down
1 change: 0 additions & 1 deletion app/src/redux/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const DEV_INTERNAL_FLAGS: DevInternalFlag[] = [
'forceHttpPolling',
'protocolStats',
'enableRunNotes',
'enableQuickTransfer',
'protocolTimeline',
'enableLabwareCreator',
]
Expand Down
1 change: 0 additions & 1 deletion app/src/redux/config/schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export type DevInternalFlag =
| 'forceHttpPolling'
| 'protocolStats'
| 'enableRunNotes'
| 'enableQuickTransfer'
| 'protocolTimeline'
| 'enableLabwareCreator'

Expand Down

0 comments on commit d3eac90

Please sign in to comment.