Skip to content

Commit

Permalink
feat: add hardware column in tests table
Browse files Browse the repository at this point in the history
Closes #408
  • Loading branch information
anajalvarenga committed Oct 25, 2024
1 parent 0375d32 commit bacf471
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/kernelCI_app/views/treeDetailsSlowView.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,17 @@ def __getCurrentRowData(self, currentRow):
testError = extract_error_message(currentRow[tempColumnDict["tests_misc"]])
testEnvironmentCompatible = currentRow[
tempColumnDict["tests_environment_compatible"]
]
][0] if currentRow[
tempColumnDict["tests_environment_compatible"]
] is not None else None

historyItem = {
"id": testId,
"status": testStatus,
"path": path,
"duration": testDuration,
"startTime": currentRow[tempColumnDict["tests_start_time"]],
"hardware": currentRow[tempColumnDict["tests_environment_compatible"]]
}

return (
Expand Down Expand Up @@ -370,7 +373,7 @@ def get(self, request, commit_hash: str | None):
tests.duration AS tests_duration,
tests.number_value AS tests_number_value,
tests.misc AS tests_misc,
tests.environment_compatible[1] AS tests_environment_compatible,
tests.environment_compatible AS tests_environment_compatible,
builds_filter.*,
incidents.id,
incidents.present,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/locales/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export const messages = {
'treeDetails.executed': 'Executed',
'treeDetails.failed': 'Failed',
'treeDetails.failedBoots': 'Failed boots',
'treeDetails.hardware': 'Hardware',
'treeDetails.hardwareUsed': 'Hardware Used',
'treeDetails.inconclusiveBoots': 'Inconclusive Boots',
'treeDetails.inconclusiveBuilds': 'Inconclusive Builds',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { TooltipDateTime } from '@/components/TooltipDateTime';
import { ChevronRightAnimate } from '@/components/AnimatedIcons/Chevron';

import { TableHeader } from '@/components/Table/TableHeader';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/Tooltip';
import { sanitizeTableValue } from '@/components/Table/tableUtils';

const columns: ColumnDef<TIndividualTest>[] = [
{
Expand Down Expand Up @@ -79,12 +81,52 @@ const columns: ColumnDef<TIndividualTest>[] = [
cell: ({ row }): string =>
row.getValue('duration') ? row.getValue('duration') : '-',
},
{
id: 'hardware',
accessorKey: 'hardware',
header: ({ column }): JSX.Element =>
TableHeader({
column: column,
sortable: true,
intlKey: 'treeDetails.hardware',
intlDefaultMessage: 'Hardware',
}),
cell: ({ row }): JSX.Element => (
<TooltipHardware hardwares={row.getValue('hardware')} />
),
},
{
id: 'chevron',
cell: (): JSX.Element => <ChevronRightAnimate />,
},
];

const TooltipHardware = ({
hardwares,
}: {
hardwares: string[] | undefined;
}): JSX.Element => {
const hardwaresTooltip = useMemo(() => {
return hardwares
? hardwares.map(hardware => (
<div key={hardware} className="text-center">
<span>{hardware}</span>
<br />
</div>
))
: '-';
}, [hardwares]);

return (
<Tooltip>
<TooltipTrigger>
{sanitizeTableValue(hardwares?.[0], false)}
</TooltipTrigger>
<TooltipContent>{hardwaresTooltip}</TooltipContent>
</Tooltip>
);
};

export function IndividualTestsTable({
data,
}: {
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/pages/TreeDetails/Tabs/Tests/TestsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export function TestsTable({ testHistory }: ITestsTable): JSX.Element {
path: e.path,
start_time: e.startTime,
status: e.status,
hardware: e.hardware,
});
switch (e.status) {
case 'DONE':
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/types/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type TIndividualTest = {
status?: Status;
start_time: string;
duration: string;
hardware?: string[];
};

export type TBuildTests = {
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/types/tree/TreeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export type TestHistory = {
path: string;
id: string;
duration?: number;
hardware?: string[];
};

type CompilersPerArchitecture = {
Expand Down

0 comments on commit bacf471

Please sign in to comment.