feat: shared environments

This commit is contained in:
Andras Bacsai
2024-01-23 17:13:23 +01:00
parent abcc004953
commit fb478c79b3
42 changed files with 495 additions and 78 deletions

View File

@@ -168,3 +168,6 @@ tr td:first-child {
input.input-sm {
@apply pr-10;
}
option{
@apply text-white;
}

View File

@@ -13,7 +13,7 @@
</a>
</li>
<li title="Help us!">
<a class="hover:bg-transparent"href="https://coolify.io/sponsorships" target="_blank">
<a class="hover:bg-transparent" href="https://coolify.io/sponsorships" target="_blank">
<svg class="icon hover:text-pink-500" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
stroke-width="2">

View File

@@ -0,0 +1,48 @@
<div x-data="{
slideOverOpen: false
}" class="relative w-auto h-auto">
{{ $slot }}
<template x-teleport="body">
<div x-show="slideOverOpen" @keydown.window.escape="slideOverOpen=false" class="relative z-[99]">
<div x-show="slideOverOpen" @click="slideOverOpen = false" class="fixed inset-0 "></div>
<div class="fixed inset-0 overflow-hidden">
<div class="absolute inset-0 overflow-hidden">
<div class="fixed inset-y-0 right-0 flex max-w-full pl-10">
<div x-show="slideOverOpen" @click.away="slideOverOpen = false"
x-transition:enter="transform transition ease-in-out duration-100 sm:duration-300"
x-transition:enter-start="translate-x-full" x-transition:enter-end="translate-x-0"
x-transition:leave="transform transition ease-in-out duration-100 sm:duration-300"
x-transition:leave-start="translate-x-0" x-transition:leave-end="translate-x-full"
class="w-screen max-w-md">
<div
class="flex flex-col h-full py-5 overflow-y-scroll border-l shadow-lg bg-primary border-neutral-800">
<div class="px-4 sm:px-5">
<div class="flex items-start justify-between pb-1">
<h2 class="text-base leading-6" id="slide-over-title">
{{ $title }}</h2>
<div class="flex items-center h-auto ml-3">
<button @click="slideOverOpen=false"
class="absolute top-0 right-0 z-30 flex items-center justify-center px-3 py-2 mt-3 mr-5 space-x-1 text-xs font-normal border-none rounded">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none"
viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="w-3 h-3">
<path stroke-linecap="round" stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
</div>
</div>
<div class="relative flex-1 px-4 mt-5 sm:px-5">
<div class="absolute inset-0 px-4 sm:px-5">
{{ $content }}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
</div>

View File

@@ -14,20 +14,24 @@
</ol>
</nav>
<nav class="navbar-main">
<a class="{{ request()->routeIs('team.index') ? 'text-white' : '' }}" href="{{ route('team.index') }}">
<a class="{{ request()->routeIs('team.index') ? 'text-white' : '' }}" href="{{ route('team.index') }}">
<button>General</button>
</a>
<a class="{{ request()->routeIs('team.member.index') ? 'text-white' : '' }}" href="{{ route('team.member.index') }}">
<a class="{{ request()->routeIs('team.member.index') ? 'text-white' : '' }}" href="{{ route('team.member.index') }}">
<button>Members</button>
</a>
<a class="{{ request()->routeIs('team.storage.index') ? 'text-white' : '' }}"
<a class="{{ request()->routeIs('team.storage.index') ? 'text-white' : '' }}"
href="{{ route('team.storage.index') }}">
<button>S3 Storages</button>
</a>
<a class="{{ request()->routeIs('team.notification.index') ? 'text-white' : '' }}"
<a class="{{ request()->routeIs('team.notification.index') ? 'text-white' : '' }}"
href="{{ route('team.notification.index') }}">
<button>Notifications</button>
</a>
<a class="{{ request()->routeIs('team.shared-variables.index') ? 'text-white' : '' }}"
href="{{ route('team.shared-variables.index') }}">
<button>Shared Variables</button>
</a>
<div class="flex-1"></div>
<div class="-mt-9">
<livewire:switch-team />

