feat: auto-discover container images from registries
- Add ListImages() to registry interface, implement for Gitea - Add owner field to registry config (needed for Gitea packages API) - GET /api/registries/:id/images endpoint - "Browse Images" button on Projects and Quick Deploy pages - Image dropdown with registry grouping and search - i18n support (EN/RU) for all new UI strings
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import type { Project } from '$lib/types';
|
||||
import type { Project, Registry, RegistryImage } from '$lib/types';
|
||||
import * as api from '$lib/api';
|
||||
import { t } from '$lib/i18n';
|
||||
import { IconPlus } from '$lib/components/icons';
|
||||
import { IconPlus, IconSearch, IconLoader } from '$lib/components/icons';
|
||||
import FormField from '$lib/components/FormField.svelte';
|
||||
import SkeletonTable from '$lib/components/SkeletonTable.svelte';
|
||||
import EmptyState from '$lib/components/EmptyState.svelte';
|
||||
@@ -20,6 +20,48 @@
|
||||
let formSubmitting = $state(false);
|
||||
let formError = $state('');
|
||||
|
||||
// Image browser state
|
||||
let showImageBrowser = $state(false);
|
||||
let registries = $state<Registry[]>([]);
|
||||
let browseImages = $state<(RegistryImage & { registryName: string })[]>([]);
|
||||
let browseLoading = $state(false);
|
||||
let browseError = $state('');
|
||||
|
||||
async function handleBrowseImages() {
|
||||
showImageBrowser = !showImageBrowser;
|
||||
if (!showImageBrowser) return;
|
||||
|
||||
browseLoading = true;
|
||||
browseError = '';
|
||||
browseImages = [];
|
||||
try {
|
||||
registries = await api.listRegistries();
|
||||
const allImages: (RegistryImage & { registryName: string })[] = [];
|
||||
for (const reg of registries) {
|
||||
if (!reg.owner) continue;
|
||||
try {
|
||||
const images = await api.listRegistryImages(reg.id);
|
||||
for (const img of images) {
|
||||
allImages.push({ ...img, registryName: reg.name });
|
||||
}
|
||||
} catch {
|
||||
// Skip registries that fail (e.g., no owner configured).
|
||||
}
|
||||
}
|
||||
browseImages = allImages;
|
||||
} catch (e) {
|
||||
browseError = e instanceof Error ? e.message : $t('projects.imageLoadFailed');
|
||||
} finally {
|
||||
browseLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
function selectBrowsedImage(image: RegistryImage & { registryName: string }) {
|
||||
formImage = image.full_ref;
|
||||
formRegistry = image.registryName;
|
||||
showImageBrowser = false;
|
||||
}
|
||||
|
||||
async function loadProjects() {
|
||||
loading = true;
|
||||
error = '';
|
||||
@@ -97,7 +139,50 @@
|
||||
|
||||
<div class="mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<FormField label="{$t('projects.name')} *" name="name" bind:value={formName} placeholder="my-web-app" required />
|
||||
<FormField label="{$t('projects.image')} *" name="image" bind:value={formImage} placeholder="registry.example.com/org/app" required />
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<div class="flex items-end gap-2">
|
||||
<div class="flex-1">
|
||||
<FormField label="{$t('projects.image')} *" name="image" bind:value={formImage} placeholder="registry.example.com/org/app" required />
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onclick={handleBrowseImages}
|
||||
class="inline-flex items-center gap-1.5 rounded-lg border border-[var(--border-primary)] px-3 py-2 text-sm font-medium text-[var(--text-secondary)] hover:bg-[var(--surface-card-hover)] transition-colors"
|
||||
>
|
||||
<IconSearch size={14} />
|
||||
{$t('projects.browseImages')}
|
||||
</button>
|
||||
</div>
|
||||
{#if showImageBrowser}
|
||||
<div class="rounded-lg border border-[var(--border-primary)] bg-[var(--surface-card)] p-3 shadow-[var(--shadow-md)] max-h-60 overflow-y-auto animate-scale-in">
|
||||
{#if browseLoading}
|
||||
<div class="flex items-center gap-2 py-2 text-sm text-[var(--text-secondary)]">
|
||||
<IconLoader size={14} />
|
||||
{$t('projects.loadingImages')}
|
||||
</div>
|
||||
{:else if browseError}
|
||||
<p class="text-sm text-[var(--color-danger)]">{browseError}</p>
|
||||
{:else if browseImages.length === 0}
|
||||
<p class="text-sm text-[var(--text-tertiary)]">{$t('projects.noImages')}</p>
|
||||
{:else}
|
||||
<ul class="space-y-1">
|
||||
{#each browseImages as image}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => selectBrowsedImage(image)}
|
||||
class="w-full rounded-md px-3 py-2 text-left text-sm hover:bg-[var(--surface-card-hover)] transition-colors"
|
||||
>
|
||||
<span class="font-medium text-[var(--text-primary)]">{image.full_ref}</span>
|
||||
<span class="ml-2 text-xs text-[var(--text-tertiary)]">({image.registryName})</span>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<FormField label={$t('projects.registry')} name="registry" bind:value={formRegistry} placeholder="gitea" />
|
||||
<FormField label={$t('projects.port')} name="port" type="number" bind:value={formPort} />
|
||||
<div class="sm:col-span-2">
|
||||
|
||||
Reference in New Issue
Block a user