Skip to content

Commit 64e81b9

Browse files
author
Erwin Dondorp
committed
hide the commandbox on page navigation, i.e. usually on automatic logout, closes #379
1 parent dcad1a3 commit 64e81b9

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

saltgui/static/scripts/CommandBox.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ export class CommandBox {
126126

127127
_registerCommandBoxEventListeners () {
128128
document.getElementById("popup-run-command").
129-
addEventListener("click", (pClickEvent) => CommandBox._hideManualRun(pClickEvent));
129+
addEventListener("click", (pClickEvent) => CommandBox.hideManualRun(pClickEvent));
130130
document.getElementById("button-manual-run").
131131
addEventListener("click", (pClickEvent) => CommandBox.showManualRun(pClickEvent, this.api));
132132
document.getElementById("cmd-close-button").
133-
addEventListener("click", (pClickEvent) => CommandBox._hideManualRun(pClickEvent));
133+
addEventListener("click", (pClickEvent) => CommandBox.hideManualRun(pClickEvent));
134134

135135
document.querySelector(".run-command input[type='submit']").
136136
addEventListener("click", () => {
@@ -315,14 +315,14 @@ export class CommandBox {
315315
TargetType.autoSelectTargetType(targetField.value);
316316
targetField.onkeyup = (keyUpEvent) => {
317317
if (keyUpEvent.key === "Escape") {
318-
CommandBox._hideManualRun(keyUpEvent);
318+
CommandBox.hideManualRun(keyUpEvent);
319319
}
320320
};
321321

322322
const commandField = document.getElementById("command");
323323
commandField.onkeyup = (keyUpEvent) => {
324324
if (keyUpEvent.key === "Escape") {
325-
CommandBox._hideManualRun(keyUpEvent);
325+
CommandBox.hideManualRun(keyUpEvent);
326326
}
327327
};
328328

@@ -369,9 +369,9 @@ export class CommandBox {
369369
// pEvent is:
370370
// a MouseEvent(type="click") or
371371
// a KeyEvent(type="keyup")
372-
static _hideManualRun (pEvent) {
372+
static hideManualRun (pEvent) {
373373
// Don't close if they click inside the window
374-
if (pEvent.type === "click" && !pEvent.target.classList.contains("popup") && !pEvent.target.classList.contains("nearly-visible-button")) {
374+
if (pEvent && pEvent.type === "click" && !pEvent.target.classList.contains("popup") && !pEvent.target.classList.contains("nearly-visible-button")) {
375375
return;
376376
}
377377

@@ -382,9 +382,13 @@ export class CommandBox {
382382
RunType.setRunTypeDefault();
383383
TargetType.setTargetTypeDefault();
384384

385-
Router.currentPage.refreshPage();
385+
if (Router.currentPage) {
386+
Router.currentPage.refreshPage();
387+
}
386388

387-
pEvent.stopPropagation();
389+
if (pEvent) {
390+
pEvent.stopPropagation();
391+
}
388392
}
389393

390394
static _showError (pMessage) {

saltgui/static/scripts/Router.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ export class Router {
245245
// pForward = 2 --> back navigation using browser
246246
goTo (pHash, pQuery = {}, pForward = 0) {
247247

248+
// close the command-box when it is stil open
249+
CommandBox.hideManualRun(null);
250+
248251
if (pHash !== "login" && Utils.getStorageItem("session", "login-response") === null) {
249252
// the fact that we don't have a session will be caught later
250253
// but this was shows less error messages on the console

0 commit comments

Comments
 (0)