View File

@@ -1,13 +1,28 @@
<div>
<form wire:submit='submit' class="flex flex-col gap-2 ">
<h1>Project: {{ data_get($project, 'name') }}</h1>
<div class="pb-10">Edit project details here.</div>
<form wire:submit='submit' class="flex flex-col gap-2 pb-10">
<div class="flex items-end gap-2">
<h1>Project: {{ data_get($project, 'name') }}</h1>
<h2>General</h2>
<x-forms.button type="submit">Save</x-forms.button>
</div>
<div class="pb-10">Edit project details here.</div>
<div class="flex gap-2">
<x-forms.input label="Name" id="project.name" />
<x-forms.input label="Description" id="project.description" />
</div>
</form>
<div class="flex gap-2">
<h2>Shared Variables</h2>
<x-forms.button class="btn" onclick="newVariable.showModal()">+ Add</x-forms.button>
<livewire:project.shared.environment-variable.add />
</div>
<div class="pb-4">You can use this anywhere.</div>
<div class="flex flex-col gap-2">
@forelse ($project->environment_variables->sort()->sortBy('real_value') as $env)
<livewire:project.shared.environment-variable.show wire:key="environment-{{ $env->id }}"
:env="$env" type="project" />
@empty
<div class="text-neutral-500">No environment variables found.</div>
@endforelse
</div>
</div>

View File

@@ -8,7 +8,7 @@
<ol class="flex items-center">
<li class="inline-flex items-center">
<a class="text-xs truncate lg:text-sm"
href="{{ route('project.show', ['project_uuid' => request()->route('project_uuid')]) }}">
href="{{ route('project.show', ['project_uuid' => data_get($parameters, 'project_uuid')]) }}">
{{ $project->name }}</a>
</li>
<li>
@@ -20,7 +20,7 @@
clip-rule="evenodd"></path>
</svg>
<a class="text-xs truncate lg:text-sm"
href="{{ route('project.resource.index', ['environment_name' => request()->route('environment_name'), 'project_uuid' => request()->route('project_uuid')]) }}">{{ request()->route('environment_name') }}</a>
href="{{ route('project.resource.index', ['environment_name' => data_get($parameters, 'environment_name'), 'project_uuid' => data_get($parameters, 'project_uuid')]) }}">{{ data_get($parameters, 'environment_name') }}</a>
</div>
</li>
<li>
@@ -41,4 +41,18 @@
<x-forms.input label="Description" id="environment.description" />
</div>
</form>
<div class="flex gap-2 pt-10">
<h2>Shared Variables</h2>
<x-forms.button class="btn" onclick="newVariable.showModal()">+ Add</x-forms.button>
<livewire:project.shared.environment-variable.add />
</div>
<div class="pb-4">You can use this anywhere.</div>
<div class="flex flex-col gap-2">
@forelse ($environment->environment_variables->sort()->sortBy('real_value') as $env)
<livewire:project.shared.environment-variable.show wire:key="environment-{{ $env->id }}"
:env="$env" type="environment" />
@empty
<div class="text-neutral-500">No environment variables found.</div>
@endforelse
</div>
</div>

View File

