-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add tip management tab and items (#15291)
This PR adds the tip management tab with change tip and drop tip location settings. fix PLAT-224 Co-authored-by: Brian Cooper <[email protected]> Co-authored-by: Brent Hagen <[email protected]>
- Loading branch information
1 parent
38f6bd1
commit f49c33d
Showing
18 changed files
with
901 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
app/src/organisms/QuickTransferFlow/TipManagement/ChangeTip.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { createPortal } from 'react-dom' | ||
import { | ||
Flex, | ||
SPACING, | ||
DIRECTION_COLUMN, | ||
POSITION_FIXED, | ||
COLORS, | ||
} from '@opentrons/components' | ||
import { getTopPortalEl } from '../../../App/portal' | ||
import { LargeButton } from '../../../atoms/buttons' | ||
import { ChildNavigation } from '../../ChildNavigation' | ||
|
||
import type { | ||
ChangeTipOptions, | ||
QuickTransferSummaryState, | ||
QuickTransferSummaryAction, | ||
} from '../types' | ||
|
||
interface ChangeTipProps { | ||
onBack: () => void | ||
state: QuickTransferSummaryState | ||
dispatch: React.Dispatch<QuickTransferSummaryAction> | ||
} | ||
|
||
export function ChangeTip(props: ChangeTipProps): JSX.Element { | ||
const { onBack, state, dispatch } = props | ||
const { t } = useTranslation('quick_transfer') | ||
|
||
const allowedChangeTipOptions: ChangeTipOptions[] = ['once'] | ||
if (state.sourceWells.length <= 96 && state.destinationWells.length <= 96) { | ||
allowedChangeTipOptions.push('always') | ||
} | ||
if (state.path === 'single' && state.transferType === 'distribute') { | ||
allowedChangeTipOptions.push('perDest') | ||
} else if (state.path === 'single') { | ||
allowedChangeTipOptions.push('perSource') | ||
} | ||
|
||
const [ | ||
selectedChangeTipOption, | ||
setSelectedChangeTipOption, | ||
] = React.useState<ChangeTipOptions>(state.changeTip) | ||
|
||
const handleClickSave = (): void => { | ||
if (selectedChangeTipOption !== state.changeTip) { | ||
dispatch({ | ||
type: 'SET_CHANGE_TIP', | ||
changeTip: selectedChangeTipOption, | ||
}) | ||
} | ||
onBack() | ||
} | ||
return createPortal( | ||
<Flex position={POSITION_FIXED} backgroundColor={COLORS.white} width="100%"> | ||
<ChildNavigation | ||
header={t('change_tip')} | ||
buttonText={t('save')} | ||
onClickBack={onBack} | ||
onClickButton={handleClickSave} | ||
buttonIsDisabled={selectedChangeTipOption == null} | ||
/> | ||
<Flex | ||
marginTop={SPACING.spacing120} | ||
flexDirection={DIRECTION_COLUMN} | ||
padding={`${SPACING.spacing16} ${SPACING.spacing60} ${SPACING.spacing40} ${SPACING.spacing60}`} | ||
gridGap={SPACING.spacing4} | ||
width="100%" | ||
> | ||
{allowedChangeTipOptions.map(option => ( | ||
<LargeButton | ||
key={option} | ||
buttonType={ | ||
selectedChangeTipOption === option ? 'primary' : 'secondary' | ||
} | ||
onClick={() => { | ||
setSelectedChangeTipOption(option) | ||
}} | ||
buttonText={t(`${option}`)} | ||
/> | ||
))} | ||
</Flex> | ||
</Flex>, | ||
getTopPortalEl() | ||
) | ||
} |
109 changes: 109 additions & 0 deletions
109
app/src/organisms/QuickTransferFlow/TipManagement/TipDropLocation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import * as React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { createPortal } from 'react-dom' | ||
import { | ||
Flex, | ||
SPACING, | ||
DIRECTION_COLUMN, | ||
POSITION_FIXED, | ||
COLORS, | ||
} from '@opentrons/components' | ||
import { | ||
WASTE_CHUTE_FIXTURES, | ||
FLEX_SINGLE_SLOT_BY_CUTOUT_ID, | ||
TRASH_BIN_ADAPTER_FIXTURE, | ||
} from '@opentrons/shared-data' | ||
import { getTopPortalEl } from '../../../App/portal' | ||
import { LargeButton } from '../../../atoms/buttons' | ||
import { useNotifyDeckConfigurationQuery } from '../../../resources/deck_configuration' | ||
import { ChildNavigation } from '../../ChildNavigation' | ||
|
||
import type { | ||
QuickTransferSummaryState, | ||
QuickTransferSummaryAction, | ||
} from '../types' | ||
import type { CutoutConfig } from '@opentrons/shared-data' | ||
|
||
interface TipDropLocationProps { | ||
onBack: () => void | ||
state: QuickTransferSummaryState | ||
dispatch: React.Dispatch<QuickTransferSummaryAction> | ||
} | ||
|
||
export function TipDropLocation(props: TipDropLocationProps): JSX.Element { | ||
const { onBack, state, dispatch } = props | ||
const { t } = useTranslation('quick_transfer') | ||
const deckConfig = useNotifyDeckConfigurationQuery().data ?? [] | ||
|
||
const tipDropLocationOptions = deckConfig.filter( | ||
cutoutConfig => | ||
WASTE_CHUTE_FIXTURES.includes(cutoutConfig.cutoutFixtureId) || | ||
TRASH_BIN_ADAPTER_FIXTURE === cutoutConfig.cutoutFixtureId | ||
) | ||
|
||
// add trash bin in A3 if no trash or waste chute configured | ||
if (tipDropLocationOptions.length === 0) { | ||
tipDropLocationOptions.push({ | ||
cutoutId: 'cutoutA3', | ||
cutoutFixtureId: TRASH_BIN_ADAPTER_FIXTURE, | ||
}) | ||
} | ||
|
||
const [ | ||
selectedTipDropLocation, | ||
setSelectedTipDropLocation, | ||
] = React.useState<CutoutConfig>(state.dropTipLocation) | ||
|
||
const handleClickSave = (): void => { | ||
if (selectedTipDropLocation.cutoutId !== state.dropTipLocation.cutoutId) { | ||
dispatch({ | ||
type: 'SET_DROP_TIP_LOCATION', | ||
location: selectedTipDropLocation, | ||
}) | ||
} | ||
onBack() | ||
} | ||
return createPortal( | ||
<Flex position={POSITION_FIXED} backgroundColor={COLORS.white} width="100%"> | ||
<ChildNavigation | ||
header={t('tip_drop_location')} | ||
buttonText={t('save')} | ||
onClickBack={onBack} | ||
onClickButton={handleClickSave} | ||
buttonIsDisabled={selectedTipDropLocation == null} | ||
/> | ||
<Flex | ||
marginTop={SPACING.spacing120} | ||
flexDirection={DIRECTION_COLUMN} | ||
padding={`${SPACING.spacing16} ${SPACING.spacing60} ${SPACING.spacing40} ${SPACING.spacing60}`} | ||
gridGap={SPACING.spacing4} | ||
width="100%" | ||
> | ||
{tipDropLocationOptions.map(option => ( | ||
<LargeButton | ||
key={option.cutoutId} | ||
buttonType={ | ||
selectedTipDropLocation.cutoutId === option.cutoutId | ||
? 'primary' | ||
: 'secondary' | ||
} | ||
onClick={() => { | ||
setSelectedTipDropLocation(option) | ||
}} | ||
buttonText={t( | ||
`${ | ||
option.cutoutFixtureId === TRASH_BIN_ADAPTER_FIXTURE | ||
? 'trashBin' | ||
: 'wasteChute' | ||
}_location`, | ||
{ | ||
slotName: FLEX_SINGLE_SLOT_BY_CUTOUT_ID[option.cutoutId], | ||
} | ||
)} | ||
/> | ||
))} | ||
</Flex> | ||
</Flex>, | ||
getTopPortalEl() | ||
) | ||
} |
Oops, something went wrong.