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 { getContext, onDidChangeContext } from '../../../context';
import { PlusFeatures } from '../../../features'; import { PlusFeatures } from '../../../features';
import { GitSearchError } from '../../../git/errors'; 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 { GitContributor } from '../../../git/models/contributor';
import { GitGraphRowType } from '../../../git/models/graph'; import { GitGraphRowType } from '../../../git/models/graph';
import type { GitGraph } from '../../../git/models/graph'; import type { GitGraph } from '../../../git/models/graph';
@ -89,6 +89,7 @@ import type {
GraphHiddenRef, GraphHiddenRef,
GraphHiddenRefs, GraphHiddenRefs,
GraphHostingServiceType, GraphHostingServiceType,
GraphIncludeRef,
GraphMissingRefsMetadataType, GraphMissingRefsMetadataType,
GraphPullRequestMetadata, GraphPullRequestMetadata,
GraphRefMetadata, GraphRefMetadata,
@ -1029,6 +1030,7 @@ export class GraphWebview extends WebviewBase {
return this.notify(DidChangeRefsVisibilityNotificationType, { return this.notify(DidChangeRefsVisibilityNotificationType, {
hiddenRefs: this.getHiddenRefs(this._graph), 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); 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( private filterHiddenRefs(
hiddenRefs: Record<string, StoredGraphHiddenRef> | undefined, hiddenRefs: Record<string, StoredGraphHiddenRef> | undefined,
graph: GitGraph | undefined, graph: GitGraph | undefined,
@ -1497,6 +1519,7 @@ export class GraphWebview extends WebviewBase {
header: this.getColumnHeaderContext(columns), header: this.getColumnHeaderContext(columns),
}, },
hiddenRefs: data != null ? this.getHiddenRefs(data) : undefined, hiddenRefs: data != null ? this.getHiddenRefs(data) : undefined,
includeRefs: data != null ? this.getIncludeRefs(data) : undefined,
nonce: this.cspNonce, nonce: this.cspNonce,
workingTreeStats: getSettledValue(workingStatsResult) ?? { added: 0, deleted: 0, modified: 0 }, 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, GraphZoneType,
Head, Head,
HostingServiceType, HostingServiceType,
IncludeRefsById,
PullRequestMetadata, PullRequestMetadata,
RefMetadata, RefMetadata,
RefMetadataType, RefMetadataType,
@ -60,6 +61,7 @@ export interface State {
workingTreeStats?: GraphWorkingTreeStats; workingTreeStats?: GraphWorkingTreeStats;
searchResults?: DidSearchParams['results']; searchResults?: DidSearchParams['results'];
hiddenRefs?: GraphHiddenRefs; hiddenRefs?: GraphHiddenRefs;
includeRefs?: GraphIncludeRefs;
// Props below are computed in the webview (not passed) // Props below are computed in the webview (not passed)
activeRow?: string; 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 GraphHiddenRefs = ExcludeRefsById; // TODO: rename all HiddenRefs to use the new naming
export type GraphHiddenRef = GraphRefOptData; export type GraphHiddenRef = GraphRefOptData;
export type GraphIncludeRefs = IncludeRefsById;
export type GraphIncludeRef = GraphRefOptData;
export type GraphColumnName = GraphZoneType; export type GraphColumnName = GraphZoneType;
@ -259,6 +263,7 @@ export const DidChangeWindowFocusNotificationType = new IpcNotificationType
export interface DidChangeRefsVisibilityParams { export interface DidChangeRefsVisibilityParams {
hiddenRefs?: GraphHiddenRefs; hiddenRefs?: GraphHiddenRefs;
includeRefs?: GraphIncludeRefs;
} }
export const DidChangeRefsVisibilityNotificationType = new IpcNotificationType<DidChangeRefsVisibilityParams>( export const DidChangeRefsVisibilityNotificationType = new IpcNotificationType<DidChangeRefsVisibilityParams>(
'graph/refs/didChangeVisibility', '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 [graphDateFormatter, setGraphDateFormatter] = useState(getGraphDateFormatter(config));
const [columns, setColumns] = useState(state.columns); const [columns, setColumns] = useState(state.columns);
const [hiddenRefsById, setHiddenRefsById] = useState(state.hiddenRefs); const [hiddenRefsById, setHiddenRefsById] = useState(state.hiddenRefs);
const [includeRefsById, setIncludeRefsById] = useState(state.includeRefs);
const [context, setContext] = useState(state.context); const [context, setContext] = useState(state.context);
const [pagingHasMore, setPagingHasMore] = useState(state.paging?.hasMore ?? false); const [pagingHasMore, setPagingHasMore] = useState(state.paging?.hasMore ?? false);
const [isLoading, setIsLoading] = useState(state.loading); const [isLoading, setIsLoading] = useState(state.loading);
@ -246,6 +247,7 @@ export function GraphWrapper({
break; break;
case DidChangeRefsVisibilityNotificationType: case DidChangeRefsVisibilityNotificationType:
setHiddenRefsById(state.hiddenRefs); setHiddenRefsById(state.hiddenRefs);
setIncludeRefsById(state.includeRefs);
break; break;
case DidChangeSubscriptionNotificationType: case DidChangeSubscriptionNotificationType:
setIsAccessAllowed(state.allowed ?? false); setIsAccessAllowed(state.allowed ?? false);
@ -270,6 +272,7 @@ export function GraphWrapper({
setGraphConfig(state.config); setGraphConfig(state.config);
setSelectedRows(state.selectedRows); setSelectedRows(state.selectedRows);
setHiddenRefsById(state.hiddenRefs); setHiddenRefsById(state.hiddenRefs);
setIncludeRefsById(state.includeRefs);
setContext(state.context); setContext(state.context);
setAvatars(state.avatars ?? {}); setAvatars(state.avatars ?? {});
setRefsMetadata(state.refsMetadata); setRefsMetadata(state.refsMetadata);
@ -837,6 +840,7 @@ export function GraphWrapper({
highlightedShas={searchResults?.ids as GraphContainerProps['highlightedShas']} highlightedShas={searchResults?.ids as GraphContainerProps['highlightedShas']}
highlightRowsOnRefHover={graphConfig?.highlightRowsOnRefHover} highlightRowsOnRefHover={graphConfig?.highlightRowsOnRefHover}
excludeRefsById={hiddenRefsById} excludeRefsById={hiddenRefsById}
includeRefsById={includeRefsById}
scrollRowPadding={graphConfig?.scrollRowPadding} scrollRowPadding={graphConfig?.scrollRowPadding}
showGhostRefsOnRowHover={graphConfig?.showGhostRefsOnRowHover} showGhostRefsOnRowHover={graphConfig?.showGhostRefsOnRowHover}
showRemoteNamesOnRefs={graphConfig?.showRemoteNamesOnRefs} 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: case DidChangeRefsVisibilityNotificationType.method:
onIpc(DidChangeRefsVisibilityNotificationType, msg, (params, type) => { onIpc(DidChangeRefsVisibilityNotificationType, msg, (params, type) => {
this.state.hiddenRefs = params.hiddenRefs; this.state.hiddenRefs = params.hiddenRefs;
this.state.includeRefs = params.includeRefs;
this.setState(this.state, type); this.setState(this.state, type);
}); });
break; break;

Loading…
Cancel
Save