feat: Aggiunta selezione dello step tramite parametro

This commit is contained in:
Maicol Battistini 2023-07-05 10:17:27 +02:00
parent 3405e82c4c
commit 8ef0fa73f6
No known key found for this signature in database
2 changed files with 17 additions and 2 deletions

View File

@ -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]);
}
}

View File

@ -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<SetupPageAttributes> {
[SetupSteps.AdminUser]: new AdminUserStep()
};
oninit(vnode: Vnode<SetupPageAttributes, this>) {
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<SetupPageAttributes>) {
return <>
<h1>{__('Configurazione iniziale')}</h1>