mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-13 00:41:59 +03:00
Revised role index list to align with user list
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
namespace BookStack\Http\Controllers;
|
||||
|
||||
use BookStack\Auth\Permissions\PermissionsRepo;
|
||||
use BookStack\Auth\Queries\AllRolesPaginatedAndSorted;
|
||||
use BookStack\Auth\Role;
|
||||
use BookStack\Exceptions\PermissionsException;
|
||||
use Exception;
|
||||
@ -11,11 +12,8 @@ use Illuminate\Validation\ValidationException;
|
||||
|
||||
class RoleController extends Controller
|
||||
{
|
||||
protected $permissionsRepo;
|
||||
protected PermissionsRepo $permissionsRepo;
|
||||
|
||||
/**
|
||||
* PermissionController constructor.
|
||||
*/
|
||||
public function __construct(PermissionsRepo $permissionsRepo)
|
||||
{
|
||||
$this->permissionsRepo = $permissionsRepo;
|
||||
@ -24,14 +22,25 @@ class RoleController extends Controller
|
||||
/**
|
||||
* Show a listing of the roles in the system.
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->checkPermission('user-roles-manage');
|
||||
$roles = $this->permissionsRepo->getAllRoles();
|
||||
|
||||
$listDetails = [
|
||||
'search' => $request->get('search', ''),
|
||||
'sort' => setting()->getForCurrentUser('roles_sort', 'display_name'),
|
||||
'order' => setting()->getForCurrentUser('roles_sort_order', 'asc'),
|
||||
];
|
||||
|
||||
$roles = (new AllRolesPaginatedAndSorted())->run(20, $listDetails);
|
||||
$roles->appends(['search' => $listDetails['search']]);
|
||||
|
||||
$this->setPageTitle(trans('settings.roles'));
|
||||
|
||||
return view('settings.roles.index', ['roles' => $roles]);
|
||||
return view('settings.roles.index', [
|
||||
'roles' => $roles,
|
||||
'listDetails' => $listDetails,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,16 +84,11 @@ class RoleController extends Controller
|
||||
|
||||
/**
|
||||
* Show the form for editing a user role.
|
||||
*
|
||||
* @throws PermissionsException
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
$this->checkPermission('user-roles-manage');
|
||||
$role = $this->permissionsRepo->getRoleById($id);
|
||||
if ($role->hidden) {
|
||||
throw new PermissionsException(trans('errors.role_cannot_be_edited'));
|
||||
}
|
||||
|
||||
$this->setPageTitle(trans('settings.role_edit'));
|
||||
|
||||
|
Reference in New Issue
Block a user