From 0732f3c0e41292bd62e3b9c4ea04c82ac71b0d25 Mon Sep 17 00:00:00 2001 From: Ramin Tadayon Date: Mon, 12 Dec 2022 16:33:33 -0700 Subject: [PATCH] Add type exclusion (WIP) --- src/plus/webviews/graph/graphWebview.ts | 13 +++++++++++++ src/plus/webviews/graph/protocol.ts | 3 +++ src/webviews/apps/plus/graph/GraphWrapper.tsx | 3 +++ 3 files changed, 19 insertions(+) diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index 25c9b21..3e9b593 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -88,6 +88,7 @@ import type { GraphComponentConfig, GraphExcludedRef, GraphExcludeRefs, + GraphExcludeTypes, GraphHostingServiceType, GraphIncludeOnlyRef, GraphMissingRefsMetadataType, @@ -1269,6 +1270,17 @@ export class GraphWebview extends WebviewBase { return this.container.storage.getWorkspace('graph:columns'); } + private getExcludedTypes(graph: GitGraph | undefined): GraphExcludeTypes | undefined { + // if (graph == null) return undefined; + + return { + heads: true, + remotes: true, + stashes: true, + tags: true + }; + } + private getExcludedRefs(graph: GitGraph | undefined): Record | undefined { return this.filterExcludedRefs(this.container.storage.getWorkspace('graph:excludeRefs'), graph); } @@ -1519,6 +1531,7 @@ export class GraphWebview extends WebviewBase { header: this.getColumnHeaderContext(columns), }, excludeRefs: data != null ? this.getExcludedRefs(data) : undefined, + excludeTypes: this.getExcludedTypes(data), includeOnlyRefs: data != null ? this.getIncludeOnlyRefs(data) : undefined, nonce: this.cspNonce, workingTreeStats: getSettledValue(workingStatsResult) ?? { added: 0, deleted: 0, modified: 0 }, diff --git a/src/plus/webviews/graph/protocol.ts b/src/plus/webviews/graph/protocol.ts index 969661b..65a203f 100644 --- a/src/plus/webviews/graph/protocol.ts +++ b/src/plus/webviews/graph/protocol.ts @@ -1,5 +1,6 @@ import type { CssVariables, + ExcludeByType, ExcludeRefsById, GraphColumnSetting, GraphContexts, @@ -61,6 +62,7 @@ export interface State { workingTreeStats?: GraphWorkingTreeStats; searchResults?: DidSearchParams['results']; excludeRefs?: GraphExcludeRefs; + excludeTypes?: GraphExcludeTypes; includeOnlyRefs?: GraphIncludeOnlyRefs; // Props below are computed in the webview (not passed) @@ -123,6 +125,7 @@ export type GraphColumnsConfig = { [name: string]: GraphColumnConfig }; export type GraphExcludeRefs = ExcludeRefsById; export type GraphExcludedRef = GraphRefOptData; +export type GraphExcludeTypes = ExcludeByType; export type GraphIncludeOnlyRefs = IncludeOnlyRefsById; export type GraphIncludeOnlyRef = GraphRefOptData; diff --git a/src/webviews/apps/plus/graph/GraphWrapper.tsx b/src/webviews/apps/plus/graph/GraphWrapper.tsx index c3a5cad..c909337 100644 --- a/src/webviews/apps/plus/graph/GraphWrapper.tsx +++ b/src/webviews/apps/plus/graph/GraphWrapper.tsx @@ -163,6 +163,7 @@ export function GraphWrapper({ // const [graphDateFormatter, setGraphDateFormatter] = useState(getGraphDateFormatter(config)); const [columns, setColumns] = useState(state.columns); const [excludeRefsById, setExcludeRefsById] = useState(state.excludeRefs); + const [excludeTypes, setExcludeTypes] = useState(state.excludeTypes); const [includeOnlyRefsById, setIncludeOnlyRefsById] = useState(state.includeOnlyRefs); const [context, setContext] = useState(state.context); const [pagingHasMore, setPagingHasMore] = useState(state.paging?.hasMore ?? false); @@ -272,6 +273,7 @@ export function GraphWrapper({ setGraphConfig(state.config); setSelectedRows(state.selectedRows); setExcludeRefsById(state.excludeRefs); + setExcludeTypes(state.excludeTypes); setIncludeOnlyRefsById(state.includeOnlyRefs); setContext(state.context); setAvatars(state.avatars ?? {}); @@ -833,6 +835,7 @@ export function GraphWrapper({ cssVariables={styleProps?.cssVariables} enableMultiSelection={graphConfig?.enableMultiSelection} excludeRefsById={excludeRefsById} + excludeByType={excludeTypes} formatCommitDateTime={getGraphDateFormatter(graphConfig)} getExternalIcon={getIconElementLibrary} graphRows={rows}