feat(topology): hide Ansible Automation section when Semaphore is disabled
This commit is contained in:
@ -272,6 +272,7 @@ async function startServer() {
|
|||||||
azureEnabled: enabled && Boolean(clientId) && Boolean(tenantId) && Boolean(secret),
|
azureEnabled: enabled && Boolean(clientId) && Boolean(tenantId) && Boolean(secret),
|
||||||
effectiveRedirectUri,
|
effectiveRedirectUri,
|
||||||
checkmkEnabled: getSetting('checkmk_enabled') === 'true',
|
checkmkEnabled: getSetting('checkmk_enabled') === 'true',
|
||||||
|
semaphoreEnabled: getSetting('semaphore_enabled') === 'true',
|
||||||
checkmkBaseUrl: cmkApiUrl.replace(/\/api\/.*$/, ''),
|
checkmkBaseUrl: cmkApiUrl.replace(/\/api\/.*$/, ''),
|
||||||
isProduction: IS_PRODUCTION,
|
isProduction: IS_PRODUCTION,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -56,6 +56,7 @@ export default function App() {
|
|||||||
const [checkmkEnabled, setCheckmkEnabled] = useState(false);
|
const [checkmkEnabled, setCheckmkEnabled] = useState(false);
|
||||||
const [checkmkBaseUrl, setCheckmkBaseUrl] = useState('');
|
const [checkmkBaseUrl, setCheckmkBaseUrl] = useState('');
|
||||||
const [isProduction, setIsProduction] = useState(false);
|
const [isProduction, setIsProduction] = useState(false);
|
||||||
|
const [semaphoreEnabled, setSemaphoreEnabled] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const root = document.documentElement;
|
const root = document.documentElement;
|
||||||
@ -144,7 +145,7 @@ export default function App() {
|
|||||||
if (bookingsRes.ok) setBookings(await bookingsRes.json());
|
if (bookingsRes.ok) setBookings(await bookingsRes.json());
|
||||||
if (logsRes.ok) setLogs(await logsRes.json());
|
if (logsRes.ok) setLogs(await logsRes.json());
|
||||||
if (linksRes.ok) setLinks(await linksRes.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) {
|
} catch (err) {
|
||||||
console.error('[App] Failed to load data:', err);
|
console.error('[App] Failed to load data:', err);
|
||||||
} finally {
|
} finally {
|
||||||
@ -609,6 +610,7 @@ export default function App() {
|
|||||||
labs={labs}
|
labs={labs}
|
||||||
devices={devices}
|
devices={devices}
|
||||||
currentUser={currentUser!}
|
currentUser={currentUser!}
|
||||||
|
semaphoreEnabled={semaphoreEnabled}
|
||||||
onAddLab={handleAddLab}
|
onAddLab={handleAddLab}
|
||||||
onUpdateLab={handleUpdateLab}
|
onUpdateLab={handleUpdateLab}
|
||||||
onDeleteLab={handleDeleteLab}
|
onDeleteLab={handleDeleteLab}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ interface LabTemplatesProps {
|
|||||||
labs: LabTemplate[];
|
labs: LabTemplate[];
|
||||||
devices: Device[];
|
devices: Device[];
|
||||||
currentUser: User;
|
currentUser: User;
|
||||||
|
semaphoreEnabled: boolean;
|
||||||
onAddLab: (lab: Omit<LabTemplate, 'id' | 'ownerId'>) => void;
|
onAddLab: (lab: Omit<LabTemplate, 'id' | 'ownerId'>) => void;
|
||||||
onUpdateLab: (lab: LabTemplate) => void;
|
onUpdateLab: (lab: LabTemplate) => void;
|
||||||
onDeleteLab: (id: string) => void;
|
onDeleteLab: (id: string) => void;
|
||||||
@ -25,6 +26,7 @@ export default function LabTemplates({
|
|||||||
labs,
|
labs,
|
||||||
devices,
|
devices,
|
||||||
currentUser,
|
currentUser,
|
||||||
|
semaphoreEnabled,
|
||||||
onAddLab,
|
onAddLab,
|
||||||
onUpdateLab,
|
onUpdateLab,
|
||||||
onDeleteLab,
|
onDeleteLab,
|
||||||
@ -614,7 +616,7 @@ export default function LabTemplates({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Ansible Semaphore Automation */}
|
{/* Ansible Semaphore Automation */}
|
||||||
<div className="border-t border-slate-800 pt-3">
|
{semaphoreEnabled && <div className="border-t border-slate-800 pt-3">
|
||||||
<label className="block text-slate-300 font-bold mb-1.5 flex items-center gap-1.5">
|
<label className="block text-slate-300 font-bold mb-1.5 flex items-center gap-1.5">
|
||||||
<Terminal className="w-3.5 h-3.5 text-orange-400" />
|
<Terminal className="w-3.5 h-3.5 text-orange-400" />
|
||||||
3. Ansible Automation (optional)
|
3. Ansible Automation (optional)
|
||||||
@ -642,7 +644,7 @@ export default function LabTemplates({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>}
|
||||||
|
|
||||||
{/* Form submit handlers */}
|
{/* Form submit handlers */}
|
||||||
<div className="pt-3 border-t border-slate-800 flex justify-end gap-2.5">
|
<div className="pt-3 border-t border-slate-800 flex justify-end gap-2.5">
|
||||||
|
|||||||
Reference in New Issue
Block a user