Skip to content

Commit 687bce2

Browse files
committed
fix: top node selection UI is buggy
this also has a few UI tweaks: - trim box title to at most 34 chars - use 0-gap between boxes - improve selection UI for non-selected boxes - try to keep the duration at a fixed length, to avoid reflows, e.g. 15m 9s -> 15m 10s
1 parent 0cafbd6 commit 687bce2

File tree

1 file changed

+12
-12
lines changed
  • plugins/plugin-codeflare-dashboard/src/components/Top

1 file changed

+12
-12
lines changed

Diff for: plugins/plugin-codeflare-dashboard/src/components/Top/index.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ class Top extends React.PureComponent<Props, State> {
189189
return M
190190
}, {} as Record<string, Omit<State["groups"][number], "groupIdx">>)
191191
)
192-
.map((group, groupIdx) => Object.assign(group, { groupIdx }))
193192
.sort(this.sorter)
193+
.map((group, groupIdx) => Object.assign(group, { groupIdx }))
194194
}
195195

196-
private readonly sorter = (a: Group, b: Group) => {
196+
private readonly sorter = (a: Omit<Group, "groupIdx">, b: Omit<Group, "groupIdx">) => {
197197
return (
198198
a.stats.tot.cpu + a.stats.tot.mem + a.stats.tot.gpu - (b.stats.tot.cpu + b.stats.tot.mem + b.stats.tot.gpu) ||
199199
a.job.name.localeCompare(b.job.name)
@@ -314,19 +314,23 @@ class Top extends React.PureComponent<Props, State> {
314314
? {
315315
inverse: true,
316316
}
317-
: {}
317+
: this.hasSelection
318+
? { dimColor: true }
319+
: { bold: true }
318320

319321
return (
320322
<Box key={group.job.name} flexDirection="column" borderStyle={isSelected ? "bold" : "single"}>
321323
<Box>
322324
<Box flexGrow={1}>
323-
<Text bold {...titleStyle}>
324-
{group.job.name}
325-
</Text>
325+
<Text {...titleStyle}>{group.job.name.slice(0, 34) + (group.job.name.length > 34 ? "…" : "")}</Text>
326326
</Box>
327327
<Box justifyContent="flex-end" marginLeft={2}>
328328
<Text color="cyan">
329-
{prettyMillis(Date.now() - group.ctime, { unitCount: 2, secondsDecimalDigits: 0 })}
329+
{
330+
prettyMillis(Date.now() - group.ctime, { unitCount: 2, secondsDecimalDigits: 0 }).padEnd(
331+
7
332+
) /* 'XXm YYs'.length */
333+
}
330334
</Text>
331335
</Box>
332336
</Box>
@@ -352,11 +356,7 @@ class Top extends React.PureComponent<Props, State> {
352356
} else if (this.state.groups.length === 0) {
353357
return <Text>No active jobs</Text>
354358
} else {
355-
return (
356-
<Box flexWrap="wrap" gap={1}>
357-
{this.state.groups.map((_, idx) => this.group(_, idx))}
358-
</Box>
359-
)
359+
return <Box flexWrap="wrap">{this.state.groups.map((_, idx) => this.group(_, idx))}</Box>
360360
}
361361
}
362362
}

0 commit comments

Comments
 (0)