Skip to content

Commit

Permalink
IBX-6729: Drafts should be removed from user menu (#939)
Browse files Browse the repository at this point in the history
Co-authored-by: Jakub Brzegowski <[email protected]>
  • Loading branch information
GrabowskiM and tischsoic authored Oct 19, 2023
1 parent 1adcd98 commit 6accf58
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
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

0 comments on commit 6accf58

Please sign in to comment.