Skip to content

Commit

Permalink
fix short link url
Browse files Browse the repository at this point in the history
  • Loading branch information
atmonshi committed Dec 3, 2023
1 parent 818008a commit 3eb3112
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 66 deletions.
28 changes: 18 additions & 10 deletions src/Filament/Resources/FaqResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,26 @@ public static function table(Table $table): Table
->relationship('tags', 'name')
->label(__('Tags')),
])
->actions([
ActionGroup::make([
EditAction::make('edit')->label(__('Edit')),
->actions(static::getActions());
}

//@phpstan-ignore-next-line
\LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (): string => route('faq')),
public static function getActions(): array
{
$action = [
ActionGroup::make([
EditAction::make('edit')->label(__('Edit')),
DeleteAction::make('delete')
->label(__('Delete')),
]),
];

DeleteAction::make('delete')
->label(__('Delete')),
]),
]);
if (class_exists(\LaraZeus\Helen\HelenServiceProvider::class)) {
//@phpstan-ignore-next-line
$action[] = \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (): string => route('faq'));
}

return $action;
}

public static function getPages(): array
Expand Down
44 changes: 27 additions & 17 deletions src/Filament/Resources/LibraryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,7 @@ public static function table(Table $table): Table
->type('library'),
])
->actions([
ActionGroup::make([
EditAction::make('edit')
->label(__('Edit')),
Action::make('Open')
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (Library $record): string => route('library.item', ['slug' => $record->slug]))
->openUrlInNewTab(),

//@phpstan-ignore-next-line
\LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (Library $record): string => route('library.item', ['slug' => $record->slug])),

DeleteAction::make('delete')
->label(__('Delete')),
]),
ActionGroup::make(static::getActions()),
])
->filters([
SelectFilter::make('type')
Expand Down Expand Up @@ -201,4 +185,30 @@ public static function getNavigationLabel(): string
{
return __('Libraries');
}

public static function getActions(): array
{
$action = [
ActionGroup::make([
EditAction::make('edit')
->label(__('Edit')),
Action::make('Open')
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (Library $record): string => route('library.item', ['slug' => $record->slug]))
->openUrlInNewTab(),
DeleteAction::make('delete')
->label(__('Delete')),
]),
];

if (class_exists(\LaraZeus\Helen\HelenServiceProvider::class)) {
//@phpstan-ignore-next-line
$action[] = \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (Library $record): string => route('library.item', ['slug' => $record->slug]));
}

return $action;
}
}
48 changes: 28 additions & 20 deletions src/Filament/Resources/PageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,26 +172,7 @@ public static function table(Table $table): Table
->tooltip(fn (Post $record): string => $record->published_at->format('Y/m/d | H:i A')),
])
->defaultSort('id', 'desc')
->actions([
ActionGroup::make([
EditAction::make('edit')->label(__('Edit')),

Action::make('Open')
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (Post $record): string => route('page', ['slug' => $record]))
->openUrlInNewTab(),

//@phpstan-ignore-next-line
\LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (Post $record): string => route('page', ['slug' => $record])),

DeleteAction::make('delete'),
ForceDeleteAction::make(),
RestoreAction::make(),
]),
])
->actions(static::getActions())
->bulkActions([
DeleteBulkAction::make(),
ForceDeleteBulkAction::make(),
Expand Down Expand Up @@ -232,4 +213,31 @@ public static function getNavigationLabel(): string
{
return __('Pages');
}

public static function getActions(): array
{
$action = [
ActionGroup::make([
EditAction::make('edit')->label(__('Edit')),

Action::make('Open')
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (Post $record): string => route('page', ['slug' => $record]))
->openUrlInNewTab(),
DeleteAction::make('delete'),
ForceDeleteAction::make(),
RestoreAction::make(),
]),
];

if (class_exists(\LaraZeus\Helen\HelenServiceProvider::class)) {
//@phpstan-ignore-next-line
$action[] = \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (Post $record): string => route('page', ['slug' => $record]));
}

return $action;
}
}
46 changes: 27 additions & 19 deletions src/Filament/Resources/PostResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,7 @@ public static function table(Table $table): Table
->type('category'),
])
->defaultSort('id', 'desc')
->actions([
ActionGroup::make([
EditAction::make('edit')->label(__('Edit')),
Action::make('Open')
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (Post $record): string => route('post', ['slug' => $record]))
->openUrlInNewTab(),

//@phpstan-ignore-next-line
\LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (Post $record): string => route('post', ['slug' => $record])),

DeleteAction::make('delete'),
ForceDeleteAction::make(),
RestoreAction::make(),
]),
])
->actions(static::getActions())
->bulkActions([
DeleteBulkAction::make(),
ForceDeleteBulkAction::make(),
Expand Down Expand Up @@ -272,4 +254,30 @@ public static function getNavigationLabel(): string
{
return __('Posts');
}

public static function getActions(): array
{
$action = [
ActionGroup::make([
EditAction::make('edit')->label(__('Edit')),
Action::make('Open')
->color('warning')
->icon('heroicon-o-arrow-top-right-on-square')
->label(__('Open'))
->url(fn (Post $record): string => route('post', ['slug' => $record]))
->openUrlInNewTab(),
DeleteAction::make('delete'),
ForceDeleteAction::make(),
RestoreAction::make(),
]),
];

if (class_exists(\LaraZeus\Helen\HelenServiceProvider::class)) {
//@phpstan-ignore-next-line
$action[] = \LaraZeus\Helen\Actions\ShortUrlAction::make('get-link')
->distUrl(fn (Post $record): string => route('post', ['slug' => $record]));
}

return $action;
}
}

0 comments on commit 3eb3112

Please sign in to comment.