localized description, built per-request for the view. */ private function channelDescriptions(): array { return [ 'stable' => __('system.channel_stable'), 'beta' => __('system.channel_beta'), ]; } public function mount(DeploymentService $deployment): void { // Active = what the stack currently serves (snapshot); the form edits the PENDING // (configured) domain. They differ when a saved change awaits a restart. $this->domain = (string) ($deployment->domain() ?? ''); $this->domainInput = (string) ($deployment->configuredDomain() ?? ''); $this->restartPending = $deployment->restartPending(); $channel = Setting::get('release_channel', config('clusev.channel')) ?? 'stable'; // Clamp to a valid user channel — a stale/legacy value (e.g. 'dev') falls back to stable. $this->channel = in_array($channel, self::CHANNELS, true) ? $channel : 'stable'; } /** @return array> */ private function domainRules(): array { // Empty clears the override (revert to install-time APP_DOMAIN / bare IP). return ['domainInput' => ['nullable', 'string', 'max:253', 'regex:'.DeploymentService::DOMAIN_REGEX]]; } /** Validate, then confirm the domain change via the shared modal (audited there). */ public function confirmDomain(DeploymentService $deployment): void { $this->validate($this->domainRules(), [ 'domainInput.regex' => __('system.domain_invalid'), 'domainInput.max' => __('system.domain_invalid'), ]); $new = strtolower(trim($this->domainInput)); if ($new === (string) ($deployment->configuredDomain() ?? '')) { return; // no change vs the already-configured (pending) domain } $this->dispatch('openModal', component: 'modals.confirm-action', arguments: [ 'heading' => __('system.change_domain_heading'), 'body' => $new !== '' ? __('system.change_domain_body', ['domain' => $new]) : __('system.clear_domain_body'), 'confirmLabel' => __('system.change_domain_confirm'), 'danger' => true, 'icon' => 'globe', 'auditAction' => 'system.settings_updated', 'auditTarget' => 'panel_domain='.($new !== '' ? $new : '(cleared)'), 'event' => 'domainChanged', 'params' => ['domain' => $new], 'notify' => '', // defer: we surface the restart notice instead of a toast ], ); } #[On('domainChanged')] public function applyDomain(string $domain, DeploymentService $deployment): void { $domain = strtolower(trim($domain)); // Defensive re-validation (the value round-trips through the modal event). if ($domain !== '' && ! preg_match(DeploymentService::DOMAIN_REGEX, $domain)) { return; } $pending = $deployment->setDomain($domain); // The active (served) domain stays frozen until restart; only the pending changes. $this->domainInput = (string) ($pending ?? ''); $this->restartPending = $deployment->restartPending(); $this->dispatch('notify', message: __('system.domain_saved_notify')); } /** Release channel changes are audited (confirmation via the shared modal). */ public function confirmChannel(string $channel): void { if (! in_array($channel, self::CHANNELS, true) || $channel === $this->channel) { return; } $this->dispatch('openModal', component: 'modals.confirm-action', arguments: [ 'heading' => __('system.change_channel_heading'), 'body' => __('system.change_channel_body', ['channel' => $channel]), 'confirmLabel' => __('system.change_channel_confirm'), 'danger' => false, 'icon' => 'git-branch', 'auditAction' => 'system.settings_updated', 'auditTarget' => 'release_channel='.$channel, 'event' => 'channelChanged', 'params' => ['channel' => $channel], 'notify' => __('system.change_channel_notify', ['channel' => $channel]), ], ); } #[On('channelChanged')] public function applyChannel(string $channel): void { if (! in_array($channel, self::CHANNELS, true)) { return; } Setting::put('release_channel', $channel); $this->channel = $channel; } public function render(DeploymentService $deployment) { return view('livewire.system.index', [ 'hasTls' => $this->domain !== '', 'panelUrl' => $deployment->panelUrl(), 'isOverridden' => $deployment->domainIsOverridden(), 'channels' => $this->channelDescriptions(), ])->title(__('system.title')); } }