[PM-31364] discard edits dialog to policies page#20096
[PM-31364] discard edits dialog to policies page#20096
Conversation
* Added `openDrawer` method to `PolicyDialogComponent` and `MultiStepPolicyEditDialogComponent` to support opening dialogs in a drawer format. * Updated `edit` method in `PoliciesComponent` to conditionally use the drawer based on the `PolicyDrawers` feature flag. * Introduced `PolicyDrawers` feature flag in `feature-flag.enum.ts` to control the new drawer functionality.
* Updated `policy-edit-dialog.component.html` and `multi-step-policy-edit-dialog.component.html` to conditionally apply full height class based on drawer state. * Modified `PolicyEditDialogComponent` to include a host binding for full height when in drawer mode.
…drawer mode by adding a host binding for the full height class based on the dialog reference state.
…m-25627-convery-policy-dialogs-to-drawers
…er cleanup on destroy. Added drawerRef to handle drawer state and close it when the component is destroyed.
…le, allowing for potential updates to the dialog reference during component lifecycle.
…onent - Introduced PoliciesDeactivateGuard to prevent navigation away from the PoliciesComponent if there are unsaved changes in the drawer. - Enhanced PoliciesComponent with a canDeactivate method to check for unsaved changes. - Updated policy-edit-dialog components to implement discard edits confirmation dialogs. - Added localization messages for discard edits confirmation prompts. - Modified organization-settings-routing to include the new guard for the policies route.
Bitwarden Claude Code ReviewOverall Assessment: REQUEST CHANGES This PR adds a "discard edits" confirmation dialog when navigating away from an open policy drawer with unsaved changes. It introduces a The shared dialog service changes ( Code Review Details
|
| }); | ||
| // Clear the predicate so the drawer closes immediately after a successful save. |
There was a problem hiding this comment.
closePredicate clear on the confirm() cancellation path
Details and fix
The predicate is correctly cleared here before close("saved"), but the same pattern is missing a few lines above (around the original line 162) where confirm() returns false:
if ((await policyComponent.confirm?.()) == false) {
this.dialogRef.close(); // <-- triggers closePredicate in drawer mode
return;
}When OrganizationDataOwnershipComponent.confirm() returns false, the drawer's close() delegates to tryClose(), which invokes closePredicate. Since the form is dirty at that point, the user sees a second "Discard edits?" dialog after already cancelling the confirmation warning.
Add this.dialogRef.closePredicate = undefined; before this.dialogRef.close() in the confirm() cancellation path to match this pattern.
|
New Issues (17)Checkmarx found the following issues in this Pull Request
|
- Changed cancel button text from "Keep editing" to "Back to editing" for clarity. - Updated dialog type to "danger" to better reflect the action's implications. - Added option to hide the dialog icon for a cleaner interface. - Localized new button text and updated existing localization for discard edits confirmation.
|







🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-31364
📔 Objective
Adds a discard edits modal when navigating away with changes in the opened policy drawer.
📸 Screenshots