From 539f82eb08facf20c83d5bc514e08db370692158 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 5 May 2023 09:28:00 +0200 Subject: [PATCH] ui fixes --- .../Application/EnvironmentVariable/Add.php | 11 +++++- .../Application/EnvironmentVariable/All.php | 16 +++++++++ .../Application/EnvironmentVariable/Show.php | 2 +- .../Livewire/Project/Application/General.php | 2 +- .../views/components/inputs/input.blade.php | 36 ++++++++++--------- .../environment-variable/add.blade.php | 8 ++--- .../environment-variable/all.blade.php | 10 ++++++ .../environment-variable/show.blade.php | 4 +-- .../application/configuration.blade.php | 11 ++---- 9 files changed, 66 insertions(+), 34 deletions(-) create mode 100644 app/Http/Livewire/Project/Application/EnvironmentVariable/All.php create mode 100644 resources/views/livewire/project/application/environment-variable/all.blade.php diff --git a/app/Http/Livewire/Project/Application/EnvironmentVariable/Add.php b/app/Http/Livewire/Project/Application/EnvironmentVariable/Add.php index c6bd504f5..3e1635a65 100644 --- a/app/Http/Livewire/Project/Application/EnvironmentVariable/Add.php +++ b/app/Http/Livewire/Project/Application/EnvironmentVariable/Add.php @@ -15,13 +15,20 @@ class Add extends Component public string $value; public bool $is_build_time = false; + protected $rules = [ + 'key' => 'required|string', + 'value' => 'required|string', + 'is_build_time' => 'required|boolean', + ]; public function mount() { $this->parameters = Route::current()->parameters(); } public function submit() { + $this->validate(); try { + $application_id = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail()->id; EnvironmentVariable::create([ 'key' => $this->key, @@ -29,7 +36,9 @@ class Add extends Component 'is_build_time' => $this->is_build_time, 'application_id' => $application_id, ]); - $this->emit('reloadWindow'); + $this->emit('refreshEnvs'); + $this->key = ''; + $this->value = ''; } catch (mixed $e) { dd('asdf'); if ($e instanceof QueryException) { diff --git a/app/Http/Livewire/Project/Application/EnvironmentVariable/All.php b/app/Http/Livewire/Project/Application/EnvironmentVariable/All.php new file mode 100644 index 000000000..37c2bd7ec --- /dev/null +++ b/app/Http/Livewire/Project/Application/EnvironmentVariable/All.php @@ -0,0 +1,16 @@ + 'refreshEnvs']; + public function refreshEnvs() + { + $this->application->refresh(); + } +} diff --git a/app/Http/Livewire/Project/Application/EnvironmentVariable/Show.php b/app/Http/Livewire/Project/Application/EnvironmentVariable/Show.php index f32260ca0..8c855e8f4 100644 --- a/app/Http/Livewire/Project/Application/EnvironmentVariable/Show.php +++ b/app/Http/Livewire/Project/Application/EnvironmentVariable/Show.php @@ -30,6 +30,6 @@ class Show extends Component public function delete() { $this->env->delete(); - $this->emit('reloadWindow'); + $this->emit('refreshEnvs'); } } diff --git a/app/Http/Livewire/Project/Application/General.php b/app/Http/Livewire/Project/Application/General.php index ec55e5f99..9b40b4be3 100644 --- a/app/Http/Livewire/Project/Application/General.php +++ b/app/Http/Livewire/Project/Application/General.php @@ -45,7 +45,7 @@ class General extends Component ]; public function instantSave() { - // @TODO: find another way + // @TODO: find another way - if possible $this->application->settings->is_static = $this->is_static; $this->application->settings->is_git_submodules_allowed = $this->is_git_submodules_allowed; $this->application->settings->is_git_lfs_allowed = $this->is_git_lfs_allowed; diff --git a/resources/views/components/inputs/input.blade.php b/resources/views/components/inputs/input.blade.php index 975e59f8d..10c61ba50 100644 --- a/resources/views/components/inputs/input.blade.php +++ b/resources/views/components/inputs/input.blade.php @@ -1,36 +1,40 @@ @props([ 'id' => null, 'type' => 'text', - 'required' => false, + 'required' => $attributes->has('required'), 'label' => null, 'instantSave' => false, 'disabled' => false, 'hidden' => false, + 'noLabel' => false, + 'noDirty' => false, ]) - $type === 'checkbox', 'flex flex-col' => $type !== 'checkbox', ])> - + @if (!$noLabel) + + @endif @if ($type === 'textarea') - + @else - @endif - @error($id)
{{ $message }}
@enderror diff --git a/resources/views/livewire/project/application/environment-variable/add.blade.php b/resources/views/livewire/project/application/environment-variable/add.blade.php index d7dbeadff..4ad26a2f0 100644 --- a/resources/views/livewire/project/application/environment-variable/add.blade.php +++ b/resources/views/livewire/project/application/environment-variable/add.blade.php @@ -1,10 +1,10 @@ -
- - + + +
- +
diff --git a/resources/views/livewire/project/application/environment-variable/all.blade.php b/resources/views/livewire/project/application/environment-variable/all.blade.php new file mode 100644 index 000000000..b68741be8 --- /dev/null +++ b/resources/views/livewire/project/application/environment-variable/all.blade.php @@ -0,0 +1,10 @@ +
+

Environment Variables

+ @forelse ($application->environment_variables as $env) + + @empty +

There are no environment variables for this application.

+ @endforelse +

Add new environment variable

+ +
diff --git a/resources/views/livewire/project/application/environment-variable/show.blade.php b/resources/views/livewire/project/application/environment-variable/show.blade.php index e0d54759e..cadff1f8e 100644 --- a/resources/views/livewire/project/application/environment-variable/show.blade.php +++ b/resources/views/livewire/project/application/environment-variable/show.blade.php @@ -1,11 +1,11 @@
- +
- +
diff --git a/resources/views/project/application/configuration.blade.php b/resources/views/project/application/configuration.blade.php index 91775f5dc..795268f1c 100644 --- a/resources/views/project/application/configuration.blade.php +++ b/resources/views/project/application/configuration.blade.php @@ -23,15 +23,8 @@

General Configurations

-
-

Environment Variables

- @forelse ($application->environment_variables as $env) - - @empty -

There are no environment variables for this application.

- @endforelse -

Add new environment variable

- +
+

Source