mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-30 21:36:57 +00:00
Remove dead always-true runnable action field
runnable was hardcoded true on every action, and only loaded+enabled capabilities ever reach the registry, so every JS === false branch was unreachable. Drop the field, its JSON, the guards, and the orphan .disabled CSS rule.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
// node vm can exercise the pure helpers (filterActions / parseId / nextSel).
|
// node vm can exercise the pure helpers (filterActions / parseId / nextSel).
|
||||||
|
|
||||||
// ---- state (populated by the C++ bridge via window.HandleStudio) ----
|
// ---- state (populated by the C++ bridge via window.HandleStudio) ----
|
||||||
var ACTIONS = []; // [{id,title,pkg,runnable,shortcut}], already frecency-sorted by C++
|
var ACTIONS = []; // [{id,title,pkg,shortcut}], already frecency-sorted by C++
|
||||||
var FAVS = []; // [id...]
|
var FAVS = []; // [id...]
|
||||||
var query = "";
|
var query = "";
|
||||||
var sel = { zone: "list", i: 0 }; // zone: 'list' | 'fav'
|
var sel = { zone: "list", i: 0 }; // zone: 'list' | 'fav'
|
||||||
@@ -69,10 +69,10 @@ function parseId(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function visibleFavourites(favourites, actions) {
|
function visibleFavourites(favourites, actions) {
|
||||||
// why: a non-runnable fav renders a dead monogram tile whose click run()s to a silent
|
// why: a fav whose id has no live action (plugin unloaded/disabled) renders a dead
|
||||||
// no-op; drop it from the quick-bar (the searchable list still shows it greyed).
|
// monogram tile whose click run()s to a silent no-op; drop it from the quick-bar.
|
||||||
var seen = {};
|
var seen = {};
|
||||||
(actions || []).forEach(function (a) { if (a.runnable !== false) seen[a.id] = true; });
|
(actions || []).forEach(function (a) { seen[a.id] = true; });
|
||||||
return (favourites || []).filter(function (id, i, arr) {
|
return (favourites || []).filter(function (id, i, arr) {
|
||||||
return seen[id] && arr.indexOf(id) === i;
|
return seen[id] && arr.indexOf(id) === i;
|
||||||
});
|
});
|
||||||
@@ -314,7 +314,7 @@ function renderList() {
|
|||||||
arr.forEach(function (a, i) {
|
arr.forEach(function (a, i) {
|
||||||
var on = FAVS.indexOf(a.id) !== -1;
|
var on = FAVS.indexOf(a.id) !== -1;
|
||||||
var row = document.createElement("div");
|
var row = document.createElement("div");
|
||||||
row.className = "row" + (sel.zone === "list" && sel.i === i ? " sel" : "") + (a.runnable === false ? " disabled" : "");
|
row.className = "row" + (sel.zone === "list" && sel.i === i ? " sel" : "");
|
||||||
row.setAttribute("aria-label", actionLabel(a, ACTIONS));
|
row.setAttribute("aria-label", actionLabel(a, ACTIONS));
|
||||||
|
|
||||||
var tile = document.createElement("div");
|
var tile = document.createElement("div");
|
||||||
@@ -345,16 +345,14 @@ function renderList() {
|
|||||||
row.appendChild(tile);
|
row.appendChild(tile);
|
||||||
row.appendChild(left);
|
row.appendChild(left);
|
||||||
|
|
||||||
if (a.runnable !== false) {
|
var star = document.createElement("button");
|
||||||
var star = document.createElement("button");
|
star.className = "star" + (on ? " on" : "");
|
||||||
star.className = "star" + (on ? " on" : "");
|
star.innerHTML = starSvg(on);
|
||||||
star.innerHTML = starSvg(on);
|
star.title = on ? "Unpin from favourites" : "Pin to favourites";
|
||||||
star.title = on ? "Unpin from favourites" : "Pin to favourites";
|
star.onclick = function (ev) { ev.stopPropagation(); toggleFav(a.id); };
|
||||||
star.onclick = function (ev) { ev.stopPropagation(); toggleFav(a.id); };
|
// why: two quick fav/unfav clicks must not dblclick-run the row
|
||||||
// why: two quick fav/unfav clicks must not dblclick-run the row
|
star.ondblclick = function (ev) { ev.stopPropagation(); };
|
||||||
star.ondblclick = function (ev) { ev.stopPropagation(); };
|
row.appendChild(star);
|
||||||
row.appendChild(star);
|
|
||||||
}
|
|
||||||
|
|
||||||
row.onclick = function () { sel = { zone: "list", i: i }; render(); };
|
row.onclick = function () { sel = { zone: "list", i: i }; render(); };
|
||||||
row.ondblclick = function () { sel = { zone: "list", i: i }; run(a); };
|
row.ondblclick = function () { sel = { zone: "list", i: i }; run(a); };
|
||||||
@@ -410,7 +408,7 @@ function toggleFav(id) {
|
|||||||
|
|
||||||
// Fire the action; C++ owns the run-confirm (native dialog) + suppression, then closes the popup + toasts.
|
// Fire the action; C++ owns the run-confirm (native dialog) + suppression, then closes the popup + toasts.
|
||||||
function run(a) {
|
function run(a) {
|
||||||
if (!a || a.runnable === false) return;
|
if (!a) return;
|
||||||
SendMessage({ command: "run_action", id: a.id, title: a.title });
|
SendMessage({ command: "run_action", id: a.id, title: a.title });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,6 @@ kbd {
|
|||||||
border: 1px solid var(--border, var(--orca-border, #ddd));
|
border: 1px solid var(--border, var(--orca-border, #ddd));
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
.row.disabled { opacity: .5; cursor: not-allowed; }
|
|
||||||
.star {
|
.star {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
width: 24px;
|
width: 24px;
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ bool ActionRegistry::make_action(const std::string& plugin_key, const std::strin
|
|||||||
out.pkg = package_name_for(plugin_key);
|
out.pkg = package_name_for(plugin_key);
|
||||||
out.plugin_key = plugin_key;
|
out.plugin_key = plugin_key;
|
||||||
out.capability = capability;
|
out.capability = capability;
|
||||||
out.runnable = true;
|
|
||||||
seed_state(out);
|
seed_state(out);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -295,7 +294,6 @@ nlohmann::json ActionRegistry::snapshot() const
|
|||||||
actions.push_back({{"id", a->id},
|
actions.push_back({{"id", a->id},
|
||||||
{"title", a->title},
|
{"title", a->title},
|
||||||
{"pkg", a->pkg},
|
{"pkg", a->pkg},
|
||||||
{"runnable", a->runnable},
|
|
||||||
{"shortcut", ""}});
|
{"shortcut", ""}});
|
||||||
// why: favourites is the ORDERED pin list - it must come from favourite_actions
|
// why: favourites is the ORDERED pin list - it must come from favourite_actions
|
||||||
// as stored, not be re-derived from the frecency-sorted actions (that would
|
// as stored, not be re-derived from the frecency-sorted actions (that would
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ struct AppAction
|
|||||||
std::string pkg; // owning package display name (row eyebrow)
|
std::string pkg; // owning package display name (row eyebrow)
|
||||||
std::string plugin_key; // weak handle: owning package
|
std::string plugin_key; // weak handle: owning package
|
||||||
std::string capability; // weak handle: capability name
|
std::string capability; // weak handle: capability name
|
||||||
bool runnable = true;
|
|
||||||
|
|
||||||
// seeded from AppConfig for the snapshot / sort:
|
// seeded from AppConfig for the snapshot / sort:
|
||||||
bool favourite = false;
|
bool favourite = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user