Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ticketmigration #825

Merged
merged 3 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions app/Settings/GeneralSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -41,7 +41,7 @@ public static function getValidations()
'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
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public function up(): void
$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
Expand Down Expand Up @@ -57,11 +58,16 @@ public function getOldValue(string $key)
$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);
Expand Down
1 change: 1 addition & 0 deletions database/settings/2023_05_07_195343_ticket_information.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{
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.");
}
};
5 changes: 3 additions & 2 deletions themes/default/views/admin/settings/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ class="nav-icon fas {{ $options['category_icon'] ?? 'fas fa-cog' }}"></i>
@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>
Expand Down