feat(ui): gate profile create/clone/delete to edit mode
Made-with: Cursor
This commit is contained in:
@@ -11,8 +11,22 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
return;
|
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 = () => {
|
const openModal = () => {
|
||||||
profilesModal.classList.add("active");
|
profilesModal.classList.add("active");
|
||||||
|
updateProfileEditorControlsVisibility();
|
||||||
loadProfiles();
|
loadProfiles();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,6 +68,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const editMode = isEditModeActive();
|
||||||
entries.forEach(([profileId, profile]) => {
|
entries.forEach(([profileId, profile]) => {
|
||||||
const row = document.createElement("div");
|
const row = document.createElement("div");
|
||||||
row.className = "profiles-row";
|
row.className = "profiles-row";
|
||||||
@@ -161,8 +176,10 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
|
|
||||||
row.appendChild(label);
|
row.appendChild(label);
|
||||||
row.appendChild(applyButton);
|
row.appendChild(applyButton);
|
||||||
|
if (editMode) {
|
||||||
row.appendChild(cloneButton);
|
row.appendChild(cloneButton);
|
||||||
row.appendChild(deleteButton);
|
row.appendChild(deleteButton);
|
||||||
|
}
|
||||||
profilesList.appendChild(row);
|
profilesList.appendChild(row);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -197,6 +214,9 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const createProfile = async () => {
|
const createProfile = async () => {
|
||||||
|
if (!isEditModeActive()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!newProfileInput) {
|
if (!newProfileInput) {
|
||||||
return;
|
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) => {
|
profilesModal.addEventListener("click", (event) => {
|
||||||
if (event.target === profilesModal) {
|
if (event.target === profilesModal) {
|
||||||
closeModal();
|
closeModal();
|
||||||
|
|||||||
Reference in New Issue
Block a user