Skip to content

Commit

Permalink
Remove roles count check from UserPermissions
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Sep 8, 2024
1 parent 9f27837 commit ac44dfd
Show file tree
Hide file tree
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
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Panel/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down
2 changes: 1 addition & 1 deletion tests/Cms/Roles/RolesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/Panel/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public function testOptions()
'changeLanguage' => true,
'changeName' => true,
'changePassword' => true,
'changeRole' => false, // just one role
'changeRole' => true,
'delete' => true,
'update' => true,
];
Expand Down

0 comments on commit ac44dfd

Please sign in to comment.