ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat: add pinned preview deployment controls and queued lifecycle feedback
Juan Denisada1276d39a0
diff --git a/frontend/scripts/effective-environment-browser.mjs b/frontend/scripts/effective-environment-browser.mjsindex 80684d69..7883d99d 100644--- a/frontend/scripts/effective-environment-browser.mjs+++ b/frontend/scripts/effective-environment-browser.mjs@@ -24,6 +24,9 @@ window.testApi={getPreviews:()=>Promise.resolve({previews:[{id:1,pr_number:1,status:'unavailable',domain:'unavailable.test',url:'https://unavailable.test'},{id:2,pr_number:2,status:'running',domain:'running.test',url:'https://running.test'}]}),getPreviewSettings:()=>Promise.resolve({enabled:true}),redeployPreview:()=>Promise.resolve({status:'unavailable'}),+ createPreview:(id,pr)=>{window.created=pr;return Promise.resolve({status:'queued',job_id:'job'});},+ destroyPreview:()=>Promise.resolve({status:'queued'}),+ updatePreviewSettings:(id,patch)=>{window.settingsPatch=patch;return Promise.resolve({enabled:true,...patch});},};createRoot(document.getElementById('root')).render(<MemoryRouter><ConfirmProvider>{location.search==='?preview'?<PreviewList appId={1}/>:<EnvironmentPanel appId={1}/>}</ConfirmProvider></MemoryRouter>);`;@@ -112,6 +115,20 @@ try {assert.equal(await page.evaluate(()=>window.toasts.some(x=>x.startsWith('SUCCESS:'))),false);assert.deepEqual(errors,[]);console.log('PASS previews: unavailable links suppressed and unsuccessful redeploy has no success toast');+ await page.getByLabel('PR number', {exact:true}).fill('23');+ await page.getByLabel('Repository branch', {exact:true}).fill('feature/test');+ await page.getByLabel('Full commit SHA', {exact:true}).fill('a'.repeat(40));+ await page.getByRole('button',{name:'Deploy preview',exact:true}).click();+ await page.waitForFunction(()=>window.created?.pr_number===23);+ assert.deepEqual(await page.evaluate(()=>window.created),{pr_number:23,branch:'feature/test',commit_sha:'a'.repeat(40)});+ await page.getByRole('switch',{name:/Inherit application environment/}).click();+ await page.waitForFunction(()=>window.settingsPatch?.inherit_environment===true);+ await page.getByRole('button',{name:'Delete',exact:true}).first().click();+ await page.getByRole('alertdialog').getByRole('button',{name:'Delete',exact:true}).click();+ await page.waitForFunction(()=>window.toasts.some(t=>t.includes('deletion queued')));+ assert.deepEqual(errors,[]);+ console.log('PASS previews: pinned create form, explicit inheritance and queued deletion');+} finally {await browser?.close();await server.close();diff --git a/frontend/src/components/previews/PreviewCreateForm.jsx b/frontend/src/components/previews/PreviewCreateForm.jsxnew file mode 100644index 00000000..283d856e--- /dev/null+++ b/frontend/src/components/previews/PreviewCreateForm.jsx@@ -0,0 +1,31 @@+import { useState } from 'react';+import { useTranslation } from 'react-i18next';+import { Input } from '../ui/input';+import FormField from '../FormField';+import { Button } from '../ui/button';++export default function PreviewCreateForm({ onCreate, busy }) {+ const { t } = useTranslation();+ const [number, setNumber] = useState('');+ const [branch, setBranch] = useState('');+ const [sha, setSha] = useState('');+ async function submit(event) {+ event.preventDefault();+ await onCreate({ pr_number: Number(number), branch: branch.trim(), commit_sha: sha.trim() });+ }+ return <form onSubmit={submit} className="preview-settings">+ <p className="preview-settings__hint">{t('app.previewList.pinnedHelp', 'Deploy a branch from this application’s configured repository at an exact commit. Signed PR webhooks can also create and remove previews automatically.')}</p>+ <div className="form-row">+ <FormField htmlFor="preview-pr-number" label={t('app.previewList.prNumber', 'PR number')}>+ <Input id="preview-pr-number" type="number" min="1" step="1" required value={number} onChange={e => setNumber(e.target.value)} />+ </FormField>+ <FormField htmlFor="preview-branch" label={t('app.previewList.branch', 'Repository branch')}>+ <Input id="preview-branch" required value={branch} onChange={e => setBranch(e.target.value)} />+ </FormField>+ <FormField htmlFor="preview-commit" label={t('app.previewList.commit', 'Full commit SHA')}>+ <Input id="preview-commit" required pattern="[0-9a-fA-F]{40}|[0-9a-fA-F]{64}" value={sha} onChange={e => setSha(e.target.value)} />+ </FormField>+ </div>+ <Button type="submit" disabled={busy}>{t('app.previewList.createPreview', 'Deploy preview')}</Button>+ </form>;+}diff --git a/frontend/src/components/previews/PreviewList.jsx b/frontend/src/components/previews/PreviewList.jsxindex 0f1f649b..01d5abaf 100644--- a/frontend/src/components/previews/PreviewList.jsx+++ b/frontend/src/components/previews/PreviewList.jsx@@ -6,6 +6,7 @@ import api from '../../services/api';import { useToast } from '../../contexts/useToast.js';import { useConfirm } from '../../hooks/useConfirm';import EmptyState from '../EmptyState';+import PreviewCreateForm from './PreviewCreateForm';import { Pill, serviceStatusKind } from '../ds';import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';@@ -27,6 +28,7 @@ const PreviewList = ({ appId }) => {const [saving, setSaving] = useState(false);const [syncing, setSyncing] = useState(false);const [busyId, setBusyId] = useState(null);+ const [creating, setCreating] = useState(false);const [template, setTemplate] = useState(DEFAULT_TEMPLATE);const load = useCallback(async () => {@@ -101,6 +103,19 @@ const PreviewList = ({ appId }) => {}}+ async function handleCreate(pr) {+ setCreating(true);+ try {+ await api.createPreview(appId, pr);+ toast?.success?.(t('app.previewList.queued', 'Preview deployment queued. Refresh for status; execution details are in Jobs.'));+ await load();+ } catch (err) {+ toastError(toast, t('app.previewList.createFailed', 'Could not queue the preview.'), err);+ } finally {+ setCreating(false);+ }+ }+async function handleDestroy(preview) {const ok = await confirm({title: t('app.previewList.destroyPreview', 'Delete preview'),@@ -111,8 +126,10 @@ const PreviewList = ({ appId }) => {if (!ok) return;setBusyId(preview.id);try {- await api.destroyPreview(appId, preview.id);- toast?.success?.(t('app.previewList.previewForPrDestroyed', 'Preview for PR #{{prnumber}} deleted', { prnumber: preview.pr_number }));+ const result = await api.destroyPreview(appId, preview.id);+ toast?.success?.(result.status === 'queued'+ ? t('app.previewList.deletionQueued', 'Preview deletion queued. Refresh for status.')+ : t('app.previewList.previewForPrDestroyed', 'Preview for PR #{{prnumber}} deleted', { prnumber: preview.pr_number }));await load();} catch (err) {toastError(toast, t('app.previewList.destroyFailed', "Couldn't delete the preview."), err);@@ -137,7 +154,7 @@ const PreviewList = ({ appId }) => {<div><h3>{t('app.previewList.prPreviewEnvironments', 'PR preview environments')}</h3><p className="preview-settings__hint">- {t('app.previewList.supportedProvisioners', 'Preview deployment requires a supported runtime provisioner. Generic application previews are not available yet. A domain alone does not mean a preview is deployed.')}+ {t('app.previewList.genericSupport', 'Generic previews support local Git-backed Dockerfile and container-buildpack apps with nginx. Compose, remote targets and host-command builds are not supported. Configure preview DNS to point at this server.')}</p></div></div>@@ -179,9 +196,19 @@ const PreviewList = ({ appId }) => {)}</div>+ {enabled && <>+ <div className="preview-settings__toggle">+ <Label htmlFor="preview-inherit">{t('app.previewList.inheritEnv', 'Inherit application environment (may grant access to production databases and services)')}</Label>+ <Switch id="preview-inherit" checked={!!settings?.inherit_environment} disabled={saving}+ onCheckedChange={inherit_environment => saveSettings({ inherit_environment })} />+ </div>+ <PreviewCreateForm onCreate={handleCreate} busy={creating} />+ </>}+{/* Active previews */}<div className="preview-list__toolbar"><h4>{t('app.previewList.activePreviews', 'Active previews')}</h4>+ <Button variant="ghost" onClick={load}>{t('app.previewList.refresh', 'Refresh status')}</Button><Button variant="ghost" onClick={handleSync} disabled={syncing}><RefreshCw size={15} className={syncing ? 'spin' : undefined} />{t('app.previewList.syncWithOpenPrs', 'Sync with open PRs')}@@ -194,7 +221,7 @@ const PreviewList = ({ appId }) => {title={t('app.previewList.noActivePreviews', 'No active previews')}description={enabled- ? t('app.previewList.openAPullRequestToSpin', 'Open a pull request to spin up a preview, or sync to reconcile now.')+ ? t('app.previewList.createOrWebhook', 'Deploy a pinned branch above, or connect a signed PR webhook to this application.'): t('app.previewList.enablePrPreviewsAboveToStart', 'Enable PR previews above to start deploying preview environments.')}/>@@ -222,7 +249,8 @@ const PreviewList = ({ appId }) => {</a>)}</div>- {p.status === 'unavailable' && (+ {p.status_reason && p.status !== 'running' && <p className="preview-settings__hint">{p.status_reason}</p>}+ {p.status === 'unavailable' && !p.status_reason && (<p className="preview-settings__hint">{t('app.previewList.noRuntime', 'No provisioned runtime is recorded for this preview. Its URL is unavailable.')}</p>diff --git a/frontend/src/i18n/locales/ar.json b/frontend/src/i18n/locales/ar.jsonindex 5b56511f..79553fa5 100644--- a/frontend/src/i18n/locales/ar.json+++ b/frontend/src/i18n/locales/ar.json@@ -4431,7 +4431,6 @@"enabled": "مفعّل","loadingPreviews": "جارٍ تحميل المعاينات...","noActivePreviews": "لا توجد معاينات نشطة",- "openAPullRequestToSpin": "افتح طلب سحب لتدوير المعاينة، أو قم بالمزامنة للتوفيق الآن.","placeholders": "العناصر النائبة:","pr": "العلاقات العامة #","prPreviewEnvironments": "بيئات معاينة العلاقات العامة",diff --git a/frontend/src/i18n/locales/bn.json b/frontend/src/i18n/locales/bn.jsonindex d2ddb562..e509e9e5 100644--- a/frontend/src/i18n/locales/bn.json+++ b/frontend/src/i18n/locales/bn.json@@ -4431,7 +4431,6 @@"enabled": "সক্রিয়","loadingPreviews": "পূর্বরূপ লোড হচ্ছে...","noActivePreviews": "কোন সক্রিয় পূর্বরূপ",- "openAPullRequestToSpin": "একটি পূর্বরূপ স্পিন আপ করার জন্য একটি পুল অনুরোধ খুলুন, অথবা এখনই পুনর্মিলন করতে সিঙ্ক করুন৷","placeholders": "স্থানধারক:","pr": "পিআর #","prPreviewEnvironments": "পিআর প্রিভিউ পরিবেশ",diff --git a/frontend/src/i18n/locales/de.json b/frontend/src/i18n/locales/de.jsonindex 644f8ebf..b4e766af 100644--- a/frontend/src/i18n/locales/de.json+++ b/frontend/src/i18n/locales/de.json@@ -4431,7 +4431,6 @@"enabled": "Aktiviert","loadingPreviews": "Vorschau wird geladen...","noActivePreviews": "Keine aktiven Vorschauen",- "openAPullRequestToSpin": "Öffnen Sie eine Pull-Anfrage, um eine Vorschau zu starten, oder synchronisieren Sie sie, um sie jetzt abzugleichen.","placeholders": "Platzhalter:","pr": "PR-Nr.","prPreviewEnvironments": "PR-Vorschauumgebungen",diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.jsonindex bab1eaf9..db340737 100644--- a/frontend/src/i18n/locales/en.json+++ b/frontend/src/i18n/locales/en.json@@ -4420,8 +4420,14 @@},"previewList": {"activePreviews": "Active previews",+ "branch": "Repository branch",+ "commit": "Full commit SHA","couldNotLoadPrPreviews": "Couldn't load PR previews.","couldNotSaveSettings": "Couldn't save the settings.",+ "createFailed": "Could not queue the preview.",+ "createOrWebhook": "Deploy a pinned branch above, or connect a signed PR webhook to this application.",+ "createPreview": "Deploy preview",+ "deletionQueued": "Preview deletion queued. Refresh for status.","destroy": "Delete","destroyFailed": "Couldn't delete the preview.","destroyPreview": "Delete preview",@@ -4429,21 +4435,25 @@"domainTemplate": "Domain template","enablePrPreviewsAboveToStart": "Enable PR previews above to start deploying preview environments.","enabled": "Enabled",+ "genericSupport": "Generic previews support local Git-backed Dockerfile and container-buildpack apps with nginx. Compose, remote targets and host-command builds are not supported. Configure preview DNS to point at this server.",+ "inheritEnv": "Inherit application environment (may grant access to production databases and services)","loadingPreviews": "Loading previews…","noActivePreviews": "No active previews","noRuntime": "No provisioned runtime is recorded for this preview. Its URL is unavailable.",- "openAPullRequestToSpin": "Open a pull request to spin up a preview, or sync to reconcile now.",+ "pinnedHelp": "Deploy a branch from this application’s configured repository at an exact commit. Signed PR webhooks can also create and remove previews automatically.","placeholders": "Placeholders:","pr": "PR #",+ "prNumber": "PR number","prPreviewEnvironments": "PR preview environments","previewForPrDestroyed": "Preview for PR #{{prnumber}} deleted","previewNotDeployed": "The preview was not deployed. Review its status below.","previewSettingsSaved": "Preview settings saved",+ "queued": "Preview deployment queued. Refresh for status; execution details are in Jobs.","reconciledPreviewsAgainstOpenPrs": "Reconciled previews against open PRs","redeploy": "Redeploy","redeployFailed": "Couldn't redeploy the preview.","redeployingPreviewForPr": "Redeploying preview for PR #{{prnumber}}",- "supportedProvisioners": "Preview deployment requires a supported runtime provisioner. Generic application previews are not available yet. A domain alone does not mean a preview is deployed.",+ "refresh": "Refresh status","syncFailed": "Couldn't sync previews.","syncWithOpenPrs": "Sync with open PRs","tearDownThePreviewEnvironmentFor": "Tear down the preview environment for PR #{{prnumber}}? This removes its temporary domain and resources."diff --git a/frontend/src/i18n/locales/es.json b/frontend/src/i18n/locales/es.jsonindex 6c2cf92c..b2b09252 100644--- a/frontend/src/i18n/locales/es.json+++ b/frontend/src/i18n/locales/es.json@@ -4431,7 +4431,6 @@"enabled": "Activado","loadingPreviews": "Cargando vistas previas...","noActivePreviews": "No hay vistas previas activas",- "openAPullRequestToSpin": "Abre un pull request para crear una vista previa, o sincroniza para reconciliar ahora.","placeholders": "Marcadores de posición:","pr": "PR #","prPreviewEnvironments": "Entornos de vista previa de PR",diff --git a/frontend/src/i18n/locales/fr.json b/frontend/src/i18n/locales/fr.jsonindex c49546e5..74d98fba 100644--- a/frontend/src/i18n/locales/fr.json+++ b/frontend/src/i18n/locales/fr.json@@ -4431,7 +4431,6 @@"enabled": "Activé","loadingPreviews": "Chargement des aperçus...","noActivePreviews": "Aucun aperçu actif",- "openAPullRequestToSpin": "Ouvrez une pull request pour afficher un aperçu ou synchronisez pour réconcilier maintenant.","placeholders": "Espaces réservés :","pr": "RP #","prPreviewEnvironments": "Environnements de prévisualisation des relations publiques",diff --git a/frontend/src/i18n/locales/id.json b/frontend/src/i18n/locales/id.jsonindex d4ade2a0..508006ff 100644--- a/frontend/src/i18n/locales/id.json+++ b/frontend/src/i18n/locales/id.json@@ -4431,7 +4431,6 @@"enabled": "Aktif","loadingPreviews": "Memuat pratinjau...","noActivePreviews": "Tidak ada pratinjau aktif",- "openAPullRequestToSpin": "Buka permintaan tarik untuk menjalankan pratinjau, atau sinkronkan untuk merekonsiliasi sekarang.","placeholders": "Penampung:","pr": "PR#","prPreviewEnvironments": "Lingkungan pratinjau PR",diff --git a/frontend/src/i18n/locales/it.json b/frontend/src/i18n/locales/it.jsonindex 63eadbd4..48e1f778 100644--- a/frontend/src/i18n/locales/it.json+++ b/frontend/src/i18n/locales/it.json@@ -4431,7 +4431,6 @@"enabled": "Abilitato","loadingPreviews": "Caricamento anteprime...","noActivePreviews": "Nessuna anteprima attiva",- "openAPullRequestToSpin": "Apri una richiesta pull per avviare un'anteprima o sincronizza per riconciliare ora.","placeholders": "Segnaposto:","pr": "PR n.","prPreviewEnvironments": "Ambienti di anteprima PR",diff --git a/frontend/src/i18n/locales/ko.json b/frontend/src/i18n/locales/ko.jsonindex 4f6d0d57..9ac6bcce 100644--- a/frontend/src/i18n/locales/ko.json+++ b/frontend/src/i18n/locales/ko.json@@ -4431,7 +4431,6 @@"enabled": "활성화됨","loadingPreviews": "미리보기 로드 중...","noActivePreviews": "활성 미리보기 없음",- "openAPullRequestToSpin": "끌어오기 요청을 열어 미리보기를 실행하거나 동기화하여 지금 조정하세요.","placeholders": "자리 표시자:","pr": "홍보번호","prPreviewEnvironments": "PR 미리보기 환경",diff --git a/frontend/src/i18n/locales/pl.json b/frontend/src/i18n/locales/pl.jsonindex 4421ee9a..edd33525 100644--- a/frontend/src/i18n/locales/pl.json+++ b/frontend/src/i18n/locales/pl.json@@ -4431,7 +4431,6 @@"enabled": "Włączone","loadingPreviews": "Ładowanie podglądów...","noActivePreviews": "Brak aktywnych podglądów",- "openAPullRequestToSpin": "Otwórz żądanie ściągnięcia, aby wyświetlić podgląd, lub zsynchronizuj, aby teraz uzgodnić.","placeholders": "Elementy zastępcze:","pr": "PR#","prPreviewEnvironments": "Środowiska podglądu PR",diff --git a/frontend/src/i18n/locales/pt.json b/frontend/src/i18n/locales/pt.jsonindex be3f4777..fc379fc3 100644--- a/frontend/src/i18n/locales/pt.json+++ b/frontend/src/i18n/locales/pt.json@@ -4431,7 +4431,6 @@"enabled": "Ativado","loadingPreviews": "Carregando visualizações...","noActivePreviews": "Nenhuma visualização ativa",- "openAPullRequestToSpin": "Abra uma solicitação pull para iniciar uma visualização ou sincronize para reconciliar agora.","placeholders": "Espaços reservados:","pr": "RP#","prPreviewEnvironments": "Ambientes de visualização de relações públicas",diff --git a/frontend/src/i18n/locales/ru.json b/frontend/src/i18n/locales/ru.jsonindex 360cad82..094882ff 100644--- a/frontend/src/i18n/locales/ru.json+++ b/frontend/src/i18n/locales/ru.json@@ -4431,7 +4431,6 @@"enabled": "Включено","loadingPreviews": "Загрузка превью...","noActivePreviews": "Нет активных превью",- "openAPullRequestToSpin": "Откройте запрос на включение, чтобы активировать предварительный просмотр, или выполните синхронизацию, чтобы выполнить согласование прямо сейчас.","placeholders": "Заполнители:","pr": "PR №","prPreviewEnvironments": "Среды предварительного просмотра PR",diff --git a/frontend/src/i18n/locales/th.json b/frontend/src/i18n/locales/th.jsonindex 91b55e42..597ce1cd 100644--- a/frontend/src/i18n/locales/th.json+++ b/frontend/src/i18n/locales/th.json@@ -4431,7 +4431,6 @@"enabled": "เปิดใช้งาน","loadingPreviews": "กำลังโหลดตัวอย่าง...","noActivePreviews": "ไม่มีการแสดงตัวอย่างที่ใช้งานอยู่",- "openAPullRequestToSpin": "เปิดคำขอดึงเพื่อดูตัวอย่าง หรือซิงค์เพื่อปรับยอดทันที","placeholders": "ตัวยึดตำแหน่ง:","pr": "ประชาสัมพันธ์ #","prPreviewEnvironments": "สภาพแวดล้อมการแสดงตัวอย่าง PR",diff --git a/frontend/src/i18n/locales/tr.json b/frontend/src/i18n/locales/tr.jsonindex 197949be..ed79b36d 100644--- a/frontend/src/i18n/locales/tr.json+++ b/frontend/src/i18n/locales/tr.json@@ -4431,7 +4431,6 @@"enabled": "Etkin","loadingPreviews": "Önizlemeler yükleniyor...","noActivePreviews": "Etkin önizleme yok",- "openAPullRequestToSpin": "Önizlemeyi başlatmak için bir çekme isteği açın veya şimdi mutabakata varmak için senkronize edin.","placeholders": "Yer tutucular:","pr": "Halkla ilişkiler numarası","prPreviewEnvironments": "PR önizleme ortamları",diff --git a/frontend/src/i18n/locales/vi.json b/frontend/src/i18n/locales/vi.jsonindex bc676b9e..351caab8 100644--- a/frontend/src/i18n/locales/vi.json+++ b/frontend/src/i18n/locales/vi.json@@ -4431,7 +4431,6 @@"enabled": "Đã bật","loadingPreviews": "Đang tải bản xem trước...","noActivePreviews": "Không có bản xem trước nào đang hoạt động",- "openAPullRequestToSpin": "Mở yêu cầu kéo để xem trước hoặc đồng bộ hóa để điều chỉnh ngay bây giờ.","placeholders": "Phần giữ chỗ:","pr": "PR #","prPreviewEnvironments": "Môi trường xem trước PR",diff --git a/frontend/src/i18n/locales/zh-Hans.json b/frontend/src/i18n/locales/zh-Hans.jsonindex d31e4aa9..0e967f9a 100644--- a/frontend/src/i18n/locales/zh-Hans.json+++ b/frontend/src/i18n/locales/zh-Hans.json@@ -4431,7 +4431,6 @@"enabled": "已启用","loadingPreviews": "正在加载预览...","noActivePreviews": "没有活动预览",- "openAPullRequestToSpin": "打开拉取请求以启动预览,或立即同步以进行协调。","placeholders": "占位符:","pr": "公关号#","prPreviewEnvironments": "PR 预览环境",diff --git a/frontend/src/i18n/locales/zh-Hant.json b/frontend/src/i18n/locales/zh-Hant.jsonindex 8185d16d..742c9ba2 100644--- a/frontend/src/i18n/locales/zh-Hant.json+++ b/frontend/src/i18n/locales/zh-Hant.json@@ -4431,7 +4431,6 @@"enabled": "已啟用","loadingPreviews": "正在載入預覽…","noActivePreviews": "沒有活動預覽",- "openAPullRequestToSpin": "開啟 Pull Request 即可建立預覽環境,或立即同步以更新現有環境。","placeholders": "佔位符:","pr": "PR #","prPreviewEnvironments": "PR 預覽環境",diff --git a/frontend/src/services/api/previews.js b/frontend/src/services/api/previews.jsindex ce6aa494..f0afb537 100644--- a/frontend/src/services/api/previews.js+++ b/frontend/src/services/api/previews.js@@ -24,3 +24,7 @@ export async function redeployPreview(appId, previewId) {export async function destroyPreview(appId, previewId) {return this.request(`/apps/${appId}/previews/${previewId}`, { method: 'DELETE' });}++export async function createPreview(appId, pr) {+ return this.request(`/apps/${appId}/previews`, { method: 'POST', body: pr });+}