mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 06:56:15 +00:00
- 2.x - scripts
This commit is contained in:
53
app/Web/Pages/Settings/SSHKeys/Widgets/SshKeysList.php
Normal file
53
app/Web/Pages/Settings/SSHKeys/Widgets/SshKeysList.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Web\Pages\Settings\SSHKeys\Widgets;
|
||||
|
||||
use App\Models\SshKey;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class SshKeysList extends TableWidget
|
||||
{
|
||||
protected $listeners = ['$refresh'];
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return SshKey::query()->where('user_id', auth()->id());
|
||||
}
|
||||
|
||||
protected static ?string $heading = '';
|
||||
|
||||
protected function getTableColumns(): array
|
||||
{
|
||||
return [
|
||||
TextColumn::make('name')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('public_key')
|
||||
->tooltip('Copy')
|
||||
->limit(20)
|
||||
->copyable(),
|
||||
TextColumn::make('created_at')
|
||||
->sortable(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getTable(): Table
|
||||
{
|
||||
return $this->table
|
||||
->actions([
|
||||
DeleteAction::make('delete')
|
||||
->requiresConfirmation()
|
||||
->authorize(fn (SshKey $record) => auth()->user()->can('delete', $record))
|
||||
->action(function (SshKey $record) {
|
||||
run_action($this, function () use ($record) {
|
||||
$record->delete();
|
||||
$this->dispatch('$refresh');
|
||||
});
|
||||
}),
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user