瀏覽代碼

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 年之前
父節點
當前提交
fe0b6b0dd9
共有 8 個文件被更改,包括 85 次插入11 次删除
  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 查看文件

@ -2097,7 +2097,7 @@
"gitlens.graph.avatars": {
"type": "boolean",
"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",
"order": 10
},
@ -2108,12 +2108,32 @@
"scope": "window",
"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": {
"type": "boolean",
"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",
"order": 12
"order": 13
},
"gitlens.graph.defaultItemLimit": {
"type": "number",

+ 1
- 1
src/commands/gitCommands.actions.ts 查看文件

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

+ 1
- 0
src/config.ts 查看文件

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

+ 3
- 1
src/env/node/git/localGitProvider.ts 查看文件

@ -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 ids = new Set<string>();
const reachableFromHEAD = new Set<string>();
@ -1829,7 +1831,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
owner: remote.name,
url: remote.url,
avatarUrl: (
remote.provider?.avatarUri ??
(useAvatars ? remote.provider?.avatarUri : undefined) ??
getRemoteIconUri(this.container, remote, asWebviewUri)
)?.toString(true),
context: serializeWebviewItemContext<GraphItemRefContext>({

+ 5
- 2
src/plus/github/githubGitProvider.ts 查看文件

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

+ 25
- 4
src/plus/webviews/graph/graphWebview.ts 查看文件

@ -28,6 +28,7 @@ import type {
} from '../../../commands';
import { parseCommandContext } from '../../../commands/base';
import { GitActions } from '../../../commands/gitCommands.actions';
import type { Config } from '../../../configuration';
import { configuration } from '../../../configuration';
import { Commands, ContextKeys, CoreGitCommands } from '../../../constants';
import type { Container } from '../../../container';
@ -185,6 +186,7 @@ export class GraphWebview extends WebviewBase {
private _etagSubscription?: number;
private _etagRepository?: number;
private _firstSelection = true;
private _graph?: GitGraph;
private _pendingIpcNotifications = new Map<IpcNotificationType, IpcMessage | (() => Promise<boolean>)>();
private _refsMetadata: Map<string, GraphRefMetadata | null> | null | undefined;
@ -192,10 +194,10 @@ export class GraphWebview extends WebviewBase {
private _searchCancellation: CancellationTokenSource | undefined;
private _selectedId?: string;
private _selectedRows: GraphSelectedRows | undefined;
private _repositoryEventsDisposable: Disposable | undefined;
private _showDetailsView: Config['graph']['showDetailsView'];
private _statusBarItem: StatusBarItem | undefined;
private _theme: ColorTheme | undefined;
private _repositoryEventsDisposable: Disposable | undefined;
private previewBanner?: boolean;
private trialBanner?: boolean;
@ -210,6 +212,9 @@ export class GraphWebview extends WebviewBase {
'graphWebview',
Commands.ShowGraphPage,
);
this._showDetailsView = configuration.get('graph.showDetailsView');
this.disposables.push(
configuration.onDidChange(this.onConfigurationChanged, this),
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> {
this._firstSelection = true;
if (!(await ensurePlusFeaturesEnabled())) return;
if (this.container.git.repositoryCount > 1) {
@ -412,7 +418,11 @@ export class GraphWebview extends WebviewBase {
setTimeout(() => void setContext(ContextKeys.GraphPageFocused, focused), 0);
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;
@ -433,6 +443,10 @@ export class GraphWebview extends WebviewBase {
}
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')) {
this.updateStatusBar();
}
@ -812,7 +826,14 @@ export class GraphWebview extends WebviewBase {
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;

+ 24
- 0
src/webviews/apps/settings/partials/commit-graph.html 查看文件

@ -76,6 +76,30 @@
</div>
<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">
<input
id="graph.showGhostRefsOnRowHover"

+ 3
- 0
src/webviews/commitDetails/commitDetailsWebviewView.ts 查看文件

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

Loading…
取消
儲存