Add alert message for failed Actions workflow
This also changes the failure reason alert component to remove the logs button since it's not used by any failure reason. Instead, a link is added into the message for a failed Actions workflow using which the Actions workflow run may be opened.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import React from 'react';
|
||||
|
||||
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
||||
import { VariantAnalysisFailureReason } from '../../remote-queries/shared/variant-analysis';
|
||||
import { FailureReasonAlert } from '../../view/variant-analysis/FailureReasonAlert';
|
||||
|
||||
export default {
|
||||
title: 'Variant Analysis/Failure reason alert',
|
||||
component: FailureReasonAlert,
|
||||
} as ComponentMeta<typeof FailureReasonAlert>;
|
||||
|
||||
const Template: ComponentStory<typeof FailureReasonAlert> = (args) => (
|
||||
<FailureReasonAlert {...args} />
|
||||
);
|
||||
|
||||
export const NoReposQueried = Template.bind({});
|
||||
NoReposQueried.args = {
|
||||
failureReason: VariantAnalysisFailureReason.NoReposQueried,
|
||||
};
|
||||
|
||||
export const ActionsWorkflowRunFailed = Template.bind({});
|
||||
ActionsWorkflowRunFailed.args = {
|
||||
failureReason: VariantAnalysisFailureReason.ActionsWorkflowRunFailed,
|
||||
};
|
||||
|
||||
export const InternalError = Template.bind({});
|
||||
InternalError.args = {
|
||||
failureReason: VariantAnalysisFailureReason.InternalError,
|
||||
};
|
||||
@@ -1,30 +1,12 @@
|
||||
import * as React from 'react';
|
||||
import { VSCodeButton } from '@vscode/webview-ui-toolkit/react';
|
||||
import { ReactNode } from 'react';
|
||||
import { VSCodeLink } from '@vscode/webview-ui-toolkit/react';
|
||||
import { Alert } from '../common';
|
||||
import { vscode } from '../vscode-api';
|
||||
import { VariantAnalysisFailureReason } from '../../remote-queries/shared/variant-analysis';
|
||||
|
||||
type Props = {
|
||||
failureReason: VariantAnalysisFailureReason;
|
||||
showLogsButton: boolean;
|
||||
};
|
||||
|
||||
const getTitle = (failureReason: VariantAnalysisFailureReason): string => {
|
||||
switch (failureReason) {
|
||||
case VariantAnalysisFailureReason.NoReposQueried:
|
||||
return 'No repositories to analyze';
|
||||
case VariantAnalysisFailureReason.InternalError:
|
||||
return 'Something unexpected happened';
|
||||
}
|
||||
};
|
||||
|
||||
const getMessage = (failureReason: VariantAnalysisFailureReason): string => {
|
||||
switch (failureReason) {
|
||||
case VariantAnalysisFailureReason.NoReposQueried:
|
||||
return 'No repositories available after processing. No repositories were analyzed.';
|
||||
case VariantAnalysisFailureReason.InternalError:
|
||||
return 'An internal error occurred while running this variant analysis. Please try again later.';
|
||||
}
|
||||
};
|
||||
|
||||
const openLogs = () => {
|
||||
@@ -33,16 +15,36 @@ const 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. <VSCodeLink onClick={openLogs}>Check logs</VSCodeLink> 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,
|
||||
showLogsButton,
|
||||
}: Props) => {
|
||||
return (
|
||||
<Alert
|
||||
type="error"
|
||||
title={getTitle(failureReason)}
|
||||
message={getMessage(failureReason)}
|
||||
actions={showLogsButton && <VSCodeButton appearance="secondary" onClick={openLogs}>View logs</VSCodeButton>}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ export const VariantAnalysisOutcomePanels = ({
|
||||
/>
|
||||
)}
|
||||
{variantAnalysis.status === VariantAnalysisStatus.Failed && variantAnalysis.failureReason && (
|
||||
<FailureReasonAlert failureReason={variantAnalysis.failureReason} showLogsButton={!!variantAnalysis.actionsWorkflowRunId} />
|
||||
<FailureReasonAlert failureReason={variantAnalysis.failureReason} />
|
||||
)}
|
||||
{overLimitRepositoryCount > 0 && (
|
||||
<Alert
|
||||
|
||||
Reference in New Issue
Block a user