Skip to content

Commit 70ffd6b

Browse files
authored
Allow configuring whether to use external dependencies (#278)
1 parent ce0afc9 commit 70ffd6b

5 files changed

Lines changed: 37 additions & 8 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
use Spatie\LaravelSettings\Migrations\SettingsMigration;
4+
5+
return new class extends SettingsMigration
6+
{
7+
/**
8+
* Run the migrations.
9+
*/
10+
public function up(): void
11+
{
12+
rescue(fn () => $this->migrator->add('app.enable_external_dependencies', true));
13+
}
14+
};

resources/lang/en/settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
'show_timezone' => 'Show Timezone',
1616
'show_dashboard_link' => 'Show Dashboard Link',
1717
'display_graphs' => 'Display Graphs',
18+
'enable_external_dependencies' => 'Enable External Dependencies',
1819
'only_show_disrupted_days' => 'Only Show Disrupted Days',
1920
'recent_incidents_only' => 'Show Recent Incidents Only',
2021
'recent_incidents_days' => 'Number of Days to Show Recent Incidents',
2122
],
23+
'display_settings_title' => 'Display Settings',
2224
],
2325
'manage_customization' => [
2426
'header_label' => 'Custom Header HTML',

src/CachetDashboardServiceProvider.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Cachet\Filament\Pages\EditProfile;
66
use Cachet\Http\Middleware\SetAppLocale;
7+
use Cachet\Settings\AppSettings;
8+
use Filament\FontProviders\LocalFontProvider;
79
use Filament\Http\Middleware\Authenticate;
810
use Filament\Http\Middleware\DisableBladeIconComponents;
911
use Filament\Http\Middleware\DispatchServingFilamentEvent;
@@ -25,9 +27,15 @@ class CachetDashboardServiceProvider extends PanelProvider
2527
{
2628
public function panel(Panel $panel): Panel
2729
{
30+
$appSettings = app(AppSettings::class);
31+
2832
return $panel
2933
->id('cachet')
30-
->font('switzer', 'https://fonts.cdnfonts.com/css/switzer')
34+
->when(
35+
! app()->runningInConsole() && $appSettings->enable_external_dependencies,
36+
fn ($panel) => $panel->font('switzer', 'https://fonts.cdnfonts.com/css/switzer'),
37+
fn ($panel) => $panel->font('ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" ', provider: LocalFontProvider::class),
38+
)
3139
->default()
3240
->login()
3341
->passwordReset()

src/Filament/Pages/Settings/ManageCachet.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Filament\Forms\Form;
88
use Filament\Forms\Get;
99
use Illuminate\Support\Str;
10+
use function __;
1011

1112
class ManageCachet extends SettingsPage
1213
{
@@ -71,13 +72,6 @@ public function form(Form $form): Form
7172
->step(1)
7273
->suffix(__('cachet::settings.manage_cachet.refresh_rate_label_input_suffix_seconds')),
7374

74-
Forms\Components\Grid::make(2)
75-
->schema([
76-
Forms\Components\Toggle::make('show_support')
77-
->label(__('cachet::settings.manage_cachet.toggles.support_cachet')),
78-
Forms\Components\Toggle::make('display_graphs')
79-
->label(__('cachet::settings.manage_cachet.toggles.display_graphs')),
80-
]),
8175
Forms\Components\Toggle::make('show_timezone')
8276
->label(__('cachet::settings.manage_cachet.toggles.show_timezone')),
8377
Forms\Components\Toggle::make('only_disrupted_days')
@@ -99,6 +93,15 @@ public function form(Form $form): Form
9993
->hidden(fn (Get $get) => $get('recent_incidents_only') !== true),
10094
]),
10195
]),
96+
Forms\Components\Section::make(__('cachet::settings.manage_cachet.display_settings_title'))
97+
->schema([
98+
Forms\Components\Toggle::make('show_support')
99+
->label(__('cachet::settings.manage_cachet.toggles.support_cachet')),
100+
Forms\Components\Toggle::make('display_graphs')
101+
->label(__('cachet::settings.manage_cachet.toggles.display_graphs')),
102+
Forms\Components\Toggle::make('enable_external_dependencies')
103+
->label(__('cachet::settings.manage_cachet.toggles.enable_external_dependencies')),
104+
]),
102105
]);
103106
}
104107
}

src/Settings/AppSettings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class AppSettings extends Settings
3434

3535
public bool $display_graphs = true;
3636

37+
public bool $enable_external_dependencies = true;
38+
3739
public static function group(): string
3840
{
3941
return 'app';

0 commit comments

Comments
 (0)