Fix Ticketmigration (#825)

This commit is contained in:
Dennis 2023-05-08 13:53:52 +02:00 committed by GitHub
commit b4b61bcc47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 10 deletions

View file

@ -8,13 +8,13 @@ class GeneralSettings extends Settings
{
public bool $store_enabled;
public string $credits_display_name;
public bool $recaptcha_enabled;
public string $recaptcha_site_key;
public string $recaptcha_secret_key;
public string $phpmyadmin_url;
public bool $alert_enabled;
public ?bool $recaptcha_enabled;
public ?string $recaptcha_site_key;
public ?string $recaptcha_secret_key;
public ?string $phpmyadmin_url;
public ?bool $alert_enabled;
public string $alert_type;
public string $alert_message;
public ?string $alert_message;
public string $theme;
//public int $initial_user_role; wait for Roles & Permissions PR.
@ -41,7 +41,7 @@ class GeneralSettings extends Settings
'phpmyadmin_url' => 'nullable|string',
'alert_enabled' => 'nullable|boolean',
'alert_type' => 'required|in:primary,secondary,success,danger,warning,info',
'alert_message' => 'required|string',
'alert_message' => 'nullable|string',
'theme' => 'required|in:default,BlueInfinity' // TODO: themes should be made/loaded dynamically
];
}

View file

@ -10,7 +10,8 @@ class CreateTicketSettings extends SettingsMigration
$table_exists = DB::table('settings_old')->exists();
// Get the user-set configuration values from the old table.
$this->migrator->add('ticket.enabled', $table_exists ? $this->getOldValue('SETTINGS::TICKET:ENABLED') : 'all');
$this->migrator->add('ticket.enabled', $table_exists ? $this->getOldValue('SETTINGS::TICKET:ENABLED') : 'true');
$this->migrator->add('ticket.notify', $table_exists ? $this->getOldValue('SETTINGS::TICKET:NOTIFY') : 'all');
}
public function down(): void
@ -57,11 +58,16 @@ class CreateTicketSettings extends SettingsMigration
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
// Handle the old values to return without it being a string in all cases.
if (is_null($old_value)) {
return '';
}
if ($old_value->type === "string" || $old_value->type === "text") {
if (is_null($old_value->value)) {
return '';
}
// Some values have the type string, but their values are boolean.
if ($old_value->value === "false" || $old_value->value === "true") {
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);

View file

@ -6,6 +6,7 @@ return new class extends SettingsMigration
{
public function up(): void
{
$this->migrator->delete('ticket.notify');
$this->migrator->add('ticket.information', "Can't start your server? Need an additional port? Do you have any other questions? Let us know by opening a ticket.");
}
};

View file

@ -121,10 +121,11 @@
@case($value['type'] == 'select')
<select id="{{ $key }}"
class="custom-select w-100" name="{{ $key }}">
@foreach ($value['options'] as $option)
@foreach ($value['options'] as $option=>$display)
<option value="{{ $option }}"
{{ $value['value'] == $option ? 'selected' : '' }}>
{{ __($option) }}
{{ __($display) }}
</option>
@endforeach
</select>