1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Merge branch 'development' into bugfix/fix-being-unable-to-clear-filters

This commit is contained in:
Dan Brown
2022-10-15 15:12:55 +01:00
65 changed files with 1084 additions and 468 deletions

View File

@@ -14,9 +14,8 @@
]])
</div>
<main class="card content-wrap">
<h1 class="list-heading">{{ trans('entities.books_permissions') }}</h1>
@include('form.entity-permissions', ['model' => $book])
<main class="card content-wrap auto-height">
@include('form.entity-permissions', ['model' => $book, 'title' => trans('entities.books_permissions')])
</main>
</div>

View File

@@ -71,7 +71,7 @@
<h5>{{ trans('common.details') }}</h5>
<div class="blended-links">
@include('entities.meta', ['entity' => $book])
@if($book->restricted)
@if($book->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $book))
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">

View File

@@ -15,9 +15,8 @@
]])
</div>
<main class="card content-wrap">
<h1 class="list-heading">{{ trans('entities.chapters_permissions') }}</h1>
@include('form.entity-permissions', ['model' => $chapter])
<main class="card content-wrap auto-height">
@include('form.entity-permissions', ['model' => $chapter, 'title' => trans('entities.chapters_permissions')])
</main>
</div>

View File

@@ -69,7 +69,7 @@
<div class="blended-links">
@include('entities.meta', ['entity' => $chapter])
@if($book->restricted)
@if($book->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $book))
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
@@ -85,7 +85,7 @@
</div>
@endif
@if($chapter->restricted)
@if($chapter->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $chapter))
<a href="{{ $chapter->getUrl('/permissions') }}" class="entity-meta-item">

View File

@@ -5,7 +5,7 @@ $checked
$label
--}}
<label custom-checkbox class="toggle-switch @if($errors->has($name)) text-neg @endif">
<input type="checkbox" name="{{$name}}" value="{{ $value }}" @if($checked) checked="checked" @endif>
<input type="checkbox" name="{{$name}}" value="{{ $value }}" @if($checked) checked="checked" @endif @if($disabled ?? false) disabled="disabled" @endif>
<span tabindex="0" role="checkbox"
aria-checked="{{ $checked ? 'true' : 'false' }}"
class="custom-checkbox text-primary">@icon('check')</span>

View File

@@ -0,0 +1,88 @@
{{--
$role - The Role to display this row for.
$entityType - String identifier for type of entity having permissions applied.
$permission - The entity permission containing the permissions.
$inheriting - Boolean if the current row should be marked as inheriting default permissions. Used for "Everyone Else" role.
--}}
<div component="permissions-table" class="content-permissions-row flex-container-row justify-space-between wrap">
<div class="gap-x-m flex-container-row items-center px-l py-m flex">
<div class="text-large" title="{{ $role->id === 0 ? trans('entities.permissions_role_everyone_else') : trans('common.role') }}">
@icon($role->id === 0 ? 'groups' : 'role')
</div>
<span>
<strong>{{ $role->display_name }}</strong> <br>
<small class="text-muted">{{ $role->description }}</small>
</span>
@if($role->id !== 0)
<button type="button"
class="ml-auto flex-none text-small text-primary text-button hover-underline content-permissions-row-toggle-all hide-under-s"
refs="permissions-table@toggle-all"
><strong>{{ trans('common.toggle_all') }}</strong></button>
@endif
</div>
@if($role->id === 0)
<div class="px-l flex-container-row items-center" refs="entity-permissions@everyone-inherit">
@include('form.custom-checkbox', [
'name' => 'entity-permissions-inherit',
'label' => 'Inherit defaults',
'value' => 'true',
'checked' => $inheriting
])
</div>
@endif
<div class="flex-container-row justify-space-between gap-x-xl wrap items-center">
<input type="hidden" name="permissions[{{ $role->id }}][active]"
@if($inheriting) disabled="disabled" @endif
value="true">
<div class="px-l">
@include('form.custom-checkbox', [
'name' => 'permissions[' . $role->id . '][view]',
'label' => trans('common.view'),
'value' => 'true',
'checked' => $permission->view,
'disabled' => $inheriting
])
</div>
@if($entityType !== 'page')
<div class="px-l">
@include('form.custom-checkbox', [
'name' => 'permissions[' . $role->id . '][create]',
'label' => trans('common.create'),
'value' => 'true',
'checked' => $permission->create,
'disabled' => $inheriting
])
</div>
@endif
<div class="px-l">
@include('form.custom-checkbox', [
'name' => 'permissions[' . $role->id . '][update]',
'label' => trans('common.update'),
'value' => 'true',
'checked' => $permission->update,
'disabled' => $inheriting
])
</div>
<div class="px-l">
@include('form.custom-checkbox', [
'name' => 'permissions[' . $role->id . '][delete]',
'label' => trans('common.delete'),
'value' => 'true',
'checked' => $permission->delete,
'disabled' => $inheriting
])
</div>
</div>
@if($role->id !== 0)
<div class="flex-container-row items-center px-m py-s">
<button type="button"
class="text-neg p-m icon-button"
data-role-id="{{ $role->id }}"
data-role-name="{{ $role->display_name }}"
title="{{ trans('common.remove') }}">
@icon('close') <span class="hide-over-m ml-xs">{{ trans('common.remove') }}</span>
</button>
</div>
@endif
</div>

