Skip to content

Commit

Permalink
Updates empty state for branch sections
Browse files Browse the repository at this point in the history
  • Loading branch information
d13 committed Nov 15, 2024
1 parent 306ce04 commit e8d51de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/webviews/apps/plus/home/components/branch-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})`;
}

Expand All @@ -75,6 +73,14 @@ export class GlBranchSection extends LitElement {
${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
4 changes: 2 additions & 2 deletions src/webviews/apps/plus/home/components/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class GlOverview extends SignalWatcher(LitElement) {
const { repository } = overview;
return html`
<gl-branch-section
label="Recent"
label="recent"
.isFetching=${isFetching}
.repo=${repository.path}
.branches=${repository.branches.recent}
Expand All @@ -120,7 +120,7 @@ export class GlOverview extends SignalWatcher(LitElement) {
this._overviewState.filter.stale?.show === true,
() => html`
<gl-branch-section
label="Stale"
label="stale"
.repo=${repository.path}
.branches=${repository.branches.stale}
></gl-branch-section>
Expand Down

0 comments on commit e8d51de

Please sign in to comment.