Skip to content

Commit 17a5da9

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 (cherry picked from commit 76a23b7)
1 parent 748539f commit 17a5da9

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;
@@ -154,6 +156,16 @@ export class ApplicationActionsComponent implements OnInit {
154156
this.notificator.showInstantSuccess('VO_DETAIL.APPLICATION.SUCCESS.APPROVE');
155157
this.refreshTable();
156158
},
159+
error: (error: RPCError) => {
160+
this.showErrorDialog(
161+
'VO_DETAIL.APPLICATION.ERROR.APPROVE',
162+
error,
163+
this.translate.instant('VO_DETAIL.APPLICATION.ERROR.APPROVE_DESCRIPTION', {
164+
error: error.message,
165+
}),
166+
);
167+
this.refreshTable();
168+
},
157169
});
158170
}
159171
});
@@ -177,6 +189,16 @@ export class ApplicationActionsComponent implements OnInit {
177189
this.notificator.showInstantSuccess('VO_DETAIL.APPLICATION.SUCCESS.REJECT');
178190
this.refreshTable();
179191
},
192+
error: (error: RPCError) => {
193+
this.showErrorDialog(
194+
'VO_DETAIL.APPLICATION.ERROR.REJECT',
195+
error,
196+
this.translate.instant('VO_DETAIL.APPLICATION.ERROR.REJECT_DESCRIPTION', {
197+
error: error.message,
198+
}),
199+
);
200+
this.refreshTable();
201+
},
180202
});
181203
}
182204
});
@@ -372,4 +394,37 @@ export class ApplicationActionsComponent implements OnInit {
372394
newDate.setDate(newDate.getDate() - 365);
373395
return newDate;
374396
}
397+
398+
// FIXME: showErrorDialog() and createNotificationData() are part of a quickfix and to be remove after proper fix is made
399+
private showErrorDialog(title: string, error: RPCError, description: string): void {
400+
const notificationData: NotificationData = this.createNotificationData(
401+
title,
402+
error,
403+
description,
404+
);
405+
this.dialog.open(NotificationDialogComponent, {
406+
width: '550px',
407+
data: notificationData,
408+
autoFocus: false,
409+
});
410+
}
411+
412+
private createNotificationData(
413+
title: string,
414+
error?: RPCError,
415+
description?: string,
416+
): NotificationData {
417+
const notificationData: NotificationData = {
418+
type: 'error',
419+
error: error,
420+
description: description,
421+
title: this.translate.instant(title),
422+
actionText: this.notificator.getDefaultActionMessage(),
423+
delay: this.notificator.defaultErrorDelayMs,
424+
icon: 'error_outline',
425+
action: null,
426+
timeStamp: `${new Date().getHours()}:${new Date().getMinutes()}`,
427+
};
428+
return notificationData;
429+
}
375430
}

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)