Pārlūkot izejas kodu

Add settings for additional graph minimap marker types (#2514)

* Move head to "always on", stashes to default on marker settings

* Add plumbing for minimap marker settings

* Sends settings through to the markers calculation logic
main
Ramin Tadayon pirms 1 gada
revīziju iesūtīja GitHub
vecāks
revīzija
0428b1e5c8
Šim parakstam datu bāzē netika atrasta zināma atslēga GPG atslēgas ID: 4AEE18F83AFDEB23
5 mainītis faili ar 126 papildinājumiem un 32 dzēšanām
  1. +31
    -5
      package.json
  2. +11
    -0
      src/config.ts
  3. +22
    -5
      src/plus/webviews/graph/graphWebview.ts
  4. +12
    -0
      src/plus/webviews/graph/protocol.ts
  5. +50
    -22
      src/webviews/apps/plus/graph/GraphWrapper.tsx

+ 31
- 5
package.json Parādīt failu

@ -2226,20 +2226,18 @@
"gitlens.graph.scrollMarkers.additionalTypes": {
"type": "array",
"default": [
"head",
"localBranches"
"localBranches",
"stashes"
],
"items": {
"type": "string",
"enum": [
"head",
"localBranches",
"remoteBranches",
"tags",
"stashes"
],
"enumDescriptions": [
"Marks the location of the current HEAD and its upstream",
"Marks the location of local branches",
"Marks the location of remote branches",
"Marks the location of tags",
@ -2247,7 +2245,7 @@
]
},
"minItems": 0,
"maxItems": 5,
"maxItems": 4,
"uniqueItems": true,
"markdownDescription": "Specifies additional markers to show on the scrollbar in the _Commit Graph_",
"scope": "window",
@ -2387,6 +2385,34 @@
"markdownDescription": "Specifies whether to show an experimental minimap of commit activity above the _Commit Graph_",
"scope": "window",
"order": 100
},
"gitlens.graph.experimental.minimap.additionalTypes": {
"type": "array",
"default": [
"localBranches",
"stashes"
],
"items": {
"type": "string",
"enum": [
"localBranches",
"remoteBranches",
"tags",
"stashes"
],
"enumDescriptions": [
"Marks the location of local branches",
"Marks the location of remote branches",
"Marks the location of tags",
"Marks the location of stashes"
]
},
"minItems": 0,
"maxItems": 4,
"uniqueItems": true,
"markdownDescription": "Specifies additional markers to show on the minimap in the _Commit Graph_",
"scope": "window",
"order": 101
}
}
},

+ 11
- 0
src/config.ts Parādīt failu

