Browse Source

Add setting to toggle PR icons in Graph (#2450)

* Combine metadata settings into one array and include PR metadata

* Rename setting

* Reword active --> enabled

* Fix prop ordering

* Use enum and values array

* Add hints for remote service connection

* Bump graph version

* Remove remote service hint from upstream setting
main
Ramin Tadayon 1 year ago
committed by GitHub
parent
commit
3992bc8ae4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 63 additions and 11 deletions
  1. +8
    -1
      package.json
  2. +3
    -0
      src/config.ts
  3. +21
    -4
      src/plus/webviews/graph/graphWebview.ts
  4. +9
    -1
      src/plus/webviews/graph/protocol.ts
  5. +1
    -1
      src/webviews/apps/plus/graph/GraphWrapper.tsx
  6. +17
    -0
      src/webviews/apps/settings/partials/commit-graph.html
  7. +4
    -4
      yarn.lock

+ 8
- 1
package.json View File

@ -2250,6 +2250,13 @@
"scope": "window", "scope": "window",
"order": 26 "order": 26
}, },
"gitlens.graph.pullRequests.enabled": {
"type": "boolean",
"default": false,
"markdownDescription": "Specifies whether to show associated pull requests on remote branches in the _Commit Graph_. Requires a connection to a supported remote service (e.g. GitHub)",
"scope": "window",
"order": 27
},
"gitlens.graph.commitOrdering": { "gitlens.graph.commitOrdering": {
"type": "string", "type": "string",
"default": "date", "default": "date",
@ -12724,7 +12731,7 @@
"vscode:prepublish": "yarn run bundle" "vscode:prepublish": "yarn run bundle"
}, },
"dependencies": { "dependencies": {
"@gitkraken/gitkraken-components": "1.1.0-rc.22",
"@gitkraken/gitkraken-components": "2.0.0",
"@microsoft/fast-element": "1.11.0", "@microsoft/fast-element": "1.11.0",
"@microsoft/fast-react-wrapper": "0.3.16-0", "@microsoft/fast-react-wrapper": "0.3.16-0",
"@octokit/core": "4.1.0", "@octokit/core": "4.1.0",

+ 3
- 0
src/config.ts View File

@ -392,6 +392,9 @@ export interface GraphConfig {
scrollRowPadding: number; scrollRowPadding: number;
showDetailsView: 'open' | 'selection' | false; showDetailsView: 'open' | 'selection' | false;
showGhostRefsOnRowHover: boolean; showGhostRefsOnRowHover: boolean;
pullRequests: {
enabled: boolean;
};
showRemoteNames: boolean; showRemoteNames: boolean;
showUpstreamStatus: boolean; showUpstreamStatus: boolean;
pageItemLimit: number; pageItemLimit: number;

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

@ -96,6 +96,7 @@ import type {
GraphMissingRefsMetadataType, GraphMissingRefsMetadataType,
GraphPullRequestMetadata, GraphPullRequestMetadata,
GraphRefMetadata, GraphRefMetadata,
GraphRefMetadataType,
GraphRepository, GraphRepository,
GraphSelectedRows, GraphSelectedRows,
GraphUpstreamMetadata, GraphUpstreamMetadata,
@ -131,8 +132,10 @@ import {
GetMissingAvatarsCommandType, GetMissingAvatarsCommandType,
GetMissingRefsMetadataCommandType, GetMissingRefsMetadataCommandType,
GetMoreRowsCommandType, GetMoreRowsCommandType,
GraphRefMetadataTypes,
SearchCommandType, SearchCommandType,
SearchOpenInViewCommandType, SearchOpenInViewCommandType,
supportedRefMetadataTypes,
UpdateColumnsCommandType, UpdateColumnsCommandType,
UpdateExcludeTypeCommandType, UpdateExcludeTypeCommandType,
UpdateIncludeOnlyRefsCommandType, UpdateIncludeOnlyRefsCommandType,
@ -546,6 +549,7 @@ export class GraphWebview extends WebviewBase {
configuration.changed(e, 'graph.highlightRowsOnRefHover') || configuration.changed(e, 'graph.highlightRowsOnRefHover') ||
configuration.changed(e, 'graph.scrollRowPadding') || configuration.changed(e, 'graph.scrollRowPadding') ||
configuration.changed(e, 'graph.showGhostRefsOnRowHover') || configuration.changed(e, 'graph.showGhostRefsOnRowHover') ||
configuration.changed(e, 'graph.pullRequests.enabled') ||
configuration.changed(e, 'graph.showRemoteNames') || configuration.changed(e, 'graph.showRemoteNames') ||
configuration.changed(e, 'graph.showUpstreamStatus') configuration.changed(e, 'graph.showUpstreamStatus')
) { ) {
@ -739,14 +743,14 @@ export class GraphWebview extends WebviewBase {
} }
for (const type of missingTypes) { for (const type of missingTypes) {
if (type !== 'pullRequests' && type !== 'upstream') {
if (!supportedRefMetadataTypes.includes(type)) {
(metadata as any)[type] = null; (metadata as any)[type] = null;
this._refsMetadata.set(id, metadata); this._refsMetadata.set(id, metadata);
continue; continue;
} }
if (type === 'pullRequests') {
if (type === GraphRefMetadataTypes.PullRequest) {
const pr = await branch?.getAssociatedPullRequest(); const pr = await branch?.getAssociatedPullRequest();
if (pr == null) { if (pr == null) {
@ -783,7 +787,7 @@ export class GraphWebview extends WebviewBase {
continue; continue;
} }
if (type === 'upstream') {
if (type === GraphRefMetadataTypes.Upstream) {
const upstream = branch?.upstream; const upstream = branch?.upstream;
if (upstream == null || upstream == undefined || upstream.missing) { if (upstream == null || upstream == undefined || upstream.missing) {
@ -1555,18 +1559,31 @@ export class GraphWebview extends WebviewBase {
dateFormat: dateFormat:
configuration.get('graph.dateFormat') ?? configuration.get('defaultDateFormat') ?? 'short+short', configuration.get('graph.dateFormat') ?? configuration.get('defaultDateFormat') ?? 'short+short',
dateStyle: configuration.get('graph.dateStyle') ?? configuration.get('defaultDateStyle'), dateStyle: configuration.get('graph.dateStyle') ?? configuration.get('defaultDateStyle'),
enabledRefMetadataTypes: this.getEnabledRefMetadataTypes(),
dimMergeCommits: configuration.get('graph.dimMergeCommits'), dimMergeCommits: configuration.get('graph.dimMergeCommits'),
enableMultiSelection: false, enableMultiSelection: false,
highlightRowsOnRefHover: configuration.get('graph.highlightRowsOnRefHover'), highlightRowsOnRefHover: configuration.get('graph.highlightRowsOnRefHover'),
scrollRowPadding: configuration.get('graph.scrollRowPadding'), scrollRowPadding: configuration.get('graph.scrollRowPadding'),
showGhostRefsOnRowHover: configuration.get('graph.showGhostRefsOnRowHover'), showGhostRefsOnRowHover: configuration.get('graph.showGhostRefsOnRowHover'),
showRemoteNamesOnRefs: configuration.get('graph.showRemoteNames'), showRemoteNamesOnRefs: configuration.get('graph.showRemoteNames'),
showUpstreamStatus: configuration.get('graph.showUpstreamStatus'),
idLength: configuration.get('advanced.abbreviatedShaLength'), idLength: configuration.get('advanced.abbreviatedShaLength'),
}; };
return config; return config;
} }
private getEnabledRefMetadataTypes(): GraphRefMetadataType[] {
const types: GraphRefMetadataType[] = [];
if (configuration.get('graph.pullRequests.enabled')) {
types.push(GraphRefMetadataTypes.PullRequest as GraphRefMetadataType);
}
if (configuration.get('graph.showUpstreamStatus')) {
types.push(GraphRefMetadataTypes.Upstream as GraphRefMetadataType);
}
return types;
}
private async getGraphAccess() { private async getGraphAccess() {
let access = await this.container.git.access(PlusFeatures.Graph, this.repository?.path); let access = await this.container.git.access(PlusFeatures.Graph, this.repository?.path);
this._etagSubscription = this.container.subscription.etag; this._etagSubscription = this.container.subscription.etag;

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

@ -37,10 +37,18 @@ export type GraphRefMetadata = RefMetadata | null;
export type GraphUpstreamMetadata = UpstreamMetadata | null; export type GraphUpstreamMetadata = UpstreamMetadata | null;
export type GraphRefsMetadata = Record</* id */ string, GraphRefMetadata>; export type GraphRefsMetadata = Record</* id */ string, GraphRefMetadata>;
export type GraphHostingServiceType = HostingServiceType; export type GraphHostingServiceType = HostingServiceType;
export type GraphRefMetadataType = RefMetadataType;
export type GraphMissingRefsMetadataType = RefMetadataType; export type GraphMissingRefsMetadataType = RefMetadataType;
export type GraphMissingRefsMetadata = Record</*id*/ string, /*missingType*/ GraphMissingRefsMetadataType[]>; export type GraphMissingRefsMetadata = Record</*id*/ string, /*missingType*/ GraphMissingRefsMetadataType[]>;
export type GraphPullRequestMetadata = PullRequestMetadata; export type GraphPullRequestMetadata = PullRequestMetadata;
export enum GraphRefMetadataTypes {
Upstream = 'upstream',
PullRequest = 'pullRequests',
}
export const supportedRefMetadataTypes: GraphRefMetadataType[] = Object.values(GraphRefMetadataTypes);
export interface State { export interface State {
windowFocused?: boolean; windowFocused?: boolean;
repositories?: GraphRepository[]; repositories?: GraphRepository[];
@ -112,12 +120,12 @@ export interface GraphComponentConfig {
dateFormat: DateTimeFormat | string; dateFormat: DateTimeFormat | string;
dateStyle: DateStyle; dateStyle: DateStyle;
dimMergeCommits?: boolean; dimMergeCommits?: boolean;
enabledRefMetadataTypes?: GraphRefMetadataType[];
enableMultiSelection?: boolean; enableMultiSelection?: boolean;
highlightRowsOnRefHover?: boolean; highlightRowsOnRefHover?: boolean;
scrollRowPadding?: number; scrollRowPadding?: number;
showGhostRefsOnRowHover?: boolean; showGhostRefsOnRowHover?: boolean;
showRemoteNamesOnRefs?: boolean; showRemoteNamesOnRefs?: boolean;
showUpstreamStatus?: boolean;
idLength?: number; idLength?: number;
} }

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

@ -1011,6 +1011,7 @@ export function GraphWrapper({
contexts={context} contexts={context}
cssVariables={styleProps?.cssVariables} cssVariables={styleProps?.cssVariables}
dimMergeCommits={graphConfig?.dimMergeCommits} dimMergeCommits={graphConfig?.dimMergeCommits}
enabledRefMetadataTypes={graphConfig?.enabledRefMetadataTypes}
enableMultiSelection={graphConfig?.enableMultiSelection} enableMultiSelection={graphConfig?.enableMultiSelection}
excludeRefsById={excludeRefsById} excludeRefsById={excludeRefsById}
excludeByType={excludeTypes} excludeByType={excludeTypes}
@ -1041,7 +1042,6 @@ export function GraphWrapper({
platform={clientPlatform} platform={clientPlatform}
refMetadataById={refsMetadata} refMetadataById={refsMetadata}
shaLength={graphConfig?.idLength} shaLength={graphConfig?.idLength}
showUpstreamStatus={graphConfig?.showUpstreamStatus}
themeOpacityFactor={styleProps?.themeOpacityFactor} themeOpacityFactor={styleProps?.themeOpacityFactor}
useAuthorInitialsForAvatars={!graphConfig?.avatars} useAuthorInitialsForAvatars={!graphConfig?.avatars}
workDirStats={workingTreeStats} workDirStats={workingTreeStats}

+ 17
- 0
src/webviews/apps/settings/partials/commit-graph.html View File

@ -172,6 +172,23 @@
<div class="setting"> <div class="setting">
<div class="setting__input"> <div class="setting__input">
<input
id="graph.pullRequests.enabled"
name="graph.pullRequests.enabled"
type="checkbox"
data-setting
/>
<label for="graph.pullRequests.enabled"
>Show associated pull requests on remote branches</label
>
</div>
<p class="setting__hint hidden" data-visibility="graph.pullRequests.enabled">
<i class="icon icon__info"></i>Requires a connection to a supported remote service (e.g. GitHub)
</p>
</div>
<div class="setting">
<div class="setting__input">
<input id="graph.avatars" name="graph.avatars" type="checkbox" data-setting /> <input id="graph.avatars" name="graph.avatars" type="checkbox" data-setting />
<label for="graph.avatars">Use author and remote avatars</label> <label for="graph.avatars">Use author and remote avatars</label>
</div> </div>

+ 4
- 4
yarn.lock View File

@ -295,10 +295,10 @@
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6" resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw== integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==
"@gitkraken/gitkraken-components@1.1.0-rc.22":
version "1.1.0-rc.22"
resolved "https://registry.yarnpkg.com/@gitkraken/gitkraken-components/-/gitkraken-components-1.1.0-rc.22.tgz#6a5fa32dff603fe4561e092508678dc54f62a185"
integrity sha512-e7oqU9ibjC11aKs9Z6POjwq1+exk+lIj9nxUDBxGIwVMidfaowaMIH7j7x2tM3we1rdROqsg/sXMImrFbMm6fA==
"@gitkraken/gitkraken-components@2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@gitkraken/gitkraken-components/-/gitkraken-components-2.0.0.tgz#1a1cbb2ef3873a412b693381ea56869a018e697c"
integrity sha512-3caeyF2imEIwZSCwDAf8f5bsxzVZ+0kmL1lZww3CANFlDnhgK8LRU3QkdnuW/PICwZYEpOJop3/0myVBwE3Ieg==
dependencies: dependencies:
"@axosoft/react-virtualized" "9.22.3-gitkraken.3" "@axosoft/react-virtualized" "9.22.3-gitkraken.3"
classnames "^2.3.2" classnames "^2.3.2"

Loading…
Cancel
Save