diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6c0b4b0ad4..29ca53b8d0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -456,7 +456,7 @@ parameters: path: src/bundle/Controller/LinkManagerController.php - - message: "#^Cannot access offset 0 on iterable\\\\.$#" + message: "#^Cannot access offset 0 on iterable\\\\.$#" count: 1 path: src/bundle/Controller/LocationController.php @@ -9546,7 +9546,7 @@ parameters: path: src/lib/UI/Dataset/VersionsDataset.php - - message: "#^Parameter \\#2 \\$array of function array_map expects array, iterable\\ given\\.$#" + message: "#^Parameter \\#2 \\$array of function array_map expects array, iterable\\ given\\.$#" count: 1 path: src/lib/UI/Dataset/VersionsDataset.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'), + ], + ]); + } +}