diff --git a/.zscripts/dev.pid b/.zscripts/dev.pid
index 2b4ff56..bd9b507 100755
--- a/.zscripts/dev.pid
+++ b/.zscripts/dev.pid
@@ -1 +1 @@
-1114
+1242
diff --git a/src/components/aos/views/instances.tsx b/src/components/aos/views/instances.tsx
index 06afbf8..fdbdcc3 100755
--- a/src/components/aos/views/instances.tsx
+++ b/src/components/aos/views/instances.tsx
@@ -175,6 +175,17 @@ interface InstanceStats {
expiringSoon: number
}
+interface AllowedRepoLite {
+ id: string
+ giteaOwner: string
+ giteaRepo: string
+ displayName: string
+ description: string | null
+ product: string
+ isPublic: boolean
+ isActive: boolean
+}
+
interface InstancesData {
instances: Instance[]
stats: InstanceStats
@@ -1183,10 +1194,8 @@ function CreateInstanceDialog({
const [companyId, setCompanyId] = useState('')
const [licenseId, setLicenseId] = useState('')
- const [product, setProduct] = useState('restov1')
+ const [allowedRepoId, setAllowedRepoId] = useState('')
const [plan, setPlan] = useState<'starter' | 'pro' | 'enterprise'>('pro')
- const [gitRepo, setGitRepo] = useState('https://github.com/cetinmustafa83/restov1')
- const [gitBranch, setGitBranch] = useState('main')
const [isDemo, setIsDemo] = useState(true)
const [saving, setSaving] = useState(false)
@@ -1198,6 +1207,11 @@ function CreateInstanceDialog({
[crmData?.companies]
)
+ // Fetch repos available to the selected company
+ const { data: reposData } = useFetch<{ repos: AllowedRepoLite[] }>(
+ companyId ? `/api/aos/repos?companyId=${companyId}` : null
+ )
+
// Filter licenses: same company, no existing live instance.
const availableLicenses = useMemo(() => {
const all = licensesData?.licenses ?? []
@@ -1220,22 +1234,28 @@ function CreateInstanceDialog({
if (availableLicenses.length === 0) setLicenseId('')
}, [availableLicenses, licenseId])
+ // Auto-select first available repo
+ useEffect(() => {
+ if (reposData?.repos?.[0] && !reposData.repos.find((r) => r.id === allowedRepoId)) {
+ setAllowedRepoId(reposData.repos[0].id)
+ }
+ if (!reposData?.repos?.length) setAllowedRepoId('')
+ }, [reposData, allowedRepoId])
+
// Reset form when closing
useEffect(() => {
if (open) return
setCompanyId('')
setLicenseId('')
- setProduct('restov1')
+ setAllowedRepoId('')
setPlan('pro')
- setGitRepo('https://github.com/cetinmustafa83/restov1')
- setGitBranch('main')
setIsDemo(true)
}, [open])
const submit = async () => {
if (!companyId) { toast.error('Bitte Firma auswählen'); return }
if (!licenseId) { toast.error('Bitte Lizenz auswählen'); return }
- if (!product.trim()) { toast.error('Produkt eingeben'); return }
+ if (!allowedRepoId) { toast.error('Bitte Produkt/Repo auswählen'); return }
setSaving(true)
const t = toast.loading('Instanz wird provisioniert (1–3 Min)…')
try {
@@ -1245,10 +1265,8 @@ function CreateInstanceDialog({
body: JSON.stringify({
companyId,
licenseId,
- product: product.trim(),
+ allowedRepoId,
plan,
- gitRepo: gitRepo.trim(),
- gitBranch: gitBranch.trim(),
isDemo,
}),
})
@@ -1267,6 +1285,8 @@ function CreateInstanceDialog({
}
}
+ const availableRepos = reposData?.repos ?? []
+
return (
- {/* Produkt + Plan */}
-
-
-
- setProduct(e.target.value)} />
-
-
-
-
-
+ {/* Produkt/Repo (from AllowedRepo list) */}
+
+
+
+
+ Repos werden vom Admin freigegeben. Quelle: Gitea (git.dfmpanel.eu), Branch: main.
+
- {/* Git */}
-
-
-
- setGitRepo(e.target.value)} />
-
-
-
- setGitBranch(e.target.value)} />
-
+ {/* Plan */}
+
+
+
{/* Demo Switch */}
@@ -1369,7 +1400,7 @@ function CreateInstanceDialog({
-