Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-6729: Drafts should be removed from user menu #939

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/bundle/Resources/translations/ibexa_menu.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,6 @@
<target state="new">Logout</target>
<note>key: user__content</note>
</trans-unit>
<trans-unit id="22a2aa3863b8f6a0ab24403998badeb4bb196254" resname="user__drafts">
<source>Drafts</source>
<target state="new">Drafts</target>
<note>key: user__drafts</note>
</trans-unit>
<trans-unit id="d4a0cfb90774164e94f11e2a4f019a2538faebcf" resname="user__settings">
<source>User settings</source>
<target state="new">User settings</target>
Expand Down
21 changes: 1 addition & 20 deletions src/lib/Menu/UserMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

use Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent;
use Ibexa\Contracts\AdminUi\Menu\AbstractBuilder;
use Ibexa\Contracts\Core\Repository\PermissionResolver;
use JMS\TranslationBundle\Model\Message;
use JMS\TranslationBundle\Translation\TranslationContainerInterface;
use Knp\Menu\ItemInterface;
Expand All @@ -27,25 +26,19 @@ class UserMenuBuilder extends AbstractBuilder implements TranslationContainerInt
public const ITEM_LOGOUT = 'user__content';
public const ITEM_USER_SETTINGS = 'user__settings';
public const ITEM_BOOKMARK = 'user__bookmark';
public const ITEM_DRAFTS = 'user__drafts';
public const ITEM_NOTIFICATION = 'menu.notification';

/** @var \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface */
private $tokenStorage;

/** @var \Ibexa\Contracts\Core\Repository\PermissionResolver */
private $permissionResolver;

public function __construct(
MenuItemFactory $factory,
EventDispatcherInterface $eventDispatcher,
TokenStorageInterface $tokenStorage,
PermissionResolver $permissionResolver
TokenStorageInterface $tokenStorage
) {
parent::__construct($factory, $eventDispatcher);

$this->tokenStorage = $tokenStorage;
$this->permissionResolver = $permissionResolver;
}

/**
Expand All @@ -69,17 +62,6 @@ public function createStructure(array $options): ItemInterface

$token = $this->tokenStorage->getToken();
if (null !== $token && is_object($token->getUser())) {
if ($this->permissionResolver->hasAccess('content', 'versionread') !== false) {
$menu->addChild(
$this->createMenuItem(self::ITEM_DRAFTS, [
'route' => 'ibexa.content_draft.list',
'extras' => [
'orderNumber' => 30,
],
])
);
}

$menu->addChild(
$this->createMenuItem(self::ITEM_USER_SETTINGS, [
'route' => 'ibexa.user_settings.list',
Expand Down Expand Up @@ -111,7 +93,6 @@ public static function getTranslationMessages(): array
return [
(new Message(self::ITEM_LOGOUT, 'ibexa_menu'))->setDesc('Logout'),
(new Message(self::ITEM_USER_SETTINGS, 'ibexa_menu'))->setDesc('User settings'),
(new Message(self::ITEM_DRAFTS, 'ibexa_menu'))->setDesc('Drafts'),
(new Message(self::ITEM_NOTIFICATION, 'ibexa_notifications'))->setDesc('View Notifications'),
];
}
Expand Down
Loading