From 8ef0fa73f62092f09251d3e448453c125f68213b Mon Sep 17 00:00:00 2001 From: Maicol Battistini Date: Wed, 5 Jul 2023 10:17:27 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Aggiunta=20selezione=20dell?= =?UTF-8?q?o=20step=20tramite=20parametro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Middleware/CheckConfigurationMiddleware.php | 4 ++-- resources/ts/Views/Setup/SetupPage.tsx | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Http/Middleware/CheckConfigurationMiddleware.php b/app/Http/Middleware/CheckConfigurationMiddleware.php index 0d1e63caf..9d1bc1769 100644 --- a/app/Http/Middleware/CheckConfigurationMiddleware.php +++ b/app/Http/Middleware/CheckConfigurationMiddleware.php @@ -23,7 +23,7 @@ class CheckConfigurationMiddleware 'admin_user' => static fn (): bool => !empty(User::exists()), ]; - foreach ($checks as $check) { + foreach ($checks as $name => $check) { try { $check = $check(); } catch (QueryException|InvalidArgumentException|PDOException $exception) { @@ -44,7 +44,7 @@ class CheckConfigurationMiddleware return \response()->json(['message' => __('Configurazione del database richiesta')], Response::HTTP_SERVICE_UNAVAILABLE); } - return redirect()->route('setup.index'); + return redirect()->route('setup.index', ['step' => $name]); } } diff --git a/resources/ts/Views/Setup/SetupPage.tsx b/resources/ts/Views/Setup/SetupPage.tsx index 7e6d1aaaa..df74cbc0f 100644 --- a/resources/ts/Views/Setup/SetupPage.tsx +++ b/resources/ts/Views/Setup/SetupPage.tsx @@ -12,6 +12,7 @@ import { Request, RequestError } from 'mithril-utilities'; +import {match} from 'ts-pattern'; import { SetupStep, @@ -34,6 +35,20 @@ export default class SetupPage extends Page { [SetupSteps.AdminUser]: new AdminUserStep() }; + oninit(vnode: Vnode) { + super.oninit(vnode); + // @ts-expect-error + const {step} = route().params; + if (step) { + const setupStep = match(step) + .with('regional_settings', () => SetupSteps.RegionalSettings) + .with('database', () => SetupSteps.Database) + .with('admin_user', () => SetupSteps.AdminUser) + .otherwise(() => SetupSteps.Welcome); + this.currentStep(setupStep); + } + } + contents(vnode: Vnode) { return <>

{__('Configurazione iniziale')}