@perses-dev/prometheus-plugin 0.53.0 → 0.53.2
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.7d2f1afa.js} +3 -3
- package/__mf/js/async/{8706.9a6f6579.js → 8706.a36614fb.js} +1 -1
- 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.82b19cf2.js +1 -0
- package/__mf/js/{main.61a2057a.js → main.b9fe0e65.js} +2 -2
- package/lib/cjs/components/PromQLEditor.js +3 -1
- package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +17 -6
- package/lib/cjs/plugins/prometheus-variables.js +108 -46
- package/lib/components/PromQLEditor.d.ts +2 -1
- package/lib/components/PromQLEditor.d.ts.map +1 -1
- package/lib/components/PromQLEditor.js +3 -1
- package/lib/components/PromQLEditor.js.map +1 -1
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +17 -6
- 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 +24 -24
- package/mf-stats.json +29 -29
- 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/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.90b49f7e.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
|
});
|
|
@@ -5,6 +5,7 @@ import { PrometheusDatasourceSelector } from '../model';
|
|
|
5
5
|
export type PromQLEditorProps = {
|
|
6
6
|
completeConfig: CompleteConfiguration;
|
|
7
7
|
datasource: PrometheusDatasourceSelector;
|
|
8
|
+
isReadOnly?: boolean;
|
|
8
9
|
} & Omit<ReactCodeMirrorProps, 'theme' | 'extensions'>;
|
|
9
|
-
export declare function PromQLEditor({ completeConfig, datasource, ...rest }: PromQLEditorProps): ReactElement;
|
|
10
|
+
export declare function PromQLEditor({ completeConfig, datasource, isReadOnly, ...rest }: PromQLEditorProps): ReactElement;
|
|
10
11
|
//# sourceMappingURL=PromQLEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromQLEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PromQLEditor.tsx"],"names":[],"mappings":"AAaA,OAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAmB,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAI1F,OAAO,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAC;AAIxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AASxD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,qBAAqB,CAAC;IACtC,UAAU,EAAE,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"PromQLEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PromQLEditor.tsx"],"names":[],"mappings":"AAaA,OAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAmB,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAI1F,OAAO,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAC;AAIxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AASxD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,qBAAqB,CAAC;IACtC,UAAU,EAAE,4BAA4B,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,YAAY,CAAC,CAAC;AAEvD,wBAAgB,YAAY,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,GAAG,YAAY,CAwHjH"}
|
|
@@ -26,10 +26,11 @@ import TreeNode from './TreeNode';
|
|
|
26
26
|
const treeViewStr = 'Tree View';
|
|
27
27
|
const treeViewOpenStr = 'Open ' + treeViewStr;
|
|
28
28
|
const treeViewCloseStr = 'Close ' + treeViewStr;
|
|
29
|
-
export function PromQLEditor({ completeConfig, datasource, ...rest }) {
|
|
29
|
+
export function PromQLEditor({ completeConfig, datasource, isReadOnly, ...rest }) {
|
|
30
30
|
const theme = useTheme();
|
|
31
31
|
const isDarkMode = theme.palette.mode === 'dark';
|
|
32
32
|
const [isTreeViewVisible, setTreeViewVisible] = useState(false);
|
|
33
|
+
const readOnly = isReadOnly ?? false;
|
|
33
34
|
const promQLExtension = useMemo(()=>{
|
|
34
35
|
return new PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();
|
|
35
36
|
}, [
|
|
@@ -70,6 +71,7 @@ export function PromQLEditor({ completeConfig, datasource, ...rest }) {
|
|
|
70
71
|
border: `1px solid ${theme.palette.divider}`
|
|
71
72
|
},
|
|
72
73
|
theme: isDarkMode ? 'dark' : 'light',
|
|
74
|
+
readOnly: readOnly,
|
|
73
75
|
basicSetup: {
|
|
74
76
|
highlightActiveLine: false,
|
|
75
77
|
highlightActiveLineGutter: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PromQLEditor.tsx"],"sourcesContent":["// Copyright 2025 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 CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror';\nimport { PromQLExtension, CompleteConfiguration } from '@prometheus-io/codemirror-promql';\nimport { EditorView } from '@codemirror/view';\nimport { useTheme, CircularProgress, InputLabel, Stack, IconButton, Tooltip } from '@mui/material';\nimport FileTreeIcon from 'mdi-material-ui/FileTree';\nimport { ReactElement, useMemo, useState } from 'react';\nimport { ErrorAlert } from '@perses-dev/components';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useReplaceVariablesInString } from '@perses-dev/plugin-system';\nimport { PrometheusDatasourceSelector } from '../model';\nimport { replacePromBuiltinVariables } from '../plugins/prometheus-time-series-query/replace-prom-builtin-variables';\nimport { useParseQuery } from './query';\nimport TreeNode from './TreeNode';\n\nconst treeViewStr = 'Tree View';\nconst treeViewOpenStr = 'Open ' + treeViewStr;\nconst treeViewCloseStr = 'Close ' + treeViewStr;\n\nexport type PromQLEditorProps = {\n completeConfig: CompleteConfiguration;\n datasource: PrometheusDatasourceSelector;\n} & Omit<ReactCodeMirrorProps, 'theme' | 'extensions'>;\n\nexport function PromQLEditor({ completeConfig, datasource, ...rest }: PromQLEditorProps): ReactElement {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n const [isTreeViewVisible, setTreeViewVisible] = useState(false);\n\n const promQLExtension = useMemo(() => {\n return new PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();\n }, [completeConfig]);\n\n let queryExpr = useReplaceVariablesInString(rest.value);\n if (queryExpr) {\n // TODO placeholder values for steps to be replaced with actual values\n // Looks like providing proper values involves some refactoring: currently we'd need to rely on the timeseries query context,\n // but these step values are actually computed independently / before the queries are getting fired, so it's useless to fire\n // queries here, so maybe we should extract this part to independant hook(s), to be reused here?\n queryExpr = replacePromBuiltinVariables(queryExpr, 12345, 12345);\n }\n\n const { data: parseQueryResponse, isLoading, error } = useParseQuery(queryExpr ?? '', datasource, isTreeViewVisible);\n\n const handleShowTreeView = (): void => {\n setTreeViewVisible(!isTreeViewVisible);\n };\n\n return (\n <Stack position=\"relative\">\n <InputLabel // reproduce the same kind of input label that regular MUI TextFields have\n shrink\n sx={{\n position: 'absolute',\n top: '-12px',\n left: '10px',\n padding: '0 4px',\n color: theme.palette.text.primary,\n zIndex: 1,\n }}\n >\n PromQL Expression\n </InputLabel>\n {/* TODO: We need to wait for this to be merged, then we need to add proper e2e for some scenarios */}\n <CodeMirror\n data-testid=\"promql_expression_editor\"\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n basicSetup={{\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n foldGutter: false,\n }}\n extensions={[\n EditorView.lineWrapping,\n promQLExtension,\n EditorView.theme({\n '.cm-content': {\n paddingTop: '8px',\n paddingBottom: '8px',\n paddingRight: '40px', // offset for the tree view button\n },\n }),\n ]}\n placeholder=\"Example: sum(rate(http_requests_total[5m]))\"\n />\n {queryExpr && (\n <>\n <Tooltip title={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}>\n <IconButton\n aria-label={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}\n onClick={handleShowTreeView}\n sx={{ position: 'absolute', right: '5px', top: '5px' }}\n size=\"small\"\n key=\"tree-view-button\"\n >\n <FileTreeIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {isTreeViewVisible && (\n <div style={{ border: `1px solid ${theme.palette.divider}`, position: 'relative' }}>\n <Tooltip title={treeViewCloseStr}>\n <IconButton\n aria-label={treeViewCloseStr}\n onClick={() => setTreeViewVisible(false)}\n sx={{ position: 'absolute', top: '5px', right: '5px' }}\n size=\"small\"\n key=\"tree-view-close-button\"\n >\n <CloseIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {error ? (\n // Here the user is able to hide the error alert\n <ErrorAlert\n error={{\n name: `${treeViewStr} not available`,\n message: error.message,\n }}\n />\n ) : (\n <div\n style={{\n padding: `${theme.spacing(1.5)} ${theme.spacing(1.5)} 0 ${theme.spacing(1.5)}`, // let paddingBottom at 0 because nodes have margin-bottom\n overflowX: 'auto',\n backgroundColor: theme.palette.background.default,\n }}\n >\n {isLoading ? (\n <CircularProgress />\n ) : parseQueryResponse?.data ? (\n <TreeNode node={parseQueryResponse.data} reverse={false} childIdx={0} datasource={datasource} />\n ) : null}\n </div>\n )}\n </div>\n )}\n </>\n )}\n </Stack>\n );\n}\n"],"names":["CodeMirror","PromQLExtension","EditorView","useTheme","CircularProgress","InputLabel","Stack","IconButton","Tooltip","FileTreeIcon","useMemo","useState","ErrorAlert","CloseIcon","useReplaceVariablesInString","replacePromBuiltinVariables","useParseQuery","TreeNode","treeViewStr","treeViewOpenStr","treeViewCloseStr","PromQLEditor","completeConfig","datasource","rest","theme","isDarkMode","palette","mode","isTreeViewVisible","setTreeViewVisible","promQLExtension","activateLinter","setComplete","asExtension","queryExpr","value","data","parseQueryResponse","isLoading","error","handleShowTreeView","position","shrink","sx","top","left","padding","color","text","primary","zIndex","data-testid","style","border","divider","basicSetup","highlightActiveLine","highlightActiveLineGutter","foldGutter","extensions","lineWrapping","paddingTop","paddingBottom","paddingRight","placeholder","title","aria-label","onClick","right","size","fontSize","div","name","message","spacing","overflowX","backgroundColor","background","default","node","reverse","childIdx"],"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,OAAOA,gBAA0C,wBAAwB;AACzE,SAASC,eAAe,QAA+B,mCAAmC;AAC1F,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,QAAQ,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAEC,OAAO,QAAQ,gBAAgB;AACnG,OAAOC,kBAAkB,2BAA2B;AACpD,SAAuBC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACxD,SAASC,UAAU,QAAQ,yBAAyB;AACpD,OAAOC,eAAe,wBAAwB;AAC9C,SAASC,2BAA2B,QAAQ,4BAA4B;AAExE,SAASC,2BAA2B,QAAQ,yEAAyE;AACrH,SAASC,aAAa,QAAQ,UAAU;AACxC,OAAOC,cAAc,aAAa;AAElC,MAAMC,cAAc;AACpB,MAAMC,kBAAkB,UAAUD;AAClC,MAAME,mBAAmB,WAAWF;AAOpC,OAAO,SAASG,aAAa,EAAEC,cAAc,EAAEC,UAAU,EAAE,GAAGC,MAAyB;IACrF,MAAMC,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yright 2025 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 CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror';\nimport { PromQLExtension, CompleteConfiguration } from '@prometheus-io/codemirror-promql';\nimport { EditorView } from '@codemirror/view';\nimport { useTheme, CircularProgress, InputLabel, Stack, IconButton, Tooltip } from '@mui/material';\nimport FileTreeIcon from 'mdi-material-ui/FileTree';\nimport { ReactElement, useMemo, useState } from 'react';\nimport { ErrorAlert } from '@perses-dev/components';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useReplaceVariablesInString } from '@perses-dev/plugin-system';\nimport { PrometheusDatasourceSelector } from '../model';\nimport { replacePromBuiltinVariables } from '../plugins/prometheus-time-series-query/replace-prom-builtin-variables';\nimport { useParseQuery } from './query';\nimport TreeNode from './TreeNode';\n\nconst treeViewStr = 'Tree View';\nconst treeViewOpenStr = 'Open ' + treeViewStr;\nconst treeViewCloseStr = 'Close ' + treeViewStr;\n\nexport type PromQLEditorProps = {\n completeConfig: CompleteConfiguration;\n datasource: PrometheusDatasourceSelector;\n isReadOnly?: boolean;\n} & Omit<ReactCodeMirrorProps, 'theme' | 'extensions'>;\n\nexport function PromQLEditor({ completeConfig, datasource, isReadOnly, ...rest }: PromQLEditorProps): ReactElement {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n const [isTreeViewVisible, setTreeViewVisible] = useState(false);\n const readOnly = isReadOnly ?? false;\n\n const promQLExtension = useMemo(() => {\n return new PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();\n }, [completeConfig]);\n\n let queryExpr = useReplaceVariablesInString(rest.value);\n if (queryExpr) {\n // TODO placeholder values for steps to be replaced with actual values\n // Looks like providing proper values involves some refactoring: currently we'd need to rely on the timeseries query context,\n // but these step values are actually computed independently / before the queries are getting fired, so it's useless to fire\n // queries here, so maybe we should extract this part to independant hook(s), to be reused here?\n queryExpr = replacePromBuiltinVariables(queryExpr, 12345, 12345);\n }\n\n const { data: parseQueryResponse, isLoading, error } = useParseQuery(queryExpr ?? '', datasource, isTreeViewVisible);\n\n const handleShowTreeView = (): void => {\n setTreeViewVisible(!isTreeViewVisible);\n };\n\n return (\n <Stack position=\"relative\">\n <InputLabel // reproduce the same kind of input label that regular MUI TextFields have\n shrink\n sx={{\n position: 'absolute',\n top: '-12px',\n left: '10px',\n padding: '0 4px',\n color: theme.palette.text.primary,\n zIndex: 1,\n }}\n >\n PromQL Expression\n </InputLabel>\n {/* TODO: We need to wait for this to be merged, then we need to add proper e2e for some scenarios */}\n <CodeMirror\n data-testid=\"promql_expression_editor\"\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n readOnly={readOnly}\n basicSetup={{\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n foldGutter: false,\n }}\n extensions={[\n EditorView.lineWrapping,\n promQLExtension,\n EditorView.theme({\n '.cm-content': {\n paddingTop: '8px',\n paddingBottom: '8px',\n paddingRight: '40px', // offset for the tree view button\n },\n }),\n ]}\n placeholder=\"Example: sum(rate(http_requests_total[5m]))\"\n />\n {queryExpr && (\n <>\n <Tooltip title={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}>\n <IconButton\n aria-label={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}\n onClick={handleShowTreeView}\n sx={{ position: 'absolute', right: '5px', top: '5px' }}\n size=\"small\"\n key=\"tree-view-button\"\n >\n <FileTreeIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {isTreeViewVisible && (\n <div style={{ border: `1px solid ${theme.palette.divider}`, position: 'relative' }}>\n <Tooltip title={treeViewCloseStr}>\n <IconButton\n aria-label={treeViewCloseStr}\n onClick={() => setTreeViewVisible(false)}\n sx={{ position: 'absolute', top: '5px', right: '5px' }}\n size=\"small\"\n key=\"tree-view-close-button\"\n >\n <CloseIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {error ? (\n // Here the user is able to hide the error alert\n <ErrorAlert\n error={{\n name: `${treeViewStr} not available`,\n message: error.message,\n }}\n />\n ) : (\n <div\n style={{\n padding: `${theme.spacing(1.5)} ${theme.spacing(1.5)} 0 ${theme.spacing(1.5)}`, // let paddingBottom at 0 because nodes have margin-bottom\n overflowX: 'auto',\n backgroundColor: theme.palette.background.default,\n }}\n >\n {isLoading ? (\n <CircularProgress />\n ) : parseQueryResponse?.data ? (\n <TreeNode node={parseQueryResponse.data} reverse={false} childIdx={0} datasource={datasource} />\n ) : null}\n </div>\n )}\n </div>\n )}\n </>\n )}\n </Stack>\n );\n}\n"],"names":["CodeMirror","PromQLExtension","EditorView","useTheme","CircularProgress","InputLabel","Stack","IconButton","Tooltip","FileTreeIcon","useMemo","useState","ErrorAlert","CloseIcon","useReplaceVariablesInString","replacePromBuiltinVariables","useParseQuery","TreeNode","treeViewStr","treeViewOpenStr","treeViewCloseStr","PromQLEditor","completeConfig","datasource","isReadOnly","rest","theme","isDarkMode","palette","mode","isTreeViewVisible","setTreeViewVisible","readOnly","promQLExtension","activateLinter","setComplete","asExtension","queryExpr","value","data","parseQueryResponse","isLoading","error","handleShowTreeView","position","shrink","sx","top","left","padding","color","text","primary","zIndex","data-testid","style","border","divider","basicSetup","highlightActiveLine","highlightActiveLineGutter","foldGutter","extensions","lineWrapping","paddingTop","paddingBottom","paddingRight","placeholder","title","aria-label","onClick","right","size","fontSize","div","name","message","spacing","overflowX","backgroundColor","background","default","node","reverse","childIdx"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC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D;oCACZkD,SAAS,IAAMvC,mBAAmB;oCAClCe,IAAI;wCAAEF,UAAU;wCAAYG,KAAK;wCAAOwB,OAAO;oCAAM;oCACrDC,MAAK;8CAGL,cAAA,KAAC3D;wCAAUiC,IAAI;4CAAE2B,UAAU;wCAAO;;mCAF9B;;4BAKP/B,QACC,gDAAgD;0CAChD,KAAC9B;gCACC8B,OAAO;oCACLiC,MAAM,GAAGzD,YAAY,cAAc,CAAC;oCACpC0D,SAASlC,MAAMkC,OAAO;gCACxB;+CAGF,KAACF;gCACCnB,OAAO;oCACLN,SAAS,GAAGvB,MAAMmD,OAAO,CAAC,KAAK,CAAC,EAAEnD,MAAMmD,OAAO,CAAC,KAAK,GAAG,EAAEnD,MAAMmD,OAAO,CAAC,MAAM;oCAC9EC,WAAW;oCACXC,iBAAiBrD,MAAME,OAAO,CAACoD,UAAU,CAACC,OAAO;gCACnD;0CAECxC,0BACC,KAACrC,wBACCoC,oBAAoBD,qBACtB,KAACtB;oCAASiE,MAAM1C,mBAAmBD,IAAI;oCAAE4C,SAAS;oCAAOC,UAAU;oCAAG7D,YAAYA;qCAChF;;;;;;;;AAStB"}
|
|
@@ -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,CA4HzG"}
|
|
@@ -23,7 +23,7 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
23
23
|
/**
|
|
24
24
|
* The options editor component for editing a PrometheusTimeSeriesQuery's spec.
|
|
25
25
|
*/ export function PrometheusTimeSeriesQueryEditor(props) {
|
|
26
|
-
const { onChange, value, value: { query, datasource }, queryHandlerSettings } = props;
|
|
26
|
+
const { onChange, value, value: { query, datasource }, queryHandlerSettings, isReadonly } = props;
|
|
27
27
|
const datasourceSelectValue = datasource ?? DEFAULT_PROM;
|
|
28
28
|
const datasourceSelectLabelID = useId('prom-datasource-label'); // for panels with multiple queries, this component is rendered multiple times on the same page
|
|
29
29
|
const selectedDatasource = useDatasourceSelectValueToSelector(datasourceSelectValue, PROM_DATASOURCE_KIND);
|
|
@@ -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');
|
|
@@ -88,7 +95,8 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
88
95
|
onChange: handleDatasourceChange,
|
|
89
96
|
labelId: datasourceSelectLabelID,
|
|
90
97
|
label: "Prometheus Datasource",
|
|
91
|
-
notched: true
|
|
98
|
+
notched: true,
|
|
99
|
+
readOnly: isReadonly
|
|
92
100
|
})
|
|
93
101
|
}),
|
|
94
102
|
/*#__PURE__*/ _jsx(PromQLEditor, {
|
|
@@ -100,7 +108,8 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
100
108
|
value: query,
|
|
101
109
|
datasource: selectedDatasource,
|
|
102
110
|
onChange: handlePromQlEditorChanges,
|
|
103
|
-
onBlur: queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined
|
|
111
|
+
onBlur: queryHandlerSettings?.runWithOnBlur ? handleQueryBlur : undefined,
|
|
112
|
+
isReadOnly: isReadonly
|
|
104
113
|
}),
|
|
105
114
|
/*#__PURE__*/ _jsxs(Stack, {
|
|
106
115
|
direction: "row",
|
|
@@ -113,7 +122,8 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
113
122
|
helperText: "Text to be displayed in the legend and the tooltip. Use {{label_name}} to interpolate label values.",
|
|
114
123
|
value: format ?? '',
|
|
115
124
|
onChange: handleLegendSpecChange,
|
|
116
|
-
onBlur: queryHandlerSettings?.runWithOnBlur ? handleFormatBlur : undefined
|
|
125
|
+
onBlur: queryHandlerSettings?.runWithOnBlur ? handleFormatBlur : undefined,
|
|
126
|
+
disabled: isReadonly
|
|
117
127
|
}),
|
|
118
128
|
/*#__PURE__*/ _jsx(TextField, {
|
|
119
129
|
label: "Min Step",
|
|
@@ -124,7 +134,8 @@ import { useQueryState, useFormatState, useMinStepState } from './query-editor-m
|
|
|
124
134
|
onBlur: queryHandlerSettings?.runWithOnBlur ? handleMinStepBlur : undefined,
|
|
125
135
|
sx: {
|
|
126
136
|
width: '250px'
|
|
127
|
-
}
|
|
137
|
+
},
|
|
138
|
+
disabled: isReadonly
|
|
128
139
|
})
|
|
129
140
|
]
|
|
130
141
|
})
|
|
@@ -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,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,cAAc,EACdC,eAAe,QACV,uBAAuB;AAE9B;;CAEC,GACD,OAAO,SAASC,gCAAgCC,KAA2C;IACzF,MAAM,EACJC,QAAQ,EACRC,KAAK,EACLA,OAAO,EAAEC,KAAK,EAAEC,UAAU,EAAE,EAC5BC,oBAAoB,EACrB,GAAGL;IAEJ,MAAMM,wBAAwBF,cAAcd;IAE5C,MAAMiB,0BAA0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sC,0BAA0BnD,YAC9B,CAAC6C;QACCb,oBAAoBa,EAAEG,MAAM,CAACnC,KAAK,GAAIgC,EAAEG,MAAM,CAACnC,KAAK,GAAsB6B;QAC1E,IAAI1B,sBAAsBiC,oBACxBjC,qBAAqBiC,kBAAkB,CAAC;YAAE,GAAGpC,KAAK;YAAEkB,SAASc,EAAEG,MAAM,CAACnC,KAAK;QAAC;IAChF,GACA;QAACG;QAAsBgB;QAAqBnB;KAAM;IAGpD,qBACE,MAACf;QAAMsD,SAAS;;0BACd,KAACvD;gBAAYwD,QAAO;gBAAQC,WAAW;0BACrC,cAAA,KAAC9D;oBACC+D,sBAAsBnD;oBACtBS,OAAOI;oBACPL,UAAU0B;oBACVkB,SAAStC;oBACTuC,OAAM;oBACNC,OAAO;;;0BAGX,KAACpD;gBACCqD,gBAAgB;oBAAEC,QAAQ;wBAAEC,KAAKvC;oBAAQ;gBAAE;gBAC3CT,OAAOC;gBACPC,YAAYI;gBACZP,UAAUgC;gBACVkB,QAAQ9C,sBAAsB+C,gBAAgBpC,kBAAkBe;;0BAElE,MAAC5C;gBAAMkE,WAAU;gBAAMZ,SAAS;;kCAC9B,KAACrD;wBACCuD,SAAS;wBACTG,OAAM;wBACNQ,aAAY;wBACZC,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 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 disabled={isReadonly}\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 disabled={isReadonly}\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","disabled","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,cAAc,EACdC,eAAe,QACV,uBAAuB;AAE9B;;CAEC,GACD,OAAO,SAASC,gCAAgCC,KAA2C;IACzF,MAAM,EACJC,QAAQ,EACRC,KAAK,EACLA,OAAO,EAAEC,KAAK,EAAEC,UAAU,EAAE,EAC5BC,oBAAoB,EACpBC,UAAU,EACX,GAAGN;IAEJ,MAAMO,wBAAwBH,cAAcd;IAE5C,MAAMkB,0BAA0BvB,MAAM,0BAA0B,+FAA+F;IAE/J,MAAMwB,qBAAqBzB,mCACzBuB,uBACAd;IAGF,MAAM,EAAEiB,MAAMC,MAAM,EA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/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"}
|