Skip to content

Commit

Permalink
chore: disable remove if not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Nov 22, 2024
1 parent 67dad93 commit eadc53b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions static/manifest-gui.css
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ button#reset-to-default:active::before {
content: "♻️♻️♻️♻️♻️";
}

button#remove.disabled {
background-color: #303030;
color: #808080;
cursor: not-allowed;
opacity: 0.5;
pointer-events: none;
}

button#remove::before {
content: "−";
}
Expand Down
16 changes: 12 additions & 4 deletions static/scripts/rendering/config-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,23 @@ export function renderConfigEditor(renderer: ManifestRenderer, pluginManifest: M
});
}

const add = document.getElementById("add");
const remove = document.getElementById("remove");
const add = document.getElementById("add") as HTMLButtonElement;
const remove = document.getElementById("remove") as HTMLButtonElement;
if (!add || !remove) {
throw new Error("Add or remove button not found");
}
add.addEventListener("click", writeNewConfig.bind(null, renderer, "add"));
remove.addEventListener("click", () => writeNewConfig.bind(null, renderer, "remove"));

const resetToDefaultButton = document.getElementById("reset-to-default");
if (plugin) {
remove.disabled = false;
remove.classList.remove("disabled");
remove.addEventListener("click", () => writeNewConfig.bind(null, renderer, "remove"));
} else {
remove.disabled = true;
remove.classList.add("disabled");
}

const resetToDefaultButton = document.getElementById("reset-to-default") as HTMLButtonElement;
if (!resetToDefaultButton) {
throw new Error("Reset to default button not found");
}
Expand Down

0 comments on commit eadc53b

Please sign in to comment.