Skip to content

Commit f3e2487

Browse files
authored
fix(app): add virtualization to load a big protocol (#20532)
* fix(app): add virtualization to load a big protocol
1 parent da89a9a commit f3e2487

File tree

10 files changed

+513
-177
lines changed

10 files changed

+513
-177
lines changed

app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"react-select": "5.4.0",
5959
"react-simple-keyboard": "^3.7.0",
6060
"react-viewport-list": "6.3.0",
61+
"react-window": "2.2.4",
6162
"redux": "5.0.1",
6263
"redux-observable": "1.1.0",
6364
"redux-thunk": "3.1.0",

app/src/organisms/Desktop/ProtocolDetails/AnnotatedSteps/AnnotatedGroup.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ export function AnnotatedGroup(props: AnnotatedGroupProps): JSX.Element {
4141
setIsExpanded(subCommands.some(command => command.isHighlighted))
4242
}, [subCommands])
4343

44+
const handleClick = (): void => {
45+
setIsExpanded(!isExpanded)
46+
handlePause?.()
47+
}
48+
4449
return (
4550
<div className={styles.annotated_group_container}>
46-
<div
47-
onClick={() => {
48-
setIsExpanded(!isExpanded)
49-
handlePause?.()
50-
}}
51-
className={styles.annotated_group_header}
52-
>
51+
<div onClick={handleClick} className={styles.annotated_group_header}>
5352
<StyledText desktopStyle="bodyDefaultRegular">
5453
{annotationType}
5554
</StyledText>
5655
<Icon
56+
data-testid={isExpanded ? 'chevron-up' : 'chevron-down'}
5757
name={isExpanded ? 'chevron-up' : 'chevron-down'}
5858
size="2rem"
5959
color={COLORS.black90}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { COLORS, Icon, StyledText } from '@opentrons/components'
2+
3+
import { AnnotatedGroup } from './AnnotatedGroup'
4+
import styles from './annotatedsteps.module.css'
5+
import { IndividualCommand } from './IndividualCommand'
6+
7+
import type { RowComponentProps } from 'react-window'
8+
import type { ItemData } from './index'
9+
10+
export function AnnotatedStepsRowItem(
11+
props: RowComponentProps<ItemData>
12+
): JSX.Element {
13+
const { index, style, ariaAttributes, ...data } = props
14+
const row = data.rows[index]
15+
return (
16+
<div style={style} {...ariaAttributes}>
17+
<div className={styles.annotated_steps_row}>
18+
{row.type === 'group' ? (
19+
<AnnotatedGroup
20+
scrollTargetId={data.scrollTargetId}
21+
analysis={data.analysis}
22+
annotationType={row.annotationType}
23+
subCommands={row.group.subCommands}
24+
commandStartNumber={row.commandStartNumber}
25+
allRunDefs={data.allRunDefs}
26+
setSelectedCommand={data.setSelectedCommand}
27+
handlePause={data.handlePause}
28+
/>
29+
) : row.type === 'command' ? (
30+
<IndividualCommand
31+
scrollTargetId={data.scrollTargetId}
32+
fromGroup={row.fromGroup}
33+
command={row.command}
34+
isHighlighted={row.isHighlighted}
35+
analysis={data.analysis}
36+
allRunDefs={data.allRunDefs}
37+
setSelectedCommand={data.setSelectedCommand}
38+
commandNumber={row.commandNumber}
39+
/>
40+
) : (
41+
<div className={styles.annotated_steps_error_wrapper}>
42+
{row.errors.map(error => (
43+
<div
44+
className={styles.annotated_steps_error_container}
45+
key={error.id}
46+
onClick={() => {
47+
data.onShowErrorDetails()
48+
}}
49+
>
50+
<div className={styles.annotated_steps_header}>
51+
<Icon name="ot-alert" size="1rem" color={COLORS.red60} />
52+
<StyledText
53+
desktopStyle="captionSemiBold"
54+
color={COLORS.red60}
55+
>
56+
{data.t('step_error')}
57+
</StyledText>
58+
</div>
59+
<StyledText desktopStyle="bodyDefaultRegular">
60+
{error.detail}
61+
</StyledText>
62+
</div>
63+
))}
64+
<div className={styles.annotated_steps_final_command}>
65+
<StyledText desktopStyle="bodyDefaultRegular">
66+
{data.t('unable_to_show_steps_past_errors')}
67+
</StyledText>
68+
</div>
69+
</div>
70+
)}
71+
</div>
72+
</div>
73+
)
74+
}

app/src/organisms/Desktop/ProtocolDetails/AnnotatedSteps/annotatedsteps.module.css

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,18 @@
7575
}
7676

7777
.annotated_steps_container {
78-
display: flex;
79-
flex-direction: column;
80-
overflow-y: auto;
78+
width: 100%;
79+
height: 100%;
8180
}
8281

83-
.annotated_steps_container::-webkit-scrollbar {
84-
display: none;
82+
.annotated_steps_list {
83+
width: 100%;
84+
height: 100%;
8585
}
8686

87-
.annotated_steps_wrap {
88-
display: flex;
89-
flex-direction: column;
90-
gap: var(--spacing-4);
87+
.annotated_steps_row {
88+
box-sizing: border-box;
89+
padding-bottom: var(--spacing-4);
9190
}
9291

9392
.annotated_steps_error_wrapper {

0 commit comments

Comments
 (0)