Skip to content

Commit 1bb995d

Browse files
committed
improve code display
1 parent ae1763a commit 1bb995d

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/components/JobList.jsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ import {
1818
TableRow,
1919
Tooltip,
2020
} from "@mui/material";
21-
import { RestartAlt as RestartIcon } from "@mui/icons-material";
21+
import {
22+
RestartAlt as RestartIcon,
23+
Code as CodeIcon,
24+
GitHub as GitHubIcon,
25+
Archive as ArchiveIcon,
26+
Folder as FolderIcon,
27+
} from "@mui/icons-material";
2228

2329
import StatusChip from "./StatusChip";
2430

@@ -49,6 +55,27 @@ function filterJobs(jobs, statusFilter, hardwareFilter, tagFilter) {
4955
return filteredJobs;
5056
}
5157

58+
function formatCode(code) {
59+
const style = { display: "inline-flex", verticalAlign: "middle", color: "lightgray" };
60+
let icon = <CodeIcon sx={style} />;
61+
if (code.includes("github")) {
62+
icon = <GitHubIcon sx={style} />;
63+
} else if (code.startsWith("http")) {
64+
icon = <ArchiveIcon sx={style} />;
65+
} else if (code.startsWith("collab:")) {
66+
icon = <FolderIcon sx={style} />;
67+
} else if (code.startsWith("drive:")) {
68+
icon = <FolderIcon sx={style} />;
69+
}
70+
71+
return (
72+
<span>
73+
{icon}&nbsp;&nbsp;
74+
<code>{code.trim().slice(0, 60).replaceAll("\n", "⏎")}</code>
75+
</span>
76+
);
77+
}
78+
5279
function LinkedTableCell(props) {
5380
return (
5481
<TableCell align={props.align}>
@@ -196,7 +223,7 @@ function JobList(props) {
196223
{job.hardware_platform}
197224
</LinkedTableCell>
198225
<LinkedTableCell align="left" to={`/${props.collab}/jobs/${job.id}`}>
199-
<code>{job.code.slice(0, 60)}</code>
226+
{formatCode(job.code)}
200227
</LinkedTableCell>
201228
<LinkedTableCell align="left" to={`/${props.collab}/jobs/${job.id}`}>
202229
{timeFormat(job.timestamp_submission)}

0 commit comments

Comments
 (0)