Skip to content

Commit 76a23b7

Browse files
michalberkyHejdaJakub
authored andcommitted
fix(admin): bulk application approve/reject error handling
* An error during bulk approval or reject now creates a new notification and immediately opens its dialog to provide feedback
1 parent 248b065 commit 76a23b7

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

apps/admin-gui/src/app/shared/components/application-actions/application-actions.component.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { NotificatorService, PerunTranslateService } from '@perun-web-apps/perun
1616
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
1717
import { ApplicationsBulkOperationDialogComponent } from '../dialogs/applications-bulk-operation-dialog/applications-bulk-operation-dialog.component';
1818
import { getDefaultDialogConfig } from '@perun-web-apps/perun/utils';
19+
import { NotificationData, RPCError } from '@perun-web-apps/perun/models';
20+
import { NotificationDialogComponent } from '@perun-web-apps/perun/dialogs';
1921

2022
export interface AppAction {
2123
approve: boolean;
@@ -155,6 +157,16 @@ export class ApplicationActionsComponent implements OnInit {
155157
this.notificator.showInstantSuccess('VO_DETAIL.APPLICATION.SUCCESS.APPROVE');
156158
this.refreshTable();
157159
},
160+
error: (error: RPCError) => {
161+
this.showErrorDialog(
162+
'VO_DETAIL.APPLICATION.ERROR.APPROVE',
163+
error,
164+
this.translate.instant('VO_DETAIL.APPLICATION.ERROR.APPROVE_DESCRIPTION', {
165+
error: error.message,
166+
}),
167+
);
168+
this.refreshTable();
169+
},
158170
});
159171
}
160172
});
@@ -178,6 +190,16 @@ export class ApplicationActionsComponent implements OnInit {
178190
this.notificator.showInstantSuccess('VO_DETAIL.APPLICATION.SUCCESS.REJECT');
179191
this.refreshTable();
180192
},
193+
error: (error: RPCError) => {
194+
this.showErrorDialog(
195+
'VO_DETAIL.APPLICATION.ERROR.REJECT',
196+
error,
197+
this.translate.instant('VO_DETAIL.APPLICATION.ERROR.REJECT_DESCRIPTION', {
198+
error: error.message,
199+
}),
200+
);
201+
this.refreshTable();
202+
},
181203
});
182204
}
183205
});
@@ -373,4 +395,37 @@ export class ApplicationActionsComponent implements OnInit {
373395
newDate.setDate(newDate.getDate() - 365);
374396
return newDate;
375397
}
398+
399+
// FIXME: showErrorDialog() and createNotificationData() are part of a quickfix and to be remove after proper fix is made
400+
private showErrorDialog(title: string, error: RPCError, description: string): void {
401+
const notificationData: NotificationData = this.createNotificationData(
402+
title,
403+
error,
404+
description,
405+
);
406+
this.dialog.open(NotificationDialogComponent, {
407+
width: '550px',
408+
data: notificationData,
409+
autoFocus: false,
410+
});
411+
}
412+
413+
private createNotificationData(
414+
title: string,
415+
error?: RPCError,
416+
description?: string,
417+
): NotificationData {
418+
const notificationData: NotificationData = {
419+
type: 'error',
420+
error: error,
421+
description: description,
422+
title: this.translate.instant(title),
423+
actionText: this.notificator.getDefaultActionMessage(),
424+
delay: this.notificator.defaultErrorDelayMs,
425+
icon: 'error_outline',
426+
action: null,
427+
timeStamp: `${new Date().getHours()}:${new Date().getMinutes()}`,
428+
};
429+
return notificationData;
430+
}
376431
}

apps/admin-gui/src/assets/i18n/en.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,12 @@
674674
"DELETE": "Applications were successfully deleted.",
675675
"RESEND": "Notifications for applications were re-sent."
676676
},
677+
"ERROR": {
678+
"APPROVE": "Failed to approve some applications.",
679+
"APPROVE_DESCRIPTION": "A problem occurred during approval: [{{error}}] and not all of the selected applications got approved. There may still be some of the selected applications that could possibly be approved.",
680+
"REJECT": "Failed to reject some applications.",
681+
"REJECT_DESCRIPTION": "A problem occurred during rejection: [{{error}}] and not all of the selected applications got rejected. There may still be some of the selected applications that could possibly be rejected."
682+
},
677683

678684
"APPLICATION_DETAIL": {
679685
"TITLE": "Application detail",

0 commit comments

Comments
 (0)