Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make runtype switch from "normal" to "async" a sticky setting #536

Merged
merged 9 commits into from
Aug 16, 2023
4 changes: 3 additions & 1 deletion saltgui/static/scripts/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ export class API {
}

static _cleanStorage () {
// clear local storage except key 'eauth'
// clear local storage except key 'eauth' and 'runtype'
const eauth = Utils.getStorageItem("local", "eauth");
const runtype = Utils.getStorageItem("local", "runtype");
Utils.clearStorage("local");
Utils.setStorageItem("local", "eauth", eauth);
Utils.setStorageItem("local", "runtype", runtype);

spankywetfish marked this conversation as resolved.
Show resolved Hide resolved
// clear all of session storage
Utils.clearStorage("session");
Expand Down
14 changes: 11 additions & 3 deletions saltgui/static/scripts/RunType.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export class RunType {
Utils.error("runType", runType);
}

// Store last used runType
Utils.setStorageItem("local", "runtype", runType);

const menuItems = RunType.menuRunType.menuDropdownContent.children;
for (const menuItem of menuItems) {
let menuItemText = menuItem.innerText;
Expand All @@ -43,17 +46,22 @@ export class RunType {
}

static setRunTypeDefault () {
RunType.menuRunType._value = "normal";
// Retrieve last used runType
let runType = Utils.getStorageItem("local", "runtype");
// Set default if previous runtype not stored
if (runType !== "normal" && runType !== "async") {
runType = "normal";
}
RunType._updateRunTypeText();
// reset the title to the absolute minimum
// so that the menu does not stand out in trivial situations
RunType.menuRunType.setTitle("");
}

static getRunType () {
const runType = RunType.menuRunType._value;
let runType = RunType.menuRunType._value;
if (runType === undefined || runType === "") {
return "normal";
runType = Utils.getStorageItem("local", "runtype", "normal");
}
return runType;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when a page-refresh is done, all GUI values are unavoidably lost.
this function would then reset the value to "normal" and also save it.

  • saving the value should only be done in function _updateRunTypeText, as that is the callback function from the dropdownlist.
  • instead of runType = "normal", the saved value should be retrieved: runType = Utils.getStorageItem("local", "runtype", "normal"); (which itself will have a default of 'normal')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to _updateRunTypeText, and suggested modification for retrieval applied, all tested and linted.

}
Expand Down