Browse Source

Adds context items for toggling scroll markers to graph settings cog

Adds submenu & fixes missing re-rendering
main
Ramin Tadayon 1 year ago
committed by Eric Amodio
parent
commit
81fcac4e0a
5 changed files with 256 additions and 39 deletions
  1. +141
    -18
      package.json
  2. +90
    -6
      src/plus/webviews/graph/graphWebview.ts
  3. +10
    -1
      src/plus/webviews/graph/protocol.ts
  4. +2
    -3
      src/webviews/apps/plus/graph/GraphWrapper.tsx
  5. +13
    -11
      src/webviews/apps/plus/graph/graph.tsx

+ 141
- 18
package.json View File

@ -7488,6 +7488,46 @@
"category": "GitLens"
},
{
"command": "gitlens.graph.scrollMarkerLocalBranchOn",
"title": "Show Local Branch Markers",
"category": "GitLens"
},
{
"command": "gitlens.graph.scrollMarkerLocalBranchOff",
"title": "Hide Local Branch Markers",
"category": "GitLens"
},
{
"command": "gitlens.graph.scrollMarkerRemoteBranchOn",
"title": "Show Remote Branch Markers",
"category": "GitLens"
},
{
"command": "gitlens.graph.scrollMarkerRemoteBranchOff",
"title": "Hide Remote Branch Markers",
"category": "GitLens"
},
{
"command": "gitlens.graph.scrollMarkerStashOn",
"title": "Show Stash Markers",
"category": "GitLens"
},
{
"command": "gitlens.graph.scrollMarkerStashOff",
"title": "Hide Stash Markers",
"category": "GitLens"
},
{
"command": "gitlens.graph.scrollMarkerTagOn",
"title": "Show Tag Markers",
"category": "GitLens"
},
{
"command": "gitlens.graph.scrollMarkerTagOff",
"title": "Hide Tag Markers",
"category": "GitLens"
},
{
"command": "gitlens.timeline.refresh",
"title": "Refresh",
"category": "GitLens",
@ -9781,6 +9821,38 @@
"when": "false"
},
{
"command": "gitlens.graph.scrollMarkerLocalBranchOn",
"when": "false"
},
{
"command": "gitlens.graph.scrollMarkerLocalBranchOff",
"when": "false"
},
{
"command": "gitlens.graph.scrollMarkerRemoteBranchOn",
"when": "false"
},
{
"command": "gitlens.graph.scrollMarkerRemoteBranchOff",
"when": "false"
},
{
"command": "gitlens.graph.scrollMarkerStashOn",
"when": "false"
},
{
"command": "gitlens.graph.scrollMarkerStashOff",
"when": "false"
},
{
"command": "gitlens.graph.scrollMarkerTagOn",
"when": "false"
},
{
"command": "gitlens.graph.scrollMarkerTagOff",
"when": "false"
},
{
"command": "gitlens.enableDebugLogging",
"when": "config.gitlens.outputLevel != debug"
},
@ -12636,93 +12708,98 @@
"group": "7_gitlens_cutcopypaste@1"
},
{
"submenu": "gitlens/graph/markers",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/",
"group": "0_markers@0"
},
{
"command": "gitlens.graph.columnAuthorOn",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bauthor:hidden\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:author:hidden\\b/",
"group": "1_columns@1"
},
{
"command": "gitlens.graph.columnAuthorOff",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bauthor:visible\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:author:visible\\b/",
"group": "1_columns@1"
},
{
"command": "gitlens.graph.columnRefOn",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bref:hidden\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:ref:hidden\\b/",
"group": "1_columns@2"
},
{
"command": "gitlens.graph.columnRefOff",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bref:visible\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:ref:visible\\b/",
"group": "1_columns@2"
},
{
"command": "gitlens.graph.columnChangesOn",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bchanges:hidden\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:changes:hidden\\b/",
"group": "1_columns@3"
},
{
"command": "gitlens.graph.columnChangesOff",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bchanges:visible\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:changes:visible\\b/",
"group": "1_columns@3"
},
{
"command": "gitlens.graph.columnMessageOn",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bmessage:hidden\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:message:hidden\\b/",
"group": "1_columns@4"
},
{
"command": "gitlens.graph.columnMessageOff",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bmessage:visible\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:message:visible\\b/",
"group": "1_columns@4"
},
{
"command": "gitlens.graph.columnDateTimeOn",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bdatetime:hidden\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:datetime:hidden\\b/",
"group": "1_columns@5"
},
{
"command": "gitlens.graph.columnDateTimeOff",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bdatetime:visible\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:datetime:visible\\b/",
"group": "1_columns@5"
},
{
"command": "gitlens.graph.columnGraphOn",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bgraph:hidden\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:graph:hidden\\b/",
"group": "1_columns@6"
},
{
"command": "gitlens.graph.columnGraphOff",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bgraph:visible\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:graph:visible\\b/",
"group": "1_columns@6"
},
{
"command": "gitlens.graph.columnShaOn",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bsha:hidden\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:sha:hidden\\b/",
"group": "1_columns@7"
},
{
"command": "gitlens.graph.columnShaOff",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bsha:visible\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:sha:visible\\b/",
"group": "1_columns@7"
},
{
"command": "gitlens.graph.columnGraphDefault",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bgraph:visible[^,]*\\+compact\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:graph:visible[^,]*\\+compact\\b/",
"group": "2_columns@1"
},
{
"command": "gitlens.graph.columnGraphCompact",
"when": "webviewItem =~ /gitlens:graph:columns\\b/ && webviewItemValue =~ /\\bgraph:visible(?![^,]*\\+compact\\b)/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/ && webviewItemValue =~ /\\bcolumn:graph:visible(?![^,]*\\+compact\\b)/",
"group": "2_columns@1"
},
{
"command": "gitlens.graph.resetColumnsDefault",
"when": "webviewItem =~ /gitlens:graph:columns\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/",
"group": "3_columns@1"
},
{
"command": "gitlens.graph.resetColumnsCompact",
"when": "webviewItem =~ /gitlens:graph:columns\\b/",
"when": "webviewItem =~ /gitlens:graph:(columns|settings)\\b/",
"group": "3_columns@2"
}
],
@ -13267,6 +13344,48 @@
"group": "9_gitlens@1"
}
],
"gitlens/graph/markers": [
{
"command": "gitlens.graph.scrollMarkerLocalBranchOn",
"when": "webviewItem =~ /gitlens:graph:settings\\b/ && webviewItemValue =~ /\\bscrollMarker:localBranches:disabled\\b/",
"group": "4_settings@1"
},
{
"command": "gitlens.graph.scrollMarkerLocalBranchOff",
"when": "webviewItem =~ /gitlens:graph:settings\\b/ && webviewItemValue =~ /\\bscrollMarker:localBranches:enabled\\b/",
"group": "4_settings@1"
},
{
"command": "gitlens.graph.scrollMarkerRemoteBranchOn",
"when": "webviewItem =~ /gitlens:graph:settings\\b/ && webviewItemValue =~ /\\bscrollMarker:remoteBranches:disabled\\b/",
"group": "4_settings@2"
},
{
"command": "gitlens.graph.scrollMarkerRemoteBranchOff",
"when": "webviewItem =~ /gitlens:graph:settings\\b/ && webviewItemValue =~ /\\bscrollMarker:remoteBranches:enabled\\b/",
"group": "4_settings@2"
},
{
"command": "gitlens.graph.scrollMarkerStashOn",
"when": "webviewItem =~ /gitlens:graph:settings\\b/ && webviewItemValue =~ /\\bscrollMarker:stashes:disabled\\b/",
"group": "4_settings@3"
},
{
"command": "gitlens.graph.scrollMarkerStashOff",
"when": "webviewItem =~ /gitlens:graph:settings\\b/ && webviewItemValue =~ /\\bscrollMarker:stashes:enabled\\b/",
"group": "4_settings@3"
},
{
"command": "gitlens.graph.scrollMarkerTagOn",
"when": "webviewItem =~ /gitlens:graph:settings\\b/ && webviewItemValue =~ /\\bscrollMarker:tags:disabled\\b/",
"group": "4_settings@4"
},
{
"command": "gitlens.graph.scrollMarkerTagOff",
"when": "webviewItem =~ /gitlens:graph:settings\\b/ && webviewItemValue =~ /\\bscrollMarker:tags:enabled\\b/",
"group": "4_settings@4"
}
],
"gitlens/scm/resourceGroup/changes": [
{
"command": "gitlens.externalDiffAll",
@ -13553,6 +13672,10 @@
"icon": "$(gear)"
},
{
"id": "gitlens/graph/markers",
"label": "Scroll Markers"
},
{
"id": "gitlens/scm/resourceGroup/changes",
"label": "Open Changes"
},

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

@ -11,7 +11,7 @@ import type {
ShowCommitsInViewCommandArgs,
} from '../../../commands';
import { parseCommandContext } from '../../../commands/base';
import type { Config, GraphMinimapMarkersAdditionalTypes } from '../../../config';
import type { Config, GraphMinimapMarkersAdditionalTypes, GraphScrollMarkersAdditionalTypes } from '../../../config';
import type { StoredGraphFilters, StoredGraphIncludeOnlyRef, StoredGraphRefType } from '../../../constants';
import { Commands, GlyphChars } from '../../../constants';
import type { Container } from '../../../container';
@ -150,6 +150,7 @@ import {
DidChangeRefsVisibilityNotificationType,
DidChangeRowsNotificationType,
DidChangeRowsStatsNotificationType,
DidChangeScrollMarkersNotificationType,
DidChangeSelectionNotificationType,
DidChangeSubscriptionNotificationType,
DidChangeWindowFocusNotificationType,
@ -231,6 +232,7 @@ export class GraphWebviewProvider implements WebviewProvider {
[DidChangeGraphConfigurationNotificationType, this.notifyDidChangeConfiguration],
[DidChangeNotificationType, this.notifyDidChangeState],
[DidChangeRefsVisibilityNotificationType, this.notifyDidChangeRefsVisibility],
[DidChangeScrollMarkersNotificationType, this.notifyDidChangeScrollMarkers],
[DidChangeSelectionNotificationType, this.notifyDidChangeSelection],
[DidChangeSubscriptionNotificationType, this.notifyDidChangeSubscription],
[DidChangeWorkingTreeNotificationType, this.notifyDidChangeWorkingTree],
@ -422,6 +424,22 @@ export class GraphWebviewProvider implements WebviewProvider {
registerCommand('gitlens.graph.columnRefOff', () => this.toggleColumn('ref', false)),
registerCommand('gitlens.graph.columnGraphCompact', () => this.setColumnMode('graph', 'compact')),
registerCommand('gitlens.graph.columnGraphDefault', () => this.setColumnMode('graph', undefined)),
registerCommand('gitlens.graph.scrollMarkerLocalBranchOn', () =>
this.toggleScrollMarker('localBranches', true),
),
registerCommand('gitlens.graph.scrollMarkerLocalBranchOff', () =>
this.toggleScrollMarker('localBranches', false),
),
registerCommand('gitlens.graph.scrollMarkerRemoteBranchOn', () =>
this.toggleScrollMarker('remoteBranches', true),
),
registerCommand('gitlens.graph.scrollMarkerRemoteBranchOff', () =>
this.toggleScrollMarker('remoteBranches', false),
),
registerCommand('gitlens.graph.scrollMarkerStashOn', () => this.toggleScrollMarker('stashes', true)),
registerCommand('gitlens.graph.scrollMarkerStashOff', () => this.toggleScrollMarker('stashes', false)),
registerCommand('gitlens.graph.scrollMarkerTagOn', () => this.toggleScrollMarker('tags', true)),
registerCommand('gitlens.graph.scrollMarkerTagOff', () => this.toggleScrollMarker('tags', false)),
registerCommand('gitlens.graph.copyDeepLinkToBranch', this.copyDeepLinkToBranch, this),
registerCommand('gitlens.graph.copyDeepLinkToCommit', this.copyDeepLinkToCommit, this),
@ -1293,6 +1311,21 @@ export class GraphWebviewProvider implements WebviewProvider {
return this.host.notify(DidChangeColumnsNotificationType, {
columns: columnSettings,
context: this.getColumnHeaderContext(columnSettings),
settingsContext: this.getGraphSettingsIconContext(columnSettings),
});
}
@debug()
private async notifyDidChangeScrollMarkers() {
if (!this.host.ready || !this.host.visible) {
this.host.addPendingIpcNotification(DidChangeScrollMarkersNotificationType, this._ipcNotificationMap, this);
return false;
}
const columns = this.getColumns();
const columnSettings = this.getColumnSettings(columns);
return this.host.notify(DidChangeScrollMarkersNotificationType, {
context: this.getGraphSettingsIconContext(columnSettings),
});
}
@ -1652,6 +1685,20 @@ export class GraphWebviewProvider implements WebviewProvider {
}
private getColumnHeaderContext(columnSettings: GraphColumnsSettings): string {
return serializeWebviewItemContext<GraphItemContext>({
webviewItem: 'gitlens:graph:columns',
webviewItemValue: this.getColumnContextItems(columnSettings).join(','),
});
}
private getGraphSettingsIconContext(columnsSettings?: GraphColumnsSettings): string {
return serializeWebviewItemContext<GraphItemContext>({
webviewItem: 'gitlens:graph:settings',
webviewItemValue: this.getSettingsIconContextItems(columnsSettings).join(','),
});
}
private getColumnContextItems(columnSettings: GraphColumnsSettings): string[] {
const contextItems: string[] = [];
// Old column settings that didn't get cleaned up can mess with calculation of only visible column.
// All currently used ones are listed here.
@ -1665,7 +1712,7 @@ export class GraphWebviewProvider implements WebviewProvider {
visibleColumns++;
}
contextItems.push(
`${name}:${settings.isHidden ? 'hidden' : 'visible'}${settings.mode ? `+${settings.mode}` : ''}`,
`column:${name}:${settings.isHidden ? 'hidden' : 'visible'}${settings.mode ? `+${settings.mode}` : ''}`,
);
}
@ -1673,10 +1720,28 @@ export class GraphWebviewProvider implements WebviewProvider {
contextItems.push('columns:canHide');
}
return serializeWebviewItemContext<GraphItemContext>({
webviewItem: 'gitlens:graph:columns',
webviewItemValue: contextItems.join(','),
});
return contextItems;
}
private getSettingsIconContextItems(columnSettings?: GraphColumnsSettings): string[] {
const contextItems: string[] = columnSettings != null ? this.getColumnContextItems(columnSettings) : [];
if (configuration.get('graph.scrollMarkers.enabled')) {
const configurableScrollMarkerTypes: GraphScrollMarkersAdditionalTypes[] = [
'localBranches',
'remoteBranches',
'stashes',
'tags',
];
const enabledScrollMarkerTypes = configuration.get('graph.scrollMarkers.additionalTypes');
for (const type of configurableScrollMarkerTypes) {
contextItems.push(
`scrollMarker:${type}:${enabledScrollMarkerTypes.includes(type) ? 'enabled' : 'disabled'}`,
);
}
}
return contextItems;
}
private getComponentConfig(): GraphComponentConfig {
@ -1912,6 +1977,7 @@ export class GraphWebviewProvider implements WebviewProvider {
config: this.getComponentConfig(),
context: {
header: this.getColumnHeaderContext(columnSettings),
settings: this.getGraphSettingsIconContext(columnSettings),
},
excludeRefs: data != null ? this.getExcludedRefs(data) ?? {} : {},
excludeTypes: this.getExcludedTypes(data) ?? {},
@ -2621,6 +2687,24 @@ export class GraphWebviewProvider implements WebviewProvider {
}
@debug()
private async toggleScrollMarker(type: GraphScrollMarkersAdditionalTypes, enabled: boolean) {
let scrollMarkers = configuration.get('graph.scrollMarkers.additionalTypes');
let updated = false;
if (enabled && !scrollMarkers.includes(type)) {
scrollMarkers = scrollMarkers.concat(type);
updated = true;
} else if (!enabled && scrollMarkers.includes(type)) {
scrollMarkers = scrollMarkers.filter(marker => marker !== type);
updated = true;
}
if (updated) {
await configuration.updateEffective('graph.scrollMarkers.additionalTypes', scrollMarkers);
void this.notifyDidChangeScrollMarkers();
}
}
@debug()
private async setColumnMode(name: GraphColumnName, mode?: string) {
let columns = this.container.storage.getWorkspace('graph:columns');
let column = columns?.[name];

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

@ -17,6 +17,7 @@ import type {
RefMetadataType,
Remote,
RowStats,
GraphItemContext as SerializedGraphItemContext,
Tag,
UpstreamMetadata,
WorkDirStats,
@ -105,7 +106,7 @@ export interface State {
paging?: GraphPaging;
columns?: GraphColumnsSettings;
config?: GraphComponentConfig;
context?: GraphContexts;
context?: GraphContexts & { settings?: SerializedGraphItemContext };
nonce?: string;
trialBanner?: boolean;
workingTreeStats?: GraphWorkingTreeStats;
@ -350,11 +351,19 @@ export const DidChangeRefsMetadataNotificationType = new IpcNotificationType
export interface DidChangeColumnsParams {
columns: GraphColumnsSettings | undefined;
context?: string;
settingsContext?: string;
}
export const DidChangeColumnsNotificationType = new IpcNotificationType<DidChangeColumnsParams>(
'graph/columns/didChange',
);
export interface DidChangeScrollMarkersParams {
context?: string;
}
export const DidChangeScrollMarkersNotificationType = new IpcNotificationType<DidChangeScrollMarkersParams>(
'graph/scrollMarkers/didChange',
);
export interface DidChangeFocusParams {
focused: boolean;
}

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

@ -3,7 +3,6 @@ import type {
GraphColumnSetting,
GraphColumnsSettings,
GraphContainerProps,
GraphMarkerType,
GraphPlatform,
GraphRef,
GraphRefGroup,
@ -1352,7 +1351,7 @@ export function GraphWrapper({
dimMergeCommits={graphConfig?.dimMergeCommits}
downstreamsByUpstream={downstreams}
enabledRefMetadataTypes={graphConfig?.enabledRefMetadataTypes}
enabledScrollMarkerTypes={graphConfig?.scrollMarkerTypes as GraphMarkerType[] | undefined}
enabledScrollMarkerTypes={graphConfig?.scrollMarkerTypes}
enableMultiSelection={graphConfig?.enableMultiSelection}
excludeRefsById={excludeRefsById}
excludeByType={excludeTypes}
@ -1400,7 +1399,7 @@ export function GraphWrapper({
className="column-button"
type="button"
role="button"
data-vscode-context={context?.header || JSON.stringify({ webviewItem: 'gitlens:graph:columns' })}
data-vscode-context={context?.settings || JSON.stringify({ webviewItem: 'gitlens:graph:settings' })}
onClick={handleToggleColumnSettings}
>
<span className="codicon codicon-settings-gear" aria-label="Column Settings"></span>

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

@ -28,6 +28,7 @@ import {
DidChangeRefsVisibilityNotificationType,
DidChangeRowsNotificationType,
DidChangeRowsStatsNotificationType,
DidChangeScrollMarkersNotificationType,
DidChangeSelectionNotificationType,
DidChangeSubscriptionNotificationType,
DidChangeWindowFocusNotificationType,
@ -179,17 +180,11 @@ export class GraphApp extends App {
case DidChangeColumnsNotificationType.method:
onIpc(DidChangeColumnsNotificationType, msg, (params, type) => {
this.state.columns = params.columns;
if (params.context != null) {
if (this.state.context == null) {
this.state.context = { header: params.context };
} else {
this.state.context.header = params.context;
}
} else if (this.state.context?.header != null) {
this.state.context.header = undefined;
}
this.state.context = {
...this.state.context,
header: params.context,
settings: params.settingsContext,
};
this.setState(this.state, type);
});
break;
@ -298,6 +293,13 @@ export class GraphApp extends App {
});
break;
case DidChangeScrollMarkersNotificationType.method:
onIpc(DidChangeScrollMarkersNotificationType, msg, (params, type) => {
this.state.context = { ...this.state.context, settings: params.context };
this.setState(this.state, type);
});
break;
case DidSearchNotificationType.method:
onIpc(DidSearchNotificationType, msg, (params, type) => {
this.state.searchResults = params.results;

Loading…
Cancel
Save