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} /> - +