Skip to content

Commit dd0394d

Browse files
authored
fix(app): show tiprack nickname in spotlight window in PV (#20796)
closes RQA-5155
1 parent 7d704b7 commit dd0394d

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

app/src/organisms/Desktop/ProtocolVisualization/SecondWindow/TipPickupSlot/TipPickupSlot.test.tsx renamed to app/src/organisms/Desktop/ProtocolVisualization/SecondWindow/TipPickupSlot/__tests__/TipPickupSlot.test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import { CLEAN, DIRTY, EMPTY } from '@opentrons/step-generation'
77
import { renderWithProviders } from '/app/__testing-utils__'
88
import { i18n } from '/app/i18n'
99

10-
import { TipPickupSlot } from './'
10+
import { TipPickupSlot } from '..'
1111

1212
import type { ComponentProps } from 'react'
1313
import type * as OpentronsComponents from '@opentrons/components'
1414
import type { LabwareDefinition2 } from '@opentrons/shared-data'
15-
import type { LabwareEntity, RobotState } from '@opentrons/step-generation'
15+
import type { RobotState } from '@opentrons/step-generation'
16+
import type { LabwareEntityExtended } from '../../../DeckView'
1617

1718
vi.mock('@opentrons/components', async importOriginal => {
1819
const actual = await importOriginal<typeof OpentronsComponents>()
@@ -38,12 +39,13 @@ const createMockLabwareDef = (): LabwareDefinition2 => {
3839
} as LabwareDefinition2
3940
}
4041

41-
const createMockTiprackEntity = (): LabwareEntity => {
42+
const createMockTiprackEntity = (): LabwareEntityExtended => {
4243
return {
4344
id: MOCK_TIPRACK_ID,
4445
labwareDefURI: 'opentrons/fixture_tiprack_300_ul/1',
4546
def: createMockLabwareDef(),
4647
pythonName: 'mock_tiprack',
48+
nickName: 'mockNickname',
4749
}
4850
}
4951

@@ -95,7 +97,7 @@ describe('TipPickupSlot', () => {
9597
it('should render TipPickupSlot', () => {
9698
render(props)
9799
screen.getByText(MOCK_SLOT)
98-
screen.getByText('Mock 300µL Tiprack')
100+
screen.getByText('mockNickname')
99101
screen.getByText('mock LabwareRender')
100102
screen.getByTestId('robot-workspace')
101103
})

app/src/organisms/Desktop/ProtocolVisualization/SecondWindow/TipPickupSlot/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ import { getMissingTips } from '../../utils/getMissingTips'
1616
import styles from './tippickupslot.module.css'
1717

1818
import type { TipType } from '@opentrons/components'
19-
import type { LabwareEntity, RobotState } from '@opentrons/step-generation'
19+
import type { RobotState } from '@opentrons/step-generation'
20+
import type { LabwareEntityExtended } from '../../DeckView'
2021

2122
interface TipPickupSlotProps {
22-
tiprackEntity: LabwareEntity
23+
tiprackEntity: LabwareEntityExtended
2324
robotState: RobotState
2425
}
2526

2627
export function TipPickupSlot(props: TipPickupSlotProps): JSX.Element {
2728
const { tiprackEntity, robotState } = props
2829
const { t } = useTranslation('protocol_visualization')
29-
const { id, def } = tiprackEntity
30+
const { id, def, nickName } = tiprackEntity
3031
const { tipState, labware } = robotState
3132
const tipStateInfo = tipState.tipracks[id]
3233
const tipStatusByWellName =
@@ -50,6 +51,9 @@ export function TipPickupSlot(props: TipPickupSlotProps): JSX.Element {
5051
<div className={styles.container}>
5152
<div className={styles.header}>
5253
<RobotInfoLabel deckLabel={slot} />
54+
{nickName != null ? (
55+
<StyledText desktopStyle="bodyDefaultSemiBold">{nickName}</StyledText>
56+
) : null}
5357
<StyledText desktopStyle="bodyDefaultRegular" color={COLORS.grey60}>
5458
{def.metadata.displayName}
5559
</StyledText>

app/src/organisms/Desktop/ProtocolVisualization/SlotDetails/index.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ import { TipDisposalSlot } from '../SecondWindow/TipDisposalSlot'
1313
import { TipPickupSlot } from '../SecondWindow/TipPickupSlot'
1414
import styles from './slotdetails.module.css'
1515

16-
import type { Liquid, ProtocolAnalysisOutput } from '@opentrons/shared-data'
16+
import type {
17+
Liquid,
18+
LoadLabwareRunTimeCommand,
19+
ProtocolAnalysisOutput,
20+
} from '@opentrons/shared-data'
1721
import type {
1822
HopperLocationMapKey,
1923
InvariantContext,
2024
RobotState,
2125
} from '@opentrons/step-generation'
26+
import type { LabwareEntityExtended } from '../DeckView'
2227

2328
interface SlotDetailsProps {
2429
slotId: string
@@ -37,6 +42,9 @@ export function SlotDetails(props: SlotDetailsProps): JSX.Element {
3742
moduleEntities,
3843
} = invariantContext
3944
const { commands } = analysis
45+
const loadLabwareCommands = commands.filter(
46+
command => command.commandType === 'loadLabware'
47+
)
4048
const stackOfLabwareOnSlot = getFullStackFromLabwares(labware, slotId)
4149
const isHopperSlot = HOPPER_FAKE_LOCATIONS.includes(slotId)
4250
const mappedSlot = isHopperSlot
@@ -45,6 +53,22 @@ export function SlotDetails(props: SlotDetailsProps): JSX.Element {
4553
const moduleOnSlot = Object.entries(modules).find(
4654
([id, module]) => module.slot === mappedSlot
4755
)
56+
const labwareEntitiesExtended = Object.entries(labwareEntities).reduce(
57+
(acc: Record<string, LabwareEntityExtended>, [key, entity]) => {
58+
const matchingCommand =
59+
loadLabwareCommands.find(
60+
(command): command is LoadLabwareRunTimeCommand =>
61+
command.result?.labwareId === entity.id
62+
) ?? null
63+
acc[key] = {
64+
...entity,
65+
nickName: matchingCommand?.params?.displayName ?? null,
66+
}
67+
return acc
68+
},
69+
{}
70+
)
71+
4872
const topMostLabwareOnSlot =
4973
stackOfLabwareOnSlot?.length > 1 ? stackOfLabwareOnSlot[0] : null
5074
const isTopmostLabwareATiprack =
@@ -81,7 +105,7 @@ export function SlotDetails(props: SlotDetailsProps): JSX.Element {
81105
case 'tiprack':
82106
return (
83107
<TipPickupSlot
84-
tiprackEntity={labwareEntities[topMostLabwareOnSlot]}
108+
tiprackEntity={labwareEntitiesExtended[topMostLabwareOnSlot]}
85109
robotState={robotState}
86110
/>
87111
)

0 commit comments

Comments
 (0)