Skip to content

Commit b7ec1d7

Browse files
committed
fix: limits & server creation page
1 parent 7e37068 commit b7ec1d7

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

app/Http/Controllers/ServerController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public function new_server()
2020
}
2121
$servers = auth()->user()->currentTeam()->servers->count();
2222
$subscription = auth()->user()->currentTeam()?->subscription->type();
23-
$limits = config('constants.limits.server')[strtolower($subscription)];
24-
$limit_reached = true ?? $servers >= $limits[$subscription];
23+
$your_limit = config('constants.limits.server')[strtolower($subscription)];
24+
$limit_reached = $servers >= $your_limit;
2525

2626
return view('server.create', [
2727
'limit_reached' => $limit_reached,

app/Http/Livewire/Project/New/Select.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ public function set_destination(string $destination_uuid)
4646

4747
public function load_servers()
4848
{
49-
$this->servers = Server::ownedByCurrentTeam()->get();
49+
$this->servers = Server::isUsable()->get();
5050
}
5151
}

app/Models/Server.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ static public function isReachable()
3333

3434
static public function ownedByCurrentTeam(array $select = ['*'])
3535
{
36+
$teamId = auth()->user()->currentTeam()->id;
3637
$selectArray = collect($select)->concat(['id']);
37-
return Server::whereTeamId(auth()->user()->currentTeam()->id)->with('settings')->select($selectArray->all())->orderBy('name');
38+
return Server::whereTeamId($teamId)->with('settings')->select($selectArray->all())->orderBy('name');
3839
}
3940

4041
static public function isUsable()

resources/views/livewire/project/new/select.blade.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<li class="step">Select a Destination</li>
8181
</ul>
8282
<div class="flex flex-col justify-center gap-2 text-left xl:flex-row">
83-
@foreach ($servers as $server)
83+
@forelse($servers as $server)
8484
<div class="gap-2 py-4 cursor-pointer group hover:bg-coollabs bg-coolgray-200"
8585
wire:click="set_server({{ $server }})">
8686
<div class="flex flex-col mx-6">
@@ -91,7 +91,15 @@
9191
{{ $server->description }}</div>
9292
</div>
9393
</div>
94-
@endforeach
94+
@empty
95+
<div>
96+
<div>No validated & reachable servers found. <a class="text-white underline" href="/servers">
97+
Go to servers page
98+
</a></div>
99+
100+
<x-use-magic-bar link="/server/new" />
101+
</div>
102+
@endforelse
95103
</div>
96104
@endif
97105
@if ($current_step === 'destinations')

resources/views/server/all.blade.php

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

0 commit comments

Comments
 (0)