Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/webviews/apps/plus/home/components/branch-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,30 @@ export class GlBranchSection extends LitElement {
@property({ type: Array }) branches!: GetOverviewBranch[];
@property({ type: Boolean }) isFetching = false;

private renderSectionLabel() {
if (this.isFetching || this.branches.length === 0) {
return this.label;
}

return `${this.label} (${this.branches.length})`;
}

override render() {
return html`
<gl-section>
<span slot="heading"
>${this.label}${when(!this.isFetching, () => html` (${this.branches.length})`)}</span
>
<span slot="heading">${this.renderSectionLabel()}</span>
<span slot="heading-actions"><slot name="heading-actions"></slot></span>
${this.branches.map(
branch => html`<gl-branch-card .repo=${this.repo} .branch=${branch}></gl-branch-card>`,
)}
${when(
this.branches.length > 0,
() =>
this.branches.map(
branch => html`<gl-branch-card .repo=${this.repo} .branch=${branch}></gl-branch-card>`,
),
() => html`<p>No ${this.label} branches</p>`,
)}
</gl-section>
`;
}
Expand Down
51 changes: 23 additions & 28 deletions src/webviews/apps/plus/home/components/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,37 +95,32 @@ export class GlOverview extends SignalWatcher(LitElement) {
if (overview == null) return nothing;
const { repository } = overview;
return html`
<gl-branch-section
label="recent"
.isFetching=${isFetching}
.repo=${repository.path}
.branches=${repository.branches.recent}
>
<gl-branch-threshold-filter
slot="heading-actions"
@gl-change=${this.onChangeRecentThresholdFilter.bind(this)}
.options=${[
{ value: 'OneDay', label: '1 day' },
{ value: 'OneWeek', label: '1 week' },
{ value: 'OneMonth', label: '1 month' },
] satisfies {
value: OverviewRecentThreshold;
label: string;
}[]}
.disabled=${isFetching}
.value=${this._overviewState.filter.recent?.threshold}
></gl-branch-threshold-filter>
</gl-branch-section>
${when(
repository.branches.recent.length > 0,
this._overviewState.filter.stale?.show === true,
() => html`
<gl-branch-section
label="Recent"
.isFetching=${isFetching}
.repo=${repository.path}
.branches=${repository.branches.recent}
>
<gl-branch-threshold-filter
slot="heading-actions"
@gl-change=${this.onChangeRecentThresholdFilter.bind(this)}
.options=${[
{ value: 'OneDay', label: '1 day' },
{ value: 'OneWeek', label: '1 week' },
{ value: 'OneMonth', label: '1 month' },
] satisfies {
value: OverviewRecentThreshold;
label: string;
}[]}
.disabled=${isFetching}
.value=${this._overviewState.filter.recent?.threshold}
></gl-branch-threshold-filter>
</gl-branch-section>
`,
)}
${when(
repository.branches.stale.length > 0,
() => html`
<gl-branch-section
label="Stale (${repository.branches.stale.length})"
label="stale"
.repo=${repository.path}
.branches=${repository.branches.stale}
></gl-branch-section>
Expand Down
Loading