Skip to content

Commit 3bbf47a

Browse files
Add loading indicator; dismiss modals correctly
1 parent 61eed76 commit 3bbf47a

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

frontend/src/app/annotate/annotation-input/problem-details/problem-labels/manage-labels-modal/manage-labels-modal.component.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ <h5 class="modal-title" i18n>Manage Labels</h5>
55
class="btn-close"
66
aria-label="Close"
77
i18n-aria-label
8-
(click)="closeModal()"
8+
(click)="activeModal.dismiss()"
99
></button>
1010
</div>
1111
<div class="modal-body">
@@ -63,6 +63,15 @@ <h6 i18n>Available labels</h6>
6363
</tr>
6464
</thead>
6565
<tbody>
66+
@if (loadingLabels$ | async) {
67+
<tr>
68+
<td colspan="3" class="text-center py-3">
69+
<div class="spinner-border spinner-border-sm text-secondary" role="status">
70+
<span class="visually-hidden" i18n>Loading labels...</span>
71+
</div>
72+
</td>
73+
</tr>
74+
} @else {
6675
@for (label of availableLabels$ | async; track label.id) {
6776
<tr class="clickable-row align-middle" (click)="addLabel(label.id)">
6877
<td>
@@ -84,6 +93,7 @@ <h6 i18n>Available labels</h6>
8493
</td>
8594
</tr>
8695
}
96+
}
8797
</tbody>
8898
</table>
8999

@@ -107,7 +117,7 @@ <h6 i18n>Available labels</h6>
107117
<button
108118
type="button"
109119
class="btn btn-secondary"
110-
(click)="closeModal({ save: false })"
120+
(click)="activeModal.dismiss()"
111121
i18n
112122
>
113123
Close

frontend/src/app/annotate/annotation-input/problem-details/problem-labels/manage-labels-modal/manage-labels-modal.component.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export class ManageLabelsModalComponent implements OnInit {
6060
})
6161
);
6262

63+
public loadingLabels$ = this.availableLabels$.pipe(
64+
map(() => false),
65+
startWith(true)
66+
);
67+
6368
constructor(public activeModal: NgbActiveModal) { }
6469

6570
ngOnInit(): void {
@@ -113,11 +118,7 @@ export class ManageLabelsModalComponent implements OnInit {
113118
this.addLabelSubject.next(labelId);
114119
}
115120

116-
public closeModal(options: { save: boolean; } = { save: true }): void {
117-
if (!options.save) {
118-
this.activeModal.dismiss();
119-
return;
120-
}
121+
public closeModal(): void {
121122
this.activeModal.close(this.form.getRawValue());
122123
}
123124

0 commit comments

Comments
 (0)