Browse Source

(wip) hack to demo "include" filtering in Graph

main
Eric Amodio 2 years ago
committed by Keith Daulton
parent
commit
38528246f4
4 changed files with 34 additions and 1 deletions
  1. +24
    -1
      src/plus/webviews/graph/graphWebview.ts
  2. +5
    -0
      src/plus/webviews/graph/protocol.ts
  3. +4
    -0
      src/webviews/apps/plus/graph/GraphWrapper.tsx
  4. +1
    -0
      src/webviews/apps/plus/graph/graph.tsx

+ 24
- 1
src/plus/webviews/graph/graphWebview.ts View File

@ -35,7 +35,7 @@ import type { Container } from '../../../container';
import { getContext, onDidChangeContext } from '../../../context';
import { PlusFeatures } from '../../../features';
import { GitSearchError } from '../../../git/errors';
import { getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '../../../git/models/branch';
import { getBranchId, getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '../../../git/models/branch';
import { GitContributor } from '../../../git/models/contributor';
import { GitGraphRowType } from '../../../git/models/graph';
import type { GitGraph } from '../../../git/models/graph';
@ -89,6 +89,7 @@ import type {
GraphHiddenRef,
GraphHiddenRefs,
GraphHostingServiceType,
GraphIncludeRef,
GraphMissingRefsMetadataType,
GraphPullRequestMetadata,
GraphRefMetadata,
@ -1029,6 +1030,7 @@ export class GraphWebview extends WebviewBase {
return this.notify(DidChangeRefsVisibilityNotificationType, {
hiddenRefs: this.getHiddenRefs(this._graph),
includeRefs: this.getIncludeRefs(this._graph),
});
}
@ -1271,6 +1273,26 @@ export class GraphWebview extends WebviewBase {
return this.filterHiddenRefs(this.container.storage.getWorkspace('graph:hiddenRefs'), graph);
}
private getIncludeRefs(graph: GitGraph | undefined): Record<string, GraphIncludeRef> | undefined {
if (graph == null) return undefined;
if (Math.random() < 0.5) return {};
return {
[getBranchId(graph.repoPath, false, 'main')]: {
id: getBranchId(graph.repoPath, false, 'main'),
name: 'main',
type: 'head',
},
[getBranchId(graph.repoPath, true, 'main')]: {
id: getBranchId(graph.repoPath, true, 'main'),
name: 'main',
type: 'head',
owner: 'origin',
},
};
}
private filterHiddenRefs(
hiddenRefs: Record<string, StoredGraphHiddenRef> | undefined,
graph: GitGraph | undefined,
@ -1497,6 +1519,7 @@ export class GraphWebview extends WebviewBase {
header: this.getColumnHeaderContext(columns),
},
hiddenRefs: data != null ? this.getHiddenRefs(data) : undefined,
includeRefs: data != null ? this.getIncludeRefs(data) : undefined,
nonce: this.cspNonce,
workingTreeStats: getSettledValue(workingStatsResult) ?? { added: 0, deleted: 0, modified: 0 },
};

+ 5
- 0
src/plus/webviews/graph/protocol.ts View File

@ -9,6 +9,7 @@ import type {
GraphZoneType,
Head,
HostingServiceType,
IncludeRefsById,
PullRequestMetadata,
RefMetadata,
RefMetadataType,
@ -60,6 +61,7 @@ export interface State {
workingTreeStats?: GraphWorkingTreeStats;
searchResults?: DidSearchParams['results'];
hiddenRefs?: GraphHiddenRefs;
includeRefs?: GraphIncludeRefs;
// Props below are computed in the webview (not passed)
activeRow?: string;
@ -121,6 +123,8 @@ export type GraphColumnsConfig = { [name: string]: GraphColumnConfig };
export type GraphHiddenRefs = ExcludeRefsById; // TODO: rename all HiddenRefs to use the new naming
export type GraphHiddenRef = GraphRefOptData;
export type GraphIncludeRefs = IncludeRefsById;
export type GraphIncludeRef = GraphRefOptData;
export type GraphColumnName = GraphZoneType;
@ -259,6 +263,7 @@ export const DidChangeWindowFocusNotificationType = new IpcNotificationType
export interface DidChangeRefsVisibilityParams {
hiddenRefs?: GraphHiddenRefs;
includeRefs?: GraphIncludeRefs;
}
export const DidChangeRefsVisibilityNotificationType = new IpcNotificationType<DidChangeRefsVisibilityParams>(
'graph/refs/didChangeVisibility',

+ 4
- 0
src/webviews/apps/plus/graph/GraphWrapper.tsx View File

@ -163,6 +163,7 @@ export function GraphWrapper({
// const [graphDateFormatter, setGraphDateFormatter] = useState(getGraphDateFormatter(config));
const [columns, setColumns] = useState(state.columns);
const [hiddenRefsById, setHiddenRefsById] = useState(state.hiddenRefs);
const [includeRefsById, setIncludeRefsById] = useState(state.includeRefs);
const [context, setContext] = useState(state.context);
const [pagingHasMore, setPagingHasMore] = useState(state.paging?.hasMore ?? false);
const [isLoading, setIsLoading] = useState(state.loading);
@ -246,6 +247,7 @@ export function GraphWrapper({
break;
case DidChangeRefsVisibilityNotificationType:
setHiddenRefsById(state.hiddenRefs);
setIncludeRefsById(state.includeRefs);
break;
case DidChangeSubscriptionNotificationType:
setIsAccessAllowed(state.allowed ?? false);
@ -270,6 +272,7 @@ export function GraphWrapper({
setGraphConfig(state.config);
setSelectedRows(state.selectedRows);
setHiddenRefsById(state.hiddenRefs);
setIncludeRefsById(state.includeRefs);
setContext(state.context);
setAvatars(state.avatars ?? {});
setRefsMetadata(state.refsMetadata);
@ -837,6 +840,7 @@ export function GraphWrapper({
highlightedShas={searchResults?.ids as GraphContainerProps['highlightedShas']}
highlightRowsOnRefHover={graphConfig?.highlightRowsOnRefHover}
excludeRefsById={hiddenRefsById}
includeRefsById={includeRefsById}
scrollRowPadding={graphConfig?.scrollRowPadding}
showGhostRefsOnRowHover={graphConfig?.showGhostRefsOnRowHover}
showRemoteNamesOnRefs={graphConfig?.showRemoteNamesOnRefs}

+ 1
- 0
src/webviews/apps/plus/graph/graph.tsx View File

@ -171,6 +171,7 @@ export class GraphApp extends App {
case DidChangeRefsVisibilityNotificationType.method:
onIpc(DidChangeRefsVisibilityNotificationType, msg, (params, type) => {
this.state.hiddenRefs = params.hiddenRefs;
this.state.includeRefs = params.includeRefs;
this.setState(this.state, type);
});
break;

Loading…
Cancel
Save