Skip to content

Commit 7bd9599

Browse files
Adds pull request markers to graph scroll and minimap
1 parent 89b7218 commit 7bd9599

File tree

10 files changed

+183
-11
lines changed

10 files changed

+183
-11
lines changed

package.json

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5353,6 +5353,26 @@
53535353
"highContrast": "#3087cf"
53545354
}
53555355
},
5356+
{
5357+
"id": "gitlens.graphMinimapMarkerPullRequestsColor",
5358+
"description": "Specifies the color marking pull requests on the minimap of the _Commit Graph_",
5359+
"defaults": {
5360+
"light": "#ff8f18",
5361+
"highContrastLight": "#ff8f18",
5362+
"dark": "#c76801",
5363+
"highContrast": "#c76801"
5364+
}
5365+
},
5366+
{
5367+
"id": "gitlens.graphScrollMarkerPullRequestsColor",
5368+
"description": "Specifies the color marking pull requests on the scrollbar of the _Commit Graph_",
5369+
"defaults": {
5370+
"light": "#ff8f18",
5371+
"highContrastLight": "#ff8f18",
5372+
"dark": "#c76801",
5373+
"highContrast": "#c76801"
5374+
}
5375+
},
53565376
{
53575377
"id": "gitlens.graphMinimapMarkerRemoteBranchesColor",
53585378
"description": "Specifies the color marking remote branches on the minimap of the _Commit Graph_",
@@ -9145,6 +9165,16 @@
91459165
"title": "Hide Tag Markers",
91469166
"category": "GitLens"
91479167
},
9168+
{
9169+
"command": "gitlens.graph.scrollMarkerPullRequestOn",
9170+
"title": "Show Pull Request Markers",
9171+
"category": "GitLens"
9172+
},
9173+
{
9174+
"command": "gitlens.graph.scrollMarkerPullRequestOff",
9175+
"title": "Hide Pull Request Markers",
9176+
"category": "GitLens"
9177+
},
91489178
{
91499179
"command": "gitlens.graph.shareAsCloudPatch",
91509180
"title": "Share as Cloud Patch...",
@@ -12072,6 +12102,14 @@
1207212102
"command": "gitlens.graph.scrollMarkerTagOff",
1207312103
"when": "false"
1207412104
},
12105+
{
12106+
"command": "gitlens.graph.scrollMarkerPullRequestOn",
12107+
"when": "false"
12108+
},
12109+
{
12110+
"command": "gitlens.graph.scrollMarkerPullRequestOff",
12111+
"when": "false"
12112+
},
1207512113
{
1207612114
"command": "gitlens.graph.shareAsCloudPatch",
1207712115
"when": "false"
@@ -16307,6 +16345,16 @@
1630716345
"command": "gitlens.graph.scrollMarkerTagOff",
1630816346
"when": "webviewItem =~ /gitlens:graph:settings\\b/ && webviewItemValue =~ /\\bscrollMarker:tags:enabled\\b/",
1630916347
"group": "4_settings@4"
16348+
},
16349+
{
16350+
"command": "gitlens.graph.scrollMarkerPullRequestOn",
16351+
"when": "webviewItem =~ /gitlens:graph:settings\\b/ && webviewItemValue =~ /\\bscrollMarker:pullRequests:disabled\\b/",
16352+
"group": "4_settings@5"
16353+
},
16354+
{
16355+
"command": "gitlens.graph.scrollMarkerPullRequestOff",
16356+
"when": "webviewItem =~ /gitlens:graph:settings\\b/ && webviewItemValue =~ /\\bscrollMarker:pullRequests:enabled\\b/",
16357+
"group": "4_settings@5"
1631016358
}
1631116359
],
1631216360
"gitlens/scm/resourceGroup/changes": [
@@ -17511,7 +17559,7 @@
1751117559
"vscode:prepublish": "yarn run bundle"
1751217560
},
1751317561
"dependencies": {
17514-
"@gitkraken/gitkraken-components": "10.4.0",
17562+
"@gitkraken/gitkraken-components": "10.5.1",
1751517563
"@gitkraken/provider-apis": "0.22.9",
1751617564
"@gitkraken/shared-web-components": "0.1.1-rc.15",
1751717565
"@lit/react": "1.0.5",

src/config.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,18 @@ export type DateSource = 'authored' | 'committed';
305305
export type DateStyle = 'absolute' | 'relative';
306306
export type FileAnnotationType = 'blame' | 'changes' | 'heatmap';
307307
export type GitCommandSorting = 'name' | 'usage';
308-
export type GraphScrollMarkersAdditionalTypes = 'localBranches' | 'remoteBranches' | 'stashes' | 'tags';
309-
export type GraphMinimapMarkersAdditionalTypes = 'localBranches' | 'remoteBranches' | 'stashes' | 'tags';
308+
export type GraphScrollMarkersAdditionalTypes =
309+
| 'localBranches'
310+
| 'remoteBranches'
311+
| 'stashes'
312+
| 'tags'
313+
| 'pullRequests';
314+
export type GraphMinimapMarkersAdditionalTypes =
315+
| 'localBranches'
316+
| 'remoteBranches'
317+
| 'stashes'
318+
| 'tags'
319+
| 'pullRequests';
310320
export type GravatarDefaultStyle = 'wavatar' | 'identicon' | 'monsterid' | 'mp' | 'retro' | 'robohash';
311321
export type HeatmapLocations = 'gutter' | 'line' | 'overview';
312322
export type KeyMap = 'alternate' | 'chorded' | 'none';

src/plus/webviews/graph/graphWebview.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,12 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
539539
this.host.registerWebviewCommand('gitlens.graph.scrollMarkerTagOff', () =>
540540
this.toggleScrollMarker('tags', false),
541541
),
542+
this.host.registerWebviewCommand('gitlens.graph.scrollMarkerPullRequestOn', () =>
543+
this.toggleScrollMarker('pullRequests', true),
544+
),
545+
this.host.registerWebviewCommand('gitlens.graph.scrollMarkerPullRequestOff', () =>
546+
this.toggleScrollMarker('pullRequests', false),
547+
),
542548

543549
this.host.registerWebviewCommand('gitlens.graph.copyDeepLinkToBranch', this.copyDeepLinkToBranch),
544550
this.host.registerWebviewCommand('gitlens.graph.copyDeepLinkToCommit', this.copyDeepLinkToCommit),
@@ -693,6 +699,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
693699
case 'remoteBranches':
694700
case 'stashes':
695701
case 'tags':
702+
case 'pullRequests':
696703
additionalTypes.push(marker);
697704
break;
698705
}
@@ -1968,6 +1975,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
19681975
'remoteBranches',
19691976
'stashes',
19701977
'tags',
1978+
'pullRequests',
19711979
];
19721980
const enabledScrollMarkerTypes = configuration.get('graph.scrollMarkers.additionalTypes');
19731981
for (const type of configurableScrollMarkerTypes) {

src/plus/webviews/graph/protocol.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export type GraphScrollMarkerTypes =
6868
| 'head'
6969
| 'highlights'
7070
| 'localBranches'
71+
| 'pullRequests'
7172
| 'remoteBranches'
7273
| 'stashes'
7374
| 'tags'
@@ -78,6 +79,7 @@ export type GraphMinimapMarkerTypes =
7879
| 'head'
7980
| 'highlights'
8081
| 'localBranches'
82+
| 'pullRequests'
8183
| 'remoteBranches'
8284
| 'stashes'
8385
| 'tags'

src/webviews/apps/plus/graph/GraphWrapper.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,22 @@ export function GraphWrapper({
14651465
Tags
14661466
</VSCodeCheckbox>
14671467
</MenuItem>
1468+
<MenuItem role="none">
1469+
<VSCodeCheckbox
1470+
value="pullRequests"
1471+
onChange={handleOnMinimapAdditionalTypesChange}
1472+
defaultChecked={
1473+
graphConfig?.minimapMarkerTypes?.includes('pullRequests') ??
1474+
true
1475+
}
1476+
>
1477+
<span
1478+
className="minimap-marker-swatch"
1479+
data-marker="pullRequests"
1480+
></span>
1481+
Pull Requests
1482+
</VSCodeCheckbox>
1483+
</MenuItem>
14681484
</MenuList>
14691485
</PopMenu>
14701486
<span slot="content">Minimap Options</span>
@@ -1509,6 +1525,7 @@ export function GraphWrapper({
15091525
rowsStats={rowsStats}
15101526
dataType={graphConfig?.minimapDataType ?? 'commits'}
15111527
markerTypes={graphConfig?.minimapMarkerTypes}
1528+
refMetadata={refsMetadata}
15121529
searchResults={searchResults}
15131530
visibleDays={visibleDays}
15141531
onSelected={e => handleOnMinimapDaySelected(e)}

src/webviews/apps/plus/graph/graph.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
--color-graph-scroll-marker-highlights: var(--vscode-gitlens-graphScrollMarkerHighlightsColor);
5858
--color-graph-minimap-marker-local-branches: var(--vscode-gitlens-graphMinimapMarkerLocalBranchesColor);
5959
--color-graph-scroll-marker-local-branches: var(--vscode-gitlens-graphScrollMarkerLocalBranchesColor);
60+
--color-graph-minimap-marker-pull-requests: var(--vscode-gitlens-graphMinimapMarkerPullRequestsColor);
61+
--color-graph-scroll-marker-pull-requests: var(--vscode-gitlens-graphScrollMarkerPullRequestsColor);
6062
--color-graph-minimap-marker-remote-branches: var(--vscode-gitlens-graphMinimapMarkerRemoteBranchesColor);
6163
--color-graph-scroll-marker-remote-branches: var(--vscode-gitlens-graphScrollMarkerRemoteBranchesColor);
6264
--color-graph-minimap-marker-stashes: var(--vscode-gitlens-graphMinimapMarkerStashesColor);
@@ -87,6 +89,10 @@
8789
--color-graph-minimap-tip-stashBorder: var(--color-graph-scroll-marker-stashes);
8890
--color-graph-minimap-tip-stashForeground: var(--vscode-editor-foreground, var(--vscode-foreground));
8991

92+
--color-graph-minimap-pullRequestBackground: var(--color-graph-scroll-marker-pull-requests);
93+
--color-graph-minimap-pullRequestBorder: var(--color-graph-scroll-marker-pull-requests);
94+
--color-graph-minimap-pullRequestForeground: var(--vscode-editor-foreground, var(--vscode-foreground));
95+
9096
--color-graph-minimap-tip-tagBackground: var(--color-graph-scroll-marker-tags);
9197
--color-graph-minimap-tip-tagBorder: var(--color-graph-scroll-marker-tags);
9298
--color-graph-minimap-tip-tagForeground: var(--vscode-editor-foreground, var(--vscode-foreground));
@@ -1178,6 +1184,10 @@ gl-feature-gate gl-feature-badge {
11781184
background-color: var(--color-graph-minimap-marker-local-branches);
11791185
}
11801186

1187+
&[data-marker='pullRequests'] {
1188+
background-color: var(--color-graph-minimap-marker-pull-requests);
1189+
}
1190+
11811191
&[data-marker='remoteBranches'] {
11821192
background-color: var(--color-graph-minimap-marker-remote-branches);
11831193
}

src/webviews/apps/plus/graph/graph.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@ export class GraphApp extends App<State> {
487487
'--color-graph-scroll-marker-selection',
488488
computedStyle,
489489
),
490+
'--scroll-marker-pull-requests-color': getCssVariable(
491+
'--color-graph-scroll-marker-pull-requests',
492+
computedStyle,
493+
),
490494

491495
'--stats-added-color': getCssVariable('--color-graph-stats-added', computedStyle),
492496
'--stats-deleted-color': getCssVariable('--color-graph-stats-deleted', computedStyle),

src/webviews/apps/plus/graph/minimap/minimap-container.ts

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { customElement, property, query, state } from 'lit/decorators.js';
44
import type {
55
GraphDownstreams,
66
GraphMinimapMarkerTypes,
7+
GraphRefsMetadata,
78
GraphRowStats,
89
GraphSearchResults,
910
GraphSearchResultsError,
@@ -48,6 +49,9 @@ export class GlGraphMinimapContainer extends GlElement {
4849
@property({ type: Array })
4950
markerTypes: GraphMinimapMarkerTypes[] = [];
5051

52+
@property({ type: Object })
53+
refMetadata?: GraphRefsMetadata | null;
54+
5155
@property({ type: Array })
5256
rows: GraphRow[] = [];
5357

@@ -71,7 +75,7 @@ export class GlGraphMinimapContainer extends GlElement {
7175

7276
private pendingDataChange = false;
7377

74-
@observe(['dataType', 'downstreams', 'markerTypes', 'rows', 'rowsStats'])
78+
@observe(['dataType', 'downstreams', 'markerTypes', 'refMetadata', 'rows', 'rowsStats'])
7579
private handleDataChanged(changedKeys: PropertyKey[]) {
7680
// If only the rowsStats changed, and we're not in lines mode, we don't need to reprocess the rows
7781
if (changedKeys.length === 1 && changedKeys[0] === 'rowsStats') {
@@ -154,6 +158,7 @@ export class GlGraphMinimapContainer extends GlElement {
154158

155159
let markers;
156160
let headMarkers: GraphMinimapMarker[];
161+
let pullRequestMarkers: GraphMinimapMarker[];
157162
let remoteMarkers: GraphMinimapMarker[];
158163
let stashMarker: StashMarker | undefined;
159164
let tagMarkers: GraphMinimapMarker[];
@@ -165,6 +170,7 @@ export class GlGraphMinimapContainer extends GlElement {
165170
// Iterate in reverse order so that we can track the HEAD upstream properly
166171
for (let i = rows.length - 1; i >= 0; i--) {
167172
row = rows[i];
173+
pullRequestMarkers = [];
168174

169175
day = getDay(row.date);
170176
if (day !== prevDay) {
@@ -179,7 +185,9 @@ export class GlGraphMinimapContainer extends GlElement {
179185

180186
if (
181187
row.heads?.length &&
182-
(this.markerTypes.includes('head') || this.markerTypes.includes('localBranches'))
188+
(this.markerTypes.includes('head') ||
189+
this.markerTypes.includes('localBranches') ||
190+
this.markerTypes.includes('pullRequests'))
183191
) {
184192
rankedShas.branch = row.sha;
185193

@@ -201,6 +209,19 @@ export class GlGraphMinimapContainer extends GlElement {
201209
current: h.isCurrentHead && this.markerTypes.includes('head'),
202210
});
203211
}
212+
213+
if (
214+
this.markerTypes.includes('pullRequests') &&
215+
h.id != null &&
216+
this.refMetadata?.[h.id]?.pullRequest?.length
217+
) {
218+
for (const pr of this.refMetadata?.[h.id]?.pullRequest ?? []) {
219+
pullRequestMarkers.push({
220+
type: 'pull-request',
221+
name: pr.title,
222+
});
223+
}
224+
}
204225
});
205226

206227
markers = markersByDay.get(day);
@@ -215,7 +236,8 @@ export class GlGraphMinimapContainer extends GlElement {
215236
row.remotes?.length &&
216237
(this.markerTypes.includes('upstream') ||
217238
this.markerTypes.includes('remoteBranches') ||
218-
this.markerTypes.includes('localBranches'))
239+
this.markerTypes.includes('localBranches') ||
240+
this.markerTypes.includes('pullRequests'))
219241
) {
220242
rankedShas.remote = row.sha;
221243

@@ -241,6 +263,19 @@ export class GlGraphMinimapContainer extends GlElement {
241263
current: current && this.markerTypes.includes('upstream'),
242264
});
243265
}
266+
267+
if (
268+
this.markerTypes.includes('pullRequests') &&
269+
r.id != null &&
270+
this.refMetadata?.[r.id]?.pullRequest?.length
271+
) {
272+
for (const pr of this.refMetadata?.[r.id]?.pullRequest ?? []) {
273+
pullRequestMarkers.push({
274+
type: 'pull-request',
275+
name: pr.title,
276+
});
277+
}
278+
}
244279
});
245280

246281
markers = markersByDay.get(day);
@@ -277,6 +312,13 @@ export class GlGraphMinimapContainer extends GlElement {
277312
}
278313
}
279314

315+
markers = markersByDay.get(day);
316+
if (markers == null) {
317+
markersByDay.set(day, pullRequestMarkers);
318+
} else {
319+
markers.push(...pullRequestMarkers);
320+
}
321+
280322
stat = statsByDayMap.get(day);
281323
if (stat == null) {
282324
if (showLinesChanged) {

0 commit comments

Comments
 (0)