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

Show abandoned tag #209

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/Http/Resources/PackageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Favorite;
use App\Package;
use Illuminate\Support\Str;
use Illuminate\Support\Arr;

class PackageResource extends ModelResource
{
Expand Down Expand Up @@ -35,9 +36,19 @@ public function toArray($package)
'github_username' => $package->author->github_username,
],
'nova_version' => $package->nova_version ?? null,
'possibly_abandoned' => $this->isPossiblyAbandoned($package, $composer_latest ?? null, $packagistData ?? []),
];
}

/**
* If a package is old *and* not on Packagist, mark it as likely abandoned
*/
public function isPossiblyAbandoned($package, $composer_latest, $packagistData)
{
return Arr::get($packagistData, 'package.abandoned', false) ||
($package->created_at->diffInDays(now()) > 15 && ! $composer_latest);
}

protected function averageRating($package)
{
return number_format($package->average_rating, '2', '.', '');
Expand Down
4 changes: 3 additions & 1 deletion resources/views/livewire/partials/package-card.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
</div>
@endif

@if ($package['nova_version'] == config('novapackages.nova.latest_major_version'))
@if($package['possibly_abandoned'])
<span class="absolute top-0 right-0 px-3 py-1 text-xs tracking-widest text-white rounded-bl rounded-tr" style="background-color: {{ $package['accent'] }}">Possibly Abandoned</span>
@elseif ($package['nova_version'] == config('novapackages.nova.latest_major_version'))
<span class="absolute top-0 right-0 px-3 py-1 text-xs tracking-widest text-white rounded-bl rounded-tr" style="background-color: {{ $package['accent'] }}">Nova {{ config('novapackages.nova.latest_major_version') ?? 'N/A' }} Support</span>
@endif

Expand Down