Skip to content

Commit 18d44fa

Browse files
author
Erwin Dondorp
committed
fine-tuned change detection for command-box
1 parent 7b172fe commit 18d44fa

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

saltgui/static/scripts/CommandBox.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,18 @@ export class CommandBox {
295295
CommandBox.applyTemplateByTemplate(template);
296296
}
297297

298+
static getReadOnlyScreens () {
299+
return [
300+
"events",
301+
"options",
302+
"reactors",
303+
"templates"
304+
];
305+
}
306+
298307
static getScreenModifyingCommands () {
308+
// commands marked with "*" can change any page
309+
// read-only screens are already filtered out
299310
return {
300311
"beacons.add": ["beacons", "beacons-minion"],
301312
"beacons.delete": ["beacons", "beacons-minion"],
@@ -323,9 +334,9 @@ export class CommandBox {
323334
"schedule.enable_job": ["schedules-minion", "issues"],
324335
"schedule.modify": ["schedules", "schedules-minion"],
325336
"schedule.run_job": ["*"],
326-
"state.apply": ["highstate"],
327-
"state.highstate": ["highstate"],
328-
"state.sls_id": ["issues"]
337+
"state.apply": ["*"],
338+
"state.highstate": ["*"],
339+
"state.sls_id": ["*"]
329340
};
330341
}
331342

@@ -361,18 +372,19 @@ export class CommandBox {
361372
button.disabled = true;
362373
output.innerText = "loading" + Character.HORIZONTAL_ELLIPSIS;
363374

375+
const readOnlyScreens = CommandBox.getReadOnlyScreens();
364376
const screenModifyingCommands = CommandBox.getScreenModifyingCommands();
365377
// test whether the command may have caused an update to the list
366378
const command = commandValue.split(" ")[0];
367379
if (command in screenModifyingCommands) {
368380
// update panel when it may have changed
369381
for (const panel of Router.currentPage.panels) {
370-
if (screenModifyingCommands[command].indexOf(panel.key) >= 0) {
371-
// Arrays.includes() is only available from ES7/2016
382+
if (readOnlyScreens.includes(panel.key)) {
383+
// nothing changed on this screen
384+
} else if (screenModifyingCommands[command].includes(panel.key)) {
372385
// the command may have changed a specific panel
373386
panel.needsRefresh = true;
374-
} else if (screenModifyingCommands[command].indexOf("*") >= 0) {
375-
// Arrays.includes() is only available from ES7/2016
387+
} else if (screenModifyingCommands[command].includes("*")) {
376388
// the command may have changed any panel
377389
panel.needsRefresh = true;
378390
}

0 commit comments

Comments
 (0)