Browse Source

Update naming, test using a *

main
Ramin Tadayon 2 years ago
committed by Keith Daulton
parent
commit
3ffabb1c24
5 changed files with 55 additions and 55 deletions
  1. +28
    -28
      src/plus/webviews/graph/graphWebview.ts
  2. +10
    -10
      src/plus/webviews/graph/protocol.ts
  3. +2
    -2
      src/storage.ts
  4. +10
    -10
      src/webviews/apps/plus/graph/GraphWrapper.tsx
  5. +5
    -5
      src/webviews/apps/plus/graph/graph.tsx

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

@ -51,7 +51,7 @@ import type { RepositoryChangeEvent, RepositoryFileSystemChangeEvent } from '../
import { Repository, RepositoryChange, RepositoryChangeComparisonMode } from '../../../git/models/repository'; import { Repository, RepositoryChange, RepositoryChangeComparisonMode } from '../../../git/models/repository';
import type { GitSearch } from '../../../git/search'; import type { GitSearch } from '../../../git/search';
import { getSearchQueryComparisonKey } 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 { executeActionCommand, executeCommand, executeCoreGitCommand, registerCommand } from '../../../system/command';
import { gate } from '../../../system/decorators/gate'; import { gate } from '../../../system/decorators/gate';
import { debug } from '../../../system/decorators/log'; import { debug } from '../../../system/decorators/log';
@ -86,10 +86,10 @@ import type {
GraphColumnsConfig, GraphColumnsConfig,
GraphColumnsSettings, GraphColumnsSettings,
GraphComponentConfig, GraphComponentConfig,
GraphHiddenRef,
GraphHiddenRefs,
GraphExcludedRef,
GraphExcludeRefs,
GraphHostingServiceType, GraphHostingServiceType,
GraphIncludeRef,
GraphIncludeOnlyRef,
GraphMissingRefsMetadataType, GraphMissingRefsMetadataType,
GraphPullRequestMetadata, GraphPullRequestMetadata,
GraphRefMetadata, GraphRefMetadata,
@ -599,7 +599,7 @@ export class GraphWebview extends WebviewBase {
} }
private onRefsVisibilityChanged(e: UpdateRefsVisibilityParams) { private onRefsVisibilityChanged(e: UpdateRefsVisibilityParams) {
this.updateHiddenRefs(e.refs, e.visible);
this.updateExcludedRefs(e.refs, e.visible);
} }
private onDoubleClickRef(e: DoubleClickedRefParams) { private onDoubleClickRef(e: DoubleClickedRefParams) {
@ -1029,8 +1029,8 @@ export class GraphWebview extends WebviewBase {
} }
return this.notify(DidChangeRefsVisibilityNotificationType, { 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'); return this.container.storage.getWorkspace('graph:columns');
} }
private getHiddenRefs(graph: GitGraph | undefined): Record<string, GraphHiddenRef> | undefined {
return this.filterHiddenRefs(this.container.storage.getWorkspace('graph:hiddenRefs'), graph);
private getExcludedRefs(graph: GitGraph | undefined): Record<string, GraphExcludedRef> | undefined {
return this.filterExcludedRefs(this.container.storage.getWorkspace('graph:excludeRefs'), graph);
} }
private getIncludeRefs(graph: GitGraph | undefined): Record<string, GraphIncludeRef> | undefined {
private getIncludeOnlyRefs(graph: GitGraph | undefined): Record<string, GraphIncludeOnlyRef> | undefined {
if (graph == null) return undefined; if (graph == null) return undefined;
if (Math.random() < 0.5) return {}; if (Math.random() < 0.5) return {};
@ -1286,26 +1286,26 @@ export class GraphWebview extends WebviewBase {
}, },
[getBranchId(graph.repoPath, true, 'main')]: { [getBranchId(graph.repoPath, true, 'main')]: {
id: getBranchId(graph.repoPath, true, 'main'), id: getBranchId(graph.repoPath, true, 'main'),
name: 'main',
type: 'head',
name: '*',
type: 'remote',
owner: 'origin', owner: 'origin',
}, },
}; };
} }
private filterHiddenRefs(
hiddenRefs: Record<string, StoredGraphHiddenRef> | undefined,
private filterExcludedRefs(
excludeRefs: Record<string, StoredGraphExcludedRef> | undefined,
graph: GitGraph | 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 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) { if (getRepoPathFromBranchOrTagId(id) === graph.repoPath) {
const ref: GraphHiddenRef = { ...hiddenRefs[id] };
const ref: GraphExcludedRef = { ...excludeRefs[id] };
if (ref.type === 'remote' && ref.owner) { if (ref.type === 'remote' && ref.owner) {
const remote = graph.remotes.get(ref.owner); const remote = graph.remotes.get(ref.owner);
if (remote != null) { if (remote != null) {
@ -1351,7 +1351,7 @@ export class GraphWebview extends WebviewBase {
// return filteredHiddenRefsById; // return filteredHiddenRefsById;
// For v13, we return directly the hidden refs without validating them // For v13, we return directly the hidden refs without validating them
return hiddenRefs;
// return excludeRefs;
} }
private getColumnSettings(columns: Record<GraphColumnName, GraphColumnConfig> | undefined): GraphColumnsSettings { private getColumnSettings(columns: Record<GraphColumnName, GraphColumnConfig> | undefined): GraphColumnsSettings {
@ -1518,8 +1518,8 @@ export class GraphWebview extends WebviewBase {
context: { context: {
header: this.getColumnHeaderContext(columns), 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, nonce: this.cspNonce,
workingTreeStats: getSettledValue(workingStatsResult) ?? { added: 0, deleted: 0, modified: 0 }, workingTreeStats: getSettledValue(workingStatsResult) ?? { added: 0, deleted: 0, modified: 0 },
}; };
@ -1534,17 +1534,17 @@ export class GraphWebview extends WebviewBase {
void this.notifyDidChangeColumns(); 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) { for (const ref of refs) {
storedHiddenRefs = updateRecordValue(
storedHiddenRefs,
storedExcludedRefs = updateRecordValue(
storedExcludedRefs,
ref.id, ref.id,
visible ? undefined : { id: ref.id, type: ref.type, name: ref.name, owner: ref.owner }, 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(); void this.notifyDidChangeRefsVisibility();
} }
@ -1841,7 +1841,7 @@ export class GraphWebview extends WebviewBase {
} }
if (refs != null) { if (refs != null) {
this.updateHiddenRefs(
this.updateExcludedRefs(
refs.map(r => { refs.map(r => {
const remoteBranch = r.refType === 'branch' && r.remote; const remoteBranch = r.refType === 'branch' && r.remote;
return { return {

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

@ -9,7 +9,7 @@ import type {
GraphZoneType, GraphZoneType,
Head, Head,
HostingServiceType, HostingServiceType,
IncludeRefsById,
IncludeOnlyRefsById,
PullRequestMetadata, PullRequestMetadata,
RefMetadata, RefMetadata,
RefMetadataType, RefMetadataType,
@ -60,8 +60,8 @@ export interface State {
trialBanner?: boolean; trialBanner?: boolean;
workingTreeStats?: GraphWorkingTreeStats; workingTreeStats?: GraphWorkingTreeStats;
searchResults?: DidSearchParams['results']; searchResults?: DidSearchParams['results'];
hiddenRefs?: GraphHiddenRefs;
includeRefs?: GraphIncludeRefs;
excludeRefs?: GraphExcludeRefs;
includeOnlyRefs?: GraphIncludeOnlyRefs;
// Props below are computed in the webview (not passed) // Props below are computed in the webview (not passed)
activeRow?: string; activeRow?: string;
@ -121,10 +121,10 @@ export interface GraphColumnConfig {
export type GraphColumnsConfig = { [name: string]: 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; export type GraphColumnName = GraphZoneType;
@ -181,7 +181,7 @@ export interface UpdateColumnsParams {
export const UpdateColumnsCommandType = new IpcCommandType<UpdateColumnsParams>('graph/columns/update'); export const UpdateColumnsCommandType = new IpcCommandType<UpdateColumnsParams>('graph/columns/update');
export interface UpdateRefsVisibilityParams { export interface UpdateRefsVisibilityParams {
refs: GraphHiddenRef[];
refs: GraphExcludedRef[];
visible: boolean; visible: boolean;
} }
export const UpdateRefsVisibilityCommandType = new IpcCommandType<UpdateRefsVisibilityParams>( export const UpdateRefsVisibilityCommandType = new IpcCommandType<UpdateRefsVisibilityParams>(
@ -262,8 +262,8 @@ export const DidChangeWindowFocusNotificationType = new IpcNotificationType
); );
export interface DidChangeRefsVisibilityParams { export interface DidChangeRefsVisibilityParams {
hiddenRefs?: GraphHiddenRefs;
includeRefs?: GraphIncludeRefs;
excludeRefs?: GraphExcludeRefs;
includeOnlyRefs?: GraphIncludeOnlyRefs;
} }
export const DidChangeRefsVisibilityNotificationType = new IpcNotificationType<DidChangeRefsVisibilityParams>( export const DidChangeRefsVisibilityNotificationType = new IpcNotificationType<DidChangeRefsVisibilityParams>(
'graph/refs/didChangeVisibility', 'graph/refs/didChangeVisibility',

+ 2
- 2
src/storage.ts View File

@ -191,7 +191,7 @@ export interface WorkspaceStorage {
dismissed?: Record<string, boolean>; dismissed?: Record<string, boolean>;
}; };
columns?: Record<string, StoredGraphColumn>; columns?: Record<string, StoredGraphColumn>;
hiddenRefs?: Record<string, StoredGraphHiddenRef>;
excludeRefs?: Record<string, StoredGraphExcludedRef>;
}; };
remote: { remote: {
default?: string; default?: string;
@ -247,7 +247,7 @@ export interface StoredGraphColumn {
export type StoredGraphRefType = 'head' | 'remote' | 'tag'; export type StoredGraphRefType = 'head' | 'remote' | 'tag';
export interface StoredGraphHiddenRef {
export interface StoredGraphExcludedRef {
id: string; id: string;
type: StoredGraphRefType; type: StoredGraphRefType;
name: string; name: string;

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

@ -24,7 +24,7 @@ import type {
GraphColumnName, GraphColumnName,
GraphColumnsConfig, GraphColumnsConfig,
GraphComponentConfig, GraphComponentConfig,
GraphHiddenRef,
GraphExcludedRef,
GraphMissingRefsMetadata, GraphMissingRefsMetadata,
GraphRepository, GraphRepository,
GraphSearchResults, GraphSearchResults,
@ -68,7 +68,7 @@ export interface GraphWrapperProps {
onMissingAvatars?: (emails: { [email: string]: string }) => void; onMissingAvatars?: (emails: { [email: string]: string }) => void;
onMissingRefsMetadata?: (metadata: GraphMissingRefsMetadata) => void; onMissingRefsMetadata?: (metadata: GraphMissingRefsMetadata) => void;
onMoreRows?: (id?: string) => 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; onSearch?: (search: SearchQuery | undefined, options?: { limit?: number }) => void;
onSearchPromise?: ( onSearchPromise?: (
search: SearchQuery, search: SearchQuery,
@ -162,8 +162,8 @@ export function GraphWrapper({
const [graphConfig, setGraphConfig] = useState(state.config); const [graphConfig, setGraphConfig] = useState(state.config);
// 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 [includeRefsById, setIncludeRefsById] = useState(state.includeRefs);
const [excludeRefsById, setExcludeRefsById] = useState(state.excludeRefs);
const [includeOnlyRefsById, setIncludeOnlyRefsById] = useState(state.includeOnlyRefs);
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,8 +246,8 @@ export function GraphWrapper({
setSelectedRows(state.selectedRows); setSelectedRows(state.selectedRows);
break; break;
case DidChangeRefsVisibilityNotificationType: case DidChangeRefsVisibilityNotificationType:
setHiddenRefsById(state.hiddenRefs);
setIncludeRefsById(state.includeRefs);
setExcludeRefsById(state.excludeRefs);
setIncludeOnlyRefsById(state.includeOnlyRefs);
break; break;
case DidChangeSubscriptionNotificationType: case DidChangeSubscriptionNotificationType:
setIsAccessAllowed(state.allowed ?? false); setIsAccessAllowed(state.allowed ?? false);
@ -271,8 +271,8 @@ export function GraphWrapper({
setWorkingTreeStats(state.workingTreeStats ?? { added: 0, modified: 0, deleted: 0 }); setWorkingTreeStats(state.workingTreeStats ?? { added: 0, modified: 0, deleted: 0 });
setGraphConfig(state.config); setGraphConfig(state.config);
setSelectedRows(state.selectedRows); setSelectedRows(state.selectedRows);
setHiddenRefsById(state.hiddenRefs);
setIncludeRefsById(state.includeRefs);
setExcludeRefsById(state.excludeRefs);
setIncludeOnlyRefsById(state.includeOnlyRefs);
setContext(state.context); setContext(state.context);
setAvatars(state.avatars ?? {}); setAvatars(state.avatars ?? {});
setRefsMetadata(state.refsMetadata); setRefsMetadata(state.refsMetadata);
@ -832,6 +832,7 @@ export function GraphWrapper({
contexts={context} contexts={context}
cssVariables={styleProps?.cssVariables} cssVariables={styleProps?.cssVariables}
enableMultiSelection={graphConfig?.enableMultiSelection} enableMultiSelection={graphConfig?.enableMultiSelection}
excludeRefsById={excludeRefsById}
formatCommitDateTime={getGraphDateFormatter(graphConfig)} formatCommitDateTime={getGraphDateFormatter(graphConfig)}
getExternalIcon={getIconElementLibrary} getExternalIcon={getIconElementLibrary}
graphRows={rows} graphRows={rows}
@ -839,8 +840,7 @@ export function GraphWrapper({
// Just cast the { [id: string]: number } object to { [id: string]: boolean } for performance // Just cast the { [id: string]: number } object to { [id: string]: boolean } for performance
highlightedShas={searchResults?.ids as GraphContainerProps['highlightedShas']} highlightedShas={searchResults?.ids as GraphContainerProps['highlightedShas']}
highlightRowsOnRefHover={graphConfig?.highlightRowsOnRefHover} highlightRowsOnRefHover={graphConfig?.highlightRowsOnRefHover}
excludeRefsById={hiddenRefsById}
includeRefsById={includeRefsById}
includeOnlyRefsById={includeOnlyRefsById}
scrollRowPadding={graphConfig?.scrollRowPadding} scrollRowPadding={graphConfig?.scrollRowPadding}
showGhostRefsOnRowHover={graphConfig?.showGhostRefsOnRowHover} showGhostRefsOnRowHover={graphConfig?.showGhostRefsOnRowHover}
showRemoteNamesOnRefs={graphConfig?.showRemoteNamesOnRefs} showRemoteNamesOnRefs={graphConfig?.showRemoteNamesOnRefs}

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

@ -8,7 +8,7 @@ import type {
DismissBannerParams, DismissBannerParams,
GraphAvatars, GraphAvatars,
GraphColumnsConfig, GraphColumnsConfig,
GraphHiddenRef,
GraphExcludedRef,
GraphMissingRefsMetadata, GraphMissingRefsMetadata,
GraphRepository, GraphRepository,
InternalNotificationType, InternalNotificationType,
@ -88,7 +88,7 @@ export class GraphApp extends App {
settings => this.onColumnsChanged(settings), settings => this.onColumnsChanged(settings),
250, 250,
)} )}
onRefsVisibilityChange={(refs: GraphHiddenRef[], visible: boolean) =>
onRefsVisibilityChange={(refs: GraphExcludedRef[], visible: boolean) =>
this.onRefsVisibilityChanged(refs, visible) this.onRefsVisibilityChanged(refs, visible)
} }
onSelectRepository={debounce<GraphApp['onRepositorySelectionChanged']>( onSelectRepository={debounce<GraphApp['onRepositorySelectionChanged']>(
@ -170,8 +170,8 @@ 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.includeRefs = params.includeRefs;
this.state.excludeRefs = params.excludeRefs;
this.state.includeOnlyRefs = params.includeOnlyRefs;
this.setState(this.state, type); this.setState(this.state, type);
}); });
break; 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, { this.sendCommand(UpdateRefsVisibilityCommandType, {
refs: refs, refs: refs,
visible: visible, visible: visible,

Loading…
Cancel
Save