Skip to content

Commit c9ae585

Browse files
committed
Merge branch '12918-no-conditional-assignment'
2 parents 00c0b71 + dc236b5 commit c9ae585

File tree

11 files changed

+38
-17
lines changed

11 files changed

+38
-17
lines changed

public/app/containers/Explore/utils/dom.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ if ('Element' in window && !Element.prototype.closest) {
99
i = matches.length;
1010
// eslint-disable-next-line
1111
while (--i >= 0 && matches.item(i) !== el) {}
12-
} while (i < 0 && (el = el.parentElement));
12+
el = el.parentElement;
13+
} while (i < 0 && el);
1314
return el;
1415
};
1516
}

public/app/core/components/search/search.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ export class SearchCtrl {
130130
}
131131

132132
const max = flattenedResult.length;
133-
let newIndex = this.selectedIndex + direction;
134-
this.selectedIndex = (newIndex %= max) < 0 ? newIndex + max : newIndex;
133+
const newIndex = (this.selectedIndex + direction) % max;
134+
this.selectedIndex = newIndex < 0 ? newIndex + max : newIndex;
135135
const selectedItem = flattenedResult[this.selectedIndex];
136136

137137
if (selectedItem.dashboardIndex === undefined && this.results[selectedItem.folderIndex].id === 0) {

public/app/core/directives/rebuild_on_change.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ function getBlockNodes(nodes) {
55
let node = nodes[0];
66
const endNode = nodes[nodes.length - 1];
77
let blockNodes;
8+
node = node.nextSibling;
89

9-
for (let i = 1; node !== endNode && (node = node.nextSibling); i++) {
10+
for (let i = 1; node !== endNode && node; i++) {
1011
if (blockNodes || nodes[i] !== node) {
1112
if (!blockNodes) {
1213
blockNodes = $([].slice.call(nodes, 0, i));
1314
}
1415
blockNodes.push(node);
1516
}
17+
node = node.nextSibling;
1618
}
1719

1820
return blockNodes || nodes;

public/app/features/dashboard/dashboard_import_ctrl.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _ from 'lodash';
22
import config from 'app/core/config';
3+
import locationUtil from 'app/core/utils/location_util';
34

45
export class DashboardImportCtrl {
56
navModel: any;
@@ -179,7 +180,8 @@ export class DashboardImportCtrl {
179180
folderId: this.folderId,
180181
})
181182
.then(res => {
182-
this.$location.url(res.importedUrl);
183+
const dashUrl = locationUtil.stripBaseFromUrl(res.importedUrl);
184+
this.$location.url(dashUrl);
183185
});
184186
}
185187

public/app/features/dashboard/upload.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
3636
};
3737
};
3838

39-
for (let i = 0, f; (f = files[i]); i++) {
39+
let i = 0;
40+
let file = files[i];
41+
42+
while (file) {
4043
const reader = new FileReader();
4144
reader.onload = readerOnload();
42-
reader.readAsText(f);
45+
reader.readAsText(file);
46+
i += 1;
47+
file = files[i];
4348
}
4449
}
4550

public/app/plugins/datasource/graphite/datasource.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
218218
if (matches) {
219219
const expressions = [];
220220
const exprRegex = /, *([^,]+)/g;
221-
let match;
222-
while ((match = exprRegex.exec(matches[2])) !== null) {
221+
let match = exprRegex.exec(matches[2]);
222+
while (match !== null) {
223223
expressions.push(match[1]);
224+
match = exprRegex.exec(matches[2]);
224225
}
225226
options.limit = 10000;
226227
return this.getTagValuesAutoComplete(expressions, matches[1], undefined, options);
@@ -233,9 +234,10 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
233234
if (matches[1]) {
234235
expressions.push(matches[1]);
235236
const exprRegex = /, *([^,]+)/g;
236-
let match;
237-
while ((match = exprRegex.exec(matches[2])) !== null) {
237+
let match = exprRegex.exec(matches[2]);
238+
while (match !== null) {
238239
expressions.push(match[1]);
240+
match = exprRegex.exec(matches[2]);
239241
}
240242
}
241243
options.limit = 10000;

public/app/plugins/datasource/graphite/lexer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -941,9 +941,10 @@ Lexer.prototype = {
941941

942942
tokenize: function() {
943943
const list = [];
944-
let token;
945-
while ((token = this.next())) {
944+
let token = this.next();
945+
while (token) {
946946
list.push(token);
947+
token = this.next();
947948
}
948949
return list;
949950
},

public/app/plugins/datasource/logging/result_transformer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ export function getSearchMatches(line: string, search: string) {
2626
}
2727
const regexp = new RegExp(`(?:${search})`, 'g');
2828
const matches = [];
29-
let match;
30-
while ((match = regexp.exec(line))) {
29+
let match = regexp.exec(line);
30+
while (match) {
3131
matches.push({
3232
text: match[0],
3333
start: match.index,
3434
length: match[0].length,
3535
});
36+
match = regexp.exec(line);
3637
}
3738
return matches;
3839
}

public/app/plugins/datasource/prometheus/datasource.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ export function addLabelToQuery(query: string, key: string, value: string): stri
5555

5656
// Adding label to existing selectors
5757
const selectorRegexp = /{([^{]*)}/g;
58-
let match = null;
58+
let match = selectorRegexp.exec(query);
5959
const parts = [];
6060
let lastIndex = 0;
6161
let suffix = '';
62-
while ((match = selectorRegexp.exec(query))) {
62+
63+
while (match) {
6364
const prefix = query.slice(lastIndex, match.index);
6465
const selectorParts = match[1].split(',');
6566
const labels = selectorParts.reduce((acc, label) => {
@@ -77,6 +78,7 @@ export function addLabelToQuery(query: string, key: string, value: string): stri
7778
lastIndex = match.index + match[1].length + 2;
7879
suffix = query.slice(match.index + match[0].length);
7980
parts.push(prefix, '{', selector, '}');
81+
match = selectorRegexp.exec(query);
8082
}
8183
parts.push(suffix);
8284
return parts.join('');

public/sass/components/_search.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@
192192
&:hover,
193193
&.selected {
194194
background: $list-item-hover-bg;
195+
196+
.search-item__body-title {
197+
color: $text-color-strong;
198+
}
195199
}
196200
}
197201

0 commit comments

Comments
 (0)