Skip to content

Commit 139fb69

Browse files
committed
Adds commit with AI button in Inspect view
1 parent 378677b commit 139fb69

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

src/webviews/apps/commitDetails/components/gl-details-base.ts

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { TemplateResult } from 'lit';
22
import { html, LitElement } from 'lit';
33
import { property } from 'lit/decorators.js';
4-
import { when } from 'lit/directives/when.js';
54
import type { TextDocumentShowOptions } from 'vscode';
65
import type { ViewFilesLayout } from '../../../../config';
76
import type { HierarchicalItem } from '../../../../system/array';
87
import { makeHierarchical } from '../../../../system/array';
8+
import { createCommandLink } from '../../../../system/commands';
99
import { pluralize } from '../../../../system/string';
1010
import type { Preferences, State } from '../../../commitDetails/protocol';
1111
import type {
@@ -103,24 +103,49 @@ export class GlDetailsBase extends LitElement {
103103
icon="${icon}"
104104
></action-item>
105105
</action-nav>
106-
${when(
107-
fileCount > 0 && this.tab === 'wip',
108-
() =>
109-
html`<div class="section section--actions">
110-
<p class="button-container">
111-
<span class="button-group button-group--single">
112-
<gl-button full href="command:workbench.view.scm"
113-
>Commit via SCM <code-icon rotate="45" icon="arrow-up" slot="suffix"></code-icon
114-
></gl-button>
115-
</span>
116-
</p>
117-
</div>`,
118-
)}
119-
${this.renderTreeFileModel(treeModel)}
106+
${this.renderChangedFilesActions()} ${this.renderTreeFileModel(treeModel)}
120107
</webview-pane>
121108
`;
122109
}
123110

111+
protected renderChangedFilesActions(): TemplateResult<1> | undefined {
112+
if (this.tab !== 'wip' || !this.files?.length) return undefined;
113+
114+
if (this.preferences?.aiEnabled) {
115+
return html`<div class="section section--actions">
116+
<p class="button-container">
117+
<span class="button-group button-group--single">
118+
<gl-button
119+
full
120+
.href=${createCommandLink('gitlens.ai.generateCommits', {
121+
122+
})}
123+
tooltip="Generate Commits with AI (Preview) — organize working changes into meaningful commits"
124+
.tooltipPlacement=${'top'}
125+
>Commit with AI (Preview)<code-icon icon="sparkle" slot="prefix"></code-icon
126+
></gl-button>
127+
</span>
128+
</p>
129+
<p class="button-container">
130+
<span class="button-group button-group--single">
131+
<gl-button appearance="secondary" full href="command:workbench.view.scm"
132+
>Commit via SCM <code-icon rotate="45" icon="arrow-up" slot="prefix"></code-icon
133+
></gl-button>
134+
</span>
135+
</p>
136+
</div>`;
137+
}
138+
return html`<div class="section section--actions">
139+
<p class="button-container">
140+
<span class="button-group button-group--single">
141+
<gl-button full href="command:workbench.view.scm"
142+
>Commit via SCM <code-icon rotate="45" icon="arrow-up" slot="suffix"></code-icon
143+
></gl-button>
144+
</span>
145+
</p>
146+
</div>`;
147+
}
148+
124149
protected onShareWipChanges(_e: Event, staged: boolean, hasFiles: boolean): void {
125150
if (!hasFiles) return;
126151
const event = new CustomEvent('share-wip', {

0 commit comments

Comments
 (0)