Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove roles count check from UserPermissions
Browse files Browse the repository at this point in the history
distantnative committed Sep 8, 2024

Verified

This commit was signed with the committer’s verified signature.
pradyunsg Pradyun Gedam
1 parent 9f27837 commit ac44dfd
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Cms/UserPermissions.php
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ public function __construct(User $model)

protected function canChangeRole(): bool
{
return $this->model->roles()->count() > 1;
return true;
}

protected function canCreate(): bool
2 changes: 1 addition & 1 deletion src/Panel/User.php
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ public function dropdown(array $options = []): array
'dialog' => $url . '/changeRole',
'icon' => 'bolt',
'text' => I18n::translate('user.changeRole'),
'disabled' => $this->isDisabledDropdownOption('changeRole', $options, $permissions)
'disabled' => $this->isDisabledDropdownOption('changeRole', $options, $permissions) || $this->model->roles('change')->count() < 2
];

$result[] = [
2 changes: 1 addition & 1 deletion tests/Cms/Roles/RolesTest.php
Original file line number Diff line number Diff line change
@@ -151,7 +151,7 @@ public function testCanBeChanged()

$this->assertInstanceOf(Roles::class, $roles);
$this->assertCount(2, $roles);
$this->assertCount(1, $canBeChanged);
$this->assertCount(2, $canBeChanged);
}

public function testCanBeCreated()
2 changes: 1 addition & 1 deletion tests/Panel/UserTest.php
Original file line number Diff line number Diff line change
@@ -275,7 +275,7 @@ public function testOptions()
'changeLanguage' => true,
'changeName' => true,
'changePassword' => true,
'changeRole' => false, // just one role
'changeRole' => true,
'delete' => true,
'update' => true,
];

0 comments on commit ac44dfd

Please sign in to comment.