View File

@@ -1,54 +1,73 @@
<form action="{{ $model->getUrl('/permissions') }}" method="POST" entity-permissions-editor>
<?php
/** @var \BookStack\Auth\Permissions\PermissionFormData $data */
?>
<form component="entity-permissions"
option:entity-permissions:entity-type="{{ $model->getType() }}"
action="{{ $model->getUrl('/permissions') }}"
method="POST">
{!! csrf_field() !!}
<input type="hidden" name="_method" value="PUT">
<div class="grid half left-focus v-center">
<div class="grid half left-focus v-end gap-m wrap">
<div>
<p class="mb-none mt-m">{{ trans('entities.permissions_intro') }}</p>
<div>
@include('form.checkbox', [
'name' => 'restricted',
'label' => trans('entities.permissions_enable'),
])
</div>
<h1 class="list-heading">{{ $title }}</h1>
<p class="text-muted mb-s">
{{ trans('entities.permissions_desc') }}
@if($model instanceof \BookStack\Entities\Models\Book)
<br> {{ trans('entities.permissions_book_cascade') }}
@elseif($model instanceof \BookStack\Entities\Models\Chapter)
<br> {{ trans('entities.permissions_chapter_cascade') }}
@endif
</p>
@if($model instanceof \BookStack\Entities\Models\Bookshelf)
<p class="text-warn">{{ trans('entities.shelves_permissions_cascade_warning') }}</p>
@endif
</div>
<div>
<div class="form-group">
<div class="flex-container-row justify-flex-end">
<div class="form-group mb-m">
<label for="owner">{{ trans('entities.permissions_owner') }}</label>
@include('form.user-select', ['user' => $model->ownedBy, 'name' => 'owned_by'])
</div>
</div>
</div>
@if($model instanceof \BookStack\Entities\Models\Bookshelf)
<p class="text-warn">{{ trans('entities.shelves_permissions_cascade_warning') }}</p>
@endif
<hr>
<table permissions-table class="table permissions-table toggle-switch-list" style="{{ !$model->restricted ? 'display: none' : '' }}">
<tr>
<th>{{ trans('common.role') }}</th>
<th colspan="{{ $model->isA('page') ? '3' : '4' }}">
{{ trans('common.actions') }}
<a href="#" permissions-table-toggle-all class="text-small ml-m text-primary">{{ trans('common.toggle_all') }}</a>
</th>
</tr>
@foreach(\BookStack\Auth\Role::restrictable() as $role)
<tr>
<td width="33%" class="pt-m">
{{ $role->display_name }}
<a href="#" permissions-table-toggle-all-in-row class="text-small float right ml-m text-primary">{{ trans('common.toggle_all') }}</a>
</td>
<td>@include('form.restriction-checkbox', ['name'=>'restrictions', 'label' => trans('common.view'), 'action' => 'view'])</td>
@if(!$model->isA('page'))
<td>@include('form.restriction-checkbox', ['name'=>'restrictions', 'label' => trans('common.create'), 'action' => 'create'])</td>
@endif
<td>@include('form.restriction-checkbox', ['name'=>'restrictions', 'label' => trans('common.update'), 'action' => 'update'])</td>
<td>@include('form.restriction-checkbox', ['name'=>'restrictions', 'label' => trans('common.delete'), 'action' => 'delete'])</td>
</tr>
<div refs="entity-permissions@role-container" class="content-permissions mt-m mb-m">
@foreach($data->permissionsWithRoles() as $permission)
@include('form.entity-permissions-row', [
'permission' => $permission,
'role' => $permission->role,
'entityType' => $model->getType(),
'inheriting' => false,
])
@endforeach
</table>
</div>
<div class="flex-container-row justify-flex-end mb-xl">
<div class="flex-container-row items-center gap-m">
<label for="role_select" class="m-none p-none"><span class="bold">{{ trans('entities.permissions_role_override') }}</span></label>
<select name="role_select" id="role_select" refs="entity-permissions@role-select">
<option value="">{{ trans('common.select') }}</option>
@foreach($data->rolesNotAssigned() as $role)
<option value="{{ $role->id }}">{{ $role->display_name }}</option>
@endforeach
</select>
</div>
</div>
<div class="content-permissions mt-m mb-xl">
@include('form.entity-permissions-row', [
'role' => $data->everyoneElseRole(),
'permission' => $data->everyoneElseEntityPermission(),
'entityType' => $model->getType(),
'inheriting' => !$model->permissions()->where('role_id', '=', 0)->exists(),
])
</div>
<hr class="mb-m">
<div class="text-right">
<a href="{{ $model->getUrl() }}" class="button outline">{{ trans('common.cancel') }}</a>

