fix(appstore): data files, надёжность установки/удаления и сворачиваемые диалоги
All checks were successful
Backend Tests / pytest (Python 3.12) (push) Successful in 57s
Deploy to Production / Trigger production update (push) Successful in 8s

Доставка файлов приложения из каталога (data_files) до compose up,
APP_PASSWORD/default_credentials для Umbrel, сворачивание диалогов
долгих операций (MinimizableDialog), фильтрация pull-шума в ошибках.

Исправления багов:
- teardown: отсутствующий в Proxmox CT считается удалённым — orphaned-приложение
  теперь можно удалить из БД
- install: сдвиг VMID мимо занятых записей (nextid не резервирует номер,
  retry мог подхватить чужой контейнер)
- retry: параметры установки сохраняются в installed_apps.install_params
  (cores/memory/disk/storage/bridge/ip_config/port_explicit, миграция JSONB)
  вместо жёстких дефолтов
- reconcile: недоступный сервер больше не помечает все приложения orphaned
- update: реально опубликованный порт фиксируется в БД (url/health)
- .env: значения с '#' кавычатся (dotenv-парсер обрезал их как inline-комментарий)
- порт 80, выбранный явно в мастере, публикуется как есть
- useCatalog: available_only включён в queryKey (коллизия кэша)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
markmorado
2026-07-17 12:52:14 +05:00
parent f22b24d86a
commit 4621ffe88a
14 changed files with 654 additions and 72 deletions

View File

@@ -3,6 +3,9 @@ import { useTranslation } from 'react-i18next';
import { toast } from 'sonner';
import { Loader2, HardDriveDownload, CheckCircle2, XCircle } from 'lucide-react';
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog';
import {
DialogMinimizeButton, MinimizedTaskPill, type MinimizedStatus,
} from '@/components/shared/MinimizableDialog';
import { Button } from '@/components/ui/button';
import { Checkbox } from '@/components/ui/checkbox';
import { Input } from '@/components/ui/input';
@@ -22,6 +25,9 @@ export default function GoldenTemplateDialog({ open, onOpenChange }: Props) {
const [serverId, setServerId] = useState('');
const [node, setNode] = useState('');
// Свёрнутое состояние: диалог скрыт, прогресс сборки — в плашке внизу справа.
// open остаётся true, поэтому опрос статуса (useGoldenTemplateStatus) продолжается.
const [minimized, setMinimized] = useState(false);
const [templateStorage, setTemplateStorage] = useState('local');
const [rootfsStorage, setRootfsStorage] = useState('local-lvm');
const [force, setForce] = useState(false);
@@ -67,9 +73,19 @@ export default function GoldenTemplateDialog({ open, onOpenChange }: Props) {
);
};
const handleOpenChange = (o: boolean) => {
if (!o) setMinimized(false);
onOpenChange(o);
};
const pillStatus: MinimizedStatus =
running ? 'running' : op?.status === 'completed' ? 'done' : op?.status === 'failed' ? 'failed' : 'idle';
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<>
<Dialog open={open && !minimized} onOpenChange={handleOpenChange}>
<DialogContent className="max-w-lg">
<DialogMinimizeButton onClick={() => setMinimized(true)} title={t('appstore.minimize')} />
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<HardDriveDownload className="h-5 w-5 text-primary" />
@@ -165,7 +181,7 @@ export default function GoldenTemplateDialog({ open, onOpenChange }: Props) {
</div>
<DialogFooter>
<Button variant="outline" onClick={() => onOpenChange(false)}>
<Button variant="outline" onClick={() => handleOpenChange(false)}>
{t('common.close', 'Закрыть')}
</Button>
<Button onClick={handleBuild} disabled={!canSubmit}>
@@ -177,5 +193,18 @@ export default function GoldenTemplateDialog({ open, onOpenChange }: Props) {
</DialogFooter>
</DialogContent>
</Dialog>
{open && minimized && (
<MinimizedTaskPill
title={t('appstore.golden.title', 'Золотой LXC-шаблон')}
subtitle={op?.status === 'failed'
? (op.error_text || t('appstore.golden.failed', 'Ошибка сборки'))
: (lastStep || t('appstore.golden.working', 'Выполняется...'))}
progress={op ? op.progress : undefined}
status={pillStatus}
onRestore={() => setMinimized(false)}
onClose={() => handleOpenChange(false)}
/>
)}
</>
);
}

View File

