diff --git a/app/Console/Commands/InfoCommand.php b/app/Console/Commands/InfoCommand.php index 2ae8079e93..53b1dd8894 100644 --- a/app/Console/Commands/InfoCommand.php +++ b/app/Console/Commands/InfoCommand.php @@ -26,7 +26,7 @@ public function handle(): void { $this->output->title('Version Information'); $this->table([], [ - ['Panel Version', config('app.version')], + ['Panel Version', $this->versionService->versionData()['version']], ['Latest Version', $this->versionService->getPanel()], ['Up-to-Date', $this->versionService->isLatestPanel() ? 'Yes' : $this->formatText('No', 'bg=red')], ], 'compact'); diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php index 4b57da696f..af76c00f54 100644 --- a/app/Filament/Pages/Dashboard.php +++ b/app/Filament/Pages/Dashboard.php @@ -7,6 +7,7 @@ use App\Models\Node; use App\Models\Server; use App\Models\User; +use App\Services\Helpers\SoftwareVersionService; use Filament\Actions\CreateAction; use Filament\Pages\Page; @@ -29,8 +30,14 @@ public function getTitle(): string public function getViewData(): array { + /** @var SoftwareVersionService $softwareVersionService */ + $softwareVersionService = app(SoftwareVersionService::class); + return [ 'inDevelopment' => config('app.version') === 'canary', + 'version' => $softwareVersionService->versionData()['version'], + 'latestVersion' => $softwareVersionService->getPanel(), + 'isLatest' => $softwareVersionService->isLatestPanel(), 'eggsCount' => Egg::query()->count(), 'nodesList' => ListNodes::getUrl(), 'nodesCount' => Node::query()->count(), @@ -43,6 +50,13 @@ public function getViewData(): array ->icon('tabler-brand-github') ->url('https://github.com/pelican-dev/panel/discussions', true), ], + 'updateActions' => [ + CreateAction::make() + ->label('Read Documentation') + ->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')) @@ -53,7 +67,7 @@ public function getViewData(): array CreateAction::make() ->label(trans('dashboard/index.sections.intro-support.button_donate')) ->icon('tabler-cash') - ->url('https://pelican.dev/donate', true) + ->url($softwareVersionService->getDonations(), true) ->color('success'), ], 'helpActions' => [ diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 1c0deb6221..5817890b1b 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -6,6 +6,7 @@ use App\Models; use App\Models\ApiKey; use App\Models\Node; +use App\Services\Helpers\SoftwareVersionService; use Dedoc\Scramble\Scramble; use Dedoc\Scramble\Support\Generator\OpenApi; use Dedoc\Scramble\Support\Generator\SecurityScheme; @@ -30,8 +31,9 @@ public function boot(): void { Schema::defaultStringLength(191); - View::share('appVersion', $this->versionData()['version'] ?? 'undefined'); - View::share('appIsGit', $this->versionData()['is_git'] ?? false); + $versionData = app(SoftwareVersionService::class)->versionData(); + View::share('appVersion', $versionData['version'] ?? 'undefined'); + View::share('appIsGit', $versionData['is_git'] ?? false); Paginator::useBootstrap(); @@ -96,34 +98,6 @@ public function register(): void Scramble::ignoreDefaultRoutes(); } - /** - * Return version information for the footer. - */ - protected function versionData(): array - { - return cache()->remember('git-version', 5, function () { - if (file_exists(base_path('.git/HEAD'))) { - $head = explode(' ', file_get_contents(base_path('.git/HEAD'))); - - if (array_key_exists(1, $head)) { - $path = base_path('.git/' . trim($head[1])); - } - } - - if (isset($path) && file_exists($path)) { - return [ - 'version' => substr(file_get_contents($path), 0, 8), - 'is_git' => true, - ]; - } - - return [ - 'version' => config('app.version'), - 'is_git' => false, - ]; - }); - } - public function bootAuth(): void { Sanctum::usePersonalAccessTokenModel(ApiKey::class); diff --git a/app/Services/Helpers/SoftwareVersionService.php b/app/Services/Helpers/SoftwareVersionService.php index b5f3a9b128..21402a4907 100644 --- a/app/Services/Helpers/SoftwareVersionService.php +++ b/app/Services/Helpers/SoftwareVersionService.php @@ -49,6 +49,14 @@ public function getDiscord(): string return Arr::get(self::$result, 'discord') ?? 'https://pelican.dev/discord'; } + /** + * Get the donation URL. + */ + public function getDonations(): string + { + return Arr::get(self::$result, 'donate') ?? 'https://pelican.dev/donate'; + } + /** * Determine if the current version of the panel is the latest. */ @@ -93,8 +101,28 @@ protected function cacheVersionData(): array }); } - public function getDonations(): string + public function versionData(): array { - return 'https://github.com'; + return cache()->remember('git-version', 5, function () { + if (file_exists(base_path('.git/HEAD'))) { + $head = explode(' ', file_get_contents(base_path('.git/HEAD'))); + + if (array_key_exists(1, $head)) { + $path = base_path('.git/' . trim($head[1])); + } + } + + if (isset($path) && file_exists($path)) { + return [ + 'version' => 'canary (' . substr(file_get_contents($path), 0, 8) . ')', + 'is_git' => true, + ]; + } + + return [ + 'version' => config('app.version'), + 'is_git' => false, + ]; + }); } } diff --git a/lang/en/dashboard/index.php b/lang/en/dashboard/index.php index 1dff4f01a7..2c201a30b6 100644 --- a/lang/en/dashboard/index.php +++ b/lang/en/dashboard/index.php @@ -19,6 +19,10 @@ 'button_issues' => 'Create Issue', 'button_features' => 'Discuss Features', ], + 'intro-update' => [ + 'heading' => 'Update available', + 'content' => ':latestVersion is available! Read our documentation to update your Panel.', + ], 'intro-first-node' => [ 'heading' => 'No Nodes Detected', 'content' => "It looks like you don't have any Nodes set up yet, but don't worry because you click the action button to create your first one!", diff --git a/resources/views/filament/pages/dashboard.blade.php b/resources/views/filament/pages/dashboard.blade.php index 527a48aba7..ef7f539bd9 100644 --- a/resources/views/filament/pages/dashboard.blade.php +++ b/resources/views/filament/pages/dashboard.blade.php @@ -4,7 +4,7 @@ :actions="$this->getCachedHeaderActions()" :breadcrumbs="filament()->hasBreadcrumbs() ? $this->getBreadcrumbs() : []" :heading=" trans('dashboard/index.heading')" - :subheading="trans('strings.version', ['version' => config('app.version')])" + :subheading="trans('strings.version', ['version' => $version])" >

{{ trans('dashboard/index.expand_sections') }}

@@ -30,6 +30,22 @@ @endif + @if (!$isLatest) + + {{ trans('dashboard/index.sections.intro-update.heading') }} + +

{{ trans('dashboard/index.sections.intro-update.content', ['latestVersion' => $latestVersion]) }}

+ +
+ @endif + {{-- No Nodes Created --}} @if ($nodesCount <= 0)