fix: [orggroups:ui] Aligned UI with what users can actually do

refacto/CRUDComponent
Sami Mokaddem 2023-10-30 10:45:38 +01:00
parent b987444da2
commit 1a7320e363
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 13 additions and 2 deletions

View File

@ -8,7 +8,7 @@ class OrgGroupsNavigation extends BaseNavigation
public function addLinks()
{
$controller = 'OrgGroups';
if (empty($this->viewVars['canEdit'])) {
if (empty($this->viewVars['canEditDefinition'])) {
$this->bcf->removeLink($controller, 'view', $controller, 'edit');
$this->bcf->removeLink($controller, 'edit', $controller, 'edit');
}
@ -17,9 +17,10 @@ class OrgGroupsNavigation extends BaseNavigation
public function addActions()
{
$controller = 'OrgGroups';
if (empty($this->viewVars['canEdit'])) {
if (empty($this->viewVars['canEditDefinition'])) {
$this->bcf->removeAction($controller, 'view', $controller, 'delete');
$this->bcf->removeAction($controller, 'edit', $controller, 'delete');
$this->bcf->removeAction($controller, 'view', $controller, 'add');
}
}
}

View File

@ -58,6 +58,7 @@ class OrgGroupsController extends AppController
return $responsePayload;
}
$this->set('canEdit', $this->canEdit($id));
$this->set('canEditDefinition', $this->canEditDefinition($id));
}
public function edit($id)
@ -136,6 +137,15 @@ class OrgGroupsController extends AppController
return false;
}
private function canEditDefinition($groupId): bool
{
$currentUser = $this->ACL->getUser();
if ($currentUser['role']['perm_admin']) {
return true;
}
return false;
}
// Listing should be available to all, it's purely informational
public function listAdmins($groupId)
{