@milabench/bujang 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +16 -0
  2. package/dist/api.d.ts +16 -3
  3. package/dist/components/OrganizerNav.d.ts +28 -0
  4. package/dist/components/ProjectsNav.d.ts +15 -0
  5. package/dist/index.d.ts +10 -2
  6. package/dist/index.js +6132 -5023
  7. package/dist/index.js.map +1 -1
  8. package/dist/paths.d.ts +25 -3
  9. package/dist/routes.d.ts +7 -2
  10. package/dist/types.d.ts +77 -5
  11. package/dist/views/CollectionView.d.ts +22 -0
  12. package/dist/views/JobDataOverview.d.ts +1 -1
  13. package/dist/views/JobsView.d.ts +12 -1
  14. package/dist/views/LogDisplay.d.ts +2 -0
  15. package/dist/views/OrganizerValuesView.d.ts +13 -0
  16. package/dist/views/OverviewPanels.d.ts +13 -2
  17. package/dist/views/ProjectDetailsView.d.ts +3 -0
  18. package/dist/views/ProjectsView.d.ts +18 -0
  19. package/dist/views/dataCharts.d.ts +1 -1
  20. package/package.json +1 -1
  21. package/src/api.ts +36 -6
  22. package/src/components/OrganizerNav.tsx +121 -0
  23. package/src/components/ProjectsNav.tsx +101 -0
  24. package/src/index.ts +10 -2
  25. package/src/paths.ts +47 -6
  26. package/src/routes.tsx +19 -4
  27. package/src/types.ts +77 -6
  28. package/src/views/CollectionView.tsx +68 -0
  29. package/src/views/JanitorView.tsx +2 -1
  30. package/src/views/JobDataOverview.tsx +23 -6
  31. package/src/views/JobLogs.tsx +2 -1
  32. package/src/views/JobSubmit.tsx +68 -0
  33. package/src/views/JobsTable.tsx +44 -6
  34. package/src/views/JobsView.tsx +26 -9
  35. package/src/views/LogDisplay.tsx +5 -2
  36. package/src/views/OrganizerValuesView.tsx +207 -0
  37. package/src/views/OverviewPanels.tsx +531 -7
  38. package/src/views/ProjectDetailsView.tsx +112 -0
  39. package/src/views/ProjectsView.tsx +117 -8
  40. package/src/views/SetupView.tsx +39 -1
  41. package/src/views/dataCharts.tsx +1 -1
@@ -15,6 +15,8 @@ import {
15
15
  Card,
16
16
  Spinner,
17
17
  Icon,
18
+ Dialog,
19
+ Code,
18
20
  } from '@chakra-ui/react';
19
21
  import { LuCheck, LuX, LuLock, LuCalendar, LuPaperclip, LuChevronDown, LuChevronUp, LuBookOpen, LuWorkflow } from 'react-icons/lu';
20
22
  import { toaster } from '../toast';
@@ -338,6 +340,9 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
338
340
  // Sweep dialog: the arguments of the form when it was opened (null: closed)
339
341
  const [sweepArgs, setSweepArgs] = useState<Record<string, string> | null>(null);
340
342
 
343
+ // Script arguments edited but not applied to the script when Submit was clicked (null: no question)
344
+ const [unappliedArgs, setUnappliedArgs] = useState<string[] | null>(null);
345
+
341
346
  // Schedule dialog (name and cron expression)
342
347
  const [scheduleOpen, setScheduleOpen] = useState(false);
343
348
 
@@ -522,6 +527,9 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
522
527
 
523
528
  const handleTemplateSelect = (templateName: string) => {
524
529
  setSelectedTemplate(templateName);
530
+ // a script of a project ("<project>:<name>"): the job goes with that project
531
+ const owner = templateName.includes(':') ? templateName.split(':')[0] : '';
532
+ if (owner && projectNames.includes(owner)) setProject(owner);
525
533
  if (templateName && templates?.includes(templateName)) {
526
534
  loadTemplateMutation.mutate(templateName);
527
535
  }
@@ -655,7 +663,25 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
655
663
  return result;
656
664
  };
657
665
 
