fix: limits & server creation page

This commit is contained in:
Andras Bacsai 2023-08-21 10:18:11 +02:00
parent 7e37068fc0
commit b7ec1d7d65
5 changed files with 20 additions and 7 deletions

View File

@ -20,8 +20,8 @@ public function new_server()
}
$servers = auth()->user()->currentTeam()->servers->count();
$subscription = auth()->user()->currentTeam()?->subscription->type();
$limits = config('constants.limits.server')[strtolower($subscription)];
$limit_reached = true ?? $servers >= $limits[$subscription];
$your_limit = config('constants.limits.server')[strtolower($subscription)];
$limit_reached = $servers >= $your_limit;
return view('server.create', [
'limit_reached' => $limit_reached,

View File

@ -46,6 +46,6 @@ public function set_destination(string $destination_uuid)
public function load_servers()
{
$this->servers = Server::ownedByCurrentTeam()->get();
$this->servers = Server::isUsable()->get();
}
}

View File

@ -33,8 +33,9 @@ static public function isReachable()
static public function ownedByCurrentTeam(array $select = ['*'])
{
$teamId = auth()->user()->currentTeam()->id;
$selectArray = collect($select)->concat(['id']);
return Server::whereTeamId(auth()->user()->currentTeam()->id)->with('settings')->select($selectArray->all())->orderBy('name');
return Server::whereTeamId($teamId)->with('settings')->select($selectArray->all())->orderBy('name');
}
static public function isUsable()

View File

@ -80,7 +80,7 @@
<li class="step">Select a Destination</li>
</ul>
<div class="flex flex-col justify-center gap-2 text-left xl:flex-row">
@foreach ($servers as $server)
@forelse($servers as $server)
<div class="gap-2 py-4 cursor-pointer group hover:bg-coollabs bg-coolgray-200"
wire:click="set_server({{ $server }})">
<div class="flex flex-col mx-6">
@ -91,7 +91,15 @@
{{ $server->description }}</div>
</div>
</div>
@endforeach
@empty
<div>
<div>No validated & reachable servers found. <a class="text-white underline" href="/servers">
Go to servers page
</a></div>
<x-use-magic-bar link="/server/new" />
</div>
@endforelse
</div>
@endif
@if ($current_step === 'destinations')

View File

@ -1,5 +1,9 @@
<x-layout>
<h1>Servers</span></h1>
<div class="flex items-start gap-2">
<h1>Servers</h1>
<a class="text-white hover:no-underline" href="/server/new"> <x-forms.button class="btn">+ Add
</x-forms.button></a>
</div>
<div class="subtitle ">All Servers</div>
<div class="grid gap-2 lg:grid-cols-2">
@forelse ($servers as $server)