1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

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
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}");
}
}