Replace showWarning by passing in skippedRepositoryCount
This commit is contained in:
@@ -34,6 +34,8 @@ export const Starting = Template.bind({});
|
||||
Starting.args = {
|
||||
variantAnalysisStatus: VariantAnalysisStatus.InProgress,
|
||||
totalRepositoryCount: 10,
|
||||
completedRepositoryCount: 0,
|
||||
skippedRepositoryCount: 0,
|
||||
};
|
||||
|
||||
export const Started = Template.bind({});
|
||||
@@ -43,10 +45,10 @@ Started.args = {
|
||||
completedRepositoryCount: 2,
|
||||
};
|
||||
|
||||
export const StartedWithWarnings = Template.bind({});
|
||||
StartedWithWarnings.args = {
|
||||
export const StartedWithSkippedRepositories = Template.bind({});
|
||||
StartedWithSkippedRepositories.args = {
|
||||
...Starting.args,
|
||||
hasWarnings: true,
|
||||
skippedRepositoryCount: 3,
|
||||
};
|
||||
|
||||
export const Succeeded = Template.bind({});
|
||||
@@ -59,12 +61,12 @@ Succeeded.args = {
|
||||
completedAt: new Date(1661263446000),
|
||||
};
|
||||
|
||||
export const SucceededWithWarnings = Template.bind({});
|
||||
SucceededWithWarnings.args = {
|
||||
export const SucceededWithSkippedRepositories = Template.bind({});
|
||||
SucceededWithSkippedRepositories.args = {
|
||||
...Succeeded.args,
|
||||
totalRepositoryCount: 10,
|
||||
completedRepositoryCount: 2,
|
||||
hasWarnings: true,
|
||||
completedRepositoryCount: 10,
|
||||
skippedRepositoryCount: 6,
|
||||
};
|
||||
|
||||
export const Failed = Template.bind({});
|
||||
@@ -77,6 +79,6 @@ Failed.args = {
|
||||
|
||||
export const Stopped = Template.bind({});
|
||||
Stopped.args = {
|
||||
...SucceededWithWarnings.args,
|
||||
...SucceededWithSkippedRepositories.args,
|
||||
variantAnalysisStatus: VariantAnalysisStatus.Canceled,
|
||||
};
|
||||
|
||||
@@ -72,8 +72,8 @@ export const VariantAnalysisHeader = ({
|
||||
const resultCount = useMemo(() => {
|
||||
return getTotalResultCount(variantAnalysis.scannedRepos);
|
||||
}, [variantAnalysis.scannedRepos]);
|
||||
const hasSkippedRepos = useMemo(() => {
|
||||
return getSkippedRepoCount(variantAnalysis.skippedRepos) > 0;
|
||||
const skippedRepositoryCount = useMemo(() => {
|
||||
return getSkippedRepoCount(variantAnalysis.skippedRepos);
|
||||
}, [variantAnalysis.skippedRepos]);
|
||||
const filteredRepositories = useMemo(() => {
|
||||
return filterAndSortRepositoriesWithResults(variantAnalysis.scannedRepos, {
|
||||
@@ -130,8 +130,8 @@ export const VariantAnalysisHeader = ({
|
||||
variantAnalysisStatus={variantAnalysis.status}
|
||||
totalRepositoryCount={totalScannedRepositoryCount}
|
||||
completedRepositoryCount={completedRepositoryCount}
|
||||
skippedRepositoryCount={skippedRepositoryCount}
|
||||
resultCount={resultCount}
|
||||
hasWarnings={hasSkippedRepos}
|
||||
createdAt={parseDate(variantAnalysis.createdAt)}
|
||||
completedAt={parseDate(variantAnalysis.completedAt)}
|
||||
onViewLogsClick={onViewLogsClick}
|
||||
|
||||
@@ -13,15 +13,14 @@ type Props = {
|
||||
|
||||
totalRepositoryCount: number;
|
||||
completedRepositoryCount: number;
|
||||
|
||||
showWarning?: boolean;
|
||||
skippedRepositoryCount: number;
|
||||
};
|
||||
|
||||
export const VariantAnalysisRepositoriesStats = ({
|
||||
variantAnalysisStatus,
|
||||
totalRepositoryCount,
|
||||
completedRepositoryCount,
|
||||
showWarning,
|
||||
skippedRepositoryCount,
|
||||
}: Props) => {
|
||||
if (variantAnalysisStatus === VariantAnalysisStatus.Failed) {
|
||||
return (
|
||||
@@ -32,6 +31,8 @@ export const VariantAnalysisRepositoriesStats = ({
|
||||
);
|
||||
}
|
||||
|
||||
const showWarning = skippedRepositoryCount > 0;
|
||||
|
||||
return (
|
||||
<>
|
||||
{formatDecimal(completedRepositoryCount)}/
|
||||
|
||||
@@ -13,8 +13,7 @@ export type VariantAnalysisStatsProps = {
|
||||
|
||||
totalRepositoryCount: number;
|
||||
completedRepositoryCount: number;
|
||||
|
||||
hasWarnings?: boolean;
|
||||
skippedRepositoryCount: number;
|
||||
|
||||
resultCount?: number | undefined;
|
||||
createdAt: Date;
|
||||
@@ -33,7 +32,7 @@ export const VariantAnalysisStats = ({
|
||||
variantAnalysisStatus,
|
||||
totalRepositoryCount,
|
||||
completedRepositoryCount,
|
||||
hasWarnings,
|
||||
skippedRepositoryCount,
|
||||
resultCount,
|
||||
createdAt,
|
||||
completedAt,
|
||||
@@ -54,13 +53,13 @@ export const VariantAnalysisStats = ({
|
||||
|
||||
if (
|
||||
variantAnalysisStatus === VariantAnalysisStatus.Succeeded &&
|
||||
hasWarnings
|
||||
skippedRepositoryCount > 0
|
||||
) {
|
||||
return "Succeeded warnings";
|
||||
}
|
||||
|
||||
return "Succeeded";
|
||||
}, [variantAnalysisStatus, hasWarnings]);
|
||||
}, [variantAnalysisStatus, skippedRepositoryCount]);
|
||||
|
||||
const duration = useMemo(() => {
|
||||
if (!completedAt) {
|
||||
@@ -80,7 +79,7 @@ export const VariantAnalysisStats = ({
|
||||
variantAnalysisStatus={variantAnalysisStatus}
|
||||
totalRepositoryCount={totalRepositoryCount}
|
||||
completedRepositoryCount={completedRepositoryCount}
|
||||
showWarning={hasWarnings}
|
||||
skippedRepositoryCount={skippedRepositoryCount}
|
||||
/>
|
||||
</StatItem>
|
||||
<StatItem title="Duration">
|
||||
|
||||
@@ -20,6 +20,7 @@ describe(VariantAnalysisStats.name, () => {
|
||||
variantAnalysisStatus={VariantAnalysisStatus.InProgress}
|
||||
totalRepositoryCount={10}
|
||||
completedRepositoryCount={0}
|
||||
skippedRepositoryCount={0}
|
||||
onViewLogsClick={onViewLogsClick}
|
||||
createdAt={new Date()}
|
||||
{...props}
|
||||
@@ -45,8 +46,8 @@ describe(VariantAnalysisStats.name, () => {
|
||||
expect(screen.getByText("654,321/123,456")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders a warning icon when has warnings is set", () => {
|
||||
render({ hasWarnings: true });
|
||||
it("renders a warning icon when skippedRepositoryCount is greater than zero", () => {
|
||||
render({ skippedRepositoryCount: 4 });
|
||||
|
||||
expect(
|
||||
screen.getByRole("img", {
|
||||
@@ -103,10 +104,10 @@ describe(VariantAnalysisStats.name, () => {
|
||||
expect(screen.getByText("Stopped")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders a succeeded warnings text when the variant analysis status is succeeded and has warnings", () => {
|
||||
it("renders a succeeded warnings text when the variant analysis status is succeeded and skipped repositories count is greater than zero", () => {
|
||||
render({
|
||||
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
|
||||
hasWarnings: true,
|
||||
skippedRepositoryCount: 5,
|
||||
});
|
||||
|
||||
expect(screen.getByText("Succeeded warnings")).toBeInTheDocument();
|
||||
|
||||
Reference in New Issue
Block a user