@perses-dev/prometheus-plugin 0.41.1 → 0.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/cjs/model/prometheus-client.js +16 -0
  2. package/dist/cjs/model/prometheus-selectors.js +1 -1
  3. package/dist/cjs/plugins/PrometheusDatasourceEditor.js +272 -186
  4. package/dist/cjs/plugins/prometheus-datasource.js +4 -0
  5. package/dist/cjs/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +88 -0
  6. package/dist/cjs/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +123 -0
  7. package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +34 -60
  8. package/dist/model/prometheus-client.d.ts +4 -0
  9. package/dist/model/prometheus-client.d.ts.map +1 -1
  10. package/dist/model/prometheus-client.js +15 -0
  11. package/dist/model/prometheus-client.js.map +1 -1
  12. package/dist/model/prometheus-selectors.js +1 -1
  13. package/dist/model/prometheus-selectors.js.map +1 -1
  14. package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +1 -1
  15. package/dist/plugins/PrometheusDatasourceEditor.js +272 -186
  16. package/dist/plugins/PrometheusDatasourceEditor.js.map +1 -1
  17. package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
  18. package/dist/plugins/prometheus-datasource.js +5 -1
  19. package/dist/plugins/prometheus-datasource.js.map +1 -1
  20. package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts +21 -0
  21. package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
  22. package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +80 -0
  23. package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js.map +1 -0
  24. package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts +21 -0
  25. package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
  26. package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +115 -0
  27. package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js.map +1 -0
  28. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
  29. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +37 -63
  30. package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  31. package/dist/plugins/types.d.ts +1 -15
  32. package/dist/plugins/types.d.ts.map +1 -1
  33. package/dist/plugins/types.js.map +1 -1
  34. package/package.json +4 -4
@@ -21,6 +21,9 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
+ healthCheck: function() {
25
+ return healthCheck;
26
+ },
24
27
  instantQuery: function() {
25
28
  return instantQuery;
26
29
  },
@@ -38,6 +41,19 @@ _export(exports, {
38
41
  }
39
42
  });
40
43
  const _core = require("@perses-dev/core");
44
+ function healthCheck(queryOptions) {
45
+ return async ()=>{
46
+ const url = `${queryOptions.datasourceUrl}/-/healthy`;
47
+ try {
48
+ const resp = await (0, _core.fetch)(url, {
49
+ headers: queryOptions.headers
50
+ });
51
+ return resp.status === 200;
52
+ } catch (e) {
53
+ return false;
54
+ }
55
+ };
56
+ }
41
57
  function instantQuery(params, queryOptions) {
42
58
  return fetchWithPost('/api/v1/query', params, queryOptions);
43
59
  }
@@ -39,7 +39,7 @@ const DEFAULT_PROM = {
39
39
  kind: PROM_DATASOURCE_KIND
40
40
  };
41
41
  function isDefaultPromSelector(selector) {
42
- return selector.name === undefined && selector.group === undefined;
42
+ return selector.name === undefined;
43
43
  }
44
44
  function isPrometheusDatasourceSelector(selector) {
45
45
  return selector.kind === PROM_DATASOURCE_KIND;
@@ -25,6 +25,7 @@ const _pluginsystem = require("@perses-dev/plugin-system");
25
25
  const _material = require("@mui/material");
26
26
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
27
27
  const _immer = require("immer");
28
+ const _reacthookform = require("react-hook-form");
28
29
  const _Minus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Minus"));
29
30
  const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
30
31
  const _types = require("./types");
@@ -73,7 +74,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
73
74
  return newObj;
74
75
  }
