@@ -15,22 +15,24 @@ import {
15
15
InfoScreen ,
16
16
JUSTIFY_FLEX_START ,
17
17
LegacyStyledText ,
18
+ MODULE_ICON_NAME_BY_TYPE ,
18
19
OVERFLOW_HIDDEN ,
19
20
SPACING ,
20
21
TYPOGRAPHY ,
21
22
} from '@opentrons/components'
22
23
import {
24
+ FLEX_STACKER_MODULE_TYPE ,
23
25
getLabwareDefURI ,
24
26
getLabwareDisplayName ,
25
27
getLoadedLabwareDefinitionsByUri ,
26
- getModuleDisplayName ,
28
+ getModuleType ,
27
29
} from '@opentrons/shared-data'
28
30
import { useCsvFileQuery } from '@opentrons/react-api-client'
29
31
import { DownloadCsvFileLink } from './DownloadCsvFileLink'
30
32
import { useMostRecentCompletedAnalysis } from '/app/resources/runs'
31
33
import { useDeckCalibrationData } from './hooks'
32
34
import { OffsetVector } from '/app/molecules/OffsetVector'
33
- import type { RunData } from '@opentrons/api-client'
35
+ import type { LabwareOffset , RunData } from '@opentrons/api-client'
34
36
35
37
interface HistoricalProtocolRunDrawerProps {
36
38
run : RunData
@@ -42,9 +44,11 @@ export function HistoricalProtocolRunDrawer(
42
44
) : JSX . Element | null {
43
45
const { i18n, t } = useTranslation ( 'run_details' )
44
46
const { run, robotName } = props
45
- const allLabwareOffsets = run . labwareOffsets ?. sort (
46
- ( a , b ) => new Date ( b . createdAt ) . getTime ( ) - new Date ( a . createdAt ) . getTime ( )
47
- )
47
+ const allLabwareOffsets : LabwareOffset [ ] =
48
+ run . labwareOffsets ?. sort (
49
+ ( a , b ) =>
50
+ new Date ( b . createdAt ) . getTime ( ) - new Date ( a . createdAt ) . getTime ( )
51
+ ) ?? [ ]
48
52
const runDataFileIds =
49
53
'runTimeParameters' in run
50
54
? run . runTimeParameters . reduce < string [ ] > ( ( acc , parameter ) => {
@@ -60,17 +64,22 @@ export function HistoricalProtocolRunDrawer(
60
64
runDataFileIds . push ( ...run . outputFileIds )
61
65
}
62
66
63
- const uniqueLabwareOffsets = allLabwareOffsets ? .filter (
67
+ const uniqueLabwareOffsets = allLabwareOffsets . filter (
64
68
( offset , index , array ) => {
65
69
return (
66
70
array . findIndex (
67
71
firstOffset =>
68
- firstOffset . location . slotName === offset . location . slotName &&
69
- firstOffset . definitionUri === offset . definitionUri
70
- ) === index && ! isEqual ( offset . vector , { x : 0 , y : 0 , z : 0 } )
72
+ isEqual ( firstOffset . locationSequence , offset . locationSequence ) &&
73
+ isEqual ( firstOffset . definitionUri , offset . definitionUri )
74
+ ) === index
71
75
)
72
76
}
73
77
)
78
+ const sortedUniqueLwOffsets = uniqueLabwareOffsets . sort ( ( a , b ) =>
79
+ a . location . slotName . localeCompare ( b . location . slotName , 'en' , {
80
+ numeric : true ,
81
+ } )
82
+ )
74
83
75
84
const deckCalibrationData = useDeckCalibrationData ( robotName )
76
85
. deckCalibrationData
@@ -82,11 +91,10 @@ export function HistoricalProtocolRunDrawer(
82
91
83
92
const isOutOfDate =
84
93
typeof lastModifiedDeckCal === 'string' &&
85
- uniqueLabwareOffsets != null &&
86
- uniqueLabwareOffsets . length > 0 &&
94
+ sortedUniqueLwOffsets . length > 0 &&
87
95
new Date ( lastModifiedDeckCal ) . getTime ( ) >
88
96
new Date (
89
- uniqueLabwareOffsets [ uniqueLabwareOffsets ?. length - 1 ] . createdAt
97
+ sortedUniqueLwOffsets [ sortedUniqueLwOffsets ?. length - 1 ] . createdAt
90
98
) . getTime ( )
91
99
const outOfDateBanner = isOutOfDate ? (
92
100
< Banner
@@ -153,7 +161,7 @@ export function HistoricalProtocolRunDrawer(
153
161
)
154
162
155
163
const labwareOffsets =
156
- uniqueLabwareOffsets == null || uniqueLabwareOffsets . length === 0 ? (
164
+ sortedUniqueLwOffsets == null || sortedUniqueLwOffsets . length === 0 ? (
157
165
< InfoScreen content = { t ( 'no_offsets_available' ) } />
158
166
) : (
159
167
< Flex flexDirection = { DIRECTION_COLUMN } gridGap = { SPACING . spacing4 } >
@@ -198,7 +206,7 @@ export function HistoricalProtocolRunDrawer(
198
206
</ Box >
199
207
</ Flex >
200
208
< Flex flexDirection = { DIRECTION_COLUMN } gridGap = { SPACING . spacing4 } >
201
- { uniqueLabwareOffsets . map ( ( offset , index ) => {
209
+ { sortedUniqueLwOffsets . map ( ( offset , index ) => {
202
210
const labwareDefinitions =
203
211
protocolDetails ?. commands != null
204
212
? getLoadedLabwareDefinitionsByUri ( protocolDetails ?. commands )
@@ -227,11 +235,25 @@ export function HistoricalProtocolRunDrawer(
227
235
alignItems = { ALIGN_CENTER }
228
236
>
229
237
< DeckInfoLabel deckLabel = { offset . location . slotName } />
230
- < LegacyStyledText as = "p" >
231
- { offset . location . moduleModel != null
232
- ? getModuleDisplayName ( offset . location . moduleModel )
233
- : null }
234
- </ LegacyStyledText >
238
+ { offset . locationSequence ?. some (
239
+ seq => seq . kind === 'onLabware'
240
+ ) && (
241
+ < DeckInfoLabel
242
+ iconName = {
243
+ MODULE_ICON_NAME_BY_TYPE [ FLEX_STACKER_MODULE_TYPE ]
244
+ }
245
+ key = "stacked-icon"
246
+ />
247
+ ) }
248
+ { offset . location . moduleModel && (
249
+ < DeckInfoLabel
250
+ iconName = {
251
+ MODULE_ICON_NAME_BY_TYPE [
252
+ getModuleType ( offset . location . moduleModel )
253
+ ]
254
+ }
255
+ />
256
+ ) }
235
257
</ Flex >
236
258
< Box width = "33%" >
237
259
< LegacyStyledText as = "p" title = { labwareName } >
0 commit comments