Skip to content

Commit d8e4cea

Browse files
nzaytsevd13
authored andcommitted
Adds no branches placeholder to keep the date filter always displayed
1 parent b2088e4 commit d8e4cea

File tree

2 files changed

+38
-39
lines changed

2 files changed

+38
-39
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,20 @@ export class GlBranchSection extends LitElement {
5757
@property({ type: Array }) branches!: GetOverviewBranch[];
5858
@property({ type: Boolean }) isFetching = false;
5959

60+
private renderSectionLabel() {
61+
if (this.isFetching) {
62+
return this.label;
63+
}
64+
if (!this.branches.length) {
65+
return `No ${this.label} branches`;
66+
}
67+
return `${this.label} (${this.branches.length})`;
68+
}
69+
6070
override render() {
6171
return html`
6272
<gl-section>
63-
<span slot="heading"
64-
>${this.label}${when(!this.isFetching, () => html` (${this.branches.length})`)}</span
65-
>
73+
<span slot="heading">${this.renderSectionLabel()}</span>
6674
<span slot="heading-actions"><slot name="heading-actions"></slot></span>
6775
${this.branches.map(
6876
branch => html`<gl-branch-card .repo=${this.repo} .branch=${branch}></gl-branch-card>`,

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

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -95,42 +95,33 @@ export class GlOverview extends SignalWatcher(LitElement) {
9595
if (overview == null) return nothing;
9696
const { repository } = overview;
9797
return html`
98-
${when(
99-
repository.branches.recent.length > 0,
100-
() => html`
101-
<gl-branch-section
102-
label="Recent"
103-
.isFetching=${isFetching}
104-
.repo=${repository.path}
105-
.branches=${repository.branches.recent}
106-
>
107-
<gl-branch-threshold-filter
108-
slot="heading-actions"
109-
@gl-change=${this.onChangeRecentThresholdFilter.bind(this)}
110-
.options=${[
111-
{ value: 'OneDay', label: '1 day' },
112-
{ value: 'OneWeek', label: '1 week' },
113-
{ value: 'OneMonth', label: '1 month' },
114-
] satisfies {
115-
value: OverviewRecentThreshold;
116-
label: string;
117-
}[]}
118-
.disabled=${isFetching}
119-
.value=${this._overviewState.filter.recent?.threshold}
120-
></gl-branch-threshold-filter>
121-
</gl-branch-section>
122-
`,
123-
)}
124-
${when(
125-
repository.branches.stale.length > 0,
126-
() => html`
127-
<gl-branch-section
128-
label="Stale (${repository.branches.stale.length})"
129-
.repo=${repository.path}
130-
.branches=${repository.branches.stale}
131-
></gl-branch-section>
132-
`,
133-
)}
98+
<gl-branch-section
99+
label="Recent"
100+
.isFetching=${isFetching}
101+
.repo=${repository.path}
102+
.branches=${repository.branches.recent}
103+
>
104+
<gl-branch-threshold-filter
105+
slot="heading-actions"
106+
@gl-change=${this.onChangeRecentThresholdFilter.bind(this)}
107+
.options=${[
108+
{ value: 'OneDay', label: '1 day' },
109+
{ value: 'OneWeek', label: '1 week' },
110+
{ value: 'OneMonth', label: '1 month' },
111+
] satisfies {
112+
value: OverviewRecentThreshold;
113+
label: string;
114+
}[]}
115+
.disabled=${isFetching}
116+
.value=${this._overviewState.filter.recent?.threshold}
117+
></gl-branch-threshold-filter>
118+
</gl-branch-section>
119+
<gl-branch-section
120+
label="Stale"
121+
?hidden=${this._overviewState.filter.stale?.show !== true}
122+
.repo=${repository.path}
123+
.branches=${repository.branches.stale}
124+
></gl-branch-section>
134125
`;
135126
}
136127
}

0 commit comments

Comments
 (0)