mirror of
https://github.com/pelican-dev/panel.git
synced 2025-09-08 09:58:37 +02:00
replace custom suffixCopy
with filaments copyable
This commit is contained in:
parent
b1a670f8f5
commit
62df59008e
@ -97,14 +97,14 @@ class CreateDatabaseHost extends CreateRecord
|
|||||||
->default(fn (Get $get) => "CREATE USER '{$get('username')}'@'{$get('panel_ip')}' IDENTIFIED BY '{$get('password')}';")
|
->default(fn (Get $get) => "CREATE USER '{$get('username')}'@'{$get('panel_ip')}' IDENTIFIED BY '{$get('password')}';")
|
||||||
->disabled()
|
->disabled()
|
||||||
->dehydrated(false)
|
->dehydrated(false)
|
||||||
->suffixCopy()
|
->copyable()
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
TextInput::make('assign_permissions')
|
TextInput::make('assign_permissions')
|
||||||
->label(trans('admin/databasehost.setup.command_assign_permissions'))
|
->label(trans('admin/databasehost.setup.command_assign_permissions'))
|
||||||
->default(fn (Get $get) => "GRANT ALL PRIVILEGES ON *.* TO '{$get('username')}'@'{$get('panel_ip')}' WITH GRANT OPTION;")
|
->default(fn (Get $get) => "GRANT ALL PRIVILEGES ON *.* TO '{$get('username')}'@'{$get('panel_ip')}' WITH GRANT OPTION;")
|
||||||
->disabled()
|
->disabled()
|
||||||
->dehydrated(false)
|
->dehydrated(false)
|
||||||
->suffixCopy()
|
->copyable()
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
TextEntry::make('cli_exit')
|
TextEntry::make('cli_exit')
|
||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
|
@ -176,7 +176,7 @@ class EditServer extends EditRecord
|
|||||||
|
|
||||||
TextInput::make('uuid')
|
TextInput::make('uuid')
|
||||||
->label(trans('admin/server.uuid'))
|
->label(trans('admin/server.uuid'))
|
||||||
->suffixCopy()
|
->copyable()
|
||||||
->columnSpan([
|
->columnSpan([
|
||||||
'default' => 2,
|
'default' => 2,
|
||||||
'sm' => 1,
|
'sm' => 1,
|
||||||
@ -187,7 +187,7 @@ class EditServer extends EditRecord
|
|||||||
->dehydrated(false),
|
->dehydrated(false),
|
||||||
TextInput::make('uuid_short')
|
TextInput::make('uuid_short')
|
||||||
->label(trans('admin/server.short_uuid'))
|
->label(trans('admin/server.short_uuid'))
|
||||||
->suffixCopy()
|
->copyable()
|
||||||
->columnSpan([
|
->columnSpan([
|
||||||
'default' => 2,
|
'default' => 2,
|
||||||
'sm' => 1,
|
'sm' => 1,
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Filament\Components\Actions;
|
|
||||||
|
|
||||||
use Closure;
|
|
||||||
use Filament\Actions\Action;
|
|
||||||
use Illuminate\Support\HtmlString;
|
|
||||||
use Illuminate\Support\Js;
|
|
||||||
|
|
||||||
class CopyAction extends Action
|
|
||||||
{
|
|
||||||
protected Closure|string|null $copyable = null;
|
|
||||||
|
|
||||||
public static function getDefaultName(): ?string
|
|
||||||
{
|
|
||||||
return 'copy';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$this->icon('tabler-clipboard-copy');
|
|
||||||
|
|
||||||
$this->successNotificationTitle(trans('filament::components/copyable.messages.copied'));
|
|
||||||
|
|
||||||
$this->extraAttributes(fn () => [
|
|
||||||
'x-on:click' => new HtmlString('window.navigator.clipboard.writeText('.$this->getCopyable().'); $tooltip('.Js::from($this->getSuccessNotificationTitle()).');'),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function copyable(Closure|string|null $copyable): self
|
|
||||||
{
|
|
||||||
$this->copyable = $copyable;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCopyable(): ?string
|
|
||||||
{
|
|
||||||
return Js::from($this->evaluate($this->copyable));
|
|
||||||
}
|
|
||||||
}
|
|
@ -168,7 +168,7 @@ class Settings extends ServerFormPage
|
|||||||
->label(trans('server/setting.node_info.sftp.connection'))
|
->label(trans('server/setting.node_info.sftp.connection'))
|
||||||
->columnSpan(1)
|
->columnSpan(1)
|
||||||
->disabled()
|
->disabled()
|
||||||
->suffixCopy()
|
->copyable()
|
||||||
->hintAction(
|
->hintAction(
|
||||||
Action::make('connect_sftp')
|
Action::make('connect_sftp')
|
||||||
->label(trans('server/setting.node_info.sftp.action'))
|
->label(trans('server/setting.node_info.sftp.action'))
|
||||||
@ -188,7 +188,7 @@ class Settings extends ServerFormPage
|
|||||||
TextInput::make('username')
|
TextInput::make('username')
|
||||||
->label(trans('server/setting.node_info.sftp.username'))
|
->label(trans('server/setting.node_info.sftp.username'))
|
||||||
->columnSpan(1)
|
->columnSpan(1)
|
||||||
->suffixCopy()
|
->copyable()
|
||||||
->disabled()
|
->disabled()
|
||||||
->formatStateUsing(fn (Server $server) => auth()->user()->username . '.' . $server->uuid_short),
|
->formatStateUsing(fn (Server $server) => auth()->user()->username . '.' . $server->uuid_short),
|
||||||
TextEntry::make('password')
|
TextEntry::make('password')
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Filament\Server\Resources\Databases;
|
namespace App\Filament\Server\Resources\Databases;
|
||||||
|
|
||||||
use App\Filament\Components\Actions\CopyAction;
|
|
||||||
use App\Filament\Components\Actions\RotateDatabasePasswordAction;
|
use App\Filament\Components\Actions\RotateDatabasePasswordAction;
|
||||||
use App\Filament\Server\Resources\Databases\Pages\ListDatabases;
|
use App\Filament\Server\Resources\Databases\Pages\ListDatabases;
|
||||||
use App\Filament\Components\Tables\Columns\DateTimeColumn;
|
use App\Filament\Components\Tables\Columns\DateTimeColumn;
|
||||||
@ -77,13 +76,13 @@ class DatabaseResource extends Resource
|
|||||||
TextInput::make('host')
|
TextInput::make('host')
|
||||||
->label(trans('server/database.host'))
|
->label(trans('server/database.host'))
|
||||||
->formatStateUsing(fn (Database $database) => $database->address())
|
->formatStateUsing(fn (Database $database) => $database->address())
|
||||||
->suffixCopy(),
|
->copyable(),
|
||||||
TextInput::make('database')
|
TextInput::make('database')
|
||||||
->label(trans('server/database.database'))
|
->label(trans('server/database.database'))
|
||||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null),
|
->copyable(),
|
||||||
TextInput::make('username')
|
TextInput::make('username')
|
||||||
->label(trans('server/database.username'))
|
->label(trans('server/database.username'))
|
||||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null),
|
->copyable(),
|
||||||
TextInput::make('password')
|
TextInput::make('password')
|
||||||
->label(trans('server/database.password'))
|
->label(trans('server/database.password'))
|
||||||
->password()->revealable()
|
->password()->revealable()
|
||||||
@ -92,7 +91,7 @@ class DatabaseResource extends Resource
|
|||||||
RotateDatabasePasswordAction::make()
|
RotateDatabasePasswordAction::make()
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_DATABASE_UPDATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_DATABASE_UPDATE, $server))
|
||||||
)
|
)
|
||||||
->suffixCopy()
|
->copyable()
|
||||||
->formatStateUsing(fn (Database $database) => $database->password),
|
->formatStateUsing(fn (Database $database) => $database->password),
|
||||||
TextInput::make('remote')
|
TextInput::make('remote')
|
||||||
->label(trans('server/database.remote')),
|
->label(trans('server/database.remote')),
|
||||||
@ -103,7 +102,7 @@ class DatabaseResource extends Resource
|
|||||||
->label(trans('server/database.jdbc'))
|
->label(trans('server/database.jdbc'))
|
||||||
->password()->revealable()
|
->password()->revealable()
|
||||||
->hidden(!auth()->user()->can(Permission::ACTION_DATABASE_VIEW_PASSWORD, $server))
|
->hidden(!auth()->user()->can(Permission::ACTION_DATABASE_VIEW_PASSWORD, $server))
|
||||||
->suffixCopy()
|
->copyable()
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
->formatStateUsing(fn (Database $database) => $database->jdbc),
|
->formatStateUsing(fn (Database $database) => $database->jdbc),
|
||||||
]);
|
]);
|
||||||
|
@ -28,7 +28,6 @@ use Dedoc\Scramble\Scramble;
|
|||||||
use Dedoc\Scramble\Support\Generator\OpenApi;
|
use Dedoc\Scramble\Support\Generator\OpenApi;
|
||||||
use Dedoc\Scramble\Support\Generator\SecurityScheme;
|
use Dedoc\Scramble\Support\Generator\SecurityScheme;
|
||||||
use Filament\Forms\Components\Field;
|
use Filament\Forms\Components\Field;
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Support\Colors\Color;
|
use Filament\Support\Colors\Color;
|
||||||
use Filament\Support\Facades\FilamentColor;
|
use Filament\Support\Facades\FilamentColor;
|
||||||
use Filament\Support\Facades\FilamentView;
|
use Filament\Support\Facades\FilamentView;
|
||||||
@ -151,11 +150,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
$component->dispatch('alertBannerSent');
|
$component->dispatch('alertBannerSent');
|
||||||
});
|
});
|
||||||
|
|
||||||
Field::macro('suffixCopy', function () {
|
|
||||||
/** @var TextInput $this */
|
|
||||||
return $this->suffixAction(fn (?string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null); // @phpstan-ignore varTag.nativeType
|
|
||||||
});
|
|
||||||
|
|
||||||
Field::macro('hintCopy', function () {
|
Field::macro('hintCopy', function () {
|
||||||
/** @var Field $this */
|
/** @var Field $this */
|
||||||
return $this->hintAction(fn (?string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null); // @phpstan-ignore varTag.nativeType
|
return $this->hintAction(fn (?string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null); // @phpstan-ignore varTag.nativeType
|
||||||
|
@ -14,7 +14,6 @@ parameters:
|
|||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
- identifier: argument.templateType
|
- identifier: argument.templateType
|
||||||
- identifier: missingType.generics
|
- identifier: missingType.generics
|
||||||
- '#Call to an undefined method Filament\\Forms\\Components\\TextInput::suffixCopy\(\)#'
|
|
||||||
- '#Call to an undefined method Filament\\Forms\\Components\\TextInput::hintCopy\(\)#'
|
- '#Call to an undefined method Filament\\Forms\\Components\\TextInput::hintCopy\(\)#'
|
||||||
- '#Call to an undefined method Filament\\Forms\\Components\\Textarea::hintCopy\(\)#'
|
- '#Call to an undefined method Filament\\Forms\\Components\\Textarea::hintCopy\(\)#'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user