Skip to content

Commit

Permalink
Merge pull request #708 from ezsystems/ezp-29793-permission-aware-das…
Browse files Browse the repository at this point in the history
…hboard-button

EZP-29793: Implement permissions for the Create button on the dashboard
  • Loading branch information
Łukasz Serwatka committed Nov 8, 2018
2 parents 029bee5 + 988a643 commit 997b274
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/bundle/Controller/DashboardController.php
Expand Up @@ -10,14 +10,23 @@


use EzSystems\EzPlatformAdminUi\Form\Data\Content\Draft\ContentEditData; use EzSystems\EzPlatformAdminUi\Form\Data\Content\Draft\ContentEditData;
use EzSystems\EzPlatformAdminUi\Form\Factory\FormFactory; use EzSystems\EzPlatformAdminUi\Form\Factory\FormFactory;
use eZ\Publish\API\Repository\PermissionResolver;


class DashboardController extends Controller class DashboardController extends Controller
{ {
protected $formFactory; protected $formFactory;


public function __construct(FormFactory $formFactory) /** @var \eZ\Publish\API\Repository\PermissionResolver */
private $permissionResolver;

/**
* @param \EzSystems\EzplatformAdminUi\Form\Factory\FormFactory $formFactory
* @param \eZ\Publish\API\Repository\PermissionResolver $permissionResolver
*/
public function __construct(FormFactory $formFactory, PermissionResolver $permissionResolver)
{ {
$this->formFactory = $formFactory; $this->formFactory = $formFactory;
$this->permissionResolver = $permissionResolver;
} }


public function dashboardAction() public function dashboardAction()
Expand All @@ -28,6 +37,7 @@ public function dashboardAction()


return $this->render('@ezdesign/dashboard/dashboard.html.twig', [ return $this->render('@ezdesign/dashboard/dashboard.html.twig', [
'form_edit' => $editForm->createView(), 'form_edit' => $editForm->createView(),
'can_create_content' => $this->permissionResolver->hasAccess('content', 'create'),
]); ]);
} }
} }
5 changes: 5 additions & 0 deletions src/bundle/Resources/translations/dashboard.en.xliff
Expand Up @@ -106,6 +106,11 @@
<target state="new">Me</target> <target state="new">Me</target>
<note>key: me</note> <note>key: me</note>
</trans-unit> </trans-unit>
<trans-unit id="013cb5f0c7391fd9db25ef277f72bd0d3b62a0e3" resname="my.dashboard">
<source>My dashboard</source>
<target state="new">My dashboard</target>
<note>key: my.dashboard</note>
</trans-unit>
<trans-unit id="c4d3f17636317e532c589f3008d82c263ab5c39d" resname="tab.name.everyone_content"> <trans-unit id="c4d3f17636317e532c589f3008d82c263ab5c39d" resname="tab.name.everyone_content">
<source>Content</source> <source>Content</source>
<target state="new">Content</target> <target state="new">Content</target>
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/translations/menu.en.xliff
Expand Up @@ -361,7 +361,7 @@
<target state="new">Logout</target> <target state="new">Logout</target>
<note>key: user__content</note> <note>key: user__content</note>
</trans-unit> </trans-unit>
<trans-unit id="b244f658b186fa1af8074bdf2f0e83752b504904" resname="user__drafts"> <trans-unit id="22a2aa3863b8f6a0ab24403998badeb4bb196254" resname="user__drafts">
<source>Drafts</source> <source>Drafts</source>
<target state="new">Drafts</target> <target state="new">Drafts</target>
<note>key: user__drafts</note> <note>key: user__drafts</note>
Expand Down
6 changes: 3 additions & 3 deletions src/bundle/Resources/views/dashboard/dashboard.html.twig
Expand Up @@ -10,10 +10,10 @@
<div class="container-fluid ez-header"> <div class="container-fluid ez-header">
<div class="col-sm-12"> <div class="col-sm-12">
<div class="container ez-dashboard__header"> <div class="container ez-dashboard__header">
<h1 class="py-3">My dashboard</h1> <h1 class="py-3">{{ 'my.dashboard'|trans|desc('My dashboard') }}</h1>
<div class="ez-dashboard__create"> <div class="ez-dashboard__create">
<button class="btn btn-primary ez-btn--cotf-create" data-udw-config="{{ ez_udw_config('create', {}) }}"> <button type="button" class="btn btn-primary ez-btn--cotf-create" data-udw-config="{{ ez_udw_config('create', {}) }}" {% if not can_create_content %}disabled{% endif %}>
<svg class="ez-icon ez-icon--medium ez-icon--light ez-icon-create"> <svg class="ez-icon ez-icon--medium ez-icon--light">
<use xlink:href="{{ asset('bundles/ezplatformadminui/img/ez-icons.svg') }}#create"></use> <use xlink:href="{{ asset('bundles/ezplatformadminui/img/ez-icons.svg') }}#create"></use>
</svg> </svg>
<span>{{ 'dashboard.create'|trans|desc('Create') }}</span> <span>{{ 'dashboard.create'|trans|desc('Create') }}</span>
Expand Down

0 comments on commit 997b274

Please sign in to comment.