21 - Add dynamic channel labels based on platform type
All checks were successful
CI / ci (push) Successful in 5m21s
CI / ci (pull_request) Successful in 5m39s
Build and Push Docker Image / build (push) Successful in 4m36s

This commit is contained in:
myrmidex 2026-03-08 18:10:47 +01:00
parent bf96489362
commit ec09711a6f
4 changed files with 28 additions and 4 deletions

View file

@ -5,4 +5,18 @@
enum PlatformEnum: string
{
case LEMMY = 'lemmy';
public function channelLabel(): string
{
return match ($this) {
self::LEMMY => 'Community',
};
}
public function channelLabelPlural(): string
{
return match ($this) {
self::LEMMY => 'Communities',
};
}
}

View file

@ -161,7 +161,7 @@ public function deleteKeyword(int $keywordId): void
public function render(): \Illuminate\Contracts\View\View
{
$routes = Route::with(['feed', 'platformChannel'])
$routes = Route::with(['feed', 'platformChannel.platformInstance'])
->orderBy('priority', 'desc')
->get();
@ -186,7 +186,7 @@ public function render(): \Illuminate\Contracts\View\View
$editingKeywords = collect();
if ($this->editingFeedId && $this->editingChannelId) {
$editingRoute = Route::with(['feed', 'platformChannel'])
$editingRoute = Route::with(['feed', 'platformChannel.platformInstance'])
->where('feed_id', $this->editingFeedId)
->where('platform_channel_id', $this->editingChannelId)
->first();

View file

@ -47,7 +47,7 @@ class="inline-flex items-center px-4 py-2 border border-transparent text-sm font
<span>&bull;</span>
<span>Feed: {{ $route->feed?->name }}</span>
<span>&bull;</span>
<span>Channel: {{ $route->platformChannel?->display_name ?? $route->platformChannel?->name }}</span>
<span>{{ $route->platformChannel?->platformInstance?->platform?->channelLabel() ?? 'Channel' }}: {{ $route->platformChannel?->display_name ?? $route->platformChannel?->name }}</span>
<span>&bull;</span>
<span>Created: {{ $route->created_at->format('M d, Y') }}</span>
</div>
@ -246,7 +246,7 @@ class="px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transp
<strong>Feed:</strong> {{ $editingRoute->feed?->name }}
</p>
<p class="text-sm text-gray-600">
<strong>Channel:</strong> {{ $editingRoute->platformChannel?->display_name ?? $editingRoute->platformChannel?->name }}
<strong>{{ $editingRoute->platformChannel?->platformInstance?->platform?->channelLabel() ?? 'Channel' }}:</strong> {{ $editingRoute->platformChannel?->display_name ?? $editingRoute->platformChannel?->name }}
</p>
</div>

View file

@ -86,4 +86,14 @@ public function test_enum_value_is_string_backed(): void
{
$this->assertIsString(PlatformEnum::LEMMY->value);
}
public function test_channel_label_returns_community_for_lemmy(): void
{
$this->assertEquals('Community', PlatformEnum::LEMMY->channelLabel());
}
public function test_channel_label_plural_returns_communities_for_lemmy(): void
{
$this->assertEquals('Communities', PlatformEnum::LEMMY->channelLabelPlural());
}
}