Skip to content

Commit

Permalink
[5.x] Don't show updates badge count for local/dev installations (#10884
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jesseleite authored Oct 1, 2024
1 parent 3618a20 commit 9a09538
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
38 changes: 20 additions & 18 deletions resources/views/updater/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,26 @@ class="btn-primary btn-lg">{{ __('Try again') }}</a>
</table>
</div>

<h6 class="mt-8">{{ __('Addons') }}</h6>
<div class="card p-0 mt-2">
<table class="data-table">
@foreach ($addons as $addon)
<tr>
<td class="w-64"><a href="{{ route('statamic.cp.updater.product', $addon -> slug()) }}"
class="text-blue font-bold rtl:ml-2 ltr:mr-2">{{ $addon -> name() }}</a>
<td>{{ $addon -> version() }}</td>
@if ($count = $addon->changelog()->availableUpdatesCount())
<td class="rtl:text-left ltr:text-right"><span
class="badge-sm bg-green-600 btn-xs">{{ trans_choice('1 update|:count updates', $count) }}</span></td>
@else
<td class="rtl:text-left ltr:text-right">{{ __('Up to date') }}</td>
@endif
</tr>
@endforeach
</table>
</div>
@if($addons->count())
<h6 class="mt-8">{{ __('Addons') }}</h6>
<div class="card p-0 mt-2">
<table class="data-table">
@foreach ($addons as $addon)
<tr>
<td class="w-64"><a href="{{ route('statamic.cp.updater.product', $addon -> slug()) }}"
class="text-blue font-bold rtl:ml-2 ltr:mr-2">{{ $addon -> name() }}</a>
<td>{{ $addon -> version() }}</td>
@if ($count = $addon->changelog()->availableUpdatesCount())
<td class="rtl:text-left ltr:text-right"><span
class="badge-sm bg-green-600 btn-xs">{{ trans_choice('1 update|:count updates', $count) }}</span></td>
@else
<td class="rtl:text-left ltr:text-right">{{ __('Up to date') }}</td>
@endif
</tr>
@endforeach
</table>
</div>
@endif

@if($unlistedAddons->count())
<h6 class="mt-8">{{ __('Unlisted Addons') }}</h6>
Expand Down
4 changes: 4 additions & 0 deletions src/Extend/Addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ public function changelog()

public function isLatestVersion()
{
if (Str::startsWith($this->version, 'dev-') || Str::endsWith($this->version, '-dev')) {
return true;
}

if (! $this->latestVersion) {
return true;
}
Expand Down
16 changes: 3 additions & 13 deletions src/Http/Controllers/CP/Updater/UpdaterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function index(Licenses $licenses)
{
$this->authorize('view updates');

$addons = $this->getUpdatableAddons();
$addons = Addon::all();

if ($addons->isEmpty()) {
return redirect()->route('statamic.cp.updater.product', Statamic::CORE_SLUG);
Expand All @@ -28,8 +28,8 @@ public function index(Licenses $licenses)
return view('statamic::updater.index', [
'requestError' => $licenses->requestFailed(),
'statamic' => Marketplace::statamic()->changelog(),
'addons' => Addon::all()->filter->existsOnMarketplace(),
'unlistedAddons' => Addon::all()->reject->existsOnMarketplace(),
'addons' => $addons->filter->existsOnMarketplace(),
'unlistedAddons' => $addons->reject->existsOnMarketplace(),
]);
}

Expand All @@ -42,14 +42,4 @@ public function count(Request $request)

return UpdatesOverview::count();
}

/**
* Get updatable addons.
*
* @return \Illuminate\Support\Collection
*/
private function getUpdatableAddons()
{
return Addon::all()->filter->marketplaceSlug();
}
}
8 changes: 8 additions & 0 deletions src/Updater/UpdatesOverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Facades\Statamic\Marketplace\Marketplace;
use Illuminate\Support\Facades\Cache;
use Statamic\Facades\Addon;
use Statamic\Statamic;
use Statamic\Support\Str;

class UpdatesOverview
{
Expand Down Expand Up @@ -93,6 +95,12 @@ protected function resetState()
*/
protected function checkForStatamicUpdates()
{
$version = Statamic::version();

if (Str::startsWith($version, 'dev-') || Str::endsWith($version, '-dev')) {
return $this;
}

if (Marketplace::statamic()->changelog()->latest()->type === 'upgrade') {
$this->statamic = true;
$this->count++;
Expand Down

0 comments on commit 9a09538

Please sign in to comment.