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

Admin Area Translations #965

Merged
merged 49 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
b345769
Init
notAreYouScared Jan 27, 2025
86ffe8e
Health Page
notAreYouScared Jan 27, 2025
064e3ea
Admin API Keys
notAreYouScared Jan 27, 2025
e951d11
Update API Keys
notAreYouScared Jan 27, 2025
706e923
Database Hosts
notAreYouScared Jan 27, 2025
2c11fe7
Mounts
notAreYouScared Jan 27, 2025
aa1f10a
remove `s`
notAreYouScared Jan 28, 2025
a099489
Users
notAreYouScared Jan 28, 2025
3362e96
Webhooks
notAreYouScared Jan 28, 2025
a902c13
Server
notAreYouScared Jan 28, 2025
ac34c36
Fix Server
notAreYouScared Jan 28, 2025
4819c5b
Merge branch 'main' into charles/translations
notAreYouScared Jan 28, 2025
940702e
Settings
notAreYouScared Jan 28, 2025
2da1992
Merge branch 'main' into charles/translations
notAreYouScared Jan 31, 2025
89ac201
Update Mounts
notAreYouScared Jan 31, 2025
f9c2974
Update Databasehost
notAreYouScared Jan 31, 2025
e53d498
Update Server
notAreYouScared Jan 31, 2025
6a90a28
Oops, Update Server
notAreYouScared Jan 31, 2025
6b5b94c
Nodes
notAreYouScared Jan 31, 2025
9107277
Update User
notAreYouScared Jan 31, 2025
334114d
Dashboard
notAreYouScared Feb 2, 2025
549c769
Update Server
notAreYouScared Feb 2, 2025
308cf6d
Profile
notAreYouScared Feb 2, 2025
2376c8a
Egg
notAreYouScared Feb 2, 2025
017c170
Role & Update Egg
notAreYouScared Feb 2, 2025
66c0a98
Add base Laravel lang files
notAreYouScared Feb 2, 2025
14e6543
update apikey
notAreYouScared Feb 2, 2025
0f80b1d
remove html back to settings, remove comment
notAreYouScared Feb 2, 2025
1acf570
add `:resource` to create_action
notAreYouScared Feb 2, 2025
889d846
Update Egg
notAreYouScared Feb 2, 2025
cf974c5
Update Egg v2
notAreYouScared Feb 2, 2025
c7f9f48
Update 1
notAreYouScared Feb 3, 2025
b982640
trans cf info label
notAreYouScared Feb 3, 2025
46ad018
Update charts
notAreYouScared Feb 3, 2025
6858526
more trans
notAreYouScared Feb 3, 2025
5c964db
Update Webhook
notAreYouScared Feb 3, 2025
e0ea527
update Health
notAreYouScared Feb 3, 2025
671204f
Update Server
notAreYouScared Feb 3, 2025
b6e6f29
Update Role
notAreYouScared Feb 3, 2025
6afa329
Fixes
notAreYouScared Feb 3, 2025
21ac59d
Bulk Update
notAreYouScared Feb 6, 2025
f7cb147
AnotherOne
notAreYouScared Feb 6, 2025
e081900
Fix relation button label
notAreYouScared Feb 6, 2025
34dd812
Merge branch 'main' into charles/translations
notAreYouScared Feb 6, 2025
1f12a11
rename `admin1` to `admin`
notAreYouScared Feb 6, 2025
618311f
More Translations
notAreYouScared Feb 6, 2025
d4d95af
Updates
notAreYouScared Feb 7, 2025
1994585
`pint` + Relation Manager Titles
notAreYouScared Feb 7, 2025
0412931
Merge branch 'main' into charles/translations
notAreYouScared Feb 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
58 changes: 58 additions & 0 deletions app/Checks/CacheCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Checks;

use Exception;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Spatie\Health\Checks\Check;
use Spatie\Health\Checks\Result;

class CacheCheck extends Check
{
protected ?string $driver = null;

public function driver(string $driver): self
{
$this->driver = $driver;

return $this;
}

public function run(): Result
{
$driver = $this->driver ?? $this->defaultDriver();

$result = Result::make()->meta([
'driver' => $driver,
]);

try {
return $this->canWriteValuesToCache($driver)
? $result->ok(trans('admin/health.results.cache.ok'))
: $result->failed(trans('admin/health.results.cache.failed_retrieve'));
} catch (Exception $exception) {
return $result->failed(trans('admin/health.results.cache.failed', ['error' => $exception->getMessage()]));
}
}

protected function defaultDriver(): ?string
{
return config('cache.default', 'file');
}

protected function canWriteValuesToCache(?string $driver): bool
{
$expectedValue = Str::random(5);

$cacheName = "laravel-health:check-{$expectedValue}";

Cache::driver($driver)->put($cacheName, $expectedValue, 10);

$actualValue = Cache::driver($driver)->get($cacheName);

Cache::driver($driver)->forget($cacheName);

return $actualValue === $expectedValue;
}
}
42 changes: 42 additions & 0 deletions app/Checks/DatabaseCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Checks;

