mirror of
https://github.com/ceph/ceph
synced 2026-08-02 07:03:18 +00:00
mgr/dashboard: fix notification re-navigation when already on page
When a notification is clicked in the panel while the user is already on the notifications page, the selected notification now updates correctly by bypassing the preselect guard for query param changes. Signed-off-by: Afreen Misbah <afreen@ibm.com>
This commit is contained in:
parent
a9a6255cd2
commit
a1a70d06f4
@ -347,6 +347,17 @@ describe('NotificationsPageComponent', () => {
|
||||
expect(component.selectedNotificationID()).toBe('1');
|
||||
});
|
||||
|
||||
it('should re-select when query params change while a notification is already selected', () => {
|
||||
queryParamsSubject.next({ id: '1' });
|
||||
fixture.detectChanges();
|
||||
expect(component.selectedNotificationID()).toBe('1');
|
||||
|
||||
queryParamsSubject.next({ id: '2' });
|
||||
fixture.detectChanges();
|
||||
expect(component.selectedNotificationID()).toBe('2');
|
||||
expect(notificationService.markAsRead).toHaveBeenCalledWith('2');
|
||||
});
|
||||
|
||||
it('should pre-select when navigating from toast view more link', () => {
|
||||
dataSourceSubject.next(mockNotifications);
|
||||
fixture.detectChanges();
|
||||
|
||||
@ -88,7 +88,7 @@ export class NotificationsPageComponent implements OnInit, OnDestroy {
|
||||
this.sub.add(
|
||||
this.route.queryParams.subscribe((params) => {
|
||||
this._pendingId = params['id'] || null;
|
||||
this._tryPreselect(this.notificationService.getNotificationsSnapshot());
|
||||
this._tryPreselect(this.notificationService.getNotificationsSnapshot(), true);
|
||||
})
|
||||
);
|
||||
}
|
||||
@ -133,8 +133,8 @@ export class NotificationsPageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
private _tryPreselect(notifications: CdNotification[]): void {
|
||||
if (!this._pendingId || this.selectedNotificationID()) return;
|
||||
private _tryPreselect(notifications: CdNotification[], force = false): void {
|
||||
if (!this._pendingId || (!force && this.selectedNotificationID())) return;
|
||||
const match = notifications.find((n) => n.id === this._pendingId);
|
||||
if (match) {
|
||||
this.selectedNotificationID.set(this._pendingId);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user