@perses-dev/prometheus-plugin 0.55.0 → 0.56.0
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.
- package/__mf/js/{Prometheus.f0d65264.js → Prometheus.4d0d5812.js} +3 -3
- package/__mf/js/async/{4421.6ebf935f.js → 4421.1fcb466e.js} +1 -1
- package/__mf/js/async/4557.f3eb9456.js +2 -0
- package/__mf/js/async/4676.b7a22f90.js +22 -0
- package/__mf/js/async/58.1c9a8daa.js +2 -0
- package/__mf/js/async/{6341.70ddfbe9.js → 6341.20eccf91.js} +2 -2
- package/__mf/js/async/8706.89677575.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusDatasource.45ee94e2.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusExplorer.b8e555e1.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.00dfb1dd.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.956ef2d0.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.59f2d170.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.d7143352.js +1 -0
- package/__mf/js/{main.d76b840e.js → main.afc2ee60.js} +3 -3
- package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +7 -43
- package/lib/cjs/plugins/prometheus-variables.js +11 -65
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +7 -43
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
- package/lib/plugins/prometheus-variables.d.ts.map +1 -1
- package/lib/plugins/prometheus-variables.js +12 -72
- package/lib/plugins/prometheus-variables.js.map +1 -1
- package/mf-manifest.json +49 -49
- package/mf-stats.json +49 -49
- package/package.json +6 -6
- package/__mf/js/async/2178.0f075947.js +0 -2
- package/__mf/js/async/2472.2134f9f7.js +0 -22
- package/__mf/js/async/6620.5a15a075.js +0 -2
- package/__mf/js/async/8706.08030938.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusDatasource.dcb93aae.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusExplorer.9ab5666d.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.0f7697ac.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.cd804473.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.4c376d6b.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.d4984d73.js +0 -1
- /package/__mf/js/async/{2178.0f075947.js.LICENSE.txt → 4557.f3eb9456.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{2472.2134f9f7.js.LICENSE.txt → 4676.b7a22f90.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6620.5a15a075.js.LICENSE.txt → 58.1c9a8daa.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6341.70ddfbe9.js.LICENSE.txt → 6341.20eccf91.js.LICENSE.txt} +0 -0
|
@@ -49,7 +49,7 @@ const _components = require("../components");
|
|
|
49
49
|
const _model = require("../model");
|
|
50
50
|
const _MatcherEditor = require("./MatcherEditor");
|
|
51
51
|
function PrometheusLabelValuesVariableEditor(props) {
|
|
52
|
-
const { onChange, value, value: { datasource }
|
|
52
|
+
const { onChange, value, value: { datasource } } = props;
|
|
53
53
|
const selectedDatasource = datasource ?? _model.DEFAULT_PROM;
|
|
54
54
|
const [labelValue, setLabelValue] = (0, _react.useState)(props.value.labelName);
|
|
55
55
|
const [matchersValues, setMatchersValues] = (0, _react.useState)(props.value.matchers ?? []);
|
|
@@ -59,38 +59,19 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
59
59
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
60
60
|
draft.datasource = !(0, _pluginsystem.isVariableDatasource)(next) && (0, _model.isDefaultPromSelector)(next) ? undefined : next;
|
|
61
61
|
}));
|
|
62
|
-
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
63
|
-
...value,
|
|
64
|
-
datasource: next
|
|
65
|
-
});
|
|
66
62
|
return;
|
|
67
63
|
}
|
|
68
64
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
69
65
|
}, [
|
|
70
66
|
onChange,
|
|
71
|
-
queryHandlerSettings,
|
|
72
67
|
value
|
|
73
68
|
]);
|
|
74
69
|
const handleLabelChange = (0, _react.useCallback)((e)=>{
|
|
75
70
|
setLabelValue(e.target.value);
|
|
76
|
-
|
|
77
|
-
...value,
|
|
78
|
-
labelName: e.target.value
|
|
79
|
-
});
|
|
80
|
-
}, [
|
|
81
|
-
value,
|
|
82
|
-
queryHandlerSettings
|
|
83
|
-
]);
|
|
71
|
+
}, []);
|
|
84
72
|
const handleMatchEditorsChange = (0, _react.useCallback)((e)=>{
|
|
85
73
|
setMatchersValues(e);
|
|
86
|
-
|
|
87
|
-
...value,
|
|
88
|
-
matchers: e
|
|
89
|
-
});
|
|
90
|
-
}, [
|
|
91
|
-
value,
|
|
92
|
-
queryHandlerSettings
|
|
93
|
-
]);
|
|
74
|
+
}, []);
|
|
94
75
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
95
76
|
spacing: 2,
|
|
96
77
|
children: [
|
|
@@ -123,7 +104,7 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
123
104
|
});
|
|
124
105
|
}
|
|
125
106
|
function PrometheusLabelNamesVariableEditor(props) {
|
|
126
|
-
const { onChange, value, value: { datasource }
|
|
107
|
+
const { onChange, value, value: { datasource } } = props;
|
|
127
108
|
const selectedDatasource = datasource ?? _model.DEFAULT_PROM;
|
|
128
109
|
const [matchersValues, setMatchersValues] = (0, _react.useState)(props.value.matchers ?? []);
|
|
129
110
|
const handleDatasourceChange = (0, _react.useCallback)((next)=>{
|
|
@@ -132,30 +113,16 @@ function PrometheusLabelNamesVariableEditor(props) {
|
|
|
132
113
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
133
114
|
draft.datasource = !(0, _pluginsystem.isVariableDatasource)(next) && (0, _model.isDefaultPromSelector)(next) ? undefined : next;
|
|
134
115
|
}));
|
|
135
|
-
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
136
|
-
...value,
|
|
137
|
-
datasource: next
|
|
138
|
-
});
|
|
139
116
|
return;
|
|
140
117
|
}
|
|
141
118
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
142
119
|
}, [
|
|
143
120
|
onChange,
|
|
144
|
-
queryHandlerSettings,
|
|
145
121
|
value
|
|
146
122
|
]);
|
|
147
123
|
const handleMatchEditorChange = (0, _react.useCallback)((e)=>{
|
|
148
124
|
setMatchersValues(e);
|
|
149
|
-
|
|
150
|
-
queryHandlerSettings.setWatchOtherSpecs({
|
|
151
|
-
...value,
|
|
152
|
-
matchers: e
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
}, [
|
|
156
|
-
value,
|
|
157
|
-
queryHandlerSettings
|
|
158
|
-
]);
|
|
125
|
+
}, []);
|
|
159
126
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
160
127
|
spacing: 2,
|
|
161
128
|
children: [
|
|
@@ -179,29 +146,24 @@ function PrometheusLabelNamesVariableEditor(props) {
|
|
|
179
146
|
});
|
|
180
147
|
}
|
|
181
148
|
function PrometheusPromQLVariableEditor(props) {
|
|
182
|
-
const { onChange, value, value: { datasource }
|
|
149
|
+
const { onChange, value, value: { datasource } } = props;
|
|
183
150
|
const datasourceSelectValue = datasource ?? _model.DEFAULT_PROM;
|
|
184
151
|
const selectedDatasource = (0, _pluginsystem.useDatasourceSelectValueToSelector)(datasourceSelectValue, _model.PROM_DATASOURCE_KIND);
|
|
185
152
|
const { data: client } = (0, _pluginsystem.useDatasourceClient)(selectedDatasource);
|
|
186
153
|
const promURL = client?.options.datasourceUrl;
|
|
187
|
-
const [labelValue,
|
|
154
|
+
const [labelValue, setLabelValue] = (0, _react.useState)(props.value.labelName);
|
|
188
155
|
const handleDatasourceChange = (0, _react.useCallback)((next)=>{
|
|
189
156
|
if ((0, _pluginsystem.isVariableDatasource)(next) || (0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
190
157
|
onChange((0, _immer.produce)(value, (draft)=>{
|
|
191
158
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
192
159
|
draft.datasource = !(0, _pluginsystem.isVariableDatasource)(next) && (0, _model.isDefaultPromSelector)(next) ? undefined : next;
|
|
193
160
|
}));
|
|
194
|
-
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
|
|
195
|
-
...value,
|
|
196
|
-
datasource: next
|
|
197
|
-
});
|
|
198
161
|
return;
|
|
199
162
|
}
|
|
200
163
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
201
164
|
}, [
|
|
202
165
|
value,
|
|
203
|
-
onChange
|
|
204
|
-
queryHandlerSettings
|
|
166
|
+
onChange
|
|
205
167
|
]);
|
|
206
168
|
const handleOnBlurPromQlChange = (0, _react.useCallback)((e)=>{
|
|
207
169
|
onChange({
|
|
@@ -212,25 +174,9 @@ function PrometheusPromQLVariableEditor(props) {
|
|
|
212
174
|
onChange,
|
|
213
175
|
value
|
|
214
176
|
]);
|
|
215
|
-
const trackPromQlChanges = (0, _react.useCallback)((e)=>{
|
|
216
|
-
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
|
|
217
|
-
...value,
|
|
218
|
-
expr: e.target.textContent ?? ''
|
|
219
|
-
});
|
|
220
|
-
}, [
|
|
221
|
-
queryHandlerSettings,
|
|
222
|
-
value
|
|
223
|
-
]);
|
|
224
177
|
const handleLabelNameChange = (0, _react.useCallback)((e)=>{
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
...value,
|
|
228
|
-
labelName: e.target.value
|
|
229
|
-
});
|
|
230
|
-
}, [
|
|
231
|
-
queryHandlerSettings,
|
|
232
|
-
value
|
|
233
|
-
]);
|
|
178
|
+
setLabelValue(e.target.value);
|
|
179
|
+
}, []);
|
|
234
180
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
235
181
|
spacing: 2,
|
|
236
182
|
children: [
|
|
@@ -253,7 +199,7 @@ function PrometheusPromQLVariableEditor(props) {
|
|
|
253
199
|
},
|
|
254
200
|
value: value.expr,
|
|
255
201
|
datasource: selectedDatasource,
|
|
256
|
-
onBlur:
|
|
202
|
+
onBlur: handleOnBlurPromQlChange,
|
|
257
203
|
readOnly: props.isReadonly,
|
|
258
204
|
width: "100%"
|
|
259
205
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"PrometheusTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAYrC,OAAO,EACL,oCAAoC,EAIrC,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,GAAG,YAAY,CAmGzG"}
|
|
@@ -15,7 +15,6 @@ import { produce } from 'immer';
|
|
|
15
15
|
import { DatasourceSelect, useDatasource, useDatasourceClient, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system';
|
|
16
16
|
import { useId } from '@perses-dev/components';
|
|
17
17
|
import { FormControl, Stack, TextField } from '@mui/material';
|
|
18
|
-
import { useCallback } from 'react';
|
|
19
18
|
import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../../model';
|
|
20
19
|
import { DEFAULT_SCRAPE_INTERVAL } from '../types';
|
|
21
20
|
import { PromQLEditor } from '../../components';
|
|
@@ -23,7 +22,7 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
23
22
|
/**
|
|
24
23
|
* The options editor component for editing a PrometheusTimeSeriesQuery's spec.
|
|
25
24
|
*/ export function PrometheusTimeSeriesQueryEditor(props) {
|
|
26
|
-
const { onChange, value, value: { query, datasource },
|
|
25
|
+
const { onChange, value, value: { query, datasource }, isReadonly } = props;
|
|
27
26
|
const datasourceSelectValue = datasource ?? DEFAULT_PROM;
|
|
28
27
|
const datasourceSelectLabelID = useId('prom-datasource-label'); // for panels with multiple queries, this component is rendered multiple times on the same page
|
|
29
28
|
const selectedDatasource = useDatasourceSelectValueToSelector(datasourceSelectValue, PROM_DATASOURCE_KIND);
|
|
@@ -44,45 +43,10 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
44
43
|
const nextDatasource = isDefaultPromSelector(next) ? undefined : next;
|
|
45
44
|
draft.datasource = nextDatasource;
|
|
46
45
|
}));
|
|
47
|
-
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
48
|
-
...value,
|
|
49
|
-
datasource: next
|
|
50
|
-
});
|
|
51
46
|
return;
|
|
52
47
|
}
|
|
53
48
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
54
49
|
};
|
|
55
|
-
const handlePromQlEditorChanges = useCallback((e)=>{
|
|
56
|
-
handleQueryChange(e);
|
|
57
|
-
if (queryHandlerSettings?.watchQueryChanges) {
|
|
58
|
-
queryHandlerSettings?.watchQueryChanges(e);
|
|
59
|
-
}
|
|
60
|
-
}, [
|
|
61
|
-
queryHandlerSettings,
|
|
62
|
-
handleQueryChange
|
|
63
|
-
]);
|
|
64
|
-
const handleLegendSpecChange = useCallback((e)=>{
|
|
65
|
-
handleFormatChange(e.target.value);
|
|
66
|
-
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
67
|
-
...value,
|
|
68
|
-
seriesNameFormat: e.target.value
|
|
69
|
-
});
|
|
70
|
-
}, [
|
|
71
|
-
queryHandlerSettings,
|
|
72
|
-
handleFormatChange,
|
|
73
|
-
value
|
|
74
|
-
]);
|
|
75
|
-
const handleMinStepSpecChange = useCallback((e)=>{
|
|
76
|
-
handleMinStepChange(e.target.value ? e.target.value : undefined);
|
|
77
|
-
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
78
|
-
...value,
|
|
79
|
-
minStep: e.target.value
|
|
80
|
-
});
|
|
81
|
-
}, [
|
|
82
|
-
queryHandlerSettings,
|
|
83
|
-
handleMinStepChange,
|
|
84
|
-
value
|
|
85
|
-
]);
|
|
86
50
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
87
51
|
spacing: 2,
|
|
88
52
|
children: [
|
|
@@ -107,8 +71,8 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
107
71
|
},
|
|
108
72
|
value: query,
|
|
109
73
|
datasource: selectedDatasource,
|
|
110
|
-
onChange:
|
|
111
|
-
onBlur:
|
|
74
|
+
onChange: handleQueryChange,
|
|
75
|
+
onBlur: handleQueryBlur,
|
|
112
76
|
isReadOnly: isReadonly
|
|
113
77
|
}),
|
|
114
78
|
/*#__PURE__*/ _jsxs(Stack, {
|
|
@@ -121,8 +85,8 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
121
85
|
placeholder: "Example: '{{instance}}' will generate series names like 'webserver-123', 'webserver-456'...",
|
|
122
86
|
helperText: "Text to be displayed in the legend and the tooltip. Use {{label_name}} to interpolate label values.",
|
|
123
87
|
value: format ?? '',
|
|
124
|
-
onChange:
|
|
125
|
-
onBlur:
|
|
88
|
+
onChange: (e)=>handleFormatChange(e.target.value),
|
|
89
|
+
onBlur: handleFormatBlur,
|
|
126
90
|
slotProps: {
|
|
127
91
|
inputLabel: {
|
|
128
92
|
shrink: isReadonly ? true : undefined
|
|
@@ -137,8 +101,8 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
137
101
|
placeholder: minStepPlaceholder,
|
|
138
102
|
helperText: "Lower bound for the step. If not provided, the scrape interval of the datasource is used.",
|
|
139
103
|
value: minStep ?? '',
|
|
140
|
-
onChange:
|
|
141
|
-
onBlur:
|
|
104
|
+
onChange: (e)=>handleMinStepChange(e.target.value ? e.target.value : undefined),
|
|
105
|
+
onBlur: handleMinStepBlur,
|
|
142
106
|
sx: {
|
|
143
107
|
width: '250px'
|
|
144
108
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { produce } from 'immer';\nimport {\n DatasourceSelect,\n DatasourceSelectProps,\n useDatasource,\n useDatasourceClient,\n useDatasourceSelectValueToSelector,\n} from '@perses-dev/plugin-system';\nimport { useId } from '@perses-dev/components';\nimport { FormControl, Stack, TextField } from '@mui/material';\nimport { ReactElement, useCallback } from 'react';\nimport {\n DEFAULT_PROM,\n DurationString,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n PrometheusDatasourceSelector,\n} from '../../model';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from '../types';\nimport { PromQLEditor } from '../../components';\nimport {\n PrometheusTimeSeriesQueryEditorProps,\n useQueryState,\n useFormatState,\n useMinStepState,\n} from './query-editor-model';\n\n/**\n * The options editor component for editing a PrometheusTimeSeriesQuery's spec.\n */\nexport function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQueryEditorProps): ReactElement {\n const {\n onChange,\n value,\n value: { query, datasource },\n queryHandlerSettings,\n isReadonly,\n } = props;\n\n const datasourceSelectValue = datasource ?? DEFAULT_PROM;\n\n const datasourceSelectLabelID = useId('prom-datasource-label'); // for panels with multiple queries, this component is rendered multiple times on the same page\n\n const selectedDatasource = useDatasourceSelectValueToSelector(\n datasourceSelectValue,\n PROM_DATASOURCE_KIND\n ) as PrometheusDatasourceSelector;\n\n const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);\n const promURL = client?.options.datasourceUrl;\n const { data: datasourceResource } = useDatasource(selectedDatasource);\n\n const { handleQueryChange, handleQueryBlur } = useQueryState(props);\n const { format, handleFormatChange, handleFormatBlur } = useFormatState(props);\n const { minStep, handleMinStepChange, handleMinStepBlur } = useMinStepState(props);\n const minStepPlaceholder =\n minStep ??\n (datasourceResource && (datasourceResource?.plugin.spec as PrometheusDatasourceSpec).scrapeInterval) ??\n DEFAULT_SCRAPE_INTERVAL;\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isPrometheusDatasourceSelector(next)) {\n /* Good to know: The usage of onchange here causes an immediate spec update which eventually updates the panel\n This was probably intentional to allow for quick switching between datasources.\n Could have been triggered only with Run Query button as well.\n */\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultPromSelector(next) ? undefined : next;\n draft.datasource = nextDatasource;\n })\n );\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, datasource: next });\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n };\n\n const handlePromQlEditorChanges = useCallback(\n (e: string) => {\n handleQueryChange(e);\n if (queryHandlerSettings?.watchQueryChanges) {\n queryHandlerSettings?.watchQueryChanges(e);\n }\n },\n [queryHandlerSettings, handleQueryChange]\n );\n\n const handleLegendSpecChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n handleFormatChange(e.target.value);\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, seriesNameFormat: e.target.value });\n },\n [queryHandlerSettings, handleFormatChange, value]\n );\n\n const handleMinStepSpecChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n handleMinStepChange(e.target.value ? (e.target.value as DurationString) : undefined);\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, minStep: e.target.value });\n },\n [queryHandlerSettings, handleMinStepChange, value]\n );\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\" fullWidth={false}>\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={datasourceSelectValue}\n onChange={handleDatasourceChange}\n labelId={datasourceSelectLabelID}\n label=\"Prometheus Datasource\"\n notched\n readOnly={isReadonly}\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={query} // here we are passing `value.query` and not `query` from useQueryState in order to get updates only on onBlur events\n datasource={selectedDatasource}\n onChange={handlePromQlEditorChanges}\n onBlur={queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined}\n isReadOnly={isReadonly}\n />\n <Stack direction=\"row\" spacing={2}>\n <TextField\n fullWidth\n label=\"Legend\"\n placeholder=\"Example: '{{instance}}' will generate series names like 'webserver-123', 'webserver-456'...\"\n helperText=\"Text to be displayed in the legend and the tooltip. Use {{label_name}} to interpolate label values.\"\n value={format ?? ''}\n onChange={handleLegendSpecChange}\n onBlur={queryHandlerSettings?.runWithOnBlur ? handleFormatBlur : undefined}\n slotProps={{\n inputLabel: { shrink: isReadonly ? true : undefined },\n input: { readOnly: isReadonly },\n }}\n />\n <TextField\n label=\"Min Step\"\n placeholder={minStepPlaceholder}\n helperText=\"Lower bound for the step. If not provided, the scrape interval of the datasource is used.\"\n value={minStep ?? ''}\n onChange={handleMinStepSpecChange}\n onBlur={queryHandlerSettings?.runWithOnBlur ? handleMinStepBlur : undefined}\n sx={{ width: '250px' }}\n slotProps={{\n inputLabel: { shrink: isReadonly ? true : undefined },\n input: { readOnly: isReadonly },\n }}\n />\n </Stack>\n </Stack>\n );\n}\n"],"names":["produce","DatasourceSelect","useDatasource","useDatasourceClient","useDatasourceSelectValueToSelector","useId","FormControl","Stack","TextField","useCallback","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","DEFAULT_SCRAPE_INTERVAL","PromQLEditor","useQueryState","useFormatState","useMinStepState","PrometheusTimeSeriesQueryEditor","props","onChange","value","query","datasource","queryHandlerSettings","isReadonly","datasourceSelectValue","datasourceSelectLabelID","selectedDatasource","data","client","promURL","options","datasourceUrl","datasourceResource","handleQueryChange","handleQueryBlur","format","handleFormatChange","handleFormatBlur","minStep","handleMinStepChange","handleMinStepBlur","minStepPlaceholder","plugin","spec","scrapeInterval","handleDatasourceChange","next","draft","nextDatasource","undefined","setWatchOtherSpecs","Error","handlePromQlEditorChanges","e","watchQueryChanges","handleLegendSpecChange","target","seriesNameFormat","handleMinStepSpecChange","spacing","margin","fullWidth","datasourcePluginKind","labelId","label","notched","readOnly","completeConfig","remote","url","onBlur","runWithOnBlur","isReadOnly","direction","placeholder","helperText","slotProps","inputLabel","shrink","input","sx","width"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE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N,UAAU2B;oBACVkB,SAAStC;oBACTuC,OAAM;oBACNC,OAAO;oBACPC,UAAU3C;;;0BAGd,KAACX;gBACCuD,gBAAgB;oBAAEC,QAAQ;wBAAEC,KAAKxC;oBAAQ;gBAAE;gBAC3CV,OAAOC;gBACPC,YAAYK;gBACZR,UAAUkC;gBACVkB,QAAQhD,sBAAsBiD,gBAAgBrC,kBAAkBe;gBAChEuB,YAAYjD;;0BAEd,MAACnB;gBAAMqE,WAAU;gBAAMd,SAAS;;kCAC9B,KAACtD;wBACCwD,SAAS;wBACTG,OAAM;wBACNU,aAAY;wBACZC,YAAW;wBACXxD,OAAOgB,UAAU;wBACjBjB,UAAUqC;wBACVe,QAAQhD,sBAAsBiD,gBAAgBlC,mBAAmBY;wBACjE2B,WAAW;4BACTC,YAAY;gCAAEC,QAAQvD,aAAa,OAAO0B;4BAAU;4BACpD8B,OAAO;gCAAEb,UAAU3C;4BAAW;wBAChC;;kCAEF,KAAClB;wBACC2D,OAAM;wBACNU,aAAajC;wBACbkC,YAAW;wBACXxD,OAAOmB,WAAW;wBAClBpB,UAAUwC;wBACVY,QAAQhD,sBAAsBiD,gBAAgB/B,oBAAoBS;wBAClE+B,IAAI;4BAAEC,OAAO;wBAAQ;wBACrBL,WAAW;4BACTC,YAAY;gCAAEC,QAAQvD,aAAa,OAAO0B;4BAAU;4BACpD8B,OAAO;gCAAEb,UAAU3C;4BAAW;wBAChC;;;;;;AAKV"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { produce } from 'immer';\nimport {\n DatasourceSelect,\n DatasourceSelectProps,\n useDatasource,\n useDatasourceClient,\n useDatasourceSelectValueToSelector,\n} from '@perses-dev/plugin-system';\nimport { useId } from '@perses-dev/components';\nimport { FormControl, Stack, TextField } from '@mui/material';\nimport { ReactElement } from 'react';\nimport {\n DEFAULT_PROM,\n DurationString,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n PrometheusDatasourceSelector,\n} from '../../model';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from '../types';\nimport { PromQLEditor } from '../../components';\nimport {\n PrometheusTimeSeriesQueryEditorProps,\n useQueryState,\n useFormatState,\n useMinStepState,\n} from './query-editor-model';\n\n/**\n * The options editor component for editing a PrometheusTimeSeriesQuery's spec.\n */\nexport function PrometheusTimeSeriesQueryEditor(props: PrometheusTimeSeriesQueryEditorProps): ReactElement {\n const {\n onChange,\n value,\n value: { query, datasource },\n isReadonly,\n } = props;\n\n const datasourceSelectValue = datasource ?? DEFAULT_PROM;\n\n const datasourceSelectLabelID = useId('prom-datasource-label'); // for panels with multiple queries, this component is rendered multiple times on the same page\n\n const selectedDatasource = useDatasourceSelectValueToSelector(\n datasourceSelectValue,\n PROM_DATASOURCE_KIND\n ) as PrometheusDatasourceSelector;\n\n const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);\n const promURL = client?.options.datasourceUrl;\n const { data: datasourceResource } = useDatasource(selectedDatasource);\n\n const { handleQueryChange, handleQueryBlur } = useQueryState(props);\n const { format, handleFormatChange, handleFormatBlur } = useFormatState(props);\n const { minStep, handleMinStepChange, handleMinStepBlur } = useMinStepState(props);\n const minStepPlaceholder =\n minStep ??\n (datasourceResource && (datasourceResource?.plugin.spec as PrometheusDatasourceSpec).scrapeInterval) ??\n DEFAULT_SCRAPE_INTERVAL;\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (isPrometheusDatasourceSelector(next)) {\n /* Good to know: The usage of onchange here causes an immediate spec update which eventually updates the panel\n This was probably intentional to allow for quick switching between datasources.\n Could have been triggered only with Run Query button as well.\n */\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n const nextDatasource = isDefaultPromSelector(next) ? undefined : next;\n draft.datasource = nextDatasource;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n };\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\" fullWidth={false}>\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={datasourceSelectValue}\n onChange={handleDatasourceChange}\n labelId={datasourceSelectLabelID}\n label=\"Prometheus Datasource\"\n notched\n readOnly={isReadonly}\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={query} // here we are passing `value.query` and not `query` from useQueryState in order to get updates only on onBlur events\n datasource={selectedDatasource}\n onChange={handleQueryChange}\n onBlur={handleQueryBlur}\n isReadOnly={isReadonly}\n />\n <Stack direction=\"row\" spacing={2}>\n <TextField\n fullWidth\n label=\"Legend\"\n placeholder=\"Example: '{{instance}}' will generate series names like 'webserver-123', 'webserver-456'...\"\n helperText=\"Text to be displayed in the legend and the tooltip. Use {{label_name}} to interpolate label values.\"\n value={format ?? ''}\n onChange={(e) => handleFormatChange(e.target.value)}\n onBlur={handleFormatBlur}\n slotProps={{\n inputLabel: { shrink: isReadonly ? true : undefined },\n input: { readOnly: isReadonly },\n }}\n />\n <TextField\n label=\"Min Step\"\n placeholder={minStepPlaceholder}\n helperText=\"Lower bound for the step. If not provided, the scrape interval of the datasource is used.\"\n value={minStep ?? ''}\n onChange={(e) => handleMinStepChange(e.target.value ? (e.target.value as DurationString) : undefined)}\n onBlur={handleMinStepBlur}\n sx={{ width: '250px' }}\n slotProps={{\n inputLabel: { shrink: isReadonly ? true : undefined },\n input: { readOnly: isReadonly },\n }}\n />\n </Stack>\n </Stack>\n );\n}\n"],"names":["produce","DatasourceSelect","useDatasource","useDatasourceClient","useDatasourceSelectValueToSelector","useId","FormControl","Stack","TextField","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","DEFAULT_SCRAPE_INTERVAL","PromQLEditor","useQueryState","useFormatState","useMinStepState","PrometheusTimeSeriesQueryEditor","props","onChange","value","query","datasource","isReadonly","datasourceSelectValue","datasourceSelectLabelID","selectedDatasource","data","client","promURL","options","datasourceUrl","datasourceResource","handleQueryChange","handleQueryBlur","format","handleFormatChange","handleFormatBlur","minStep","handleMinStepChange","handleMinStepBlur","minStepPlaceholder","plugin","spec","scrapeInterval","handleDatasourceChange","next","draft","nextDatasource","undefined","Error","spacing","margin","fullWidth","datasourcePluginKind","labelId","label","notched","readOnly","completeConfig","remote","url","onBlur","isReadOnly","direction","placeholder","helperText","e","target","slotProps","inputLabel","shrink","input","sx","width"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,OAAO,QAAQ,QAAQ;AAChC,SACEC,gBAAgB,EAEhBC,aAAa,EACbC,mBAAmB,EACnBC,kCAAkC,QAC7B,4BAA4B;AACnC,SAASC,KAAK,QAAQ,yBAAyB;AAC/C,SAASC,WAAW,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAE9D,SACEC,YAAY,EAEZC,qBAAqB,EACrBC,8BAA8B,EAC9BC,oBAAoB,QAGf,cAAc;AACrB,SAASC,uBAAuB,QAAkC,WAAW;AAC7E,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAEEC,aAAa,EACbC,cAAc,EACdC,eAAe,QACV,uBAAuB;AAE9B;;CAEC,GACD,OAAO,SAASC,gCAAgCC,KAA2C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AAQ;wBAAEC,KAAKhC;oBAAQ;gBAAE;gBAC3CT,OAAOC;gBACPC,YAAYI;gBACZP,UAAUc;gBACV6B,QAAQ5B;gBACR6B,YAAYxC;;0BAEd,MAACjB;gBAAM0D,WAAU;gBAAMb,SAAS;;kCAC9B,KAAC5C;wBACC8C,SAAS;wBACTG,OAAM;wBACNS,aAAY;wBACZC,YAAW;wBACX9C,OAAOe,UAAU;wBACjBhB,UAAU,CAACgD,IAAM/B,mBAAmB+B,EAAEC,MAAM,CAAChD,KAAK;wBAClD0C,QAAQzB;wBACRgC,WAAW;4BACTC,YAAY;gCAAEC,QAAQhD,aAAa,OAAO0B;4BAAU;4BACpDuB,OAAO;gCAAEd,UAAUnC;4BAAW;wBAChC;;kCAEF,KAAChB;wBACCiD,OAAM;wBACNS,aAAaxB;wBACbyB,YAAW;wBACX9C,OAAOkB,WAAW;wBAClBnB,UAAU,CAACgD,IAAM5B,oBAAoB4B,EAAEC,MAAM,CAAChD,KAAK,GAAI+C,EAAEC,MAAM,CAAChD,KAAK,GAAsB6B;wBAC3Fa,QAAQtB;wBACRiC,IAAI;4BAAEC,OAAO;wBAAQ;wBACrBL,WAAW;4BACTC,YAAY;gCAAEC,QAAQhD,aAAa,OAAO0B;4BAAU;4BACpDuB,OAAO;gCAAEd,UAAUnC;4BAAW;wBAChC;;;;;;AAKV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-variables.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-variables.tsx"],"names":[],"mappings":"AAaA,OAAO,EAIL,kBAAkB,EAGlB,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAIL,UAAU,EAIV,UAAU,EACX,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,mCAAmC,EACnC,oCAAoC,EACpC,+BAA+B,EAChC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"prometheus-variables.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-variables.tsx"],"names":[],"mappings":"AAaA,OAAO,EAIL,kBAAkB,EAGlB,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAIL,UAAU,EAIV,UAAU,EACX,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,mCAAmC,EACnC,oCAAoC,EACpC,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAEjB,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,kBAAkB,CAAC,oCAAoC,CAAC,GAC9D,YAAY,CA0Dd;AAED,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,kBAAkB,CAAC,mCAAmC,CAAC,GAC7D,YAAY,CA6Cd;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,kBAAkB,CAAC,+BAA+B,CAAC,GACzD,YAAY,CA0Ed;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAS/E;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAS/E;AAED;;GAEG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,MAAM,EAAE,KAAG,cAAc,EAM9E,CAAC"}
|
|
@@ -18,14 +18,8 @@ import { useCallback, useState } from 'react';
|
|
|
18
18
|
import { PromQLEditor } from '../components';
|
|
19
19
|
import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../model';
|
|
20
20
|
import { MatcherEditor } from './MatcherEditor';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
The usage of direct onchange here causes an immediate spec update which eventually updates the panel
|
|
24
|
-
This was probably intentional to allow for quick switching between values.
|
|
25
|
-
Shouldn't we update the panel only through the Run Query Button?
|
|
26
|
-
I think we should only track the changes and let the button to Run the query
|
|
27
|
-
*/ export function PrometheusLabelValuesVariableEditor(props) {
|
|
28
|
-
const { onChange, value, value: { datasource }, queryHandlerSettings } = props;
|
|
21
|
+
export function PrometheusLabelValuesVariableEditor(props) {
|
|
22
|
+
const { onChange, value, value: { datasource } } = props;
|
|
29
23
|
const selectedDatasource = datasource ?? DEFAULT_PROM;
|
|
30
24
|
const [labelValue, setLabelValue] = useState(props.value.labelName);
|
|
31
25
|
const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);
|
|
@@ -35,38 +29,19 @@ I think we should only track the changes and let the button to Run the query
|
|
|
35
29
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
36
30
|
draft.datasource = !isVariableDatasource(next) && isDefaultPromSelector(next) ? undefined : next;
|
|
37
31
|
}));
|
|
38
|
-
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
39
|
-
...value,
|
|
40
|
-
datasource: next
|
|
41
|
-
});
|
|
42
32
|
return;
|
|
43
33
|
}
|
|
44
34
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
45
35
|
}, [
|
|
46
36
|
onChange,
|
|
47
|
-
queryHandlerSettings,
|
|
48
37
|
value
|
|
49
38
|
]);
|
|
50
39
|
const handleLabelChange = useCallback((e)=>{
|
|
51
40
|
setLabelValue(e.target.value);
|
|
52
|
-
|
|
53
|
-
...value,
|
|
54
|
-
labelName: e.target.value
|
|
55
|
-
});
|
|
56
|
-
}, [
|
|
57
|
-
value,
|
|
58
|
-
queryHandlerSettings
|
|
59
|
-
]);
|
|
41
|
+
}, []);
|
|
60
42
|
const handleMatchEditorsChange = useCallback((e)=>{
|
|
61
43
|
setMatchersValues(e);
|
|
62
|
-
|
|
63
|
-
...value,
|
|
64
|
-
matchers: e
|
|
65
|
-
});
|
|
66
|
-
}, [
|
|
67
|
-
value,
|
|
68
|
-
queryHandlerSettings
|
|
69
|
-
]);
|
|
44
|
+
}, []);
|
|
70
45
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
71
46
|
spacing: 2,
|
|
72
47
|
children: [
|
|
@@ -99,7 +74,7 @@ I think we should only track the changes and let the button to Run the query
|
|
|
99
74
|
});
|
|
100
75
|
}
|
|
101
76
|
export function PrometheusLabelNamesVariableEditor(props) {
|
|
102
|
-
const { onChange, value, value: { datasource }
|
|
77
|
+
const { onChange, value, value: { datasource } } = props;
|
|
103
78
|
const selectedDatasource = datasource ?? DEFAULT_PROM;
|
|
104
79
|
const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);
|
|
105
80
|
const handleDatasourceChange = useCallback((next)=>{
|
|
@@ -108,30 +83,16 @@ export function PrometheusLabelNamesVariableEditor(props) {
|
|
|
108
83
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
109
84
|
draft.datasource = !isVariableDatasource(next) && isDefaultPromSelector(next) ? undefined : next;
|
|
110
85
|
}));
|
|
111
|
-
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
112
|
-
...value,
|
|
113
|
-
datasource: next
|
|
114
|
-
});
|
|
115
86
|
return;
|
|
116
87
|
}
|
|
117
88
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
118
89
|
}, [
|
|
119
90
|
onChange,
|
|
120
|
-
queryHandlerSettings,
|
|
121
91
|
value
|
|
122
92
|
]);
|
|
123
93
|
const handleMatchEditorChange = useCallback((e)=>{
|
|
124
94
|
setMatchersValues(e);
|
|
125
|
-
|
|
126
|
-
queryHandlerSettings.setWatchOtherSpecs({
|
|
127
|
-
...value,
|
|
128
|
-
matchers: e
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}, [
|
|
132
|
-
value,
|
|
133
|
-
queryHandlerSettings
|
|
134
|
-
]);
|
|
95
|
+
}, []);
|
|
135
96
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
136
97
|
spacing: 2,
|
|
137
98
|
children: [
|
|
@@ -155,29 +116,24 @@ export function PrometheusLabelNamesVariableEditor(props) {
|
|
|
155
116
|
});
|
|
156
117
|
}
|
|
157
118
|
export function PrometheusPromQLVariableEditor(props) {
|
|
158
|
-
const { onChange, value, value: { datasource }
|
|
119
|
+
const { onChange, value, value: { datasource } } = props;
|
|
159
120
|
const datasourceSelectValue = datasource ?? DEFAULT_PROM;
|
|
160
121
|
const selectedDatasource = useDatasourceSelectValueToSelector(datasourceSelectValue, PROM_DATASOURCE_KIND);
|
|
161
122
|
const { data: client } = useDatasourceClient(selectedDatasource);
|
|
162
123
|
const promURL = client?.options.datasourceUrl;
|
|
163
|
-
const [labelValue,
|
|
124
|
+
const [labelValue, setLabelValue] = useState(props.value.labelName);
|
|
164
125
|
const handleDatasourceChange = useCallback((next)=>{
|
|
165
126
|
if (isVariableDatasource(next) || isPrometheusDatasourceSelector(next)) {
|
|
166
127
|
onChange(produce(value, (draft)=>{
|
|
167
128
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
168
129
|
draft.datasource = !isVariableDatasource(next) && isDefaultPromSelector(next) ? undefined : next;
|
|
169
130
|
}));
|
|
170
|
-
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
|
|
171
|
-
...value,
|
|
172
|
-
datasource: next
|
|
173
|
-
});
|
|
174
131
|
return;
|
|
175
132
|
}
|
|
176
133
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
177
134
|
}, [
|
|
178
135
|
value,
|
|
179
|
-
onChange
|
|
180
|
-
queryHandlerSettings
|
|
136
|
+
onChange
|
|
181
137
|
]);
|
|
182
138
|
const handleOnBlurPromQlChange = useCallback((e)=>{
|
|
183
139
|
onChange({
|
|
@@ -188,25 +144,9 @@ export function PrometheusPromQLVariableEditor(props) {
|
|
|
188
144
|
onChange,
|
|
189
145
|
value
|
|
190
146
|
]);
|
|
191
|
-
const trackPromQlChanges = useCallback((e)=>{
|
|
192
|
-
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
|
|
193
|
-
...value,
|
|
194
|
-
expr: e.target.textContent ?? ''
|
|
195
|
-
});
|
|
196
|
-
}, [
|
|
197
|
-
queryHandlerSettings,
|
|
198
|
-
value
|
|
199
|
-
]);
|
|
200
147
|
const handleLabelNameChange = useCallback((e)=>{
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
...value,
|
|
204
|
-
labelName: e.target.value
|
|
205
|
-
});
|
|
206
|
-
}, [
|
|
207
|
-
queryHandlerSettings,
|
|
208
|
-
value
|
|
209
|
-
]);
|
|
148
|
+
setLabelValue(e.target.value);
|
|
149
|
+
}, []);
|
|
210
150
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
211
151
|
spacing: 2,
|
|
212
152
|
children: [
|
|
@@ -229,7 +169,7 @@ export function PrometheusPromQLVariableEditor(props) {
|
|
|
229
169
|
},
|
|
230
170
|
value: value.expr,
|
|
231
171
|
datasource: selectedDatasource,
|
|
232
|
-
onBlur:
|
|
172
|
+
onBlur: handleOnBlurPromQlChange,
|
|
233
173
|
readOnly: props.isReadonly,
|
|
234
174
|
width: "100%"
|
|
235
175
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/prometheus-variables.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { FormControl, Stack, TextField } from '@mui/material';\nimport {\n DatasourceSelect,\n DatasourceSelectProps,\n isVariableDatasource,\n OptionsEditorProps,\n useDatasourceClient,\n useDatasourceSelectValueToSelector,\n VariableOption,\n} from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport { ReactElement, useCallback, useState } from 'react';\nimport { PromQLEditor } from '../components';\nimport {\n DEFAULT_PROM,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n MatrixData,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n PrometheusDatasourceSelector,\n VectorData,\n} from '../model';\nimport { MatcherEditor } from './MatcherEditor';\nimport {\n PrometheusLabelNamesVariableOptions,\n PrometheusLabelValuesVariableOptions,\n PrometheusPromQLVariableOptions,\n} from './types';\n\n/* TODO: \nOpen Question for later improvement\nThe usage of direct onchange here causes an immediate spec update which eventually updates the panel\nThis was probably intentional to allow for quick switching between values.\nShouldn't we update the panel only through the Run Query Button? \nI think we should only track the changes and let the button to Run the query\n*/\n\nexport function PrometheusLabelValuesVariableEditor(\n props: OptionsEditorProps<PrometheusLabelValuesVariableOptions>\n): ReactElement {\n const {\n onChange,\n value,\n value: { datasource },\n queryHandlerSettings,\n } = props;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n const [labelValue, setLabelValue] = useState(props.value.labelName);\n const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = useCallback(\n (next) => {\n if (isVariableDatasource(next) || isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n draft.datasource = !isVariableDatasource(next) && isDefaultPromSelector(next) ? undefined : next;\n })\n );\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, datasource: next });\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n },\n [onChange, queryHandlerSettings, value]\n );\n\n const handleLabelChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setLabelValue(e.target.value);\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, labelName: e.target.value });\n },\n [value, queryHandlerSettings]\n );\n\n const handleMatchEditorsChange = useCallback(\n (e: string[]) => {\n setMatchersValues(e);\n if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({ ...value, matchers: e });\n },\n [value, queryHandlerSettings]\n );\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\">\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n readOnly={props.isReadonly}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <TextField\n label=\"Label Name\"\n required\n value={labelValue}\n onChange={handleLabelChange}\n InputProps={{\n readOnly: props.isReadonly,\n }}\n />\n <MatcherEditor matchers={matchersValues} onChange={handleMatchEditorsChange} isReadonly={props.isReadonly} />\n </Stack>\n );\n}\n\nexport function PrometheusLabelNamesVariableEditor(\n props: OptionsEditorProps<PrometheusLabelNamesVariableOptions>\n): ReactElement {\n const {\n onChange,\n value,\n value: { datasource },\n queryHandlerSettings,\n } = props;\n\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = useCallback(\n (next) => {\n if (isVariableDatasource(next) || isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n draft.datasource = !isVariableDatasource(next) && isDefaultPromSelector(next) ? undefined : next;\n })\n );\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings.setWatchOtherSpecs({ ...value, datasource: next });\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n },\n [onChange, queryHandlerSettings, value]\n );\n\n const handleMatchEditorChange = useCallback(\n (e: string[]) => {\n setMatchersValues(e);\n if (queryHandlerSettings?.setWatchOtherSpecs) {\n queryHandlerSettings.setWatchOtherSpecs({ ...value, matchers: e });\n }\n },\n [value, queryHandlerSettings]\n );\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\">\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n disabled={props.isReadonly}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <MatcherEditor matchers={matchersValues} isReadonly={props.isReadonly} onChange={handleMatchEditorChange} />\n </Stack>\n );\n}\n\nexport function PrometheusPromQLVariableEditor(\n props: OptionsEditorProps<PrometheusPromQLVariableOptions>\n): ReactElement {\n const {\n onChange,\n value,\n value: { datasource },\n queryHandlerSettings,\n } = props;\n const datasourceSelectValue = datasource ?? DEFAULT_PROM;\n const selectedDatasource = useDatasourceSelectValueToSelector(\n datasourceSelectValue,\n PROM_DATASOURCE_KIND\n ) as PrometheusDatasourceSelector;\n\n const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);\n const promURL = client?.options.datasourceUrl;\n const [labelValue, setLableValue] = useState(props.value.labelName);\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = useCallback(\n (next) => {\n if (isVariableDatasource(next) || isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n draft.datasource = !isVariableDatasource(next) && isDefaultPromSelector(next) ? undefined : next;\n })\n );\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings?.setWatchOtherSpecs({ ...value, datasource: next });\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n },\n [value, onChange, queryHandlerSettings]\n );\n\n const handleOnBlurPromQlChange = useCallback(\n (e: React.FocusEvent<HTMLDivElement, Element>) => {\n onChange({ ...value, expr: e.target.textContent ?? '' });\n },\n [onChange, value]\n );\n\n const trackPromQlChanges = useCallback(\n (e: React.FocusEvent<HTMLDivElement, Element>) => {\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings?.setWatchOtherSpecs({ ...value, expr: e.target.textContent ?? '' });\n },\n [queryHandlerSettings, value]\n );\n\n const handleLabelNameChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setLableValue(e.target.value);\n if (queryHandlerSettings?.setWatchOtherSpecs)\n queryHandlerSettings?.setWatchOtherSpecs({ ...value, labelName: e.target.value });\n },\n [queryHandlerSettings, value]\n );\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\">\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={datasourceSelectValue}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n disabled={props.isReadonly}\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={value.expr}\n datasource={selectedDatasource}\n onBlur={queryHandlerSettings?.runWithOnBlur ? handleOnBlurPromQlChange : trackPromQlChanges}\n readOnly={props.isReadonly}\n width=\"100%\"\n />\n <TextField\n label=\"Label Name\"\n required\n value={labelValue}\n InputProps={{\n readOnly: props.isReadonly,\n }}\n onChange={handleLabelNameChange}\n />\n </Stack>\n );\n}\n\nexport function capturingMatrix(matrix: MatrixData, labelName: string): string[] {\n const captured = new Set<string>();\n for (const sample of matrix.result) {\n const value = sample.metric[labelName];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\nexport function capturingVector(vector: VectorData, labelName: string): string[] {\n const captured = new Set<string>();\n for (const sample of vector.result) {\n const value = sample.metric[labelName];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\n/**\n * Takes a list of strings and returns a list of VariableOptions\n */\nexport const stringArrayToVariableOptions = (values?: string[]): VariableOption[] => {\n if (!values) return [];\n return values.map((value) => ({\n value,\n label: value,\n }));\n};\n"],"names":["FormControl","Stack","TextField","DatasourceSelect","isVariableDatasource","useDatasourceClient","useDatasourceSelectValueToSelector","produce","useCallback","useState","PromQLEditor","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","MatcherEditor","PrometheusLabelValuesVariableEditor","props","onChange","value","datasource","queryHandlerSettings","selectedDatasource","labelValue","setLabelValue","labelName","matchersValues","setMatchersValues","matchers","handleDatasourceChange","next","draft","undefined","setWatchOtherSpecs","Error","handleLabelChange","e","target","handleMatchEditorsChange","spacing","margin","datasourcePluginKind","readOnly","isReadonly","labelId","label","required","InputProps","PrometheusLabelNamesVariableEditor","handleMatchEditorChange","disabled","PrometheusPromQLVariableEditor","datasourceSelectValue","data","client","promURL","options","datasourceUrl","setLableValue","handleOnBlurPromQlChange","expr","textContent","trackPromQlChanges","handleLabelNameChange","completeConfig","remote","url","onBlur","runWithOnBlur","width","capturingMatrix","matrix","captured","Set","sample","result","metric","add","Array","from","values","capturingVector","vector","stringArrayToVariableOptions","map"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AACjC,SAASA,WAAW,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAC9D,SACEC,gBAAgB,EAEhBC,oBAAoB,EAEpBC,mBAAmB,EACnBC,kCAAkC,QAE7B,4BAA4B;AACnC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAAuBC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAC5D,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SACEC,YAAY,EACZC,qBAAqB,EACrBC,8BAA8B,EAE9BC,oBAAoB,QAIf,WAAW;AAClB,SAASC,aAAa,QAAQ,kBAAkB;AAOhD;;;;;;AAMA,GAEA,OAAO,SAASC,oCACdC,KAA+D;IAE/D,MAAM,EACJC,QAAQ,EACRC,KAAK,EACLA,OAAO,EAAEC,UAAU,EAAE,EACrBC,oBAAoB,EACrB,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D,OAAOE,MAAM,CAACnD,UAAU;QACtC,IAAIN,UAAUa,WAAW;YACvBwC,SAASK,GAAG,CAAC1D;QACf;IACF;IACA,OAAO2D,MAAMC,IAAI,CAACP,SAASQ,MAAM;AACnC;AAEA;;CAEC,GACD,OAAO,MAAMG,+BAA+B,CAACH;IAC3C,IAAI,CAACA,QAAQ,OAAO,EAAE;IACtB,OAAOA,OAAOI,GAAG,CAAC,CAACjE,QAAW,CAAA;YAC5BA;YACA0B,OAAO1B;QACT,CAAA;AACF,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/prometheus-variables.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { FormControl, Stack, TextField } from '@mui/material';\nimport {\n DatasourceSelect,\n DatasourceSelectProps,\n isVariableDatasource,\n OptionsEditorProps,\n useDatasourceClient,\n useDatasourceSelectValueToSelector,\n VariableOption,\n} from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport { ReactElement, useCallback, useState } from 'react';\nimport { PromQLEditor } from '../components';\nimport {\n DEFAULT_PROM,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n MatrixData,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\n PrometheusDatasourceSelector,\n VectorData,\n} from '../model';\nimport { MatcherEditor } from './MatcherEditor';\nimport {\n PrometheusLabelNamesVariableOptions,\n PrometheusLabelValuesVariableOptions,\n PrometheusPromQLVariableOptions,\n} from './types';\n\nexport function PrometheusLabelValuesVariableEditor(\n props: OptionsEditorProps<PrometheusLabelValuesVariableOptions>\n): ReactElement {\n const {\n onChange,\n value,\n value: { datasource },\n } = props;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n const [labelValue, setLabelValue] = useState(props.value.labelName);\n const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = useCallback(\n (next) => {\n if (isVariableDatasource(next) || isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n draft.datasource = !isVariableDatasource(next) && isDefaultPromSelector(next) ? undefined : next;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n },\n [onChange, value]\n );\n\n const handleLabelChange = useCallback((e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setLabelValue(e.target.value);\n }, []);\n\n const handleMatchEditorsChange = useCallback((e: string[]) => {\n setMatchersValues(e);\n }, []);\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\">\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n readOnly={props.isReadonly}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <TextField\n label=\"Label Name\"\n required\n value={labelValue}\n onChange={handleLabelChange}\n InputProps={{\n readOnly: props.isReadonly,\n }}\n />\n <MatcherEditor matchers={matchersValues} onChange={handleMatchEditorsChange} isReadonly={props.isReadonly} />\n </Stack>\n );\n}\n\nexport function PrometheusLabelNamesVariableEditor(\n props: OptionsEditorProps<PrometheusLabelNamesVariableOptions>\n): ReactElement {\n const {\n onChange,\n value,\n value: { datasource },\n } = props;\n\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = useCallback(\n (next) => {\n if (isVariableDatasource(next) || isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n draft.datasource = !isVariableDatasource(next) && isDefaultPromSelector(next) ? undefined : next;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n },\n [onChange, value]\n );\n\n const handleMatchEditorChange = useCallback((e: string[]) => {\n setMatchersValues(e);\n }, []);\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\">\n <DatasourceSelect\n datasourcePluginKind=\"PrometheusDatasource\"\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n disabled={props.isReadonly}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n />\n </FormControl>\n <MatcherEditor matchers={matchersValues} isReadonly={props.isReadonly} onChange={handleMatchEditorChange} />\n </Stack>\n );\n}\n\nexport function PrometheusPromQLVariableEditor(\n props: OptionsEditorProps<PrometheusPromQLVariableOptions>\n): ReactElement {\n const {\n onChange,\n value,\n value: { datasource },\n } = props;\n const datasourceSelectValue = datasource ?? DEFAULT_PROM;\n const selectedDatasource = useDatasourceSelectValueToSelector(\n datasourceSelectValue,\n PROM_DATASOURCE_KIND\n ) as PrometheusDatasourceSelector;\n\n const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);\n const promURL = client?.options.datasourceUrl;\n const [labelValue, setLabelValue] = useState(props.value.labelName);\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = useCallback(\n (next) => {\n if (isVariableDatasource(next) || isPrometheusDatasourceSelector(next)) {\n onChange(\n produce(value, (draft) => {\n // If they're using the default, just omit the datasource prop (i.e. set to undefined)\n draft.datasource = !isVariableDatasource(next) && isDefaultPromSelector(next) ? undefined : next;\n })\n );\n return;\n }\n\n throw new Error('Got unexpected non-Prometheus datasource selector');\n },\n [value, onChange]\n );\n\n const handleOnBlurPromQlChange = useCallback(\n (e: React.FocusEvent<HTMLDivElement, Element>) => {\n onChange({ ...value, expr: e.target.textContent ?? '' });\n },\n [onChange, value]\n );\n\n const handleLabelNameChange = useCallback((e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n setLabelValue(e.target.value);\n }, []);\n\n return (\n <Stack spacing={2}>\n <FormControl margin=\"dense\">\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={datasourceSelectValue}\n onChange={handleDatasourceChange}\n labelId=\"prom-datasource-label\"\n label=\"Prometheus Datasource\"\n disabled={props.isReadonly}\n />\n </FormControl>\n <PromQLEditor\n completeConfig={{ remote: { url: promURL } }}\n value={value.expr}\n datasource={selectedDatasource}\n onBlur={handleOnBlurPromQlChange}\n readOnly={props.isReadonly}\n width=\"100%\"\n />\n <TextField\n label=\"Label Name\"\n required\n value={labelValue}\n InputProps={{\n readOnly: props.isReadonly,\n }}\n onChange={handleLabelNameChange}\n />\n </Stack>\n );\n}\n\nexport function capturingMatrix(matrix: MatrixData, labelName: string): string[] {\n const captured = new Set<string>();\n for (const sample of matrix.result) {\n const value = sample.metric[labelName];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\nexport function capturingVector(vector: VectorData, labelName: string): string[] {\n const captured = new Set<string>();\n for (const sample of vector.result) {\n const value = sample.metric[labelName];\n if (value !== undefined) {\n captured.add(value);\n }\n }\n return Array.from(captured.values());\n}\n\n/**\n * Takes a list of strings and returns a list of VariableOptions\n */\nexport const stringArrayToVariableOptions = (values?: string[]): VariableOption[] => {\n if (!values) return [];\n return values.map((value) => ({\n value,\n label: value,\n }));\n};\n"],"names":["FormControl","Stack","TextField","DatasourceSelect","isVariableDatasource","useDatasourceClient","useDatasourceSelectValueToSelector","produce","useCallback","useState","PromQLEditor","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","MatcherEditor","PrometheusLabelValuesVariableEditor","props","onChange","value","datasource","selectedDatasource","labelValue","setLabelValue","labelName","matchersValues","setMatchersValues","matchers","handleDatasourceChange","next","draft","undefined","Error","handleLabelChange","e","target","handleMatchEditorsChange","spacing","margin","datasourcePluginKind","readOnly","isReadonly","labelId","label","required","InputProps","PrometheusLabelNamesVariableEditor","handleMatchEditorChange","disabled","PrometheusPromQLVariableEditor","datasourceSelectValue","data","client","promURL","options","datasourceUrl","handleOnBlurPromQlChange","expr","textContent","handleLabelNameChange","completeConfig","remote","url","onBlur","width","capturingMatrix","matrix","captured","Set","sample","result","metric","add","Array","from","values","capturingVector","vector","stringArrayToVariableOptions","map"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AACjC,SAASA,WAAW,EAAEC,KAAK,EAAEC,SAAS,QAAQ,gBAAgB;AAC9D,SACEC,gBAAgB,EAEhBC,oBAAoB,EAEpBC,mBAAmB,EACnBC,kCAAkC,QAE7B,4BAA4B;AACnC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAAuBC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAC5D,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SACEC,YAAY,EACZC,qBAAqB,EACrBC,8BAA8B,EAE9BC,oBAAoB,QAIf,WAAW;AAClB,SAASC,aAAa,QAAQ,kBAAkB;AAOhD,OAAO,SAASC,oCACdC,KAA+D;IAE/D,MAAM,EACJC,QAAQ,EACRC,KAAK,EACLA,OAAO,EAAEC,UAAU,EAAE,EACtB,GAAGH;IACJ,MAAMI,qBAAqBD,cAAcT;IACzC,MAAM,CAACW,YAAYC,cAAc,GAAGd,SAASQ,MAAME,KAAK,CAACK,SAAS;IAClE,MAAM,CAACC,gBAAgBC,kBAAkB,GAAGjB,SAASQ,MAAME,KAAK,CAACQ,QAAQ,IAAI,EAAE;IAC/E,MAAMC,yBAA4DpB,YAChE,CAACqB;QACC,IAAIzB,qBAAqByB,SAAShB,+BAA+BgB,OAAO;YACtEX,SACEX,QAAQY,OAAO,CAACW;gBACd,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