Skip to content

Commit

Permalink
feat: group tree list status
Browse files Browse the repository at this point in the history
closes: 232
Co-authored-by: WilsonNet <[email protected]>
  • Loading branch information
loadez and WilsonNet committed Sep 6, 2024
1 parent 985af16 commit c68556e
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 6 deletions.
51 changes: 48 additions & 3 deletions dashboard/src/components/Status/Status.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ColoredCircle from '@/components/ColoredCircle/ColoredCircle';
import { groupStatus } from '@/utils/status';

interface ITestStatus {
pass?: number;
Expand Down Expand Up @@ -73,6 +74,50 @@ export const TestStatus = ({
);
};

export const GroupedTestStatus = ({
pass,
error,
miss,
fail,
done,
skip,
forceNumber = true,
}: ITestStatus): JSX.Element => {
const { successCount, inconclusiveCount, failedCount } = groupStatus({
doneCount: done ?? 0,
errorCount: error ?? 0,
failCount: fail ?? 0,
missCount: miss ?? 0,
passCount: pass ?? 0,
skipCount: skip ?? 0,
});
return (
<div className="flex flex-row gap-1">
{(forceNumber || successCount) && (
<ColoredCircle
quantity={successCount ?? 0}
tooltipText="global.success"
backgroundClassName="bg-lightGreen"
/>
)}
{(forceNumber || failedCount) && (
<ColoredCircle
quantity={failedCount}
tooltipText="global.failed"
backgroundClassName="bg-lightRed"
/>
)}
{(forceNumber || inconclusiveCount) && (
<ColoredCircle
quantity={inconclusiveCount ?? 0}
tooltipText="global.inconclusive"
backgroundClassName="bg-mediumGray"
/>
)}
</div>
);
};

export const BuildStatus = ({
valid,
invalid,
Expand All @@ -83,16 +128,16 @@ export const BuildStatus = ({
<ColoredCircle
quantity={valid ?? 0}
backgroundClassName="bg-lightGreen"
tooltipText="global.valid"
tooltipText="global.success"
/>
<ColoredCircle
quantity={invalid ?? 0}
backgroundClassName="bg-lightRed"
tooltipText="global.invalid"
tooltipText="global.failed"
/>
<ColoredCircle
quantity={unknown ?? 0}
tooltipText="global.unknown"
tooltipText="global.inconclusive"
backgroundClassName="bg-lightGray"
/>
</div>
Expand Down
6 changes: 3 additions & 3 deletions dashboard/src/components/Table/TreeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useNavigate, useSearch } from '@tanstack/react-router';

import { MessagesKey } from '@/locales/messages';

import { BuildStatus, TestStatus } from '@/components/Status/Status';
import { BuildStatus, GroupedTestStatus } from '@/components/Status/Status';

import {
possibleBuildsTableFilter,
Expand Down Expand Up @@ -101,7 +101,7 @@ const TreeTableRow = (row: TreeTableBody): JSX.Element => {
/>
</TableCell>
<TableCell>
<TestStatus
<GroupedTestStatus
pass={row.bootStatus.pass}
skip={row.bootStatus.skip}
fail={row.bootStatus.fail}
Expand All @@ -111,7 +111,7 @@ const TreeTableRow = (row: TreeTableBody): JSX.Element => {
/>
</TableCell>
<TableCell>
<TestStatus
<GroupedTestStatus
pass={row.testStatus.pass}
skip={row.testStatus.skip}
fail={row.testStatus.fail}
Expand Down
2 changes: 2 additions & 0 deletions dashboard/src/locales/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const messages = {
'global.failed': 'Failed',
'global.filters': 'Filters',
'global.github': 'GitHub',
'global.inconclusive': 'Inconclusive',
'global.info': 'Info',
'global.invalid': 'Invalid',
'global.loading': 'Loading...',
Expand All @@ -104,6 +105,7 @@ export const messages = {
'global.skipped': 'Skipped',
'global.somethingWrong': 'Sorry... something went wrong',
'global.status': 'Status',
'global.success': 'Success',
'global.successful': 'Successful',
'global.summary': 'Summary',
'global.timing': 'Timing',
Expand Down
26 changes: 26 additions & 0 deletions dashboard/src/utils/status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
type StatusCount = {
doneCount: number;
missCount: number;
skipCount: number;
errorCount: number;
failCount: number;
passCount: number;
};

type GroupedStatus = {
successCount: number;
inconclusiveCount: number;
failedCount: number;
};

export function groupStatus(counts: StatusCount): GroupedStatus {
return {
successCount: counts.passCount,
failedCount: counts.failCount,
inconclusiveCount:
counts.doneCount +
counts.errorCount +
counts.missCount +
counts.skipCount,
};
}

0 comments on commit c68556e

Please sign in to comment.