diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index 6c610a4..25c9b21 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -51,7 +51,7 @@ import type { RepositoryChangeEvent, RepositoryFileSystemChangeEvent } from '../ import { Repository, RepositoryChange, RepositoryChangeComparisonMode } from '../../../git/models/repository'; import type { GitSearch } from '../../../git/search'; import { getSearchQueryComparisonKey } from '../../../git/search'; -import type { StoredGraphHiddenRef } from '../../../storage'; +import type { StoredGraphExcludedRef } from '../../../storage'; import { executeActionCommand, executeCommand, executeCoreGitCommand, registerCommand } from '../../../system/command'; import { gate } from '../../../system/decorators/gate'; import { debug } from '../../../system/decorators/log'; @@ -86,10 +86,10 @@ import type { GraphColumnsConfig, GraphColumnsSettings, GraphComponentConfig, - GraphHiddenRef, - GraphHiddenRefs, + GraphExcludedRef, + GraphExcludeRefs, GraphHostingServiceType, - GraphIncludeRef, + GraphIncludeOnlyRef, GraphMissingRefsMetadataType, GraphPullRequestMetadata, GraphRefMetadata, @@ -599,7 +599,7 @@ export class GraphWebview extends WebviewBase { } private onRefsVisibilityChanged(e: UpdateRefsVisibilityParams) { - this.updateHiddenRefs(e.refs, e.visible); + this.updateExcludedRefs(e.refs, e.visible); } private onDoubleClickRef(e: DoubleClickedRefParams) { @@ -1029,8 +1029,8 @@ export class GraphWebview extends WebviewBase { } return this.notify(DidChangeRefsVisibilityNotificationType, { - hiddenRefs: this.getHiddenRefs(this._graph), - includeRefs: this.getIncludeRefs(this._graph), + excludeRefs: this.getExcludedRefs(this._graph), + includeOnlyRefs: this.getIncludeOnlyRefs(this._graph), }); } @@ -1269,11 +1269,11 @@ export class GraphWebview extends WebviewBase { return this.container.storage.getWorkspace('graph:columns'); } - private getHiddenRefs(graph: GitGraph | undefined): Record | undefined { - return this.filterHiddenRefs(this.container.storage.getWorkspace('graph:hiddenRefs'), graph); + private getExcludedRefs(graph: GitGraph | undefined): Record | undefined { + return this.filterExcludedRefs(this.container.storage.getWorkspace('graph:excludeRefs'), graph); } - private getIncludeRefs(graph: GitGraph | undefined): Record | undefined { + private getIncludeOnlyRefs(graph: GitGraph | undefined): Record | undefined { if (graph == null) return undefined; if (Math.random() < 0.5) return {}; @@ -1286,26 +1286,26 @@ export class GraphWebview extends WebviewBase { }, [getBranchId(graph.repoPath, true, 'main')]: { id: getBranchId(graph.repoPath, true, 'main'), - name: 'main', - type: 'head', + name: '*', + type: 'remote', owner: 'origin', }, }; } - private filterHiddenRefs( - hiddenRefs: Record | undefined, + private filterExcludedRefs( + excludeRefs: Record | undefined, graph: GitGraph | undefined, - ): GraphHiddenRefs | undefined { - if (hiddenRefs == null || graph == null) return undefined; + ): GraphExcludeRefs | undefined { + if (excludeRefs == null || graph == null) return undefined; const useAvatars = configuration.get('graph.avatars', undefined, true); - const filteredRefs: GraphHiddenRefs = {}; + const filteredRefs: GraphExcludeRefs = {}; - for (const id in hiddenRefs) { + for (const id in excludeRefs) { if (getRepoPathFromBranchOrTagId(id) === graph.repoPath) { - const ref: GraphHiddenRef = { ...hiddenRefs[id] }; + const ref: GraphExcludedRef = { ...excludeRefs[id] }; if (ref.type === 'remote' && ref.owner) { const remote = graph.remotes.get(ref.owner); if (remote != null) { @@ -1351,7 +1351,7 @@ export class GraphWebview extends WebviewBase { // return filteredHiddenRefsById; // For v13, we return directly the hidden refs without validating them - return hiddenRefs; + // return excludeRefs; } private getColumnSettings(columns: Record | undefined): GraphColumnsSettings { @@ -1518,8 +1518,8 @@ export class GraphWebview extends WebviewBase { context: { header: this.getColumnHeaderContext(columns), }, - hiddenRefs: data != null ? this.getHiddenRefs(data) : undefined, - includeRefs: data != null ? this.getIncludeRefs(data) : undefined, + excludeRefs: data != null ? this.getExcludedRefs(data) : undefined, + includeOnlyRefs: data != null ? this.getIncludeOnlyRefs(data) : undefined, nonce: this.cspNonce, workingTreeStats: getSettledValue(workingStatsResult) ?? { added: 0, deleted: 0, modified: 0 }, }; @@ -1534,17 +1534,17 @@ export class GraphWebview extends WebviewBase { void this.notifyDidChangeColumns(); } - private updateHiddenRefs(refs: GraphHiddenRef[], visible: boolean) { - let storedHiddenRefs = this.container.storage.getWorkspace('graph:hiddenRefs'); + private updateExcludedRefs(refs: GraphExcludedRef[], visible: boolean) { + let storedExcludedRefs = this.container.storage.getWorkspace('graph:excludeRefs'); for (const ref of refs) { - storedHiddenRefs = updateRecordValue( - storedHiddenRefs, + storedExcludedRefs = updateRecordValue( + storedExcludedRefs, ref.id, visible ? undefined : { id: ref.id, type: ref.type, name: ref.name, owner: ref.owner }, ); } - void this.container.storage.storeWorkspace('graph:hiddenRefs', storedHiddenRefs); + void this.container.storage.storeWorkspace('graph:excludeRefs', storedExcludedRefs); void this.notifyDidChangeRefsVisibility(); } @@ -1841,7 +1841,7 @@ export class GraphWebview extends WebviewBase { } if (refs != null) { - this.updateHiddenRefs( + this.updateExcludedRefs( refs.map(r => { const remoteBranch = r.refType === 'branch' && r.remote; return { diff --git a/src/plus/webviews/graph/protocol.ts b/src/plus/webviews/graph/protocol.ts index 1058596..969661b 100644 --- a/src/plus/webviews/graph/protocol.ts +++ b/src/plus/webviews/graph/protocol.ts @@ -9,7 +9,7 @@ import type { GraphZoneType, Head, HostingServiceType, - IncludeRefsById, + IncludeOnlyRefsById, PullRequestMetadata, RefMetadata, RefMetadataType, @@ -60,8 +60,8 @@ export interface State { trialBanner?: boolean; workingTreeStats?: GraphWorkingTreeStats; searchResults?: DidSearchParams['results']; - hiddenRefs?: GraphHiddenRefs; - includeRefs?: GraphIncludeRefs; + excludeRefs?: GraphExcludeRefs; + includeOnlyRefs?: GraphIncludeOnlyRefs; // Props below are computed in the webview (not passed) activeRow?: string; @@ -121,10 +121,10 @@ export interface GraphColumnConfig { 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 GraphExcludeRefs = ExcludeRefsById; +export type GraphExcludedRef = GraphRefOptData; +export type GraphIncludeOnlyRefs = IncludeOnlyRefsById; +export type GraphIncludeOnlyRef = GraphRefOptData; export type GraphColumnName = GraphZoneType; @@ -181,7 +181,7 @@ export interface UpdateColumnsParams { export const UpdateColumnsCommandType = new IpcCommandType('graph/columns/update'); export interface UpdateRefsVisibilityParams { - refs: GraphHiddenRef[]; + refs: GraphExcludedRef[]; visible: boolean; } export const UpdateRefsVisibilityCommandType = new IpcCommandType( @@ -262,8 +262,8 @@ export const DidChangeWindowFocusNotificationType = new IpcNotificationType( 'graph/refs/didChangeVisibility', diff --git a/src/storage.ts b/src/storage.ts index f43b447..d2e12b0 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -191,7 +191,7 @@ export interface WorkspaceStorage { dismissed?: Record; }; columns?: Record; - hiddenRefs?: Record; + excludeRefs?: Record; }; remote: { default?: string; @@ -247,7 +247,7 @@ export interface StoredGraphColumn { export type StoredGraphRefType = 'head' | 'remote' | 'tag'; -export interface StoredGraphHiddenRef { +export interface StoredGraphExcludedRef { id: string; type: StoredGraphRefType; name: string; diff --git a/src/webviews/apps/plus/graph/GraphWrapper.tsx b/src/webviews/apps/plus/graph/GraphWrapper.tsx index 773509f..c3a5cad 100644 --- a/src/webviews/apps/plus/graph/GraphWrapper.tsx +++ b/src/webviews/apps/plus/graph/GraphWrapper.tsx @@ -24,7 +24,7 @@ import type { GraphColumnName, GraphColumnsConfig, GraphComponentConfig, - GraphHiddenRef, + GraphExcludedRef, GraphMissingRefsMetadata, GraphRepository, GraphSearchResults, @@ -68,7 +68,7 @@ export interface GraphWrapperProps { onMissingAvatars?: (emails: { [email: string]: string }) => void; onMissingRefsMetadata?: (metadata: GraphMissingRefsMetadata) => void; onMoreRows?: (id?: string) => void; - onRefsVisibilityChange?: (refs: GraphHiddenRef[], visible: boolean) => void; + onRefsVisibilityChange?: (refs: GraphExcludedRef[], visible: boolean) => void; onSearch?: (search: SearchQuery | undefined, options?: { limit?: number }) => void; onSearchPromise?: ( search: SearchQuery, @@ -162,8 +162,8 @@ export function GraphWrapper({ const [graphConfig, setGraphConfig] = useState(state.config); // 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 [excludeRefsById, setExcludeRefsById] = useState(state.excludeRefs); + const [includeOnlyRefsById, setIncludeOnlyRefsById] = useState(state.includeOnlyRefs); const [context, setContext] = useState(state.context); const [pagingHasMore, setPagingHasMore] = useState(state.paging?.hasMore ?? false); const [isLoading, setIsLoading] = useState(state.loading); @@ -246,8 +246,8 @@ export function GraphWrapper({ setSelectedRows(state.selectedRows); break; case DidChangeRefsVisibilityNotificationType: - setHiddenRefsById(state.hiddenRefs); - setIncludeRefsById(state.includeRefs); + setExcludeRefsById(state.excludeRefs); + setIncludeOnlyRefsById(state.includeOnlyRefs); break; case DidChangeSubscriptionNotificationType: setIsAccessAllowed(state.allowed ?? false); @@ -271,8 +271,8 @@ export function GraphWrapper({ setWorkingTreeStats(state.workingTreeStats ?? { added: 0, modified: 0, deleted: 0 }); setGraphConfig(state.config); setSelectedRows(state.selectedRows); - setHiddenRefsById(state.hiddenRefs); - setIncludeRefsById(state.includeRefs); + setExcludeRefsById(state.excludeRefs); + setIncludeOnlyRefsById(state.includeOnlyRefs); setContext(state.context); setAvatars(state.avatars ?? {}); setRefsMetadata(state.refsMetadata); @@ -832,6 +832,7 @@ export function GraphWrapper({ contexts={context} cssVariables={styleProps?.cssVariables} enableMultiSelection={graphConfig?.enableMultiSelection} + excludeRefsById={excludeRefsById} formatCommitDateTime={getGraphDateFormatter(graphConfig)} getExternalIcon={getIconElementLibrary} graphRows={rows} @@ -839,8 +840,7 @@ export function GraphWrapper({ // Just cast the { [id: string]: number } object to { [id: string]: boolean } for performance highlightedShas={searchResults?.ids as GraphContainerProps['highlightedShas']} highlightRowsOnRefHover={graphConfig?.highlightRowsOnRefHover} - excludeRefsById={hiddenRefsById} - includeRefsById={includeRefsById} + includeOnlyRefsById={includeOnlyRefsById} scrollRowPadding={graphConfig?.scrollRowPadding} showGhostRefsOnRowHover={graphConfig?.showGhostRefsOnRowHover} showRemoteNamesOnRefs={graphConfig?.showRemoteNamesOnRefs} diff --git a/src/webviews/apps/plus/graph/graph.tsx b/src/webviews/apps/plus/graph/graph.tsx index 94eef75..f66aef0 100644 --- a/src/webviews/apps/plus/graph/graph.tsx +++ b/src/webviews/apps/plus/graph/graph.tsx @@ -8,7 +8,7 @@ import type { DismissBannerParams, GraphAvatars, GraphColumnsConfig, - GraphHiddenRef, + GraphExcludedRef, GraphMissingRefsMetadata, GraphRepository, InternalNotificationType, @@ -88,7 +88,7 @@ export class GraphApp extends App { settings => this.onColumnsChanged(settings), 250, )} - onRefsVisibilityChange={(refs: GraphHiddenRef[], visible: boolean) => + onRefsVisibilityChange={(refs: GraphExcludedRef[], visible: boolean) => this.onRefsVisibilityChanged(refs, visible) } onSelectRepository={debounce( @@ -170,8 +170,8 @@ export class GraphApp extends App { case DidChangeRefsVisibilityNotificationType.method: onIpc(DidChangeRefsVisibilityNotificationType, msg, (params, type) => { - this.state.hiddenRefs = params.hiddenRefs; - this.state.includeRefs = params.includeRefs; + this.state.excludeRefs = params.excludeRefs; + this.state.includeOnlyRefs = params.includeOnlyRefs; this.setState(this.state, type); }); break; @@ -399,7 +399,7 @@ export class GraphApp extends App { }); } - private onRefsVisibilityChanged(refs: GraphHiddenRef[], visible: boolean) { + private onRefsVisibilityChanged(refs: GraphExcludedRef[], visible: boolean) { this.sendCommand(UpdateRefsVisibilityCommandType, { refs: refs, visible: visible,