View File

@@ -1,13 +0,0 @@
{{--
$name
$label
$role
$action
$model?
--}}
@include('form.custom-checkbox', [
'name' => $name . '[' . $role->id . '][' . $action . ']',
'label' => $label,
'value' => 'true',
'checked' => isset($model) && $model->hasRestriction($role->id, $action)
])

View File

@@ -16,9 +16,8 @@
]])
</div>
<main class="card content-wrap">
<h1 class="list-heading">{{ trans('entities.pages_permissions') }}</h1>
@include('form.entity-permissions', ['model' => $page])
<main class="card content-wrap auto-height">
@include('form.entity-permissions', ['model' => $page, 'title' => trans('entities.pages_permissions')])
</main>
</div>

View File

@@ -81,7 +81,7 @@
<div class="blended-links">
@include('entities.meta', ['entity' => $page])
@if($book->restricted)
@if($book->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $book))
<a href="{{ $book->getUrl('/permissions') }}" class="entity-meta-item">
@@ -97,7 +97,7 @@
</div>
@endif
@if($page->chapter && $page->chapter->restricted)
@if($page->chapter && $page->chapter->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $page->chapter))
<a href="{{ $page->chapter->getUrl('/permissions') }}" class="entity-meta-item">
@@ -113,7 +113,7 @@
</div>
@endif
@if($page->restricted)
@if($page->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $page))
<a href="{{ $page->getUrl('/permissions') }}" class="entity-meta-item">

View File

