From f2e4dce092dc0521e969b1ec0282daa7ae039e10 Mon Sep 17 00:00:00 2001 From: Kyrch Date: Sat, 1 Jun 2024 20:36:00 -0300 Subject: [PATCH] style(filament): the panel should use the full width (#684) --- .../Discord/DiscordThread/DiscordThreadUpdated.php | 2 +- .../Discord/DiscordVideoNotificationBulkAction.php | 2 +- app/Filament/Components/Columns/TextColumn.php | 11 +++++++---- app/Filament/Resources/Wiki/Anime.php | 8 ++++++-- app/Filament/Resources/Wiki/Anime/Synonym.php | 7 +++++-- app/Filament/Resources/Wiki/Anime/Theme.php | 6 ++++-- app/Filament/Resources/Wiki/Anime/Theme/Entry.php | 3 ++- app/Filament/Resources/Wiki/Video.php | 12 +++++------- app/Models/Discord/DiscordThread.php | 1 + app/Providers/FilamentPanelProvider.php | 5 +++++ lang/en/filament.php | 5 +++-- public/img/gray-logo.svg | 1 + 12 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 public/img/gray-logo.svg diff --git a/app/Events/Discord/DiscordThread/DiscordThreadUpdated.php b/app/Events/Discord/DiscordThread/DiscordThreadUpdated.php index 934e71520..87b78d4b7 100644 --- a/app/Events/Discord/DiscordThread/DiscordThreadUpdated.php +++ b/app/Events/Discord/DiscordThread/DiscordThreadUpdated.php @@ -56,7 +56,7 @@ class DiscordThreadUpdated extends AdminUpdatedEvent protected function updateThread(): void { Http::withHeaders(['x-api-key' => Config::get('services.discord.api_key')]) - ->put(Config::get('services.discord.api_url') . '/thread', $this->getModel()) + ->put(Config::get('services.discord.api_url') . '/thread', $this->getModel()->toArray()) ->throw(); } } diff --git a/app/Filament/BulkActions/Discord/DiscordVideoNotificationBulkAction.php b/app/Filament/BulkActions/Discord/DiscordVideoNotificationBulkAction.php index 9dc28d733..c6fc255d6 100644 --- a/app/Filament/BulkActions/Discord/DiscordVideoNotificationBulkAction.php +++ b/app/Filament/BulkActions/Discord/DiscordVideoNotificationBulkAction.php @@ -19,7 +19,7 @@ class DiscordVideoNotificationBulkAction extends BaseBulkAction /** * Handle the action. * - * @param Collection $videos + * @param Collection $videos * @param array $fields */ public function handle(Collection $videos, array $fields): void diff --git a/app/Filament/Components/Columns/TextColumn.php b/app/Filament/Components/Columns/TextColumn.php index 32cefe1a7..64e10d653 100644 --- a/app/Filament/Components/Columns/TextColumn.php +++ b/app/Filament/Components/Columns/TextColumn.php @@ -10,6 +10,7 @@ use App\Models\BaseModel; use Filament\Support\Enums\FontWeight; use Filament\Tables\Columns\TextColumn as ColumnsTextColumn; use Illuminate\Support\Arr; +use Illuminate\Support\Str; /** * Class TextColumn. @@ -22,23 +23,25 @@ class TextColumn extends ColumnsTextColumn * @param class-string $resourceRelated * @param string $relation * @param bool|null $shouldUseName + * @param int|null $limit * @return static */ - public function urlToRelated(string $resourceRelated, string $relation, ?bool $shouldUseName = false): static + public function urlToRelated(string $resourceRelated, string $relation, ?bool $shouldUseName = false, ?int $limit = null): static { return $this ->weight(FontWeight::SemiBold) ->html() ->hiddenOn(BaseRelationManager::class) - ->url(function (BaseModel $record) use ($resourceRelated, $relation, $shouldUseName) { + ->url(function (BaseModel $record) use ($resourceRelated, $relation, $shouldUseName, $limit) { foreach (explode('.', $relation) as $element) { $record = Arr::get($record, $element); if ($record === null) return null; } - $this->formatStateUsing(function ($state) use ($shouldUseName, $record) { + $this->formatStateUsing(function ($state) use ($shouldUseName, $record, $limit) { $name = $shouldUseName ? $record->getName() : $state; - return "

{$name}

"; + $nameLimited = Str::limit($name, $limit ?? 100); + return "

{$nameLimited}

"; }); return (new $resourceRelated)::getUrl('edit', ['record' => $record]); diff --git a/app/Filament/Resources/Wiki/Anime.php b/app/Filament/Resources/Wiki/Anime.php index 50946aa75..e600170c8 100644 --- a/app/Filament/Resources/Wiki/Anime.php +++ b/app/Filament/Resources/Wiki/Anime.php @@ -253,12 +253,16 @@ class Anime extends BaseResource ->label(__('filament.fields.anime.name.name')) ->sortable() ->copyableWithMessage() - ->toggleable(), + ->toggleable() + ->limit(50) + ->tooltip(fn (TextColumn $column) => $column->getState()), TextColumn::make(AnimeModel::ATTRIBUTE_SLUG) ->label(__('filament.fields.anime.slug.name')) ->sortable() - ->toggleable(), + ->toggleable() + ->limit(20) + ->tooltip(fn (TextColumn $column) => $column->getState()), TextColumn::make(AnimeModel::ATTRIBUTE_YEAR) ->label(__('filament.fields.anime.year.name')) diff --git a/app/Filament/Resources/Wiki/Anime/Synonym.php b/app/Filament/Resources/Wiki/Anime/Synonym.php index 7d290ce58..6559e9f8f 100644 --- a/app/Filament/Resources/Wiki/Anime/Synonym.php +++ b/app/Filament/Resources/Wiki/Anime/Synonym.php @@ -163,7 +163,8 @@ class Synonym extends BaseResource TextColumn::make(SynonymModel::RELATION_ANIME.'.'.AnimeModel::ATTRIBUTE_NAME) ->label(__('filament.resources.singularLabel.anime')) ->toggleable() - ->urlToRelated(AnimeResource::class, SynonymModel::RELATION_ANIME), + ->urlToRelated(AnimeResource::class, SynonymModel::RELATION_ANIME, limit: 40) + ->tooltip(fn (TextColumn $column) => $column->getState()), TextColumn::make(SynonymModel::ATTRIBUTE_TYPE) ->label(__('filament.fields.anime_synonym.type.name')) @@ -173,7 +174,9 @@ class Synonym extends BaseResource TextColumn::make(SynonymModel::ATTRIBUTE_TEXT) ->label(__('filament.fields.anime_synonym.text.name')) ->sortable() - ->toggleable(), + ->toggleable() + ->limit(70) + ->tooltip(fn (TextColumn $column) => $column->getState()), ]) ->searchable() ->defaultSort(SynonymModel::ATTRIBUTE_ID, 'desc') diff --git a/app/Filament/Resources/Wiki/Anime/Theme.php b/app/Filament/Resources/Wiki/Anime/Theme.php index bd79f67fd..ddd2bfc1f 100644 --- a/app/Filament/Resources/Wiki/Anime/Theme.php +++ b/app/Filament/Resources/Wiki/Anime/Theme.php @@ -219,7 +219,8 @@ class Theme extends BaseResource TextColumn::make(ThemeModel::RELATION_ANIME.'.'.AnimeModel::ATTRIBUTE_NAME) ->label(__('filament.resources.singularLabel.anime')) ->toggleable() - ->urlToRelated(AnimeResource::class, ThemeModel::RELATION_ANIME), + ->urlToRelated(AnimeResource::class, ThemeModel::RELATION_ANIME, limit: 30) + ->tooltip(fn (TextColumn $column) => $column->getState()), TextColumn::make(ThemeModel::ATTRIBUTE_ID) ->label(__('filament.fields.base.id')) @@ -252,7 +253,8 @@ class Theme extends BaseResource ->label(__('filament.resources.singularLabel.song')) ->toggleable() ->placeholder('-') - ->urlToRelated(SongResource::class, ThemeModel::RELATION_SONG), + ->urlToRelated(SongResource::class, ThemeModel::RELATION_SONG, limit: 30) + ->tooltip(fn (TextColumn $column) => $column->getState()), ]) ->searchable() ->defaultSort(ThemeModel::ATTRIBUTE_ID, 'desc') diff --git a/app/Filament/Resources/Wiki/Anime/Theme/Entry.php b/app/Filament/Resources/Wiki/Anime/Theme/Entry.php index 4c4723671..c1a8058bd 100644 --- a/app/Filament/Resources/Wiki/Anime/Theme/Entry.php +++ b/app/Filament/Resources/Wiki/Anime/Theme/Entry.php @@ -234,7 +234,8 @@ class Entry extends BaseResource ->label(__('filament.resources.singularLabel.anime')) ->toggleable() ->placeholder('-') - ->urlToRelated(AnimeResource::class, EntryModel::RELATION_ANIME), + ->urlToRelated(AnimeResource::class, EntryModel::RELATION_ANIME, limit: 30) + ->tooltip(fn (TextColumn $column) => $column->getState()), TextColumn::make(EntryModel::ATTRIBUTE_THEME) ->label(__('filament.resources.singularLabel.anime_theme')) diff --git a/app/Filament/Resources/Wiki/Video.php b/app/Filament/Resources/Wiki/Video.php index 86d140907..4d5d31e69 100644 --- a/app/Filament/Resources/Wiki/Video.php +++ b/app/Filament/Resources/Wiki/Video.php @@ -36,7 +36,6 @@ use Filament\Infolists\Infolist; use Filament\Resources\RelationManagers\RelationGroup; use Filament\Support\Enums\MaxWidth; use Filament\Tables\Actions\ActionGroup; -use Filament\Tables\Actions\BulkActionGroup; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Filters\Filter; use Filament\Tables\Filters\SelectFilter; @@ -412,12 +411,11 @@ class Video extends BaseResource return array_merge( parent::getBulkActions(), [ - BulkActionGroup::make([ - DiscordVideoNotificationBulkAction::make('discord-notification') - ->label(__('filament.bulk_actions.discord.notification.name')) - ->requiresConfirmation() - ->authorize('create', DiscordThread::class), - ]), + DiscordVideoNotificationBulkAction::make('discord-notification') + ->label(__('filament.bulk_actions.discord.notification.name')) + ->icon(__('filament.bulk_actions.discord.notification.icon')) + ->requiresConfirmation() + ->authorize('create', DiscordThread::class), ], ); } diff --git a/app/Models/Discord/DiscordThread.php b/app/Models/Discord/DiscordThread.php index 5b51be242..2343e5b89 100644 --- a/app/Models/Discord/DiscordThread.php +++ b/app/Models/Discord/DiscordThread.php @@ -14,6 +14,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; * Class DiscordThread. * * @property Anime $anime + * @property int $anime_id * @property int $thread_id * @property string $name */ diff --git a/app/Providers/FilamentPanelProvider.php b/app/Providers/FilamentPanelProvider.php index d92d31b67..8f03f1fb3 100644 --- a/app/Providers/FilamentPanelProvider.php +++ b/app/Providers/FilamentPanelProvider.php @@ -11,6 +11,7 @@ use Filament\Http\Middleware\DispatchServingFilamentEvent; use Filament\Panel; use Filament\PanelProvider; use Filament\Support\Colors\Color; +use Filament\Support\Enums\MaxWidth; use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse; use Illuminate\Cookie\Middleware\EncryptCookies; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken; @@ -31,7 +32,11 @@ class FilamentPanelProvider extends PanelProvider ->path(Config::get('filament.path')) ->domain(Config::get('filament.domain')) ->login() + ->brandLogo(asset('img/logo.svg')) + ->darkModeBrandLogo(asset('img/gray-logo.svg')) + ->brandLogoHeight('1.8rem') ->globalSearch(GlobalSearchScoutProvider::class) + ->maxContentWidth(MaxWidth::Full) ->databaseNotifications() ->sidebarCollapsibleOnDesktop() ->profile() diff --git a/lang/en/filament.php b/lang/en/filament.php index d1c4e7cc3..716dce0b8 100644 --- a/lang/en/filament.php +++ b/lang/en/filament.php @@ -412,6 +412,7 @@ return [ ], 'discord' => [ 'notification' => [ + 'icon' => 'heroicon-o-bell', 'name' => 'Create Discord Notification', 'type' => [ 'help' => 'Are they new videos or replacement?', @@ -426,8 +427,8 @@ return [ ], 'dashboards' => [ 'icon' => [ - 'admin' => 'heroicon-m-home', - 'wiki' => 'heroicon-m-home', + 'admin' => 'heroicon-m-chart-bar', + 'wiki' => 'heroicon-m-chart-bar', ], 'label' => [ 'admin' => 'Admin', diff --git a/public/img/gray-logo.svg b/public/img/gray-logo.svg new file mode 100644 index 000000000..1e59da129 --- /dev/null +++ b/public/img/gray-logo.svg @@ -0,0 +1 @@ +