private keys view

This commit is contained in:
Andras Bacsai 2023-06-15 09:58:17 +02:00
parent 1f3a7758c4
commit fe51f8fbf7
6 changed files with 115 additions and 42 deletions

View File

@ -307,54 +307,60 @@ const magicActions = [{
}, },
{ {
id: 10, id: 10,
name: 'Goto: Projects', name: 'Goto: Private Keys',
icon: 'goto', icon: 'goto',
sequence: ['main', 'redirect'] sequence: ['main', 'redirect']
}, },
{ {
id: 11, id: 11,
name: 'Goto: Sources', name: 'Goto: Projects',
icon: 'goto', icon: 'goto',
sequence: ['main', 'redirect'] sequence: ['main', 'redirect']
}, },
{ {
id: 12, id: 12,
name: 'Goto: Destinations', name: 'Goto: Sources',
icon: 'goto', icon: 'goto',
sequence: ['main', 'redirect'] sequence: ['main', 'redirect']
}, },
{ {
id: 13, id: 13,
name: 'Goto: Settings', name: 'Goto: Destinations',
icon: 'goto', icon: 'goto',
sequence: ['main', 'redirect'] sequence: ['main', 'redirect']
}, },
{ {
id: 14, id: 14,
name: 'Goto: Command Center', name: 'Goto: Settings',
icon: 'goto', icon: 'goto',
sequence: ['main', 'redirect'] sequence: ['main', 'redirect']
}, },
{ {
id: 15, id: 15,
name: 'Goto: Notifications', name: 'Goto: Command Center',
icon: 'goto', icon: 'goto',
sequence: ['main', 'redirect'] sequence: ['main', 'redirect']
}, },
{ {
id: 16, id: 16,
name: 'Goto: Profile', name: 'Goto: Notifications',
icon: 'goto', icon: 'goto',
sequence: ['main', 'redirect'] sequence: ['main', 'redirect']
}, },
{ {
id: 17, id: 17,
name: 'Goto: Teams', name: 'Goto: Profile',
icon: 'goto', icon: 'goto',
sequence: ['main', 'redirect'] sequence: ['main', 'redirect']
}, },
{ {
id: 18, id: 18,
name: 'Goto: Teams',
icon: 'goto',
sequence: ['main', 'redirect']
},
{
id: 19,
name: 'Goto: Switch Teams', name: 'Goto: Switch Teams',
icon: 'goto', icon: 'goto',
sequence: ['main', 'redirect'] sequence: ['main', 'redirect']
@ -545,32 +551,35 @@ async function redirect() {
targetUrl.pathname = `/servers` targetUrl.pathname = `/servers`
break; break;
case 10: case 10:
targetUrl.pathname = `/projects` targetUrl.pathname = `/private-keys`
break; break;
case 11: case 11:
targetUrl.pathname = `/sources` targetUrl.pathname = `/projects`
break; break;
case 12: case 12:
targetUrl.pathname = `/destinations` targetUrl.pathname = `/sources`
break; break;
case 13: case 13:
targetUrl.pathname = `/settings` targetUrl.pathname = `/destinations`
break; break;
case 14: case 14:
targetUrl.pathname = `/command-center` targetUrl.pathname = `/settings`
break; break;
case 15: case 15:
targetUrl.pathname = `/profile/team/notifications` targetUrl.pathname = `/command-center`
break; break;
case 16: case 16:
targetUrl.pathname = `/profile` targetUrl.pathname = `/profile/team/notifications`
break; break;
case 17: case 17:
targetUrl.pathname = `/profile/team` targetUrl.pathname = `/profile`
break; break;
case 18: case 18:
targetUrl.pathname = `/profile/team` targetUrl.pathname = `/profile/team`
break; break;
case 19:
targetUrl.pathname = `/profile/team`
break;
} }
window.location.href = targetUrl; window.location.href = targetUrl;
} }

View File

