Browse Source

Adds `graph.showDetailsView` setting

Controls how the Commit Details view is shown by the graph
Honors avatar setting in remote icons
main
Eric Amodio 2 years ago
parent
commit
fe0b6b0dd9
8 changed files with 85 additions and 11 deletions
  1. +23
    -3
      package.json
  2. +1
    -1
      src/commands/gitCommands.actions.ts
  3. +1
    -0
      src/config.ts
  4. +3
    -1
      src/env/node/git/localGitProvider.ts
  5. +5
    -2
      src/plus/github/githubGitProvider.ts
  6. +25
    -4
      src/plus/webviews/graph/graphWebview.ts
  7. +24
    -0
      src/webviews/apps/settings/partials/commit-graph.html
  8. +3
    -0
      src/webviews/commitDetails/commitDetailsWebviewView.ts

+ 23
- 3
package.json View File

@ -2097,7 +2097,7 @@
"gitlens.graph.avatars": { "gitlens.graph.avatars": {
"type": "boolean", "type": "boolean",
"default": true, "default": true,
"markdownDescription": "Specifies whether to show avatar images instead of author initials in the _Commit Graph_",
"markdownDescription": "Specifies whether to show avatar images instead of author initials and remote icons in the _Commit Graph_",
"scope": "window", "scope": "window",
"order": 10 "order": 10
}, },
@ -2108,12 +2108,32 @@
"scope": "window", "scope": "window",
"order": 11 "order": 11
}, },
"gitlens.graph.showDetailsView": {
"type": [
"boolean",
"string"
],
"default": "selection",
"enum": [
false,
"open",
"selection"
],
"enumDescriptions": [
"Never shows the _Commit Details_ view automatically",
"Shows the _Commit Details_ view automatically when the _Commit Graph_ is first opened",
"Shows the _Commit Details_ view automatically when selection changes in the _Commit Graph_"
],
"markdownDescription": "Specifies when to show the _Commit Details_ view for the selected row in the _Commit Graph_",
"scope": "window",
"order": 12
},
"gitlens.graph.showGhostRefsOnRowHover": { "gitlens.graph.showGhostRefsOnRowHover": {
"type": "boolean", "type": "boolean",
"default": true, "default": true,
"markdownDescription": "Specifies whether to show a ghost ref of the hovered/selected row in the _Commit Graph_",
"markdownDescription": "Specifies whether to show a ghost ref for the hovered/selected row in the _Commit Graph_",
"scope": "window", "scope": "window",
"order": 12
"order": 13
}, },
"gitlens.graph.defaultItemLimit": { "gitlens.graph.defaultItemLimit": {
"type": "number", "type": "number",

+ 1
- 1
src/commands/gitCommands.actions.ts View File

@ -768,7 +768,7 @@ export namespace GitActions {
export function showDetailsView( export function showDetailsView(
commit: GitRevisionReference | GitCommit, commit: GitRevisionReference | GitCommit,
options?: { pin?: boolean; preserveFocus?: boolean },
options?: { pin?: boolean; preserveFocus?: boolean; preserveVisibility?: boolean },
): Promise<void> { ): Promise<void> {
return Container.instance.commitDetailsView.show({ ...options, commit: commit }); return Container.instance.commitDetailsView.show({ ...options, commit: commit });
} }

+ 1
- 0
src/config.ts View File

@ -380,6 +380,7 @@ export interface GraphConfig {
dateStyle: DateStyle | null; dateStyle: DateStyle | null;
defaultItemLimit: number; defaultItemLimit: number;
highlightRowsOnRefHover: boolean; highlightRowsOnRefHover: boolean;
showDetailsView: 'open' | 'selection' | false;
showGhostRefsOnRowHover: boolean; showGhostRefsOnRowHover: boolean;
pageItemLimit: number; pageItemLimit: number;
searchItemLimit: number; searchItemLimit: number;

+ 3
- 1
src/env/node/git/localGitProvider.ts View File

@ -1664,6 +1664,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
); );
} }
const useAvatars = configuration.get('graph.avatars', undefined, true);
const avatars = new Map<string, string>(); const avatars = new Map<string, string>();
const ids = new Set<string>(); const ids = new Set<string>();
const reachableFromHEAD = new Set<string>(); const reachableFromHEAD = new Set<string>();
@ -1829,7 +1831,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
owner: remote.name, owner: remote.name,
url: remote.url, url: remote.url,
avatarUrl: ( avatarUrl: (
remote.provider?.avatarUri ??
(useAvatars ? remote.provider?.avatarUri : undefined) ??
getRemoteIconUri(this.container, remote, asWebviewUri) getRemoteIconUri(this.container, remote, asWebviewUri)
)?.toString(true), )?.toString(true),
context: serializeWebviewItemContext<GraphItemRefContext>({ context: serializeWebviewItemContext<GraphItemRefContext>({

+ 5
- 2
src/plus/github/githubGitProvider.ts View File

@ -1078,6 +1078,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
const defaultLimit = options?.limit ?? configuration.get('graph.defaultItemLimit') ?? 5000; const defaultLimit = options?.limit ?? configuration.get('graph.defaultItemLimit') ?? 5000;
// const defaultPageLimit = configuration.get('graph.pageItemLimit') ?? 1000; // const defaultPageLimit = configuration.get('graph.pageItemLimit') ?? 1000;
const ordering = configuration.get('graph.commitOrdering', undefined, 'date'); const ordering = configuration.get('graph.commitOrdering', undefined, 'date');
const useAvatars = configuration.get('graph.avatars', undefined, true);
const [logResult, branchResult, remotesResult, tagsResult, currentUserResult] = await Promise.allSettled([ const [logResult, branchResult, remotesResult, tagsResult, currentUserResult] = await Promise.allSettled([
this.getLog(repoPath, { all: true, ordering: ordering, limit: defaultLimit }), this.getLog(repoPath, { all: true, ordering: ordering, limit: defaultLimit }),
@ -1100,7 +1101,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
getSettledValue(currentUserResult), getSettledValue(currentUserResult),
avatars, avatars,
ids, ids,
options,
{ ...options, useAvatars: useAvatars },
); );
} }
@ -1119,6 +1120,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
limit?: number; limit?: number;
mode?: 'single' | 'local' | 'all'; mode?: 'single' | 'local' | 'all';
ref?: string; ref?: string;
useAvatars?: boolean;
}, },
): Promise<GitGraph> { ): Promise<GitGraph> {
if (log == null) { if (log == null) {
@ -1184,7 +1186,8 @@ export class GitHubGitProvider implements GitProvider, Disposable {
owner: remote.name, owner: remote.name,
url: remote.url, url: remote.url,
avatarUrl: ( avatarUrl: (
remote.provider?.avatarUri ?? getRemoteIconUri(this.container, remote, asWebviewUri)
(options?.useAvatars ? remote.provider?.avatarUri : undefined) ??
getRemoteIconUri(this.container, remote, asWebviewUri)
)?.toString(true), )?.toString(true),
context: serializeWebviewItemContext<GraphItemRefContext>({ context: serializeWebviewItemContext<GraphItemRefContext>({
webviewItem: 'gitlens:branch+remote', webviewItem: 'gitlens:branch+remote',

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

@ -28,6 +28,7 @@ import type {
} from '../../../commands'; } from '../../../commands';
import { parseCommandContext } from '../../../commands/base'; import { parseCommandContext } from '../../../commands/base';
import { GitActions } from '../../../commands/gitCommands.actions'; import { GitActions } from '../../../commands/gitCommands.actions';
import type { Config } from '../../../configuration';
import { configuration } from '../../../configuration'; import { configuration } from '../../../configuration';
import { Commands, ContextKeys, CoreGitCommands } from '../../../constants'; import { Commands, ContextKeys, CoreGitCommands } from '../../../constants';
import type { Container } from '../../../container'; import type { Container } from '../../../container';
@ -185,6 +186,7 @@ export class GraphWebview extends WebviewBase {
private _etagSubscription?: number; private _etagSubscription?: number;
private _etagRepository?: number; private _etagRepository?: number;
private _firstSelection = true;
private _graph?: GitGraph; private _graph?: GitGraph;
private _pendingIpcNotifications = new Map<IpcNotificationType, IpcMessage | (() => Promise<boolean>)>(); private _pendingIpcNotifications = new Map<IpcNotificationType, IpcMessage | (() => Promise<boolean>)>();
private _refsMetadata: Map<string, GraphRefMetadata | null> | null | undefined; private _refsMetadata: Map<string, GraphRefMetadata | null> | null | undefined;
@ -192,10 +194,10 @@ export class GraphWebview extends WebviewBase {
private _searchCancellation: CancellationTokenSource | undefined; private _searchCancellation: CancellationTokenSource | undefined;
private _selectedId?: string; private _selectedId?: string;
private _selectedRows: GraphSelectedRows | undefined; private _selectedRows: GraphSelectedRows | undefined;
private _repositoryEventsDisposable: Disposable | undefined;
private _showDetailsView: Config['graph']['showDetailsView'];
private _statusBarItem: StatusBarItem | undefined; private _statusBarItem: StatusBarItem | undefined;
private _theme: ColorTheme | undefined; private _theme: ColorTheme | undefined;
private _repositoryEventsDisposable: Disposable | undefined;
private previewBanner?: boolean; private previewBanner?: boolean;
private trialBanner?: boolean; private trialBanner?: boolean;
@ -210,6 +212,9 @@ export class GraphWebview extends WebviewBase {
'graphWebview', 'graphWebview',
Commands.ShowGraphPage, Commands.ShowGraphPage,
); );
this._showDetailsView = configuration.get('graph.showDetailsView');
this.disposables.push( this.disposables.push(
configuration.onDidChange(this.onConfigurationChanged, this), configuration.onDidChange(this.onConfigurationChanged, this),
once(container.onReady)(() => queueMicrotask(() => this.updateStatusBar())), once(container.onReady)(() => queueMicrotask(() => this.updateStatusBar())),
@ -260,6 +265,7 @@ export class GraphWebview extends WebviewBase {
} }
override async show(options?: { column?: ViewColumn; preserveFocus?: boolean }, ...args: unknown[]): Promise<void> { override async show(options?: { column?: ViewColumn; preserveFocus?: boolean }, ...args: unknown[]): Promise<void> {
this._firstSelection = true;
if (!(await ensurePlusFeaturesEnabled())) return; if (!(await ensurePlusFeaturesEnabled())) return;
if (this.container.git.repositoryCount > 1) { if (this.container.git.repositoryCount > 1) {
@ -412,7 +418,11 @@ export class GraphWebview extends WebviewBase {
setTimeout(() => void setContext(ContextKeys.GraphPageFocused, focused), 0); setTimeout(() => void setContext(ContextKeys.GraphPageFocused, focused), 0);
if (this.selection != null) { if (this.selection != null) {
void GitActions.Commit.showDetailsView(this.selection[0], { pin: true, preserveFocus: true });
void GitActions.Commit.showDetailsView(this.selection[0], {
pin: true,
preserveFocus: true,
preserveVisibility: this._showDetailsView === false,
});
} }
return; return;
@ -433,6 +443,10 @@ export class GraphWebview extends WebviewBase {
} }
private onConfigurationChanged(e: ConfigurationChangeEvent) { private onConfigurationChanged(e: ConfigurationChangeEvent) {
if (configuration.changed(e, 'graph.showDetailsView')) {
this._showDetailsView = configuration.get('graph.showDetailsView');
}
if (configuration.changed(e, 'graph.statusBar.enabled') || configuration.changed(e, 'plusFeatures.enabled')) { if (configuration.changed(e, 'graph.statusBar.enabled') || configuration.changed(e, 'plusFeatures.enabled')) {
this.updateStatusBar(); this.updateStatusBar();
} }
@ -812,7 +826,14 @@ export class GraphWebview extends WebviewBase {
if (commits == null) return; if (commits == null) return;
void GitActions.Commit.showDetailsView(commits[0], { pin: true, preserveFocus: true });
void GitActions.Commit.showDetailsView(commits[0], {
pin: true,
preserveFocus: true,
preserveVisibility: this._firstSelection
? this._showDetailsView === false
: this._showDetailsView !== 'selection',
});
this._firstSelection = false;
} }
private _notifyDidChangeStateDebounced: Deferrable<GraphWebview['notifyDidChangeState']> | undefined = undefined; private _notifyDidChangeStateDebounced: Deferrable<GraphWebview['notifyDidChangeState']> | undefined = undefined;

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

@ -76,6 +76,30 @@
</div> </div>
<div class="setting"> <div class="setting">
<div class="setting__input setting__input--inner-select">
<input
id="graph.showDetailsView"
name="graph.showDetailsView"
type="checkbox"
value="selection"
data-setting
/>
<label for="graph.showDetailsView">Show the Commit Details view</label>
<div class="select-container">
<select
id="graph.showDetailsView"
name="graph.showDetailsView"
data-setting
data-enablement="graph.showDetailsView !false"
>
<option value="open">when first opened</option>
<option value="selection">when selection changes (default)</option>
</select>
</div>
</div>
</div>
<div class="setting">
<div class="setting__input"> <div class="setting__input">
<input <input
id="graph.showGhostRefsOnRowHover" id="graph.showGhostRefsOnRowHover"

+ 3
- 0
src/webviews/commitDetails/commitDetailsWebviewView.ts View File

@ -113,6 +113,7 @@ export class CommitDetailsWebviewView extends WebviewViewBase
commit?: GitRevisionReference | GitCommit; commit?: GitRevisionReference | GitCommit;
pin?: boolean; pin?: boolean;
preserveFocus?: boolean | undefined; preserveFocus?: boolean | undefined;
preserveVisibility?: boolean | undefined;
}): Promise<void> { }): Promise<void> {
if (options != null) { if (options != null) {
let commit; let commit;
@ -134,6 +135,8 @@ export class CommitDetailsWebviewView extends WebviewViewBase
} }
} }
if (options?.preserveVisibility) return;
return super.show(options); return super.show(options);
} }

Loading…
Cancel
Save