Skip to content

Commit

Permalink
fix: slash in env names
Browse files Browse the repository at this point in the history
ui: placement of env switcher
  • Loading branch information
andrasbacsai committed Jun 23, 2024
1 parent a3255f3 commit 76ba365
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
14 changes: 14 additions & 0 deletions app/Console/Commands/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Enums\ApplicationDeploymentStatus;
use App\Jobs\CleanupHelperContainersJob;
use App\Models\ApplicationDeploymentQueue;
use App\Models\Environment;
use App\Models\InstanceSettings;
use App\Models\ScheduledDatabaseBackup;
use App\Models\Server;
Expand All @@ -24,6 +25,8 @@ public function handle()
get_public_ips();
$full_cleanup = $this->option('full-cleanup');
$cleanup_deployments = $this->option('cleanup-deployments');

$this->replace_slash_in_environment_name();
if ($cleanup_deployments) {
echo "Running cleanup deployments.\n";
$this->cleanup_in_progress_application_deployments();
Expand Down Expand Up @@ -150,4 +153,15 @@ private function cleanup_in_progress_application_deployments()
echo "Error: {$e->getMessage()}\n";
}
}

private function replace_slash_in_environment_name()
{
$environments = Environment::all();
foreach ($environments as $environment) {
if (str_contains($environment->name, '/')) {
$environment->name = str_replace('/', '-', $environment->name);
$environment->save();
}
}
}
}
2 changes: 1 addition & 1 deletion app/Models/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function services()
protected function name(): Attribute
{
return Attribute::make(
set: fn (string $value) => strtolower($value),
set: fn (string $value) => str($value)->lower()->trim()->replace('/', '-')->toString(),
);
}
}
6 changes: 0 additions & 6 deletions resources/views/livewire/project/environment-edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
<div class="flex items-center">
<a class="text-xs truncate lg:text-sm"
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>
<svg aria-hidden="true" class="w-4 h-4 mx-1 font-bold dark:text-warning" fill="currentColor"
viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd"
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
clip-rule="evenodd"></path>
</svg>
</div>
</li>
<li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<x-forms.select label="Switch Environment" wire:model.live="selectedEnvironment">
<option value="edit">Create/Edit Environments</option>
<option disabled>-----</option>
@foreach ($environments as $environment)
<option value="{{ $environment->name }}">{{ $environment->name }}
</option>
@endforeach
</x-forms.select>
<x-forms.select wire:model.live="selectedEnvironment">
<option value="edit">Create/Edit Environments</option>
<option disabled>-----</option>
@foreach ($environments as $environment)
<option value="{{ $environment->name }}">{{ $environment->name }}
</option>
@endforeach
</x-forms.select>
11 changes: 5 additions & 6 deletions resources/views/livewire/project/resource/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class="button">+
@endif
<livewire:project.delete-environment :disabled="!$environment->isEmpty()" :environment_id="$environment->id" />
</div>
<nav class="flex pt-2 pb-10">
<nav class="flex pt-2 pb-6">
<ol class="flex items-center">
<li class="inline-flex items-center">
<a class="text-xs truncate lg:text-sm"
Expand All @@ -37,16 +37,15 @@ class="button">+
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>
<livewire:project.resource.environment-select :environments="$project->environments" />
</div>
</li>
<li>

</li>
</ol>
</nav>
</div>
<div class="pb-4">
<livewire:project.resource.environment-select :environments="$project->environments" />
</div>
@if ($environment->isEmpty())
<a href="{{ route('project.resource.create', ['project_uuid' => request()->route('project_uuid'), 'environment_name' => request()->route('environment_name')]) }} "
class="items-center justify-center box">+ Add New Resource</a>
Expand Down

0 comments on commit 76ba365

Please sign in to comment.