@ -7,6 +7,7 @@
'disabled' => null, 'disabled' => null,
'helper' => $attributes->has('helper'), 'helper' => $attributes->has('helper'),
'noDirty' => $attributes->has('noDirty'), 'noDirty' => $attributes->has('noDirty'),
'cannotPeak' => $attributes->has('cannotPeak'),
]) ])
<div {{ $attributes->merge(['class' => 'w-full form-control']) }}> <div {{ $attributes->merge(['class' => 'w-full form-control']) }}>
@if ($label) @if ($label)
@ -37,31 +38,52 @@
@endif @endif
@if ($type === 'password') @if ($type === 'password')
<div class="join" x-data> <div class="join" x-data>
<input class="w-full border-r-0 rounded-l join-item" type={{ $type }} <input class="w-full join-item" type={{ $type }} @class([
@if ($id) id={{ $id }} name={{ $id }} wire:model.defer={{ $id }} @endisset 'border-r-0 rounded-l' => $cannotPeak,
]) @if ($id) id={{ $id }} name={{ $id }}
wire:model.defer={{ $id }} @endisset
@if ($disabled !== null) disabled @endif @if ($disabled !== null) disabled @endif
@if ($required !== null) required @endif @if ($readonly !== null) readonly @endif @if ($required !== null) required @endif @if ($readonly !== null) readonly @endif
@if (!$noDirty && $id) wire:dirty.class="input-warning" @endif {{ $attributes }} /> @if (!$noDirty && $id) wire:dirty.class="input-warning"
<span x-on:click="changePasswordFieldType('{{ $id }}')" x-cloak @endif {{ $attributes }} />
class="border-l-0 border-none rounded-r hover:bg-coolgray-200 no-animation h-7 btn join-item btn-xs bg-coolgray-200 "><svg @if (!$cannotPeak)
xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 icon" viewBox="0 0 24 24" stroke-width="1.5" @if (!$disabled)
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <span x-on:click="changePasswordFieldType('{{ $id }}')" x-cloak
<path stroke="none" d="M0 0h24v24H0z" fill="none" /> class="border-l-0 border-none rounded-r hover:bg-coolgray-200 no-animation h-7 btn join-item btn-xs bg-coolgray-200 "><svg
<path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" /> xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 icon" viewBox="0 0 24 24"
<path d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" /> stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
</svg></span> stroke-linejoin="round">
</div> <path stroke="none" d="M0 0h24v24H0z" fill="none" />
@else <path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
<input type={{ $type }} <path
@if ($id) name={{ $id }} wire:model.defer={{ $id }} @endisset d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" />
</svg></span>
@else
<span x-on:click="changePasswordFieldType('{{ $id }}')" x-cloak
class="text-opacity-25 border-l-0 rounded-r bg-coolgray-200/50 hover:bg-coolgray-200/50 no-animation h-7 btn join-item btn-xs"><svg
xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 icon" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
<path
d="M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6" />
</svg>
</span>
@endif
@endif
</div>
@else
<input type={{ $type }}
@if ($id) name={{ $id }} wire:model.defer={{ $id }} @endisset
@if ($disabled !== null) disabled @endif @if ($disabled !== null) disabled @endif
@if ($required !== null) required @endif @if ($readonly !== null) readonly @endif @if ($required !== null) required @endif @if ($readonly !== null) readonly @endif
@if (!$noDirty && $id) wire:dirty.class="input-warning" @endif {{ $attributes }} /> @if (!$noDirty && $id) wire:dirty.class="input-warning" @endif {{ $attributes }} />
@endif @endif
@error($id) @error($id)
<label class="label"> <label class="label">
<span class="text-red-500 label-text-alt">{{ $message }}</span> <span class="text-red-500 label-text-alt">{{ $message }}</span>
</label> </label>
@enderror @enderror
</div> </div>

View File

@ -1,9 +1,28 @@
<div x-data="{ deletePrivateKey: false }"> <div x-data="{ deletePrivateKey: false, showPrivateKey: false }">
<x-naked-modal show="deletePrivateKey" message='Are you sure you would like to delete this private key?' /> <x-naked-modal show="deletePrivateKey" message='Are you sure you would like to delete this private key?' />
<form class="flex flex-col gap-2" wire:submit.prevent='changePrivateKey'> <form class="flex flex-col gap-2" wire:submit.prevent='changePrivateKey'>
<x-forms.input id="private_key.name" label="Name" required /> <x-forms.input id="private_key.name" label="Name" required />
<x-forms.input id="private_key.description" label="Description" /> <x-forms.input id="private_key.description" label="Description" />
<x-forms.textarea rows="10" id="private_key.private_key" label="Private Key" required /> <div>
<div class="flex items-end gap-2 py-2 ">
<div class="pl-1 text-sm">Private Key <span class='text-helper'>*</span></div>
<div class="text-xs text-white underline cursor-pointer" x-cloak x-show="!showPrivateKey"
x-on:click="showPrivateKey = true">
Show
</div>
<div class="text-xs text-white underline cursor-pointer" x-cloak x-show="showPrivateKey"
x-on:click="showPrivateKey = false">
Hide
</div>
</div>
<div x-cloak x-show="!showPrivateKey">
<x-forms.input cannotPeak type="password" rows="10" id="private_key.private_key" required
disabled />
</div>
<div x-cloak x-show="showPrivateKey">
<x-forms.textarea rows="10" id="private_key.private_key" required />
</div>
</div>
<div> <div>
<x-forms.button type="submit"> <x-forms.button type="submit">
Save Save

View File

@ -0,0 +1,19 @@
<x-layout>
<h1>Private Keys</h1>
<div class="pt-2 pb-10 text-sm">All Private Keys</div>
<div class="grid gap-2 lg:grid-cols-2">
@forelse ($privateKeys as $key)
<a class="text-center hover:no-underline box group"
href="{{ route('private-key.show', ['private_key_uuid' => data_get($key, 'uuid')]) }}">
<div class="group-hover:text-white">
<div>{{ $key->name }}</div>
</div>
</a>
@empty
<div>
<div>No private keys found.</div>
<x-use-magic-bar />
</div>
@endforelse
</div>
</x-layout>

View File

@ -1,4 +1,5 @@
<x-layout> <x-layout>
<h1>Private Key</h1> <h1>Private Key</h1>
<div class="pt-2 pb-10 text-sm">Sssh, it is private</div>
<livewire:private-key.change :private_key_uuid="$private_key->uuid" /> <livewire:private-key.change :private_key_uuid="$private_key->uuid" />
</x-layout> </x-layout>

View File

@ -92,6 +92,9 @@ Route::middleware(['auth'])->group(function () {
}); });
Route::middleware(['auth'])->group(function () { Route::middleware(['auth'])->group(function () {
Route::get('/private-keys', fn () => view('private-key.all', [
'privateKeys' => PrivateKey::ownedByCurrentTeam()->get()
]))->name('private-key.all');
Route::get('/private-key/new', fn () => view('private-key.new'))->name('private-key.new'); Route::get('/private-key/new', fn () => view('private-key.new'))->name('private-key.new');
Route::get('/private-key/{private_key_uuid}', fn () => view('private-key.show', [ Route::get('/private-key/{private_key_uuid}', fn () => view('private-key.show', [
'private_key' => PrivateKey::ownedByCurrentTeam()->whereUuid(request()->private_key_uuid)->firstOrFail() 'private_key' => PrivateKey::ownedByCurrentTeam()->whereUuid(request()->private_key_uuid)->firstOrFail()