Skip to content

Commit

Permalink
feat: added new fields to views table (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Dec 11, 2024
1 parent 2a856c3 commit 310e300
Show file tree
Hide file tree
Showing 53 changed files with 613 additions and 594 deletions.
4 changes: 0 additions & 4 deletions app/Actions/Discord/DiscordVideoNotificationAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;

/**
* Class DiscordVideoNotificationAction.
Expand All @@ -28,9 +27,6 @@ public function handle(Collection $videos, array $fields): void
$type = Arr::get($fields, 'notification-type');
$shouldForce = Arr::get($fields, 'should-force-thread');

/** @var \Illuminate\Filesystem\FilesystemAdapter $fs */
$fs = Storage::disk(Config::get('image.disk'));

$newVideos = [];

foreach ($videos as $video) {
Expand Down
2 changes: 2 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Exceptions;

use App\Models\Admin\ActionLog;
use BezhanSalleh\FilamentExceptions\FilamentExceptions;
use Filament\Facades\Filament;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
Expand Down Expand Up @@ -34,6 +35,7 @@ public function register(): void
{
$this->reportable(function (Throwable $e) {
if (Filament::isServing() && $this->shouldReport($e)) {
ActionLog::updateCurrentActionLogToFailed($e);
FilamentExceptions::report($e);
}
});
Expand Down
5 changes: 3 additions & 2 deletions app/Filament/Actions/Base/EditAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Concerns\Filament\ActionLogs\HasPivotActionLogs;
use App\Filament\RelationManagers\BaseRelationManager;
use App\Filament\Resources\Base\BaseManageResources;
use Filament\Forms\Form;
use Filament\Tables\Actions\EditAction as DefaultEditAction;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
Expand All @@ -28,9 +29,9 @@ protected function setUp(): void

$this->label(__('filament.actions.base.edit'));

$this->form(fn (Form $form, BaseRelationManager $livewire) => [
$this->form(fn (Form $form, BaseRelationManager|BaseManageResources $livewire) => [
...$livewire->form($form)->getComponents(),
...$livewire->getPivotFields(),
...($livewire instanceof BaseRelationManager ? $livewire->getPivotFields() : []),
]);

$this->after(function ($livewire, $record) {
Expand Down
1 change: 0 additions & 1 deletion app/Filament/Components/Columns/BelongsToColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function reload(): void
{
$relation = explode('.', $this->getName())[0];

$this->placeholder('-');
$this->label($this->resource->getModelLabel());
$this->tooltip(fn (BelongsToColumn $column) => is_array($column->getState()) ? null : $column->getState());
$this->weight(FontWeight::SemiBold);
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Components/Filters/CheckboxFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class CheckboxFilter extends Filter
{
/**
* Initial setup for the filter
* Initial setup for the filter.
*
* @return void
*/
Expand Down
1 change: 0 additions & 1 deletion app/Filament/Components/Infolist/TextEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class TextEntry extends ComponentsTextEntry
public function urlToRelated(string $resourceRelated, string $relation, ?bool $shouldUseName = false): static
{
return $this
->placeholder('-')
->weight(FontWeight::SemiBold)
->html()
->url(function (BaseModel|Model $record) use ($resourceRelated, $relation, $shouldUseName) {
Expand Down
29 changes: 10 additions & 19 deletions app/Filament/Resources/Admin/ActionLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Filament\Facades\Filament;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Form;
use Filament\Infolists\Components\TextEntry\TextEntrySize;
use Filament\Infolists\Infolist;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
Expand Down Expand Up @@ -124,7 +125,6 @@ public static function form(Form $form): Form
Textarea::make(ActionLogModel::ATTRIBUTE_EXCEPTION)
->label(__('filament.fields.action_log.exception'))
->disabled()
->placeholder('-')
->columnSpanFull(),
]);
}
Expand All @@ -143,40 +143,32 @@ public static function table(Table $table): Table
->recordUrl('')
->columns([
TextColumn::make(ActionLogModel::ATTRIBUTE_ID)
->label(__('filament.fields.base.id'))
->sortable(),
->label(__('filament.fields.base.id')),

TextColumn::make(ActionLogModel::ATTRIBUTE_NAME)
->label(__('filament.fields.action_log.name'))
->sortable()
->searchable(),

BelongsToColumn::make(ActionLogModel::RELATION_USER.'.'.UserModel::ATTRIBUTE_NAME)
->resource(User::class)
->sortable(),
->resource(User::class),

TextColumn::make(ActionLogModel::ATTRIBUTE_TARGET)
->label(__('filament.fields.action_log.target'))
->formatStateUsing(fn ($state) => Str::headline(class_basename($state)) . ': ' . $state->getName())
->sortable(),
->formatStateUsing(fn ($state) => Str::headline(class_basename($state)) . ': ' . $state->getName()),

TextColumn::make(ActionLogModel::ATTRIBUTE_STATUS)
->label(__('filament.fields.action_log.status'))
->formatStateUsing(fn (ActionLogStatus $state) => $state->localize())
->color(fn (ActionLogStatus $state) => $state->color())
->badge()
->sortable(),
->badge(),

TextColumn::make(BaseModel::ATTRIBUTE_CREATED_AT)
->label(__('filament.fields.action_log.happened_at'))
->dateTime()
->sortable(),
->dateTime(),

TextColumn::make(ActionLogModel::ATTRIBUTE_FINISHED_AT)
->label(__('filament.fields.action_log.finished_at'))
->dateTime()
->sortable()
->placeholder('-'),
->dateTime(),
]);
}

Expand Down Expand Up @@ -216,13 +208,12 @@ public static function infolist(Infolist $infolist): Infolist

TextEntry::make(ActionLogModel::ATTRIBUTE_FINISHED_AT)
->label(__('filament.fields.action_log.finished_at'))
->dateTime()
->placeholder('-'),
->dateTime(),

TextEntry::make(ActionLogModel::ATTRIBUTE_EXCEPTION)
->label(__('filament.fields.action_log.exception'))
->placeholder('-')
->columnSpanFull(),
->columnSpanFull()
->size(TextEntrySize::Large),
])->columns(3);
}

Expand Down
4 changes: 1 addition & 3 deletions app/Filament/Resources/Admin/Announcement.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,10 @@ public static function table(Table $table): Table
->recordUrl('')
->columns([
TextColumn::make(AnnouncementModel::ATTRIBUTE_ID)
->label(__('filament.fields.base.id'))
->sortable(),
->label(__('filament.fields.base.id')),

TextColumn::make(AnnouncementModel::ATTRIBUTE_CONTENT)
->label(__('filament.fields.announcement.content'))
->sortable()
->searchable()
->copyableWithMessage(),
]);
Expand Down
6 changes: 2 additions & 4 deletions app/Filament/Resources/Admin/Dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,10 @@ public static function table(Table $table): Table
->recordUrl('')
->columns([
TextColumn::make(DumpModel::ATTRIBUTE_ID)
->label(__('filament.fields.base.id'))
->sortable(),
->label(__('filament.fields.base.id')),

TextColumn::make(DumpModel::ATTRIBUTE_PATH)
->label(__('filament.fields.dump.path'))
->sortable()
->searchable()
->copyableWithMessage(),
]);
Expand Down Expand Up @@ -240,7 +238,7 @@ public static function getTableActions(): array
DumpWikiTableAction::make('dump-wiki'),

DumpDocumentTableAction::make('dump-document'),

PruneDumpTableAction::make('prune-dump'),

ReconcileDumpTableAction::make('reconcile-dump'),
Expand Down
12 changes: 3 additions & 9 deletions app/Filament/Resources/Admin/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,24 @@ public static function table(Table $table): Table
'danger' => fn ($state): bool => $state === 'DELETE',
'gray' => fn ($state): bool => $state === 'OPTIONS',
])
->searchable()
->sortable(),
->searchable(),

TextColumn::make('path')
->label(__('filament-exceptions::filament-exceptions.columns.path'))
->searchable(),

TextColumn::make('type')
->label(__('filament-exceptions::filament-exceptions.columns.type'))
->sortable()
->searchable(),

TextColumn::make('code')
->label(__('filament-exceptions::filament-exceptions.columns.code'))
->searchable()
->sortable()
->toggleable(),
->searchable(),

TextColumn::make('created_at')
->label(__('filament-exceptions::filament-exceptions.columns.occurred_at'))
->sortable()
->searchable()
->dateTime()
->toggleable(),
->dateTime(),
])
->actions([
ViewAction::make('view')
Expand Down
5 changes: 1 addition & 4 deletions app/Filament/Resources/Admin/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,15 @@ public static function table(Table $table): Table
->modifyQueryUsing(fn (Builder $query) => $query->where(FeatureModel::ATTRIBUTE_SCOPE, FeatureConstants::NULL_SCOPE))
->columns([
TextColumn::make(FeatureModel::ATTRIBUTE_ID)
->label(__('filament.fields.base.id'))
->sortable(),
->label(__('filament.fields.base.id')),

TextColumn::make(FeatureModel::ATTRIBUTE_NAME)
->label(__('filament.fields.feature.key.name'))
->sortable()
->searchable()
->copyableWithMessage(),

TextColumn::make(FeatureModel::ATTRIBUTE_VALUE)
->label(__('filament.fields.feature.value.name'))
->sortable()
->copyableWithMessage(),
]);
}
Expand Down
23 changes: 6 additions & 17 deletions app/Filament/Resources/Admin/FeaturedTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,32 +204,24 @@ public static function table(Table $table): Table
return parent::table($table)
->columns([
TextColumn::make(FeaturedThemeModel::ATTRIBUTE_ID)
->label(__('filament.fields.base.id'))
->sortable(),
->label(__('filament.fields.base.id')),

TextColumn::make(FeaturedThemeModel::ATTRIBUTE_START_AT)
->label(__('filament.fields.featured_theme.start_at'))
->sortable()
->date()
->toggleable(),
->date(),

TextColumn::make(FeaturedThemeModel::ATTRIBUTE_END_AT)
->label(__('filament.fields.featured_theme.end_at'))
->sortable()
->date()
->toggleable(),
->date(),

BelongsToColumn::make(FeaturedThemeModel::RELATION_VIDEO.'.'.Video::ATTRIBUTE_FILENAME)
->resource(VideoResource::class)
->toggleable(),
->resource(VideoResource::class),

BelongsToColumn::make(FeaturedThemeModel::RELATION_ENTRY.'.'.EntryModel::ATTRIBUTE_ID)
->resource(EntryResource::class)
->toggleable(),
->resource(EntryResource::class),

BelongsToColumn::make(FeaturedThemeModel::RELATION_USER.'.'.User::ATTRIBUTE_NAME)
->resource(UserResource::class)
->toggleable(),
->resource(UserResource::class),
]);
}

Expand Down Expand Up @@ -260,17 +252,14 @@ public static function infolist(Infolist $infolist): Infolist

TextEntry::make(FeaturedThemeModel::RELATION_VIDEO.'.'.Video::ATTRIBUTE_FILENAME)
->label(__('filament.resources.singularLabel.video'))
->placeholder('-')
->urlToRelated(VideoResource::class, FeaturedThemeModel::RELATION_VIDEO),

TextEntry::make(FeaturedThemeModel::RELATION_ENTRY)
->label(__('filament.resources.singularLabel.anime_theme_entry'))
->placeholder('-')
->urlToRelated(EntryResource::class, FeaturedThemeModel::RELATION_ENTRY, true),

TextEntry::make(FeaturedThemeModel::RELATION_USER.'.'.User::ATTRIBUTE_NAME)
->label(__('filament.resources.singularLabel.user'))
->placeholder('-')
->urlToRelated(UserResource::class, FeaturedThemeModel::RELATION_USER),
])
->columns(3),
Expand Down
4 changes: 1 addition & 3 deletions app/Filament/Resources/Auth/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,10 @@ public static function table(Table $table): Table
->recordUrl(fn (PermissionModel $record): string => static::getUrl('view', ['record' => $record]))
->columns([
TextColumn::make(PermissionModel::ATTRIBUTE_ID)
->label(__('filament.fields.base.id'))
->sortable(),
->label(__('filament.fields.base.id')),

TextColumn::make(PermissionModel::ATTRIBUTE_NAME)
->label(__('filament.fields.permission.name'))
->sortable()
->searchable()
->copyableWithMessage(),
]);
Expand Down
21 changes: 5 additions & 16 deletions app/Filament/Resources/Auth/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,32 +167,22 @@ public static function table(Table $table): Table
return parent::table($table)
->columns([
TextColumn::make(RoleModel::ATTRIBUTE_ID)
->label(__('filament.fields.base.id'))
->sortable(),
->label(__('filament.fields.base.id')),

TextColumn::make(RoleModel::ATTRIBUTE_NAME)
->label(__('filament.fields.role.name'))
->sortable()
->searchable()
->copyableWithMessage()
->toggleable(),
->copyableWithMessage(),

IconColumn::make(RoleModel::ATTRIBUTE_DEFAULT)
->label(__('filament.fields.role.default.name'))
->sortable()
->toggleable()
->boolean(),

ColorColumn::make(RoleModel::ATTRIBUTE_COLOR)
->label(__('filament.fields.role.color.name'))
->sortable()
->toggleable(),
->label(__('filament.fields.role.color.name')),

TextColumn::make(RoleModel::ATTRIBUTE_PRIORITY)
->label(__('filament.fields.role.priority.name'))
->sortable()
->toggleable()
->placeholder('-'),
->label(__('filament.fields.role.priority.name')),
]);
}

