Browse Source

Add "dim merge commit rows" to filter dropdown (#2403)

* Update naming, add to filter dropdown

* Show filter indicator if checked
main
Ramin Tadayon 2 years ago
committed by GitHub
parent
commit
365997ec72
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 5 deletions
  1. +1
    -1
      package.json
  2. +9
    -0
      src/plus/webviews/graph/graphWebview.ts
  3. +5
    -0
      src/plus/webviews/graph/protocol.ts
  4. +21
    -3
      src/webviews/apps/plus/graph/GraphWrapper.tsx
  5. +8
    -0
      src/webviews/apps/plus/graph/graph.tsx
  6. +1
    -1
      src/webviews/apps/settings/partials/commit-graph.html

+ 1
- 1
package.json View File

@ -2239,7 +2239,7 @@
"gitlens.graph.dimMergeCommits": {
"type": "boolean",
"default": false,
"markdownDescription": "Specifies whether to always dim rows with merge commits in the _Commit Graph_",
"markdownDescription": "Specifies whether to dim rows with merge commits in the _Commit Graph_",
"scope": "window",
"order": 25
},

+ 9
- 0
src/plus/webviews/graph/graphWebview.ts View File

@ -75,6 +75,7 @@ import { WebviewBase } from '../../../webviews/webviewBase';
import type { SubscriptionChangeEvent } from '../../subscription/subscriptionService';
import { arePlusFeaturesEnabled, ensurePlusFeaturesEnabled } from '../../subscription/utils';
import type {
DimMergeCommitsParams,
DismissBannerParams,
DoubleClickedRefParams,
EnsureRowParams,
@ -121,6 +122,7 @@ import {
DidEnsureRowNotificationType,
DidFetchNotificationType,
DidSearchNotificationType,
DimMergeCommitsCommandType,
DismissBannerCommandType,
DoubleClickedRefCommandType,
EnsureRowCommandType,
@ -404,6 +406,9 @@ export class GraphWebview extends WebviewBase {
protected override onMessageReceived(e: IpcMessage) {
switch (e.method) {
case DimMergeCommitsCommandType.method:
onIpc(DimMergeCommitsCommandType, e, params => this.dimMergeCommits(params));
break;
case DismissBannerCommandType.method:
onIpc(DismissBannerCommandType, e, params => this.dismissBanner(params));
break;
@ -597,6 +602,10 @@ export class GraphWebview extends WebviewBase {
this.updateState();
}
private dimMergeCommits(e: DimMergeCommitsParams) {
void configuration.updateEffective('graph.dimMergeCommits', e.dim);
}
private dismissBanner(e: DismissBannerParams) {
if (e.key === 'trial') {
this.trialBanner = false;

+ 5
- 0
src/plus/webviews/graph/protocol.ts View File

@ -141,6 +141,11 @@ export interface UpdateStateCallback {
}
// Commands
export interface DimMergeCommitsParams {
dim: boolean;
}
export const DimMergeCommitsCommandType = new IpcCommandType<DimMergeCommitsParams>('graph/dimMergeCommits');
export interface DismissBannerParams {
key: 'preview' | 'trial';
}

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

@ -67,6 +67,7 @@ export interface GraphWrapperProps {
subscriber: (callback: UpdateStateCallback) => () => void;
onSelectRepository?: (repository: GraphRepository) => void;
onColumnsChange?: (colsSettings: GraphColumnsConfig) => void;
onDimMergeCommits?: (dim: boolean) => void;
onDoubleClickRef?: (ref: GraphRef) => void;
onMissingAvatars?: (emails: { [email: string]: string }) => void;
onMissingRefsMetadata?: (metadata: GraphMissingRefsMetadata) => void;
@ -141,6 +142,7 @@ export function GraphWrapper({
state,
onSelectRepository,
onColumnsChange,
onDimMergeCommits,
onDoubleClickRef,
onEnsureRowPromise,
onMissingAvatars,
@ -337,6 +339,10 @@ export function GraphWrapper({
return true;
}
if (graphConfig?.dimMergeCommits) {
return true;
}
if (excludeTypes == null) {
return false;
}
@ -491,11 +497,14 @@ export function GraphWrapper({
const value = $el.value;
const isLocalBranches = ['branch-all', 'branch-current'].includes(value);
if (!isLocalBranches && !['remotes', 'stashes', 'tags'].includes(value)) return;
const key = value as keyof GraphExcludeTypes;
if (!isLocalBranches && !['remotes', 'stashes', 'tags', 'mergeCommits'].includes(value)) return;
const isChecked = $el.checked;
if (value === 'mergeCommits') {
onDimMergeCommits?.(isChecked);
return;
}
const key = value as keyof GraphExcludeTypes;
const currentFilter = excludeTypes?.[key];
if ((currentFilter == null && isChecked) || (currentFilter != null && currentFilter !== isChecked)) {
setExcludeTypes({
@ -925,6 +934,15 @@ export function GraphWrapper({
Hide Tags
</VSCodeCheckbox>
</MenuItem>
<MenuItem role="none">
<VSCodeCheckbox
value="mergeCommits"
onChange={handleExcludeTypeChange}
defaultChecked={graphConfig?.dimMergeCommits ?? false}
>
Dim Merge Commit Rows
</VSCodeCheckbox>
</MenuItem>
</MenuList>
</PopMenu>
<span>

+ 8
- 0
src/webviews/apps/plus/graph/graph.tsx View File

@ -30,6 +30,7 @@ import {
DidEnsureRowNotificationType,
DidFetchNotificationType,
DidSearchNotificationType,
DimMergeCommitsCommandType,
DismissBannerCommandType,
DoubleClickedRefCommandType,
EnsureRowCommandType,
@ -91,6 +92,7 @@ export class GraphApp extends App {
settings => this.onColumnsChanged(settings),
250,
)}
onDimMergeCommits={dim => this.onDimMergeCommits(dim)}
onRefsVisibilityChange={(refs: GraphExcludedRef[], visible: boolean) =>
this.onRefsVisibilityChanged(refs, visible)
}
@ -412,6 +414,12 @@ export class GraphApp extends App {
});
}
private onDimMergeCommits(dim: boolean) {
this.sendCommand(DimMergeCommitsCommandType, {
dim: dim,
});
}
private onDoubleClickRef(ref: GraphRef) {
this.sendCommand(DoubleClickedRefCommandType, {
ref: ref,

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

@ -141,7 +141,7 @@
data-setting
/>
<label for="graph.dimMergeCommits"
>Always dim merge commit rows</label
>Dim merge commit rows</label
>
</div>
</div>

Loading…
Cancel
Save