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.

feat(shared-variables): display project icons in project views

Andras Bacsaic6a12d707876
diff --git a/resources/views/livewire/shared-variables/project/index.blade.php b/resources/views/livewire/shared-variables/project/index.blade.php
index 802dfe371b..eb394ae83e 100644
--- a/resources/views/livewire/shared-variables/project/index.blade.php
+++ b/resources/views/livewire/shared-variables/project/index.blade.php
@@ -23,7 +23,13 @@
href="{{ route('shared-variables.project.show', ['project_uuid' => $project->uuid]) }}" {{ wireNavigate() }}>
<div class="flex items-start gap-3">
<div class="flex size-8 shrink-0 items-center justify-center rounded-lg border border-neutral-200 bg-neutral-50 text-neutral-500 dark:border-white/[0.08] dark:bg-white/[0.04] dark:text-fg-dim">
- <x-reicon name="projects" class="size-4" />
+ @if ($project->icon_path)
+ <img src="{{ route('project.icon', ['project_uuid' => $project->uuid, 'v' => $project->updated_at->timestamp]) }}"
+ alt="{{ $project->name }} icon"
+ class="h-full w-full rounded-lg object-cover">
+ @else
+ <x-reicon name="projects" class="size-4" />
+ @endif
</div>
<div class="min-w-0 flex-1">
<h2 class="truncate text-[13px]! leading-4! font-semibold! text-black dark:text-fg">{{ $project->name }}</h2>
@@ -42,7 +48,12 @@
<a x-show="matches(@js([$project->name, $project->description]))"
href="{{ route('shared-variables.project.show', ['project_uuid' => $project->uuid]) }}" {{ wireNavigate() }}
class="flex min-h-14 items-center gap-3 border-b border-neutral-200 px-4 py-2.5 last:border-b-0 hover:bg-neutral-50 hover:no-underline dark:border-white/[0.07] dark:hover:bg-white/[0.025]">
- <x-reicon name="projects" class="size-4 shrink-0 text-neutral-500 dark:text-fg-dim" />
+ @if ($project->icon_path)
+ <img src="{{ route('project.icon', ['project_uuid' => $project->uuid, 'v' => $project->updated_at->timestamp]) }}"
+ alt="{{ $project->name }} icon" class="size-4 shrink-0 rounded object-cover">
+ @else
+ <x-reicon name="projects" class="size-4 shrink-0 text-neutral-500 dark:text-fg-dim" />
+ @endif
<div class="min-w-0 flex-1"><div class="truncate text-[13px] font-medium">{{ $project->name }}</div><div class="truncate text-[11px] text-neutral-500 dark:text-fg-faint">{{ $project->description ?: 'No description' }}</div></div>
<span class="shrink-0 text-[11px] text-neutral-500 dark:text-fg-dim">{{ $project->environment_variables()->count() }} {{ Str::plural('variable', $project->environment_variables()->count()) }}</span>
</a>
diff --git a/tests/Feature/ProjectIconTest.php b/tests/Feature/ProjectIconTest.php
index 6f5357c5c5..3599c0b4b5 100644
--- a/tests/Feature/ProjectIconTest.php
+++ b/tests/Feature/ProjectIconTest.php
@@ -3,6 +3,7 @@
use App\Livewire\Dashboard;
use App\Livewire\Project\Edit;
use App\Livewire\Project\Index;
+use App\Livewire\SharedVariables\Project\Index as SharedVariablesProjectIndex;
use App\Models\InstanceSettings;
use App\Models\Project;
use App\Models\Team;
@@ -113,3 +114,19 @@ it('displays the project icon on the dashboard', function () {
'v' => $this->project->updated_at->timestamp,
]).'"');
});
+
+it('displays the project icon in shared variables project views', function () {
+ $this->project->forceFill([
+ 'icon_path' => "project-icons/{$this->project->uuid}/icon.jpg",
+ 'icon_storage_type' => 'local',
+ ])->save();
+
+ $iconUrl = route('project.icon', [
+ 'project_uuid' => $this->project->uuid,
+ 'v' => $this->project->updated_at->timestamp,
+ ]);
+
+ $component = Livewire::test(SharedVariablesProjectIndex::class);
+
+ expect(substr_count($component->html(), 'src="'.$iconUrl.'"'))->toBe(2);
+});