-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathFailureReasonAlert.tsx
More file actions
53 lines (48 loc) · 1.67 KB
/
FailureReasonAlert.tsx
File metadata and controls
53 lines (48 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import type { ReactNode } from "react";
import { Alert } from "../common";
import { vscode } from "../vscode-api";
import { VariantAnalysisFailureReason } from "../../variant-analysis/shared/variant-analysis";
import { Link } from "../common/Link";
type Props = {
failureReason: VariantAnalysisFailureReason;
};
const openLogs = () => {
vscode.postMessage({
t: "openLogs",
});
};
const getTitle = (failureReason: VariantAnalysisFailureReason): string => {
switch (failureReason) {
case VariantAnalysisFailureReason.NoReposQueried:
return "No repositories to analyze";
case VariantAnalysisFailureReason.ActionsWorkflowRunFailed:
return "GitHub Actions workflow run failed";
case VariantAnalysisFailureReason.InternalError:
return "Something unexpected happened";
}
};
const getMessage = (failureReason: VariantAnalysisFailureReason): ReactNode => {
switch (failureReason) {
case VariantAnalysisFailureReason.NoReposQueried:
return "No repositories available after processing. No repositories were analyzed.";
case VariantAnalysisFailureReason.ActionsWorkflowRunFailed:
return (
<>
The GitHub Actions workflow run has failed.{" "}
<Link onClick={openLogs}>View actions logs</Link> and try running this
query again.
</>
);
case VariantAnalysisFailureReason.InternalError:
return "An internal error occurred while running this variant analysis. Please try again later.";
}
};
export const FailureReasonAlert = ({ failureReason }: Props) => {
return (
<Alert
type="error"
title={getTitle(failureReason)}
message={getMessage(failureReason)}
/>
);
};