Skip to content

Commit

Permalink
Adds feature #3297 - Setting for compact graph
Browse files Browse the repository at this point in the history
  • Loading branch information
TJohnsonSE committed May 17, 2024
1 parent 1cc51d9 commit 16647ce
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2772,6 +2772,13 @@
"scope": "window",
"order": 27
},
"gitlens.graph.useCompactByDefault": {
"type": "boolean",
"default": false,
"markdownDescription": "Specifies whether to default to using the compact graph layout in the _Commit Graph_",
"scope": "window",
"order": 28
},
"gitlens.graph.commitOrdering": {
"type": "string",
"default": "date",
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ export interface GraphConfig {
readonly additionalTypes: GraphMinimapMarkersAdditionalTypes[];
};
readonly highlightRowsOnRefHover: boolean;
readonly useCompactByDefault: boolean;
readonly layout: 'editor' | 'panel';
readonly scrollRowPadding: number;
readonly showDetailsView: 'open' | 'selection' | false;
Expand Down
6 changes: 6 additions & 0 deletions src/plus/webviews/graph/graphWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
const columnsSettings: GraphColumnsSettings = {
...defaultGraphColumnsSettings,
};

if (columns != null) {
for (const [column, columnCfg] of Object.entries(columns) as [GraphColumnName, GraphColumnConfig][]) {
columnsSettings[column] = {
Expand All @@ -1770,6 +1771,10 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
}
}

if (this._graph == undefined && this.getComponentConfig().useCompactByDefault && this._firstSelection) {
void this.setColumnMode('graph', 'compact');
}

return columnsSettings;
}

Expand Down Expand Up @@ -1851,6 +1856,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
showGhostRefsOnRowHover: configuration.get('graph.showGhostRefsOnRowHover'),
showRemoteNamesOnRefs: configuration.get('graph.showRemoteNames'),
idLength: configuration.get('advanced.abbreviatedShaLength'),
useCompactByDefault: configuration.get('graph.useCompactByDefault'),
};
return config;
}
Expand Down
1 change: 1 addition & 0 deletions src/plus/webviews/graph/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export interface GraphComponentConfig {
showGhostRefsOnRowHover?: boolean;
showRemoteNamesOnRefs?: boolean;
idLength?: number;
useCompactByDefault?: boolean;
}

export interface GraphColumnConfig {
Expand Down
12 changes: 12 additions & 0 deletions src/webviews/apps/settings/partials/commit-graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ <h2>
</p>
</div>

<div class="setting">
<div class="setting__input">
<input
id="graph.useCompactByDefault"
name="graph.useCompactByDefault"
type="checkbox"
data-setting
/>
<label for="graph.useCompactByDefault">Use compact graph view by default</label>
</div>
</div>

<div class="setting">
<div class="setting__input">
<input id="graph.avatars" name="graph.avatars" type="checkbox" data-setting />
Expand Down

0 comments on commit 16647ce

Please sign in to comment.