Skip to content

Commit 7d8910e

Browse files
simonhampclaude
andcommitted
Fix CI failures: Pint formatting, test compatibility, and team plugins view
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 49d7855 commit 7d8910e

File tree

11 files changed

+112
-18
lines changed

11 files changed

+112
-18
lines changed

app/Livewire/Customer/PurchasedPlugins/Index.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Livewire\Customer\PurchasedPlugins;
44

55
use Illuminate\Database\Eloquent\Collection;
6+
use Illuminate\Support\Collection as SupportCollection;
67
use Livewire\Attributes\Computed;
78
use Livewire\Attributes\Layout;
89
use Livewire\Attributes\Title;
@@ -27,6 +28,32 @@ public function pluginLicenseKey(): string
2728
return auth()->user()->getPluginLicenseKey();
2829
}
2930

31+
#[Computed]
32+
public function teamPlugins(): SupportCollection
33+
{
34+
$membership = auth()->user()->activeTeamMembership();
35+
36+
if (! $membership) {
37+
return collect();
38+
}
39+
40+
return $membership->team->owner->pluginLicenses()
41+
->active()
42+
->with('plugin')
43+
->get()
44+
->pluck('plugin')
45+
->filter()
46+
->unique('id');
47+
}
48+
49+
#[Computed]
50+
public function teamOwnerName(): ?string
51+
{
52+
$membership = auth()->user()->activeTeamMembership();
53+
54+
return $membership?->team->owner->display_name;
55+
}
56+
3057
public function rotateKey(): void
3158
{
3259
auth()->user()->regeneratePluginLicenseKey();

app/Models/Team.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Models;
44

5+
use App\Enums\TeamUserStatus;
56
use Illuminate\Database\Eloquent\Factories\HasFactory;
67
use Illuminate\Database\Eloquent\Model;
78
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -40,7 +41,7 @@ public function users(): HasMany
4041
public function activeUsers(): HasMany
4142
{
4243
return $this->hasMany(TeamUser::class)
43-
->where('status', \App\Enums\TeamUserStatus::Active);
44+
->where('status', TeamUserStatus::Active);
4445
}
4546

4647
/**
@@ -49,7 +50,7 @@ public function activeUsers(): HasMany
4950
public function pendingInvitations(): HasMany
5051
{
5152
return $this->hasMany(TeamUser::class)
52-
->where('status', \App\Enums\TeamUserStatus::Pending);
53+
->where('status', TeamUserStatus::Pending);
5354
}
5455

5556
public function activeUserCount(): int

config/database.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Illuminate\Support\Str;
4+
use Pdo\Mysql;
45

56
return [
67

@@ -59,7 +60,7 @@
5960
'strict' => true,
6061
'engine' => null,
6162
'options' => extension_loaded('pdo_mysql') ? array_filter([
62-
Pdo\Mysql::ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
63+
Mysql::ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
6364
]) : [],
6465
],
6566

database/factories/TeamFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
namespace Database\Factories;
44

5+
use App\Models\Team;
56
use App\Models\User;
67
use Illuminate\Database\Eloquent\Factories\Factory;
78

89
/**
9-
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Team>
10+
* @extends Factory<Team>
1011
*/
1112
class TeamFactory extends Factory
1213
{

database/factories/TeamUserFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
use App\Enums\TeamUserRole;
66
use App\Enums\TeamUserStatus;
77
use App\Models\Team;
8+
use App\Models\TeamUser;
89
use App\Models\User;
910
use Illuminate\Database\Eloquent\Factories\Factory;
1011

1112
/**
12-
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TeamUser>
13+
* @extends Factory<TeamUser>
1314
*/
1415
class TeamUserFactory extends Factory
1516
{

resources/views/livewire/customer/purchased-plugins.blade.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,54 @@
7878
<flux:button variant="primary" href="{{ route('plugins.marketplace') }}">Browse Plugins</flux:button>
7979
</x-customer.empty-state>
8080
@endif
81+
82+
{{-- Team Plugins --}}
83+
@if($this->teamPlugins->isNotEmpty())
84+
<flux:heading class="mb-3 mt-8">
85+
Team Plugins
86+
<span class="text-sm font-normal text-zinc-500 dark:text-white/70">— shared by {{ $this->teamOwnerName }}</span>
87+
</flux:heading>
88+
<flux:table>
89+
<flux:table.columns>
90+
<flux:table.column>Plugin</flux:table.column>
91+
<flux:table.column>Access</flux:table.column>
92+
</flux:table.columns>
93+
94+
<flux:table.rows>
95+
@foreach($this->teamPlugins as $plugin)
96+
<flux:table.row :key="'team-' . $plugin->id">
97+
<flux:table.cell>
98+
<div class="flex items-center gap-3">
99+
<div class="shrink-0">
100+
@if($plugin->hasLogo())
101+
<img src="{{ $plugin->getLogoUrl() }}" alt="{{ $plugin->name }}" class="size-10 rounded-lg object-cover">
102+
@elseif($plugin->hasGradientIcon())
103+
<div class="grid size-10 place-items-center rounded-lg bg-gradient-to-br {{ $plugin->getGradientClasses() }} text-white">
104+
<x-dynamic-component :component="'heroicon-o-' . $plugin->icon_name" class="size-5" />
105+
</div>
106+
@else
107+
<div class="grid size-10 place-items-center rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600 text-white">
108+
<x-vaadin-plug class="size-5" />
109+
</div>
110+
@endif
111+
</div>
112+
<div>
113+
<a href="{{ route('plugins.show', $plugin->routeParams()) }}" class="font-medium text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300">
114+
{{ $plugin->name }}
115+
</a>
116+
@if($plugin->description)
117+
<flux:text class="text-xs line-clamp-1">{{ $plugin->description }}</flux:text>
118+
@endif
119+
</div>
120+
</div>
121+
</flux:table.cell>
122+
123+
<flux:table.cell>
124+
<x-customer.status-badge status="Team" />
125+
</flux:table.cell>
126+
</flux:table.row>
127+
@endforeach
128+
</flux:table.rows>
129+
</flux:table>
130+
@endif
81131
</div>

tests/Feature/CustomerPluginReviewChecksTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function submitting_a_plugin_runs_review_checks(): void
2323

2424
$user = User::factory()->create([
2525
'github_id' => '12345',
26+
'github_token' => encrypt('fake-token'),
2627
]);
2728
DeveloperAccount::factory()->withAcceptedTerms()->create([
2829
'user_id' => $user->id,
@@ -45,7 +46,7 @@ public function submitting_a_plugin_runs_review_checks(): void
4546
'content' => base64_encode("# Test Plugin\n\nSupport: dev@testplugin.io"),
4647
'encoding' => 'base64',
4748
]),
48-
"{$base}/contents/composer.json" => Http::response([
49+
"{$base}/contents/composer.json*" => Http::response([
4950
'content' => base64_encode($composerJson),
5051
'encoding' => 'base64',
5152
]),
@@ -55,6 +56,9 @@ public function submitting_a_plugin_runs_review_checks(): void
5556
"{$base}/tags*" => Http::response([]),
5657
"https://raw.githubusercontent.com/{$repoSlug}/*" => Http::response('', 404),
5758

59+
// Webhook creation
60+
"{$base}/hooks" => Http::response(['id' => 1], 201),
61+
5862
// ReviewPluginRepository calls
5963
$base => Http::response(['default_branch' => 'main']),
6064
"{$base}/git/trees/main*" => Http::response([
@@ -103,6 +107,7 @@ public function plugin_submitted_email_includes_failing_checks(): void
103107

104108
$user = User::factory()->create([
105109
'github_id' => '12345',
110+
'github_token' => encrypt('fake-token'),
106111
]);
107112
DeveloperAccount::factory()->withAcceptedTerms()->create([
108113
'user_id' => $user->id,
@@ -121,7 +126,7 @@ public function plugin_submitted_email_includes_failing_checks(): void
121126
'content' => base64_encode('# Bare Plugin'),
122127
'encoding' => 'base64',
123128
]),
124-
"{$base}/contents/composer.json" => Http::response([
129+
"{$base}/contents/composer.json*" => Http::response([
125130
'content' => base64_encode($composerJson),
126131
'encoding' => 'base64',
127132
]),
@@ -131,6 +136,9 @@ public function plugin_submitted_email_includes_failing_checks(): void
131136
"{$base}/tags*" => Http::response([]),
132137
"https://raw.githubusercontent.com/{$repoSlug}/*" => Http::response('', 404),
133138

139+
// Webhook creation
140+
"{$base}/hooks" => Http::response(['id' => 1], 201),
141+
134142
$base => Http::response(['default_branch' => 'main']),
135143
"{$base}/git/trees/main*" => Http::response([
136144
'tree' => [

tests/Feature/SendMaxToUltraAnnouncementTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Notifications\MaxToUltraAnnouncement;
88
use Illuminate\Foundation\Testing\RefreshDatabase;
99
use Illuminate\Support\Facades\Notification;
10+
use Laravel\Cashier\SubscriptionItem;
1011
use Tests\TestCase;
1112

1213
class SendMaxToUltraAnnouncementTest extends TestCase
@@ -36,7 +37,7 @@ private function createPaidMaxSubscription(User $user, ?string $priceId = null):
3637
'is_comped' => false,
3738
]);
3839

39-
\Laravel\Cashier\SubscriptionItem::factory()
40+
SubscriptionItem::factory()
4041
->for($subscription, 'subscription')
4142
->create([
4243
'stripe_price' => $price,
@@ -58,7 +59,7 @@ private function createCompedMaxSubscription(User $user): \Laravel\Cashier\Subsc
5859
'is_comped' => true,
5960
]);
6061

61-
\Laravel\Cashier\SubscriptionItem::factory()
62+
SubscriptionItem::factory()
6263
->for($subscription, 'subscription')
6364
->create([
6465
'stripe_price' => Subscription::Max->stripePriceId(),
@@ -80,7 +81,7 @@ private function createProSubscription(User $user): \Laravel\Cashier\Subscriptio
8081
'is_comped' => false,
8182
]);
8283

83-
\Laravel\Cashier\SubscriptionItem::factory()
84+
SubscriptionItem::factory()
8485
->for($subscription, 'subscription')
8586
->create([
8687
'stripe_price' => Subscription::Pro->stripePriceId(),
@@ -101,7 +102,7 @@ private function createCompedUltraSubscription(User $user): \Laravel\Cashier\Sub
101102
'stripe_price' => self::COMPED_ULTRA_PRICE_ID,
102103
]);
103104

104-
\Laravel\Cashier\SubscriptionItem::factory()
105+
SubscriptionItem::factory()
105106
->for($subscription, 'subscription')
106107
->create([
107108
'stripe_price' => self::COMPED_ULTRA_PRICE_ID,

tests/Feature/SendUltraLicenseHolderPromotionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use App\Notifications\UltraLicenseHolderPromotion;
99
use Illuminate\Foundation\Testing\RefreshDatabase;
1010
use Illuminate\Support\Facades\Notification;
11+
use Laravel\Cashier\SubscriptionItem;
1112
use Tests\TestCase;
1213

1314
class SendUltraLicenseHolderPromotionTest extends TestCase
@@ -35,7 +36,7 @@ private function createActiveSubscription(User $user, string $priceId): \Laravel
3536
'is_comped' => false,
3637
]);
3738

38-
\Laravel\Cashier\SubscriptionItem::factory()
39+
SubscriptionItem::factory()
3940
->for($subscription, 'subscription')
4041
->create([
4142
'stripe_price' => $priceId,

tests/Feature/SendUltraUpgradePromotionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Notifications\UltraUpgradePromotion;
88
use Illuminate\Foundation\Testing\RefreshDatabase;
99
use Illuminate\Support\Facades\Notification;
10+
use Laravel\Cashier\SubscriptionItem;
1011
use Tests\TestCase;
1112

1213
class SendUltraUpgradePromotionTest extends TestCase
@@ -34,7 +35,7 @@ private function createSubscription(User $user, string $priceId, bool $isComped
3435
'is_comped' => $isComped,
3536
]);
3637

37-
\Laravel\Cashier\SubscriptionItem::factory()
38+
SubscriptionItem::factory()
3839
->for($subscription, 'subscription')
3940
->create([
4041
'stripe_price' => $priceId,

0 commit comments

Comments
 (0)