Skip to content

Commit 7559167

Browse files
committed
Adds ai entitlements to inspect overview actions
1 parent 139fb69 commit 7559167

File tree

2 files changed

+48
-42
lines changed

2 files changed

+48
-42
lines changed

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

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { TextDocumentShowOptions } from 'vscode';
55
import type { ViewFilesLayout } from '../../../../config';
66
import type { HierarchicalItem } from '../../../../system/array';
77
import { makeHierarchical } from '../../../../system/array';
8-
import { createCommandLink } from '../../../../system/commands';
98
import { pluralize } from '../../../../system/string';
109
import type { Preferences, State } from '../../../commitDetails/protocol';
1110
import type {
@@ -44,6 +43,9 @@ export class GlDetailsBase extends LitElement {
4443
@property({ type: Object })
4544
preferences?: Preferences;
4645

46+
@property({ type: Object })
47+
orgSettings?: State['orgSettings'];
48+
4749
@property({ attribute: 'empty-text' })
4850
emptyText? = 'No Files';
4951

@@ -103,47 +105,13 @@ export class GlDetailsBase extends LitElement {
103105
icon="${icon}"
104106
></action-item>
105107
</action-nav>
106-
${this.renderChangedFilesActions()} ${this.renderTreeFileModel(treeModel)}
108+
${this.renderChangedFilesActions()}${this.renderTreeFileModel(treeModel)}
107109
</webview-pane>
108110
`;
109111
}
110112

111113
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>`;
114+
return undefined;
147115
}
148116

149117
protected onShareWipChanges(_e: Event, staged: boolean, hasFiles: boolean): void {

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

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Avatar, defineGkElement } from '@gitkraken/shared-web-components';
2-
import type { PropertyValueMap } from 'lit';
2+
import type { PropertyValueMap, TemplateResult } from 'lit';
33
import { css, html, nothing } from 'lit';
44
import { customElement, property, state } from 'lit/decorators.js';
55
import { repeat } from 'lit/directives/repeat.js';
66
import { when } from 'lit/directives/when.js';
7+
import type { GenerateCommitsCommandArgs } from '../../../../commands/generateRebase';
8+
import { createCommandLink } from '../../../../system/commands';
79
import { equalsIgnoreCase } from '../../../../system/string';
8-
import type { DraftState, State, Wip } from '../../../commitDetails/protocol';
10+
import type { DraftState, Wip } from '../../../commitDetails/protocol';
911
import type { TreeItemAction, TreeItemBase } from '../../shared/components/tree/base';
1012
import type { File } from './gl-details-base';
1113
import { GlDetailsBase } from './gl-details-base';
@@ -30,9 +32,6 @@ export class GlWipDetails extends GlDetailsBase {
3032
@property({ type: Object })
3133
wip?: Wip;
3234

33-
@property({ type: Object })
34-
orgSettings?: State['orgSettings'];
35-
3635
@property({ type: Object })
3736
draftState?: DraftState;
3837

@@ -123,6 +122,45 @@ export class GlWipDetails extends GlDetailsBase {
123122
return 'Working Changes';
124123
}
125124

125+
protected override renderChangedFilesActions(): TemplateResult<1> | undefined {
126+
if (!this.files?.length) return undefined;
127+
128+
if (this.preferences?.aiEnabled && this.orgSettings?.ai) {
129+
return html`<div class="section section--actions">
130+
<p class="button-container">
131+
<span class="button-group button-group--single">
132+
<gl-button
133+
full
134+
.href=${createCommandLink('gitlens.ai.generateCommits', {
135+
repoPath: this.wip?.repo.path,
136+
source: { source: 'inspect' },
137+
} as GenerateCommitsCommandArgs)}
138+
tooltip="Generate Commits with AI (Preview) — organize working changes into meaningful commits"
139+
.tooltipPlacement=${'top'}
140+
>Commit with AI (Preview)<code-icon icon="sparkle" slot="prefix"></code-icon
141+
></gl-button>
142+
</span>
143+
</p>
144+
<p class="button-container">
145+
<span class="button-group button-group--single">
146+
<gl-button appearance="secondary" full href="command:workbench.view.scm"
147+
>Commit via SCM <code-icon rotate="45" icon="arrow-up" slot="prefix"></code-icon
148+
></gl-button>
149+
</span>
150+
</p>
151+
</div>`;
152+
}
153+
return html`<div class="section section--actions">
154+
<p class="button-container">
155+
<span class="button-group button-group--single">
156+
<gl-button full href="command:workbench.view.scm"
157+
>Commit via SCM <code-icon rotate="45" icon="arrow-up" slot="suffix"></code-icon
158+
></gl-button>
159+
</span>
160+
</p>
161+
</div>`;
162+
}
163+
126164
private renderSecondaryAction() {
127165
if (!this.draftsEnabled || this.inReview) return undefined;
128166

0 commit comments

Comments
 (0)