From e0fd19f4718bb48dccc3889e7f37e348681000fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Br=C3=BCckner?= Date: Wed, 10 Jun 2026 16:37:50 +0200 Subject: [PATCH] feat(topology): hide Ansible Automation section when Semaphore is disabled --- server.ts | 1 + src/App.tsx | 4 +++- src/components/LabTemplates.tsx | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/server.ts b/server.ts index c8b5176..5b70d01 100644 --- a/server.ts +++ b/server.ts @@ -272,6 +272,7 @@ async function startServer() { azureEnabled: enabled && Boolean(clientId) && Boolean(tenantId) && Boolean(secret), effectiveRedirectUri, checkmkEnabled: getSetting('checkmk_enabled') === 'true', + semaphoreEnabled: getSetting('semaphore_enabled') === 'true', checkmkBaseUrl: cmkApiUrl.replace(/\/api\/.*$/, ''), isProduction: IS_PRODUCTION, }); diff --git a/src/App.tsx b/src/App.tsx index 69e9803..ffc7a4c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -56,6 +56,7 @@ export default function App() { const [checkmkEnabled, setCheckmkEnabled] = useState(false); const [checkmkBaseUrl, setCheckmkBaseUrl] = useState(''); const [isProduction, setIsProduction] = useState(false); + const [semaphoreEnabled, setSemaphoreEnabled] = useState(false); useEffect(() => { const root = document.documentElement; @@ -144,7 +145,7 @@ export default function App() { if (bookingsRes.ok) setBookings(await bookingsRes.json()); if (logsRes.ok) setLogs(await logsRes.json()); if (linksRes.ok) setLinks(await linksRes.json()); - if (configRes.ok) { const cfg = await configRes.json(); setCheckmkEnabled(!!cfg.checkmkEnabled); setCheckmkBaseUrl(cfg.checkmkBaseUrl || ''); setIsProduction(!!cfg.isProduction); } + if (configRes.ok) { const cfg = await configRes.json(); setCheckmkEnabled(!!cfg.checkmkEnabled); setCheckmkBaseUrl(cfg.checkmkBaseUrl || ''); setIsProduction(!!cfg.isProduction); setSemaphoreEnabled(!!cfg.semaphoreEnabled); } } catch (err) { console.error('[App] Failed to load data:', err); } finally { @@ -609,6 +610,7 @@ export default function App() { labs={labs} devices={devices} currentUser={currentUser!} + semaphoreEnabled={semaphoreEnabled} onAddLab={handleAddLab} onUpdateLab={handleUpdateLab} onDeleteLab={handleDeleteLab} diff --git a/src/components/LabTemplates.tsx b/src/components/LabTemplates.tsx index 7a6fcf9..365c9cd 100644 --- a/src/components/LabTemplates.tsx +++ b/src/components/LabTemplates.tsx @@ -15,6 +15,7 @@ interface LabTemplatesProps { labs: LabTemplate[]; devices: Device[]; currentUser: User; + semaphoreEnabled: boolean; onAddLab: (lab: Omit) => void; onUpdateLab: (lab: LabTemplate) => void; onDeleteLab: (id: string) => void; @@ -25,6 +26,7 @@ export default function LabTemplates({ labs, devices, currentUser, + semaphoreEnabled, onAddLab, onUpdateLab, onDeleteLab, @@ -614,7 +616,7 @@ export default function LabTemplates({ {/* Ansible Semaphore Automation */} -
+ {semaphoreEnabled &&
- + } {/* Form submit handlers */}