Skip to content

Commit 4392e4e

Browse files
committed
Moves secondary actions to menu in home active section
1 parent 1846f8d commit 4392e4e

File tree

5 files changed

+78
-35
lines changed

5 files changed

+78
-35
lines changed

src/webviews/apps/plus/home/components/active-work.ts

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import '../../../shared/components/skeleton-loader';
2626
import '../../../shared/components/card/card';
2727
import '../../../shared/components/commit/commit-stats';
2828
import '../../../shared/components/menu/menu-item';
29+
import '../../../shared/components/menu/menu-label';
2930
import '../../../shared/components/overlays/popover';
3031
import '../../../shared/components/overlays/tooltip';
3132
import '../../../shared/components/pills/tracking';
@@ -62,6 +63,10 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
6263
.uppercase {
6364
text-transform: uppercase;
6465
}
66+
67+
menu-item {
68+
margin-inline: 0.5rem;
69+
}
6570
`,
6671
];
6772

@@ -250,14 +255,67 @@ export class GlActiveBranchCard extends GlBranchCardBase {
250255
`;
251256
}
252257

258+
private renderActionsMenu() {
259+
const aiEnabled = this._homeState.orgSettings.ai && this._homeState.aiEnabled;
260+
const isFetching = this.busy;
261+
const workingTreeState = this.wip?.workingTreeState;
262+
const hasWip =
263+
workingTreeState != null &&
264+
workingTreeState.added + workingTreeState.changed + workingTreeState.deleted > 0;
265+
266+
const actions = [];
267+
268+
if (hasWip && aiEnabled) {
269+
actions.push(
270+
html`<menu-item ?disabled=${isFetching} href=${this.createCommandLink('gitlens.ai.explainWip:home')}
271+
>Explain Working Changes (Preview)</menu-item
272+
>`,
273+
);
274+
}
275+
276+
if (aiEnabled) {
277+
actions.push(
278+
html`<menu-item ?disabled=${isFetching} href=${this.createCommandLink('gitlens.ai.explainBranch:home')}
279+
>Explain Branch (Preview)</menu-item
280+
>`,
281+
);
282+
}
283+
284+
if (hasWip) {
285+
actions.push(
286+
html`<menu-item ?disabled=${isFetching} href=${this.createCommandLink('gitlens.home.createCloudPatch')}
287+
>Share as Cloud Patch</menu-item
288+
>`,
289+
);
290+
}
291+
292+
if (actions.length === 0) return undefined;
293+
294+
return html`<gl-popover
295+
appearance="menu"
296+
trigger="click focus"
297+
placement="bottom-end"
298+
.arrow=${false}
299+
distance="0"
300+
>
301+
<gl-button slot="anchor" appearance="toolbar" tooltipPlacement="top" tooltip="Additional Actions">
302+
<code-icon icon="ellipsis"></code-icon>
303+
</gl-button>
304+
<div slot="content">
305+
<menu-label>Actions</menu-label>
306+
${actions}
307+
</div>
308+
</gl-popover>`;
309+
}
310+
253311
private renderBranchStateActions() {
254312
const { name, upstream } = this.branch;
255313

256314
const actions: TemplateResult[] = [];
257315

258316
const wrappedActions = () => {
259-
if (actions.length === 0) return undefined;
260-
return html`<div><button-container>${actions}</button-container></div>`;
317+
if (actions.length === 0) return this.renderActionsMenu();
318+
return html`<div><button-container>${actions}${this.renderActionsMenu()}</button-container></div>`;
261319
};
262320

263321
const isFetching = this.busy;
@@ -280,40 +338,8 @@ export class GlActiveBranchCard extends GlBranchCardBase {
280338
tooltip="Generate Message &amp; Commit..."
281339
><code-icon icon="sparkle" slot="prefix"></code-icon>Commit
282340
</gl-button>
283-
<gl-button
284-
aria-busy=${ifDefined(isFetching)}
285-
?disabled=${isFetching}
286-
href=${this.createCommandLink('gitlens.ai.explainWip:home')}
287-
appearance="secondary"
288-
tooltip="Explain Working Changes (Preview)"
289-
><code-icon icon="sparkle" slot="prefix"></code-icon>WIP
290-
</gl-button>
291341
`);
292342
}
293-
294-
actions.push(html`
295-
<gl-button
296-
aria-busy=${ifDefined(isFetching)}
297-
?disabled=${isFetching}
298-
href=${this.createCommandLink('gitlens.home.createCloudPatch')}
299-
appearance="secondary"
300-
tooltip="Share as Cloud Patch"
301-
><code-icon icon="gl-cloud-patch-share"></code-icon>
302-
</gl-button>
303-
`);
304-
}
305-
306-
if (this._homeState.orgSettings.ai && this._homeState.aiEnabled) {
307-
actions.push(html`
308-
<gl-button
309-
aria-busy=${ifDefined(isFetching)}
310-
?disabled=${isFetching}
311-
href=${this.createCommandLink('gitlens.ai.explainBranch:home')}
312-
appearance="secondary"
313-
tooltip="Explain Branch (Preview)"
314-
><code-icon icon="sparkle" slot="prefix"></code-icon>Branch
315-
</gl-button>
316-
`);
317343
}
318344

319345
if (this.wip?.pausedOpStatus != null) {

src/webviews/apps/plus/home/components/branch-card.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ import '../../../shared/components/branch-icon';
4646
import './merge-target-status';
4747

4848
export const branchCardStyles = css`
49+
* {
50+
box-sizing: border-box;
51+
}
52+
4953
gl-avatar-list {
5054
--gl-avatar-size: 2.4rem;
5155
margin-block: -0.4rem;

src/webviews/apps/shared/components/menu/menu-item.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export class MenuItem extends LitElement {
1919
text-align: left;
2020
height: auto;
2121
line-height: 2.2rem;
22+
-webkit-font-smoothing: auto;
23+
border-radius: var(--menu-item-radius, 0.3rem);
2224
}
2325
2426
:host([role='option']:hover) {

src/webviews/apps/shared/components/menu/menu-label.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class MenuLabel extends LitElement {
1818
color: var(--vscode-menu-foreground);
1919
opacity: 0.6;
2020
user-select: none;
21+
-webkit-font-smoothing: auto;
2122
}
2223
`,
2324
];

src/webviews/apps/shared/components/overlays/popover.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ export class GlPopover extends GlElement {
173173
width: max-content;
174174
}
175175
176+
:host([appearance='menu']) {
177+
--sl-tooltip-padding: 0 var(--sl-spacing-2x-small) var(--sl-spacing-2x-small);
178+
--sl-tooltip-font-size: var(--vscode-font-size);
179+
--sl-tooltip-background-color: var(--vscode-menu-background);
180+
--arrow-color: var(--vscode-menu-background);
181+
}
182+
176183
/* .popover::part(hover-bridge) {
177184
background: tomato;
178185
opacity: 1;
@@ -223,6 +230,9 @@ export class GlPopover extends GlElement {
223230
@property({ type: Boolean })
224231
hoist = false;
225232

233+
@property({ reflect: true })
234+
appearance?: 'menu';
235+
226236
get currentPlacement(): SlPopup['placement'] {
227237
return (this.popup?.getAttribute('data-current-placement') ?? this.placement) as SlPopup['placement'];
228238
}
@@ -290,7 +300,7 @@ export class GlPopover extends GlElement {
290300
<div
291301
part="body"
292302
id="popover"
293-
class="popover__body scrollable"
303+
class="popover__body scrollable ${this.appearance === 'menu' ? 'is-menu' : ''}"
294304
role="tooltip"
295305
aria-live=${this.open ? 'polite' : 'off'}
296306
>

0 commit comments

Comments
 (0)