@@ -2,15 +2,33 @@
<div>
<div class="flex items-center gap-2">
<h2>Environment Variables</h2>
<x-forms.button class="btn" onclick="newVariable.showModal()">+ Add</x-forms.button>
<livewire:project.shared.environment-variable.add />
@if ($resource->type() !== 'service')
<x-slide-over>
<x-slot:title>Add Environment Variables</x-slot:title>
<x-slot:content>
<form class="flex flex-col gap-2 rounded" wire:submit='submit'>
<x-forms.input placeholder="NODE_ENV" id="key" label="Name" required />
<x-forms.input placeholder="production" id="value" label="Value" required />
<x-forms.button type="submit">
Save
</x-forms.button>
</form>
</x-slot:content>
<button @click="slideOverOpen=true"
class="font-normal text-white normal-case border-none rounded btn btn-primary btn-sm no-animation">+ Add</button>
</x-slide-over>
{{-- <x-forms.button class="btn" onclick="newVariable.showModal()">+ Add</x-forms.button> --}}
@endif
<x-forms.button
wire:click='switch'>{{ $view === 'normal' ? 'Developer view' : 'Normal view' }}</x-forms.button>
</div>
<div>Environment variables (secrets) for this resource.</div>
@if ($resource->type() === 'service')
<div>If you cannot find a variable here, or need a new one, define it in the Docker Compose file.</div>
@endif
</div>
@if ($view === 'normal')
@forelse ($resource->environment_variables as $env)
@forelse ($resource->environment_variables->sort()->sortBy('real_value') as $env)
<livewire:project.shared.environment-variable.show wire:key="environment-{{ $env->id }}"
:env="$env" :type="$resource->type()" />
@empty
@@ -21,7 +39,7 @@
<h3>Preview Deployments</h3>
<div>Environment (secrets) variables for Preview Deployments.</div>
</div>
@foreach ($resource->environment_variables_preview as $env)
@foreach ($resource->environment_variables_preview->sort()->sortBy('real_value') as $env)
<livewire:project.shared.environment-variable.show wire:key="environment-{{ $env->id }}"
:env="$env" :type="$resource->type()" />
@endforeach

View File

@@ -19,13 +19,19 @@
@if ($isDisabled)
<x-forms.input disabled id="env.key" />
<x-forms.input disabled type="password" id="env.value" />
@if ($type !== 'service')
@if ($env->is_shared)
<x-forms.input disabled type="password" id="env.real_value" />
@endif
@if ($type !== 'service' && !$isSharedVariable)
<x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
@endif
@else
<x-forms.input id="env.key" />
<x-forms.input type="password" id="env.value" />
@if ($type !== 'service')
@if ($env->is_shared)
<x-forms.input disabled type="password" id="env.real_value" />
@endif
@if ($type !== 'service' && !$isSharedVariable)
<x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
@endif
@endif

View File

@@ -1,5 +1,5 @@
<div>
<h1>Create a new Private Key</h1>
<h2>Private Key</h2>
<div class="subtitle ">Private Keys are used to connect to your servers without passwords.</div>
<x-forms.button class="mb-4" wire:click="generateNewKey">Generate new SSH key for me</x-forms.button>
<form class="flex flex-col gap-2" wire:submit='createPrivateKey'>

View File

@@ -2,7 +2,7 @@
@if ($private_keys->count() === 0)
<h1>Create Private Key</h1>
<div class="subtitle">You need to create a private key before you can create a server.</div>
<livewire:private-key.create from="server" />
<livewire:security.private-key.create from="server" />
@else
<livewire:server.new.by-ip :private_keys="$private_keys" :limit_reached="$limit_reached" />
@endif

View File

@@ -0,0 +1,17 @@
<div>
<x-team.navbar />
<div class="flex gap-2">
<h2>Shared Variables</h2>
<x-forms.button class="btn" onclick="newVariable.showModal()">+ Add</x-forms.button>
<livewire:project.shared.environment-variable.add />
</div>
<div class="pb-4">You can use this anywhere.</div>
<div class="flex flex-col gap-2">
@forelse ($team->environment_variables->sort()->sortBy('real_value') as $env)
<livewire:project.shared.environment-variable.show wire:key="environment-{{ $env->id }}"
:env="$env" type="team" />
@empty
<div class="text-neutral-500">No environment variables found.</div>
@endforelse
</div>
</div>

View File

@@ -22,3 +22,4 @@
</div>
</div>
</div>
</div>