Skip to content

Commit 0c532f2

Browse files
Preview error log in run history (#130)
--------- Co-authored-by: Ben Sherman <[email protected]>
1 parent db0e4c3 commit 0c532f2

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { useState } from "react";
2+
import clsx from "clsx";
3+
4+
import styles from "./styles.module.css";
5+
6+
const ErrorReport = ({ errorReport }: { errorReport: string }) => {
7+
const [isExpanded, setIsExpanded] = useState(false);
8+
const [copied, setCopied] = useState(false);
9+
10+
if (!errorReport) return null;
11+
12+
const firstLine = errorReport.split("\n")[0];
13+
14+
const handleCopy = (e: React.MouseEvent) => {
15+
e.preventDefault();
16+
e.stopPropagation();
17+
navigator.clipboard.writeText(errorReport);
18+
setCopied(true);
19+
setTimeout(() => setCopied(false), 2000);
20+
};
21+
22+
return (
23+
<div className={styles.errorReport}>
24+
<div
25+
className={styles.errorPreview}
26+
onClick={(e) => {
27+
e.preventDefault();
28+
e.stopPropagation();
29+
setIsExpanded(!isExpanded);
30+
}}
31+
>
32+
<div className={styles.errorContent}>
33+
{isExpanded ? errorReport : `${firstLine}...`}
34+
</div>
35+
<button
36+
className={clsx(
37+
copied ? "codicon codicon-check" : "codicon codicon-copy",
38+
styles.copyButton
39+
)}
40+
onClick={handleCopy}
41+
title={copied ? "Copied!" : "Copy error report"}
42+
></button>
43+
</div>
44+
</div>
45+
);
46+
};
47+
48+
export default ErrorReport;

webview-ui/src/Layout/SeqeraCloud/Workspace/RunHistory/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
getStatusIcon
1010
} from "./utils";
1111
import Button from "../../../../components/Button";
12+
import ErrorReport from "./ErrorReport";
1213
import FilterForProject from "../FilterForProject";
1314

1415
import styles from "./styles.module.css";
@@ -60,6 +61,9 @@ const RunHistory = () => {
6061
{relativeTime(workflow.dateCreated)}
6162
</div>
6263
</div>
64+
{workflow.status === "FAILED" && (
65+
<ErrorReport errorReport={workflow.errorReport} />
66+
)}
6367
</a>
6468
))}
6569
{hasMore && (

webview-ui/src/Layout/SeqeraCloud/Workspace/RunHistory/styles.module.css

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
cursor: pointer;
99
transition: all 0.2s;
1010
min-width: 260px;
11+
outline: none !important;
1112
&:hover {
1213
border-color: var(--vscode-button-background);
1314
color: var(--vscode-button-foreground);
@@ -64,3 +65,47 @@
6465
text-overflow: ellipsis;
6566
}
6667
}
68+
69+
.errorReport {
70+
margin-top: 6px;
71+
font-size: 11px;
72+
}
73+
74+
.errorPreview {
75+
background: var(--vscode-editor-background);
76+
border: 1px solid var(--vscode-panel-border);
77+
border-radius: 4px;
78+
padding: 6px;
79+
cursor: pointer;
80+
white-space: pre-wrap;
81+
word-break: break-word;
82+
color: var(--vscode-errorForeground);
83+
position: relative;
84+
&:hover {
85+
& .copyButton {
86+
opacity: 0.5;
87+
}
88+
}
89+
}
90+
91+
.errorContent {
92+
padding-right: 24px;
93+
}
94+
95+
.copyButton {
96+
position: absolute;
97+
top: 4px;
98+
right: 4px;
99+
background: none;
100+
border: none;
101+
padding: 4px;
102+
cursor: pointer;
103+
color: var(--vscode-button-foreground);
104+
opacity: 0;
105+
transition: opacity 0.2s;
106+
font-size: 12px;
107+
outline: none !important;
108+
&:hover {
109+
opacity: 1;
110+
}
111+
}

0 commit comments

Comments
 (0)