21 - Add dynamic channel labels based on platform type
This commit is contained in:
parent
bf96489362
commit
ec09711a6f
4 changed files with 28 additions and 4 deletions
|
|
@ -5,4 +5,18 @@
|
||||||
enum PlatformEnum: string
|
enum PlatformEnum: string
|
||||||
{
|
{
|
||||||
case LEMMY = 'lemmy';
|
case LEMMY = 'lemmy';
|
||||||
|
|
||||||
|
public function channelLabel(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::LEMMY => 'Community',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function channelLabelPlural(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::LEMMY => 'Communities',
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ public function deleteKeyword(int $keywordId): void
|
||||||
|
|
||||||
public function render(): \Illuminate\Contracts\View\View
|
public function render(): \Illuminate\Contracts\View\View
|
||||||
{
|
{
|
||||||
$routes = Route::with(['feed', 'platformChannel'])
|
$routes = Route::with(['feed', 'platformChannel.platformInstance'])
|
||||||
->orderBy('priority', 'desc')
|
->orderBy('priority', 'desc')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|
@ -186,7 +186,7 @@ public function render(): \Illuminate\Contracts\View\View
|
||||||
$editingKeywords = collect();
|
$editingKeywords = collect();
|
||||||
|
|
||||||
if ($this->editingFeedId && $this->editingChannelId) {
|
if ($this->editingFeedId && $this->editingChannelId) {
|
||||||
$editingRoute = Route::with(['feed', 'platformChannel'])
|
$editingRoute = Route::with(['feed', 'platformChannel.platformInstance'])
|
||||||
->where('feed_id', $this->editingFeedId)
|
->where('feed_id', $this->editingFeedId)
|
||||||
->where('platform_channel_id', $this->editingChannelId)
|
->where('platform_channel_id', $this->editingChannelId)
|
||||||
->first();
|
->first();
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class="inline-flex items-center px-4 py-2 border border-transparent text-sm font
|
||||||
<span>•</span>
|
<span>•</span>
|
||||||
<span>Feed: {{ $route->feed?->name }}</span>
|
<span>Feed: {{ $route->feed?->name }}</span>
|
||||||
<span>•</span>
|
<span>•</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>•</span>
|
<span>•</span>
|
||||||
<span>Created: {{ $route->created_at->format('M d, Y') }}</span>
|
<span>Created: {{ $route->created_at->format('M d, Y') }}</span>
|
||||||
</div>
|
</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 }}
|
<strong>Feed:</strong> {{ $editingRoute->feed?->name }}
|
||||||
</p>
|
</p>
|
||||||
<p class="text-sm text-gray-600">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,4 +86,14 @@ public function test_enum_value_is_string_backed(): void
|
||||||
{
|
{
|
||||||
$this->assertIsString(PlatformEnum::LEMMY->value);
|
$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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue