@perses-dev/prometheus-plugin 0.53.0 → 0.53.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.
- package/__mf/js/{Prometheus.712b445d.js → Prometheus.c0c6219f.js} +3 -3
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.86bf76a6.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.e5e35f24.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.b2270799.js +1 -0
- package/__mf/js/async/{__federation_expose_PrometheusTimeSeriesQuery.90b49f7e.js → __federation_expose_PrometheusTimeSeriesQuery.c29461ad.js} +1 -1
- package/__mf/js/{main.61a2057a.js → main.afd47409.js} +2 -2
- package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +8 -1
- package/lib/cjs/plugins/prometheus-variables.js +108 -46
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +8 -1
- 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 +115 -47
- package/lib/plugins/prometheus-variables.js.map +1 -1
- package/lib/plugins/test/setup-tests.d.ts.map +1 -0
- package/lib/plugins/test/setup-tests.js.map +1 -0
- package/mf-manifest.json +17 -17
- package/mf-stats.json +19 -19
- package/package.json +3 -3
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.e7eaadbd.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.24d74e40.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.ea97322b.js +0 -1
- package/lib/test/setup-tests.d.ts.map +0 -1
- package/lib/test/setup-tests.js.map +0 -1
- /package/lib/cjs/{test → plugins/test}/setup-tests.js +0 -0
- /package/lib/{test → plugins/test}/setup-tests.d.ts +0 -0
- /package/lib/{test → plugins/test}/setup-tests.js +0 -0
|
@@ -44,23 +44,53 @@ const _jsxruntime = require("react/jsx-runtime");
|
|
|
44
44
|
const _material = require("@mui/material");
|
|
45
45
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
46
46
|
const _immer = require("immer");
|
|
47
|
+
const _react = require("react");
|
|
47
48
|
const _components = require("../components");
|
|
48
49
|
const _model = require("../model");
|
|
49
50
|
const _MatcherEditor = require("./MatcherEditor");
|
|
50
51
|
function PrometheusLabelValuesVariableEditor(props) {
|
|
51
|
-
const { onChange, value } = props;
|
|
52
|
-
const { datasource } = value;
|
|
52
|
+
const { onChange, value, value: { datasource }, queryHandlerSettings } = props;
|
|
53
53
|
const selectedDatasource = datasource ?? _model.DEFAULT_PROM;
|
|
54
|
-
const
|
|
54
|
+
const [labelValue, setLabelValue] = (0, _react.useState)(props.value.labelName);
|
|
55
|
+
const [matchersValues, setMatchersValues] = (0, _react.useState)(props.value.matchers ?? []);
|
|
56
|
+
const handleDatasourceChange = (0, _react.useCallback)((next)=>{
|
|
55
57
|
if ((0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
56
58
|
onChange((0, _immer.produce)(value, (draft)=>{
|
|
57
59
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
58
60
|
draft.datasource = (0, _model.isDefaultPromSelector)(next) ? undefined : next;
|
|
59
61
|
}));
|
|
62
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
63
|
+
...value,
|
|
64
|
+
datasource: next
|
|
65
|
+
});
|
|
60
66
|
return;
|
|
61
67
|
}
|
|
62
68
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
63
|
-
}
|
|
69
|
+
}, [
|
|
70
|
+
onChange,
|
|
71
|
+
queryHandlerSettings,
|
|
72
|
+
value
|
|
73
|
+
]);
|
|
74
|
+
const handleLabelChange = (0, _react.useCallback)((e)=>{
|
|
75
|
+
setLabelValue(e.target.value);
|
|
76
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
77
|
+
...value,
|
|
78
|
+
labelName: e.target.value
|
|
79
|
+
});
|
|
80
|
+
}, [
|
|
81
|
+
value,
|
|
82
|
+
queryHandlerSettings
|
|
83
|
+
]);
|
|
84
|
+
const handleMatchEditorsChange = (0, _react.useCallback)((e)=>{
|
|
85
|
+
setMatchersValues(e);
|
|
86
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
87
|
+
...value,
|
|
88
|
+
matchers: e
|
|
89
|
+
});
|
|
90
|
+
}, [
|
|
91
|
+
value,
|
|
92
|
+
queryHandlerSettings
|
|
93
|
+
]);
|
|
64
94
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
65
95
|
spacing: 2,
|
|
66
96
|
children: [
|
|
@@ -78,44 +108,54 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
78
108
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
79
109
|
label: "Label Name",
|
|
80
110
|
required: true,
|
|
81
|
-
value:
|
|
82
|
-
onChange:
|
|
83
|
-
props.onChange({
|
|
84
|
-
...props.value,
|
|
85
|
-
labelName: e.target.value
|
|
86
|
-
});
|
|
87
|
-
},
|
|
111
|
+
value: labelValue,
|
|
112
|
+
onChange: handleLabelChange,
|
|
88
113
|
InputProps: {
|
|
89
114
|
readOnly: props.isReadonly
|
|
90
115
|
}
|
|
91
116
|
}),
|
|
92
117
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_MatcherEditor.MatcherEditor, {
|
|
93
|
-
matchers:
|
|
94
|
-
onChange:
|
|
95
|
-
props.onChange({
|
|
96
|
-
...props.value,
|
|
97
|
-
matchers: e
|
|
98
|
-
});
|
|
99
|
-
},
|
|
118
|
+
matchers: matchersValues,
|
|
119
|
+
onChange: handleMatchEditorsChange,
|
|
100
120
|
isReadonly: props.isReadonly
|
|
101
121
|
})
|
|
102
122
|
]
|
|
103
123
|
});
|
|
104
124
|
}
|
|
105
125
|
function PrometheusLabelNamesVariableEditor(props) {
|
|
106
|
-
const { onChange, value } = props;
|
|
107
|
-
const { datasource } = value;
|
|
126
|
+
const { onChange, value, value: { datasource }, queryHandlerSettings } = props;
|
|
108
127
|
const selectedDatasource = datasource ?? _model.DEFAULT_PROM;
|
|
109
|
-
const
|
|
128
|
+
const [matchersValues, setMatchersValues] = (0, _react.useState)(props.value.matchers ?? []);
|
|
129
|
+
const handleDatasourceChange = (0, _react.useCallback)((next)=>{
|
|
110
130
|
if ((0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
111
131
|
onChange((0, _immer.produce)(value, (draft)=>{
|
|
112
132
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
113
133
|
draft.datasource = (0, _model.isDefaultPromSelector)(next) ? undefined : next;
|
|
114
134
|
}));
|
|
135
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
136
|
+
...value,
|
|
137
|
+
datasource: next
|
|
138
|
+
});
|
|
115
139
|
return;
|
|
116
140
|
}
|
|
117
141
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
118
|
-
}
|
|
142
|
+
}, [
|
|
143
|
+
onChange,
|
|
144
|
+
queryHandlerSettings,
|
|
145
|
+
value
|
|
146
|
+
]);
|
|
147
|
+
const handleMatchEditorChange = (0, _react.useCallback)((e)=>{
|
|
148
|
+
setMatchersValues(e);
|
|
149
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) {
|
|
150
|
+
queryHandlerSettings.setWatchOtherSpecs({
|
|
151
|
+
...value,
|
|
152
|
+
matchers: e
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}, [
|
|
156
|
+
value,
|
|
157
|
+
queryHandlerSettings
|
|
158
|
+
]);
|
|
119
159
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
120
160
|
spacing: 2,
|
|
121
161
|
children: [
|
|
@@ -131,34 +171,65 @@ function PrometheusLabelNamesVariableEditor(props) {
|
|
|
131
171
|
})
|
|
132
172
|
}),
|
|
133
173
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_MatcherEditor.MatcherEditor, {
|
|
134
|
-
matchers:
|
|
174
|
+
matchers: matchersValues,
|
|
135
175
|
isReadonly: props.isReadonly,
|
|
136
|
-
onChange:
|
|
137
|
-
props.onChange({
|
|
138
|
-
...props.value,
|
|
139
|
-
matchers: e
|
|
140
|
-
});
|
|
141
|
-
}
|
|
176
|
+
onChange: handleMatchEditorChange
|
|
142
177
|
})
|
|
143
178
|
]
|
|
144
179
|
});
|
|
145
180
|
}
|
|
146
181
|
function PrometheusPromQLVariableEditor(props) {
|
|
147
|
-
const { onChange, value } = props;
|
|
148
|
-
const { datasource } = value;
|
|
182
|
+
const { onChange, value, value: { datasource }, queryHandlerSettings } = props;
|
|
149
183
|
const selectedDatasource = datasource ?? _model.DEFAULT_PROM;
|
|
150
184
|
const { data: client } = (0, _pluginsystem.useDatasourceClient)(selectedDatasource);
|
|
151
185
|
const promURL = client?.options.datasourceUrl;
|
|
152
|
-
const
|
|
186
|
+
const [labelValue, setLableValue] = (0, _react.useState)(props.value.labelName);
|
|
187
|
+
const handleDatasourceChange = (0, _react.useCallback)((next)=>{
|
|
153
188
|
if ((0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
154
189
|
onChange((0, _immer.produce)(value, (draft)=>{
|
|
155
190
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
156
191
|
draft.datasource = (0, _model.isDefaultPromSelector)(next) ? undefined : next;
|
|
157
192
|
}));
|
|
193
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
|
|
194
|
+
...value,
|
|
195
|
+
datasource: next
|
|
196
|
+
});
|
|
158
197
|
return;
|
|
159
198
|
}
|
|
160
199
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
161
|
-
}
|
|
200
|
+
}, [
|
|
201
|
+
value,
|
|
202
|
+
onChange,
|
|
203
|
+
queryHandlerSettings
|
|
204
|
+
]);
|
|
205
|
+
const handleOnBlurPromQlChange = (0, _react.useCallback)((e)=>{
|
|
206
|
+
onChange({
|
|
207
|
+
...value,
|
|
208
|
+
expr: e.target.textContent ?? ''
|
|
209
|
+
});
|
|
210
|
+
}, [
|
|
211
|
+
onChange,
|
|
212
|
+
value
|
|
213
|
+
]);
|
|
214
|
+
const trackPromQlChanges = (0, _react.useCallback)((e)=>{
|
|
215
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
|
|
216
|
+
...value,
|
|
217
|
+
expr: e.target.textContent ?? ''
|
|
218
|
+
});
|
|
219
|
+
}, [
|
|
220
|
+
queryHandlerSettings,
|
|
221
|
+
value
|
|
222
|
+
]);
|
|
223
|
+
const handleLabelNameChange = (0, _react.useCallback)((e)=>{
|
|
224
|
+
setLableValue(e.target.value);
|
|
225
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
|
|
226
|
+
...value,
|
|
227
|
+
labelName: e.target.value
|
|
228
|
+
});
|
|
229
|
+
}, [
|
|
230
|
+
queryHandlerSettings,
|
|
231
|
+
value
|
|
232
|
+
]);
|
|
162
233
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
163
234
|
spacing: 2,
|
|
164
235
|
children: [
|
|
@@ -181,27 +252,18 @@ function PrometheusPromQLVariableEditor(props) {
|
|
|
181
252
|
},
|
|
182
253
|
value: value.expr,
|
|
183
254
|
datasource: selectedDatasource,
|
|
184
|
-
onBlur:
|
|
185
|
-
props.onChange({
|
|
186
|
-
...props.value,
|
|
187
|
-
expr: event.target.textContent ?? ''
|
|
188
|
-
});
|
|
189
|
-
},
|
|
255
|
+
onBlur: queryHandlerSettings?.runWithOnBlur ? handleOnBlurPromQlChange : trackPromQlChanges,
|
|
190
256
|
readOnly: props.isReadonly,
|
|
191
257
|
width: "100%"
|
|
192
258
|
}),
|
|
193
259
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
194
260
|
label: "Label Name",
|
|
195
|
-
|
|
261
|
+
required: true,
|
|
262
|
+
value: labelValue,
|
|
196
263
|
InputProps: {
|
|
197
264
|
readOnly: props.isReadonly
|
|
198
265
|
},
|
|
199
|
-
onChange:
|
|
200
|
-
props.onChange({
|
|
201
|
-
...props.value,
|
|
202
|
-
labelName: e.target.value
|
|
203
|
-
});
|
|
204
|
-
}
|
|
266
|
+
onChange: handleLabelNameChange
|
|
205
267
|
})
|
|
206
268
|
]
|
|
207
269
|
});
|
|
@@ -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,EAAe,MAAM,OAAO,CAAC;AAYlD,OAAO,EACL,oCAAoC,EAIrC,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,GAAG,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;AAYlD,OAAO,EACL,oCAAoC,EAIrC,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,GAAG,YAAY,CAuHzG"}
|
|
@@ -36,11 +36,18 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
36
36
|
const minStepPlaceholder = minStep ?? (datasourceResource && (datasourceResource?.plugin.spec).scrapeInterval) ?? DEFAULT_SCRAPE_INTERVAL;
|
|
37
37
|
const handleDatasourceChange = (next)=>{
|
|
38
38
|
if (isPrometheusDatasourceSelector(next)) {
|
|
39
|
-
|
|
39
|
+
/* Good to know: The usage of onchange here causes an immediate spec update which eventually updates the panel
|
|
40
|
+
This was probably intentional to allow for quick switching between datasources.
|
|
41
|
+
Could have been triggered only with Run Query button as well.
|
|
42
|
+
*/ onChange(produce(value, (draft)=>{
|
|
40
43
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
41
44
|
const nextDatasource = isDefaultPromSelector(next) ? undefined : next;
|
|
42
45
|
draft.datasource = nextDatasource;
|
|
43
46
|
}));
|
|
47
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
48
|
+
...value,
|
|
49
|
+
datasource: next
|
|
50
|
+
});
|
|
44
51
|
return;
|
|
45
52
|
}
|
|
46
53
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
@@ -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 } = 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 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 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 />\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 />\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 />\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 />\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","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","handlePromQlEditorChanges","e","watchQueryChanges","handleLegendSpecChange","target","setWatchOtherSpecs","seriesNameFormat","handleMinStepSpecChange","spacing","margin","fullWidth","datasourcePluginKind","labelId","label","notched","completeConfig","remote","url","onBlur","runWithOnBlur","direction","placeholder","helperText","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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ACZC,YAAW;wBACXrD,OAAOe,UAAU;wBACjBhB,UAAUmC;wBACVe,QAAQ9C,sBAAsB+C,gBAAgBjC,mBAAmBY;;kCAEnE,KAAC3C;wBACC0D,OAAM;wBACNQ,aAAa/B;wBACbgC,YAAW;wBACXrD,OAAOkB,WAAW;wBAClBnB,UAAUuC;wBACVW,QAAQ9C,sBAAsB+C,gBAAgB9B,oBAAoBS;wBAClEyB,IAAI;4BAAEC,OAAO;wBAAQ;;;;;;AAK/B"}
|
|
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 } = 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 />\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 />\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 />\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 />\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","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","completeConfig","remote","url","onBlur","runWithOnBlur","direction","placeholder","helperText","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;AAC9D,SAAuBC,WAAW,QAAQ,QAAQ;AAClD,SACEC,YAAY,EAEZC,qBAAqB,EACrBC,8BAA8B,EAC9BC,oBAAoB,QAGf,cAAc;AACrB,SAASC,uBAAuB,QAAkC,WAAW;AAC7E,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAEEC,aAAa,EACbC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;kCAEnE,KAAC3C;wBACC0D,OAAM;wBACNQ,aAAa/B;wBACbgC,YAAW;wBACXrD,OAAOkB,WAAW;wBAClBnB,UAAUuC;wBACVW,QAAQ9C,sBAAsB+C,gBAAgB9B,oBAAoBS;wBAClEyB,IAAI;4BAAEC,OAAO;wBAAQ;;;;;;AAK/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus-variables.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-variables.tsx"],"names":[],"mappings":"AAaA,OAAO,EAGL,kBAAkB,EAElB,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"prometheus-variables.d.ts","sourceRoot":"","sources":["../../../src/plugins/prometheus-variables.tsx"],"names":[],"mappings":"AAaA,OAAO,EAGL,kBAAkB,EAElB,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAE5D,OAAO,EAIL,UAAU,EAGV,UAAU,EACX,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,mCAAmC,EACnC,oCAAoC,EACpC,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAUjB,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,kBAAkB,CAAC,oCAAoC,CAAC,GAC9D,YAAY,CAsEd;AAED,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,kBAAkB,CAAC,mCAAmC,CAAC,GAC7D,YAAY,CAsDd;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,kBAAkB,CAAC,+BAA+B,CAAC,GACzD,YAAY,CAsFd;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"}
|
|
@@ -14,23 +14,59 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
import { FormControl, Stack, TextField } from '@mui/material';
|
|
15
15
|
import { DatasourceSelect, useDatasourceClient } from '@perses-dev/plugin-system';
|
|
16
16
|
import { produce } from 'immer';
|
|
17
|
+
import { useCallback, useState } from 'react';
|
|
17
18
|
import { PromQLEditor } from '../components';
|
|
18
19
|
import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../model';
|
|
19
20
|
import { MatcherEditor } from './MatcherEditor';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
/* TODO:
|
|
22
|
+
Open Question for later improvement
|
|
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;
|
|
23
29
|
const selectedDatasource = datasource ?? DEFAULT_PROM;
|
|
24
|
-
const
|
|
30
|
+
const [labelValue, setLabelValue] = useState(props.value.labelName);
|
|
31
|
+
const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);
|
|
32
|
+
const handleDatasourceChange = useCallback((next)=>{
|
|
25
33
|
if (isPrometheusDatasourceSelector(next)) {
|
|
26
34
|
onChange(produce(value, (draft)=>{
|
|
27
35
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
28
36
|
draft.datasource = isDefaultPromSelector(next) ? undefined : next;
|
|
29
37
|
}));
|
|
38
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
39
|
+
...value,
|
|
40
|
+
datasource: next
|
|
41
|
+
});
|
|
30
42
|
return;
|
|
31
43
|
}
|
|
32
44
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
33
|
-
}
|
|
45
|
+
}, [
|
|
46
|
+
onChange,
|
|
47
|
+
queryHandlerSettings,
|
|
48
|
+
value
|
|
49
|
+
]);
|
|
50
|
+
const handleLabelChange = useCallback((e)=>{
|
|
51
|
+
setLabelValue(e.target.value);
|
|
52
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
53
|
+
...value,
|
|
54
|
+
labelName: e.target.value
|
|
55
|
+
});
|
|
56
|
+
}, [
|
|
57
|
+
value,
|
|
58
|
+
queryHandlerSettings
|
|
59
|
+
]);
|
|
60
|
+
const handleMatchEditorsChange = useCallback((e)=>{
|
|
61
|
+
setMatchersValues(e);
|
|
62
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
63
|
+
...value,
|
|
64
|
+
matchers: e
|
|
65
|
+
});
|
|
66
|
+
}, [
|
|
67
|
+
value,
|
|
68
|
+
queryHandlerSettings
|
|
69
|
+
]);
|
|
34
70
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
35
71
|
spacing: 2,
|
|
36
72
|
children: [
|
|
@@ -48,44 +84,54 @@ export function PrometheusLabelValuesVariableEditor(props) {
|
|
|
48
84
|
/*#__PURE__*/ _jsx(TextField, {
|
|
49
85
|
label: "Label Name",
|
|
50
86
|
required: true,
|
|
51
|
-
value:
|
|
52
|
-
onChange:
|
|
53
|
-
props.onChange({
|
|
54
|
-
...props.value,
|
|
55
|
-
labelName: e.target.value
|
|
56
|
-
});
|
|
57
|
-
},
|
|
87
|
+
value: labelValue,
|
|
88
|
+
onChange: handleLabelChange,
|
|
58
89
|
InputProps: {
|
|
59
90
|
readOnly: props.isReadonly
|
|
60
91
|
}
|
|
61
92
|
}),
|
|
62
93
|
/*#__PURE__*/ _jsx(MatcherEditor, {
|
|
63
|
-
matchers:
|
|
64
|
-
onChange:
|
|
65
|
-
props.onChange({
|
|
66
|
-
...props.value,
|
|
67
|
-
matchers: e
|
|
68
|
-
});
|
|
69
|
-
},
|
|
94
|
+
matchers: matchersValues,
|
|
95
|
+
onChange: handleMatchEditorsChange,
|
|
70
96
|
isReadonly: props.isReadonly
|
|
71
97
|
})
|
|
72
98
|
]
|
|
73
99
|
});
|
|
74
100
|
}
|
|
75
101
|
export function PrometheusLabelNamesVariableEditor(props) {
|
|
76
|
-
const { onChange, value } = props;
|
|
77
|
-
const { datasource } = value;
|
|
102
|
+
const { onChange, value, value: { datasource }, queryHandlerSettings } = props;
|
|
78
103
|
const selectedDatasource = datasource ?? DEFAULT_PROM;
|
|
79
|
-
const
|
|
104
|
+
const [matchersValues, setMatchersValues] = useState(props.value.matchers ?? []);
|
|
105
|
+
const handleDatasourceChange = useCallback((next)=>{
|
|
80
106
|
if (isPrometheusDatasourceSelector(next)) {
|
|
81
107
|
onChange(produce(value, (draft)=>{
|
|
82
108
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
83
109
|
draft.datasource = isDefaultPromSelector(next) ? undefined : next;
|
|
84
110
|
}));
|
|
111
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings.setWatchOtherSpecs({
|
|
112
|
+
...value,
|
|
113
|
+
datasource: next
|
|
114
|
+
});
|
|
85
115
|
return;
|
|
86
116
|
}
|
|
87
117
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
88
|
-
}
|
|
118
|
+
}, [
|
|
119
|
+
onChange,
|
|
120
|
+
queryHandlerSettings,
|
|
121
|
+
value
|
|
122
|
+
]);
|
|
123
|
+
const handleMatchEditorChange = useCallback((e)=>{
|
|
124
|
+
setMatchersValues(e);
|
|
125
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) {
|
|
126
|
+
queryHandlerSettings.setWatchOtherSpecs({
|
|
127
|
+
...value,
|
|
128
|
+
matchers: e
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}, [
|
|
132
|
+
value,
|
|
133
|
+
queryHandlerSettings
|
|
134
|
+
]);
|
|
89
135
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
90
136
|
spacing: 2,
|
|
91
137
|
children: [
|
|
@@ -101,34 +147,65 @@ export function PrometheusLabelNamesVariableEditor(props) {
|
|
|
101
147
|
})
|
|
102
148
|
}),
|
|
103
149
|
/*#__PURE__*/ _jsx(MatcherEditor, {
|
|
104
|
-
matchers:
|
|
150
|
+
matchers: matchersValues,
|
|
105
151
|
isReadonly: props.isReadonly,
|
|
106
|
-
onChange:
|
|
107
|
-
props.onChange({
|
|
108
|
-
...props.value,
|
|
109
|
-
matchers: e
|
|
110
|
-
});
|
|
111
|
-
}
|
|
152
|
+
onChange: handleMatchEditorChange
|
|
112
153
|
})
|
|
113
154
|
]
|
|
114
155
|
});
|
|
115
156
|
}
|
|
116
157
|
export function PrometheusPromQLVariableEditor(props) {
|
|
117
|
-
const { onChange, value } = props;
|
|
118
|
-
const { datasource } = value;
|
|
158
|
+
const { onChange, value, value: { datasource }, queryHandlerSettings } = props;
|
|
119
159
|
const selectedDatasource = datasource ?? DEFAULT_PROM;
|
|
120
160
|
const { data: client } = useDatasourceClient(selectedDatasource);
|
|
121
161
|
const promURL = client?.options.datasourceUrl;
|
|
122
|
-
const
|
|
162
|
+
const [labelValue, setLableValue] = useState(props.value.labelName);
|
|
163
|
+
const handleDatasourceChange = useCallback((next)=>{
|
|
123
164
|
if (isPrometheusDatasourceSelector(next)) {
|
|
124
165
|
onChange(produce(value, (draft)=>{
|
|
125
166
|
// If they're using the default, just omit the datasource prop (i.e. set to undefined)
|
|
126
167
|
draft.datasource = isDefaultPromSelector(next) ? undefined : next;
|
|
127
168
|
}));
|
|
169
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
|
|
170
|
+
...value,
|
|
171
|
+
datasource: next
|
|
172
|
+
});
|
|
128
173
|
return;
|
|
129
174
|
}
|
|
130
175
|
throw new Error('Got unexpected non-Prometheus datasource selector');
|
|
131
|
-
}
|
|
176
|
+
}, [
|
|
177
|
+
value,
|
|
178
|
+
onChange,
|
|
179
|
+
queryHandlerSettings
|
|
180
|
+
]);
|
|
181
|
+
const handleOnBlurPromQlChange = useCallback((e)=>{
|
|
182
|
+
onChange({
|
|
183
|
+
...value,
|
|
184
|
+
expr: e.target.textContent ?? ''
|
|
185
|
+
});
|
|
186
|
+
}, [
|
|
187
|
+
onChange,
|
|
188
|
+
value
|
|
189
|
+
]);
|
|
190
|
+
const trackPromQlChanges = useCallback((e)=>{
|
|
191
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
|
|
192
|
+
...value,
|
|
193
|
+
expr: e.target.textContent ?? ''
|
|
194
|
+
});
|
|
195
|
+
}, [
|
|
196
|
+
queryHandlerSettings,
|
|
197
|
+
value
|
|
198
|
+
]);
|
|
199
|
+
const handleLabelNameChange = useCallback((e)=>{
|
|
200
|
+
setLableValue(e.target.value);
|
|
201
|
+
if (queryHandlerSettings?.setWatchOtherSpecs) queryHandlerSettings?.setWatchOtherSpecs({
|
|
202
|
+
...value,
|
|
203
|
+
labelName: e.target.value
|
|
204
|
+
});
|
|
205
|
+
}, [
|
|
206
|
+
queryHandlerSettings,
|
|
207
|
+
value
|
|
208
|
+
]);
|
|
132
209
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
133
210
|
spacing: 2,
|
|
134
211
|
children: [
|
|
@@ -151,27 +228,18 @@ export function PrometheusPromQLVariableEditor(props) {
|
|
|
151
228
|
},
|
|
152
229
|
value: value.expr,
|
|
153
230
|
datasource: selectedDatasource,
|
|
154
|
-
onBlur:
|
|
155
|
-
props.onChange({
|
|
156
|
-
...props.value,
|
|
157
|
-
expr: event.target.textContent ?? ''
|
|
158
|
-
});
|
|
159
|
-
},
|
|
231
|
+
onBlur: queryHandlerSettings?.runWithOnBlur ? handleOnBlurPromQlChange : trackPromQlChanges,
|
|
160
232
|
readOnly: props.isReadonly,
|
|
161
233
|
width: "100%"
|
|
162
234
|
}),
|
|
163
235
|
/*#__PURE__*/ _jsx(TextField, {
|
|
164
236
|
label: "Label Name",
|
|
165
|
-
|
|
237
|
+
required: true,
|
|
238
|
+
value: labelValue,
|
|
166
239
|
InputProps: {
|
|
167
240
|
readOnly: props.isReadonly
|
|
168
241
|
},
|
|
169
|
-
onChange:
|
|
170
|
-
props.onChange({
|
|
171
|
-
...props.value,
|
|
172
|
-
labelName: e.target.value
|
|
173
|
-
});
|
|
174
|
-
}
|
|
242
|
+
onChange: handleLabelNameChange
|
|
175
243
|
})
|
|
176
244
|
]
|
|
177
245
|
});
|
|
@@ -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 OptionsEditorProps,\n useDatasourceClient,\n VariableOption,\n} from '@perses-dev/plugin-system';\nimport { produce } from 'immer';\nimport { ReactElement } from 'react';\nimport { PromQLEditor } from '../components';\nimport {\n DEFAULT_PROM,\n isDefaultPromSelector,\n isPrometheusDatasourceSelector,\n MatrixData,\n PROM_DATASOURCE_KIND,\n PrometheusClient,\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 { onChange, value } = props;\n const { datasource } = value;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (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 = isDefaultPromSelector(next) ? undefined : next;\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\">\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={props.value.labelName}\n onChange={(e) => {\n props.onChange({ ...props.value, labelName: e.target.value });\n }}\n InputProps={{\n readOnly: props.isReadonly,\n }}\n />\n <MatcherEditor\n matchers={props.value.matchers ?? []}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n isReadonly={props.isReadonly}\n />\n </Stack>\n );\n}\n\nexport function PrometheusLabelNamesVariableEditor(\n props: OptionsEditorProps<PrometheusLabelNamesVariableOptions>\n): ReactElement {\n const { onChange, value } = props;\n const { datasource } = value;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (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 = isDefaultPromSelector(next) ? undefined : next;\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\">\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\n matchers={props.value.matchers ?? []}\n isReadonly={props.isReadonly}\n onChange={(e) => {\n props.onChange({ ...props.value, matchers: e });\n }}\n />\n </Stack>\n );\n}\n\nexport function PrometheusPromQLVariableEditor(\n props: OptionsEditorProps<PrometheusPromQLVariableOptions>\n): ReactElement {\n const { onChange, value } = props;\n const { datasource } = value;\n const selectedDatasource = datasource ?? DEFAULT_PROM;\n\n const { data: client } = useDatasourceClient<PrometheusClient>(selectedDatasource);\n const promURL = client?.options.datasourceUrl;\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (next) => {\n if (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 = isDefaultPromSelector(next) ? undefined : next;\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\">\n <DatasourceSelect\n datasourcePluginKind={PROM_DATASOURCE_KIND}\n value={selectedDatasource}\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={(event) => {\n props.onChange({ ...props.value, expr: event.target.textContent ?? '' });\n }}\n readOnly={props.isReadonly}\n width=\"100%\"\n />\n <TextField\n label=\"Label Name\"\n value={props.value.labelName}\n InputProps={{\n readOnly: props.isReadonly,\n }}\n onChange={(e) => {\n props.onChange({ ...props.value, labelName: e.target.value });\n }}\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","useDatasourceClient","produce","PromQLEditor","DEFAULT_PROM","isDefaultPromSelector","isPrometheusDatasourceSelector","PROM_DATASOURCE_KIND","MatcherEditor","PrometheusLabelValuesVariableEditor","props","onChange","value","datasource","selectedDatasource","handleDatasourceChange","next","draft","undefined","Error","spacing","margin","datasourcePluginKind","readOnly","isReadonly","labelId","label","required","labelName","e","target","InputProps","matchers","PrometheusLabelNamesVariableEditor","disabled","PrometheusPromQLVariableEditor","data","client","promURL","options","datasourceUrl","completeConfig","remote","url","expr","onBlur","event","textContent","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,EAGhBC,mBAAmB,QAEd,4BAA4B;AACnC,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SACEC,YAAY,EACZC,qBAAqB,EACrBC,8BAA8B,EAE9BC,oBAAoB,QAGf,WAAW;AAClB,SAASC,aAAa,QAAQ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B,CAACH;IAC3C,IAAI,CAACA,QAAQ,OAAO,EAAE;IACtB,OAAOA,OAAOI,GAAG,CAAC,CAACnD,QAAW,CAAA;YAC5BA;YACAc,OAAOd;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 OptionsEditorProps,\n useDatasourceClient,\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 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 (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 = 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 (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 = 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 selectedDatasource = datasource ?? DEFAULT_PROM;\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 (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 = 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={selectedDatasource}\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","useDatasourceClient","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","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,EAGhBC,mBAAmB,QAEd,4BAA4B;AACnC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAAuBC,WA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ACnC;AAEA,OAAO,SAASC,gBAAgBC,MAAkB,EAAExD,SAAiB;IACnE,MAAM8C,WAAW,IAAIC;IACrB,KAAK,MAAMC,UAAUQ,OAAOP,MAAM,CAAE;QAClC,MAAMvD,QAAQsD,OAAOE,MAAM,CAAClD,UAAU;QACtC,IAAIN,UAAUa,WAAW;YACvBuC,SAASK,GAAG,CAACzD;QACf;IACF;IACA,OAAO0D,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,CAAChE,QAAW,CAAA;YAC5BA;YACA0B,OAAO1B;QACT,CAAA;AACF,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../../../src/plugins/test/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,yCAAyC,CAAC"}
|