From bc3ce24f64ed4098bf6666021c90ffa210bfa270 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Mon, 18 Nov 2024 08:55:52 +0100 Subject: [PATCH] IBX-8418: Added drafts deletion warning to trash modal (#1321) Co-authored-by: mikolaj Co-authored-by: katarzynazawada <> --- .../Resources/config/services/forms.yaml | 4 ++ .../config/services/test/components.yaml | 2 + src/bundle/Resources/public/scss/_modals.scss | 15 +++++++ .../translations/ibexa_drafts.en.xliff | 5 +++ .../Behat/Component/DeleteContentDialog.php | 26 +++++++++++ src/lib/Behat/Page/ContentViewPage.php | 8 +++- .../CanHaveDrafts.php | 43 +++++++++++++++++++ 7 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/lib/Behat/Component/DeleteContentDialog.php create mode 100644 src/lib/Form/TrashLocationOptionProvider/CanHaveDrafts.php diff --git a/src/bundle/Resources/config/services/forms.yaml b/src/bundle/Resources/config/services/forms.yaml index bdd11af7d7..f5ad33e4ce 100644 --- a/src/bundle/Resources/config/services/forms.yaml +++ b/src/bundle/Resources/config/services/forms.yaml @@ -379,6 +379,10 @@ services: tags: - { name: ibexa.admin_ui.form.trash_location_option, priority: 60 } + Ibexa\AdminUi\Form\TrashLocationOptionProvider\CanHaveDrafts: + tags: + - { name: ibexa.admin_ui.form.trash_location_option, priority: 20 } + Ibexa\AdminUi\Form\TrashLocationOptionProvider\OptionsFactory: arguments: [!tagged ibexa.admin_ui.form.trash_location_option] diff --git a/src/bundle/Resources/config/services/test/components.yaml b/src/bundle/Resources/config/services/test/components.yaml index cdc42cce9a..101c17fbdf 100644 --- a/src/bundle/Resources/config/services/test/components.yaml +++ b/src/bundle/Resources/config/services/test/components.yaml @@ -57,3 +57,5 @@ services: Ibexa\AdminUi\Behat\Component\PropertiesList: ~ Ibexa\AdminUi\Behat\Component\FullView: ~ + + Ibexa\AdminUi\Behat\Component\DeleteContentDialog: ~ diff --git a/src/bundle/Resources/public/scss/_modals.scss b/src/bundle/Resources/public/scss/_modals.scss index ff45e56ff6..b720929f1e 100644 --- a/src/bundle/Resources/public/scss/_modals.scss +++ b/src/bundle/Resources/public/scss/_modals.scss @@ -21,6 +21,21 @@ .modal-body { @include modal-body(); + + .ibexa-modal__trash-option { + .ibexa-modal__option-label { + margin-bottom: 0; + margin-top: calculateRem(18px); + } + + .ibexa-label { + font-size: calculateRem(16px); + } + + .ibexa-modal__option-description { + font-size: calculateRem(14px); + } + } } .modal-footer { diff --git a/src/bundle/Resources/translations/ibexa_drafts.en.xliff b/src/bundle/Resources/translations/ibexa_drafts.en.xliff index b71e873df7..1a0596f0a8 100644 --- a/src/bundle/Resources/translations/ibexa_drafts.en.xliff +++ b/src/bundle/Resources/translations/ibexa_drafts.en.xliff @@ -66,6 +66,11 @@ Version key: drafts.list.version + + Sending this content item to Trash will also delete all drafts of content items that haven’t been published yet, and belong to the trashed subtree. + Sending this content item to Trash will also delete all drafts of content items that haven’t been published yet, and belong to the trashed subtree. + key: trash.modal.send_to_trash_draft_warning.message + diff --git a/src/lib/Behat/Component/DeleteContentDialog.php b/src/lib/Behat/Component/DeleteContentDialog.php new file mode 100644 index 0000000000..574829ad1b --- /dev/null +++ b/src/lib/Behat/Component/DeleteContentDialog.php @@ -0,0 +1,26 @@ +getHTMLPage()->find($this->getLocator('trashConfirmCheckbox'))->click(); + } + + public function specifyLocators(): array + { + return array_merge(parent::specifyLocators(), [ + new VisibleCSSLocator('trashConfirmCheckbox', '.modal-content .ibexa-input--checkbox'), + ]); + } +} diff --git a/src/lib/Behat/Page/ContentViewPage.php b/src/lib/Behat/Page/ContentViewPage.php index 51b4a9d0c9..7ab43e378a 100644 --- a/src/lib/Behat/Page/ContentViewPage.php +++ b/src/lib/Behat/Page/ContentViewPage.php @@ -13,6 +13,7 @@ use Ibexa\AdminUi\Behat\Component\ContentActionsMenu; use Ibexa\AdminUi\Behat\Component\ContentItemAdminPreview; use Ibexa\AdminUi\Behat\Component\ContentTypePicker; +use Ibexa\AdminUi\Behat\Component\DeleteContentDialog; use Ibexa\AdminUi\Behat\Component\Dialog; use Ibexa\AdminUi\Behat\Component\IbexaDropdown; use Ibexa\AdminUi\Behat\Component\LanguagePicker; @@ -82,6 +83,8 @@ class ContentViewPage extends Page private UpperMenu $upperMenu; + private DeleteContentDialog $deleteContentDialog; + public function __construct( Session $session, Router $router, @@ -97,7 +100,8 @@ public function __construct( ArgumentParser $argumentParser, UniversalDiscoveryWidget $universalDiscoveryWidget, IbexaDropdown $ibexaDropdown, - UpperMenu $upperMenu + UpperMenu $upperMenu, + DeleteContentDialog $deleteContentDialog ) { parent::__construct($session, $router); $this->contentActionsMenu = $contentActionsMenu; @@ -113,6 +117,7 @@ public function __construct( $this->universalDiscoveryWidget = $universalDiscoveryWidget; $this->ibexaDropdown = $ibexaDropdown; $this->upperMenu = $upperMenu; + $this->deleteContentDialog = $deleteContentDialog; } public function startCreatingContent(string $contentTypeName, string $language = null) @@ -267,6 +272,7 @@ public function sendToTrash() { $this->contentActionsMenu->clickButton('Send to trash'); $this->dialog->verifyIsLoaded(); + $this->deleteContentDialog->confirmTrashing(); $this->dialog->confirm(); } diff --git a/src/lib/Form/TrashLocationOptionProvider/CanHaveDrafts.php b/src/lib/Form/TrashLocationOptionProvider/CanHaveDrafts.php new file mode 100644 index 0000000000..c070fd69ec --- /dev/null +++ b/src/lib/Form/TrashLocationOptionProvider/CanHaveDrafts.php @@ -0,0 +1,43 @@ +translator = $translator; + } + + public function supports(Location $location): bool + { + return true; + } + + public function addOptions(FormInterface $form, Location $location): void + { + $form + ->add('can_have_drafts', ChoiceType::class, [ + 'label' => + /** @Desc("Drafts") */ + $this->translator->trans('drafts.list', [], 'ibexa_drafts'), + 'help_multiline' => [ + /** @Desc("Sending this content item to Trash will also delete all drafts of content items that haven’t been published yet, and belong to the trashed subtree.") */ + $this->translator->trans('trash.modal.send_to_trash_draft_warning.message', [], 'ibexa_drafts'), + ], + ]); + } +}