From 8a4c2bf20869ccae261e77550ba231a58559cfef Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 26 Apr 2024 14:59:03 +0200 Subject: [PATCH] shared variables are more visible now on the ui --- app/Livewire/Project/Edit.php | 22 --------- app/Livewire/Project/EnvironmentEdit.php | 23 --------- .../SharedVariables/Environment/Index.php | 19 ++++++++ .../SharedVariables/Environment/Show.php | 47 +++++++++++++++++++ app/Livewire/SharedVariables/Index.php | 13 +++++ .../SharedVariables/Project/Index.php | 19 ++++++++ app/Livewire/SharedVariables/Project/Show.php | 47 +++++++++++++++++++ .../Team/Index.php} | 6 +-- resources/views/components/navbar.blade.php | 13 +++++ .../views/components/team/navbar.blade.php | 6 +-- .../views/livewire/project/edit.blade.php | 20 -------- .../project/environment-edit.blade.php | 17 ------- .../environment/index.blade.php | 28 +++++++++++ .../environment/show.blade.php | 20 ++++++++ .../livewire/shared-variables/index.blade.php | 28 +++++++++++ .../shared-variables/project/index.blade.php | 22 +++++++++ .../shared-variables/project/show.blade.php | 22 +++++++++ .../team/index.blade.php} | 5 +- routes/web.php | 27 +++++++++-- 19 files changed, 307 insertions(+), 97 deletions(-) create mode 100644 app/Livewire/SharedVariables/Environment/Index.php create mode 100644 app/Livewire/SharedVariables/Environment/Show.php create mode 100644 app/Livewire/SharedVariables/Index.php create mode 100644 app/Livewire/SharedVariables/Project/Index.php create mode 100644 app/Livewire/SharedVariables/Project/Show.php rename app/Livewire/{TeamSharedVariablesIndex.php => SharedVariables/Team/Index.php} (88%) create mode 100644 resources/views/livewire/shared-variables/environment/index.blade.php create mode 100644 resources/views/livewire/shared-variables/environment/show.blade.php create mode 100644 resources/views/livewire/shared-variables/index.blade.php create mode 100644 resources/views/livewire/shared-variables/project/index.blade.php create mode 100644 resources/views/livewire/shared-variables/project/show.blade.php rename resources/views/livewire/{team-shared-variables-index.blade.php => shared-variables/team/index.blade.php} (85%) diff --git a/app/Livewire/Project/Edit.php b/app/Livewire/Project/Edit.php index d222917a6..8a35eff7f 100644 --- a/app/Livewire/Project/Edit.php +++ b/app/Livewire/Project/Edit.php @@ -12,28 +12,6 @@ class Edit extends Component 'project.name' => 'required|min:3|max:255', 'project.description' => 'nullable|string|max:255', ]; - protected $listeners = ['refreshEnvs' => '$refresh', 'saveKey' => 'saveKey']; - - public function saveKey($data) - { - try { - $found = $this->project->environment_variables()->where('key', $data['key'])->first(); - if ($found) { - throw new \Exception('Variable already exists.'); - } - $this->project->environment_variables()->create([ - 'key' => $data['key'], - 'value' => $data['value'], - 'is_multiline' => $data['is_multiline'], - 'is_literal' => $data['is_literal'], - 'type' => 'project', - 'team_id' => currentTeam()->id, - ]); - $this->project->refresh(); - } catch (\Throwable $e) { - return handleError($e, $this); - } - } public function mount() { $projectUuid = request()->route('project_uuid'); diff --git a/app/Livewire/Project/EnvironmentEdit.php b/app/Livewire/Project/EnvironmentEdit.php index 173d946f3..cd952a961 100644 --- a/app/Livewire/Project/EnvironmentEdit.php +++ b/app/Livewire/Project/EnvironmentEdit.php @@ -16,29 +16,6 @@ class EnvironmentEdit extends Component 'environment.name' => 'required|min:3|max:255', 'environment.description' => 'nullable|min:3|max:255', ]; - protected $listeners = ['refreshEnvs' => '$refresh', 'saveKey' => 'saveKey']; - - public function saveKey($data) - { - try { - $found = $this->environment->environment_variables()->where('key', $data['key'])->first(); - if ($found) { - throw new \Exception('Variable already exists.'); - } - $this->environment->environment_variables()->create([ - 'key' => $data['key'], - 'value' => $data['value'], - 'is_multiline' => $data['is_multiline'], - 'is_literal' => $data['is_literal'], - 'type' => 'environment', - 'team_id' => currentTeam()->id, - ]); - $this->environment->refresh(); - } catch (\Throwable $e) { - return handleError($e, $this); - } - } - public function mount() { $this->parameters = get_route_parameters(); diff --git a/app/Livewire/SharedVariables/Environment/Index.php b/app/Livewire/SharedVariables/Environment/Index.php new file mode 100644 index 000000000..34f33ef5d --- /dev/null +++ b/app/Livewire/SharedVariables/Environment/Index.php @@ -0,0 +1,19 @@ +projects = Project::ownedByCurrentTeam()->get(); + } + public function render() + { + return view('livewire.shared-variables.environment.index'); + } +} diff --git a/app/Livewire/SharedVariables/Environment/Show.php b/app/Livewire/SharedVariables/Environment/Show.php new file mode 100644 index 000000000..29fd91153 --- /dev/null +++ b/app/Livewire/SharedVariables/Environment/Show.php @@ -0,0 +1,47 @@ + '$refresh', 'saveKey' => 'saveKey']; + + public function saveKey($data) + { + try { + $found = $this->environment->environment_variables()->where('key', $data['key'])->first(); + if ($found) { + throw new \Exception('Variable already exists.'); + } + $this->environment->environment_variables()->create([ + 'key' => $data['key'], + 'value' => $data['value'], + 'is_multiline' => $data['is_multiline'], + 'is_literal' => $data['is_literal'], + 'type' => 'environment', + 'team_id' => currentTeam()->id, + ]); + $this->environment->refresh(); + } catch (\Throwable $e) { + return handleError($e, $this); + } + } + public function mount() + { + $this->parameters = get_route_parameters(); + $this->project = Project::ownedByCurrentTeam()->where('uuid', request()->route('project_uuid'))->first(); + $this->environment = $this->project->environments()->where('name', request()->route('environment_name'))->first(); + } + public function render() + { + return view('livewire.shared-variables.environment.show'); + } +} diff --git a/app/Livewire/SharedVariables/Index.php b/app/Livewire/SharedVariables/Index.php new file mode 100644 index 000000000..61c31e9f8 --- /dev/null +++ b/app/Livewire/SharedVariables/Index.php @@ -0,0 +1,13 @@ +projects = Project::ownedByCurrentTeam()->get(); + } + public function render() + { + return view('livewire.shared-variables.project.index'); + } +} diff --git a/app/Livewire/SharedVariables/Project/Show.php b/app/Livewire/SharedVariables/Project/Show.php new file mode 100644 index 000000000..a172c52f0 --- /dev/null +++ b/app/Livewire/SharedVariables/Project/Show.php @@ -0,0 +1,47 @@ + '$refresh', 'saveKey' => 'saveKey']; + + public function saveKey($data) + { + try { + $found = $this->project->environment_variables()->where('key', $data['key'])->first(); + if ($found) { + throw new \Exception('Variable already exists.'); + } + $this->project->environment_variables()->create([ + 'key' => $data['key'], + 'value' => $data['value'], + 'is_multiline' => $data['is_multiline'], + 'is_literal' => $data['is_literal'], + 'type' => 'project', + 'team_id' => currentTeam()->id, + ]); + $this->project->refresh(); + } catch (\Throwable $e) { + return handleError($e, $this); + } + } + public function mount() + { + $projectUuid = request()->route('project_uuid'); + $teamId = currentTeam()->id; + $project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first(); + if (!$project) { + return redirect()->route('dashboard'); + } + $this->project = $project; + } + public function render() + { + return view('livewire.shared-variables.project.show'); + } +} diff --git a/app/Livewire/TeamSharedVariablesIndex.php b/app/Livewire/SharedVariables/Team/Index.php similarity index 88% rename from app/Livewire/TeamSharedVariablesIndex.php rename to app/Livewire/SharedVariables/Team/Index.php index eeee30ab9..ef5c7472c 100644 --- a/app/Livewire/TeamSharedVariablesIndex.php +++ b/app/Livewire/SharedVariables/Team/Index.php @@ -1,11 +1,11 @@ '$refresh', 'saveKey' => 'saveKey']; @@ -37,6 +37,6 @@ public function mount() } public function render() { - return view('livewire.team-shared-variables-index'); + return view('livewire.shared-variables.team.index'); } } diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 0eebffd1e..aab4b6a7a 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -170,6 +170,19 @@ class="{{ request()->is('storages*') ? 'menu-item-active menu-item' : 'menu-item S3 Storages +
  • + + + + + + + + Shared Variables + +
  • Team

    - +
    Team wide configurations.
    @@ -14,10 +14,6 @@ href="{{ route('team.member.index') }}">
    - - -
    diff --git a/resources/views/livewire/project/edit.blade.php b/resources/views/livewire/project/edit.blade.php index 9fd47a70a..816873aab 100644 --- a/resources/views/livewire/project/edit.blade.php +++ b/resources/views/livewire/project/edit.blade.php @@ -14,24 +14,4 @@ -
    -

    Shared Variables

    - - - -
    -
    -
    You can use these variables anywhere with
    -
    @{{ project.VARIABLENAME }}
    - -
    -
    - @forelse ($project->environment_variables->sort()->sortBy('key') as $env) - - @empty -
    No environment variables found.
    - @endforelse -
    diff --git a/resources/views/livewire/project/environment-edit.blade.php b/resources/views/livewire/project/environment-edit.blade.php index 23bb8748b..6439a128d 100644 --- a/resources/views/livewire/project/environment-edit.blade.php +++ b/resources/views/livewire/project/environment-edit.blade.php @@ -42,21 +42,4 @@ -
    -

    Shared Variables

    - - - -
    -
    You can use these variables anywhere with @{{environment.VARIABLENAME}} -
    -
    - @forelse ($environment->environment_variables->sort()->sortBy('key') as $env) - - @empty -
    No environment variables found.
    - @endforelse -
    diff --git a/resources/views/livewire/shared-variables/environment/index.blade.php b/resources/views/livewire/shared-variables/environment/index.blade.php new file mode 100644 index 000000000..bcb6afde6 --- /dev/null +++ b/resources/views/livewire/shared-variables/environment/index.blade.php @@ -0,0 +1,28 @@ +
    +
    +

    Environments

    +
    +
    List of your environments by projects.
    +
    + @forelse ($projects as $project) +

    {{ data_get($project, 'name') }}

    +
    {{ data_get($project, 'description') }}
    + @forelse ($project->environments as $environment) + +
    +
    {{ $environment->name }}
    +
    + {{ $environment->description }}
    +
    +
    + @empty +

    No environments found.

    + @endforelse + @empty +
    +
    No project found.
    +
    + @endforelse +
    +
    diff --git a/resources/views/livewire/shared-variables/environment/show.blade.php b/resources/views/livewire/shared-variables/environment/show.blade.php new file mode 100644 index 000000000..ed91cad02 --- /dev/null +++ b/resources/views/livewire/shared-variables/environment/show.blade.php @@ -0,0 +1,20 @@ +
    +
    +

    Shared Variables for {{ $project->name }}/{{ $environment->name }}

    + + + +
    +
    You can use these variables anywhere with @{{ environment.VARIABLENAME }} +
    +
    + @forelse ($environment->environment_variables->sort()->sortBy('key') as $env) + + @empty +
    No environment variables found.
    + @endforelse +
    +
    diff --git a/resources/views/livewire/shared-variables/index.blade.php b/resources/views/livewire/shared-variables/index.blade.php new file mode 100644 index 000000000..91975347f --- /dev/null +++ b/resources/views/livewire/shared-variables/index.blade.php @@ -0,0 +1,28 @@ +
    +
    +

    Shared Variables

    +
    +
    Set Team / Project / Environment wide variables.
    + + +
    diff --git a/resources/views/livewire/shared-variables/project/index.blade.php b/resources/views/livewire/shared-variables/project/index.blade.php new file mode 100644 index 000000000..e9f7c0838 --- /dev/null +++ b/resources/views/livewire/shared-variables/project/index.blade.php @@ -0,0 +1,22 @@ +
    +
    +

    Projects

    +
    +
    List of your projects.
    +
    + @forelse ($projects as $project) + +
    +
    {{ $project->name }}
    +
    + {{ $project->description }}
    +
    +
    + @empty +
    +
    No project found.
    +
    + @endforelse +
    +
    diff --git a/resources/views/livewire/shared-variables/project/show.blade.php b/resources/views/livewire/shared-variables/project/show.blade.php new file mode 100644 index 000000000..1f8a9ddc1 --- /dev/null +++ b/resources/views/livewire/shared-variables/project/show.blade.php @@ -0,0 +1,22 @@ +
    +
    +

    Shared Variables for {{data_get($project,'name')}}

    + + + +
    +
    +
    You can use these variables anywhere with
    +
    @{{ project.VARIABLENAME }}
    + +
    +
    + @forelse ($project->environment_variables->sort()->sortBy('key') as $env) + + @empty +
    No environment variables found.
    + @endforelse +
    +
    diff --git a/resources/views/livewire/team-shared-variables-index.blade.php b/resources/views/livewire/shared-variables/team/index.blade.php similarity index 85% rename from resources/views/livewire/team-shared-variables-index.blade.php rename to resources/views/livewire/shared-variables/team/index.blade.php index 4d36dc950..ec72c8e94 100644 --- a/resources/views/livewire/team-shared-variables-index.blade.php +++ b/resources/views/livewire/shared-variables/team/index.blade.php @@ -1,12 +1,11 @@
    -
    -

    Shared Variables

    +

    Team Shared Variables

    -
    You can use these variables anywhere with You can use these variables anywhere with @{{ team.VARIABLENAME }}
    diff --git a/routes/web.php b/routes/web.php index 623de722a..bd85ecdd1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -32,6 +32,13 @@ use App\Livewire\Storage\Index as StorageIndex; use App\Livewire\Storage\Show as StorageShow; +use App\Livewire\SharedVariables\Index as SharedVariablesIndex; +use App\Livewire\SharedVariables\Team\Index as TeamSharedVariablesIndex; +use App\Livewire\SharedVariables\Project\Index as ProjectSharedVariablesIndex; +use App\Livewire\SharedVariables\Project\Show as ProjectSharedVariablesShow; +use App\Livewire\SharedVariables\Environment\Index as EnvironmentSharedVariablesIndex; +use App\Livewire\SharedVariables\Environment\Show as EnvironmentSharedVariablesShow; + use App\Livewire\CommandCenter\Index as CommandCenterIndex; use App\Livewire\ForcePasswordReset; use App\Livewire\Project\Index as ProjectIndex; @@ -76,7 +83,6 @@ use App\Livewire\Tags\Index as TagsIndex; use App\Livewire\Tags\Show as TagsShow; -use App\Livewire\TeamSharedVariablesIndex; use App\Livewire\Waitlist\Index as WaitlistIndex; use App\Models\ScheduledDatabaseBackupExecution; use Illuminate\Support\Facades\Storage; @@ -126,21 +132,34 @@ Route::get('/settings/license', SettingsLicense::class)->name('settings.license'); Route::get('/profile', ProfileIndex::class)->name('profile'); + Route::prefix('tags')->group(function () { Route::get('/', TagsIndex::class)->name('tags.index'); Route::get('/{tag_name}', TagsShow::class)->name('tags.show'); }); + Route::prefix('notifications')->group(function () { Route::get('/email', NotificationEmail::class)->name('notifications.email'); Route::get('/telegram', NotificationTelegram::class)->name('notifications.telegram'); Route::get('/discord', NotificationDiscord::class)->name('notifications.discord'); }); - Route::get('/storages', StorageIndex::class)->name('storage.index'); - Route::get('/storages/{storage_uuid}', StorageShow::class)->name('storage.show'); + + Route::prefix('storages')->group(function () { + Route::get('/', StorageIndex::class)->name('storage.index'); + Route::get('/{storage_uuid}', StorageShow::class)->name('storage.show'); + }); + Route::prefix('shared-variables')->group(function () { + Route::get('/', SharedVariablesIndex::class)->name('shared-variables.index'); + Route::get('/team', TeamSharedVariablesIndex::class)->name('shared-variables.team.index'); + Route::get('/projects', ProjectSharedVariablesIndex::class)->name('shared-variables.project.index'); + Route::get('/project/{project_uuid}', ProjectSharedVariablesShow::class)->name('shared-variables.project.show'); + Route::get('/environments', EnvironmentSharedVariablesIndex::class)->name('shared-variables.environment.index'); + Route::get('/environment/{project_uuid}/{environment_name}', EnvironmentSharedVariablesShow::class)->name('shared-variables.environment.show'); + }); + Route::prefix('team')->group(function () { Route::get('/', TeamIndex::class)->name('team.index'); Route::get('/members', TeamMemberIndex::class)->name('team.member.index'); - Route::get('/shared-variables', TeamSharedVariablesIndex::class)->name('team.shared-variables.index'); }); Route::get('/command-center', CommandCenterIndex::class)->name('command-center');