mirror of
https://github.com/getformwork/formwork.git
synced 2025-01-17 21:49:04 +01:00
Remove logic from sidebar partials
This commit is contained in:
parent
212fea8634
commit
5563df22d9
@ -106,7 +106,51 @@ abstract class AbstractController extends BaseAbstractController
|
||||
'csrfToken' => $this->csrfToken->get(),
|
||||
'modals' => implode('', $this->modals),
|
||||
'colorScheme' => $this->getColorScheme(),
|
||||
'appConfig' => Json::encode([
|
||||
'navigation' => [
|
||||
'dashboard' => [
|
||||
'label' => $this->translate('panel.dashboard.dashboard'),
|
||||
'uri' => '/dashboard/',
|
||||
'permissions' => 'dashboard',
|
||||
'badge' => null,
|
||||
],
|
||||
'pages' => [
|
||||
'label' => $this->translate('panel.pages.pages'),
|
||||
'uri' => '/pages/',
|
||||
'permissions' => 'pages',
|
||||
'badge' => $this->site->descendants()->count(),
|
||||
],
|
||||
'statistics' => [
|
||||
'label' => $this->translate('panel.statistics.statistics'),
|
||||
'uri' => '/statistics/',
|
||||
'permissions' => 'statistics',
|
||||
'badge' => null,
|
||||
],
|
||||
'users' => [
|
||||
'label' => $this->translate('panel.users.users'),
|
||||
'uri' => '/users/',
|
||||
'permissions' => 'users',
|
||||
'badge' => $this->panel->users()->count(),
|
||||
],
|
||||
'options' => [
|
||||
'label' => $this->translate('panel.options.options'),
|
||||
'uri' => '/options/',
|
||||
'permissions' => 'options',
|
||||
'badge' => null,
|
||||
],
|
||||
'tools' => [
|
||||
'label' => $this->translate('panel.tools.tools'),
|
||||
'uri' => '/tools/',
|
||||
'permissions' => 'tools',
|
||||
'badge' => null,
|
||||
],
|
||||
'logout' => [
|
||||
'label' => $this->translate('panel.login.logout'),
|
||||
'uri' => '/logout/',
|
||||
'permissions' => '*',
|
||||
'badge' => null,
|
||||
],
|
||||
],
|
||||
'appConfig' => Json::encode([
|
||||
'baseUri' => $this->panel()->panelUri(),
|
||||
'DateInput' => [
|
||||
'weekStarts' => $this->config->get('system.date.weekStarts'),
|
||||
|
@ -36,6 +36,10 @@ class Permissions
|
||||
*/
|
||||
public function has(string $permission): bool
|
||||
{
|
||||
if ($permission === '*') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (array_key_exists($permission, $this->permissions)) {
|
||||
return $this->permissions[$permission];
|
||||
}
|
||||
|
@ -15,65 +15,16 @@
|
||||
<div class="sidebar-wrapper">
|
||||
<h3 class="caption mb-8"><?= $this->translate('panel.manage') ?></h3>
|
||||
<ul class="sidebar-navigation">
|
||||
<?php
|
||||
if ($panel->user()->permissions()->has('dashboard')):
|
||||
?>
|
||||
<li class="<?= ($location === 'dashboard') ? 'active' : '' ?>">
|
||||
<a href="<?= $panel->uri('/dashboard/') ?>"><?= $this->translate('panel.dashboard.dashboard') ?></a>
|
||||
</li>
|
||||
<?php
|
||||
endif
|
||||
?>
|
||||
<?php
|
||||
if ($panel->user()->permissions()->has('pages')):
|
||||
?>
|
||||
<li class="<?= ($location === 'pages') ? 'active' : '' ?>">
|
||||
<a href="<?= $panel->uri('/pages/') ?>"><?= $this->translate('panel.pages.pages') ?></a>
|
||||
<span class="badge"><?= $app->site()->descendants()->count() ?></span>
|
||||
</li>
|
||||
<?php
|
||||
endif
|
||||
?>
|
||||
<?php
|
||||
if ($panel->user()->permissions()->has('options')):
|
||||
?>
|
||||
<li class="<?= ($location === 'options') ? 'active' : '' ?>">
|
||||
<a href="<?= $panel->uri('/options/') ?>"><?= $this->translate('panel.options.options') ?></a>
|
||||
</li>
|
||||
<?php
|
||||
endif
|
||||
?>
|
||||
<?php
|
||||
if ($panel->user()->permissions()->has('users')):
|
||||
?>
|
||||
<li class="<?= ($location === 'users') ? 'active' : '' ?>">
|
||||
<a href="<?= $panel->uri('/users/') ?>"><?= $this->translate('panel.users.users') ?></a>
|
||||
<span class="badge"><?= $panel->users()->count() ?></span>
|
||||
</li>
|
||||
<?php
|
||||
endif
|
||||
?>
|
||||
<?php
|
||||
if ($panel->user()->permissions()->has('statistics')):
|
||||
?>
|
||||
<li class="<?= ($location === 'statistics') ? 'active' : '' ?>">
|
||||
<a href="<?= $panel->uri('/statistics/') ?>"><?= $this->translate('panel.statistics.statistics') ?></a>
|
||||
</li>
|
||||
<?php
|
||||
endif
|
||||
?>
|
||||
<?php
|
||||
if ($panel->user()->permissions()->has('tools')):
|
||||
?>
|
||||
<li class="<?= ($location === 'tools') ? 'active' : '' ?>">
|
||||
<a href="<?= $panel->uri('/tools/') ?>"><?= $this->translate('panel.tools.tools') ?></a>
|
||||
</li>
|
||||
<?php
|
||||
endif
|
||||
?>
|
||||
<li>
|
||||
<a href="<?= $panel->uri('/logout/') ?>"><?= $this->translate('panel.login.logout') ?></a>
|
||||
<?php foreach ($navigation as $id => ['label' => $label, 'uri' => $uri, 'permissions' => $permissions, 'badge' => $badge]): ?>
|
||||
<?php if ($panel->user()->permissions()->has($permissions)): ?>
|
||||
<li class="<?= ($location === $id) ? 'active' : '' ?>">
|
||||
<a href="<?= $panel->uri($uri) ?>"><?= $label ?></a>
|
||||
<?php if ($badge): ?>
|
||||
<span class="badge"><?= $badge ?></span>
|
||||
<?php endif ?>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user