Merge pull request #1809 from github/robertbrignull/failed_analysis_spinner
Don't show spinner for a failed analysis
This commit is contained in:
@@ -137,6 +137,9 @@ export function VariantAnalysis({
|
||||
return <VariantAnalysisLoading />;
|
||||
}
|
||||
|
||||
const onViewLogsClick =
|
||||
variantAnalysis.actionsWorkflowRunId === undefined ? undefined : openLogs;
|
||||
|
||||
return (
|
||||
<>
|
||||
<VariantAnalysisHeader
|
||||
@@ -146,7 +149,7 @@ export function VariantAnalysis({
|
||||
onStopQueryClick={stopQuery}
|
||||
onCopyRepositoryListClick={copyRepositoryList}
|
||||
onExportResultsClick={exportResults}
|
||||
onViewLogsClick={openLogs}
|
||||
onViewLogsClick={onViewLogsClick}
|
||||
/>
|
||||
<VariantAnalysisOutcomePanels
|
||||
variantAnalysis={variantAnalysis}
|
||||
|
||||
@@ -24,7 +24,7 @@ export type VariantAnalysisHeaderProps = {
|
||||
onCopyRepositoryListClick: () => void;
|
||||
onExportResultsClick: () => void;
|
||||
|
||||
onViewLogsClick: () => void;
|
||||
onViewLogsClick?: () => void;
|
||||
};
|
||||
|
||||
const Container = styled.div`
|
||||
|
||||
@@ -20,7 +20,7 @@ export type VariantAnalysisStatsProps = {
|
||||
createdAt: Date;
|
||||
completedAt?: Date | undefined;
|
||||
|
||||
onViewLogsClick: () => void;
|
||||
onViewLogsClick?: () => void;
|
||||
};
|
||||
|
||||
const Row = styled.div`
|
||||
@@ -88,6 +88,7 @@ export const VariantAnalysisStats = ({
|
||||
</StatItem>
|
||||
<StatItem title={completionHeaderName}>
|
||||
<VariantAnalysisStatusStats
|
||||
variantAnalysisStatus={variantAnalysisStatus}
|
||||
completedAt={completedAt}
|
||||
onViewLogsClick={onViewLogsClick}
|
||||
/>
|
||||
|
||||
@@ -2,11 +2,13 @@ import * as React from "react";
|
||||
import styled from "styled-components";
|
||||
import { VSCodeLink } from "@vscode/webview-ui-toolkit/react";
|
||||
import { formatDate } from "../../pure/date";
|
||||
import { VariantAnalysisStatus } from "../../remote-queries/shared/variant-analysis";
|
||||
|
||||
type Props = {
|
||||
completedAt?: Date | undefined;
|
||||
export type VariantAnalysisStatusStatsProps = {
|
||||
variantAnalysisStatus: VariantAnalysisStatus;
|
||||
completedAt?: Date;
|
||||
|
||||
onViewLogsClick: () => void;
|
||||
onViewLogsClick?: () => void;
|
||||
};
|
||||
|
||||
const Container = styled.div`
|
||||
@@ -21,17 +23,20 @@ const Icon = styled.span`
|
||||
`;
|
||||
|
||||
export const VariantAnalysisStatusStats = ({
|
||||
variantAnalysisStatus,
|
||||
completedAt,
|
||||
onViewLogsClick,
|
||||
}: Props) => {
|
||||
if (completedAt === undefined) {
|
||||
}: VariantAnalysisStatusStatsProps) => {
|
||||
if (variantAnalysisStatus === VariantAnalysisStatus.InProgress) {
|
||||
return <Icon className="codicon codicon-loading codicon-modifier-spin" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<span>{formatDate(completedAt)}</span>
|
||||
<VSCodeLink onClick={onViewLogsClick}>View logs</VSCodeLink>
|
||||
<span>{completedAt !== undefined ? formatDate(completedAt) : "-"}</span>
|
||||
{onViewLogsClick && (
|
||||
<VSCodeLink onClick={onViewLogsClick}>View logs</VSCodeLink>
|
||||
)}
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import * as React from "react";
|
||||
import { render as reactRender, screen } from "@testing-library/react";
|
||||
import { VariantAnalysisStatus } from "../../../remote-queries/shared/variant-analysis";
|
||||
import {
|
||||
VariantAnalysisStatusStats,
|
||||
VariantAnalysisStatusStatsProps,
|
||||
} from "../VariantAnalysisStatusStats";
|
||||
import { formatDate } from "../../../pure/date";
|
||||
|
||||
describe(VariantAnalysisStatusStats.name, () => {
|
||||
const render = (props: Partial<VariantAnalysisStatusStatsProps> = {}) =>
|
||||
reactRender(
|
||||
<VariantAnalysisStatusStats
|
||||
variantAnalysisStatus={VariantAnalysisStatus.InProgress}
|
||||
{...props}
|
||||
/>,
|
||||
);
|
||||
|
||||
it("renders an in-progress status correctly", () => {
|
||||
const { container } = render({
|
||||
variantAnalysisStatus: VariantAnalysisStatus.InProgress,
|
||||
});
|
||||
|
||||
expect(
|
||||
container.getElementsByClassName(
|
||||
"codicon codicon-loading codicon-modifier-spin",
|
||||
)[0],
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders when there is a completedAt date", () => {
|
||||
const completedAt = new Date();
|
||||
render({
|
||||
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
|
||||
completedAt,
|
||||
});
|
||||
|
||||
expect(screen.getByText(formatDate(completedAt))).toBeInTheDocument();
|
||||
expect(screen.queryByText("-")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders when there isn't a completedAt date", () => {
|
||||
render({
|
||||
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
|
||||
completedAt: undefined,
|
||||
});
|
||||
|
||||
expect(screen.getByText("-")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders when there is a viewLogs links", () => {
|
||||
render({
|
||||
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
|
||||
onViewLogsClick: () => undefined,
|
||||
});
|
||||
|
||||
expect(screen.getByText("View logs")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders when there isn't a viewLogs links", () => {
|
||||
render({
|
||||
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
|
||||
onViewLogsClick: undefined,
|
||||
});
|
||||
|
||||
expect(screen.queryByText("View logs")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user