use Exception;
use Illuminate\Support\Facades\DB;
use Spatie\Health\Checks\Check;
use Spatie\Health\Checks\Result;

class DatabaseCheck extends Check
{
protected ?string $connectionName = null;

public function connectionName(string $connectionName): self
{
$this->connectionName = $connectionName;

return $this;
}

public function run(): Result
{
$connectionName = $this->connectionName ?? $this->getDefaultConnectionName();

$result = Result::make()->meta([
'connection_name' => $connectionName,
]);

try {
DB::connection($connectionName)->getPdo();

return $result->ok(trans('admin/health.results.database.ok'));
} catch (Exception $exception) {
return $result->failed(trans('admin/health.results.database.failed', ['error' => $exception->getMessage()]));
}
}

protected function getDefaultConnectionName(): string
{
return config('database.default');
}
}
44 changes: 44 additions & 0 deletions app/Checks/DebugModeCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace App\Checks;

use Spatie\Health\Checks\Check;
use Spatie\Health\Checks\Result;

use function config;

class DebugModeCheck extends Check
{
protected bool $expected = false;

public function expectedToBe(bool $bool): self
{
$this->expected = $bool;

return $this;
}

public function run(): Result
{
$actual = config('app.debug');

$result = Result::make()
->meta([
'actual' => $actual,
'expected' => $this->expected,
])
->shortSummary($this->convertToWord($actual));

return $this->expected === $actual
? $result->ok()
: $result->failed(trans('admin/health.results.debugmode.failed', [
'actual' => $this->convertToWord($actual),
'expected' => $this->convertToWord($this->expected),
]));
}

protected function convertToWord(bool $boolean): string
{
return $boolean ? 'true' : 'false';
}
}
38 changes: 38 additions & 0 deletions app/Checks/EnvironmentCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Checks;

use Illuminate\Support\Facades\App;
use Spatie\Health\Checks\Check;
use Spatie\Health\Checks\Result;

class EnvironmentCheck extends Check
{
protected string $expectedEnvironment = 'production';

public function expectEnvironment(string $expectedEnvironment): self
{
$this->expectedEnvironment = $expectedEnvironment;

return $this;
}

public function run(): Result
{
$actualEnvironment = (string) App::environment();

$result = Result::make()
->meta([
'actual' => $actualEnvironment,
'expected' => $this->expectedEnvironment,
])
->shortSummary($actualEnvironment);

return $this->expectedEnvironment === $actualEnvironment
? $result->ok(trans('admin/health.results.environment.ok'))
: $result->failed(trans('admin/health.results.environment.failed', [
'actual' => $actualEnvironment,
'expected' => $this->expectedEnvironment,
]));
}
}
10 changes: 6 additions & 4 deletions app/Checks/NodeVersionsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public function run(): Result
$all = Node::query()->count();

if ($all === 0) {
$result = Result::make()->notificationMessage('No Nodes created')->shortSummary('No Nodes');
$result = Result::make()
->notificationMessage(trans('admin/health.results.nodeversions.no_nodes_created'))
->shortSummary(trans('admin/health.results.node_version.no_nodes'));
$result->status = Status::skipped();

return $result;
Expand All @@ -34,10 +36,10 @@ public function run(): Result
'all' => $all,
'outdated' => $outdated,
])
->shortSummary($outdated === 0 ? 'All up-to-date' : "{$outdated}/{$all} outdated");
->shortSummary($outdated === 0 ? trans('admin/health.results.nodeversions.all_up_to_date') : trans('admin/health.results.nodeversions.outdated', ['outdated' => $outdated, 'all' => $all]));

return $outdated === 0
? $result->ok('All Nodes are up-to-date.')
: $result->failed(':outdated/:all Nodes are outdated.');
? $result->ok(trans('admin/health.results.nodeversions.ok'))
: $result->failed(trans('admin/health.results.nodeversions.failed', ['outdated' => $outdated, 'all' => $all]));
}
}
9 changes: 6 additions & 3 deletions app/Checks/PanelVersionCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ public function run(): Result
'currentVersion' => $currentVersion,
'latestVersion' => $latestVersion,
])
->shortSummary($isLatest ? 'up-to-date' : 'outdated');
->shortSummary($isLatest ? trans('admin/health.results.panelversion.up_to_date') : trans('admin/health.results.panelversion.outdated'));

