@@ -11,6 +11,11 @@ import {
11
11
JUSTIFY_FLEX_START ,
12
12
DIRECTION_COLUMN ,
13
13
} from '@opentrons/components'
14
+ import {
15
+ getLabwareDefURI ,
16
+ getLabwareDisplayName ,
17
+ getModuleDisplayName ,
18
+ } from '@opentrons/shared-data'
14
19
import { StyledText } from '../../atoms/text'
15
20
import { Banner } from '../../atoms/Banner'
16
21
import { useProtocolDetailsForRun , useDeckCalibrationData } from './hooks'
@@ -27,7 +32,6 @@ export function HistoricalProtocolRunOffsetDrawer(
27
32
) : JSX . Element | null {
28
33
const { t } = useTranslation ( 'run_details' )
29
34
const { run, robotName } = props
30
- const [ showOutOfDateBanner , setShowOutOfDateBanner ] = React . useState ( false )
31
35
const allLabwareOffsets = run . labwareOffsets ?. sort (
32
36
( a , b ) => new Date ( b . createdAt ) . getTime ( ) - new Date ( a . createdAt ) . getTime ( )
33
37
)
@@ -50,7 +54,6 @@ export function HistoricalProtocolRunOffsetDrawer(
50
54
? deckCalibrationData . lastModified
51
55
: null
52
56
const protocolDetails = useProtocolDetailsForRun ( run . id )
53
- const labwareDetails = protocolDetails . protocolData ?. labware
54
57
55
58
if ( uniqueLabwareOffsets == null || uniqueLabwareOffsets . length === 0 ) {
56
59
return (
@@ -70,23 +73,20 @@ export function HistoricalProtocolRunOffsetDrawer(
70
73
</ Box >
71
74
)
72
75
}
73
- if (
76
+ const isOutOfDate =
74
77
typeof lastModifiedDeckCal === 'string' &&
75
78
new Date ( lastModifiedDeckCal ) . getTime ( ) >
76
79
new Date (
77
80
uniqueLabwareOffsets [ uniqueLabwareOffsets ?. length - 1 ] . createdAt
78
81
) . getTime ( )
79
- ) {
80
- setShowOutOfDateBanner ( true )
81
- }
82
82
83
83
return (
84
84
< Box
85
85
backgroundColor = { COLORS . medGrey }
86
86
width = "100%"
87
87
padding = { SPACING . spacing3 }
88
88
>
89
- { showOutOfDateBanner && (
89
+ { isOutOfDate ? (
90
90
< Banner
91
91
type = "warning"
92
92
marginLeft = { SPACING . spacing5 }
@@ -99,7 +99,7 @@ export function HistoricalProtocolRunOffsetDrawer(
99
99
< StyledText as = "p" > { t ( 'robot_was_recalibrated' ) } </ StyledText >
100
100
</ Flex >
101
101
</ Banner >
102
- ) }
102
+ ) : null }
103
103
< Flex
104
104
justifyContent = { JUSTIFY_FLEX_START }
105
105
borderBottom = { BORDERS . lineBorder }
@@ -111,7 +111,7 @@ export function HistoricalProtocolRunOffsetDrawer(
111
111
as = "label"
112
112
fontWeight = { TYPOGRAPHY . fontWeightSemiBold }
113
113
textTransform = { TYPOGRAPHY . textTransformCapitalize }
114
- dataTest -id= { `RecentProtocolRun_OffsetDrawer_locationTitle` }
114
+ datatest -id= { `RecentProtocolRun_OffsetDrawer_locationTitle` }
115
115
>
116
116
{ t ( 'location' ) }
117
117
</ StyledText >
@@ -120,7 +120,7 @@ export function HistoricalProtocolRunOffsetDrawer(
120
120
width = "33%"
121
121
fontWeight = { TYPOGRAPHY . fontWeightSemiBold }
122
122
textTransform = { TYPOGRAPHY . textTransformCapitalize }
123
- dataTest -id= { `RecentProtocolRun_OffsetDrawer_labwareTitle` }
123
+ datatest -id= { `RecentProtocolRun_OffsetDrawer_labwareTitle` }
124
124
>
125
125
{ t ( 'labware' ) }
126
126
</ StyledText >
@@ -129,19 +129,19 @@ export function HistoricalProtocolRunOffsetDrawer(
129
129
width = "40%"
130
130
fontWeight = { TYPOGRAPHY . fontWeightSemiBold }
131
131
textTransform = { TYPOGRAPHY . textTransformCapitalize }
132
- dataTest -id= { `RecentProtocolRun_OffsetDrawer_labwareOffsetDataTitle` }
132
+ datatest -id= { `RecentProtocolRun_OffsetDrawer_labwareOffsetDataTitle` }
133
133
>
134
134
{ t ( 'labware_offset_data' ) }
135
135
</ StyledText >
136
136
</ Flex >
137
137
{ uniqueLabwareOffsets . map ( ( offset , index ) => {
138
- let labwareName = offset . definitionUri
139
- if ( labwareDetails != null ) {
140
- labwareName =
141
- Object . values ( labwareDetails ) ?. find ( labware =>
142
- labware . definitionId . includes ( offset . definitionUri )
143
- ) ?. displayName ?? offset . definitionUri
144
- }
138
+ const definition = Object . values (
139
+ protocolDetails . protocolData ?. labwareDefinitions ?? { }
140
+ ) . find ( def => getLabwareDefURI ( def ) === offset . definitionUri )
141
+ const labwareName =
142
+ definition != null
143
+ ? getLabwareDisplayName ( definition )
144
+ : offset . definitionUri
145
145
146
146
return (
147
147
< Flex
@@ -155,18 +155,23 @@ export function HistoricalProtocolRunOffsetDrawer(
155
155
< StyledText width = "25%" as = "label" >
156
156
{ t ( 'slot' , { slotName : offset . location . slotName } ) }
157
157
{ offset . location . moduleModel != null &&
158
- ` - ${ offset . location . moduleModel } ` }
158
+ ` - ${ getModuleDisplayName ( offset . location . moduleModel ) } ` }
159
159
</ StyledText >
160
- < StyledText as = "label" width = "33%" >
160
+ < StyledText
161
+ as = "label"
162
+ width = "33%"
163
+ overflow = "hidden"
164
+ textOverflow = "ellipsis"
165
+ title = { labwareName }
166
+ >
161
167
{ labwareName }
162
168
</ StyledText >
163
- < StyledText as = "label" width = "40%" >
164
- < OffsetVector
165
- x = { offset . vector . x }
166
- y = { offset . vector . y }
167
- z = { offset . vector . z }
168
- />
169
- </ StyledText >
169
+ < OffsetVector
170
+ { ...offset . vector }
171
+ width = "40%"
172
+ fontSize = { TYPOGRAPHY . fontSizeLabel }
173
+ as = "label"
174
+ />
170
175
</ Flex >
171
176
)
172
177
} ) }
0 commit comments