From bf58a190cfc68e2008f4c7c8a06745d65106ef33 Mon Sep 17 00:00:00 2001 From: AleksanderSklorz <115619721+AleksanderSklorz@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:44:29 +0100 Subject: [PATCH] [ACS-8999] rename confirmation button label for closing conversation dialog (#10431) * [ACS-8999] Correct styles for buttons in unsaved changes dialog for different size of buttons, allowed to set maxWidth of unsaved changes dialog * [ACS-8999] Unit tests --- .../unsaved-changes-dialog.component.scss | 2 +- .../unsaved-changes-dialog.model.ts | 1 + .../unsaved-changes.guard.spec.ts | 27 +++++++++++++++++++ .../unsaved-changes.guard.ts | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes-dialog.component.scss b/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes-dialog.component.scss index 44ce960f43..e09fab48cb 100644 --- a/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes-dialog.component.scss +++ b/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes-dialog.component.scss @@ -36,6 +36,7 @@ &-actions { margin-top: 11px; margin-bottom: 1px; + margin-left: 40px; padding: 0; align-items: flex-end; @@ -51,7 +52,6 @@ &-cancel-button, &-discard-changes-button { - padding: 4px 12px; height: 32px; display: flex; align-items: center; diff --git a/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes-dialog.model.ts b/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes-dialog.model.ts index fb753c3229..9fede8b1ea 100644 --- a/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes-dialog.model.ts +++ b/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes-dialog.model.ts @@ -20,4 +20,5 @@ export interface UnsavedChangesDialogData { confirmButtonText?: string; descriptionText?: string; headerText?: string; + maxWidth?: number | string; } diff --git a/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes.guard.spec.ts b/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes.guard.spec.ts index dcaf09ae37..7d5dc8cae6 100644 --- a/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes.guard.spec.ts +++ b/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes.guard.spec.ts @@ -123,6 +123,33 @@ describe('UnsavedChangesGuard', () => { expectGuardToBe(true, done, true); afterClosed$.next(false); }); + + it('should call open on dialog with correct parameters when maxWidth is not set', () => { + guard.unsaved = true; + guard.data = { + headerText: 'header' + }; + + guard.canDeactivate(); + expect(dialog.open).toHaveBeenCalledWith(UnsavedChangesDialogComponent, { + maxWidth: 346, + data: guard.data + }); + }); + + it('should call open on dialog with correct parameters when maxWidth is set', () => { + guard.unsaved = true; + guard.data = { + headerText: 'header', + maxWidth: 'none' + }; + + guard.canDeactivate(); + expect(dialog.open).toHaveBeenCalledWith(UnsavedChangesDialogComponent, { + maxWidth: 'none', + data: guard.data + }); + }); }); describe('Without auth', () => { diff --git a/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes.guard.ts b/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes.guard.ts index ca9df5ee00..1eb92a822f 100644 --- a/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes.guard.ts +++ b/lib/core/src/lib/dialogs/unsaved-changes-dialog/unsaved-changes.guard.ts @@ -49,7 +49,7 @@ export class UnsavedChangesGuard implements CanDeactivate { return this.unsaved ? this.dialog .open(UnsavedChangesDialogComponent, { - maxWidth: 346, + maxWidth: this.data?.maxWidth ?? 346, data: this.data }) .afterClosed()