Skip to content

Commit ffbc3ef

Browse files
author
Erwin Dondorp
committed
upgrade to ES2017
1 parent c3daa37 commit ffbc3ef

7 files changed

Lines changed: 15 additions & 31 deletions

File tree

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SaltGUI
22

3-
SaltGUI is an open source web interface for managing a SaltStack server and its minions. Built using plain ES2016 and implemented as a wrapper around the rest_cherrypy server a.k.a. salt-api.
3+
SaltGUI is an open source web interface for managing a SaltStack server and its minions. Built using plain ES2017 and implemented as a wrapper around the rest_cherrypy server a.k.a. salt-api.
44

55
**Security Note**: For production deployments, TLS encryption is strongly recommended. See [TLS Configuration](#tls-configuration) for complete setup instructions.
66

saltgui/static/scripts/output/OutputDocumentation.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ export class OutputDocumentation {
5858
// reduce the search key to match the data in the response
5959
const commandArg = OutputDocumentation._reduceFilterKey(pCommandArg);
6060

61-
for (const minionId of Object.keys(pResponse)) {
62-
63-
const output = pResponse[minionId];
61+
for (const output of Object.values(pResponse)) {
6462

6563
if (!output) {
6664
// some commands do not have help-text
@@ -79,14 +77,14 @@ export class OutputDocumentation {
7977
return false;
8078
}
8179

82-
for (const key of Object.keys(output)) {
80+
for (const [key,out] of Object.entries(output)) {
8381
// e.g. for "test.rand_str"
84-
if (output[key] === null) {
82+
if (out === null) {
8583
continue;
8684
}
8785

8886
// but otherwise it must be a (documentation)string
89-
if (typeof output[key] !== "string") {
87+
if (typeof out !== "string") {
9088
return false;
9189
}
9290

@@ -147,7 +145,7 @@ export class OutputDocumentation {
147145
pFilterKey = OutputDocumentation._reduceFilterKey(pFilterKey);
148146

149147
let selectedMinion = null;
150-
for (const minionId of Object.keys(pResponse)) {
148+
for (const [minionId,minionResponse] of Object.entries(pResponse)) {
151149

152150
// When we already found the documentation ignore all others
153151
if (selectedMinion) {
@@ -157,15 +155,14 @@ export class OutputDocumentation {
157155

158156
// make sure it is an object (instead of e.g. "false" for an offline minion)
159157
// when it is not, the whole entry is ignored
160-
if (!pResponse[minionId] || typeof pResponse[minionId] !== "object") {
158+
if (!minionResponse || typeof minionResponse !== "object") {
161159
delete pResponse[minionId];
162160
continue;
163161
}
164162

165163
// make sure that the entry matches with the requested command or prefix
166164
// that's always the case for SYS.DOC output, but not for RUNNERS.DOC.RUNNER
167165
// and/or RUNNERS.DOC.WHEEL.
168-
const minionResponse = pResponse[minionId];
169166
for (const key of Object.keys(minionResponse)) {
170167

171168
// is this what we were looking for?
@@ -205,13 +202,10 @@ export class OutputDocumentation {
205202

206203
// we expect no minionIds present
207204
// as it should have been reduced already
208-
for (const minionId of Object.keys(pResponse)) {
209-
210-
const minionResponse = pResponse[minionId];
205+
for (const minionResponse of Object.values(pResponse)) {
211206

212-
for (const key of Object.keys(minionResponse).sort()) {
207+
for (let [key,out] of Object.entries(minionResponse).sort()) {
213208

214-
let out = minionResponse[key];
215209
if (out === null) {
216210
continue;
217211
}

saltgui/static/scripts/output/OutputHighstate.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ export class OutputHighstate {
4646
static getHighStateLabel (pMinionId, pMinionResponse) {
4747
let anyFailures = false;
4848
let anySkips = false;
49-
// do not use Object.entries, that is not supported by the test framework as it is ES8/2017
50-
for (const taskKey of Object.keys(pMinionResponse)) {
51-
const task = pMinionResponse[taskKey];
49+
for (const task of Object.values(pMinionResponse)) {
5250
if (task.result === null) {
5351
anySkips = true;
5452
} else if (!task.result) {

saltgui/static/scripts/output/OutputHighstateTaskSaltGui.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ export class OutputHighstateTaskSaltGui {
148148
}
149149

150150
// show any unknown attribute of a task
151-
// do not use Object.entries, that is not supported by the test framework as it is ES8/2017
152-
for (const key of Object.keys(pTask)) {
153-
const item = pTask[key];
151+
for (const [key,item] of Object.entries(pTask)) {
154152
/* eslint-disable line-comment-position,no-inline-comments,curly */
155153
if (key === "___key___") continue; // ignored, generated by us
156154
if (key === "__id__") continue; // handled

saltgui/static/scripts/output/OutputJson.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export class OutputJson {
4444
return "{ }";
4545
}
4646

47-
// do not use Object.values as eslint does understand that because it is ES8/2017
4847
if (!Array.isArray(pValue) && Object.keys(pValue).length === 1 && typeof pValue[Object.keys(pValue)[0]] !== "object") {
4948
// show the brackets for a simple object a bit wider apart
5049
return "{ " + JSON.stringify(Object.keys(pValue)[0]) + ": " + JSON.stringify(pValue[Object.keys(pValue)[0]]) + " }";
@@ -83,7 +82,6 @@ export class OutputJson {
8382
// put each name+value on its own line
8483
str = "{";
8584
let oSeparator = "";
86-
// do not use Object.entries, that is not supported by the test framework as it is ES8/2017
8785
const sortedKeys = Object.keys(pValue).sort((aa, bb) => aa.localeCompare(bb, "en", {"numeric": true}));
8886
for (const key of sortedKeys) {
8987
const item = pValue[key];

saltgui/static/scripts/panels/Keys.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,10 @@ export class KeysPanel extends Panel {
117117

118118
const allKeys = pWheelKeyFingerData.return[0].data.return;
119119

120-
for (const property of Object.keys(allKeys)) {
120+
for (const [property,hosts] of Object.entries(allKeys)) {
121121
if (property === "local") {
122122
continue;
123123
}
124-
const hosts = allKeys[property];
125124
for (const minionId of Object.keys(hosts)) {
126125
const item = this.table.querySelector("#" + Utils.getIdFromMinionId(minionId) + " .os");
127126
if (item) {

saltgui/static/scripts/panels/Orchestrations.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,11 @@ export class OrchestrationsPanel extends Panel {
6666
for (const key of Object.keys(orchestrations)) {
6767
keys[orchestrations[key].__sls__] = [];
6868
}
69-
for (const key of Object.keys(orchestrations)) {
70-
const orchestration = orchestrations[key];
69+
for (const [key,orchestration] of Object.entries(orchestrations)) {
7170
keys[orchestration.__sls__][key] = orchestration;
7271
}
7372
let nrOrchestrations = 0;
74-
for (const key of Object.keys(keys).sort()) {
75-
const orchestration = keys[key];
73+
for (const [key,orchestration] of Object.entries(keys).sort()) {
7674
if (this._addOrchestration(key, orchestration)) {
7775
nrOrchestrations += 1;
7876
}
@@ -87,8 +85,7 @@ export class OrchestrationsPanel extends Panel {
8785

8886
const steps = [];
8987
let ok = false;
90-
for (const name of Object.keys(pOrchestrations)) {
91-
const step = pOrchestrations[name];
88+
for (const [name,step] of Object.entries(pOrchestrations)) {
9289
// add key-name to object itself
9390
step.__key__ = name;
9491
const salt = step.salt || [];

0 commit comments

Comments
 (0)