1
1
import {
2
2
FLEX_ROBOT_TYPE ,
3
- getLabwareDisplayName ,
4
3
getSimplestDeckConfigForProtocol ,
5
- getTopLabwareInfo ,
6
4
} from '@opentrons/shared-data'
7
5
8
6
import { BaseDeck } from '../BaseDeck'
9
- import { LabwareInfo } from './LabwareInfo'
10
7
import { getStandardDeckViewLayerBlockList } from './utils'
11
8
import { getLabwareInfoByLiquidId } from './utils/getLabwareInfoByLiquidId'
12
9
import { getTopMostLabwareInSlots } from './utils/getLabwareInSlots'
@@ -16,61 +13,30 @@ import { getWellFillFromLabwareId } from './utils/getWellFillFromLabwareId'
16
13
import type { ComponentProps } from 'react'
17
14
import type {
18
15
CompletedProtocolAnalysis ,
19
- LabwareDefinition2 ,
20
16
ProtocolAnalysisOutput ,
21
- RunTimeCommand ,
22
- LoadLabwareRunTimeCommand ,
23
17
} from '@opentrons/shared-data'
24
18
25
19
export * from './utils/getStandardDeckViewLayerBlockList'
26
20
27
21
interface ProtocolDeckProps {
28
22
protocolAnalysis : CompletedProtocolAnalysis | ProtocolAnalysisOutput | null
29
- /** defaults to false, when set labware nicknames will appear on top level labware. If no nickname specified in protocol, falls back to labware definition display name */
30
- showLabwareInfo ?: boolean
31
- /** optional labware click handler, highlights labware */
32
- handleLabwareClick ?: (
33
- labwareDef : LabwareDefinition2 ,
34
- labwareId : string
35
- ) => void
36
23
/** extra props to pass through to BaseDeck component */
37
24
baseDeckProps ?: Partial < ComponentProps < typeof BaseDeck > >
38
25
}
39
26
40
27
export function ProtocolDeck ( props : ProtocolDeckProps ) : JSX . Element | null {
41
- const {
42
- protocolAnalysis,
43
- baseDeckProps,
44
- handleLabwareClick,
45
- showLabwareInfo = false ,
46
- } = props
28
+ const { protocolAnalysis, baseDeckProps } = props
47
29
48
30
if ( protocolAnalysis == null || ( protocolAnalysis ?. errors ?? [ ] ) . length > 0 )
49
31
return null
50
- const commands : RunTimeCommand [ ] = protocolAnalysis . commands
51
- const loadLabwareCommands = commands ?. filter (
52
- ( command ) : command is LoadLabwareRunTimeCommand =>
53
- command . commandType === 'loadLabware'
54
- )
55
32
56
33
const robotType = protocolAnalysis . robotType ?? FLEX_ROBOT_TYPE
57
34
const deckConfig = getSimplestDeckConfigForProtocol ( protocolAnalysis )
58
35
const labwareByLiquidId = getLabwareInfoByLiquidId ( protocolAnalysis . commands )
59
36
60
37
const modulesInSlots = getModulesInSlots ( protocolAnalysis )
61
38
const modulesOnDeck = modulesInSlots . map (
62
- ( {
63
- moduleModel,
64
- moduleLocation,
65
- nestedLabwareId,
66
- nestedLabwareDef,
67
- nestedLabwareNickName,
68
- } ) => {
69
- const { topLabwareId, topLabwareDefinition } = getTopLabwareInfo (
70
- nestedLabwareId ?? '' ,
71
- loadLabwareCommands
72
- )
73
-
39
+ ( { moduleModel, moduleLocation, nestedLabwareId, nestedLabwareDef } ) => {
74
40
return {
75
41
moduleModel,
76
42
moduleLocation,
@@ -80,60 +46,14 @@ export function ProtocolDeck(props: ProtocolDeckProps): JSX.Element | null {
80
46
protocolAnalysis . liquids ,
81
47
labwareByLiquidId
82
48
) ,
83
- moduleChildren :
84
- showLabwareInfo &&
85
- nestedLabwareDef != null &&
86
- ! ( nestedLabwareDef . allowedRoles ?? [ ] ) . includes ( 'adapter' ) ? (
87
- < LabwareInfo def = { nestedLabwareDef } >
88
- { nestedLabwareNickName ?? getLabwareDisplayName ( nestedLabwareDef ) }
89
- </ LabwareInfo >
90
- ) : null ,
91
- highlightLabware : handleLabwareClick != null ,
92
- highlightShadowLabware :
93
- handleLabwareClick != null &&
94
- topLabwareDefinition != null &&
95
- topLabwareId != null ,
96
- onLabwareClick :
97
- handleLabwareClick != null &&
98
- topLabwareDefinition != null &&
99
- topLabwareId != null
100
- ? ( ) => {
101
- handleLabwareClick ( topLabwareDefinition , topLabwareId )
102
- }
103
- : undefined ,
104
- stacked :
105
- handleLabwareClick != null &&
106
- topLabwareDefinition != null &&
107
- topLabwareId != null ,
108
49
}
109
50
}
110
51
)
111
52
112
- // this function gets the top labware assuming a stack of max 2 labware
53
+ // this function gets the top most labware
113
54
const topMostLabwareInSlots = getTopMostLabwareInSlots ( protocolAnalysis )
114
55
const labwareOnDeck = topMostLabwareInSlots . map (
115
- ( { labwareId, labwareDef, labwareNickName, location } ) => {
116
- // this gets the very top of the stack in case there is a stack
117
- // of many like items, such as TC lids
118
- const { topLabwareId, topLabwareDefinition } = getTopLabwareInfo (
119
- labwareId ,
120
- loadLabwareCommands
121
- )
122
- const isLabwareInStack =
123
- protocolAnalysis ?. commands . some (
124
- command =>
125
- command . commandType === 'loadLabware' &&
126
- command . result ?. labwareId === labwareId &&
127
- typeof command . params . location === 'object' &&
128
- ( 'moduleId' in command . params . location ||
129
- 'labwareId' in command . params . location )
130
- ) ||
131
- protocolAnalysis ?. commands . some (
132
- command =>
133
- command . commandType === 'loadLidStack' &&
134
- command . result ?. labwareIds . includes ( labwareId )
135
- )
136
-
56
+ ( { labwareId, labwareDef, location } ) => {
137
57
return {
138
58
definition : labwareDef ,
139
59
labwareLocation : location ,
@@ -142,20 +62,6 @@ export function ProtocolDeck(props: ProtocolDeckProps): JSX.Element | null {
142
62
protocolAnalysis . liquids ,
143
63
labwareByLiquidId
144
64
) ,
145
- labwareChildren : showLabwareInfo ? (
146
- < LabwareInfo def = { labwareDef } >
147
- { labwareNickName ?? getLabwareDisplayName ( labwareDef ) }
148
- </ LabwareInfo >
149
- ) : null ,
150
- highlight : handleLabwareClick != null ,
151
- highlightShadow : handleLabwareClick != null && isLabwareInStack ,
152
- onLabwareClick :
153
- handleLabwareClick != null && topLabwareDefinition != null
154
- ? ( ) => {
155
- handleLabwareClick ( topLabwareDefinition , topLabwareId )
156
- }
157
- : undefined ,
158
- stacked : handleLabwareClick != null && isLabwareInStack ,
159
65
}
160
66
}
161
67
)
0 commit comments