-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol-designer): wire up substeps for transfer and mix (#16383)
- Loading branch information
Showing
22 changed files
with
739 additions
and
22 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
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,37 @@ | ||
import { useSelector } from 'react-redux' | ||
import { getLabwareEntities } from '../../step-forms/selectors' | ||
import { getHoveredStepLabware } from '../../ui/steps' | ||
import { LabwareLabel } from './LabwareLabel' | ||
import type { CoordinateTuple } from '@opentrons/shared-data' | ||
import type { LabwareOnDeck } from '../../step-forms' | ||
|
||
interface HighlightLabwareProps { | ||
labwareOnDeck: LabwareOnDeck | ||
position: CoordinateTuple | ||
} | ||
|
||
export function HighlightLabware( | ||
props: HighlightLabwareProps | ||
): JSX.Element | null { | ||
const { labwareOnDeck, position } = props | ||
const labwareEntities = useSelector(getLabwareEntities) | ||
const hoveredLabware = useSelector(getHoveredStepLabware) | ||
const adapterId = | ||
labwareEntities[labwareOnDeck.slot] != null | ||
? labwareEntities[labwareOnDeck.slot].id | ||
: null | ||
|
||
const highlighted = hoveredLabware.includes(adapterId ?? labwareOnDeck.id) | ||
|
||
if (highlighted) { | ||
return ( | ||
<LabwareLabel | ||
isSelected={true} | ||
isLast={true} | ||
position={position} | ||
labwareDef={labwareOnDeck.def} | ||
/> | ||
) | ||
} | ||
return null | ||
} |
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
121 changes: 121 additions & 0 deletions
121
protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.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,121 @@ | ||
import { useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { | ||
ALIGN_CENTER, | ||
DIRECTION_COLUMN, | ||
DeckInfoLabel, | ||
Flex, | ||
JUSTIFY_SPACE_BETWEEN, | ||
ListButton, | ||
SPACING, | ||
StyledText, | ||
Tag, | ||
} from '@opentrons/components' | ||
import { Substep } from './Substep' | ||
import { formatVolume } from './utils' | ||
import type { AdditionalEquipmentName } from '@opentrons/step-generation' | ||
import type { | ||
StepItemSourceDestRow, | ||
SubstepIdentifier, | ||
WellIngredientNames, | ||
} from '../../../../steplist' | ||
|
||
interface MultichannelSubstepProps { | ||
trashName: AdditionalEquipmentName | null | ||
rowGroup: StepItemSourceDestRow[] | ||
ingredNames: WellIngredientNames | ||
stepId: string | ||
substepIndex: number | ||
selectSubstep: (substepIdentifier: SubstepIdentifier) => void | ||
highlighted?: boolean | ||
} | ||
|
||
export function MultichannelSubstep( | ||
props: MultichannelSubstepProps | ||
): JSX.Element { | ||
const { | ||
rowGroup, | ||
stepId, | ||
selectSubstep, | ||
substepIndex, | ||
ingredNames, | ||
trashName, | ||
} = props | ||
const { t } = useTranslation('application') | ||
const [collapsed, setCollapsed] = useState<Boolean>(true) | ||
const handleToggleCollapsed = (): void => { | ||
setCollapsed(!collapsed) | ||
} | ||
|
||
const firstChannelSource = rowGroup[0].source | ||
const lastChannelSource = rowGroup[rowGroup.length - 1].source | ||
const sourceWellRange = `${ | ||
firstChannelSource ? firstChannelSource.well : '' | ||
}:${lastChannelSource ? lastChannelSource.well : ''}` | ||
const firstChannelDest = rowGroup[0].dest | ||
const lastChannelDest = rowGroup[rowGroup.length - 1].dest | ||
const destWellRange = `${ | ||
firstChannelDest ? firstChannelDest.well ?? 'Trash' : '' | ||
}:${lastChannelDest ? lastChannelDest.well : ''}` | ||
|
||
return ( | ||
<Flex | ||
flexDirection={DIRECTION_COLUMN} | ||
gridGap={SPACING.spacing8} | ||
width="100%" | ||
onMouseEnter={() => { | ||
selectSubstep({ stepId, substepIndex }) | ||
}} | ||
onMouseLeave={() => { | ||
selectSubstep(null) | ||
}} | ||
> | ||
{/* TODO: need to update this to match designs! */} | ||
<ListButton type="noActive" onClick={handleToggleCollapsed}> | ||
<Flex | ||
flexDirection={DIRECTION_COLUMN} | ||
gridGap={SPACING.spacing4} | ||
width="100%" | ||
> | ||
<Flex | ||
padding={SPACING.spacing12} | ||
justifyContent={JUSTIFY_SPACE_BETWEEN} | ||
width="100%" | ||
alignItems={ALIGN_CENTER} | ||
> | ||
<StyledText desktopStyle="bodyDefaultRegular">Multi</StyledText> | ||
{firstChannelSource != null ? ( | ||
<DeckInfoLabel deckLabel={sourceWellRange} /> | ||
) : null} | ||
<Tag | ||
text={`${formatVolume(rowGroup[0].volume)} ${t( | ||
'units.microliter' | ||
)}`} | ||
type="default" | ||
/> | ||
{firstChannelDest != null ? ( | ||
<DeckInfoLabel deckLabel={destWellRange} /> | ||
) : null} | ||
</Flex> | ||
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing4}> | ||
{!collapsed && | ||
rowGroup.map((row, rowKey) => { | ||
return ( | ||
<Substep | ||
trashName={trashName} | ||
key={rowKey} | ||
volume={row.volume} | ||
ingredNames={ingredNames} | ||
source={row.source} | ||
dest={row.dest} | ||
stepId={stepId} | ||
substepIndex={substepIndex} | ||
/> | ||
) | ||
})} | ||
</Flex> | ||
</Flex> | ||
</ListButton> | ||
</Flex> | ||
) | ||
} |
73 changes: 73 additions & 0 deletions
73
protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/PipettingSubsteps.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,73 @@ | ||
import { DIRECTION_COLUMN, Flex, SPACING } from '@opentrons/components' | ||
import { Substep } from './Substep' | ||
import { MultichannelSubstep } from './MultichannelSubstep' | ||
import type { | ||
SourceDestSubstepItem, | ||
SubstepIdentifier, | ||
WellIngredientNames, | ||
} from '../../../../steplist' | ||
import { useSelector } from 'react-redux' | ||
import { | ||
getAdditionalEquipment, | ||
getSavedStepForms, | ||
} from '../../../../step-forms/selectors' | ||
|
||
interface PipettingSubstepsProps { | ||
substeps: SourceDestSubstepItem | ||
ingredNames: WellIngredientNames | ||
selectSubstep: (substepIdentifier: SubstepIdentifier) => void | ||
hoveredSubstep?: SubstepIdentifier | null | ||
} | ||
|
||
export function PipettingSubsteps(props: PipettingSubstepsProps): JSX.Element { | ||
const { substeps, selectSubstep, hoveredSubstep, ingredNames } = props | ||
const stepId = substeps.parentStepId | ||
const formData = useSelector(getSavedStepForms)[stepId] | ||
const additionalEquipment = useSelector(getAdditionalEquipment) | ||
const destLocationId = formData.dispense_labware | ||
const trashName = | ||
additionalEquipment[destLocationId] != null | ||
? additionalEquipment[destLocationId]?.name | ||
: null | ||
|
||
const renderSubsteps = substeps.multichannel | ||
? substeps.multiRows.map((rowGroup, groupKey) => ( | ||
<MultichannelSubstep | ||
trashName={trashName} | ||
key={groupKey} | ||
highlighted={ | ||
!!hoveredSubstep && | ||
hoveredSubstep.stepId === substeps.parentStepId && | ||
hoveredSubstep.substepIndex === groupKey | ||
} | ||
rowGroup={rowGroup} | ||
stepId={substeps.parentStepId} | ||
substepIndex={groupKey} | ||
selectSubstep={selectSubstep} | ||
ingredNames={ingredNames} | ||
/> | ||
)) | ||
: substeps.rows.map((row, substepIndex) => ( | ||
<Substep | ||
trashName={trashName} | ||
key={substepIndex} | ||
selectSubstep={selectSubstep} | ||
stepId={substeps.parentStepId} | ||
substepIndex={substepIndex} | ||
ingredNames={ingredNames} | ||
volume={row.volume} | ||
source={row.source} | ||
dest={row.dest} | ||
/> | ||
)) | ||
|
||
return ( | ||
<Flex | ||
flexDirection={DIRECTION_COLUMN} | ||
gridGap={SPACING.spacing4} | ||
width="100%" | ||
> | ||
{renderSubsteps} | ||
</Flex> | ||
) | ||
} |
Oops, something went wrong.