This commit is contained in:
Andras Bacsai 2023-05-15 14:54:03 +02:00
parent c47b0ddcc1
commit bdd4a24567
8 changed files with 38 additions and 37 deletions

View File

@ -9,7 +9,7 @@
class Create extends Component
{
public string $name;
public string|null $description;
public string|null $description = null;
public string $value;
public string $currentRoute;
@ -29,9 +29,6 @@ public function createPrivateKey()
'private_key' => $this->value,
'team_id' => session('currentTeam')->id
]);
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
if ($this->currentRoute !== 'server/new') {
redirect()->route('private-key.show', $new_private_key->uuid);
}
redirect()->route('server.new');
}
}

View File

@ -29,7 +29,6 @@ class ByIp extends Component
public function mount()
{
$this->name = generateRandomName();
$this->private_keys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
}
public function setPrivateKey(string $private_key_id)
{

View File

@ -33,7 +33,7 @@ function generalErrorHandler(\Throwable $e, $that = null, $isJson = false)
}
} catch (\Throwable $error) {
if ($that) {
$that->emit('error', $error);
$that->emit('error', $error->getMessage());
} elseif ($isJson) {
return response()->json([
'code' => $error->getCode(),

View File

@ -13,7 +13,9 @@
<template x-for="(item,index) in filteredItems" :key="item.name">
<div x-on:click="await set(item.next ?? 'server',item.name)"
:class="focusedIndex === index && 'magic-item-focused'" class="magic-item">
<span class="px-2 mr-1 text-xs text-white bg-green-600 rounded" x-show="item.type === 'Add'"
<span class="px-2 mr-1 text-xs text-white bg-green-600 rounded" x-show="item.type === 'App'"
x-text="item.type"></span>
<span class="px-2 mr-1 text-xs text-white bg-indigo-600 rounded" x-show="item.type === 'Add'"
x-text="item.type"></span>
<span class="px-2 mr-1 text-xs text-white bg-purple-600 rounded" x-show="item.type === 'Jump'"
x-text="item.type"></span>
@ -222,6 +224,21 @@ class="py-2 pl-4 cursor-pointer hover:bg-neutral-700">
focusedIndex: "",
items: [{
name: 'Public Repository',
type: 'App',
tags: 'application,public,repository,github,gitlab,bitbucket,git',
},
{
name: 'Private Repository (with GitHub App)',
type: 'App',
tags: 'application,private,repository,github,gitlab,bitbucket,git',
},
{
name: 'Private Repository (with Deploy Key)',
type: 'App',
tags: 'application,private,repository,github,gitlab,bitbucket,git',
},
{
name: 'Server',
type: 'Add',
tags: 'new,server',
@ -245,21 +262,7 @@ class="py-2 pl-4 cursor-pointer hover:bg-neutral-700">
tags: 'new,source,github,gitlab,bitbucket',
next: 'newSource'
},
{
name: 'Public Repository',
type: 'Add',
tags: 'application,public,repository,github,gitlab,bitbucket,git',
},
{
name: 'Private Repository (with GitHub App)',
type: 'Add',
tags: 'application,private,repository,github,gitlab,bitbucket,git',
},
{
name: 'Private Repository (with Deploy Key)',
type: 'Add',
tags: 'application,private,repository,github,gitlab,bitbucket,git',
},
{
name: 'Database',
type: 'Add',
@ -491,7 +494,7 @@ class="py-2 pl-4 cursor-pointer hover:bg-neutral-700">
return await this.newEnvironment()
}
this.selectedEnvironment = id
console.log(this.selectedAction)
if (this.selectedAction === 0) {
window.location =
`/project/${this.selectedProject}/${this.selectedEnvironment}/new?type=public&destination=${this.selectedDestination}`

View File

@ -38,7 +38,6 @@
<div class="flex gap-2">
<x-inputs.button isBold wire:click.prevent='validateServer'>Validate Server</x-inputs.button>
<x-inputs.button isBold wire:click.prevent='installDocker'>Install Docker</x-inputs.button>
</div>
</form>

View File

@ -13,20 +13,15 @@
<x-inputs.input type="number" id="port" label="Port" />
<x-inputs.input id="private_key_id" label="Private Key Id" readonly hidden />
@if ($private_keys->count() > 0)
<h1>Select a private key</h1>
<div class="flex">
@foreach ($private_keys as $key)
<div class="box" :class="{ 'bg-coollabs': {{ $private_key_id === $key->id }} }"
<div class="w-32 box" :class="{ 'bg-coollabs': {{ $private_key_id == $key->id }} }"
wire:click.defer.prevent="setPrivateKey('{{ $key->id }}')">
{{ $key->name }}
</div>
@endforeach
@endif
</form>
@if ($private_keys->count() > 0)
<h2>Or add a new private key</h2>
@else
<h2>Create private key</h2>
@endif
<livewire:private-key.create />
</div>
</form>
</div>

View File

@ -1,3 +1,9 @@
<x-layout>
<livewire:server.new.by-ip />
@if ($private_keys->count() === 0)
<h2>Create private key</h2>
<div>You need to create a private key before you can create a server.</div>
<livewire:private-key.create />
@else
<livewire:server.new.by-ip :private_keys="$private_keys" />
@endif
</x-layout>

View File

@ -170,7 +170,9 @@
})->name('source.github.show');
});
Route::middleware(['auth'])->group(function () {
Route::get('/server/new', fn () => view('server.new'))->name('server.new');
Route::get('/server/new', fn () => view('server.new', [
'private_keys' => PrivateKey::where('team_id', session('currentTeam')->id)->get(),
]))->name('server.new');
Route::get('/server/{server_uuid}', function () {
$server = session('currentTeam')->load(['servers'])->servers->firstWhere('uuid', request()->server_uuid);
if (!$server) {