75
76
  function PrometheusDatasourceEditor(props) {
76
- var _value_proxy, _value_proxy1, _value_proxy2, _value_proxy3, _value_proxy4;
77
+ var _value_proxy, _value_proxy1, _value_proxy2;
77
78
  const { value , onChange , isReadonly } = props;
78
79
  const strDirect = 'Direct access';
79
80
  const strProxy = 'Proxy';
@@ -97,33 +98,17 @@ function PrometheusDatasourceEditor(props) {
97
98
  const tabs = [
98
99
  {
99
100
  label: strDirect,
100
- content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
101
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
102
- fullWidth: true,
103
- label: "URL",
104
- value: value.directUrl || '',
105
- InputProps: {
106
- readOnly: isReadonly
107
- },
108
- InputLabelProps: {
109
- shrink: isReadonly ? true : undefined
110
- },
111
- onChange: (e)=>{
112
- onChange((0, _immer.produce)(value, (draft)=>{
113
- draft.directUrl = e.target.value;
114
- }));
115
- }
116
- })
117
- })
118
- },
119
- {
120
- label: strProxy,
121
- content: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
122
- children: [
123
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
101
+ content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
102
+ name: "URL",
103
+ render: ({ field , fieldState })=>{
104
+ var _fieldState_error;
105
+ /*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
106
+ ...field,
124
107
  fullWidth: true,
125
108
  label: "URL",
126
- value: ((_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.url) || '',
109
+ value: value.directUrl || '',
110
+ error: !!fieldState.error,
111
+ helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
127
112
  InputProps: {
128
113
  readOnly: isReadonly
129
114
  },
@@ -131,14 +116,48 @@ function PrometheusDatasourceEditor(props) {
131
116
  shrink: isReadonly ? true : undefined
132
117
  },
133
118
  onChange: (e)=>{
119
+ field.onChange(e);
134
120
  onChange((0, _immer.produce)(value, (draft)=>{
135
- if (draft.proxy !== undefined) {
136
- draft.proxy.spec.url = e.target.value;
137
- }
121
+ draft.directUrl = e.target.value;
138
122
  }));
139
- },
140
- sx: {
141
- mb: 2
123
+ }
124
+ });
125
+ }
126
+ })
127
+ },
128
+ {
129
+ label: strProxy,
130
+ content: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
131
+ children: [
132
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
133
+ name: "URL",
134
+ render: ({ field , fieldState })=>{
135
+ var _value_proxy, _fieldState_error;
136
+ /*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
137
+ ...field,
138
+ fullWidth: true,
139
+ label: "URL",
140
+ value: ((_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.url) || '',
141
+ error: !!fieldState.error,
142
+ helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
143
+ InputProps: {
144
+ readOnly: isReadonly
145
+ },
146
+ InputLabelProps: {
147
+ shrink: isReadonly ? true : undefined
148
+ },
149
+ onChange: (e)=>{
150
+ field.onChange(e);
151
+ onChange((0, _immer.produce)(value, (draft)=>{
152
+ if (draft.proxy !== undefined) {
153
+ draft.proxy.spec.url = e.target.value;
154
+ }
155
+ }));
156
+ },
157
+ sx: {
158
+ mb: 2
159
+ }
160
+ });
142
161
  }
143
162
  }),
144
163
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
@@ -151,115 +170,142 @@ function PrometheusDatasourceEditor(props) {
151
170
  spacing: 2,
152
171
  mb: 2,
153
172
  children: [
154
- ((_value_proxy1 = value.proxy) === null || _value_proxy1 === void 0 ? void 0 : _value_proxy1.spec.allowedEndpoints) && ((_value_proxy2 = value.proxy) === null || _value_proxy2 === void 0 ? void 0 : _value_proxy2.spec.allowedEndpoints.length) != 0 ? value.proxy.spec.allowedEndpoints.map(({ endpointPattern , method }, i)=>{
173
+ ((_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.allowedEndpoints) && ((_value_proxy1 = value.proxy) === null || _value_proxy1 === void 0 ? void 0 : _value_proxy1.spec.allowedEndpoints.length) != 0 ? value.proxy.spec.allowedEndpoints.map(({ endpointPattern , method }, i)=>{
155
174
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
156
175
  children: [
157
176
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
158
177
  item: true,
159
178
  xs: 8,
160
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
161
- fullWidth: true,
162
- label: "Endpoint pattern",
163
- value: endpointPattern,
164
- InputProps: {
165
- readOnly: isReadonly
166
- },
167
- InputLabelProps: {
168
- shrink: isReadonly ? true : undefined
169
- },
170
- onChange: (e)=>{
171
- onChange((0, _immer.produce)(value, (draft)=>{
172
- if (draft.proxy !== undefined) {
173
- var _draft_proxy_spec_allowedEndpoints;
174
- draft.proxy.spec.allowedEndpoints = (_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) === null || _draft_proxy_spec_allowedEndpoints === void 0 ? void 0 : _draft_proxy_spec_allowedEndpoints.map((item, itemIndex)=>{
175
- if (i === itemIndex) {
176
- return {
177
- endpointPattern: e.target.value,
178
- method: item.method
179
- };
180
- } else {
181
- return item;
179
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
180
+ name: `Endpoint pattern ${i}`,
181
+ render: ({ field , fieldState })=>{
182
+ var _fieldState_error;
183
+ /*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
184
+ ...field,
185
+ fullWidth: true,
186
+ label: "Endpoint pattern",
187
+ value: endpointPattern,
188
+ error: !!fieldState.error,
189
+ helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
190
+ InputProps: {
191
+ readOnly: isReadonly
192
+ },
193
+ InputLabelProps: {
194
+ shrink: isReadonly ? true : undefined
195
+ },
196
+ onChange: (e)=>{
197
+ field.onChange(e);
198
+ onChange((0, _immer.produce)(value, (draft)=>{
199
+ if (draft.proxy !== undefined) {
200
+ var _draft_proxy_spec_allowedEndpoints;
201
+ draft.proxy.spec.allowedEndpoints = (_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) === null || _draft_proxy_spec_allowedEndpoints === void 0 ? void 0 : _draft_proxy_spec_allowedEndpoints.map((item, itemIndex)=>{
202
+ if (i === itemIndex) {
203
+ return {
204
+ endpointPattern: e.target.value,
205
+ method: item.method
206
+ };
207
+ } else {
208
+ return item;
209
+ }
210
+ });
182
211
  }
183
- });
212
+ }));
184
213
  }
185
- }));
214
+ });
186
215
  }
187
216
  })
188
217
  }),
189
218
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
190
219
  item: true,
191
220
  xs: 3,
192
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
193
- select: true,
194
- fullWidth: true,
195
- label: "Method",
196
- value: method,
197
- InputProps: {
198
- readOnly: isReadonly
199
- },
200
- InputLabelProps: {
201
- shrink: isReadonly ? true : undefined
202
- },
203
- onChange: (e)=>{
204
- onChange((0, _immer.produce)(value, (draft)=>{
205
- if (draft.proxy !== undefined) {
206
- var _draft_proxy_spec_allowedEndpoints;
207
- draft.proxy.spec.allowedEndpoints = (_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) === null || _draft_proxy_spec_allowedEndpoints === void 0 ? void 0 : _draft_proxy_spec_allowedEndpoints.map((item, itemIndex)=>{
208
- if (i === itemIndex) {
209
- return {
210
- endpointPattern: item.endpointPattern,
211
- method: e.target.value
212
- };
213
- } else {
214
- return item;
221
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
222
+ name: `Method ${i}`,
223
+ render: ({ field , fieldState })=>{
224
+ var _fieldState_error;
225
+ /*#__PURE__*/ return (0, _jsxruntime.jsxs)(_material.TextField, {
226
+ ...field,
227
+ select: true,
228
+ fullWidth: true,
229
+ label: "Method",
230
+ value: method,
231
+ error: !!fieldState.error,
232
+ helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
233
+ InputProps: {
234
+ readOnly: isReadonly
235
+ },
236
+ InputLabelProps: {
237
+ shrink: isReadonly ? true : undefined
238
+ },
239
+ onChange: (e)=>{
240
+ field.onChange(e);
241
+ onChange((0, _immer.produce)(value, (draft)=>{
242
+ if (draft.proxy !== undefined) {
243
+ var _draft_proxy_spec_allowedEndpoints;
244
+ draft.proxy.spec.allowedEndpoints = (_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) === null || _draft_proxy_spec_allowedEndpoints === void 0 ? void 0 : _draft_proxy_spec_allowedEndpoints.map((item, itemIndex)=>{
245
+ if (i === itemIndex) {
246
+ return {
247
+ endpointPattern: item.endpointPattern,
248
+ method: e.target.value
249
+ };
250
+ } else {
251
+ return item;
252
+ }
253
+ });
215
254
  }
216
- });
217
- }
218
- }));
219
- },
220
- children: [
221
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
222
- value: "GET",
223
- children: "GET"
224
- }),
225
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
226
- value: "POST",
227
- children: "POST"
228
- }),
229
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
230
- value: "PUT",
231
- children: "PUT"
232
- }),
233
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
234
- value: "PATCH",
235
- children: "PATCH"
236
- }),
237
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
238
- value: "DELETE",
239
- children: "DELETE"
240
- })
241
- ]
255
+ }));
256
+ },
257
+ children: [
258
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
259
+ value: "GET",
260
+ children: "GET"
261
+ }),
262
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
263
+ value: "POST",
264
+ children: "POST"
265
+ }),
266
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
267
+ value: "PUT",
268
+ children: "PUT"
269
+ }),
270
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
271
+ value: "PATCH",
272
+ children: "PATCH"
273
+ }),
274
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
275
+ value: "DELETE",
276
+ children: "DELETE"
277
+ })
278
+ ]
279
+ });
280
+ }
242
281
  })
