Skip to content

Add Manage Localization Page #285

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions resources/lang/en/navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'items' => [
'manage_cachet' => 'Manage Cachet',
'manage_customization' => 'Manage Customization',
'manage_localization' => 'Manage Localization',
'manage_theme' => 'Manage Theme',
'manage_api_keys' => 'Manage API Keys',
'manage_webhooks' => 'Manage Webhooks',
Expand Down
9 changes: 7 additions & 2 deletions resources/lang/en/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
'manage_cachet' => [
'site_name_label' => 'Site Name',
'about_this_site_label' => 'About This Site',
'timezone_label' => 'Timezone',
'incident_days_label' => 'Incident Days',
'major_outage_threshold_label' => 'Major Outage Threshold',
'refresh_rate_label' => 'Automatically Refresh Page',
'refresh_rate_label_input_suffix_seconds' => 'seconds',
'recent_incidents_days_suffix_days' => 'days',
'toggles' => [
'support_cachet' => 'Support Cachet',
'show_timezone' => 'Show Timezone',
'show_dashboard_link' => 'Show Dashboard Link',
'display_graphs' => 'Display Graphs',
'enable_external_dependencies' => 'Enable External Dependencies',
Expand All @@ -27,6 +25,13 @@
'footer_label' => 'Custom Footer HTML',
'stylesheet_label' => 'Custom CSS',
],
'manage_localization' => [
'locale_label' => 'Locale',
'timezone_label' => 'Timezone',
'toggles' => [
'show_timezone' => 'Show Timezone',
],
],
'manage_theme' => [
'app_banner_label' => 'Banner Image',
'status_page_accent' => [
Expand Down
17 changes: 0 additions & 17 deletions src/Filament/Pages/Settings/ManageCachet.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Illuminate\Support\Str;

use function __;

Expand Down Expand Up @@ -36,20 +35,6 @@ public function form(Form $form): Form
->label(__('cachet::settings.manage_cachet.about_this_site_label'))
->columnSpanFull(),

Forms\Components\Select::make('timezone')
->label(__('cachet::settings.manage_cachet.timezone_label'))
->options(fn () => collect(timezone_identifiers_list())
->mapToGroups(
fn ($timezone) => [
Str::of($timezone)
->before('/')
->toString() => [$timezone => $timezone],
]
)
->map(fn ($group) => $group->collapse()))
->searchable()
->suffixIcon('heroicon-o-globe-alt'),

Forms\Components\TextInput::make('incident_days')
->numeric()
->label(__('cachet::settings.manage_cachet.incident_days_label'))
Expand All @@ -73,8 +58,6 @@ public function form(Form $form): Form
->step(1)
->suffix(__('cachet::settings.manage_cachet.refresh_rate_label_input_suffix_seconds')),

Forms\Components\Toggle::make('show_timezone')
->label(__('cachet::settings.manage_cachet.toggles.show_timezone')),
Forms\Components\Toggle::make('only_disrupted_days')
->label(__('cachet::settings.manage_cachet.toggles.only_show_disrupted_days')),
Forms\Components\Toggle::make('dashboard_login_link')
Expand Down
57 changes: 57 additions & 0 deletions src/Filament/Pages/Settings/ManageLocalization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Cachet\Filament\Pages\Settings;

use Cachet\Settings\AppSettings;
use Filament\Forms;
use Filament\Forms\Form;
use Illuminate\Support\Str;

class ManageLocalization extends SettingsPage
{
protected static string $settings = AppSettings::class;

public static function getNavigationGroup(): ?string
{
return __('cachet::navigation.settings.label');
}

public static function getNavigationLabel(): string
{
return __('cachet::navigation.settings.items.manage_localization');
}

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make()->columns(2)->schema([
Forms\Components\Select::make('locale')
->label(__('cachet::settings.manage_localization.locale_label'))
->options(
config('cachet.supported_locales', [
'en' => 'English',
])
)->searchable()
->suffixIcon('heroicon-o-language'),

Forms\Components\Select::make('timezone')
->label(__('cachet::settings.manage_localization.timezone_label'))
->options(fn () => collect(timezone_identifiers_list())
->mapToGroups(
fn ($timezone) => [
Str::of($timezone)
->before('/')
->toString() => [$timezone => $timezone],
]
)
->map(fn ($group) => $group->collapse()))
->searchable()
->suffixIcon('heroicon-o-globe-alt'),

Forms\Components\Toggle::make('show_timezone')
->label(__('cachet::settings.manage_localization.toggles.show_timezone')),
]),
]);
}
}
2 changes: 2 additions & 0 deletions src/Settings/AppSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class AppSettings extends Settings

public bool $show_support = true;

public string $locale = 'en';

public string $timezone = 'UTC';

public bool $show_timezone = false;
Expand Down