From 6188a252773543daaf4ebb7c38c67950c447160c Mon Sep 17 00:00:00 2001 From: Lucas Bracher Date: Mon, 9 Sep 2024 16:18:19 -0300 Subject: [PATCH] feat(dashboard): allow links boot and test status Links over boot and test statuses are now allowed. Closes #263 --- dashboard/src/components/Table/TreeTable.tsx | 110 ++++++++++++------- 1 file changed, 72 insertions(+), 38 deletions(-) diff --git a/dashboard/src/components/Table/TreeTable.tsx b/dashboard/src/components/Table/TreeTable.tsx index 02b90af8..3f8c9741 100644 --- a/dashboard/src/components/Table/TreeTable.tsx +++ b/dashboard/src/components/Table/TreeTable.tsx @@ -11,6 +11,7 @@ import { BuildStatus, GroupedTestStatus } from '@/components/Status/Status'; import { possibleBuildsTableFilter, possibleTestsTableFilter, + zPossibleValidator, } from '@/types/tree/TreeDetails'; import { TreeTableBody, zOrigin } from '@/types/tree/Tree'; @@ -60,41 +61,52 @@ const TreeTableRow = (row: TreeTableBody): JSX.Element => { const navigate = useNavigate({ from: '/tree' }); - const navigateToTreeDetailPage = useCallback(() => { - navigate({ - to: '/tree/$treeId', - params: { treeId: row.id }, - search: { - tableFilter: { - bootsTable: possibleTestsTableFilter[0], - buildsTable: possibleBuildsTableFilter[2], - testsTable: possibleTestsTableFilter[0], + const navigateToTreeDetailPage = useCallback( + (event: React.MouseEvent) => { + const el = event.currentTarget; + const target = el.getAttribute('data-target'); + + const safeTarget = zPossibleValidator.parse(target); + + navigate({ + to: '/tree/$treeId', + params: { treeId: row.id }, + search: { + tableFilter: { + bootsTable: possibleTestsTableFilter[0], + buildsTable: possibleBuildsTableFilter[2], + testsTable: possibleTestsTableFilter[0], + }, + origin: origin, + currentTreeDetailsTab: safeTarget, + diffFilter: {}, + treeInfo: { + gitUrl: row.url, + gitBranch: row.branch, + treeName: row.tree_names[0], + commitName: row.commitName, + headCommitHash: row.id, + }, }, - origin: origin, - currentTreeDetailsTab: 'treeDetails.builds', - diffFilter: {}, - treeInfo: { - gitUrl: row.url, - gitBranch: row.branch, - treeName: row.tree_names[0], - commitName: row.commitName, - headCommitHash: row.id, - }, - }, - }); - }, [ - navigate, - row.id, - origin, - row.url, - row.branch, - row.tree_names, - row.commitName, - ]); + }); + }, + [ + navigate, + row.id, + origin, + row.url, + row.branch, + row.tree_names, + row.commitName, + ], + ); return ( - - + +
{sanitizeTableValue(row.tree_names.join(', '), false)}
@@ -106,19 +118,38 @@ const TreeTableRow = (row: TreeTableBody): JSX.Element => {
- {sanitizeTableValue(row.branch, false)} - + + {sanitizeTableValue(row.branch, false)} + + {sanitizeTableValue(row.commitName ? row.commitName : row.commitHash)} - {sanitizeTableValue(row.date.split('T')[0] ?? '')} - + + {sanitizeTableValue(row.date.split('T')[0] ?? '')} + + - + { error={row.bootStatus.error} /> - +