feat(ui): gate profile create/clone/delete to edit mode

Made-with: Cursor
This commit is contained in:
2026-03-21 23:50:59 +13:00
parent 764d918d5b
commit a5432db99a

View File

@@ -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();