Skip to content
Merged
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
1 change: 1 addition & 0 deletions app/Filament/Resources/PluginResource/Pages/EditPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ protected function getHeaderActions(): array
->label('View on GitHub')
->icon('heroicon-o-arrow-top-right-on-square')
->color('gray')
->visible(fn () => $this->record->repository_url !== null)
->url(fn () => $this->record->getGithubUrl())
->openUrlInNewTab(),
])
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ public function getPackagistUrl(): string
return "https://packagist.org/packages/{$this->name}";
}

public function getGithubUrl(): string
public function getGithubUrl(): ?string
{
return "https://github.com/{$this->name}";
return $this->repository_url;
}

public function getWebhookUrl(): ?string
Expand Down
23 changes: 23 additions & 0 deletions tests/Feature/Filament/ResyncPluginActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,27 @@ public function test_resync_action_hidden_when_no_repository_url(): void
->test(EditPlugin::class, ['record' => $plugin->getRouteKey()])
->assertActionHidden('resync');
}

public function test_view_github_action_uses_repository_url(): void
{
$plugin = Plugin::factory()->free()->approved()->create([
'repository_url' => 'https://github.com/acme/test-plugin',
]);

Livewire::actingAs($this->admin)
->test(EditPlugin::class, ['record' => $plugin->getRouteKey()])
->assertActionVisible('viewGithub')
->assertActionHasUrl('viewGithub', 'https://github.com/acme/test-plugin');
}

public function test_view_github_action_hidden_when_no_repository_url(): void
{
$plugin = Plugin::factory()->free()->approved()->create([
'repository_url' => null,
]);

Livewire::actingAs($this->admin)
->test(EditPlugin::class, ['record' => $plugin->getRouteKey()])
->assertActionHidden('viewGithub');
}
}
Loading