Split out settings view and made functional

- Split settings out to new views using a core shared layout.
- Extracted added language text to translation files.
- Updated settings routes to be dynamic to category.
- Added redirect for old primary settings route.
- Updated existing tests to cover settings route changes.
- Added tests to cover settings view.
- Improved contrast of settings links for dark mode.
This commit is contained in:
Dan Brown 2022-03-28 11:09:55 +01:00
parent 31dbf132b9
commit 895f656897
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
14 changed files with 373 additions and 332 deletions

View file

@ -9,11 +9,8 @@ use Illuminate\Http\Request;
class SettingController extends Controller
{
protected $imageRepo;
protected ImageRepo $imageRepo;
/**
* SettingController constructor.
*/
public function __construct(ImageRepo $imageRepo)
{
$this->imageRepo = $imageRepo;
@ -22,7 +19,7 @@ class SettingController extends Controller
/**
* Display a listing of the settings.
*/
public function index()
public function index(string $category)
{
$this->checkPermission('settings-manage');
$this->setPageTitle(trans('settings.settings'));
@ -30,7 +27,8 @@ class SettingController extends Controller
// Get application version
$version = trim(file_get_contents(base_path('version')));
return view('settings.index', [
return view('settings.' . $category, [
'category' => $category,
'version' => $version,
'guestUser' => User::getDefault(),
]);
@ -39,7 +37,7 @@ class SettingController extends Controller
/**
* Update the specified settings in storage.
*/
public function update(Request $request)
public function update(Request $request, string $category)
{
$this->preventAccessInDemoMode();
$this->checkPermission('settings-manage');
@ -57,7 +55,7 @@ class SettingController extends Controller
}
// Update logo image if set
if ($request->hasFile('app_logo')) {
if ($category === 'customization' && $request->hasFile('app_logo')) {
$logoFile = $request->file('app_logo');
$this->imageRepo->destroyByType('system');
$image = $this->imageRepo->saveNew($logoFile, 'system', 0, null, 86);
@ -65,16 +63,14 @@ class SettingController extends Controller
}
// Clear logo image if requested
if ($request->get('app_logo_reset', null)) {
if ($category === 'customization' && $request->get('app_logo_reset', null)) {
$this->imageRepo->destroyByType('system');
setting()->remove('app-logo');
}
$section = $request->get('section', '');
$this->logActivity(ActivityType::SETTINGS_UPDATE, $section);
$this->logActivity(ActivityType::SETTINGS_UPDATE, $category);
$this->showSuccessNotification(trans('settings.settings_save_success'));
$redirectLocation = '/settings#' . $section;
return redirect(rtrim($redirectLocation, '#'));
return redirect("/settings/${category}");
}
}

View file

@ -10,6 +10,8 @@ return [
'settings' => 'Settings',
'settings_save' => 'Save Settings',
'settings_save_success' => 'Settings saved',
'system_version' => 'System Version',
'categories' => 'Categories',
// App Settings
'app_customization' => 'Customization',

View file

@ -677,7 +677,7 @@ ul.pagination {
padding: $-s;
}
a:not(.active) {
@include lightDark(color, #444, #666);
@include lightDark(color, #444, #888);
}
a:hover {
@include lightDark(background-color, rgba(0, 0, 0, 0.05), rgba(255, 255, 255, 0.05));

View file

@ -0,0 +1,137 @@
@extends('settings.layout')
@section('card')
<h1 id="customization" class="list-heading">{{ trans('settings.app_customization') }}</h2>
<form action="{{ url("/settings/customization") }}" method="POST" enctype="multipart/form-data">
{!! csrf_field() !!}
<input type="hidden" name="section" value="customization">
<div class="setting-list">
<div class="grid half gap-xl">
<div>
<label for="setting-app-name" class="setting-list-label">{{ trans('settings.app_name') }}</label>
<p class="small">{{ trans('settings.app_name_desc') }}</p>
</div>
<div class="pt-xs">
<input type="text" value="{{ setting('app-name', 'BookStack') }}" name="setting-app-name" id="setting-app-name">
@include('form.toggle-switch', [
'name' => 'setting-app-name-header',
'value' => setting('app-name-header'),
'label' => trans('settings.app_name_header'),
])
</div>
</div>
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.app_editor') }}</label>
<p class="small">{{ trans('settings.app_editor_desc') }}</p>
</div>
<div class="pt-xs">
<select name="setting-app-editor" id="setting-app-editor">
<option @if(setting('app-editor') === 'wysiwyg') selected @endif value="wysiwyg">WYSIWYG</option>
<option @if(setting('app-editor') === 'markdown') selected @endif value="markdown">Markdown</option>
</select>
</div>
</div>
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.app_logo') }}</label>
<p class="small">{!! trans('settings.app_logo_desc') !!}</p>
</div>
<div class="pt-xs">
@include('form.image-picker', [
'removeName' => 'setting-app-logo',
'removeValue' => 'none',
'defaultImage' => url('/logo.png'),
'currentImage' => setting('app-logo'),
'name' => 'app_logo',
'imageClass' => 'logo-image',
])
</div>
</div>
<!-- Primary Color -->
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.app_primary_color') }}</label>
<p class="small">{!! trans('settings.app_primary_color_desc') !!}</p>
</div>
<div setting-app-color-picker class="text-m-right pt-xs">
<input type="color" data-default="#206ea7" data-current="{{ setting('app-color') }}" value="{{ setting('app-color') }}" name="setting-app-color" id="setting-app-color" placeholder="#206ea7">
<input type="hidden" value="{{ setting('app-color-light') }}" name="setting-app-color-light" id="setting-app-color-light">
<div class="pr-s">
<button type="button" class="text-button text-muted mt-s" setting-app-color-picker-default>{{ trans('common.default') }}</button>
<span class="sep">|</span>
<button type="button" class="text-button text-muted mt-s" setting-app-color-picker-reset>{{ trans('common.reset') }}</button>
</div>
</div>
</div>
<!-- Entity Color -->
<div class="pb-l">
<div>
<label class="setting-list-label">{{ trans('settings.content_colors') }}</label>
<p class="small">{!! trans('settings.content_colors_desc') !!}</p>
</div>
<div class="grid half pt-m">
<div>
@include('settings.parts.setting-entity-color-picker', ['type' => 'bookshelf'])
@include('settings.parts.setting-entity-color-picker', ['type' => 'book'])
@include('settings.parts.setting-entity-color-picker', ['type' => 'chapter'])
</div>
<div>
@include('settings.parts.setting-entity-color-picker', ['type' => 'page'])
@include('settings.parts.setting-entity-color-picker', ['type' => 'page-draft'])
</div>
</div>
</div>
<div homepage-control id="homepage-control" class="grid half gap-xl">
<div>
<label for="setting-app-homepage" class="setting-list-label">{{ trans('settings.app_homepage') }}</label>
<p class="small">{{ trans('settings.app_homepage_desc') }}</p>
</div>
<div class="pt-xs">
<select name="setting-app-homepage-type" id="setting-app-homepage-type">
<option @if(setting('app-homepage-type') === 'default') selected @endif value="default">{{ trans('common.default') }}</option>
<option @if(setting('app-homepage-type') === 'books') selected @endif value="books">{{ trans('entities.books') }}</option>
<option @if(setting('app-homepage-type') === 'bookshelves') selected @endif value="bookshelves">{{ trans('entities.shelves') }}</option>
<option @if(setting('app-homepage-type') === 'page') selected @endif value="page">{{ trans('entities.pages_specific') }}</option>
</select>
<div page-picker-container style="display: none;" class="mt-m">
@include('settings.parts.page-picker', ['name' => 'setting-app-homepage', 'placeholder' => trans('settings.app_homepage_select'), 'value' => setting('app-homepage')])
</div>
</div>
</div>
<div>
<label for="setting-app-privacy-link" class="setting-list-label">{{ trans('settings.app_footer_links') }}</label>
<p class="small mb-m">{{ trans('settings.app_footer_links_desc') }}</p>
@include('settings.parts.footer-links', ['name' => 'setting-app-footer-links', 'value' => setting('app-footer-links', [])])
</div>
<div>
<label for="setting-app-custom-head" class="setting-list-label">{{ trans('settings.app_custom_html') }}</label>
<p class="small">{{ trans('settings.app_custom_html_desc') }}</p>
<textarea name="setting-app-custom-head" id="setting-app-custom-head" class="simple-code-input mt-m">{{ setting('app-custom-head', '') }}</textarea>
<p class="small text-right">{{ trans('settings.app_custom_html_disabled_notice') }}</p>
</div>
</div>
<div class="form-group text-right">
<button type="submit" class="button">{{ trans('settings.settings_save') }}</button>
</div>
</form>
@endsection
@section('after-content')
@include('entities.selector-popup', ['entityTypes' => 'page'])
@endsection

View file

@ -0,0 +1,66 @@
@extends('settings.layout')
@section('card')
<h1 id="features" class="list-heading">{{ trans('settings.app_features_security') }}</h1>
<form action="{{ url("/settings/features") }}" method="POST">
{!! csrf_field() !!}
<input type="hidden" name="section" value="features">
<div class="setting-list">
<div class="grid half gap-xl">
<div>
<label for="setting-app-public" class="setting-list-label">{{ trans('settings.app_public_access') }}</label>
<p class="small">{!! trans('settings.app_public_access_desc') !!}</p>
@if(userCan('users-manage'))
<p class="small mb-none">
<a href="{{ url($guestUser->getEditUrl()) }}">{!! trans('settings.app_public_access_desc_guest') !!}</a>
</p>
@endif
</div>
<div>
@include('form.toggle-switch', [
'name' => 'setting-app-public',
'value' => setting('app-public'),
'label' => trans('settings.app_public_access_toggle'),
])
</div>
</div>
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.app_secure_images') }}</label>
<p class="small">{{ trans('settings.app_secure_images_desc') }}</p>
</div>
<div>
@include('form.toggle-switch', [
'name' => 'setting-app-secure-images',
'value' => setting('app-secure-images'),
'label' => trans('settings.app_secure_images_toggle'),
])
</div>
</div>
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.app_disable_comments') }}</label>
<p class="small">{!! trans('settings.app_disable_comments_desc') !!}</p>
</div>
<div>
@include('form.toggle-switch', [
'name' => 'setting-app-disable-comments',
'value' => setting('app-disable-comments'),
'label' => trans('settings.app_disable_comments_toggle'),
])
</div>
</div>
</div>
<div class="form-group text-right">
<button type="submit" class="button">{{ trans('settings.settings_save') }}</button>
</div>
</form>
@endsection

View file

@ -1,300 +0,0 @@
@extends('layouts.simple')
@section('body')
<div class="container medium">
@include('settings.parts.navbar', ['selected' => 'settings'])
<div class="grid gap-xxl right-focus">
<div>
<h5>Categories</h5>
<div class="active-link-list in-sidebar">
<a href="#" class=" active">@icon('star') Features & Security</a>
<a href="#">@icon('palette') Customization</a>
<a href="#">@icon('lock') Registration</a>
</div>
<h5>Version</h5>
<div class="">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/BookStackApp/BookStack/releases">
BookStack @if(strpos($version, 'v') !== 0) version @endif {{ $version }}
</a>
</div>
</div>
<div>
<div class="card content-wrap auto-height">
<h2 id="features" class="list-heading">{{ trans('settings.app_features_security') }}</h2>
<form action="{{ url("/settings") }}" method="POST">
{!! csrf_field() !!}
<input type="hidden" name="section" value="features">
<div class="setting-list">
<div class="grid half gap-xl">
<div>
<label for="setting-app-public" class="setting-list-label">{{ trans('settings.app_public_access') }}</label>
<p class="small">{!! trans('settings.app_public_access_desc') !!}</p>
@if(userCan('users-manage'))
<p class="small mb-none">
<a href="{{ url($guestUser->getEditUrl()) }}">{!! trans('settings.app_public_access_desc_guest') !!}</a>
</p>
@endif
</div>
<div>
@include('form.toggle-switch', [
'name' => 'setting-app-public',
'value' => setting('app-public'),
'label' => trans('settings.app_public_access_toggle'),
])
</div>
</div>
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.app_secure_images') }}</label>
<p class="small">{{ trans('settings.app_secure_images_desc') }}</p>
</div>
<div>
@include('form.toggle-switch', [
'name' => 'setting-app-secure-images',
'value' => setting('app-secure-images'),
'label' => trans('settings.app_secure_images_toggle'),
])
</div>
</div>
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.app_disable_comments') }}</label>
<p class="small">{!! trans('settings.app_disable_comments_desc') !!}</p>
</div>
<div>
@include('form.toggle-switch', [
'name' => 'setting-app-disable-comments',
'value' => setting('app-disable-comments'),
'label' => trans('settings.app_disable_comments_toggle'),
])
</div>
</div>
</div>
<div class="form-group text-right">
<button type="submit" class="button">{{ trans('settings.settings_save') }}</button>
</div>
</form>
</div>
<div class="card content-wrap auto-height">
<h2 id="customization" class="list-heading">{{ trans('settings.app_customization') }}</h2>
<form action="{{ url("/settings") }}" method="POST" enctype="multipart/form-data">
{!! csrf_field() !!}
<input type="hidden" name="section" value="customization">
<div class="setting-list">
<div class="grid half gap-xl">
<div>
<label for="setting-app-name" class="setting-list-label">{{ trans('settings.app_name') }}</label>
<p class="small">{{ trans('settings.app_name_desc') }}</p>
</div>
<div class="pt-xs">
<input type="text" value="{{ setting('app-name', 'BookStack') }}" name="setting-app-name" id="setting-app-name">
@include('form.toggle-switch', [
'name' => 'setting-app-name-header',
'value' => setting('app-name-header'),
'label' => trans('settings.app_name_header'),
])
</div>
</div>
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.app_editor') }}</label>
<p class="small">{{ trans('settings.app_editor_desc') }}</p>
</div>
<div class="pt-xs">
<select name="setting-app-editor" id="setting-app-editor">
<option @if(setting('app-editor') === 'wysiwyg') selected @endif value="wysiwyg">WYSIWYG</option>
<option @if(setting('app-editor') === 'markdown') selected @endif value="markdown">Markdown</option>
</select>
</div>
</div>
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.app_logo') }}</label>
<p class="small">{!! trans('settings.app_logo_desc') !!}</p>
</div>
<div class="pt-xs">
@include('form.image-picker', [
'removeName' => 'setting-app-logo',
'removeValue' => 'none',
'defaultImage' => url('/logo.png'),
'currentImage' => setting('app-logo'),
'name' => 'app_logo',
'imageClass' => 'logo-image',
])
</div>
</div>
<!-- Primary Color -->
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.app_primary_color') }}</label>
<p class="small">{!! trans('settings.app_primary_color_desc') !!}</p>
</div>
<div setting-app-color-picker class="text-m-right pt-xs">
<input type="color" data-default="#206ea7" data-current="{{ setting('app-color') }}" value="{{ setting('app-color') }}" name="setting-app-color" id="setting-app-color" placeholder="#206ea7">
<input type="hidden" value="{{ setting('app-color-light') }}" name="setting-app-color-light" id="setting-app-color-light">
<div class="pr-s">
<button type="button" class="text-button text-muted mt-s" setting-app-color-picker-default>{{ trans('common.default') }}</button>
<span class="sep">|</span>
<button type="button" class="text-button text-muted mt-s" setting-app-color-picker-reset>{{ trans('common.reset') }}</button>
</div>
</div>
</div>
<!-- Entity Color -->
<div class="pb-l">
<div>
<label class="setting-list-label">{{ trans('settings.content_colors') }}</label>
<p class="small">{!! trans('settings.content_colors_desc') !!}</p>
</div>
<div class="grid half pt-m">
<div>
@include('settings.parts.setting-entity-color-picker', ['type' => 'bookshelf'])
@include('settings.parts.setting-entity-color-picker', ['type' => 'book'])
@include('settings.parts.setting-entity-color-picker', ['type' => 'chapter'])
</div>
<div>
@include('settings.parts.setting-entity-color-picker', ['type' => 'page'])
@include('settings.parts.setting-entity-color-picker', ['type' => 'page-draft'])
</div>
</div>
</div>
<div homepage-control id="homepage-control" class="grid half gap-xl">
<div>
<label for="setting-app-homepage" class="setting-list-label">{{ trans('settings.app_homepage') }}</label>
<p class="small">{{ trans('settings.app_homepage_desc') }}</p>
</div>
<div class="pt-xs">
<select name="setting-app-homepage-type" id="setting-app-homepage-type">
<option @if(setting('app-homepage-type') === 'default') selected @endif value="default">{{ trans('common.default') }}</option>
<option @if(setting('app-homepage-type') === 'books') selected @endif value="books">{{ trans('entities.books') }}</option>
<option @if(setting('app-homepage-type') === 'bookshelves') selected @endif value="bookshelves">{{ trans('entities.shelves') }}</option>
<option @if(setting('app-homepage-type') === 'page') selected @endif value="page">{{ trans('entities.pages_specific') }}</option>
</select>
<div page-picker-container style="display: none;" class="mt-m">
@include('settings.parts.page-picker', ['name' => 'setting-app-homepage', 'placeholder' => trans('settings.app_homepage_select'), 'value' => setting('app-homepage')])
</div>
</div>
</div>
<div>
<label for="setting-app-privacy-link" class="setting-list-label">{{ trans('settings.app_footer_links') }}</label>
<p class="small mb-m">{{ trans('settings.app_footer_links_desc') }}</p>
@include('settings.parts.footer-links', ['name' => 'setting-app-footer-links', 'value' => setting('app-footer-links', [])])
</div>
<div>
<label for="setting-app-custom-head" class="setting-list-label">{{ trans('settings.app_custom_html') }}</label>
<p class="small">{{ trans('settings.app_custom_html_desc') }}</p>
<textarea name="setting-app-custom-head" id="setting-app-custom-head" class="simple-code-input mt-m">{{ setting('app-custom-head', '') }}</textarea>
<p class="small text-right">{{ trans('settings.app_custom_html_disabled_notice') }}</p>
</div>
</div>
<div class="form-group text-right">
<button type="submit" class="button">{{ trans('settings.settings_save') }}</button>
</div>
</form>
</div>
<div class="card content-wrap auto-height">
<h2 id="registration" class="list-heading">{{ trans('settings.reg_settings') }}</h2>
<form action="{{ url("/settings") }}" method="POST">
{!! csrf_field() !!}
<input type="hidden" name="section" value="registration">
<div class="setting-list">
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.reg_enable') }}</label>
<p class="small">{!! trans('settings.reg_enable_desc') !!}</p>
</div>
<div>
@include('form.toggle-switch', [
'name' => 'setting-registration-enabled',
'value' => setting('registration-enabled'),
'label' => trans('settings.reg_enable_toggle')
])
@if(in_array(config('auth.method'), ['ldap', 'saml2', 'oidc']))
<div class="text-warn text-small mb-l">{{ trans('settings.reg_enable_external_warning') }}</div>
@endif
<label for="setting-registration-role">{{ trans('settings.reg_default_role') }}</label>
<select id="setting-registration-role" name="setting-registration-role" @if($errors->has('setting-registration-role')) class="neg" @endif>
<option value="0" @if(intval(setting('registration-role', '0')) === 0) selected @endif>-- {{ trans('common.none') }} --</option>
@foreach(\BookStack\Auth\Role::all() as $role)
<option value="{{$role->id}}"
data-system-role-name="{{ $role->system_name ?? '' }}"
@if(intval(setting('registration-role', '0')) === $role->id) selected @endif
>
{{ $role->display_name }}
</option>
@endforeach
</select>
</div>
</div>
<div class="grid half gap-xl">
<div>
<label for="setting-registration-restrict" class="setting-list-label">{{ trans('settings.reg_confirm_restrict_domain') }}</label>
<p class="small">{!! trans('settings.reg_confirm_restrict_domain_desc') !!}</p>
</div>
<div class="pt-xs">
<input type="text" id="setting-registration-restrict" name="setting-registration-restrict" placeholder="{{ trans('settings.reg_confirm_restrict_domain_placeholder') }}" value="{{ setting('registration-restrict', '') }}">
</div>
</div>
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.reg_email_confirmation') }}</label>
<p class="small">{{ trans('settings.reg_confirm_email_desc') }}</p>
</div>
<div>
@include('form.toggle-switch', [
'name' => 'setting-registration-confirmation',
'value' => setting('registration-confirmation'),
'label' => trans('settings.reg_email_confirmation_toggle')
])
</div>
</div>
</div>
<div class="form-group text-right">
<button type="submit" class="button">{{ trans('settings.settings_save') }}</button>
</div>
</form>
</div>
</div>
</div>
</div>
@include('entities.selector-popup', ['entityTypes' => 'page'])
@stop

View file

@ -0,0 +1,37 @@
@extends('layouts.simple')
@section('body')
<div class="container medium">
@include('settings.parts.navbar', ['selected' => 'settings'])
<div class="grid gap-xxl right-focus">
<div>
<h5>{{ trans('settings.categories') }}</h5>
<nav class="active-link-list in-sidebar">
<a href="{{ url('/settings/features') }}" class="{{ $category === 'features' ? 'active' : '' }}">@icon('star') Features & Security</a>
<a href="{{ url('/settings/customization') }}" class="{{ $category === 'customization' ? 'active' : '' }}">@icon('palette') Customization</a>
<a href="{{ url('/settings/registration') }}" class="{{ $category === 'registration' ? 'active' : '' }}">@icon('lock') Registration</a>
</nav>
<h5 class="mt-xl">{{ trans('settings.system_version') }}</h5>
<div class="py-xs">
<a target="_blank" rel="noopener noreferrer" href="https://github.com/BookStackApp/BookStack/releases">
BookStack @if(strpos($version, 'v') !== 0) version @endif {{ $version }}
</a>
</div>
</div>
<div>
<div class="card content-wrap auto-height">
@yield('card')
</div>
</div>
</div>
</div>
@yield('after-content')
@stop

View file

@ -0,0 +1,71 @@
@extends('settings.layout')
@section('card')
<h1 id="registration" class="list-heading">{{ trans('settings.reg_settings') }}</h2>
<form action="{{ url("/settings/registration") }}" method="POST">
{!! csrf_field() !!}
<input type="hidden" name="section" value="registration">
<div class="setting-list">
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.reg_enable') }}</label>
<p class="small">{!! trans('settings.reg_enable_desc') !!}</p>
</div>
<div>
@include('form.toggle-switch', [
'name' => 'setting-registration-enabled',
'value' => setting('registration-enabled'),
'label' => trans('settings.reg_enable_toggle')
])
@if(in_array(config('auth.method'), ['ldap', 'saml2', 'oidc']))
<div class="text-warn text-small mb-l">{{ trans('settings.reg_enable_external_warning') }}</div>
@endif
<label for="setting-registration-role">{{ trans('settings.reg_default_role') }}</label>
<select id="setting-registration-role" name="setting-registration-role" @if($errors->has('setting-registration-role')) class="neg" @endif>
<option value="0" @if(intval(setting('registration-role', '0')) === 0) selected @endif>-- {{ trans('common.none') }} --</option>
@foreach(\BookStack\Auth\Role::all() as $role)
<option value="{{$role->id}}"
data-system-role-name="{{ $role->system_name ?? '' }}"
@if(intval(setting('registration-role', '0')) === $role->id) selected @endif
>
{{ $role->display_name }}
</option>
@endforeach
</select>
</div>
</div>
<div class="grid half gap-xl">
<div>
<label for="setting-registration-restrict" class="setting-list-label">{{ trans('settings.reg_confirm_restrict_domain') }}</label>
<p class="small">{!! trans('settings.reg_confirm_restrict_domain_desc') !!}</p>
</div>
<div class="pt-xs">
<input type="text" id="setting-registration-restrict" name="setting-registration-restrict" placeholder="{{ trans('settings.reg_confirm_restrict_domain_placeholder') }}" value="{{ setting('registration-restrict', '') }}">
</div>
</div>
<div class="grid half gap-xl">
<div>
<label class="setting-list-label">{{ trans('settings.reg_email_confirmation') }}</label>
<p class="small">{{ trans('settings.reg_confirm_email_desc') }}</p>
</div>
<div>
@include('form.toggle-switch', [
'name' => 'setting-registration-confirmation',
'value' => setting('registration-confirmation'),
'label' => trans('settings.reg_email_confirmation_toggle')
])
</div>
</div>
</div>
<div class="form-group text-right">
<button type="submit" class="button">{{ trans('settings.settings_save') }}</button>
</div>
</form>
@endsection

View file

@ -207,10 +207,6 @@ Route::middleware('auth')->group(function () {
Route::get('/', [HomeController::class, 'index']);
Route::get('/home', [HomeController::class, 'index']);
// Settings
Route::get('/settings', [SettingController::class, 'index'])->name('settings');
Route::post('/settings', [SettingController::class, 'update']);
// Maintenance
Route::get('/settings/maintenance', [MaintenanceController::class, 'index']);
Route::delete('/settings/maintenance/cleanup-images', [MaintenanceController::class, 'cleanupImages']);
@ -267,6 +263,11 @@ Route::middleware('auth')->group(function () {
Route::put('/settings/webhooks/{id}', [WebhookController::class, 'update']);
Route::get('/settings/webhooks/{id}/delete', [WebhookController::class, 'delete']);
Route::delete('/settings/webhooks/{id}', [WebhookController::class, 'destroy']);
// Settings
Route::redirect('/settings', '/settings/features')->name('settings');
Route::get('/settings/{category}', [SettingController::class, 'index']);
Route::post('/settings/{category}', [SettingController::class, 'update']);
});
// MFA routes

View file

@ -202,7 +202,7 @@ class AuthTest extends TestCase
{
$this->assertFalse(setting('registration-role'));
$resp = $this->asAdmin()->get('/settings');
$resp = $this->asAdmin()->get('/settings/registration');
$resp->assertElementContains('select[name="setting-registration-role"] option[value="0"][selected]', '-- None --');
}

View file

@ -27,7 +27,7 @@ class RolesTest extends TestCase
public function test_admin_can_see_settings()
{
$this->asAdmin()->get('/settings')->assertSee('Settings');
$this->asAdmin()->get('/settings/features')->assertSee('Settings');
}
public function test_cannot_delete_admin_role()
@ -58,7 +58,7 @@ class RolesTest extends TestCase
$testRoleUpdateName = 'An Super Updated role';
// Creation
$resp = $this->asAdmin()->get('/settings');
$resp = $this->asAdmin()->get('/settings/features');
$resp->assertElementContains('a[href="' . url('/settings/roles') . '"]', 'Roles');
$resp = $this->get('/settings/roles');
@ -247,13 +247,13 @@ class RolesTest extends TestCase
public function test_settings_manage_permission()
{
$this->actingAs($this->user)->get('/settings')->assertRedirect('/');
$this->actingAs($this->user)->get('/settings/features')->assertRedirect('/');
$this->giveUserPermissions($this->user, ['settings-manage']);
$this->get('/settings')->assertOk();
$this->get('/settings/features')->assertOk();
$resp = $this->post('/settings', []);
$resp->assertRedirect('/settings');
$resp = $this->get('/settings');
$resp = $this->post('/settings/features', []);
$resp->assertRedirect('/settings/features');
$resp = $this->get('/settings/features');
$resp->assertSee('Settings saved');
}
@ -762,7 +762,7 @@ class RolesTest extends TestCase
public function test_public_role_visible_in_default_role_setting()
{
$this->asAdmin()->get('/settings')
$this->asAdmin()->get('/settings/registration')
->assertElementExists('[data-system-role-name="admin"]')
->assertElementExists('[data-system-role-name="public"]');
}

View file

@ -8,13 +8,13 @@ class FooterLinksTest extends TestCase
{
public function test_saving_setting()
{
$resp = $this->asAdmin()->post('/settings', [
$resp = $this->asAdmin()->post('/settings/customization', [
'setting-app-footer-links' => [
['label' => 'My custom link 1', 'url' => 'https://example.com/1'],
['label' => 'My custom link 2', 'url' => 'https://example.com/2'],
],
]);
$resp->assertRedirect('/settings');
$resp->assertRedirect('/settings/customization');
$result = setting('app-footer-links');
$this->assertIsArray($result);
@ -30,7 +30,7 @@ class FooterLinksTest extends TestCase
['label' => 'Another Link', 'url' => 'https://example.com/link-b'],
]]);
$resp = $this->asAdmin()->get('/settings');
$resp = $this->asAdmin()->get('/settings/customization');
$resp->assertSee('value="My custom link"', false);
$resp->assertSee('value="Another Link"', false);
$resp->assertSee('value="https://example.com/link-a"', false);

View file

@ -0,0 +1,31 @@
<?php
namespace Tests\Settings;
use Tests\TestCase;
class SettingsTest extends TestCase
{
public function test_settings_endpoint_redirects_to_settings_view()
{
$resp = $this->asAdmin()->get('/settings');
$resp->assertRedirect('/settings/features');
}
public function test_settings_category_links_work_as_expected()
{
$this->asAdmin();
$categories = [
'features' => 'Features & Security',
'customization' => 'Customization',
'registration' => 'Registration',
];
foreach ($categories as $category => $title) {
$resp = $this->get("/settings/{$category}");
$resp->assertElementContains('h1', $title);
$resp->assertElementExists("form[action$=\"/settings/{$category}\"]");
}
}
}

View file

@ -314,8 +314,8 @@ class ImageTest extends TestCase
$galleryFile = $this->getTestImage('my-system-test-upload.png');
$expectedPath = public_path('uploads/images/system/' . date('Y-m') . '/my-system-test-upload.png');
$upload = $this->call('POST', '/settings', [], [], ['app_logo' => $galleryFile], []);
$upload->assertRedirect('/settings');
$upload = $this->call('POST', '/settings/customization', [], [], ['app_logo' => $galleryFile], []);
$upload->assertRedirect('/settings/customization');
$this->assertTrue(file_exists($expectedPath), 'Uploaded image not found at path: ' . $expectedPath);