Expand Down Expand Up @@ -225,8 +215,7 @@ public static function infolist(Infolist $infolist): Infolist
->label(__('filament.fields.role.color.name')),

TextEntry::make(RoleModel::ATTRIBUTE_PRIORITY)
->label(__('filament.fields.role.priority.name'))
->placeholder('-'),
->label(__('filament.fields.role.priority.name')),
])
->columns(3),

Expand Down
10 changes: 3 additions & 7 deletions app/Filament/Resources/Auth/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ public static function table(Table $table): Table
return parent::table($table)
->columns([
TextColumn::make(UserModel::ATTRIBUTE_ID)
->label(__('filament.fields.base.id'))
->sortable(),
->label(__('filament.fields.base.id')),

ImageColumn::make('avatar')
->label(__('filament.fields.user.avatar'))
Expand All @@ -164,15 +163,12 @@ public static function table(Table $table): Table

TextColumn::make(UserModel::ATTRIBUTE_NAME)
->label(__('filament.fields.user.name'))
->sortable()
->searchable()
->copyableWithMessage()
->toggleable(),
->copyableWithMessage(),

TextColumn::make(UserModel::ATTRIBUTE_EMAIL)
->label(__('filament.fields.user.email'))
->icon('heroicon-m-envelope')
->toggleable(),
->icon('heroicon-m-envelope'),
]);
}

Expand Down
Loading

0 comments on commit 310e300

Please sign in to comment.