Skip to content

Commit 180c436

Browse files
committed
Closes #4083 shows switch and open worktree actions when collapsed
1 parent d6649d6 commit 180c436

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,8 @@ export class GlActiveBranchCard extends GlBranchCardBase {
399399
></action-item>`,
400400
];
401401
}
402+
403+
protected getCollapsedActions(): TemplateResult[] {
404+
return [];
405+
}
402406
}

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

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,17 @@ export const branchCardStyles = css`
130130
gap: 0.6rem;
131131
}
132132
133-
/*
134-
.branch-item__actions {
133+
.branch-item__collapsed-actions {
135134
position: absolute;
136135
right: 0.4rem;
137136
bottom: 0.4rem;
138137
padding: 0.2rem 0.4rem;
139138
background-color: var(--gl-card-hover-background);
140139
}
141140
142-
.branch-item:not(:focus-within):not(:hover) .branch-item__actions {
141+
.branch-item:not(:focus-within):not(:hover) .branch-item__collapsed-actions {
143142
${srOnlyStyles}
144143
}
145-
*/
146144
147145
.pill {
148146
--gl-pill-border: color-mix(in srgb, transparent 80%, var(--color-foreground));
@@ -623,6 +621,16 @@ export abstract class GlBranchCardBase extends GlElement {
623621
return html`<action-nav>${actions}</action-nav>`;
624622
}
625623

624+
protected abstract getCollapsedActions(): TemplateResult[];
625+
protected renderCollapsedActions(): TemplateResult | NothingType {
626+
if (this.expanded) return nothing;
627+
628+
const actions = this.getCollapsedActions?.();
629+
if (!actions?.length) return nothing;
630+
631+
return html`<action-nav class="branch-item__collapsed-actions">${actions}</action-nav>`;
632+
}
633+
626634
protected createCommandLink<T>(command: GlCommands, args?: T | any): string {
627635
return createCommandLink<T>(command, args ?? this.branchRef);
628636
}
@@ -843,10 +851,35 @@ export class GlBranchCard extends GlBranchCardBase {
843851
<div class="branch-item__container">
844852
${this.renderBranchItem(this.renderBranchActions())}${this.renderPrItem()}${this.renderIssuesItem()}
845853
</div>
854+
${this.renderCollapsedActions()}
846855
</gl-card>
847856
`;
848857
}
849858

859+
protected getCollapsedActions(): TemplateResult[] {
860+
const actions = [];
861+
862+
if (this.branch.worktree) {
863+
actions.push(
864+
html`<action-item
865+
label="Open Worktree"
866+
icon="browser"
867+
href=${this.createCommandLink('gitlens.home.openWorktree')}
868+
></action-item>`,
869+
);
870+
} else {
871+
actions.push(
872+
html`<action-item
873+
label="Switch to Branch..."
874+
icon="gl-switch"
875+
href=${this.createCommandLink('gitlens.home.switchToBranch')}
876+
></action-item>`,
877+
);
878+
}
879+
880+
return actions;
881+
}
882+
850883
protected getBranchActions(): TemplateResult[] {
851884
const actions = [];
852885

0 commit comments

Comments
 (0)