Skip to content

Commit 647c86f

Browse files
committed
Upgrade dependencies
1 parent ad7d5e0 commit 647c86f

File tree

5 files changed

+2132
-2934
lines changed

5 files changed

+2132
-2934
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@testing-library/jest-dom": "5.4.0",
2020
"@testing-library/react": "^10.0.2",
2121
"@types/jsonpath": "^0.2.0",
22-
"@types/lodash": "latest",
22+
"@types/lodash": "^4.14.168",
2323
"@types/memory-cache": "^0.2.1",
2424
"@types/react-virtualized-auto-sizer": "^1.0.0",
2525
"react-virtualized-auto-sizer": "^1.0.4"

src/components/KeyValueEditor.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ export const KeyValueEditor = ({ columns, values, onChange, addRowLabel, onBlur
5656
<table className={styles.root}>
5757
<thead className={styles.thead}>
5858
<tr className={styles.row}>
59-
{columns.map(_ => (
60-
<th className={styles.th}>{_}</th>
59+
{columns.map((_, key) => (
60+
<th key={key} className={styles.th}>
61+
{_}
62+
</th>
6163
))}
6264
<th className={styles.th}></th>
6365
</tr>
@@ -69,7 +71,7 @@ export const KeyValueEditor = ({ columns, values, onChange, addRowLabel, onBlur
6971
<td key={colIdx} className={styles.td}>
7072
<input
7173
value={cell}
72-
onChange={e => updateCell(colIdx, rowIdx, e.currentTarget.value)}
74+
onChange={(e) => updateCell(colIdx, rowIdx, e.currentTarget.value)}
7375
onBlur={onBlur}
7476
className={styles.input}
7577
/>

src/components/QueryEditor.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ export const QueryEditor: React.FC<Props> = ({ onRunQuery, onChange, query, limi
157157
{ label: 'GET', value: 'GET' },
158158
{ label: 'POST', value: 'POST' },
159159
]}
160-
onChange={v => onMethodChange(v.value ?? 'GET')}
160+
onChange={(v) => onMethodChange(v.value ?? 'GET')}
161161
/>
162162
</InlineField>
163163
<InlineField grow>
164164
<Input
165165
placeholder="/orders/${orderId}"
166166
value={query.urlPath}
167-
onChange={e => onChange({ ...query, urlPath: e.currentTarget.value })}
167+
onChange={(e) => onChange({ ...query, urlPath: e.currentTarget.value })}
168168
/>
169169
</InlineField>
170170
</InlineFieldRow>
@@ -202,7 +202,7 @@ export const QueryEditor: React.FC<Props> = ({ onRunQuery, onChange, query, limi
202202
<InlineField label="Syntax highlighting">
203203
<RadioButtonGroup
204204
value={bodyType}
205-
onChange={v => setBodyType(v ?? 'plaintext')}
205+
onChange={(v) => setBodyType(v ?? 'plaintext')}
206206
options={[
207207
{ label: 'Text', value: 'plaintext' },
208208
{ label: 'JSON', value: 'json' },
@@ -244,7 +244,7 @@ export const QueryEditor: React.FC<Props> = ({ onRunQuery, onChange, query, limi
244244
<InlineFieldRow>
245245
<InlineField>
246246
<RadioButtonGroup
247-
onChange={e => setTabIndex(e ?? 0)}
247+
onChange={(e) => setTabIndex(e ?? 0)}
248248
value={tabIndex}
249249
options={tabs.map((tab, idx) => ({ label: tab.title, value: idx }))}
250250
/>
@@ -255,7 +255,7 @@ export const QueryEditor: React.FC<Props> = ({ onRunQuery, onChange, query, limi
255255
>
256256
<Segment
257257
value={{ label: formatCacheTimeLabel(query.cacheDurationSeconds), value: query.cacheDurationSeconds }}
258-
options={[0, 5, 10, 30, 60, 60 * 2, 60 * 5, 60 * 10, 60 * 30, 3600, 3600 * 2, 3600 * 5].map(value => ({
258+
options={[0, 5, 10, 30, 60, 60 * 2, 60 * 5, 60 * 10, 60 * 30, 3600, 3600 * 2, 3600 * 5].map((value) => ({
259259
label: formatCacheTimeLabel(value),
260260
value,
261261
description: value ? '' : 'Response is not cached at all',
@@ -265,12 +265,15 @@ export const QueryEditor: React.FC<Props> = ({ onRunQuery, onChange, query, limi
265265
</InlineField>
266266
</InlineFieldRow>
267267
{query.method === 'GET' && query.body && (
268-
<InfoBox severity="warning">GET requests can't have a body. The body you've defined will be ignored.</InfoBox>
268+
<InfoBox severity="warning">
269+
{"GET requests can't have a body. The body you've defined will be ignored."}
270+
</InfoBox>
269271
)}
270-
{(query.headers ?? []).map(([key, _]) => key.toLowerCase()).find(_ => sensitiveHeaders.includes(_)) && (
272+
{(query.headers ?? []).map(([key, _]) => key.toLowerCase()).find((_) => sensitiveHeaders.includes(_)) && (
271273
<InfoBox severity="warning">
272-
It looks like you're adding credentials in the header. Since queries are stored unencrypted, it's strongly
273-
recommended that you add any secrets to the data source config instead.
274+
{
275+
"It looks like you're adding credentials in the header. Since queries are stored unencrypted, it's strongly recommended that you add any secrets to the data source config instead."
276+
}
274277
</InfoBox>
275278
)}
276279
{tabs[tabIndex].content}

src/datasource.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ export class DataSource extends DataSourceApi<JsonApiQuery, JsonApiDataSourceOpt
2727
}
2828

2929
async query(request: DataQueryRequest<JsonApiQuery>): Promise<DataQueryResponse> {
30-
const promises = request.targets.map(query => this.doRequest(query, request.range, request.scopedVars));
30+
const promises = request.targets.map((query) => this.doRequest(query, request.range, request.scopedVars));
3131

3232
// Wait for all queries to finish before returning the result.
33-
return Promise.all(promises).then(data => ({ data }));
33+
return Promise.all(promises).then((data) => ({ data }));
3434
}
3535

3636
/**
@@ -40,7 +40,7 @@ export class DataSource extends DataSourceApi<JsonApiQuery, JsonApiDataSourceOpt
4040
*/
4141
async metricFindQuery?(query: JsonApiQuery): Promise<MetricFindValue[]> {
4242
const frame = await this.doRequest(query);
43-
return frame.fields[0].values.toArray().map(_ => ({ text: _ }));
43+
return frame.fields[0].values.toArray().map((_) => ({ text: _ }));
4444
}
4545

4646
/**
@@ -124,8 +124,8 @@ export class DataSource extends DataSourceApi<JsonApiQuery, JsonApiDataSourceOpt
124124
}
125125

126126
const fields = query.fields
127-
.filter(field => field.jsonPath)
128-
.map(field => {
127+
.filter((field) => field.jsonPath)
128+
.map((field) => {
129129
const jsonPathTreated = replaceMacros(templateSrv.replace(field.jsonPath, scopedVars));
130130
const nameTreated = templateSrv.replace(field.name, scopedVars);
131131

@@ -146,7 +146,7 @@ export class DataSource extends DataSourceApi<JsonApiQuery, JsonApiDataSourceOpt
146146
};
147147
});
148148

149-
const fieldLengths = fields.map(field => field.values.length);
149+
const fieldLengths = fields.map((field) => field.values.length);
150150
const uniqueFieldLengths = Array.from(new Set(fieldLengths)).length;
151151

152152
// All fields need to have the same length for the data frame to be valid.
@@ -167,20 +167,20 @@ export class DataSource extends DataSourceApi<JsonApiQuery, JsonApiDataSourceOpt
167167
*/
168168
export const detectFieldType = (values: any[]): FieldType => {
169169
// If all values are null, default to strings.
170-
if (values.every(_ => _ === null)) {
170+
if (values.every((_) => _ === null)) {
171171
return FieldType.string;
172172
}
173173

174174
// If all values are valid ISO 8601, then assume that it's a time field.
175175
const isValidISO = values
176-
.filter(value => value !== null)
177-
.every(value => value.length >= 10 && isValid(parseISO(value)));
176+
.filter((value) => value !== null)
177+
.every((value) => value.length >= 10 && isValid(parseISO(value)));
178178
if (isValidISO) {
179179
return FieldType.time;
180180
}
181181

182-
if (values.every(value => typeof value === 'number')) {
183-
const uniqueLengths = Array.from(new Set(values.map(value => Math.round(value).toString().length)));
182+
if (values.every((value) => typeof value === 'number')) {
183+
const uniqueLengths = Array.from(new Set(values.map((value) => Math.round(value).toString().length)));
184184
const hasSameLength = uniqueLengths.length === 1;
185185

186186
// If all the values have the same length of either 10 (seconds) or 13
@@ -198,7 +198,7 @@ export const detectFieldType = (values: any[]): FieldType => {
198198
return FieldType.number;
199199
}
200200

201-
if (values.every(value => typeof value === 'boolean')) {
201+
if (values.every((value) => typeof value === 'boolean')) {
202202
return FieldType.boolean;
203203
}
204204

@@ -214,16 +214,16 @@ export const parseValues = (values: any[], type: FieldType): any[] => {
214214
// For time field, values are expected to be numbers representing a Unix
215215
// epoch in milliseconds.
216216

217-
if (values.filter(_ => _).every(value => typeof value === 'string')) {
218-
return values.map(_ => (_ !== null ? parseISO(_).valueOf() : _));
217+
if (values.filter((_) => _).every((value) => typeof value === 'string')) {
218+
return values.map((_) => (_ !== null ? parseISO(_).valueOf() : _));
219219
}
220220

221-
if (values.filter(_ => _).every(value => typeof value === 'number')) {
221+
if (values.filter((_) => _).every((value) => typeof value === 'number')) {
222222
const ms = 1_000_000_000_000;
223223

224224
// If there are no "big" numbers, assume seconds.
225-
if (values.filter(_ => _).every(_ => _ < ms)) {
226-
return values.map(_ => (_ !== null ? _ * 1000.0 : _));
225+
if (values.filter((_) => _).every((_) => _ < ms)) {
226+
return values.map((_) => (_ !== null ? _ * 1000.0 : _));
227227
}
228228

229229
// ... otherwise assume milliseconds.
@@ -232,13 +232,13 @@ export const parseValues = (values: any[], type: FieldType): any[] => {
232232

233233
throw new Error('Unsupported time property');
234234
case FieldType.string:
235-
return values.every(_ => typeof _ === 'string') ? values : values.map(_ => (_ !== null ? _.toString() : _));
235+
return values.every((_) => typeof _ === 'string') ? values : values.map((_) => (_ !== null ? _.toString() : _));
236236
case FieldType.number:
237-
return values.every(_ => typeof _ === 'number') ? values : values.map(_ => (_ !== null ? parseFloat(_) : _));
237+
return values.every((_) => typeof _ === 'number') ? values : values.map((_) => (_ !== null ? parseFloat(_) : _));
238238
case FieldType.boolean:
239-
return values.every(_ => typeof _ === 'boolean')
239+
return values.every((_) => typeof _ === 'boolean')
240240
? values
241-
: values.map(_ => {
241+
: values.map((_) => {
242242
if (_ === null) {
243243
return _;
244244
}

0 commit comments

Comments
 (0)