|
1 | 1 | import GlimmerComponent from '@glimmer/component'; |
| 2 | +import { cached } from '@glimmer/tracking'; |
2 | 3 | import type { CiStatus, CiGroup } from '../../utils'; |
3 | 4 |
|
4 | 5 | // ── Sub-components ────────────────────────────────────────────────────── |
@@ -144,31 +145,41 @@ class CiStatusLabel extends GlimmerComponent<CiStatusLabelSignature> { |
144 | 145 | interface CiSectionSignature { |
145 | 146 | Args: { |
146 | 147 | ciGroups: CiGroup[]; |
| 148 | + isLoading?: boolean; |
147 | 149 | }; |
148 | 150 | } |
149 | 151 |
|
150 | 152 | export class CiSection extends GlimmerComponent<CiSectionSignature> { |
| 153 | + @cached get flatItems() { |
| 154 | + return this.args.ciGroups.flatMap((g) => g.items); |
| 155 | + } |
| 156 | + |
151 | 157 | <template> |
152 | 158 | <div class='ci-section'> |
153 | 159 | <h2 class='section-heading'>CI Checks</h2> |
154 | 160 |
|
155 | | - {{#if @ciGroups.length}} |
| 161 | + {{#if this.flatItems.length}} |
156 | 162 | <ul class='ci-group' role='list'> |
157 | | - {{#each @ciGroups as |group|}} |
158 | | - {{#each group.items as |item|}} |
159 | | - <li class='ci-item'> |
160 | | - <CiDot @state={{item.state}} /> |
161 | | - <div class='ci-item-detail'> |
162 | | - <span class='ci-item-name'>{{item.name}}</span> |
163 | | - <CiStatusLabel |
164 | | - @state={{item.state}} |
165 | | - @text={{item.statusText}} |
166 | | - /> |
167 | | - </div> |
168 | | - </li> |
169 | | - {{/each}} |
| 163 | + {{#each this.flatItems key='name' as |item|}} |
| 164 | + <li class='ci-item'> |
| 165 | + <CiDot @state={{item.state}} /> |
| 166 | + <div class='ci-item-detail'> |
| 167 | + <span class='ci-item-name'>{{item.name}}</span> |
| 168 | + <CiStatusLabel |
| 169 | + @state={{item.state}} |
| 170 | + @text={{item.statusText}} |
| 171 | + /> |
| 172 | + </div> |
| 173 | + </li> |
170 | 174 | {{/each}} |
171 | 175 | </ul> |
| 176 | + {{else if @isLoading}} |
| 177 | + <div class='ci-item loading-state'> |
| 178 | + <CiDot @state='in_progress' /> |
| 179 | + <div class='ci-item-detail'> |
| 180 | + <span class='ci-item-name loading-text'>Loading CI checks...</span> |
| 181 | + </div> |
| 182 | + </div> |
172 | 183 | {{else}} |
173 | 184 | <div class='empty-state'> |
174 | 185 | <span class='empty-state-icon' aria-hidden='true'> |
@@ -257,6 +268,12 @@ export class CiSection extends GlimmerComponent<CiSectionSignature> { |
257 | 268 | font-size: var(--boxel-font-xs); |
258 | 269 | color: var(--muted-foreground, #656d76); |
259 | 270 | } |
| 271 | + .loading-state { |
| 272 | + border-radius: var(--radius, 6px); |
| 273 | + } |
| 274 | + .loading-text { |
| 275 | + color: var(--muted-foreground, #656d76); |
| 276 | + } |
260 | 277 | </style> |
261 | 278 | </template> |
262 | 279 | } |
0 commit comments