@ -299,6 +299,16 @@ export const enum GraphScrollMarkerTypes {
Tags = 'tags',
}
export const enum GraphMinimapTypes {
Selection = 'selection',
Head = 'head',
LocalBranches = 'localBranches',
RemoteBranches = 'remoteBranches',
Highlights = 'highlights',
Stashes = 'stashes',
Tags = 'tags',
}
export const enum GravatarDefaultStyle {
Faces = 'wavatar',
Geometric = 'identicon',
@ -406,6 +416,7 @@ export interface GraphConfig {
experimental: {
minimap: {
enabled: boolean;
additionalTypes: GraphMinimapTypes[];
};
};
highlightRowsOnRefHover: boolean;

+ 22
- 5
src/plus/webviews/graph/graphWebview.ts Parādīt failu

@ -145,6 +145,7 @@ import {
GetMissingAvatarsCommandType,
GetMissingRefsMetadataCommandType,
GetMoreRowsCommandType,
GraphMinimapMarkerTypes,
GraphRefMetadataTypes,
GraphScrollMarkerTypes,
SearchCommandType,
@ -612,7 +613,8 @@ export class GraphWebview extends WebviewBase {
configuration.changed(e, 'graph.pullRequests.enabled') ||
configuration.changed(e, 'graph.showRemoteNames') ||
configuration.changed(e, 'graph.showUpstreamStatus') ||
configuration.changed(e, 'graph.experimental.minimap.enabled')
configuration.changed(e, 'graph.experimental.minimap.enabled') ||
configuration.changed(e, 'graph.experimental.minimap.additionalTypes')
) {
void this.notifyDidChangeConfiguration();
@ -1656,6 +1658,7 @@ export class GraphWebview extends WebviewBase {
enableMultiSelection: false,
highlightRowsOnRefHover: configuration.get('graph.highlightRowsOnRefHover'),
minimap: configuration.get('graph.experimental.minimap.enabled'),
enabledMinimapMarkerTypes: this.getEnabledGraphMinimapMarkers(),
scrollRowPadding: configuration.get('graph.scrollRowPadding'),
enabledScrollMarkerTypes: this.getEnabledGraphScrollMarkers(),
showGhostRefsOnRowHover: configuration.get('graph.showGhostRefsOnRowHover'),
@ -1672,13 +1675,27 @@ export class GraphWebview extends WebviewBase {
const markers: GraphScrollMarkerTypes[] = [
GraphScrollMarkerTypes.Selection,
GraphScrollMarkerTypes.Highlights,
GraphScrollMarkerTypes.Head,
GraphScrollMarkerTypes.Upstream,
...(configuration.get('graph.scrollMarkers.additionalTypes') as unknown as GraphScrollMarkerTypes[]),
];
// Head and upstream are under the same setting, but separate markers in the component
if (markers.includes(GraphScrollMarkerTypes.Head)) {
markers.push(GraphScrollMarkerTypes.Upstream);
}
return markers;
}
private getEnabledGraphMinimapMarkers(): GraphMinimapMarkerTypes[] {
const markersEnabled = configuration.get('graph.experimental.minimap.enabled');
if (!markersEnabled) return [];
const markers: GraphMinimapMarkerTypes[] = [
GraphMinimapMarkerTypes.Selection,
GraphMinimapMarkerTypes.Highlights,
GraphMinimapMarkerTypes.Head,
GraphMinimapMarkerTypes.Upstream,
...(configuration.get(
'graph.experimental.minimap.additionalTypes',
) as unknown as GraphMinimapMarkerTypes[]),
];
return markers;
}

+ 12
- 0
src/plus/webviews/graph/protocol.ts Parādīt failu

@ -61,6 +61,17 @@ export const enum GraphScrollMarkerTypes {
Upstream = 'upstream',
}
export const enum GraphMinimapMarkerTypes {
Selection = 'selection',
Head = 'head',
Highlights = 'highlights',
LocalBranches = 'localBranches',
RemoteBranches = 'remoteBranches',
Stashes = 'stashes',
Tags = 'tags',
Upstream = 'upstream',
}
export const supportedRefMetadataTypes: GraphRefMetadataType[] = Object.values(GraphRefMetadataTypes);
export type GraphCommitDateTimeSource = CommitDateTimeSource;
@ -149,6 +160,7 @@ export interface GraphComponentConfig {
enableMultiSelection?: boolean;
highlightRowsOnRefHover?: boolean;
minimap?: boolean;
enabledMinimapMarkerTypes?: GraphMinimapMarkerTypes[];
scrollRowPadding?: number;
enabledScrollMarkerTypes?: GraphScrollMarkerTypes[];
showGhostRefsOnRowHover?: boolean;

+ 50
- 22
src/webviews/apps/plus/graph/GraphWrapper.tsx Parādīt failu

@ -53,6 +53,7 @@ import {
DidFetchNotificationType,
DidSearchNotificationType,
GraphCommitDateTimeSources,
GraphMinimapMarkerTypes,
} from '../../../../plus/webviews/graph/protocol';
import type { Subscription } from '../../../../subscription';
import { getSubscriptionTimeRemaining, SubscriptionState } from '../../../../subscription';
@ -351,6 +352,7 @@ export function GraphWrapper({
// Loops through all the rows and group them by day and aggregate the row.stats
const statsByDayMap = new Map<number, GraphMinimapStats>();
const markersByDay = new Map<number, GraphMinimapMarker[]>();
const enabledMinimapMarkers: GraphMinimapMarkerTypes[] = graphConfig?.enabledMinimapMarkerTypes ?? [];
let rankedShas: {
head: string | undefined;
@ -368,10 +370,10 @@ export function GraphWrapper({
let prevDay;
let markers;
let headMarkers;
let remoteMarkers;
let headMarkers: GraphMinimapMarker[];
let remoteMarkers: GraphMinimapMarker[];
let stashMarker: StashMarker | undefined;
let tagMarkers;
let tagMarkers: GraphMinimapMarker[];
let row: GraphRow;
let stat;
let stats;
@ -392,20 +394,31 @@ export function GraphWrapper({
};
}
if (row.heads?.length) {
if (
row.heads?.length &&
(enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.Head) ||
enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.LocalBranches))
) {
rankedShas.branch = row.sha;
headMarkers = [];
// eslint-disable-next-line no-loop-func
headMarkers = row.heads.map<GraphMinimapMarker>(h => {
row.heads.forEach(h => {
if (h.isCurrentHead) {
rankedShas.head = row.sha;
}
return {
type: 'branch',
name: h.name,
current: h.isCurrentHead,
};
if (
enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.LocalBranches) ||
(enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.Head) && h.isCurrentHead)
) {
headMarkers.push({
type: 'branch',
name: h.name,
current: h.isCurrentHead && enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.Head),
});
}
});
markers = markersByDay.get(day);
@ -416,22 +429,33 @@ export function GraphWrapper({
}
}
if (row.remotes?.length) {
if (
row.remotes?.length &&
(enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.Upstream) ||
enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.RemoteBranches))
) {
rankedShas.remote = row.sha;
remoteMarkers = [];
// eslint-disable-next-line no-loop-func
remoteMarkers = row.remotes.map<GraphMinimapMarker>(r => {
row.remotes.forEach(r => {
let current = false;
if (r.current) {
rankedShas.remote = row.sha;
current = true;
}
return {
type: 'remote',
name: `${r.owner}/${r.name}`,
current: current,
};
if (
enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.RemoteBranches) ||
(enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.Upstream) && current)
) {
remoteMarkers.push({
type: 'remote',
name: `${r.owner}/${r.name}`,
current: current && enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.Upstream),
});
}
});
markers = markersByDay.get(day);
@ -442,7 +466,7 @@ export function GraphWrapper({
}
}
if (row.type === 'stash-node') {
if (row.type === 'stash-node' && enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.Stashes)) {
stashMarker = { type: 'stash', name: row.message };
markers = markersByDay.get(day);
if (markers == null) {
@ -452,7 +476,7 @@ export function GraphWrapper({
}
}
if (row.tags?.length) {
if (row.tags?.length && enabledMinimapMarkers.includes(GraphMinimapMarkerTypes.Tags)) {
rankedShas.tag = row.sha;
tagMarkers = row.tags.map<GraphMinimapMarker>(t => ({
@ -499,10 +523,14 @@ export function GraphWrapper({
}
return { stats: statsByDayMap, markers: markersByDay };
}, [rows, graphConfig?.minimap]);
}, [rows, graphConfig?.minimap, graphConfig?.enabledMinimapMarkerTypes]);
const minimapSearchResults = useMemo(() => {
if (!graphConfig?.minimap) return undefined;
if (
!graphConfig?.minimap ||
!graphConfig.enabledMinimapMarkerTypes?.includes(GraphMinimapMarkerTypes.Highlights)
)
{return undefined;}
const searchResultsByDay = new Map<number, GraphMinimapSearchResultMarker>();
@ -522,7 +550,7 @@ export function GraphWrapper({
}
return searchResultsByDay;
}, [searchResults, graphConfig?.minimap]);
}, [searchResults, graphConfig?.minimap, graphConfig?.enabledMinimapMarkerTypes]);
const handleOnMinimapDaySelected = (e: CustomEvent<GraphMinimapDaySelectedEventDetail>) => {
let { sha } = e.detail;

Notiek ielāde…
Atcelt
Saglabāt