|
1 | 1 | import type { TemplateResult } from 'lit';
|
2 | 2 | import { html, LitElement } from 'lit';
|
3 | 3 | import { property } from 'lit/decorators.js';
|
4 |
| -import { when } from 'lit/directives/when.js'; |
5 | 4 | import type { TextDocumentShowOptions } from 'vscode';
|
6 | 5 | import type { ViewFilesLayout } from '../../../../config';
|
7 | 6 | import type { HierarchicalItem } from '../../../../system/array';
|
8 | 7 | import { makeHierarchical } from '../../../../system/array';
|
| 8 | +import { createCommandLink } from '../../../../system/commands'; |
9 | 9 | import { pluralize } from '../../../../system/string';
|
10 | 10 | import type { Preferences, State } from '../../../commitDetails/protocol';
|
11 | 11 | import type {
|
@@ -103,24 +103,49 @@ export class GlDetailsBase extends LitElement {
|
103 | 103 | icon="${icon}"
|
104 | 104 | ></action-item>
|
105 | 105 | </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)} |
120 | 107 | </webview-pane>
|
121 | 108 | `;
|
122 | 109 | }
|
123 | 110 |
|
| 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 | + |
124 | 149 | protected onShareWipChanges(_e: Event, staged: boolean, hasFiles: boolean): void {
|
125 | 150 | if (!hasFiles) return;
|
126 | 151 | const event = new CustomEvent('share-wip', {
|
|
0 commit comments