Skip to content

Commit 164ed76

Browse files
committed
Fixes new home view bugs
- listening to git updates (push/pull/commit) - add an indication of the async task is fetching - fix gl-button click area in case of using tooltip prop - add tooltip to the `publish branch` action - fix promo banner dismissal
1 parent ac1633c commit 164ed76

File tree

7 files changed

+59
-20
lines changed

7 files changed

+59
-20
lines changed

src/webviews/apps/home/components/preview-banner.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ export class GlPreviewBanner extends LitElement {
6666
private _button!: HTMLButtonElement;
6767

6868
override render() {
69+
if (this.closed || this._state.previewCollapsed === true) {
70+
return nothing;
71+
}
72+
6973
if (this._state.previewEnabled === true) {
7074
return html`
7175
<gl-card>
@@ -91,10 +95,6 @@ export class GlPreviewBanner extends LitElement {
9195
`;
9296
}
9397

94-
if (this.closed || this._state.previewCollapsed === true) {
95-
return nothing;
96-
}
97-
9898
return html`
9999
<gl-tooltip placement="bottom">
100100
<button class="text-button text-button--end" @click=${() => this.togglePreview()}>

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

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { consume } from '@lit/context';
22
import { SignalWatcher } from '@lit-labs/signals';
33
import { css, html, LitElement, nothing } from 'lit';
44
import { customElement, state } from 'lit/decorators.js';
5+
import { ifDefined } from 'lit/directives/if-defined.js';
56
import { when } from 'lit/directives/when.js';
67
import type { GitTrackingState } from '../../../../../git/models/branch';
78
import { createWebviewCommandLink } from '../../../../../system/webview';
@@ -79,10 +80,10 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
7980
<skeleton-loader lines="3"></skeleton-loader>
8081
`;
8182
}
82-
return this.renderComplete(this._overviewState.state);
83+
return this.renderComplete(this._overviewState.state, true);
8384
}
8485

