From f204b0e3a6d01f9dea8a61bf2e59ce23d8084d3e Mon Sep 17 00:00:00 2001 From: nzaytsev Date: Fri, 15 Nov 2024 10:39:59 +0700 Subject: [PATCH 1/3] Adds no branches placeholder to keep the date filter always displayed --- .../plus/home/components/branch-section.ts | 14 ++++- .../apps/plus/home/components/overview.ts | 63 ++++++++----------- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/webviews/apps/plus/home/components/branch-section.ts b/src/webviews/apps/plus/home/components/branch-section.ts index bc19c2feb2eae..1f916b0a28b89 100644 --- a/src/webviews/apps/plus/home/components/branch-section.ts +++ b/src/webviews/apps/plus/home/components/branch-section.ts @@ -57,12 +57,20 @@ export class GlBranchSection extends LitElement { @property({ type: Array }) branches!: GetOverviewBranch[]; @property({ type: Boolean }) isFetching = false; + private renderSectionLabel() { + if (this.isFetching) { + return this.label; + } + if (!this.branches.length) { + return `No ${this.label} branches`; + } + return `${this.label} (${this.branches.length})`; + } + override render() { return html` - ${this.label}${when(!this.isFetching, () => html` (${this.branches.length})`)} + ${this.renderSectionLabel()} ${this.branches.map( branch => html``, diff --git a/src/webviews/apps/plus/home/components/overview.ts b/src/webviews/apps/plus/home/components/overview.ts index 0545da29d8198..867e0a50f0904 100644 --- a/src/webviews/apps/plus/home/components/overview.ts +++ b/src/webviews/apps/plus/home/components/overview.ts @@ -95,42 +95,33 @@ export class GlOverview extends SignalWatcher(LitElement) { if (overview == null) return nothing; const { repository } = overview; return html` - ${when( - repository.branches.recent.length > 0, - () => html` - - - - `, - )} - ${when( - repository.branches.stale.length > 0, - () => html` - - `, - )} + + + + `; } } From 452a44f5291330f6b440f02c1ce49e9b0d946bf9 Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Fri, 15 Nov 2024 10:39:56 -0500 Subject: [PATCH 2/3] Prevents rendering stale section --- .../apps/plus/home/components/overview.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/webviews/apps/plus/home/components/overview.ts b/src/webviews/apps/plus/home/components/overview.ts index 867e0a50f0904..a3e35ebc6be83 100644 --- a/src/webviews/apps/plus/home/components/overview.ts +++ b/src/webviews/apps/plus/home/components/overview.ts @@ -116,12 +116,16 @@ export class GlOverview extends SignalWatcher(LitElement) { .value=${this._overviewState.filter.recent?.threshold} > - + ${when( + this._overviewState.filter.stale?.show === true, + () => html` + + `, + )} `; } } From 5db66d61d281341db5d86c8fe2729024fe7345ae Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Fri, 15 Nov 2024 10:51:39 -0500 Subject: [PATCH 3/3] Updates empty state for branch sections --- .../apps/plus/home/components/branch-section.ts | 14 ++++++++++---- src/webviews/apps/plus/home/components/overview.ts | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/webviews/apps/plus/home/components/branch-section.ts b/src/webviews/apps/plus/home/components/branch-section.ts index 1f916b0a28b89..b52b4849049a5 100644 --- a/src/webviews/apps/plus/home/components/branch-section.ts +++ b/src/webviews/apps/plus/home/components/branch-section.ts @@ -58,12 +58,10 @@ export class GlBranchSection extends LitElement { @property({ type: Boolean }) isFetching = false; private renderSectionLabel() { - if (this.isFetching) { + if (this.isFetching || this.branches.length === 0) { return this.label; } - if (!this.branches.length) { - return `No ${this.label} branches`; - } + return `${this.label} (${this.branches.length})`; } @@ -75,6 +73,14 @@ export class GlBranchSection extends LitElement { ${this.branches.map( branch => html``, )} + ${when( + this.branches.length > 0, + () => + this.branches.map( + branch => html``, + ), + () => html`

No ${this.label} branches

`, + )}
`; } diff --git a/src/webviews/apps/plus/home/components/overview.ts b/src/webviews/apps/plus/home/components/overview.ts index a3e35ebc6be83..2c8683d38bb12 100644 --- a/src/webviews/apps/plus/home/components/overview.ts +++ b/src/webviews/apps/plus/home/components/overview.ts @@ -96,7 +96,7 @@ export class GlOverview extends SignalWatcher(LitElement) { const { repository } = overview; return html` html`