@@ -6,6 +6,9 @@ import { Loader2, CheckCircle2, XCircle, Copy, ExternalLink } from 'lucide-react
import {
Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter,
} from '@/components/ui/dialog';
import {
DialogMinimizeButton, MinimizedTaskPill, type MinimizedStatus,
} from '@/components/shared/MinimizableDialog';
import { Button } from '@/components/ui/button';
import { Checkbox } from '@/components/ui/checkbox';
import { Input } from '@/components/ui/input';
@@ -92,6 +95,9 @@ export default function InstallWizard({ app, open, onOpenChange }: Props) {
}, [storages]);
const [phase, setPhase] = useState<Phase>('form');
// Свёрнутое состояние: диалог скрыт, внизу справа — плашка прогресса.
// Компонент остаётся смонтированным, поэтому WS/опрос прогресса живут.
const [minimized, setMinimized] = useState(false);
const [installedAppId, setInstalledAppId] = useState<number | null>(null);
const [op, setOp] = useState<AppOperation | null>(null);
const [secrets, setSecrets] = useState<Record<string, string>>({});
@@ -124,7 +130,7 @@ export default function InstallWizard({ app, open, onOpenChange }: Props) {
);
const reset = () => {
setPhase('form'); setOp(null); setInstalledAppId(null); setSecrets({});
setPhase('form'); setMinimized(false); setOp(null); setInstalledAppId(null); setSecrets({});
setName(app.app_id); setServerId(''); setNode(''); setAnswers({});
setAdvanced(false); setCores(2); setMemory(2048); setDisk(8);
setStorage('local-lvm'); setBridge('vmbr0');
@@ -173,9 +179,21 @@ export default function InstallWizard({ app, open, onOpenChange }: Props) {
const progress = op?.progress ?? 0;
// Статус для свёрнутой плашки.
const pillStatus: MinimizedStatus =
phase === 'progress' ? 'running' : phase === 'done' ? 'done' : phase === 'failed' ? 'failed' : 'idle';
const lastStep = op?.steps_log?.length ? op.steps_log[op.steps_log.length - 1].step : null;
const pillSubtitle =
phase === 'progress' ? (lastStep || t('appstore.installing'))
: phase === 'done' ? t('appstore.done')
: phase === 'failed' ? t('appstore.install_failed')
: null;
return (
<Dialog open={open} onOpenChange={handleClose}>
<>
<Dialog open={open && !minimized} onOpenChange={handleClose}>
<DialogContent className="max-w-lg">
<DialogMinimizeButton onClick={() => setMinimized(true)} title={t('appstore.minimize')} />
<DialogHeader>
<DialogTitle>{t('appstore.install_title', { name: app.name })}</DialogTitle>
</DialogHeader>
@@ -403,6 +421,17 @@ export default function InstallWizard({ app, open, onOpenChange }: Props) {
</DialogFooter>
</DialogContent>
</Dialog>
{open && minimized && (
<MinimizedTaskPill
title={t('appstore.install_title', { name: app.name })}
subtitle={pillSubtitle}
progress={phase === 'progress' || phase === 'failed' ? progress : undefined}
status={pillStatus}
onRestore={() => setMinimized(false)}
onClose={() => handleClose(false)}
/>
)}
</>
);
}

View File

@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
import { toast } from 'sonner';
import {
Package, Store, ExternalLink, RotateCw, Trash2, Loader2,
Play, Square, RefreshCcw, FileText, ArrowUpCircle, Undo2,
Play, Square, RefreshCcw, FileText, ArrowUpCircle, Undo2, KeyRound, Copy,
} from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
@@ -15,6 +15,7 @@ import {
import {
useInstalledApps, useAppstoreRealtime, useRetryApp, useDeleteApp,
useLifecycleAction, useReconcile, useAppLogs, useUpdateApp, useRollbackApp,
useAppCredentials,
} from '@/hooks/use-appstore';
import { useConfirm } from '@/components/shared/ConfirmDialog';
import type { InstalledApp } from '@/types/appstore';
@@ -32,6 +33,7 @@ export default function MyAppsPage() {
const update = useUpdateApp();
const rollback = useRollbackApp();
const [logsApp, setLogsApp] = useState<InstalledApp | null>(null);
const [credsApp, setCredsApp] = useState<InstalledApp | null>(null);
// ТЗ 6.6 — реконсиляция статусов при открытии экрана.
useEffect(() => {
@@ -178,6 +180,9 @@ export default function MyAppsPage() {
<FileText className="h-3.5 w-3.5" />
</Button>
)}
<Button size="icon-sm" variant="ghost" title={t('appstore.credentials_btn')} onClick={() => setCredsApp(a)}>
<KeyRound className="h-3.5 w-3.5" />
</Button>
{a.update_available && ['running', 'stopped', 'update_failed'].includes(a.status) && (
<Button size="icon-sm" variant="ghost" className="text-primary" title={t('appstore.update')} onClick={() => handleUpdate(a)} disabled={busy}>
<ArrowUpCircle className="h-3.5 w-3.5" />
@@ -208,10 +213,50 @@ export default function MyAppsPage() {
)}
<LogsDialog app={logsApp} onClose={() => setLogsApp(null)} />
<CredentialsDialog app={credsApp} onClose={() => setCredsApp(null)} />
</div>
);
}
function CredentialsDialog({ app, onClose }: { app: InstalledApp | null; onClose: () => void }) {
const { t } = useTranslation();
const { data: creds, isFetching } = useAppCredentials(app?.id ?? 0, !!app);
const entries = Object.entries(creds ?? {});
const copy = (v: string) => {
navigator.clipboard.writeText(v);
toast.success(t('appstore.copied'));
};
return (
<Dialog open={!!app} onOpenChange={(o) => { if (!o) onClose(); }}>
<DialogContent className="max-w-lg">
<DialogHeader>
<DialogTitle>{t('appstore.credentials_title', { name: app?.name ?? '' })}</DialogTitle>
</DialogHeader>
{isFetching && !creds ? (
<div className="py-8 text-center text-sm text-muted-foreground">{t('appstore.loading')}</div>
) : entries.length === 0 ? (
<p className="py-4 text-sm text-muted-foreground">{t('appstore.no_credentials')}</p>
) : (
<div className="space-y-2">
<p className="text-xs text-muted-foreground">{t('appstore.credentials_hint')}</p>
{entries.map(([k, v]) => (
<div key={k} className="flex items-center gap-2 rounded-md border bg-muted/40 px-3 py-2">
<span className="font-mono text-xs text-muted-foreground">{k}</span>
<span className="ml-auto truncate font-mono text-sm">{v}</span>
<Button size="icon-sm" variant="ghost" title={t('appstore.copy')} onClick={() => copy(v)}>
<Copy className="h-3.5 w-3.5" />
</Button>
</div>
))}
</div>
)}
</DialogContent>
</Dialog>
);
}
function LogsDialog({ app, onClose }: { app: InstalledApp | null; onClose: () => void }) {
const { t } = useTranslation();
const { data: logs, isFetching, refetch } = useAppLogs(app?.id ?? 0, !!app);