Skip to content

Commit

Permalink
Added fallback for local env to server overview widget
Browse files Browse the repository at this point in the history
  • Loading branch information
korridor authored and Onatcer committed Oct 8, 2024
1 parent 2372ee0 commit 7af1990
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
14 changes: 9 additions & 5 deletions app/Filament/Widgets/ServerOverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@ class ServerOverview extends Widget
*/
protected function getViewData(): array
{
$currentVersion = Cache::get('latest_version', null);
/** @var string|null $currentVersion */
$currentVersion = config('app.version');
/** @var string|null $build */
$build = config('app.build');
$latestVersion = Cache::get('latest_version', null);

$needsUpdate = false;
if ($currentVersion !== null && version_compare($currentVersion, config('app.version')) > 0) {
if ($latestVersion !== null && $currentVersion !== null && version_compare($latestVersion, $currentVersion) > 0) {
$needsUpdate = true;
}

return [
'version' => config('app.version'),
'build' => config('app.build'),
'version' => $currentVersion,
'build' => $build,
'environment' => config('app.env'),
'currentVersion' => $currentVersion,
'currentVersion' => $latestVersion,
'needsUpdate' => $needsUpdate,
];
}
Expand Down
18 changes: 15 additions & 3 deletions resources/views/filament/widgets/server-overview.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
<x-filament-widgets::widget>
<x-filament::section>
<div>
<span class="text-gray-950 font-bold">Version</span> <span>v{{ $version }}</span><br>
<span class="text-gray-950 font-bold">Build</span> {{ $build }}
<span class="text-gray-950 font-bold">Version</span>
@if($version !== null)
<span>v{{ $version }}</span>
@else
<span>-</span>
@endif
<br>
<span class="text-gray-950 font-bold">Build</span>
@if($build !== null)
<span>{{ $build }}</span>
@else
<span>-</span>
@endif

</div>

@if ($currentVersion !== null)
@if ($currentVersion !== null && $version !== null)
<div class="mt-4 inline-flex items-center justify-center gap-1">
@if ($needsUpdate)
<span>
Expand Down

0 comments on commit 7af1990

Please sign in to comment.