Skip to content

Commit a6e3c6f

Browse files
committed
Improves graph search by showing no results
1 parent 42bcf9e commit a6e3c6f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/webviews/apps/plus/graph/graph-wrapper/gl-graph.react.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type {
1616
GraphZoneType,
1717
OnFormatCommitDateTime,
1818
} from '@gitkraken/gitkraken-components';
19-
import GraphContainer, { CommitDateTimeSources, refZone } from '@gitkraken/gitkraken-components';
19+
import GraphContainer, { CommitDateTimeSources, noShaHighlightedSha, refZone } from '@gitkraken/gitkraken-components';
2020
import type { ReactElement } from 'react';
2121
import React, { createElement, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2222
import { getPlatform } from '@env/platform';
@@ -576,6 +576,13 @@ export const GlGraphReact = memo((initProps: GraphWrapperInitProps) => {
576576
};
577577
};
578578

579+
let footer;
580+
if (props.searchResults?.count === 0) {
581+
footer = <>No results found</>;
582+
} else if (props.searchResults?.count && !props.searchResults.paging?.hasMore && !props.loading) {
583+
footer = <>No more results found</>;
584+
}
585+
579586
return (
580587
<GraphContainer
581588
ref={graphRef}
@@ -597,7 +604,11 @@ export const GlGraphReact = memo((initProps: GraphWrapperInitProps) => {
597604
graphRows={props.rows ?? emptyRows}
598605
hasMoreCommits={props.paging?.hasMore}
599606
// Just cast the { [id: string]: number } object to { [id: string]: boolean } for performance
600-
highlightedShas={props.searchResults?.ids as GraphContainerProps['highlightedShas']}
607+
highlightedShas={
608+
props.searchResults?.count === 0
609+
? { [noShaHighlightedSha]: true }
610+
: (props.searchResults?.ids as GraphContainerProps['highlightedShas'])
611+
}
601612
highlightRowsOnRefHover={config.highlightRowsOnRefHover}
602613
includeOnlyRefsById={props.includeOnlyRefs}
603614
scrollRowPadding={config.scrollRowPadding}
@@ -646,6 +657,7 @@ export const GlGraphReact = memo((initProps: GraphWrapperInitProps) => {
646657
themeOpacityFactor={props.theming?.themeOpacityFactor}
647658
useAuthorInitialsForAvatars={!config.avatars}
648659
workDirStats={props.workingTreeStats}
660+
customFooterRow={footer}
649661
/>
650662
);
651663
});

0 commit comments

Comments
 (0)