mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 12:14:45 +02:00
Fix CopyAction
& Add to Server Settings page (#950)
* Fix & Add to Server Settings page * Add `request()->isSecure()` CopyAction only works on SSL, no point in showing it when its not SSL --------- Co-authored-by: notCharles <charles@pelican.dev>
This commit is contained in:
parent
7cde90a39a
commit
e352754e6f
@ -34,7 +34,7 @@ final class DiscordProvider extends OAuthProvider
|
||||
TextInput::make('_noenv_redirect')
|
||||
->label('Redirect URL')
|
||||
->disabled()
|
||||
->hintAction(CopyAction::make())
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->formatStateUsing(fn () => config('app.url') . (Str::endsWith(config('app.url'), '/') ? '' : '/') . 'auth/oauth/callback/discord'),
|
||||
]),
|
||||
], parent::getSetupSteps());
|
||||
|
@ -26,7 +26,7 @@ final class GithubProvider extends OAuthProvider
|
||||
TextInput::make('_noenv_callback')
|
||||
->label('Authorization callback URL')
|
||||
->disabled()
|
||||
->hintAction(CopyAction::make())
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->default(fn () => config('app.url') . (Str::endsWith(config('app.url'), '/') ? '' : '/') . 'auth/oauth/callback/github'),
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString('<p>When you filled all fields click on <b>Register application</b>.</p>')),
|
||||
|
@ -258,7 +258,7 @@ class EditNode extends EditRecord
|
||||
'lg' => 2,
|
||||
])
|
||||
->label('Node UUID')
|
||||
->hintAction(CopyAction::make())
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->disabled(),
|
||||
TagsInput::make('tags')
|
||||
->columnSpan([
|
||||
@ -513,7 +513,7 @@ class EditNode extends EditRecord
|
||||
->label('/etc/pelican/config.yml')
|
||||
->disabled()
|
||||
->rows(19)
|
||||
->hintAction(CopyAction::make())
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->columnSpanFull(),
|
||||
Grid::make()
|
||||
->columns()
|
||||
@ -548,7 +548,7 @@ class EditNode extends EditRecord
|
||||
->label('To auto-configure your node run the following command:')
|
||||
->readOnly()
|
||||
->autosize()
|
||||
->hintAction(fn (string $state) => CopyAction::make()->copyable($state))
|
||||
->hintAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->formatStateUsing(fn (NodeAutoDeployService $service, Node $node, Set $set, Get $get) => $set('generatedToken', $service->handle(request(), $node, $get('docker')))),
|
||||
])
|
||||
->mountUsing(function (Forms\Form $form) {
|
||||
|
@ -136,7 +136,7 @@ class EditServer extends EditRecord
|
||||
->columnSpanFull(),
|
||||
|
||||
TextInput::make('uuid')
|
||||
->hintAction(CopyAction::make())
|
||||
->suffixAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->columnSpan([
|
||||
'default' => 2,
|
||||
'sm' => 1,
|
||||
@ -147,7 +147,7 @@ class EditServer extends EditRecord
|
||||
->dehydrated(false),
|
||||
TextInput::make('uuid_short')
|
||||
->label('Short UUID')
|
||||
->hintAction(CopyAction::make())
|
||||
->suffixAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->columnSpan([
|
||||
'default' => 2,
|
||||
'sm' => 1,
|
||||
@ -554,7 +554,7 @@ class EditServer extends EditRecord
|
||||
->autosize(),
|
||||
|
||||
Textarea::make('defaultStartup')
|
||||
->hintAction(CopyAction::make())
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->label('Default Startup Command')
|
||||
->disabled()
|
||||
->autosize()
|
||||
|
@ -18,6 +18,7 @@ use Filament\Forms\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Support\Enums\Alignment;
|
||||
use Illuminate\Support\Number;
|
||||
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
||||
|
||||
class Settings extends ServerFormPage
|
||||
{
|
||||
@ -161,7 +162,8 @@ class Settings extends ServerFormPage
|
||||
->label('Connection')
|
||||
->columnSpan(1)
|
||||
->disabled()
|
||||
->hintActions([
|
||||
->suffixAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->hintAction(
|
||||
Action::make('connect_sftp')
|
||||
->label('Connect to SFTP')
|
||||
->color('success')
|
||||
@ -171,7 +173,7 @@ class Settings extends ServerFormPage
|
||||
|
||||
return 'sftp://' . auth()->user()->username . '.' . $server->uuid_short . '@' . $fqdn . ':' . $server->node->daemon_sftp;
|
||||
}),
|
||||
])
|
||||
)
|
||||
->formatStateUsing(function (Server $server) {
|
||||
$fqdn = $server->node->daemon_sftp_alias ?? $server->node->fqdn;
|
||||
|
||||
@ -180,6 +182,7 @@ class Settings extends ServerFormPage
|
||||
TextInput::make('username')
|
||||
->label('Username')
|
||||
->columnSpan(1)
|
||||
->suffixAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->disabled()
|
||||
->formatStateUsing(fn (Server $server) => auth()->user()->username . '.' . $server->uuid_short),
|
||||
Placeholder::make('password')
|
||||
|
@ -35,9 +35,9 @@ class ListDatabases extends ListRecords
|
||||
->schema([
|
||||
TextInput::make('database')
|
||||
->columnSpanFull()
|
||||
->suffixAction(CopyAction::make()),
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null),
|
||||
TextInput::make('username')
|
||||
->suffixAction(CopyAction::make()),
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null),
|
||||
TextInput::make('password')
|
||||
->password()->revealable()
|
||||
->hidden(fn () => !auth()->user()->can(Permission::ACTION_DATABASE_VIEW_PASSWORD, $server))
|
||||
@ -45,7 +45,7 @@ class ListDatabases extends ListRecords
|
||||
RotateDatabasePasswordAction::make()
|
||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_DATABASE_UPDATE, $server))
|
||||
)
|
||||
->suffixAction(CopyAction::make())
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->formatStateUsing(fn (Database $database) => $database->password),
|
||||
TextInput::make('remote')
|
||||
->label('Connections From'),
|
||||
@ -55,7 +55,7 @@ class ListDatabases extends ListRecords
|
||||
->label('JDBC Connection String')
|
||||
->password()->revealable()
|
||||
->hidden(!auth()->user()->can(Permission::ACTION_DATABASE_VIEW_PASSWORD, $server))
|
||||
->suffixAction(CopyAction::make())
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->columnSpanFull()
|
||||
->formatStateUsing(fn (Database $database) => $database->jdbc),
|
||||
]);
|
||||
|
@ -45,14 +45,14 @@ class QueueStep
|
||||
TextInput::make('crontab')
|
||||
->label(new HtmlString('Run the following command to set up your crontab. Note that <code>www-data</code> is your webserver user. On some systems this username might be different!'))
|
||||
->disabled()
|
||||
->hintAction(CopyAction::make())
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->default('(crontab -l -u www-data 2>/dev/null; echo "* * * * * php ' . base_path() . '/artisan schedule:run >> /dev/null 2>&1") | crontab -u www-data -')
|
||||
->hidden(fn () => file_exists('/.dockerenv'))
|
||||
->columnSpanFull(),
|
||||
TextInput::make('queueService')
|
||||
->label(new HtmlString('To setup the queue worker service you simply have to run the following command.'))
|
||||
->disabled()
|
||||
->hintAction(CopyAction::make())
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->default('sudo php ' . base_path() . '/artisan p:environment:queue-service')
|
||||
->hidden(fn () => file_exists('/.dockerenv'))
|
||||
->columnSpanFull(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user