Skip to content

Commit

Permalink
IBX-8418: Added drafts deletion warning to trash modal (#1321)
Browse files Browse the repository at this point in the history
Co-authored-by: mikolaj <mikolaj.adamczyk@ez.no>
Co-authored-by: katarzynazawada <>
  • Loading branch information
barw4 and mikadamczyk authored Nov 18, 2024
1 parent 65f22bf commit bc3ce24
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/bundle/Resources/config/services/forms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 2 additions & 0 deletions src/bundle/Resources/config/services/test/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ services:
Ibexa\AdminUi\Behat\Component\PropertiesList: ~

Ibexa\AdminUi\Behat\Component\FullView: ~

Ibexa\AdminUi\Behat\Component\DeleteContentDialog: ~
15 changes: 15 additions & 0 deletions src/bundle/Resources/public/scss/_modals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/bundle/Resources/translations/ibexa_drafts.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
<target state="new">Version</target>
<note>key: drafts.list.version</note>
</trans-unit>
<trans-unit id="b107e8277d2dda6c41872a6478d99abbe9b46dc0" resname="trash.modal.send_to_trash_draft_warning.message">
<source>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.</source>
<target state="new">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.</target>
<note>key: trash.modal.send_to_trash_draft_warning.message</note>
</trans-unit>
</body>
</file>
</xliff>
26 changes: 26 additions & 0 deletions src/lib/Behat/Component/DeleteContentDialog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\AdminUi\Behat\Component;

use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;

class DeleteContentDialog extends Dialog
{
public function confirmTrashing(): void
{
$this->getHTMLPage()->find($this->getLocator('trashConfirmCheckbox'))->click();
}

public function specifyLocators(): array
{
return array_merge(parent::specifyLocators(), [
new VisibleCSSLocator('trashConfirmCheckbox', '.modal-content .ibexa-input--checkbox'),
]);
}
}
8 changes: 7 additions & 1 deletion src/lib/Behat/Page/ContentViewPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -82,6 +83,8 @@ class ContentViewPage extends Page

private UpperMenu $upperMenu;

private DeleteContentDialog $deleteContentDialog;

public function __construct(
Session $session,
Router $router,
Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -267,6 +272,7 @@ public function sendToTrash()
{
$this->contentActionsMenu->clickButton('Send to trash');
$this->dialog->verifyIsLoaded();
$this->deleteContentDialog->confirmTrashing();
$this->dialog->confirm();
}

Expand Down
43 changes: 43 additions & 0 deletions src/lib/Form/TrashLocationOptionProvider/CanHaveDrafts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\AdminUi\Form\TrashLocationOptionProvider;

use Ibexa\Contracts\Core\Repository\Values\Content\Location;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

final class CanHaveDrafts implements TrashLocationOptionProvider
{
private TranslatorInterface $translator;

public function __construct(TranslatorInterface $translator)
{
$this->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'),
],
]);
}
}

0 comments on commit bc3ce24

Please sign in to comment.