diff --git a/src/static/profiles.js b/src/static/profiles.js index fba2c77..9e6d393 100644 --- a/src/static/profiles.js +++ b/src/static/profiles.js @@ -11,8 +11,22 @@ document.addEventListener("DOMContentLoaded", () => { return; } + const isEditModeActive = () => { + const toggle = document.querySelector('.ui-mode-toggle'); + return !!(toggle && toggle.getAttribute('aria-pressed') === 'true'); + }; + + const updateProfileEditorControlsVisibility = () => { + const editMode = isEditModeActive(); + const actions = profilesModal.querySelector('.profiles-actions'); + if (actions) { + actions.style.display = editMode ? '' : 'none'; + } + }; + const openModal = () => { profilesModal.classList.add("active"); + updateProfileEditorControlsVisibility(); loadProfiles(); }; @@ -54,6 +68,7 @@ document.addEventListener("DOMContentLoaded", () => { return; } + const editMode = isEditModeActive(); entries.forEach(([profileId, profile]) => { const row = document.createElement("div"); row.className = "profiles-row"; @@ -161,8 +176,10 @@ document.addEventListener("DOMContentLoaded", () => { row.appendChild(label); row.appendChild(applyButton); - row.appendChild(cloneButton); - row.appendChild(deleteButton); + if (editMode) { + row.appendChild(cloneButton); + row.appendChild(deleteButton); + } profilesList.appendChild(row); }); }; @@ -197,6 +214,9 @@ document.addEventListener("DOMContentLoaded", () => { }; const createProfile = async () => { + if (!isEditModeActive()) { + return; + } if (!newProfileInput) { return; } @@ -264,6 +284,16 @@ document.addEventListener("DOMContentLoaded", () => { }); } + // Keep modal controls in sync with run/edit mode. + document.querySelectorAll('.ui-mode-toggle').forEach((btn) => { + btn.addEventListener('click', () => { + if (profilesModal.classList.contains('active')) { + updateProfileEditorControlsVisibility(); + loadProfiles(); + } + }); + }); + profilesModal.addEventListener("click", (event) => { if (event.target === profilesModal) { closeModal();