666
+ // the script arguments whose input differs from the value the script exports: only the script is
667
+ // submitted, so these edits would be lost
668
+ const _unappliedScriptArgs = (): string[] => {
669
+ const inScript = parseExportVariables(editorRef.current?.getValue() || '', true);
670
+ return Object.entries(_collectScriptArgs())
671
+ .filter(([name, value]) => name in inScript && inScript[name] !== value)
672
+ .map(([name]) => name);
673
+ };
674
+
658
675
  const handleSubmitJob = async () => {
676
+ const unapplied = _unappliedScriptArgs();
677
+ if (unapplied.length > 0) {
678
+ setUnappliedArgs(unapplied);
679
+ return;
680
+ }
681
+ await doSubmitJob();
682
+ };
683
+
684
+ const doSubmitJob = async () => {
659
685
  let files;
660
686
  try {
661
687
  files = attachments.length
@@ -1479,6 +1505,48 @@ export const JobSubmissionForm: React.FC<JobSubmissionFormProps> = ({
1479
1505
  ensureConnected={sshGate.ensure}
1480
1506
  />
1481
1507
  )}
1508
+ {unappliedArgs && (
1509
+ <Dialog.Root open onOpenChange={(details) => { if (!details.open) setUnappliedArgs(null); }} size="sm">
1510
+ <Dialog.Backdrop />
1511
+ <Dialog.Positioner>
1512
+ <Dialog.Content className="bujang-dialog">
1513
+ <Dialog.Header py={3} px={4} borderBottom="1px solid" borderColor="var(--color-border)">
1514
+ <Dialog.Title fontSize="md" color="var(--color-text)">Apply the script arguments?</Dialog.Title>
1515
+ </Dialog.Header>
1516
+ <Dialog.Body px={4} py={4}>
1517
+ <VStack align="stretch" gap={2}>
1518
+ <Text fontSize="sm" color="var(--color-text)">
1519
+ These arguments were changed but not applied to the script: the job runs the
1520
+ script as it is in the editor.
1521
+ </Text>
1522
+ <HStack gap={2} wrap="wrap">
1523
+ {unappliedArgs.map(name => <Code key={name} fontSize="xs">{name}</Code>)}
1524
+ </HStack>
1525
+ </VStack>
1526
+ </Dialog.Body>
1527
+ <Dialog.Footer px={4} py={3} borderTop="1px solid" borderColor="var(--color-border)" gap={2}>
1528
+ <Button size="sm" variant="ghost" onClick={() => setUnappliedArgs(null)}>Cancel</Button>
1529
+ <Button
1530
+ size="sm"
1531
+ variant="outline"
1532
+ onClick={() => { setUnappliedArgs(null); void doSubmitJob(); }}
1533
+ >
1534
+ Submit without them
1535
+ </Button>
1536
+ <Button
1537
+ size="sm"
1538
+ bg="var(--color-primary)"
1539
+ color="var(--color-primary-text)"
1540
+ _hover={{ bg: 'var(--color-primary-hover)' }}
1541
+ onClick={() => { applyScriptArgs(); setUnappliedArgs(null); void doSubmitJob(); }}
1542
+ >
1543
+ Apply and submit
1544
+ </Button>
1545
+ </Dialog.Footer>
1546
+ </Dialog.Content>
1547
+ </Dialog.Positioner>
1548
+ </Dialog.Root>
1549
+ )}
1482
1550
  {sshGate.dialog}
1483
1551
  </Box>
1484
1552
  );
@@ -245,11 +245,26 @@ interface Column {
245
245
  label: string;
246
246
  /** 'values': tick any of the values in the rows; 'text': a substring */
247
247
  filter: 'text' | 'values' | null;
248
+ /** 'values' filter: a fixed list of choices, in this order, shown even when no row has them */
249
+ choices?: string[];
248
250
  /** what the filter looks at */
249
251
  text: (r: JobRow) => string;
250
252
  sort: (r: JobRow) => string | number | null;
251
253
  }
252
254
 
255
+ /**
256
+ * every state a job can show: slurm's job states (squeue/sacct), plus HELD (a PENDING job on hold),
257
+ * the most common first so they are found without scrolling
258
+ */
259
+ const JOB_STATES = [
260
+ // common
261
+ 'RUNNING', 'PENDING', 'COMPLETED', 'FAILED', 'CANCELLED', 'TIMEOUT', 'HELD', 'OUT_OF_MEMORY',
262
+ // occasional
263
+ 'COMPLETING', 'CONFIGURING', 'PREEMPTED', 'NODE_FAIL', 'REQUEUED', 'SUSPENDED',
264
+ // rare
265
+ 'BOOT_FAIL', 'DEADLINE', 'STOPPED', 'SIGNALING', 'STAGE_OUT', 'RESIZING', 'REVOKED', 'SPECIAL_EXIT',
266
+ ];
267
+
253
268
  const COLUMNS: Column[] = [
254
269
  { id: 'jobId', label: 'Job ID', filter: 'text', text: (r) => r.jobId, sort: (r) => (Number.isFinite(+r.jobId) ? +r.jobId : r.jobId) },
255
270
  { id: 'jrJobId', label: 'JR Job ID', filter: 'text', text: (r) => r.jrJobId ?? '', sort: (r) => r.jrJobId },
@@ -268,7 +283,14 @@ const COLUMNS: Column[] = [
268
283
  // the jobs outside a pipeline last
269
284
  sort: (r) => r.pipeline?.run_id ?? null,
270
285
  },
271
- { id: 'status', label: 'Status', filter: 'values', text: (r) => r.status, sort: (r) => r.status },
286
+ {
287
+ id: 'status',
288
+ label: 'Status',
289
+ filter: 'values',
290
+ choices: JOB_STATES,
291
+ text: (r) => r.status,
292
+ sort: (r) => r.status,
293
+ },
272
294
  { id: 'cluster', label: 'Cluster', filter: 'values', text: (r) => r.cluster, sort: (r) => r.cluster },
273
295
  { id: 'partition', label: 'Partition', filter: 'values', text: (r) => r.partition, sort: (r) => r.partition },
274
296
  { id: 'user', label: 'User', filter: 'text', text: (r) => r.user, sort: (r) => r.user },
@@ -454,10 +476,16 @@ export const JobsTable: React.FC<JobsTableProps & { cardProps?: React.ComponentP
454
476
  const options = React.useMemo(() => {
455
477
  const out: Partial<Record<ColumnId, string[]>> = {};
456
478
  for (const c of COLUMNS) {
457
- if (c.filter === 'values') out[c.id] = [...new Set(rows.map(c.text))].sort(compare);
479
+ if (c.filter !== 'values') continue;
480
+ // the ticked values too: a filter from the URL that matches no row can still be unticked
481
+ const ticked = filters[c.id];
482
+ const seen = [...new Set([...rows.map(c.text), ...(Array.isArray(ticked) ? ticked : [])])];
483
+ const fixed = c.choices ?? [];
484
+ // a value outside the fixed list (a state slurm added, '-') still shows, after it
485
+ out[c.id] = [...fixed, ...seen.filter((v) => !fixed.includes(v)).sort(compare)];
458
486
  }
459
487
  return out;
460
- }, [rows]);
488
+ }, [rows, filters]);
461
489
 
462
490
  const shown = React.useMemo(() => {
463
491
  const active = COLUMNS.filter((c) => isSet(filters[c.id]));
@@ -671,14 +699,24 @@ const JobRowView: React.FC<{
671
699
  />
672
700
  </Tooltip>
673
701
  )}
702
+ {/* the slot is kept without an agent: the job ids stay aligned */}
703
+ <Box as="span" display="inline-flex" w="1em" flexShrink={0}>
704
+ <AgentBadge tag={row.agent} />
705
+ </Box>
674
706
  <Text fontWeight="semibold" color="var(--color-text)">
675
707
  {row.jobId}
676
708
  </Text>
677
- <AgentBadge tag={row.agent} />
678
709
  </HStack>
679
710
  </Table.Cell>
680
- <Table.Cell>
681
- <Text fontFamily="mono" fontSize="sm" color="var(--color-text-muted)">
711
+ {/* the id shrinks with the window, then is clipped (the full id in the tooltip) */}
712
+ <Table.Cell maxW="clamp(6ch, 14vw, 36ch)">
713
+ <Text
714
+ fontFamily="mono"
715
+ fontSize="clamp(0.65rem, 0.8vw, 0.875rem)"
716
+ color="var(--color-text-muted)"
717
+ truncate
718
+ title={row.jrJobId ?? undefined}
719
+ >
682
720
  {row.jrJobId}
683
721
  </Text>
684
722
  </Table.Cell>
@@ -31,7 +31,18 @@ import { SshConnectButton } from '../components/SshConnectDialog';
31
31
  import { JobsTable, fromActive, fromPersisted, mergeRows } from './JobsTable';
32
32
  import { SETTINGS_KEY } from './SettingsView';
33
33
 
34
- type JobsViewProps = Record<string, never>;
34
+ interface JobsViewProps {
35
+ /** organizer filters always applied, not shown in the filter bar ({ projects: 'my-repo' }) */
36
+ filters?: Record<string, string>;
37
+ /** the heading (default "Jobs") */
38
+ title?: React.ReactNode;
39
+ /** the browser tab title (default "Jobs") */
40
+ pageTitle?: string;
41
+ /** shown under the heading */
42
+ header?: React.ReactNode;
43
+ /** where "Submit New Job" goes (default the Submit page) */
44
+ submitPath?: string;
45
+ }
35
46
 
36
47
  const AUTO_REFRESH_KEY = 'bujang-jobs-auto-refresh';
37
48
  const AUTO_REFRESH_MS = 30_000;
@@ -103,8 +114,8 @@ const OrganizerFilters: React.FC<{
103
114
  );
104
115
  };
105
116
 
106
- export const JobsView: React.FC<JobsViewProps> = () => {
107
- usePageTitle('Jobs');
117
+ export const JobsView: React.FC<JobsViewProps> = ({ filters, title, pageTitle, header, submitPath }) => {
118
+ usePageTitle(pageTitle ?? 'Jobs');
108
119
 
109
120
  const queryClient = useQueryClient();
110
121
  const navigate = useNavigate();
@@ -181,7 +192,12 @@ export const JobsView: React.FC<JobsViewProps> = () => {
181
192
 
182
193
  // ?clusters=mila&experiments=lr-sweep: the jobs under every chosen value
183
194
  const [params, setParams] = useSearchParams();
184
- const organizerNames = React.useMemo(() => organizers.map((o) => o.name), [organizers]);
195
+ // the fixed filters are not offered in the filter bar
196
+ const shownOrganizers = React.useMemo(
197
+ () => organizers.filter((o) => !filters?.[o.name]),
198
+ [organizers, filters],
199
+ );
200
+ const organizerNames = React.useMemo(() => shownOrganizers.map((o) => o.name), [shownOrganizers]);
185
201
  const selected = React.useMemo(() => {
186
202
  const out: Record<string, string> = {};
187
203
  for (const name of organizerNames) {
@@ -191,14 +207,14 @@ export const JobsView: React.FC<JobsViewProps> = () => {
191
207
  return out;
192
208
  }, [params, organizerNames]);
193
209
  const allowed = React.useMemo(() => {
194
- const sets = Object.entries(selected).map(([name, value]) => {
210
+ const sets = Object.entries({ ...selected, ...filters }).map(([name, value]) => {
195
211
  const group = organizers.find((o) => o.name === name)?.groups.find((g) => g.value === value);
196
212
  return new Set<string>(group?.jobs ?? []);
197
213
  });
198
214
  if (sets.length === 0) return null;
199
215
  const [first, ...rest] = sets;
200
216
  return new Set<string>([...first].filter((id) => rest.every((set) => set.has(id))));
201
- }, [selected, organizers]);
217
+ }, [selected, filters, organizers]);
202
218
  const setFilter = (name: string, value: string) => {
203
219
  const next = new URLSearchParams(params);
204
220
  if (value) next.set(name, value);
@@ -331,7 +347,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
331
347
  >
332
348
  <LuStar fill={importantOnly ? 'currentColor' : 'none'} /> Important
333
349
  </Button>
334
- <OrganizerFilters organizers={organizers} selected={selected} onChange={setFilter} onClear={clearFilters} />
350
+ <OrganizerFilters organizers={shownOrganizers} selected={selected} onChange={setFilter} onClear={clearFilters} />
335
351
  </>
336
352
  );
337
353
 
@@ -346,14 +362,14 @@ export const JobsView: React.FC<JobsViewProps> = () => {
346
362
  <HStack justify="space-between" align="center">
347
363
  <HStack gap={3} align="center">
348
364
  <Heading size="xl" fontWeight="bold" color="var(--color-text)">
349
- Jobs
365
+ {title ?? 'Jobs'}
350
366
  </Heading>
351
367
  <SshConnectButton />
352
368
  </HStack>
353
369
 
354
370
  <HStack gap={3}>
355
371
  <Button
356
- onClick={() => navigate(paths.submitJob())}
372
+ onClick={() => navigate(submitPath ?? paths.submitJob())}
357
373
  size="sm"
358
374
  fontWeight="medium"
359
375
  bg="var(--color-primary)"
@@ -418,6 +434,7 @@ export const JobsView: React.FC<JobsViewProps> = () => {
418
434
  </HStack>
419
435
  </HStack>
420
436
  </Box>
437
+ {header}
421
438
 
422
439
 
423
440
  {merged ? (
@@ -19,6 +19,8 @@ interface LogDisplayProps {
19
19
  formatFileSize: (bytes: number) => string;
20
20
  fetchLogData: (jrJobId: string, start?: number, end?: number) => Promise<string>;
21
21
  getSlurmJobLogSize: (jrJobId: string) => Promise<number>;
22
+ /** Milliseconds between two refreshes while the job runs */
23
+ refreshInterval?: number;
22
24
  }
23
25
 
24
26
  export const LogDisplay: React.FC<LogDisplayProps> = ({
@@ -27,7 +29,8 @@ export const LogDisplay: React.FC<LogDisplayProps> = ({
27
29
  isJobFinished,
28
30
  formatFileSize,
29
31
  fetchLogData,
30
- getSlurmJobLogSize
32
+ getSlurmJobLogSize,
33
+ refreshInterval = 30000,
31
34
  }) => {
32
35
  // Internal state for truncation and log size
33
36
  const [isTruncated, setIsTruncated] = useState(false);
@@ -73,7 +76,7 @@ export const LogDisplay: React.FC<LogDisplayProps> = ({
73
76
  queryKey: [`slurm-job-${logType}-full`, jrJobId],
74
77
  queryFn: () => loadLogsChunked(jrJobId),
75
78
  enabled: !!jrJobId,
76
- refetchInterval: isJobFinished ? false : 30000, // Disable refresh if job is finished
79
+ refetchInterval: isJobFinished ? false : refreshInterval, // Disable refresh if job is finished
77
80
  refetchIntervalInBackground: true,
78
81
  });
79
82
 
@@ -0,0 +1,207 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Link, useParams, useSearchParams } from 'react-router-dom';
3
+ import { Box, Button, Heading, HStack, Input, NativeSelect, Spinner, Table, Text } from '@chakra-ui/react';
4
+ import { keepPreviousData, useQuery } from '@tanstack/react-query';
5
+ import { LuChevronLeft, LuChevronRight, LuSearch } from 'react-icons/lu';
6
+ import { getOrganizerValues } from '../api';
7
+ import type { ApiError, OrganizerValuesPage } from '../types';
8
+ import { ORGANIZER_PAGES } from '../components/OrganizerNav';
9
+ import { useBujangPaths } from '../context';
10
+ import { usePageTitle } from '../hooks/usePageTitle';
11
+ import { JobsView } from './JobsView';
12
+ import { CollectionOverview, CollectionTabs, useCollectionTab } from './CollectionView';
13
+
14
+ const PAGE_SIZES = [25, 50, 100];
15
+ type Sort = 'last' | 'name' | 'jobs';
16
+
17
+ const inputStyle = {
18
+ bg: 'var(--color-input-bg)',
19
+ borderColor: 'var(--color-input-border)',
20
+ color: 'var(--color-text)',
21
+ } as const;
22
+
23
+ const when = (ts: number | null) => (ts ? new Date(ts * 1000).toLocaleString() : '—');
24
+
25
+ function ago(ts: number | null): string {
26
+ if (!ts) return '—';
27
+ const s = Date.now() / 1000 - ts;
28
+ if (s < 60) return 'just now';
29
+ if (s < 3600) return `${Math.round(s / 60)} min ago`;
30
+ if (s < 86400) return `${Math.round(s / 3600)} h ago`;
31
+ return `${Math.round(s / 86400)} d ago`;
32
+ }
33
+
34
+ /** The value typed, given to the query a moment after the last key */
35
+ function useDebounced<T>(value: T, ms = 250): T {
36
+ const [out, setOut] = useState(value);
37
+ useEffect(() => {
38
+ const timer = window.setTimeout(() => setOut(value), ms);
39
+ return () => window.clearTimeout(timer);
40
+ }, [value, ms]);
41
+ return out;
42
+ }
43
+
44
+ /**
45
+ * Every experiment (or group): a table with their job count and last activity, searched by name and
46
+ * paginated on the server. The search, sort, page and page size are in the URL.
47
+ */
48
+ export const OrganizerValuesView: React.FC<{ organizer: keyof typeof ORGANIZER_PAGES }> = ({ organizer }) => {
49
+ const page = ORGANIZER_PAGES[organizer];
50
+ usePageTitle(page.label);
51
+ const paths = useBujangPaths();
52
+ const [params, setParams] = useSearchParams();
53
+ const [search, setSearch] = useState(params.get('q') ?? '');
54
+ const query = useDebounced(search.trim());
55
+ const sort = (['last', 'name', 'jobs'].includes(params.get('sort') ?? '') ? params.get('sort') : 'last') as Sort;
56
+ const size = PAGE_SIZES.includes(Number(params.get('size'))) ? Number(params.get('size')) : PAGE_SIZES[0];
57
+ const index = Math.max(0, Number(params.get('page')) || 0);
58
+
59
+ const update = (changes: Record<string, string | null>) => {
60
+ const next = new URLSearchParams(params);
61
+ for (const [k, v] of Object.entries(changes)) {
62
+ if (v === null || v === '') next.delete(k);
63
+ else next.set(k, v);
64
+ }
65
+ setParams(next, { replace: true });
66
+ };
67
+ // a new search starts on the first page
68
+ useEffect(() => {
69
+ if ((params.get('q') ?? '') !== query) update({ q: query, page: null });
70
+ // eslint-disable-next-line react-hooks/exhaustive-deps
71
+ }, [query]);
72
+
73
+ const { data, isLoading, isFetching, error } = useQuery<OrganizerValuesPage>({
74
+ queryKey: ['bujang-organizer-values', organizer, query, sort, index, size],
75
+ queryFn: () => getOrganizerValues(organizer, { search: query, sort, offset: index * size, limit: size }),
76
+ placeholderData: keepPreviousData,
77
+ staleTime: 15_000,
78
+ });
79
+ const total = data?.total ?? 0;
80
+ const pages = Math.max(1, Math.ceil(total / size));
81
+ const Icon = page.icon;
82
+
83
+ const header = (key: Sort, label: string, align?: 'end') => (
84
+ <Table.ColumnHeader textAlign={align} color="var(--color-text-muted)">
85
+ <Button size="xs" variant="ghost" px={1} fontWeight={sort === key ? 'bold' : 'semibold'}
86
+ color={sort === key ? 'var(--color-primary)' : 'var(--color-text-muted)'}
87
+ onClick={() => update({ sort: key === 'last' ? null : key, page: null })}>
88
+ {label}
89
+ </Button>
90
+ </Table.ColumnHeader>
91
+ );
92
+
93
+ return (
94
+ <Box p={6} maxW="1200px">
95
+ <HStack mb={2} gap={3} color="var(--color-text)">
96
+ <Icon size={24} />
97
+ <Heading size="lg">{page.label}</Heading>
98
+ {isFetching && <Spinner size="sm" />}
99
+ </HStack>
100
+ <Text mb={4} color="var(--color-text-muted)">
101
+ Every {page.singular} with its jobs and when they last changed. Open one to see its jobs.
102
+ </Text>
103
+ <HStack mb={3} gap={3} wrap="wrap">
104
+ <HStack flex="1" minW="240px" maxW="420px" gap={2}>
105
+ <LuSearch color="var(--color-text-muted)" />
106
+ <Input {...inputStyle} size="sm" placeholder={`Search the ${page.label.toLowerCase()}`} value={search}
107
+ onChange={(e) => setSearch(e.target.value)} aria-label={`Search the ${page.label.toLowerCase()}`} />
108
+ </HStack>
109
+ <Text fontSize="sm" color="var(--color-text-muted)">
110
+ {total} {total === 1 ? page.singular : page.label.toLowerCase()}
111
+ </Text>
112
+ </HStack>
113
+ {isLoading && <Spinner />}
114
+ {error && <Text color="var(--color-status-failed)">{(error as unknown as ApiError).message || String(error)}</Text>}
115
+ {data && (
116
+ <Box borderWidth="1px" borderColor="var(--color-border)" borderRadius="md" bg="var(--color-bg-card)" overflowX="auto">
117
+ <Table.Root size="sm">
118
+ <Table.Header>
119
+ <Table.Row bg="transparent">
120
+ {header('name', 'Name')}
121
+ {header('jobs', 'Jobs', 'end')}
122
+ {header('last', 'Last activity')}
123
+ <Table.ColumnHeader color="var(--color-text-muted)">First job</Table.ColumnHeader>
124
+ </Table.Row>
125
+ </Table.Header>
126
+ <Table.Body>
127
+ {data.values.length === 0 && (
128
+ <Table.Row bg="transparent">
129
+ <Table.Cell colSpan={4} color="var(--color-text-muted)" fontStyle="italic">
130
+ {query ? `No ${page.singular} matches "${query}".` : `No ${page.singular} yet.`}
131
+ </Table.Cell>
132
+ </Table.Row>
133
+ )}
134
+ {data.values.map((v) => (
135
+ <Table.Row key={v.value} bg="transparent" _hover={{ bg: 'var(--color-bg-hover)' }}>
136
+ <Table.Cell>
137
+ <Link to={page.detail(paths, v.value)}>
138
+ <Text color="var(--color-text)" fontWeight="medium" _hover={{ textDecoration: 'underline' }}>{v.value}</Text>
139
+ </Link>
140
+ </Table.Cell>
141
+ <Table.Cell textAlign="end" color="var(--color-text)">{v.jobs}</Table.Cell>
142
+ <Table.Cell color="var(--color-text)" title={when(v.last)}>{ago(v.last)}</Table.Cell>
143
+ <Table.Cell color="var(--color-text-muted)">{when(v.first)}</Table.Cell>
144
+ </Table.Row>
145
+ ))}
146
+ </Table.Body>
147
+ </Table.Root>
148
+ </Box>
149
+ )}
150
+ {data && total > 0 && (
151
+ <HStack mt={3} gap={2} justify="flex-end" wrap="wrap" color="var(--color-text-muted)" fontSize="sm">
152
+ <Text>rows</Text>
153
+ <NativeSelect.Root size="xs" w="70px">
154
+ <NativeSelect.Field {...inputStyle} value={size} onChange={(e) => update({ size: e.target.value, page: null })}>
155
+ {PAGE_SIZES.map((n) => <option key={n} value={n}>{n}</option>)}
156
+ </NativeSelect.Field>
157
+ <NativeSelect.Indicator />
158
+ </NativeSelect.Root>
159
+ <Text>
160
+ {index * size + 1}–{Math.min(total, (index + 1) * size)} of {total}
161
+ </Text>
162
+ <Button size="xs" variant="ghost" aria-label="Previous page" disabled={index === 0}
163
+ onClick={() => update({ page: index - 1 ? String(index - 1) : null })}>
164
+ <LuChevronLeft />
165
+ </Button>
166
+ <Text>page {index + 1} / {pages}</Text>
167
+ <Button size="xs" variant="ghost" aria-label="Next page" disabled={index + 1 >= pages}
168
+ onClick={() => update({ page: String(index + 1) })}>
169
+ <LuChevronRight />
170
+ </Button>
171
+ </HStack>
172
+ )}
173
+ </Box>
174
+ );
175
+ };
176
+
177
+ /** One experiment (or group): its jobs (the jobs page filtered on it), or their Overview (compared) */
178
+ export const OrganizerValueView: React.FC<{ organizer: keyof typeof ORGANIZER_PAGES }> = ({ organizer }) => {
179
+ const { value = '' } = useParams();
180
+ const page = ORGANIZER_PAGES[organizer];
181
+ const paths = useBujangPaths();
182
+ const [tab, setTab] = useCollectionTab();
183
+ const Icon = page.icon;
184
+ const title = <HStack gap={2} as="span"><Icon /> {value}</HStack>;
185
+ const header = (
186
+ <HStack mt={-3} gap={4} wrap="wrap">
187
+ <CollectionTabs tab={tab} onTab={setTab} />
188
+ <Link to={page.list(paths)}>
189
+ <Text fontSize="sm" color="var(--color-text-muted)" _hover={{ textDecoration: 'underline' }}>
190
+ ← every {page.singular}
191
+ </Text>
192
+ </Link>
193
+ </HStack>
194
+ );
195
+ if (tab === 'overview') {
196
+ return <CollectionOverview organizer={organizer} value={value} title={title} pageTitle={value} header={header} />;
197
+ }
198
+ return (
199
+ <JobsView
200
+ key={`${organizer}:${value}`}
201
+ filters={{ [organizer]: value }}
202
+ pageTitle={value}
203
+ title={title}
204
+ header={header}
205
+ />
206
+ );
207
+ };