Skip to content

Commit

Permalink
feat(dashboard): add commit tag on x axis
Browse files Browse the repository at this point in the history
Close #894
  • Loading branch information
Francisco2002 committed Feb 11, 2025
1 parent f993c81 commit 7251fbc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,29 @@ import type { TFilter } from '@/types/general';

import { MemoizedSectionError } from '@/components/DetailsPages/SectionError';

import type { gitValues } from '@/components/Tooltip/CommitTagTooltip';

const graphDisplaySize = 8;

export const getChartXLabel = ({
commitTags,
commitHash,
commitName,
}: gitValues): string => {
let content = commitHash ?? commitName ?? '';
if (commitTags && commitTags.length > 0) {
content = commitTags[0];

if (content.length > graphDisplaySize) {
content = `...${content.slice(-graphDisplaySize)}`;
}
} else {
content = `${content.slice(0, graphDisplaySize)}`;
}

return content;
};

interface ICommitNavigationGraph {
origin: string;
currentPageTab: string;
Expand Down Expand Up @@ -120,6 +141,7 @@ const CommitNavigationGraph = ({
type TCommitValue = {
commitHash: string;
commitName?: string;
commitTags?: string[];
earliestStartTime?: string;
};

Expand Down Expand Up @@ -157,8 +179,10 @@ const CommitNavigationGraph = ({
commitData.unshift({
commitHash: item.git_commit_hash,
commitName: item.git_commit_name,
commitTags: item.git_commit_tags,
earliestStartTime: item.earliest_start_time,
});

xAxisIndexes.push(index);
});

Expand Down Expand Up @@ -186,6 +210,7 @@ const CommitNavigationGraph = ({
},
},
];

return (
<QuerySwitcher
status={status}
Expand Down Expand Up @@ -225,9 +250,8 @@ const CommitNavigationGraph = ({

isCurrentCommit =
treeId === commitData[parsedPossibleIndex].commitHash;
displayText = commitData[
parsedPossibleIndex
]?.commitHash.slice(0, graphDisplaySize);

displayText = getChartXLabel(commitData[parsedPossibleIndex]);
}

return (
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/Tooltip/CommitTagTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import CopyButton from '@/components/Button/CopyButton';

import { Tooltip, TooltipTrigger, TooltipContent } from './Tooltip';

interface gitValues {
export interface gitValues {
commitTags?: string[];
commitHash?: string;
commitName?: string;
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 @@ -189,6 +189,7 @@ export type TTestByCommitHashResponse = {
export type PaginatedCommitHistoryByTree = {
git_commit_hash: string;
git_commit_name?: string;
git_commit_tags?: string[];
earliest_start_time: string;
builds: {
valid: number;
Expand Down

0 comments on commit 7251fbc

Please sign in to comment.