return $isLatest
? $result->ok('Panel is up-to-date.')
: $result->failed('Installed version is `:currentVersion` but latest is `:latestVersion`.');
? $result->ok(trans('admin/health.results.panelversion.ok'))
: $result->failed(trans('admin/health.results.panelversion.failed', [
'currentVersion' => $currentVersion,
'latestVersion' => $latestVersion,
]));
}
}
78 changes: 78 additions & 0 deletions app/Checks/ScheduleCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace App\Checks;

use Carbon\Carbon;
use Composer\InstalledVersions;
use Spatie\Health\Checks\Check;
use Spatie\Health\Checks\Result;

class ScheduleCheck extends Check
{
protected string $cacheKey = 'health:checks:schedule:latestHeartbeatAt';

protected ?string $cacheStoreName = null;

protected int $heartbeatMaxAgeInMinutes = 1;

public function useCacheStore(string $cacheStoreName): self
{
$this->cacheStoreName = $cacheStoreName;

return $this;
}

public function getCacheStoreName(): string
{
return $this->cacheStoreName ?? config('cache.default');
}

public function cacheKey(string $cacheKey): self
{
$this->cacheKey = $cacheKey;

return $this;
}

public function heartbeatMaxAgeInMinutes(int $heartbeatMaxAgeInMinutes): self
{
$this->heartbeatMaxAgeInMinutes = $heartbeatMaxAgeInMinutes;

return $this;
}

public function getCacheKey(): string
{
return $this->cacheKey;
}

public function run(): Result
{
$result = Result::make()->ok(trans('admin/health.results.schedule.ok'));

$lastHeartbeatTimestamp = cache()->store($this->cacheStoreName)->get($this->cacheKey);

if (!$lastHeartbeatTimestamp) {
return $result->failed(trans('admin/health.results.schedule.failed_not_ran'));
}

$latestHeartbeatAt = Carbon::createFromTimestamp($lastHeartbeatTimestamp);

$carbonVersion = InstalledVersions::getVersion('nesbot/carbon');

$minutesAgo = $latestHeartbeatAt->diffInMinutes();

if (version_compare($carbonVersion,
'3.0.0', '<')) {
$minutesAgo += 1;
}

if ($minutesAgo > $this->heartbeatMaxAgeInMinutes) {
return $result->failed(trans('admin/health.results.schedule.failed_last_ran', [
'time' => $minutesAgo,
]));
}

return $result;
}
}
21 changes: 12 additions & 9 deletions app/Filament/Admin/Pages/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ class Dashboard extends Page

public function getTitle(): string
{
return trans('strings.dashboard');
return trans('admin/dashboard.title');
}

protected static ?string $slug = '/';
public static function getNavigationLabel(): string
{
return trans('admin/dashboard.title');
}

public string $activeTab = 'nodes';
protected static ?string $slug = '/';

private SoftwareVersionService $softwareVersionService;

Expand All @@ -51,33 +54,33 @@ public function getViewData(): array

'devActions' => [
CreateAction::make()
->label('Bugs & Features')
->label(trans('admin/dashboard.sections.intro-developers.button_issues'))
->icon('tabler-brand-github')
->url('https://github.com/pelican-dev/panel/discussions', true),
->url('https://github.com/pelican-dev/panel/issues', true),
],
'updateActions' => [
CreateAction::make()
->label('Read Documentation')
->label(trans('admin/dashboard.sections.intro-update-available.heading'))
->icon('tabler-clipboard-text')
->url('https://pelican.dev/docs/panel/update', true)
->color('warning'),
],
'nodeActions' => [
CreateAction::make()
->label(trans('dashboard/index.sections.intro-first-node.button_label'))
->label(trans('admin/dashboard.sections.intro-first-node.button_label'))
->icon('tabler-server-2')
->url(CreateNode::getUrl()),
],
'supportActions' => [
CreateAction::make()
->label(trans('dashboard/index.sections.intro-support.button_donate'))
->label(trans('admin/dashboard.sections.intro-support.button_donate'))
->icon('tabler-cash')
->url('https://pelican.dev/donate', true)
->color('success'),
],
'helpActions' => [
CreateAction::make()
->label(trans('dashboard/index.sections.intro-help.button_docs'))
->label(trans('admin/dashboard.sections.intro-help.button_docs'))
->icon('tabler-speedboat')
->url('https://pelican.dev/docs', true),
],
Expand Down
Loading