From 6f88282df5a6d404aa900018ab57d30940e77b12 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Thu, 28 May 2026 14:36:29 +0900 Subject: [PATCH] Simplify customer license UI for expired licenses Hide status/expiry noise from the customer license dashboard: - Drop the "License Expired" banner and the "keys cannot be created for expired licenses" notice (suspended messaging is retained). - Hide the sub-key limit (e.g. x/9) once a license is expired. - Remove the Status column and Expires detail from the licenses index and individual license screens. - Remove the "Create Key" button while leaving the creation flow intact. Co-Authored-By: Claude Opus 4.7 (1M context) --- app/Models/License.php | 5 ++ .../livewire/customer/licenses.blade.php | 66 ------------------- .../livewire/customer/licenses/show.blade.php | 41 ++---------- .../livewire/sub-license-manager.blade.php | 11 +--- .../Feature/CustomerLicenseManagementTest.php | 18 +++-- .../CustomerSubLicenseManagementTest.php | 18 ++++- 6 files changed, 43 insertions(+), 116 deletions(-) diff --git a/app/Models/License.php b/app/Models/License.php index 56b8f038..bc1ef131 100644 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -100,6 +100,11 @@ protected function remainingSubLicenses(): Attribute }); } + public function isExpired(): bool + { + return $this->expires_at && $this->expires_at->isPast(); + } + public function canCreateSubLicense(): bool { if (! $this->supportsSubLicenses()) { diff --git a/resources/views/livewire/customer/licenses.blade.php b/resources/views/livewire/customer/licenses.blade.php index 5d94250b..1894b661 100644 --- a/resources/views/livewire/customer/licenses.blade.php +++ b/resources/views/livewire/customer/licenses.blade.php @@ -9,24 +9,10 @@ License Key - Status - Expires @foreach($this->licenses as $license) - @php - $isLegacyLicense = $license->isLegacy(); - $daysUntilExpiry = $license->expires_at ? (int) now()->diffInDays($license->expires_at, false) : null; - $needsRenewal = $isLegacyLicense && $daysUntilExpiry !== null && !$license->expires_at->isPast(); - - $status = match(true) { - $license->is_suspended => 'Suspended', - $license->expires_at && $license->expires_at->isPast() => 'Expired', - $needsRenewal => 'Needs Renewal', - default => 'Active', - }; - @endphp
@@ -42,32 +28,6 @@ - - - - - - - @if($needsRenewal) -
- - {{ $daysUntilExpiry }} day{{ $daysUntilExpiry === 1 ? '' : 's' }} - - @if($isLegacyLicense) - Lock in Early Access Pricing - @endif -
- @elseif($license->expires_at) -
- {{ $license->expires_at->format('M j, Y') }} - @if($license->expires_at->isPast()) - Expired {{ $license->expires_at->diffForHumans() }} - @endif -
- @else - No expiration - @endif -
@endforeach @@ -82,19 +42,10 @@ License Key - Status - Expires @foreach($this->assignedSubLicenses as $subLicense) - @php - $subStatus = match(true) { - $subLicense->is_suspended => 'Suspended', - $subLicense->expires_at && $subLicense->expires_at->isPast() => 'Expired', - default => 'Active', - }; - @endphp
@@ -106,23 +57,6 @@ - - - - - - - @if($subLicense->expires_at) -
- {{ $subLicense->expires_at->format('M j, Y') }} - @if($subLicense->expires_at->isPast()) - Expired {{ $subLicense->expires_at->diffForHumans() }} - @endif -
- @else - No expiration - @endif -
@endforeach diff --git a/resources/views/livewire/customer/licenses/show.blade.php b/resources/views/livewire/customer/licenses/show.blade.php index 25c1eab7..d23795ce 100644 --- a/resources/views/livewire/customer/licenses/show.blade.php +++ b/resources/views/livewire/customer/licenses/show.blade.php @@ -24,12 +24,9 @@ {{-- License Information Card --}} -
-
- License Information - Details about your NativePHP license. -
- +
+ License Information + Details about your NativePHP license.
@@ -80,23 +77,6 @@ ({{ $license->created_at->diffForHumans() }}) - - {{-- Expires --}} - - Expires - - @if($license->expires_at) - {{ $license->expires_at->format('F j, Y \a\t g:i A') }} - @if($license->expires_at->isPast()) - (Expired {{ $license->expires_at->diffForHumans() }}) - @else - ({{ $license->expires_at->diffForHumans() }}) - @endif - @else - Never - @endif - - @@ -126,20 +106,11 @@ @endif - @if($license->is_suspended || ($license->expires_at && $license->expires_at->isPast())) + @if($license->is_suspended) - - {{ $license->is_suspended ? 'License Suspended' : 'License Expired' }} - + License Suspended - @if($license->is_suspended) - This license has been suspended. Please contact support for assistance. - @elseif($isLegacyLicense) - This license has expired. You can still renew it to restore access. - Renew now - @else - This license has expired. Please renew your subscription to continue using NativePHP. - @endif + This license has been suspended. Please contact support for assistance. @endif diff --git a/resources/views/livewire/sub-license-manager.blade.php b/resources/views/livewire/sub-license-manager.blade.php index 26c46c20..a43685fa 100644 --- a/resources/views/livewire/sub-license-manager.blade.php +++ b/resources/views/livewire/sub-license-manager.blade.php @@ -5,16 +5,11 @@ Keys - ({{ $activeSubLicenses->count() }}{{ $license->subLicenseLimit ? '/' . $license->subLicenseLimit : '' }}) + ({{ $activeSubLicenses->count() }}{{ $license->subLicenseLimit && ! $license->isExpired() ? '/' . $license->subLicenseLimit : '' }}) Manage license keys for team members or additional devices.
- @if($license->canCreateSubLicense()) - - Create Key - - @endif
@if($license->subLicenses->isEmpty()) @@ -120,15 +115,13 @@ @endif @endif - @if(!$license->canCreateSubLicense()) + @if(!$license->canCreateSubLicense() && ! $license->isExpired()) @if($license->remainingSubLicenses === 0) You have reached the maximum number of keys for this plan. @elseif($license->is_suspended) Keys cannot be created for suspended licenses. - @elseif($license->expires_at && $license->expires_at->isPast()) - Keys cannot be created for expired licenses. @else Keys cannot be created at this time. @endif diff --git a/tests/Feature/CustomerLicenseManagementTest.php b/tests/Feature/CustomerLicenseManagementTest.php index 76756db8..080092fe 100644 --- a/tests/Feature/CustomerLicenseManagementTest.php +++ b/tests/Feature/CustomerLicenseManagementTest.php @@ -106,7 +106,8 @@ public function test_customer_can_view_individual_license_details(): void $response->assertSee('pro'); $response->assertSee('test-license-key-123'); $response->assertSee('License Information'); - $response->assertSee('Active'); + $response->assertDontSee('Active'); + $response->assertDontSee('Expires'); } public function test_customer_cannot_view_other_customers_license_details(): void @@ -124,13 +125,14 @@ public function test_customer_cannot_view_other_customers_license_details(): voi $response->assertStatus(404); } - public function test_license_status_displays_correctly(): void + public function test_license_index_does_not_display_status_or_expiry(): void { $user = User::factory()->create(); // Active license $activeLicense = License::factory()->create([ 'user_id' => $user->id, + 'key' => 'license-key-one', 'expires_at' => now()->addDays(30), 'is_suspended' => false, ]); @@ -138,6 +140,7 @@ public function test_license_status_displays_correctly(): void // Expired license $expiredLicense = License::factory()->create([ 'user_id' => $user->id, + 'key' => 'license-key-two', 'expires_at' => now()->subDays(1), 'is_suspended' => false, ]); @@ -145,15 +148,20 @@ public function test_license_status_displays_correctly(): void // Suspended license $suspendedLicense = License::factory()->create([ 'user_id' => $user->id, + 'key' => 'license-key-three', 'is_suspended' => true, ]); $response = $this->actingAs($user)->get('/dashboard/licenses'); $response->assertStatus(200); - $response->assertSee('Active'); - $response->assertSee('Expired'); - $response->assertSee('Suspended'); + $response->assertSee('license-key-one'); + $response->assertSee('license-key-two'); + $response->assertSee('license-key-three'); + $response->assertDontSee('Status'); + $response->assertDontSee('Expires'); + $response->assertDontSee('Expired'); + $response->assertDontSee('Suspended'); } public function test_customer_can_update_license_name(): void diff --git a/tests/Feature/CustomerSubLicenseManagementTest.php b/tests/Feature/CustomerSubLicenseManagementTest.php index 5cf01958..4b403ea9 100644 --- a/tests/Feature/CustomerSubLicenseManagementTest.php +++ b/tests/Feature/CustomerSubLicenseManagementTest.php @@ -335,7 +335,6 @@ public function test_license_show_page_displays_sub_licenses(): void $response->assertSee('Testing Team'); $response->assertSee($subLicense1->key); $response->assertSee($subLicense2->key); - $response->assertSee('Active'); $response->assertSee('Suspended'); } @@ -520,4 +519,21 @@ public function test_livewire_component_displays_sublicenses(): void ->assertSee($activeSubLicense->key) ->assertSee($suspendedSubLicense->key); } + + public function test_expired_license_hides_key_limit_and_expired_banner(): void + { + $user = User::factory()->create(); + $license = License::factory()->create([ + 'user_id' => $user->id, + 'policy_name' => 'pro', // Pro has a sub-license limit of 9 + 'is_suspended' => false, + 'expires_at' => now()->subDay(), + ]); + + $this->actingAs($user); + + Livewire::test(SubLicenseManager::class, ['license' => $license]) + ->assertDontSee('/9') + ->assertDontSee('Keys cannot be created for expired licenses.'); + } }