85-
private renderComplete(overview: Overview) {
86+
private renderComplete(overview: Overview, isFetching = false) {
8687
const repo = overview?.repository;
8788
const activeBranches = repo?.branches?.active;
8889
if (!activeBranches) return html`<span>None</span>`;
@@ -95,6 +96,8 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
9596
() =>
9697
html`<span
9798
><gl-button
99+
aria-busy="${isFetching}"
100+
?disabled=${isFetching}
98101
class="section-heading-action"
99102
appearance="toolbar"
100103
tooltip="Change Repository"
@@ -103,11 +106,11 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
103106
></span>`,
104107
)}
105108
</h3>
106-
${activeBranches.map(branch => this.renderRepoBranchCard(branch, repo.path))}
109+
${activeBranches.map(branch => this.renderRepoBranchCard(branch, repo.path, isFetching))}
107110
`;
108111
}
109112

110-
private renderRepoBranchCard(branch: GetOverviewBranch, repo: string) {
113+
private renderRepoBranchCard(branch: GetOverviewBranch, repo: string, isFetching: boolean) {
111114
const { name, pr, state, workingTreeState, upstream } = branch;
112115
return html`
113116
<gl-card class="branch-item" active>
@@ -117,7 +120,7 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
117120
</span>
118121
<span class="branch-item__name">${name}</span>
119122
</p>
120-
${when(state, () => this.renderBranchStateActions(state, upstream))}
123+
${when(state, () => this.renderBranchStateActions(state, upstream, isFetching))}
121124
${when(pr, pr => {
122125
return html` <p class="branch-item__main is-end">
123126
<span class="branch-item__icon">
@@ -179,14 +182,22 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
179182
return html`<action-nav class="branch-item__actions">${actions}</action-nav>`;
180183
}
181184

182-
private renderBranchStateActions(state?: GitTrackingState, upstream?: { name: string; missing: boolean }) {
185+
private renderBranchStateActions(
186+
state?: GitTrackingState,
187+
upstream?: { name: string; missing: boolean },
188+
isFetching?: boolean,
189+
) {
183190
if (upstream?.missing !== false) {
191+
const publishTooltip = upstream?.name ? `Publish branch to ${upstream.name}` : 'Publish branch';
184192
return html`<div>
185193
<button-container>
186194
<gl-button
195+
aria-busy=${ifDefined(isFetching)}
196+
?disabled=${isFetching}
187197
href=${createWebviewCommandLink('gitlens.views.home.publishBranch', 'gitlens.views.home', '')}
188198
full
189199
appearance="secondary"
200+
tooltip="${publishTooltip}"
190201
><code-icon icon="cloud-upload" slot="prefix"></code-icon> Publish Branch</gl-button
191202
></button-container
192203
>
@@ -201,6 +212,8 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
201212
return html`<div>
202213
<button-container>
203214
<gl-button
215+
aria-busy=${ifDefined(isFetching)}
216+
?disabled=${isFetching}
204217
href=${createWebviewCommandLink('gitlens.views.home.pull', 'gitlens.views.home', '')}
205218
full
206219
appearance="secondary"
@@ -213,6 +226,8 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
213226
></gl-tracking-pill
214227
></gl-button>
215228
<gl-button
229+
aria-busy=${ifDefined(isFetching)}
230+
?disabled=${isFetching}
216231
href=${createWebviewCommandLink('gitlens.views.home.push', 'gitlens.views.home', '', {
217232
force: true,
218233
})}
@@ -229,6 +244,8 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
229244
return html`<div>
230245
<button-container>
231246
<gl-button
247+
aria-busy=${ifDefined(isFetching)}
248+
?disabled=${isFetching}
232249
href=${createWebviewCommandLink('gitlens.views.home.pull', 'gitlens.views.home', '')}
233250
full
234251
appearance="secondary"
@@ -247,6 +264,8 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
247264
return html`<div>
248265
<button-container>
249266
<gl-button
267+
aria-busy=${ifDefined(isFetching)}
268+
?disabled=${isFetching}
250269
href=${createWebviewCommandLink('gitlens.views.home.push', 'gitlens.views.home', '')}
251270
full
252271
appearance="secondary"

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ export class GlBranchSection extends LitElement {
5959
@property({ type: String }) label!: string;
6060
@property() repo!: string;
6161
@property({ type: Array }) branches!: GetOverviewBranch[];
62+
@property({ type: Boolean }) isFetching = false;
6263

6364
override render() {
6465
return html`
6566
<gl-section>
66-
<span slot="heading">${this.label}</span>
67+
<span slot="heading"
68+
>${this.label}${when(!this.isFetching, () => html` (${this.branches.length})`)}</span
69+
>
6770
<span slot="heading-actions"><slot name="heading-actions"></slot></span>
6871
${this.branches.map(
6972
branch => html`<gl-branch-card .repo=${this.repo} .branch=${branch}></gl-branch-card>`,

src/webviews/apps/plus/home/components/branch-threshold-filter.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ export const selectStyles = css`
1111
background: none;
1212
outline: none;
1313
border: none;
14-
cursor: pointer;
15-
color: var(--color-foreground--50);
1614
text-decoration: none !important;
1715
font-weight: 500;
16+
color: var(--color-foreground--25);
1817
}
1918
.select option {
2019
color: var(--vscode-foreground);
2120
background-color: var(--vscode-dropdown-background);
2221
}
23-
.select:focus {
22+
.select:not(:disabled) {
23+
cursor: pointer;
24+
color: var(--color-foreground--50);
25+
}
26+
.select:not(:disabled):focus {
2427
outline: 1px solid var(--color-focus-border);
2528
}
26-
.select:hover {
29+
.select:not(:disabled):hover {
2730
color: var(--vscode-foreground);
2831
text-decoration: underline !important;
2932
}
@@ -32,6 +35,7 @@ export const selectStyles = css`
3235
export abstract class GlObjectSelect<T, L = T[keyof T], V = T[keyof T]> extends GlElement {
3336
static override readonly styles = [selectStyles];
3437

38+
@property({ type: Boolean }) disabled: boolean = false;
3539
@property({ type: String }) value?: V;
3640
@property({ type: Array }) options?: T[];
3741

@@ -44,7 +48,7 @@ export abstract class GlObjectSelect<T, L = T[keyof T], V = T[keyof T]> extends
4448
return;
4549
}
4650
return html`
47-
<select class="select" @change=${(e: InputEvent) => this.onChange?.(e)}>
51+
<select .disabled=${this.disabled} class="select" @change=${(e: InputEvent) => this.onChange?.(e)}>
4852
${repeat(this.options, item => {
4953
const value = this.getValue(item);
5054
const label = this.getLabel(item);

src/webviews/apps/plus/home/components/overview.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class GlOverview extends SignalWatcher(LitElement) {
6666
<skeleton-loader lines="3"></skeleton-loader>
6767
`;
6868
}
69-
return this.renderComplete(this._overviewState.state);
69+
return this.renderComplete(this._overviewState.state, true);
7070
}
7171

7272
@consume({ context: ipcContext })
@@ -82,13 +82,14 @@ export class GlOverview extends SignalWatcher(LitElement) {
8282
});
8383
}
8484

85-
private renderComplete(overview: Overview) {
85+
private renderComplete(overview: Overview, isFetching = false) {
8686
if (overview == null) return nothing;
8787
const { repository } = overview;
8888
return html`
8989
<div class="repository">
9090
<gl-branch-section
91-
label="Recent (${repository.branches.recent.length})"
91+
label="Recent"
92+
.isFetching=${isFetching}
9293
.repo=${repository.path}
9394
.branches=${repository.branches.recent}
9495
>
@@ -103,6 +104,7 @@ export class GlOverview extends SignalWatcher(LitElement) {
103104
value: OverviewRecentThreshold;
104105
label: string;
105106
}[]}
107+
.disabled=${isFetching}
106108
.value=${this._overviewState.filter.recent?.threshold}
107109
></gl-branch-threshold-filter>
108110
</gl-branch-section>

src/webviews/apps/shared/components/button.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export class GlButton extends LitElement {
150150
151151
gl-tooltip {
152152
height: 100%;
153+
width: 100%;
153154
display: inline-flex;
154155
align-items: center;
155156
justify-content: center;

src/webviews/home/homeWebview.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,17 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
469469
repo.watchFileSystem(1000),
470470
repo.onDidChangeFileSystem(() => this.onWipChanged(repo)),
471471
repo.onDidChange(e => {
472-
if (e.changed(RepositoryChange.Index, RepositoryChangeComparisonMode.Any)) {
472+
if (
473+
e.changed(
474+
RepositoryChange.Unknown,
475+
RepositoryChange.Index,
476+
RepositoryChange.Status,
477+
RepositoryChange.Remotes,
478+
RepositoryChange.Config,
479+
RepositoryChange.Heads,
480+
RepositoryChangeComparisonMode.Any,
481+
)
482+
) {
473483
this.onWipChanged(repo);
474484
}
475485
}),

0 commit comments

Comments
 (0)