fix(postgresql): persist selected public access state
This commit is contained in:
parent
69dbfe0079
commit
8ecf77eadb
3 changed files with 19 additions and 2 deletions
|
|
@ -209,11 +209,15 @@ public function instantSaveAdvanced()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function instantSave()
|
public function instantSave(?bool $isPublic = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->authorize('update', $this->database);
|
$this->authorize('update', $this->database);
|
||||||
|
|
||||||
|
if ($isPublic !== null) {
|
||||||
|
$this->isPublic = $isPublic;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->isPublic && ! $this->publicPort) {
|
if ($this->isPublic && ! $this->publicPort) {
|
||||||
$this->dispatch('error', 'Public port is required.');
|
$this->dispatch('error', 'Public port is required.');
|
||||||
$this->isPublic = false;
|
$this->isPublic = false;
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@
|
||||||
<x-table.loading target="instantSave" text="Updating public access..." />
|
<x-table.loading target="instantSave" text="Updating public access..." />
|
||||||
<div class="grid gap-4 lg:grid-cols-2">
|
<div class="grid gap-4 lg:grid-cols-2">
|
||||||
<div wire:key="public-access-{{ $publicPort ?: 'unset' }}">
|
<div wire:key="public-access-{{ $publicPort ?: 'unset' }}">
|
||||||
<x-forms.listbox id="isPublic" label="Access" live onChange="instantSave"
|
<x-forms.listbox id="isPublic" label="Access" live onChange="instantSave" :onChangeArgs="[]"
|
||||||
:disabled="! auth()->user()->can('update', $database)" :options="[
|
:disabled="! auth()->user()->can('update', $database)" :options="[
|
||||||
['value' => false, 'label' => 'Private'],
|
['value' => false, 'label' => 'Private'],
|
||||||
['value' => true, 'label' => blank($publicPort) ? 'Public through TCP proxy (set public port first)' : 'Public through TCP proxy', 'disabled' => blank($publicPort)],
|
['value' => true, 'label' => blank($publicPort) ? 'Public through TCP proxy (set public port first)' : 'Public through TCP proxy', 'disabled' => blank($publicPort)],
|
||||||
|
|
|
||||||
|
|
@ -26,3 +26,16 @@
|
||||||
->not->toContain('id="publicPort" live');
|
->not->toContain('id="publicPort" live');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('passes the selected PostgreSQL public access state to the save action', function () {
|
||||||
|
$generalSettings = file_get_contents(resource_path('views/livewire/project/database/postgresql/general.blade.php'));
|
||||||
|
|
||||||
|
expect($generalSettings)
|
||||||
|
->toContain('onChange="instantSave" :onChangeArgs="[]"');
|
||||||
|
|
||||||
|
$component = file_get_contents(app_path('Livewire/Project/Database/Postgresql/General.php'));
|
||||||
|
|
||||||
|
expect($component)
|
||||||
|
->toContain('public function instantSave(?bool $isPublic = null)')
|
||||||
|
->toContain('$this->isPublic = $isPublic;');
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue