feat(core): prevent using servers with existing resources as build servers
This commit is contained in:
parent
372b064dba
commit
65b925252c
3 changed files with 22 additions and 1 deletions
|
|
@ -7,6 +7,7 @@
|
|||
use App\Events\ServerReachabilityChanged;
|
||||
use App\Models\Server;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Attributes\Validate;
|
||||
use Livewire\Component;
|
||||
|
||||
|
|
@ -50,6 +51,9 @@ class Show extends Component
|
|||
#[Validate(['required'])]
|
||||
public bool $isBuildServer;
|
||||
|
||||
#[Locked]
|
||||
public bool $isBuildServerLocked = false;
|
||||
|
||||
#[Validate(['required'])]
|
||||
public bool $isMetricsEnabled;
|
||||
|
||||
|
|
@ -95,6 +99,9 @@ public function mount(string $server_uuid)
|
|||
try {
|
||||
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
|
||||
$this->syncData();
|
||||
if (! $this->server->isEmpty()) {
|
||||
$this->isBuildServerLocked = true;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1341,4 +1341,11 @@ public function changeProxy(string $proxyType, bool $async = true)
|
|||
throw new \Exception('Invalid proxy type.');
|
||||
}
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return $this->applications()->count() == 0 &&
|
||||
$this->databases()->count() == 0 &&
|
||||
$this->services()->count() == 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,14 @@ class="px-4 py-2 text-gray-800 cursor-pointer hover:bg-gray-100 dark:hover:bg-co
|
|||
<div class="w-full">
|
||||
@if (!$server->isLocalhost())
|
||||
<div class="w-96">
|
||||
<x-forms.checkbox instantSave id="isBuildServer" label="Use it as a build server?" />
|
||||
@if ($isBuildServerLocked)
|
||||
<x-forms.checkbox disabled instantSave id="isBuildServer"
|
||||
helper="You can't use this server as a build server because it has defined resources."
|
||||
label="Use it as a build server?" />
|
||||
@else
|
||||
<x-forms.checkbox instantSave id="isBuildServer"
|
||||
label="Use it as a build server?" />
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if (!$server->isBuildServer() && !$server->settings->is_cloudflare_tunnel)
|
||||
|
|
|
|||
Loading…
Reference in a new issue