Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: tags

Andras Bacsai0b5baf60a51d
diff --git a/app/Http/Controllers/Api/Deploy.php b/app/Http/Controllers/Api/Deploy.php
index 322d73e672..04fc9b816a 100644
--- a/app/Http/Controllers/Api/Deploy.php
+++ b/app/Http/Controllers/Api/Deploy.php
@@ -73,12 +73,17 @@ class Deploy extends Controller
$message->push("Tag {$tag} not found.");
continue;
}
- $resources = $found_tag->resources()->get();
- if ($resources->count() === 0) {
+ $applications = $found_tag->applications();
+ $services = $found_tag->services();
+ if ($applications->count() === 0 && $services->count() === 0) {
$message->push("No resources found for tag {$tag}.");
continue;
}
- foreach ($resources as $resource) {
+ foreach ($applications as $resource) {
+ $return_message = $this->deploy_resource($resource, $force);
+ $message = $message->merge($return_message);
+ }
+ foreach ($services as $resource) {
$return_message = $this->deploy_resource($resource, $force);
$message = $message->merge($return_message);
}
diff --git a/app/Livewire/Project/Shared/Tags.php b/app/Livewire/Project/Shared/Tags.php
index db330b15c5..fc17dcdf6d 100644
--- a/app/Livewire/Project/Shared/Tags.php
+++ b/app/Livewire/Project/Shared/Tags.php
@@ -37,12 +37,13 @@ class Tags extends Component
return handleError($e, $this);
}
}
- public function deleteTag($id, $name)
+ public function deleteTag(string $id)
{
try {
- $found_more_tags = Tag::where(['name' => $name, 'team_id' => currentTeam()->id])->first();
$this->resource->tags()->detach($id);
- if ($found_more_tags->resources()->get()->count() == 0) {
+
+ $found_more_tags = Tag::where(['id' => $id, 'team_id' => currentTeam()->id])->first();
+ if ($found_more_tags->applications()->count() == 0 && $found_more_tags->services()->count() == 0){
$found_more_tags->delete();
}
$this->refresh();
diff --git a/app/Livewire/Tags/Show.php b/app/Livewire/Tags/Show.php
index 6a61a08517..8574646d72 100644
--- a/app/Livewire/Tags/Show.php
+++ b/app/Livewire/Tags/Show.php
@@ -10,14 +10,27 @@ use Livewire\Component;
class Show extends Component
{
public Tag $tag;
- public $resources;
+ public $applications;
+ public $services;
public $webhook = null;
public $deployments_per_tag_per_server = [];
+ public function mount()
+ {
+ $tag = Tag::ownedByCurrentTeam()->where('name', request()->tag_name)->first();
+ if (!$tag) {
+ return redirect()->route('tags.index');
+ }
+ $this->webhook = generatTagDeployWebhook($tag->name);
+ $this->applications = $tag->applications()->get();
+ $this->services = $tag->services()->get();
+ $this->tag = $tag;
+ $this->get_deployments();
+ }
public function get_deployments()
{
try {
- $resource_ids = $this->resources->pluck('id');
+ $resource_ids = $this->applications->pluck('id');
$this->deployments_per_tag_per_server = ApplicationDeploymentQueue::whereIn("status", ["in_progress", "queued"])->whereIn('application_id', $resource_ids)->get([
"id",
"application_id",
@@ -35,7 +48,11 @@ class Show extends Component
public function redeploy_all()
{
try {
- $this->resources->each(function ($resource) {
+ $this->applications->each(function ($resource) {
+ $deploy = new Deploy();
+ $deploy->deploy_resource($resource);
+ });
+ $this->services->each(function ($resource) {
$deploy = new Deploy();
$deploy->deploy_resource($resource);
});
@@ -44,17 +61,7 @@ class Show extends Component
return handleError($e, $this);
}
}
- public function mount()
- {
- $tag = Tag::ownedByCurrentTeam()->where('name', request()->tag_name)->first();
- if (!$tag) {
- return redirect()->route('tags.index');
- }
- $this->webhook = generatTagDeployWebhook($tag->name);
- $this->resources = $tag->resources()->get();
- $this->tag = $tag;
- $this->get_deployments();
- }
+
public function render()
{
return view('livewire.tags.show');
diff --git a/app/Models/Application.php b/app/Models/Application.php
index b91acdcffb..cf3141ed7a 100644
--- a/app/Models/Application.php
+++ b/app/Models/Application.php
@@ -216,6 +216,9 @@ class Application extends BaseModel
{
return $this->morphToMany(Tag::class, 'taggable');
}
+ public function project() {
+ return data_get($this, 'environment.project');
+ }
public function team()
{
return data_get($this, 'environment.project.team');
diff --git a/app/Models/Service.php b/app/Models/Service.php
index b6d5e86d31..244964db1c 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -16,6 +16,10 @@ class Service extends BaseModel
{
return 'service';
}
+ public function project()
+ {
+ return data_get($this, 'environment.project');
+ }
public function team()
{
return data_get($this, 'environment.project.team');
diff --git a/app/Models/Tag.php b/app/Models/Tag.php
index 02b3a7ff5d..b7d50b84fe 100644
--- a/app/Models/Tag.php
+++ b/app/Models/Tag.php
@@ -24,9 +24,8 @@ class Tag extends BaseModel
{
return $this->morphedByMany(Application::class, 'taggable');
}
-
- public function resources() {
- return $this->applications();
+ public function services()
+ {
+ return $this->morphedByMany(Service::class, 'taggable');
}
-
}
diff --git a/resources/views/livewire/project/resource/index.blade.php b/resources/views/livewire/project/resource/index.blade.php
index f87b7ea87e..9f366ce558 100644
--- a/resources/views/livewire/project/resource/index.blade.php
+++ b/resources/views/livewire/project/resource/index.blade.php
@@ -46,7 +46,7 @@
@else
<div x-data="searchComponent()">
<x-forms.input placeholder="Search for name, fqdn..." class="w-full" x-model="search" />
- <div class="grid gap-4 pt-4 lg:grid-cols-4">
+ <div class="grid grid-cols-1 gap-4 pt-4 lg:grid-cols-2 xl:grid-cols-3">
<template x-for="item in filteredApplications" :key="item.id">
<span class="relative">
<a class="h-24 box group" :href="item.hrefLink">
diff --git a/resources/views/livewire/project/shared/tags.blade.php b/resources/views/livewire/project/shared/tags.blade.php
index ec13dbe7f7..4cd3f9f3d4 100644
--- a/resources/views/livewire/project/shared/tags.blade.php
+++ b/resources/views/livewire/project/shared/tags.blade.php
@@ -4,7 +4,7 @@
@forelse ($this->resource->tags as $tagId => $tag)
<div class="px-2 py-1 text-center text-white select-none w-fit bg-coolgray-100 hover:bg-coolgray-200">
{{ $tag->name }}
- <svg wire:click="deleteTag('{{ $tag->id }}','{{ $tag->name }}')"
+ <svg wire:click="deleteTag('{{ $tag->id }}')"
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
class="inline-block w-3 h-3 rounded cursor-pointer stroke-current hover:bg-red-500">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
@@ -17,16 +17,19 @@
<form wire:submit='submit' class="flex items-end gap-2 pt-4">
<div class="w-64">
<x-forms.input label="Create new or assign existing tags"
- helper="You add more at once with space seperated list: web api something<br><br>If the tag does not exists, it will be created." wire:model="new_tag" />
+ helper="You add more at once with space seperated list: web api something<br><br>If the tag does not exists, it will be created."
+ wire:model="new_tag" />
</div>
<x-forms.button type="submit">Add</x-forms.button>
</form>
- <h3 class="pt-4">Already defined tags</h3>
- <div>Click to quickly add</div>
- <div class="flex gap-2 pt-4">
- @foreach ($tags as $tag)
- <x-forms.button wire:click="addTag('{{ $tag->id }}','{{ $tag->name }}')">
- {{ $tag->name }}</x-forms.button>
- @endforeach
- </div>
+ @if ($tags->count() > 0)
+ <h3 class="pt-4">Already defined tags</h3>
+ <div>Click to quickly add</div>
+ <div class="flex gap-2 pt-4">
+ @foreach ($tags as $tag)
+ <x-forms.button wire:click="addTag('{{ $tag->id }}','{{ $tag->name }}')">
+ {{ $tag->name }}</x-forms.button>
+ @endforeach
+ </div>
+ @endif
</div>
diff --git a/resources/views/livewire/tags/show.blade.php b/resources/views/livewire/tags/show.blade.php
index 34427c7ab7..ae318de1ab 100644
--- a/resources/views/livewire/tags/show.blade.php
+++ b/resources/views/livewire/tags/show.blade.php
@@ -14,11 +14,19 @@
All resources will be redeployed.
</x-new-modal>
</div>
- <div class="grid gap-2 pt-4 lg:grid-cols-4">
- @foreach ($resources as $resource)
- <a href="{{ $resource->link() }}" class="flex flex-col box group">
- <span class="font-bold text-white">{{ $resource->name }}</span>
- <span class="description">{{ $resource->description }}</span>
+ <div class="grid grid-cols-1 gap-2 pt-4 lg:grid-cols-2 xl:grid-cols-3">
+ @foreach ($applications as $application)
+ <a href="{{ $application->link() }}" class="flex flex-col box group">
+ <span class="font-bold text-white">{{ $application->project()->name }}/{{$application->environment->name}}</span>
+ <span class="text-white ">{{ $application->name }}</span>
+ <span class="description">{{ $application->description }}</span>
+ </a>
+ @endforeach
+ @foreach ($services as $service)
+ <a href="{{ $service->link() }}" class="flex flex-col box group">
+ <span class="font-bold text-white">{{ $service->project()->name }}/{{$service->environment->name}}</span>
+ <span class="text-white ">{{ $service->name }}</span>
+ <span class="description">{{ $service->description }}</span>
</a>
@endforeach
</div>