243
282
  }),
244
283
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
245
284
  item: true,
246
285
  xs: 1,
247
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
248
- disabled: isReadonly,
249
- // Remove the given allowed endpoint from the list
250
- onClick: ()=>{
251
- onChange((0, _immer.produce)(value, (draft)=>{
252
- if (draft.proxy !== undefined) {
253
- var _draft_proxy_spec_allowedEndpoints;
254
- draft.proxy.spec.allowedEndpoints = [
255
- ...((_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) === null || _draft_proxy_spec_allowedEndpoints === void 0 ? void 0 : _draft_proxy_spec_allowedEndpoints.filter((item, itemIndex)=>{
256
- return itemIndex !== i;
257
- })) || []
258
- ];
259
- }
260
- }));
261
- },
262
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
286
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
287
+ name: `Remove Endpoint ${i}`,
288
+ render: ({ field })=>{
289
+ /*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.IconButton, {
290
+ ...field,
291
+ disabled: isReadonly,
292
+ // Remove the given allowed endpoint from the list
293
+ onClick: (e)=>{
294
+ field.onChange(e);
295
+ onChange((0, _immer.produce)(value, (draft)=>{
296
+ if (draft.proxy !== undefined) {
297
+ var _draft_proxy_spec_allowedEndpoints;
298
+ draft.proxy.spec.allowedEndpoints = [
299
+ ...((_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) === null || _draft_proxy_spec_allowedEndpoints === void 0 ? void 0 : _draft_proxy_spec_allowedEndpoints.filter((item, itemIndex)=>{
300
+ return itemIndex !== i;
301
+ })) || []
302
+ ];
303
+ }
304
+ }));
305
+ },
306
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
307
+ });
308
+ }
263
309
  })
264
310
  })
265
311
  ]
@@ -311,72 +357,102 @@ function PrometheusDatasourceEditor(props) {
311
357
  spacing: 2,
312
358
  mb: 2,
313
359
  children: [
314
- ((_value_proxy3 = value.proxy) === null || _value_proxy3 === void 0 ? void 0 : _value_proxy3.spec.headers) && Object.keys(value.proxy.spec.headers).map((headerName, i)=>{
315
- var _value_proxy_spec_headers, _value_proxy;
360
+ ((_value_proxy2 = value.proxy) === null || _value_proxy2 === void 0 ? void 0 : _value_proxy2.spec.headers) && Object.keys(value.proxy.spec.headers).map((headerName, i)=>{
316
361
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
317
362
  children: [
318
363
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
319
364
  item: true,
320
365
  xs: 4,
321
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
322
- fullWidth: true,
323
- label: "Header name",
324
- value: headerName,
325
- InputProps: {
326
- readOnly: isReadonly
327
- },
328
- InputLabelProps: {
329
- shrink: isReadonly ? true : undefined
330
- },
331
- onChange: (e)=>onChange((0, _immer.produce)(value, (draft)=>{
332
- if (draft.proxy !== undefined) {
333
- draft.proxy.spec.headers = buildNewHeaders(draft.proxy.spec.headers, headerName, e.target.value);
366
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
367
+ name: `Header name ${i}`,
368
+ render: ({ field , fieldState })=>{
369
+ var _fieldState_error;
370
+ /*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
371
+ ...field,
372
+ fullWidth: true,
373
+ label: "Header name",
374
+ value: headerName,
375
+ error: !!fieldState.error,
376
+ helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
377
+ InputProps: {
378
+ readOnly: isReadonly
379
+ },
380
+ InputLabelProps: {
381
+ shrink: isReadonly ? true : undefined
382
+ },
383
+ onChange: (e)=>{
384
+ field.onChange(e);
385
+ onChange((0, _immer.produce)(value, (draft)=>{
386
+ if (draft.proxy !== undefined) {
387
+ draft.proxy.spec.headers = buildNewHeaders(draft.proxy.spec.headers, headerName, e.target.value);
388
+ }
389
+ }));
334
390
  }
335
- }))
391
+ });
392
+ }
336
393
  })
337
394
  }),
338
395
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
339
396
  item: true,
340
397
  xs: 7,
341
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
342
- fullWidth: true,
343
- label: "Header value",
344
- value: (_value_proxy_spec_headers = (_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.headers) === null || _value_proxy_spec_headers === void 0 ? void 0 : _value_proxy_spec_headers[headerName],
345
- InputProps: {
346
- readOnly: isReadonly
347
- },
348
- InputLabelProps: {
349
- shrink: isReadonly ? true : undefined
350
- },
351
- onChange: (e)=>onChange((0, _immer.produce)(value, (draft)=>{
352
- if (draft.proxy !== undefined) {
353
- draft.proxy.spec.headers = {
354
- ...draft.proxy.spec.headers,
355
- [headerName]: e.target.value
356
- };
398
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
399
+ name: `Header value ${i}`,
400
+ render: ({ field , fieldState })=>{
401
+ var _value_proxy_spec_headers, _value_proxy, _fieldState_error;
402
+ /*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
403
+ ...field,
404
+ fullWidth: true,
405
+ label: "Header value",
406
+ value: (_value_proxy_spec_headers = (_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.headers) === null || _value_proxy_spec_headers === void 0 ? void 0 : _value_proxy_spec_headers[headerName],
407
+ error: !!fieldState.error,
408
+ helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
409
+ InputProps: {
410
+ readOnly: isReadonly
411
+ },
412
+ InputLabelProps: {
413
+ shrink: isReadonly ? true : undefined
414
+ },
415
+ onChange: (e)=>{
416
+ field.onChange(e);
417
+ onChange((0, _immer.produce)(value, (draft)=>{
418
+ if (draft.proxy !== undefined) {
419
+ draft.proxy.spec.headers = {
420
+ ...draft.proxy.spec.headers,
421
+ [headerName]: e.target.value
422
+ };
423
+ }
424
+ }));
357
425
  }
358
- }))
426
+ });
427
+ }
359
428
  })
360
429
  }),
361
430
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
362
431
  item: true,
363
432
  xs: 1,
364
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
365
- disabled: isReadonly,
366
- // Remove the given header from the list
367
- onClick: ()=>{
368
- var _value_proxy;
369
- const newHeaders = {
370
- ...(_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.headers
371
- };
372
- delete newHeaders[headerName];
373
- onChange((0, _immer.produce)(value, (draft)=>{
374
- if (draft.proxy !== undefined) {
375
- draft.proxy.spec.headers = newHeaders;
376
- }
377
- }));
378
- },
379
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
433
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
434
+ name: `Remove Header ${i}`,
435
+ render: ({ field })=>{
436
+ /*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.IconButton, {
437
+ ...field,
438
+ disabled: isReadonly,
439
+ // Remove the given header from the list
440
+ onClick: (e)=>{
441
+ var _value_proxy;
442
+ field.onChange(e);
443
+ const newHeaders = {
444
+ ...(_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.headers
445
+ };
446
+ delete newHeaders[headerName];
447
+ onChange((0, _immer.produce)(value, (draft)=>{
448
+ if (draft.proxy !== undefined) {
449
+ draft.proxy.spec.headers = newHeaders;
450
+ }
451
+ }));
452
+ },
453
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
454
+ });
455
+ }
380
456
  })
381
457
  })
382
458
  ]
@@ -405,22 +481,32 @@ function PrometheusDatasourceEditor(props) {
405
481
  })
406
482
  ]
407
483
  }),
408
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
409
- fullWidth: true,
410
- label: "Secret",
411
- value: ((_value_proxy4 = value.proxy) === null || _value_proxy4 === void 0 ? void 0 : _value_proxy4.spec.secret) || '',
412
- InputProps: {
413
- readOnly: isReadonly
414
- },
415
- InputLabelProps: {
416
- shrink: isReadonly ? true : undefined
417
- },
418
- onChange: (e)=>{
419
- onChange((0, _immer.produce)(value, (draft)=>{
420
- if (draft.proxy !== undefined) {
421
- draft.proxy.spec.secret = e.target.value;
484
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
485
+ name: "Secret",
486
+ render: ({ field , fieldState })=>{
487
+ var _value_proxy, _fieldState_error;
488
+ /*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
489
+ ...field,
490
+ fullWidth: true,
491
+ label: "Secret",
492
+ value: ((_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.secret) || '',
493
+ error: !!fieldState.error,
494
+ helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
495
+ InputProps: {
496
+ readOnly: isReadonly
497
+ },
498
+ InputLabelProps: {
499
+ shrink: isReadonly ? true : undefined
500
+ },
501
+ onChange: (e)=>{
502
+ field.onChange(e);
503
+ onChange((0, _immer.produce)(value, (draft)=>{
504
+ if (draft.proxy !== undefined) {
505
+ draft.proxy.spec.secret = e.target.value;
506
+ }
507
+ }));
422
508
  }
423
- }));
509
+ });
424
510
  }
425
511
  })
426
512
  ]
@@ -38,6 +38,10 @@ const _PrometheusDatasourceEditor = require("./PrometheusDatasourceEditor");
38
38
  options: {
39
39
  datasourceUrl
40
40
  },
41
+ healthCheck: (0, _model.healthCheck)({
42
+ datasourceUrl,
43
+ headers: specHeaders
44
+ }),
41
45
  instantQuery: (params, headers)=>(0, _model.instantQuery)(params, {
42
46
  datasourceUrl,
43
47
  headers: headers !== null && headers !== void 0 ? headers : specHeaders