@@ -26,9 +26,9 @@
</div>
</div>
<div permissions-table>
<div component="permissions-table">
<label class="setting-list-label">{{ trans('settings.role_system') }}</label>
<a href="#" permissions-table-toggle-all class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
<a href="#" refs="permissions-table@toggle-all" class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
<div class="toggle-switch-list grid half mt-m">
<div>
@@ -56,20 +56,20 @@
<p class="text-warn">{{ trans('settings.role_asset_admins') }}</p>
@endif
<table permissions-table class="table toggle-switch-list compact permissions-table">
<table component="permissions-table" class="table toggle-switch-list compact permissions-table">
<tr>
<th width="20%">
<a href="#" permissions-table-toggle-all class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
<a href="#" refs="permissions-table@toggle-all" class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
</th>
<th width="20%" permissions-table-toggle-all-in-column>{{ trans('common.create') }}</th>
<th width="20%" permissions-table-toggle-all-in-column>{{ trans('common.view') }}</th>
<th width="20%" permissions-table-toggle-all-in-column>{{ trans('common.edit') }}</th>
<th width="20%" permissions-table-toggle-all-in-column>{{ trans('common.delete') }}</th>
<th width="20%" refs="permissions-table@toggle-column">{{ trans('common.create') }}</th>
<th width="20%" refs="permissions-table@toggle-column">{{ trans('common.view') }}</th>
<th width="20%" refs="permissions-table@toggle-column">{{ trans('common.edit') }}</th>
<th width="20%" refs="permissions-table@toggle-column">{{ trans('common.delete') }}</th>
</tr>
<tr>
<td>
<div>{{ trans('entities.shelves') }}</div>
<a href="#" permissions-table-toggle-all-in-row class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
<a href="#" refs="permissions-table@toggle-row" class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
</td>
<td>
@include('settings.roles.parts.checkbox', ['permission' => 'bookshelf-create-all', 'label' => trans('settings.role_all')])
@@ -93,7 +93,7 @@
<tr>
<td>
<div>{{ trans('entities.books') }}</div>
<a href="#" permissions-table-toggle-all-in-row class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
<a href="#" refs="permissions-table@toggle-row" class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
</td>
<td>
@include('settings.roles.parts.checkbox', ['permission' => 'book-create-all', 'label' => trans('settings.role_all')])
@@ -117,7 +117,7 @@
<tr>
<td>
<div>{{ trans('entities.chapters') }}</div>
<a href="#" permissions-table-toggle-all-in-row class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
<a href="#" refs="permissions-table@toggle-row" class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
</td>
<td>
@include('settings.roles.parts.checkbox', ['permission' => 'chapter-create-own', 'label' => trans('settings.role_own')])
@@ -143,7 +143,7 @@
<tr>
<td>
<div>{{ trans('entities.pages') }}</div>
<a href="#" permissions-table-toggle-all-in-row class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
<a href="#" refs="permissions-table@toggle-row" class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
</td>
<td>
@include('settings.roles.parts.checkbox', ['permission' => 'page-create-own', 'label' => trans('settings.role_own')])
@@ -169,7 +169,7 @@
<tr>
<td>
<div>{{ trans('entities.images') }}</div>
<a href="#" permissions-table-toggle-all-in-row class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
<a href="#" refs="permissions-table@toggle-row" class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
</td>
<td>@include('settings.roles.parts.checkbox', ['permission' => 'image-create-all', 'label' => ''])</td>
<td style="line-height:1.2;"><small class="faded">{{ trans('settings.role_controlled_by_asset') }}<sup>1</sup></small></td>
@@ -187,7 +187,7 @@
<tr>
<td>
<div>{{ trans('entities.attachments') }}</div>
<a href="#" permissions-table-toggle-all-in-row class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
<a href="#" refs="permissions-table@toggle-row" class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
</td>
<td>@include('settings.roles.parts.checkbox', ['permission' => 'attachment-create-all', 'label' => ''])</td>
<td style="line-height:1.2;"><small class="faded">{{ trans('settings.role_controlled_by_asset') }}</small></td>
@@ -205,7 +205,7 @@
<tr>
<td>
<div>{{ trans('entities.comments') }}</div>
<a href="#" permissions-table-toggle-all-in-row class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
<a href="#" refs="permissions-table@toggle-row" class="text-small text-primary">{{ trans('common.toggle_all') }}</a>
</td>
<td>@include('settings.roles.parts.checkbox', ['permission' => 'comment-create-all', 'label' => ''])</td>
<td style="line-height:1.2;"><small class="faded">{{ trans('settings.role_controlled_by_asset') }}</small></td>

View File

@@ -2,7 +2,7 @@
@section('body')
<div class="container small">
<div class="container">
<div class="my-s">
@include('entities.breadcrumbs', ['crumbs' => [
@@ -15,14 +15,15 @@
</div>
<div class="card content-wrap auto-height">
<h1 class="list-heading">{{ trans('entities.shelves_permissions') }}</h1>
@include('form.entity-permissions', ['model' => $shelf])
@include('form.entity-permissions', ['model' => $shelf, 'title' => trans('entities.shelves_permissions')])
</div>
<div class="card content-wrap auto-height">
<h2 class="list-heading">{{ trans('entities.shelves_copy_permissions_to_books') }}</h2>
<p>{{ trans('entities.shelves_copy_permissions_explain') }}</p>
<form action="{{ $shelf->getUrl('/copy-permissions') }}" method="post" class="text-right">
<div class="card content-wrap auto-height flex-container-row items-center gap-x-xl wrap">
<div class="flex">
<h2 class="list-heading">{{ trans('entities.shelves_copy_permissions_to_books') }}</h2>
<p>{{ trans('entities.shelves_copy_permissions_explain') }}</p>
</div>
<form action="{{ $shelf->getUrl('/copy-permissions') }}" method="post" class="flex text-right">
{{ csrf_field() }}
<button class="button">{{ trans('entities.shelves_copy_permissions') }}</button>
</form>

View File

@@ -85,7 +85,7 @@
<h5>{{ trans('common.details') }}</h5>
<div class="blended-links">
@include('entities.meta', ['entity' => $shelf])
@if($shelf->restricted)
@if($shelf->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $shelf))
<a href="{{ $shelf->getUrl('/permissions') }}" class="entity-meta-item">