Skip to content

Commit 0754dab

Browse files
committed
feat: group jobs by their versions
1 parent 5696537 commit 0754dab

File tree

6 files changed

+101
-61
lines changed

6 files changed

+101
-61
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"@rjsf/utils": "5.24.10",
5353
"@rjsf/validator-ajv8": "5.24.10",
5454
"@sentry/nextjs": "8.55.0",
55-
"@squonk/account-server-client": "4.2.0-rc.8",
56-
"@squonk/data-manager-client": "4.0.0-rc.1",
55+
"@squonk/account-server-client": "4.2.1",
56+
"@squonk/data-manager-client": "4.1.0",
5757
"@squonk/mui-theme": "5.0.0",
5858
"@squonk/sdf-parser": "1.3.1",
5959
"@tanstack/match-sorter-utils": "8.19.4",
@@ -67,6 +67,7 @@
6767
"@types/prismjs": "1.26.5",
6868
"@types/react": "19.1.4",
6969
"@types/react-plotly.js": "2.6.3",
70+
"@types/semver": "^7.7.0",
7071
"axios": "1.9.0",
7172
"dayjs": "1.11.13",
7273
"filesize": "10.1.6",
@@ -93,6 +94,7 @@
9394
"react-dropzone": "14.3.8",
9495
"react-plotly.js": "2.6.0",
9596
"react-use-websocket": "4.13.0",
97+
"semver": "^7.7.2",
9698
"sharp": "0.34.1",
9799
"typescript": "5.8.3",
98100
"use-immer": "0.11.0",

pnpm-lock.yaml

Lines changed: 41 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/BaseCard.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,13 @@ export const BaseCard = ({
8686
/>
8787
)}
8888
<CardContent>{children}</CardContent>
89-
<CardActions disableSpacing sx={{ justifyContent: "right" }}>
89+
<CardActions disableSpacing sx={{ justifyContent: "right", display: "flex", alignItems: "flex-start", gap: 1 }}>
9090
{/* ? should this be a functionCall() or a <ReactElement />
9191
or should this be separate props with a union and one a never type */}
9292
{typeof actions === "function" ? actions({ setExpanded }) : actions}
9393
{collapsed !== undefined && (
9494
<IconButton
9595
aria-expanded={expanded}
96-
size="large"
9796
sx={(theme) => ({
9897
marginLeft: "auto",
9998
transform: `rotate(${expanded ? 180 : 0}deg)`,

src/components/runCards/JobCard/JobCard.tsx

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
1+
import { useState } from "react";
2+
13
import { type JobSummary } from "@squonk/data-manager-client";
24

3-
import { Alert, Chip, LinearProgress, Link, Typography } from "@mui/material";
5+
import { Alert, Chip, LinearProgress, Link, MenuItem, TextField, Typography } from "@mui/material";
46
import dynamic from "next/dynamic";
7+
import semver from "semver";
58

69
import { BaseCard } from "../../BaseCard";
710
import { Chips } from "../../Chips";
811
import { type InstancesListProps } from "../InstancesList";
912
import { RunJobButton, type RunJobButtonProps } from "./RunJobButton";
1013

14+
const compareJobs = (a: JobSummary, b: JobSummary) => {
15+
return -semver.compare(a.version, b.version);
16+
};
17+
18+
1119
const InstancesList = dynamic<InstancesListProps>(
1220
() => import("../InstancesList").then((mod) => mod.InstancesList),
1321
{ loading: () => <LinearProgress /> },
1422
);
1523

1624
export interface ApplicationCardProps extends Pick<RunJobButtonProps, "projectId"> {
1725
/**
18-
* the job to be instantiated
26+
* the list of jobs (different versions) to be instantiated
1927
*/
20-
job: JobSummary;
28+
job: JobSummary[];
2129
/**
2230
* Whether to disable the button
2331
*/
@@ -28,16 +36,37 @@ export interface ApplicationCardProps extends Pick<RunJobButtonProps, "projectId
2836
* MuiCard that displays a summary of a job with actions to create new instances and view
2937
* existing instances.
3038
*/
31-
export const JobCard = ({ projectId, job, disabled = false }: ApplicationCardProps) => {
39+
export const JobCard = ({ projectId, job: jobs, disabled = false }: ApplicationCardProps) => {
40+
jobs.sort(compareJobs);
41+
const [selectedJobId, setSelectedJobId] = useState(jobs[0]?.id || "");
42+
const job = jobs.find(j => j.id === selectedJobId) as JobSummary;
43+
3244
return (
3345
<BaseCard
3446
actions={({ setExpanded }) => (
35-
<RunJobButton
36-
disabled={job.disabled || disabled}
37-
jobId={job.id}
38-
projectId={projectId}
39-
onLaunch={() => setExpanded(true)}
40-
/>
47+
<>
48+
<TextField
49+
select
50+
disabled={jobs.length === 1}
51+
label="Version"
52+
size="small"
53+
sx={{ minWidth: 120 }}
54+
value={selectedJobId}
55+
onChange={(e) => setSelectedJobId(e.target.value)}
56+
>
57+
{jobs.map((jobVersion) => (
58+
<MenuItem key={jobVersion.id} value={jobVersion.id}>
59+
{jobVersion.version}
60+
</MenuItem>
61+
))}
62+
</TextField>
63+
<RunJobButton
64+
disabled={job.disabled || disabled}
65+
jobId={job.id}
66+
projectId={projectId}
67+
onLaunch={() => setExpanded(true)}
68+
/>
69+
</>
4170
)}
4271
collapsed={
4372
<InstancesList

src/components/runCards/TestJob/TestJobCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const TestJobCard = () => {
2626
<Grid key={job.id} size={{ md: 3, sm: 6, xs: 12 }}>
2727
<JobCard
2828
disabled={!hasPermission}
29-
job={job as JobSummary} // assertion needed as JSON loader doesn't use string literal types
29+
job={[job] as JobSummary[]} // assertion needed as JSON loader doesn't use string literal types
3030
projectId={currentProject?.project_id}
3131
/>
3232
</Grid>

0 commit comments

Comments
 (0)