mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-07 00:42:34 +00:00
- 2.x - sites finishing
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
use Filament\Support\Enums\MaxWidth;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget as Widget;
|
||||
@ -26,9 +26,9 @@ protected function getTableQuery(): Builder
|
||||
protected function getTableColumns(): array
|
||||
{
|
||||
return [
|
||||
ImageColumn::make('image_url')
|
||||
->label('Provider')
|
||||
->size(24),
|
||||
IconColumn::make('provider')
|
||||
->icon(fn (ServerProvider $record) => 'icon-'.$record->provider)
|
||||
->width(24),
|
||||
TextColumn::make('name')
|
||||
->default(fn ($record) => $record->profile)
|
||||
->label('Name')
|
||||
|
@ -8,7 +8,7 @@
|
||||
use Filament\Support\Enums\MaxWidth;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget as Widget;
|
||||
@ -28,9 +28,9 @@ protected function getTableQuery(): Builder
|
||||
protected function getTableColumns(): array
|
||||
{
|
||||
return [
|
||||
ImageColumn::make('image_url')
|
||||
->label('Provider')
|
||||
->size(24),
|
||||
IconColumn::make('provider')
|
||||
->icon(fn (SourceControl $record) => 'icon-'.$record->provider)
|
||||
->width(24),
|
||||
TextColumn::make('name')
|
||||
->default(fn (SourceControl $record) => $record->profile)
|
||||
->label('Name')
|
||||
|
@ -8,7 +8,7 @@
|
||||
use Filament\Support\Enums\MaxWidth;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget as Widget;
|
||||
@ -26,11 +26,12 @@ protected function getTableQuery(): Builder
|
||||
protected function getTableColumns(): array
|
||||
{
|
||||
return [
|
||||
ImageColumn::make('image_url')
|
||||
->label('Provider')
|
||||
->size(24),
|
||||
IconColumn::make('provider')
|
||||
->icon(fn (StorageProvider $record) => 'icon-'.$record->provider)
|
||||
->tooltip(fn (StorageProvider $record) => $record->provider)
|
||||
->width(24),
|
||||
TextColumn::make('name')
|
||||
->default(fn ($record) => $record->profile)
|
||||
->default(fn (StorageProvider $record) => $record->profile)
|
||||
->label('Name')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
@ -5,57 +5,91 @@
|
||||
use App\Actions\Tag\SyncTags;
|
||||
use App\Models\Server;
|
||||
use App\Models\Site;
|
||||
use Filament\Forms\Components\Actions\Action as FormAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Infolists\Components\Actions\Action;
|
||||
use Filament\Infolists\Components\Actions\Action as InfolistAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Support\Enums\MaxWidth;
|
||||
use Filament\Tables\Actions\Action as TableAction;
|
||||
|
||||
class EditTags
|
||||
{
|
||||
/**
|
||||
* @param Site|Server $taggable
|
||||
*/
|
||||
public static function infolist(mixed $taggable): Action
|
||||
public static function infolist(mixed $taggable): InfolistAction
|
||||
{
|
||||
return Action::make('edit_tags')
|
||||
return InfolistAction::make('edit_tags')
|
||||
->icon('heroicon-o-pencil-square')
|
||||
->tooltip('Edit Tags')
|
||||
->hiddenLabel()
|
||||
->modalSubmitActionLabel('Save')
|
||||
->modalHeading('Edit Tags')
|
||||
->modalWidth(MaxWidth::Medium)
|
||||
->form([
|
||||
Select::make('tags')
|
||||
->default($taggable->tags()->pluck('tags.id')->toArray())
|
||||
->options(function () {
|
||||
return auth()->user()->currentProject->tags()->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->nestedRecursiveRules(SyncTags::rules(auth()->user()->currentProject->id)['tags.*'])
|
||||
->suffixAction(
|
||||
\Filament\Forms\Components\Actions\Action::make('create_tag')
|
||||
->icon('heroicon-o-plus')
|
||||
->tooltip('Create a new tag')
|
||||
->modalSubmitActionLabel('Create')
|
||||
->modalHeading('Create Tag')
|
||||
->modalWidth(MaxWidth::Medium)
|
||||
->form(Create::form())
|
||||
->action(function (array $data) {
|
||||
Create::action($data);
|
||||
}),
|
||||
)
|
||||
->multiple(),
|
||||
])
|
||||
->action(function (array $data) use ($taggable) {
|
||||
app(SyncTags::class)->sync(auth()->user(), [
|
||||
'taggable_id' => $taggable->id,
|
||||
'taggable_type' => get_class($taggable),
|
||||
'tags' => $data['tags'],
|
||||
]);
|
||||
->form(static::form($taggable))
|
||||
->action(static::action($taggable));
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Tags updated!')
|
||||
->send();
|
||||
});
|
||||
/**
|
||||
* @param Site|Server $taggable
|
||||
*/
|
||||
public static function table(mixed $taggable): TableAction
|
||||
{
|
||||
return TableAction::make('edit_tags')
|
||||
->icon('heroicon-o-pencil-square')
|
||||
->tooltip('Edit Tags')
|
||||
->hiddenLabel()
|
||||
->modalSubmitActionLabel('Save')
|
||||
->modalHeading('Edit Tags')
|
||||
->modalWidth(MaxWidth::Medium)
|
||||
->form(static::form($taggable))
|
||||
->action(static::action($taggable));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Site|Server $taggable
|
||||
*/
|
||||
private static function form(mixed $taggable): array
|
||||
{
|
||||
return [
|
||||
Select::make('tags')
|
||||
->default($taggable->tags()->pluck('tags.id')->toArray())
|
||||
->options(function () {
|
||||
return auth()->user()->currentProject->tags()->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->nestedRecursiveRules(SyncTags::rules(auth()->user()->currentProject->id)['tags.*'])
|
||||
->suffixAction(
|
||||
FormAction::make('create_tag')
|
||||
->icon('heroicon-o-plus')
|
||||
->tooltip('Create a new tag')
|
||||
->modalSubmitActionLabel('Create')
|
||||
->modalHeading('Create Tag')
|
||||
->modalWidth(MaxWidth::Medium)
|
||||
->form(Create::form())
|
||||
->action(function (array $data) {
|
||||
Create::action($data);
|
||||
}),
|
||||
)
|
||||
->multiple(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Site|Server $taggable
|
||||
*/
|
||||
private static function action(mixed $taggable): \Closure
|
||||
{
|
||||
return function (array $data) use ($taggable) {
|
||||
app(SyncTags::class)->sync(auth()->user(), [
|
||||
'taggable_id' => $taggable->id,
|
||||
'taggable_type' => get_class($taggable),
|
||||
'tags' => $data['tags'],
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Tags updated!')
|
||||
->send();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user