From 87594dfe17d01dfa60e28e2c0865a98a4c81e7c2 Mon Sep 17 00:00:00 2001 From: juancarmore Date: Wed, 3 Sep 2025 12:12:43 +0200 Subject: [PATCH] frontend: update delete room dialog to clarify error handling and enhance policy options --- .../delete-room-dialog.component.html | 2 +- .../delete-room-dialog.component.ts | 24 +++++--- .../pages/console/rooms/rooms.component.ts | 55 ++++++------------- 3 files changed, 36 insertions(+), 45 deletions(-) diff --git a/frontend/projects/shared-meet-components/src/lib/components/dialogs/delete-room-dialog/delete-room-dialog.component.html b/frontend/projects/shared-meet-components/src/lib/components/dialogs/delete-room-dialog/delete-room-dialog.component.html index 03f6873..42981e4 100644 --- a/frontend/projects/shared-meet-components/src/lib/components/dialogs/delete-room-dialog/delete-room-dialog.component.html +++ b/frontend/projects/shared-meet-components/src/lib/components/dialogs/delete-room-dialog/delete-room-dialog.component.html @@ -6,7 +6,7 @@
-

Please choose how to handle this situation:

+

Please choose how to handle room deletion errors:

@if (data.showWithMeetingPolicy) { diff --git a/frontend/projects/shared-meet-components/src/lib/components/dialogs/delete-room-dialog/delete-room-dialog.component.ts b/frontend/projects/shared-meet-components/src/lib/components/dialogs/delete-room-dialog/delete-room-dialog.component.ts index d90206b..39a09fa 100644 --- a/frontend/projects/shared-meet-components/src/lib/components/dialogs/delete-room-dialog/delete-room-dialog.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/components/dialogs/delete-room-dialog/delete-room-dialog.component.ts @@ -33,28 +33,38 @@ export class DeleteRoomDialogComponent { readonly dialogRef = inject(MatDialogRef); meetingPolicyOptions = [ + { + value: MeetRoomDeletionPolicyWithMeeting.FORCE, + label: 'Force', + description: + 'The meeting will be ended immediately, and the room will be deleted without waiting for participants to leave.' + }, { value: MeetRoomDeletionPolicyWithMeeting.WHEN_MEETING_ENDS, label: 'When meeting ends', description: 'The room will be deleted when the meeting ends.' }, { - value: MeetRoomDeletionPolicyWithMeeting.FORCE, - label: 'Force', - description: - 'The meeting will be ended immediately, and the room will be deleted without waiting for participants to leave.' + value: MeetRoomDeletionPolicyWithMeeting.FAIL, + label: 'Fail', + description: 'The deletion will fail if there is an active meeting.' } ]; recordingPolicyOptions = [ + { + value: MeetRoomDeletionPolicyWithRecordings.FORCE, + label: 'Force', + description: 'The room and its recordings will be deleted immediately.' + }, { value: MeetRoomDeletionPolicyWithRecordings.CLOSE, label: 'Close', description: 'The room will be closed instead of deleted, maintaining its recordings.' }, { - value: MeetRoomDeletionPolicyWithRecordings.FORCE, - label: 'Force', - description: 'The room and its recordings will be deleted immediately.' + value: MeetRoomDeletionPolicyWithRecordings.FAIL, + label: 'Fail', + description: 'The deletion will fail if the room has recordings.' } ]; diff --git a/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.ts b/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.ts index 1a485a1..f6ec148 100644 --- a/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.ts +++ b/frontend/projects/shared-meet-components/src/lib/pages/console/rooms/rooms.component.ts @@ -335,7 +335,7 @@ export class RoomsComponent implements OnInit { const errorCode = error.error?.error; if (errorCode && this.isValidMeetRoomDeletionErrorCode(errorCode)) { const errorMessage = this.extractGenericMessage(error.error.message); - this.showDeletionErrorDialogWithOptions(roomId, errorCode, errorMessage); + this.showDeletionErrorDialogWithOptions(roomId, errorMessage); } else { this.notificationService.showSnackbar('Failed to delete room'); this.log.e('Error deleting room:', error); @@ -375,15 +375,7 @@ export class RoomsComponent implements OnInit { this.notificationService.showSnackbar(this.extractGenericMessage(message)); } - private showDeletionErrorDialogWithOptions( - roomId: string, - errorCode: MeetRoomDeletionErrorCode, - errorMessage: string - ) { - // Determine available policy options based on error code - const showWithMeetingPolicy = errorCode !== MeetRoomDeletionErrorCode.ROOM_HAS_RECORDINGS; - const showWithRecordingsPolicy = errorCode !== MeetRoomDeletionErrorCode.ROOM_HAS_ACTIVE_MEETING; - + private showDeletionErrorDialogWithOptions(roomId: string, errorMessage: string) { const deleteWithPoliciesCallback = async ( meetingPolicy: MeetRoomDeletionPolicyWithMeeting, recordingPolicy: MeetRoomDeletionPolicyWithRecordings @@ -406,8 +398,8 @@ export class RoomsComponent implements OnInit { title: 'Error Deleting Room', message: errorMessage, confirmText: 'Delete with Options', - showWithMeetingPolicy, - showWithRecordingsPolicy, + showWithMeetingPolicy: true, + showWithRecordingsPolicy: true, confirmCallback: deleteWithPoliciesCallback }; this.dialog.open(DeleteRoomDialogComponent, { @@ -430,13 +422,22 @@ export class RoomsComponent implements OnInit { this.notificationService.showSnackbar(message); } catch (error: any) { // Check if it's a structured error with failed rooms - const failed = error.error?.failed; + const failed = error.error?.failed as { roomId: string; error: string; message: string }[]; const successful = error.error?.successful; - const message = error.error?.message; + const errorMessage = error.error?.message; if (failed && successful) { this.handleSuccessfulBulkDeletion(successful); - this.showBulkDeletionErrorDialogWithOptions(failed, message); + + const hasRoomDeletionError = failed.some((result) => + this.isValidMeetRoomDeletionErrorCode(result.error) + ); + if (hasRoomDeletionError) { + this.showBulkDeletionErrorDialogWithOptions(failed, errorMessage); + } else { + this.notificationService.showSnackbar(errorMessage); + this.log.e('Error in bulk delete:', failed); + } } else { this.notificationService.showSnackbar('Failed to delete rooms'); this.log.e('Error in bulk delete:', error); @@ -499,25 +500,6 @@ export class RoomsComponent implements OnInit { }[], errorMessage: string ) { - // Determine available policy options based on error codes - const showWithMeetingPolicy = failedResults.some( - (result) => - this.isValidMeetRoomDeletionErrorCode(result.error) && - result.error !== MeetRoomDeletionErrorCode.ROOM_HAS_RECORDINGS - ); - const showWithRecordingsPolicy = failedResults.some( - (result) => - this.isValidMeetRoomDeletionErrorCode(result.error) && - result.error !== MeetRoomDeletionErrorCode.ROOM_HAS_ACTIVE_MEETING - ); - - if (!showWithMeetingPolicy && !showWithRecordingsPolicy) { - // Generic error - this.notificationService.showSnackbar(errorMessage); - this.log.e('Error in bulk delete:', failedResults); - return; - } - const roomIds = failedResults.map((r) => r.roomId); const bulkDeleteWithPoliciesCallback = async ( @@ -555,11 +537,10 @@ export class RoomsComponent implements OnInit { message: `${errorMessage}. They have active meetings and/or recordings:

${roomIds.join(', ')}

`, confirmText: 'Delete with Options', - showWithMeetingPolicy, - showWithRecordingsPolicy, + showWithMeetingPolicy: true, + showWithRecordingsPolicy: true, confirmCallback: bulkDeleteWithPoliciesCallback }; - this.dialog.open(DeleteRoomDialogComponent, { data: dialogOptions, disableClose: true