feat(core): prevent using servers with existing resources as build servers
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Actions\Server\StopSentinel;
|
|||||||
use App\Events\ServerReachabilityChanged;
|
use App\Events\ServerReachabilityChanged;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Livewire\Attributes\Computed;
|
use Livewire\Attributes\Computed;
|
||||||
|
use Livewire\Attributes\Locked;
|
||||||
use Livewire\Attributes\Validate;
|
use Livewire\Attributes\Validate;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
@@ -50,6 +51,9 @@ class Show extends Component
|
|||||||
#[Validate(['required'])]
|
#[Validate(['required'])]
|
||||||
public bool $isBuildServer;
|
public bool $isBuildServer;
|
||||||
|
|
||||||
|
#[Locked]
|
||||||
|
public bool $isBuildServerLocked = false;
|
||||||
|
|
||||||
#[Validate(['required'])]
|
#[Validate(['required'])]
|
||||||
public bool $isMetricsEnabled;
|
public bool $isMetricsEnabled;
|
||||||
|
|
||||||
@@ -95,6 +99,9 @@ class Show extends Component
|
|||||||
try {
|
try {
|
||||||
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
|
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
|
||||||
$this->syncData();
|
$this->syncData();
|
||||||
|
if (! $this->server->isEmpty()) {
|
||||||
|
$this->isBuildServerLocked = true;
|
||||||
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
return handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1341,4 +1341,11 @@ $schema://$host {
|
|||||||
throw new \Exception('Invalid proxy type.');
|
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 @@
|
|||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
@if (!$server->isLocalhost())
|
@if (!$server->isLocalhost())
|
||||||
<div class="w-96">
|
<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>
|
</div>
|
||||||
|
|
||||||
@if (!$server->isBuildServer() && !$server->settings->is_cloudflare_tunnel)
|
@if (!$server->isBuildServer() && !$server->settings->is_cloudflare_tunnel)
|
||||||
|
|||||||
Reference in New Issue
Block a user