README not available yet.
diff --git a/app/Filament/Resources/PluginResource/Pages/EditPlugin.php b/app/Filament/Resources/PluginResource/Pages/EditPlugin.php index c8f40df0..f2ab2a1c 100644 --- a/app/Filament/Resources/PluginResource/Pages/EditPlugin.php +++ b/app/Filament/Resources/PluginResource/Pages/EditPlugin.php @@ -161,7 +161,7 @@ protected function getHeaderActions(): array ->color('gray') ->url(fn () => route('plugins.show', $this->record->routeParams())) ->openUrlInNewTab() - ->visible(fn () => $this->record->isApproved()), + ->visible(fn () => $this->record->isApproved() || $this->record->isPending()), Actions\Action::make('viewPackagist') ->label('View on Packagist') diff --git a/app/Filament/Resources/PluginResource/Pages/ViewPlugin.php b/app/Filament/Resources/PluginResource/Pages/ViewPlugin.php index 3be53785..600f29e6 100644 --- a/app/Filament/Resources/PluginResource/Pages/ViewPlugin.php +++ b/app/Filament/Resources/PluginResource/Pages/ViewPlugin.php @@ -20,7 +20,7 @@ protected function getHeaderActions(): array ->color('gray') ->url(fn () => route('plugins.show', $this->record->routeParams())) ->openUrlInNewTab() - ->visible(fn () => $this->record->isApproved()), + ->visible(fn () => $this->record->isApproved() || $this->record->isPending()), Actions\Action::make('approve') ->icon('heroicon-o-check') diff --git a/app/Http/Controllers/PluginDirectoryController.php b/app/Http/Controllers/PluginDirectoryController.php index e2e86b52..4b0855aa 100644 --- a/app/Http/Controllers/PluginDirectoryController.php +++ b/app/Http/Controllers/PluginDirectoryController.php @@ -49,12 +49,14 @@ public function show(string $vendor, string $package): View { $plugin = Plugin::findByVendorPackageOrFail($vendor, $package); - abort_unless($plugin->isApproved(), 404); - $user = Auth::user(); - // For paid plugins, check if user has an accessible price - if ($plugin->isPaid() && ! $plugin->hasAccessiblePriceFor($user)) { + $isAdmin = $user?->isAdmin() ?? false; + + abort_unless($plugin->isApproved() || $isAdmin, 404); + + // For paid plugins, check if user has an accessible price (admins bypass) + if (! $isAdmin && $plugin->isPaid() && ! $plugin->hasAccessiblePriceFor($user)) { abort(404); } @@ -72,6 +74,7 @@ public function show(string $vendor, string $package): View 'bestPrice' => $bestPrice, 'regularPrice' => $regularPrice, 'hasDiscount' => $bestPrice && $regularPrice && $bestPrice->id !== $regularPrice->id, + 'isAdminPreview' => ! $plugin->isApproved(), ]); } diff --git a/package-lock.json b/package-lock.json index abb3f776..21461018 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "nativephp", + "name": "kind-goose", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/resources/views/components/plugin-toc.blade.php b/resources/views/components/plugin-toc.blade.php new file mode 100644 index 00000000..ad14bdf3 --- /dev/null +++ b/resources/views/components/plugin-toc.blade.php @@ -0,0 +1,35 @@ +
diff --git a/resources/views/plugin-license.blade.php b/resources/views/plugin-license.blade.php index 55c3f687..91d9c589 100644 --- a/resources/views/plugin-license.blade.php +++ b/resources/views/plugin-license.blade.php @@ -1,6 +1,6 @@+ Admin Preview — This plugin is not yet published. Status: {{ $plugin->status->label() }} +
+README not available yet.
Steps here.
More content.
', + ]); + + $this->get(route('plugins.show', $plugin->routeParams())) + ->assertStatus(200) + ->assertSee('On this page'); + } + + public function test_toc_component_not_rendered_when_no_readme(): void + { + $plugin = Plugin::factory()->approved()->create([ + 'readme_html' => null, + ]); + + $this->get(route('plugins.show', $plugin->routeParams())) + ->assertStatus(200) + ->assertDontSee('On this page'); + } +}