From e4f807b297d96d7acd5751994d5aa233323cf822 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 7 Oct 2025 22:25:16 -0400 Subject: [PATCH] Change node config to use Code Entry (#1781) --- .../Admin/Resources/Nodes/Pages/EditNode.php | 11 +-- composer.json | 1 + composer.lock | 73 ++++++++++++++++++- 3 files changed, 79 insertions(+), 6 deletions(-) diff --git a/app/Filament/Admin/Resources/Nodes/Pages/EditNode.php b/app/Filament/Admin/Resources/Nodes/Pages/EditNode.php index 5eb2274df..175e4a1c2 100644 --- a/app/Filament/Admin/Resources/Nodes/Pages/EditNode.php +++ b/app/Filament/Admin/Resources/Nodes/Pages/EditNode.php @@ -18,6 +18,7 @@ use Filament\Forms\Components\TagsInput; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\ToggleButtons; +use Filament\Infolists\Components\CodeEntry; use Filament\Infolists\Components\TextEntry; use Filament\Notifications\Notification; use Filament\Resources\Pages\EditRecord; @@ -34,6 +35,7 @@ use Filament\Schemas\Schema; use Filament\Support\Enums\Alignment; use Illuminate\Http\Client\ConnectionException; use Illuminate\Support\HtmlString; +use Phiki\Grammar\Grammar; use Throwable; class EditNode extends EditRecord @@ -547,11 +549,12 @@ class EditNode extends EditRecord ->label(trans('admin/node.instructions')) ->columnSpanFull() ->state(new HtmlString(trans('admin/node.instructions_help'))), - Textarea::make('config') + CodeEntry::make('config') ->label('/etc/pelican/config.yml') + ->grammar(Grammar::Yaml) + ->state(fn (Node $node) => $node->getYamlConfiguration()) + ->copyable() ->disabled() - ->rows(19) - ->hintCopy() ->columnSpanFull(), Grid::make() ->columns() @@ -629,8 +632,6 @@ class EditNode extends EditRecord { $node = Node::findOrFail($data['id']); - $data['config'] = $node->getYamlConfiguration(); - if (!is_ip($node->fqdn)) { $ip = get_ip_from_hostname($node->fqdn); if ($ip) { diff --git a/composer.json b/composer.json index 4b203940d..f38583f74 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "lcobucci/jwt": "^5.5", "league/flysystem-aws-s3-v3": "^3.29", "league/flysystem-memory": "^3.29", + "phiki/phiki": "^2.0", "phpseclib/phpseclib": "~3.0.18", "predis/predis": "^2.3", "s1lentium/iptools": "~1.2.0", diff --git a/composer.lock b/composer.lock index 1d2931332..86077619e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fe426a19ad44b345d4cefbd0bd779be6", + "content-hash": "77cf4449e7671237bbb750d1f2b793fb", "packages": [ { "name": "anourvalar/eloquent-serialize", @@ -5196,6 +5196,77 @@ }, "time": "2020-10-15T08:29:30+00:00" }, + { + "name": "phiki/phiki", + "version": "v2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phikiphp/phiki.git", + "reference": "160785c50c01077780ab217e5808f00ab8f05a13" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phikiphp/phiki/zipball/160785c50c01077780ab217e5808f00ab8f05a13", + "reference": "160785c50c01077780ab217e5808f00ab8f05a13", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "league/commonmark": "^2.5.3", + "php": "^8.2", + "psr/simple-cache": "^3.0" + }, + "require-dev": { + "illuminate/support": "^11.45", + "laravel/pint": "^1.18.1", + "orchestra/testbench": "^9.15", + "pestphp/pest": "^3.5.1", + "phpstan/extension-installer": "^1.4.3", + "phpstan/phpstan": "^2.0", + "symfony/var-dumper": "^7.1.6" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Phiki\\Adapters\\Laravel\\PhikiServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Phiki\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ryan Chandler", + "email": "support@ryangjchandler.co.uk", + "homepage": "https://ryangjchandler.co.uk", + "role": "Developer" + } + ], + "description": "Syntax highlighting using TextMate grammars in PHP.", + "support": { + "issues": "https://github.com/phikiphp/phiki/issues", + "source": "https://github.com/phikiphp/phiki/tree/v2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sponsors/ryangjchandler", + "type": "github" + }, + { + "url": "https://buymeacoffee.com/ryangjchandler", + "type": "other" + } + ], + "time": "2025-09-20T17:21:02+00:00" + }, { "name": "phpdocumentor/reflection", "version": "6.3.0",