@perses-dev/prometheus-plugin 0.51.0-rc.3 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/js/{622.893bb954.js → 622.a776ec11.js} +1 -1
- package/__mf/js/{Prometheus.bafb3562.js → Prometheus.c57c8a9f.js} +3 -3
- package/__mf/js/async/{5345.2e531d76.js → 5345.1f4fc17b.js} +1 -1
- package/__mf/js/async/{5503.7c0ff0ee.js → 5503.daedd4dd.js} +1 -1
- package/__mf/js/async/__federation_expose_PrometheusExplorer.171d04eb.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.8551745e.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.a4085adb.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.46f99477.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.fc3c5730.js +1 -0
- package/__mf/js/{main.04881e62.js → main.9866e9bf.js} +1 -1
- package/lib/cjs/components/PromQLEditor.js +1 -1
- package/lib/cjs/components/TreeNode.js +1 -2
- package/lib/cjs/explore/PrometheusMetricsFinder/filter/FilterInputs.js +85 -69
- package/lib/cjs/explore/PrometheusMetricsFinder/filter/FinderFilters.js +16 -14
- package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +11 -18
- package/lib/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +8 -0
- package/lib/cjs/plugins/prometheus-variables.js +27 -45
- package/lib/components/PromQLEditor.js +1 -1
- package/lib/components/PromQLEditor.js.map +1 -1
- package/lib/components/TreeNode.js +1 -2
- package/lib/components/TreeNode.js.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.d.ts.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js +87 -72
- package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.d.ts.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js +17 -15
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.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 +12 -19
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.js +8 -0
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
- package/lib/plugins/prometheus-time-series-query/query-editor-model.d.ts +1 -1
- package/lib/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -1
- package/lib/plugins/prometheus-variables.d.ts.map +1 -1
- package/lib/plugins/prometheus-variables.js +28 -46
- package/lib/plugins/prometheus-variables.js.map +1 -1
- package/mf-manifest.json +40 -40
- package/mf-stats.json +43 -43
- package/package.json +9 -1
- package/__mf/js/async/__federation_expose_PrometheusExplorer.f3fe63da.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.873e5f4d.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.6696e340.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.ab45c7cc.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.66611c9d.js +0 -1
|
@@ -64,22 +64,16 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
64
64
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
65
65
|
spacing: 2,
|
|
66
66
|
children: [
|
|
67
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
67
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControl, {
|
|
68
68
|
margin: "dense",
|
|
69
|
-
children:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
onChange: handleDatasourceChange,
|
|
78
|
-
readOnly: props.isReadonly,
|
|
79
|
-
labelId: "prom-datasource-label",
|
|
80
|
-
label: "Prometheus Datasource"
|
|
81
|
-
})
|
|
82
|
-
]
|
|
69
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceSelect, {
|
|
70
|
+
datasourcePluginKind: "PrometheusDatasource",
|
|
71
|
+
value: selectedDatasource,
|
|
72
|
+
onChange: handleDatasourceChange,
|
|
73
|
+
readOnly: props.isReadonly,
|
|
74
|
+
labelId: "prom-datasource-label",
|
|
75
|
+
label: "Prometheus Datasource"
|
|
76
|
+
})
|
|
83
77
|
}),
|
|
84
78
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
85
79
|
label: "Label Name",
|
|
@@ -125,22 +119,16 @@ function PrometheusLabelNamesVariableEditor(props) {
|
|
|
125
119
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
126
120
|
spacing: 2,
|
|
127
121
|
children: [
|
|
128
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
122
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControl, {
|
|
129
123
|
margin: "dense",
|
|
130
|
-
children:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
onChange: handleDatasourceChange,
|
|
139
|
-
disabled: props.isReadonly,
|
|
140
|
-
labelId: "prom-datasource-label",
|
|
141
|
-
label: "Prometheus Datasource"
|
|
142
|
-
})
|
|
143
|
-
]
|
|
124
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceSelect, {
|
|
125
|
+
datasourcePluginKind: "PrometheusDatasource",
|
|
126
|
+
value: selectedDatasource,
|
|
127
|
+
onChange: handleDatasourceChange,
|
|
128
|
+
disabled: props.isReadonly,
|
|
129
|
+
labelId: "prom-datasource-label",
|
|
130
|
+
label: "Prometheus Datasource"
|
|
131
|
+
})
|
|
144
132
|
}),
|
|
145
133
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_MatcherEditor.MatcherEditor, {
|
|
146
134
|
matchers: props.value.matchers ?? [],
|
|
@@ -174,22 +162,16 @@ function PrometheusPromQLVariableEditor(props) {
|
|
|
174
162
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
175
163
|
spacing: 2,
|
|
176
164
|
children: [
|
|
177
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
165
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControl, {
|
|
178
166
|
margin: "dense",
|
|
179
|
-
children:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
onChange: handleDatasourceChange,
|
|
188
|
-
labelId: "prom-datasource-label",
|
|
189
|
-
label: "Prometheus Datasource",
|
|
190
|
-
disabled: props.isReadonly
|
|
191
|
-
})
|
|
192
|
-
]
|
|
167
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceSelect, {
|
|
168
|
+
datasourcePluginKind: _model.PROM_DATASOURCE_KIND,
|
|
169
|
+
value: selectedDatasource,
|
|
170
|
+
onChange: handleDatasourceChange,
|
|
171
|
+
labelId: "prom-datasource-label",
|
|
172
|
+
label: "Prometheus Datasource",
|
|
173
|
+
disabled: props.isReadonly
|
|
174
|
+
})
|
|
193
175
|
}),
|
|
194
176
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.PromQLEditor, {
|
|
195
177
|
completeConfig: {
|
|
@@ -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: '-8px',\n left: '10px',\n padding: '0 4px',\n color: theme.palette.text.primary,\n zIndex: 1,\n }}\n >\n PromQL Expression\n </InputLabel>\n <CodeMirror\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","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,w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mCAF9B;;4BAKP9B,QACC,gDAAgD;0CAChD,KAAC5B;gCACC4B,OAAO;oCACLgC,MAAM,GAAGtD,YAAY,cAAc,CAAC;oCACpCuD,SAASjC,MAAMiC,OAAO;gCACxB;+CAGF,KAACF;gCACCnB,OAAO;oCACLL,SAAS,GAAGtB,MAAMiD,OAAO,CAAC,KAAK,CAAC,EAAEjD,MAAMiD,OAAO,CAAC,KAAK,GAAG,EAAEjD,MAAMiD,OAAO,CAAC,MAAM;oCAC9EC,WAAW;oCACXC,iBAAiBnD,MAAME,OAAO,CAACkD,UAAU,CAACC,OAAO;gCACnD;0CAECvC,0BACC,KAACnC,wBACCkC,oBAAoBD,qBACtB,KAACpB;oCAAS8D,MAAMzC,mBAAmBD,IAAI;oCAAE2C,SAAS;oCAAOC,UAAU;oCAAG1D,YAAYA;qCAChF;;;;;;;;AAStB"}
|
|
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 <CodeMirror\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","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,QAAQtB;IACd,MAAMuB,aAAaD,MAAME,OAAO,CAACC,IAAI,KAAK;IAC1C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T,mBAAmBD;4BACnDgD,SAAS1B;4BACTG,IAAI;gCAAEF,UAAU;gCAAY0B,OAAO;gCAAOvB,KAAK;4BAAM;4BACrDwB,MAAK;sCAGL,cAAA,KAAC5D;gCAAamC,IAAI;oCAAE0B,UAAU;gCAAO;;2BAFjC;;oBAKPzC,mCACC,MAAC0C;wBAAInB,OAAO;4BAAEC,QAAQ,CAAC,UAAU,EAAE5B,MAAME,OAAO,CAAC2B,OAAO,EAAE;4BAAEZ,UAAU;wBAAW;;0CAC/E,KAAClC;gCAAQyD,OAAO7C;0CACd,cAAA,KAACb;oCACC2D,cAAY9C;oCACZ+C,SAAS,IAAMrC,mBAAmB;oCAClCc,IAAI;wCAAEF,UAAU;wCAAYG,KAAK;wCAAOuB,OAAO;oCAAM;oCACrDC,MAAK;8CAGL,cAAA,KAACxD;wCAAU+B,IAAI;4CAAE0B,UAAU;wCAAO;;mCAF9B;;4BAKP9B,QACC,gDAAgD;0CAChD,KAAC5B;gCACC4B,OAAO;oCACLgC,MAAM,GAAGtD,YAAY,cAAc,CAAC;oCACpCuD,SAASjC,MAAMiC,OAAO;gCACxB;+CAGF,KAACF;gCACCnB,OAAO;oCACLL,SAAS,GAAGtB,MAAMiD,OAAO,CAAC,KAAK,CAAC,EAAEjD,MAAMiD,OAAO,CAAC,KAAK,GAAG,EAAEjD,MAAMiD,OAAO,CAAC,MAAM;oCAC9EC,WAAW;oCACXC,iBAAiBnD,MAAME,OAAO,CAACkD,UAAU,CAACC,OAAO;gCACnD;0CAECvC,0BACC,KAACnC,wBACCkC,oBAAoBD,qBACtB,KAACpB;oCAAS8D,MAAMzC,mBAAmBD,IAAI;oCAAE2C,SAAS;oCAAOC,UAAU;oCAAG1D,YAAYA;qCAChF;;;;;;;;AAStB"}
|
|
@@ -344,8 +344,7 @@ function QueryStatus({ mergedChildState, isFetching, error, resultStats, respons
|
|
|
344
344
|
" result",
|
|
345
345
|
resultStats.numSeries !== 1 && 's',
|
|
346
346
|
" – ",
|
|
347
|
-
responseTime,
|
|
348
|
-
"ms",
|
|
347
|
+
responseTime ? `${Math.round(responseTime)}ms` : '? ms',
|
|
349
348
|
resultStats.sortedLabelCards.length > 0 && /*#__PURE__*/ _jsx(_Fragment, {
|
|
350
349
|
children: " –"
|
|
351
350
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/TreeNode.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\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx\n\nimport { Box, CircularProgress, List, ListItem, Stack, Tooltip, Typography, useTheme } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { ReactElement, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';\nimport AlertCircle from 'mdi-material-ui/AlertCircle';\nimport { StatusError } from '@perses-dev/core';\nimport { PrometheusDatasourceSelector } from '../model';\nimport ASTNode, { nodeType } from './promql/ast';\nimport { escapeString, getNodeChildren } from './promql/utils';\nimport { formatNode } from './promql/format';\nimport serializeNode from './promql/serialize';\nimport { functionSignatures } from './promql/functionSignatures';\nimport { useInstantQuery } from './query';\n\n// The indentation factor for each level of the tree.\nconst nodeIndent = 5;\nconst connectorWidth = nodeIndent * 5;\n\n// max number of label names and values to show in the individual query status\nconst maxLabelNames = 10;\nconst maxLabelValues = 10;\n\ntype NodeState = 'waiting' | 'running' | 'error' | 'success';\n\n// mergeChildStates basically returns the \"worst\" state found among the children.\nconst mergeChildStates = (states: NodeState[]): NodeState => {\n if (states.includes('error')) {\n return 'error';\n }\n if (states.includes('waiting')) {\n return 'waiting';\n }\n if (states.includes('running')) {\n return 'running';\n }\n\n return 'success';\n};\n\ninterface TreeNodeProps {\n // The AST node to render.\n node: ASTNode;\n // The parent element of this node.\n parentEl?: HTMLDivElement | null;\n // Used to compute the position of the connector line between this node and its parent.\n reverse: boolean;\n // Datasource used for the node's individual query.\n datasource: PrometheusDatasourceSelector;\n // The index of this node in its parent's children.\n // Used to render the node's individual query.\n childIdx: number;\n // Function to report the node state to the parent.\n // Used to render the node's individual query.\n reportNodeState?: (childIdx: number, state: NodeState) => void;\n}\n\nexport default function TreeNode({\n node,\n parentEl,\n reverse,\n datasource,\n childIdx,\n reportNodeState,\n}: TreeNodeProps): ReactElement {\n const theme = useTheme();\n const children = getNodeChildren(node);\n\n // A normal ref won't work properly here because the ref's `current` property\n // going from `null` to defined won't trigger a re-render of the child\n // component, since it's not a React state update. So we manually have to\n // create a state update using a callback ref. See also\n // https://tkdodo.eu/blog/avoiding-use-effect-with-callback-refs\n const [nodeEl, setNodeEl] = useState<HTMLDivElement | null>(null);\n const nodeRef = useCallback((node: HTMLDivElement) => setNodeEl(node), []);\n\n const [resultStats, setResultStats] = useState<{\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n }>({\n numSeries: 0,\n labelExamples: {},\n sortedLabelCards: [],\n });\n\n const [connectorStyle, setConnectorStyle] = useState({\n borderColor: theme.palette.grey['500'],\n borderLeftStyle: 'solid',\n borderLeftWidth: 2,\n width: connectorWidth,\n left: -connectorWidth,\n });\n\n const [childStates, setChildStates] = useState<NodeState[]>(children.map(() => 'waiting'));\n const mergedChildState = useMemo(() => mergeChildStates(childStates), [childStates]);\n\n // Optimize range vector selector fetches to give us the info we're looking for\n // more cheaply. E.g. 'foo[7w]' can be expensive to fully fetch, but wrapping it\n // in 'last_over_time(foo[7w])' is cheaper and also gives us all the info we\n // need (number of series and labels).\n let queryNode = node;\n if (queryNode.type === nodeType.matrixSelector) {\n queryNode = {\n type: nodeType.call,\n func: functionSignatures.last_over_time!,\n args: [node],\n };\n }\n\n // Individual query for the current node\n const {\n data: instantQueryResponse,\n isFetching,\n error,\n } = useInstantQuery(serializeNode(queryNode) ?? '', datasource, mergedChildState === 'success');\n\n // report the node state to the parent\n useEffect(() => {\n if (reportNodeState) {\n if (mergedChildState === 'error' || error) {\n reportNodeState(childIdx, 'error');\n } else if (isFetching) {\n reportNodeState(childIdx, 'running');\n }\n }\n }, [mergedChildState, error, isFetching, reportNodeState, childIdx]);\n\n // This function is passed down to the child nodes so they can report their state.\n const childReportNodeState = useCallback(\n (childIdx: number, state: NodeState) => {\n setChildStates((prev) => {\n const newStates = [...prev];\n newStates[childIdx] = state;\n return newStates;\n });\n },\n [setChildStates]\n );\n\n // Update the size and position of tree connector lines based on the node's and its parent's position.\n useLayoutEffect(() => {\n if (parentEl === undefined) {\n // We're the root node.\n return;\n }\n\n if (parentEl === null || nodeEl === null) {\n // Either of the two connected nodes hasn't been rendered yet.\n return;\n }\n\n const parentRect = parentEl.getBoundingClientRect();\n const nodeRect = nodeEl.getBoundingClientRect();\n if (reverse) {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: 'calc(50% - 1px)',\n bottom: nodeRect.bottom - parentRect.top,\n borderTopLeftRadius: 10,\n borderTopStyle: 'solid',\n borderBottomLeftRadius: undefined,\n }));\n } else {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: parentRect.bottom - nodeRect.top,\n bottom: 'calc(50% - 1px)',\n borderBottomLeftRadius: 10,\n borderBottomStyle: 'solid',\n borderTopLeftRadius: undefined,\n }));\n }\n }, [parentEl, nodeEl, reverse, nodeRef, setConnectorStyle]);\n\n // Update the node info state based on the query result.\n useEffect(() => {\n if (instantQueryResponse?.status !== 'success') {\n return;\n }\n\n if (reportNodeState) {\n reportNodeState(childIdx, 'success');\n }\n\n let resultSeries = 0;\n // labelValuesByName records the number of times each label value appears for each label name.\n const labelValuesByName: Record<string, Record<string, number>> = {};\n const { resultType, result } = instantQueryResponse.data;\n\n if (resultType === 'scalar' || resultType === 'string') {\n resultSeries = 1;\n } else if (result && result.length > 0) {\n resultSeries = result.length;\n result.forEach((s) => {\n Object.entries(s.metric).forEach(([ln, lv]) => {\n // TODO: If we ever want to include __name__ here again, we cannot use the\n // last_over_time(foo[7d]) optimization since that removes the metric name.\n if (ln !== '__name__') {\n labelValuesByName[ln] = labelValuesByName[ln] ?? {};\n labelValuesByName[ln]![lv] = (labelValuesByName[ln]![lv] ?? 0) + 1;\n }\n });\n });\n }\n\n // labelCardinalities records the number of unique label values for each label name.\n const labelCardinalities: Record<string, number> = {};\n // labelExamples records the most common label values for each label name.\n const labelExamples: Record<string, Array<{ value: string; count: number }>> = {};\n Object.entries(labelValuesByName).forEach(([ln, lvs]) => {\n labelCardinalities[ln] = Object.keys(lvs).length;\n // Sort label values by their number of occurrences within this label name.\n labelExamples[ln] = Object.entries(lvs)\n .sort(([, aCnt], [, bCnt]) => bCnt - aCnt)\n .slice(0, maxLabelValues)\n .map(([lv, cnt]) => ({ value: lv, count: cnt }));\n });\n\n setResultStats({\n numSeries: resultSeries,\n sortedLabelCards: Object.entries(labelCardinalities).sort((a, b) => b[1] - a[1]),\n labelExamples,\n });\n }, [instantQueryResponse, reportNodeState, childIdx]);\n\n const innerNode = (\n <Stack direction=\"row\" gap={2}>\n <Box\n ref={nodeRef}\n sx={{\n position: 'relative',\n display: 'inline-block',\n padding: 1,\n marginBottom: 1.5,\n borderRadius: 2,\n backgroundColor: theme.palette.background.code,\n }}\n >\n {parentEl !== undefined && (\n // Connector line between this node and its parent.\n <Box\n sx={{\n position: 'absolute',\n display: 'inline-block',\n ...connectorStyle,\n }}\n />\n )}\n {/* The node (visible box) itself. */}\n {formatNode(node, false, 1)}\n </Box>\n {/* The node's individual query: */}\n <QueryStatus\n mergedChildState={mergedChildState}\n isFetching={isFetching}\n error={error}\n resultStats={resultStats}\n responseTime={instantQueryResponse?.responseTime}\n />\n </Stack>\n );\n\n if (node.type === nodeType.binaryExpr) {\n return (\n <div>\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[0]!}\n parentEl={nodeEl}\n reverse={true}\n datasource={datasource}\n childIdx={0}\n reportNodeState={childReportNodeState}\n />\n </Box>\n {innerNode}\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[1]!}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={1}\n reportNodeState={childReportNodeState}\n />\n </Box>\n </div>\n );\n }\n\n return (\n <div>\n {innerNode}\n {children.map((child, idx) => (\n <Box ml={nodeIndent} key={idx}>\n <TreeNode\n node={child}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={idx}\n reportNodeState={childReportNodeState}\n />\n </Box>\n ))}\n </div>\n );\n}\n\ninterface QueryStatusProps {\n mergedChildState: NodeState;\n isFetching: boolean;\n error: StatusError | null;\n resultStats: {\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n };\n responseTime?: number;\n}\n\nfunction QueryStatus({\n mergedChildState,\n isFetching,\n error,\n resultStats,\n responseTime,\n}: QueryStatusProps): ReactElement {\n if (mergedChildState === 'waiting') {\n return <ProgressState text=\"Waiting for child query\" />;\n }\n\n if (mergedChildState === 'running') {\n return <ProgressState text=\"Running\" />;\n }\n\n if (mergedChildState === 'error') {\n return (\n <Stack>\n <AlertCircle />\n Blocked on child query error\n </Stack>\n );\n }\n\n if (isFetching) {\n return <ProgressState text=\"Loading\" />;\n }\n\n if (error) {\n return (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n gap={1}\n sx={{ color: (theme) => theme.palette.error.main }}\n marginBottom={1.5}\n >\n <AlertCircle />\n <Typography variant=\"body2\">\n <strong>Error executing query:</strong> {error.message}\n </Typography>\n </Box>\n );\n }\n\n return (\n <Stack direction=\"row\" gap={1} alignItems=\"center\" marginBottom={1.5}>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n {resultStats.numSeries} result{resultStats.numSeries !== 1 && 's'}\n – \n {responseTime}ms\n {resultStats.sortedLabelCards.length > 0 && <> –</>}\n </Typography>\n {resultStats.sortedLabelCards.slice(0, maxLabelNames).map(([ln, cnt]) => (\n <Tooltip\n key={ln}\n title={\n <Box>\n <List dense>\n {resultStats.labelExamples[ln]?.map(({ value, count }) => (\n <ListItem\n key={value}\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n color: (theme) =>\n theme.palette.mode === 'dark' // TODO we shouldnt have to do that I guess..\n ? theme.palette.warning.dark\n : theme.palette.warning.main,\n fontFamily: 'monospace',\n }}\n >\n {escapeString(value)}\n </Typography>\n <Typography variant=\"body2\" component=\"span\">\n ({count}x)\n </Typography>\n </ListItem>\n ))}\n {cnt > maxLabelValues && (\n <ListItem\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography variant=\"body2\">. . .</Typography>\n </ListItem>\n )}\n </List>\n </Box>\n }\n arrow\n >\n <span style={{ cursor: 'pointer', whiteSpace: 'nowrap' }}>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{ fontFamily: 'monospace', color: (theme) => theme.palette.success.main }}\n >\n {ln}\n </Typography>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n : {cnt}\n </Typography>\n </span>\n </Tooltip>\n ))}\n {resultStats.sortedLabelCards.length > maxLabelNames ? (\n <Typography variant=\"body2\">...{resultStats.sortedLabelCards.length - maxLabelNames} more...</Typography>\n ) : null}\n </Stack>\n );\n}\n\nfunction ProgressState({ text }: { text: string }): ReactElement {\n return (\n <Box display=\"flex\" alignItems=\"center\" gap={1} marginBottom={1.5}>\n <CircularProgress size={16} color=\"secondary\" />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {text}...\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","CircularProgress","List","ListItem","Stack","Tooltip","Typography","useTheme","CircleIcon","useCallback","useEffect","useLayoutEffect","useMemo","useState","AlertCircle","nodeType","escapeString","getNodeChildren","formatNode","serializeNode","functionSignatures","useInstantQuery","nodeIndent","connectorWidth","maxLabelNames","maxLabelValues","mergeChildStates","states","includes","TreeNode","node","parentEl","reverse","datasource","childIdx","reportNodeState","theme","children","nodeEl","setNodeEl","nodeRef","resultStats","setResultStats","numSeries","labelExamples","sortedLabelCards","connectorStyle","setConnectorStyle","borderColor","palette","grey","borderLeftStyle","borderLeftWidth","width","left","childStates","setChildStates","map","mergedChildState","queryNode","type","matrixSelector","call","func","last_over_time","args","data","instantQueryResponse","isFetching","error","childReportNodeState","state","prev","newStates","undefined","parentRect","getBoundingClientRect","nodeRect","prevStyle","top","bottom","borderTopLeftRadius","borderTopStyle","borderBottomLeftRadius","borderBottomStyle","status","resultSeries","labelValuesByName","resultType","result","length","forEach","s","Object","entries","metric","ln","lv","labelCardinalities","lvs","keys","sort","aCnt","bCnt","slice","cnt","value","count","a","b","innerNode","direction","gap","ref","sx","position","display","padding","marginBottom","borderRadius","backgroundColor","background","code","QueryStatus","responseTime","binaryExpr","div","ml","child","idx","ProgressState","text","alignItems","color","main","variant","strong","message","component","title","dense","py","px","fontSize","mode","warning","dark","fontFamily","arrow","span","style","cursor","whiteSpace","success","size"],"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,oJAAoJ;;AAEpJ,SAASA,GAAG,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,OAAO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0DAECnI,aAAa0F;;0DAEhB,MAACpG;gDAAWiI,SAAQ;gDAAQG,WAAU;;oDAAO;oDACzC/B;oDAAM;;;;uCAvBLD;gCA2BRD,MAAMhF,gCACL,MAACtB;oCACC+G,IAAI;wCACFE,SAAS;wCACTJ,KAAK;wCACL6B,IAAI;wCACJC,IAAI;oCACN;;sDAEA,KAACtI;4CAAW0G,IAAI;gDAAE6B,UAAU;4CAAE;;sDAC9B,KAACzI;4CAAWiI,SAAQ;sDAAQ;;;;;;;oBAMtCa,KAAK;8BAEL,cAAA,MAACC;wBAAKC,OAAO;4BAAEC,QAAQ;4BAAWC,YAAY;wBAAS;;0CACrD,KAAClJ;gCACCiI,SAAQ;gCACRG,WAAU;gCACVxB,IAAI;oCAAEiC,YAAY;oCAAad,OAAO,CAACjG,QAAUA,MAAMa,OAAO,CAACwG,OAAO,CAACnB,IAAI;gCAAC;0CAE3EtC;;0CAEH,MAAC1F;gCAAWiI,SAAQ;gCAAQG,WAAU;gCAAOxB,IAAI;oCAAEmB,OAAO,CAACjG,QAAUA,MAAMa,OAAO,CAACC,IAAI,CAAC,IAAI;gCAAC;;oCAAG;oCAC3FuD;;;;;mBA5DFT;YAiERvD,YAAYI,gBAAgB,CAAC6C,MAAM,GAAGlE,8BACrC,MAAClB;gBAAWiI,SAAQ;;oBAAQ;oBAAI9F,YAAYI,gBAAgB,CAAC6C,MAAM,GAAGlE;oBAAc;;iBAClF;;;AAGV;AAEA,SAAS0G,cAAc,EAAEC,IAAI,EAAoB;IAC/C,qBACE,MAACnI;QAAIoH,SAAQ;QAAOgB,YAAW;QAASpB,KAAK;QAAGM,cAAc;;0BAC5D,KAACrH;gBAAiByJ,MAAM;gBAAIrB,OAAM;;0BAClC,MAAC/H;gBAAWiI,SAAQ;gBAAQF,OAAM;;oBAC/BF;oBAAK;;;;;AAId"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeNode.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\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx\n\nimport { Box, CircularProgress, List, ListItem, Stack, Tooltip, Typography, useTheme } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { ReactElement, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';\nimport AlertCircle from 'mdi-material-ui/AlertCircle';\nimport { StatusError } from '@perses-dev/core';\nimport { PrometheusDatasourceSelector } from '../model';\nimport ASTNode, { nodeType } from './promql/ast';\nimport { escapeString, getNodeChildren } from './promql/utils';\nimport { formatNode } from './promql/format';\nimport serializeNode from './promql/serialize';\nimport { functionSignatures } from './promql/functionSignatures';\nimport { useInstantQuery } from './query';\n\n// The indentation factor for each level of the tree.\nconst nodeIndent = 5;\nconst connectorWidth = nodeIndent * 5;\n\n// max number of label names and values to show in the individual query status\nconst maxLabelNames = 10;\nconst maxLabelValues = 10;\n\ntype NodeState = 'waiting' | 'running' | 'error' | 'success';\n\n// mergeChildStates basically returns the \"worst\" state found among the children.\nconst mergeChildStates = (states: NodeState[]): NodeState => {\n if (states.includes('error')) {\n return 'error';\n }\n if (states.includes('waiting')) {\n return 'waiting';\n }\n if (states.includes('running')) {\n return 'running';\n }\n\n return 'success';\n};\n\ninterface TreeNodeProps {\n // The AST node to render.\n node: ASTNode;\n // The parent element of this node.\n parentEl?: HTMLDivElement | null;\n // Used to compute the position of the connector line between this node and its parent.\n reverse: boolean;\n // Datasource used for the node's individual query.\n datasource: PrometheusDatasourceSelector;\n // The index of this node in its parent's children.\n // Used to render the node's individual query.\n childIdx: number;\n // Function to report the node state to the parent.\n // Used to render the node's individual query.\n reportNodeState?: (childIdx: number, state: NodeState) => void;\n}\n\nexport default function TreeNode({\n node,\n parentEl,\n reverse,\n datasource,\n childIdx,\n reportNodeState,\n}: TreeNodeProps): ReactElement {\n const theme = useTheme();\n const children = getNodeChildren(node);\n\n // A normal ref won't work properly here because the ref's `current` property\n // going from `null` to defined won't trigger a re-render of the child\n // component, since it's not a React state update. So we manually have to\n // create a state update using a callback ref. See also\n // https://tkdodo.eu/blog/avoiding-use-effect-with-callback-refs\n const [nodeEl, setNodeEl] = useState<HTMLDivElement | null>(null);\n const nodeRef = useCallback((node: HTMLDivElement) => setNodeEl(node), []);\n\n const [resultStats, setResultStats] = useState<{\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n }>({\n numSeries: 0,\n labelExamples: {},\n sortedLabelCards: [],\n });\n\n const [connectorStyle, setConnectorStyle] = useState({\n borderColor: theme.palette.grey['500'],\n borderLeftStyle: 'solid',\n borderLeftWidth: 2,\n width: connectorWidth,\n left: -connectorWidth,\n });\n\n const [childStates, setChildStates] = useState<NodeState[]>(children.map(() => 'waiting'));\n const mergedChildState = useMemo(() => mergeChildStates(childStates), [childStates]);\n\n // Optimize range vector selector fetches to give us the info we're looking for\n // more cheaply. E.g. 'foo[7w]' can be expensive to fully fetch, but wrapping it\n // in 'last_over_time(foo[7w])' is cheaper and also gives us all the info we\n // need (number of series and labels).\n let queryNode = node;\n if (queryNode.type === nodeType.matrixSelector) {\n queryNode = {\n type: nodeType.call,\n func: functionSignatures.last_over_time!,\n args: [node],\n };\n }\n\n // Individual query for the current node\n const {\n data: instantQueryResponse,\n isFetching,\n error,\n } = useInstantQuery(serializeNode(queryNode) ?? '', datasource, mergedChildState === 'success');\n\n // report the node state to the parent\n useEffect(() => {\n if (reportNodeState) {\n if (mergedChildState === 'error' || error) {\n reportNodeState(childIdx, 'error');\n } else if (isFetching) {\n reportNodeState(childIdx, 'running');\n }\n }\n }, [mergedChildState, error, isFetching, reportNodeState, childIdx]);\n\n // This function is passed down to the child nodes so they can report their state.\n const childReportNodeState = useCallback(\n (childIdx: number, state: NodeState) => {\n setChildStates((prev) => {\n const newStates = [...prev];\n newStates[childIdx] = state;\n return newStates;\n });\n },\n [setChildStates]\n );\n\n // Update the size and position of tree connector lines based on the node's and its parent's position.\n useLayoutEffect(() => {\n if (parentEl === undefined) {\n // We're the root node.\n return;\n }\n\n if (parentEl === null || nodeEl === null) {\n // Either of the two connected nodes hasn't been rendered yet.\n return;\n }\n\n const parentRect = parentEl.getBoundingClientRect();\n const nodeRect = nodeEl.getBoundingClientRect();\n if (reverse) {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: 'calc(50% - 1px)',\n bottom: nodeRect.bottom - parentRect.top,\n borderTopLeftRadius: 10,\n borderTopStyle: 'solid',\n borderBottomLeftRadius: undefined,\n }));\n } else {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: parentRect.bottom - nodeRect.top,\n bottom: 'calc(50% - 1px)',\n borderBottomLeftRadius: 10,\n borderBottomStyle: 'solid',\n borderTopLeftRadius: undefined,\n }));\n }\n }, [parentEl, nodeEl, reverse, nodeRef, setConnectorStyle]);\n\n // Update the node info state based on the query result.\n useEffect(() => {\n if (instantQueryResponse?.status !== 'success') {\n return;\n }\n\n if (reportNodeState) {\n reportNodeState(childIdx, 'success');\n }\n\n let resultSeries = 0;\n // labelValuesByName records the number of times each label value appears for each label name.\n const labelValuesByName: Record<string, Record<string, number>> = {};\n const { resultType, result } = instantQueryResponse.data;\n\n if (resultType === 'scalar' || resultType === 'string') {\n resultSeries = 1;\n } else if (result && result.length > 0) {\n resultSeries = result.length;\n result.forEach((s) => {\n Object.entries(s.metric).forEach(([ln, lv]) => {\n // TODO: If we ever want to include __name__ here again, we cannot use the\n // last_over_time(foo[7d]) optimization since that removes the metric name.\n if (ln !== '__name__') {\n labelValuesByName[ln] = labelValuesByName[ln] ?? {};\n labelValuesByName[ln]![lv] = (labelValuesByName[ln]![lv] ?? 0) + 1;\n }\n });\n });\n }\n\n // labelCardinalities records the number of unique label values for each label name.\n const labelCardinalities: Record<string, number> = {};\n // labelExamples records the most common label values for each label name.\n const labelExamples: Record<string, Array<{ value: string; count: number }>> = {};\n Object.entries(labelValuesByName).forEach(([ln, lvs]) => {\n labelCardinalities[ln] = Object.keys(lvs).length;\n // Sort label values by their number of occurrences within this label name.\n labelExamples[ln] = Object.entries(lvs)\n .sort(([, aCnt], [, bCnt]) => bCnt - aCnt)\n .slice(0, maxLabelValues)\n .map(([lv, cnt]) => ({ value: lv, count: cnt }));\n });\n\n setResultStats({\n numSeries: resultSeries,\n sortedLabelCards: Object.entries(labelCardinalities).sort((a, b) => b[1] - a[1]),\n labelExamples,\n });\n }, [instantQueryResponse, reportNodeState, childIdx]);\n\n const innerNode = (\n <Stack direction=\"row\" gap={2}>\n <Box\n ref={nodeRef}\n sx={{\n position: 'relative',\n display: 'inline-block',\n padding: 1,\n marginBottom: 1.5,\n borderRadius: 2,\n backgroundColor: theme.palette.background.code,\n }}\n >\n {parentEl !== undefined && (\n // Connector line between this node and its parent.\n <Box\n sx={{\n position: 'absolute',\n display: 'inline-block',\n ...connectorStyle,\n }}\n />\n )}\n {/* The node (visible box) itself. */}\n {formatNode(node, false, 1)}\n </Box>\n {/* The node's individual query: */}\n <QueryStatus\n mergedChildState={mergedChildState}\n isFetching={isFetching}\n error={error}\n resultStats={resultStats}\n responseTime={instantQueryResponse?.responseTime}\n />\n </Stack>\n );\n\n if (node.type === nodeType.binaryExpr) {\n return (\n <div>\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[0]!}\n parentEl={nodeEl}\n reverse={true}\n datasource={datasource}\n childIdx={0}\n reportNodeState={childReportNodeState}\n />\n </Box>\n {innerNode}\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[1]!}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={1}\n reportNodeState={childReportNodeState}\n />\n </Box>\n </div>\n );\n }\n\n return (\n <div>\n {innerNode}\n {children.map((child, idx) => (\n <Box ml={nodeIndent} key={idx}>\n <TreeNode\n node={child}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={idx}\n reportNodeState={childReportNodeState}\n />\n </Box>\n ))}\n </div>\n );\n}\n\ninterface QueryStatusProps {\n mergedChildState: NodeState;\n isFetching: boolean;\n error: StatusError | null;\n resultStats: {\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n };\n responseTime?: number;\n}\n\nfunction QueryStatus({\n mergedChildState,\n isFetching,\n error,\n resultStats,\n responseTime,\n}: QueryStatusProps): ReactElement {\n if (mergedChildState === 'waiting') {\n return <ProgressState text=\"Waiting for child query\" />;\n }\n\n if (mergedChildState === 'running') {\n return <ProgressState text=\"Running\" />;\n }\n\n if (mergedChildState === 'error') {\n return (\n <Stack>\n <AlertCircle />\n Blocked on child query error\n </Stack>\n );\n }\n\n if (isFetching) {\n return <ProgressState text=\"Loading\" />;\n }\n\n if (error) {\n return (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n gap={1}\n sx={{ color: (theme) => theme.palette.error.main }}\n marginBottom={1.5}\n >\n <AlertCircle />\n <Typography variant=\"body2\">\n <strong>Error executing query:</strong> {error.message}\n </Typography>\n </Box>\n );\n }\n\n return (\n <Stack direction=\"row\" gap={1} alignItems=\"center\" marginBottom={1.5}>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n {resultStats.numSeries} result{resultStats.numSeries !== 1 && 's'}\n – \n {responseTime ? `${Math.round(responseTime)}ms` : '? ms'}\n {resultStats.sortedLabelCards.length > 0 && <> –</>}\n </Typography>\n {resultStats.sortedLabelCards.slice(0, maxLabelNames).map(([ln, cnt]) => (\n <Tooltip\n key={ln}\n title={\n <Box>\n <List dense>\n {resultStats.labelExamples[ln]?.map(({ value, count }) => (\n <ListItem\n key={value}\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n color: (theme) =>\n theme.palette.mode === 'dark' // TODO we shouldnt have to do that I guess..\n ? theme.palette.warning.dark\n : theme.palette.warning.main,\n fontFamily: 'monospace',\n }}\n >\n {escapeString(value)}\n </Typography>\n <Typography variant=\"body2\" component=\"span\">\n ({count}x)\n </Typography>\n </ListItem>\n ))}\n {cnt > maxLabelValues && (\n <ListItem\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography variant=\"body2\">. . .</Typography>\n </ListItem>\n )}\n </List>\n </Box>\n }\n arrow\n >\n <span style={{ cursor: 'pointer', whiteSpace: 'nowrap' }}>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{ fontFamily: 'monospace', color: (theme) => theme.palette.success.main }}\n >\n {ln}\n </Typography>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n : {cnt}\n </Typography>\n </span>\n </Tooltip>\n ))}\n {resultStats.sortedLabelCards.length > maxLabelNames ? (\n <Typography variant=\"body2\">...{resultStats.sortedLabelCards.length - maxLabelNames} more...</Typography>\n ) : null}\n </Stack>\n );\n}\n\nfunction ProgressState({ text }: { text: string }): ReactElement {\n return (\n <Box display=\"flex\" alignItems=\"center\" gap={1} marginBottom={1.5}>\n <CircularProgress size={16} color=\"secondary\" />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {text}...\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","CircularProgress","List","ListItem","Stack","Tooltip","Typography","useTheme","CircleIcon","useCallback","useEffect","useLayoutEffect","useMemo","useState","AlertCircle","nodeType","escapeString","getNodeChildren","formatNode","serializeNode","functionSignatures","useInstantQuery","nodeIndent","connectorWidth","maxLabelNames","maxLabelValues","mergeChildStates","states","includes","TreeNode","node","parentEl","reverse","datasource","childIdx","reportNodeState","theme","children","nodeEl","setNodeEl","nodeRef","resultStats","setResultStats","numSeries","labelExamples","sortedLabelCards","connectorStyle","setConnectorStyle","borderColor","palette","grey","borderLeftStyle","borderLeftWidth","width","left","childStates","setChildStates","map","mergedChildState","queryNode","type","matrixSelector","call","func","last_over_time","args","data","instantQueryResponse","isFetching","error","childReportNodeState","state","prev","newStates","undefined","parentRect","getBoundingClientRect","nodeRect","prevStyle","top","bottom","borderTopLeftRadius","borderTopStyle","borderBottomLeftRadius","borderBottomStyle","status","resultSeries","labelValuesByName","resultType","result","length","forEach","s","Object","entries","metric","ln","lv","labelCardinalities","lvs","keys","sort","aCnt","bCnt","slice","cnt","value","count","a","b","innerNode","direction","gap","ref","sx","position","display","padding","marginBottom","borderRadius","backgroundColor","background","code","QueryStatus","responseTime","binaryExpr","div","ml","child","idx","ProgressState","text","alignItems","color","main","variant","strong","message","component","Math","round","title","dense","py","px","fontSize","mode","warning","dark","fontFamily","arrow","span","style","cursor","whiteSpace","success","size"],"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,oJAAoJ;;AAEpJ,SAASA,GAAG,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,OAAO,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,gBAAgB;AAC5G,OAAOC,gBAAgB,yBAAyB;AAChD,SAAuBC,WAAW,EAAEC,SAAS,EAAEC,eAAe,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACjG,OAAOC,iBAAiB,8BAA8B;AAGtD,SAAkBC,QAAQ,QAAQ,eAAe;AACjD,SAASC,YAAY,EAAEC,e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CACN;;sDAEA,KAACxI;4CAAW0G,IAAI;gDAAE+B,UAAU;4CAAE;;sDAC9B,KAAC3I;4CAAWiI,SAAQ;sDAAQ;;;;;;;oBAMtCe,KAAK;8BAEL,cAAA,MAACC;wBAAKC,OAAO;4BAAEC,QAAQ;4BAAWC,YAAY;wBAAS;;0CACrD,KAACpJ;gCACCiI,SAAQ;gCACRG,WAAU;gCACVxB,IAAI;oCAAEmC,YAAY;oCAAahB,OAAO,CAACjG,QAAUA,MAAMa,OAAO,CAAC0G,OAAO,CAACrB,IAAI;gCAAC;0CAE3EtC;;0CAEH,MAAC1F;gCAAWiI,SAAQ;gCAAQG,WAAU;gCAAOxB,IAAI;oCAAEmB,OAAO,CAACjG,QAAUA,MAAMa,OAAO,CAACC,IAAI,CAAC,IAAI;gCAAC;;oCAAG;oCAC3FuD;;;;;mBA5DFT;YAiERvD,YAAYI,gBAAgB,CAAC6C,MAAM,GAAGlE,8BACrC,MAAClB;gBAAWiI,SAAQ;;oBAAQ;oBAAI9F,YAAYI,gBAAgB,CAAC6C,MAAM,GAAGlE;oBAAc;;iBAClF;;;AAGV;AAEA,SAAS0G,cAAc,EAAEC,IAAI,EAAoB;IAC/C,qBACE,MAACnI;QAAIoH,SAAQ;QAAOgB,YAAW;QAASpB,KAAK;QAAGM,cAAc;;0BAC5D,KAACrH;gBAAiB2J,MAAM;gBAAIvB,OAAM;;0BAClC,MAAC/H;gBAAWiI,SAAQ;gBAAQF,OAAM;;oBAC/BF;oBAAK;;;;;AAId"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterInputs.d.ts","sourceRoot":"","sources":["../../../../../src/explore/PrometheusMetricsFinder/filter/FilterInputs.tsx"],"names":[],"mappings":"AAaA,OAAO,EAGL,cAAc,EACd,YAAY,EAKb,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"FilterInputs.d.ts","sourceRoot":"","sources":["../../../../../src/explore/PrometheusMetricsFinder/filter/FilterInputs.tsx"],"names":[],"mappings":"AAaA,OAAO,EAGL,cAAc,EACd,YAAY,EAKb,MAAM,OAAO,CAAC;AAaf,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAY,MAAM,UAAU,CAAC;AAGjD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,UAAU,EACV,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,qBAAqB,GAAG,YAAY,CAwBtC;AAGD,eAAO,MAAM,gBAAgB,+HAiC5B,CAAC;AAGF,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,WAAW,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,2BAA2B,EAC3B,QAAQ,EACR,QAAQ,GACT,EAAE,mBAAmB,GAAG,YAAY,CAsGpC"}
|
|
@@ -10,14 +10,12 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { cloneElement, forwardRef, useMemo, useRef, useState } from 'react';
|
|
15
|
-
import { Autocomplete, CircularProgress, IconButton, InputAdornment, TextField } from '@mui/material';
|
|
16
|
-
import CheckIcon from 'mdi-material-ui/Check';
|
|
15
|
+
import { Autocomplete, CircularProgress, IconButton, InputAdornment, MenuItem, Select, Stack, TextField } from '@mui/material';
|
|
17
16
|
import DeleteIcon from 'mdi-material-ui/Delete';
|
|
18
17
|
import { Virtuoso } from 'react-virtuoso';
|
|
19
18
|
import { useLabels, useLabelValues } from '../utils';
|
|
20
|
-
// TODO: fix when a filter is deleted => refresh data
|
|
21
19
|
export function LabelFilterInput({ datasource, value, filters, onChange, onDelete }) {
|
|
22
20
|
const filtersWithoutCurrent = useMemo(()=>filters.filter((filter)=>filter.label !== value.label), [
|
|
23
21
|
filters,
|
|
@@ -74,22 +72,10 @@ export const ListboxComponent = /*#__PURE__*/ forwardRef(({ children, ...rest },
|
|
|
74
72
|
});
|
|
75
73
|
ListboxComponent.displayName = 'ListboxComponent';
|
|
76
74
|
export function RawFilterInput({ value, labelOptions, labelValuesOptions, isLabelOptionsLoading, isLabelValuesOptionsLoading, onChange, onDelete }) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
onChange({
|
|
82
|
-
label: labelName,
|
|
83
|
-
labelValues: value.labelValues,
|
|
84
|
-
operator: value.operator
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
function handleKeyPress(event) {
|
|
88
|
-
if (isEditingLabelName && event.key === 'Enter') {
|
|
89
|
-
handleLabelConfirmation();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
75
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
76
|
+
gap: 0,
|
|
77
|
+
flexDirection: "row",
|
|
78
|
+
alignItems: "center",
|
|
93
79
|
children: [
|
|
94
80
|
/*#__PURE__*/ _jsx(Autocomplete, {
|
|
95
81
|
freeSolo: true,
|
|
@@ -97,8 +83,7 @@ export function RawFilterInput({ value, labelOptions, labelValuesOptions, isLabe
|
|
|
97
83
|
options: labelOptions ?? [],
|
|
98
84
|
value: value.label,
|
|
99
85
|
sx: {
|
|
100
|
-
minWidth:
|
|
101
|
-
display: isEditingLabelName ? 'block' : 'none'
|
|
86
|
+
minWidth: 200
|
|
102
87
|
},
|
|
103
88
|
ListboxComponent: ListboxComponent,
|
|
104
89
|
loading: isLabelOptionsLoading,
|
|
@@ -109,31 +94,58 @@ export function RawFilterInput({ value, labelOptions, labelValuesOptions, isLabe
|
|
|
109
94
|
variant: "outlined",
|
|
110
95
|
fullWidth: true,
|
|
111
96
|
size: "medium",
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
isLabelOptionsLoading ? /*#__PURE__*/ _jsx(CircularProgress, {
|
|
118
|
-
color: "inherit",
|
|
119
|
-
size: 20
|
|
120
|
-
}) : null,
|
|
121
|
-
/*#__PURE__*/ _jsx(IconButton, {
|
|
122
|
-
"aria-label": "validate label name",
|
|
123
|
-
onClick: ()=>handleLabelConfirmation(),
|
|
124
|
-
edge: "end",
|
|
125
|
-
children: /*#__PURE__*/ _jsx(CheckIcon, {})
|
|
126
|
-
})
|
|
127
|
-
]
|
|
128
|
-
})
|
|
97
|
+
sx: {
|
|
98
|
+
'& .MuiOutlinedInput-root': {
|
|
99
|
+
borderTopRightRadius: 0,
|
|
100
|
+
borderBottomRightRadius: 0
|
|
101
|
+
}
|
|
129
102
|
}
|
|
130
103
|
});
|
|
131
104
|
},
|
|
132
|
-
onKeyDown: handleKeyPress,
|
|
133
105
|
onInputChange: (_, newValue)=>{
|
|
134
|
-
|
|
106
|
+
onChange({
|
|
107
|
+
label: newValue ?? '',
|
|
108
|
+
labelValues: value.labelValues,
|
|
109
|
+
operator: value.operator
|
|
110
|
+
});
|
|
135
111
|
}
|
|
136
112
|
}),
|
|
113
|
+
/*#__PURE__*/ _jsxs(Select, {
|
|
114
|
+
value: value.operator,
|
|
115
|
+
variant: "outlined",
|
|
116
|
+
onChange: (event)=>{
|
|
117
|
+
onChange({
|
|
118
|
+
label: value.label,
|
|
119
|
+
labelValues: value.labelValues,
|
|
120
|
+
operator: event.target.value
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
size: "medium",
|
|
124
|
+
sx: {
|
|
125
|
+
borderTopLeftRadius: 0,
|
|
126
|
+
borderBottomLeftRadius: 0,
|
|
127
|
+
borderTopRightRadius: 0,
|
|
128
|
+
borderBottomRightRadius: 0
|
|
129
|
+
},
|
|
130
|
+
children: [
|
|
131
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
132
|
+
value: "=",
|
|
133
|
+
children: "="
|
|
134
|
+
}),
|
|
135
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
136
|
+
value: "!=",
|
|
137
|
+
children: "!="
|
|
138
|
+
}),
|
|
139
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
140
|
+
value: "=~",
|
|
141
|
+
children: "=~"
|
|
142
|
+
}),
|
|
143
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
144
|
+
value: "!~",
|
|
145
|
+
children: "!~"
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
}),
|
|
137
149
|
/*#__PURE__*/ _jsx(Autocomplete, {
|
|
138
150
|
freeSolo: true,
|
|
139
151
|
multiple: value.operator === '=~' || value.operator === '!~',
|
|
@@ -143,48 +155,49 @@ export function RawFilterInput({ value, labelOptions, labelValuesOptions, isLabe
|
|
|
143
155
|
value: value.labelValues,
|
|
144
156
|
ListboxComponent: ListboxComponent,
|
|
145
157
|
sx: {
|
|
146
|
-
minWidth:
|
|
147
|
-
display: isEditingLabelName ? 'none' : 'block'
|
|
158
|
+
minWidth: 200
|
|
148
159
|
},
|
|
149
160
|
loading: isLabelValuesOptionsLoading,
|
|
150
161
|
renderInput: (params)=>{
|
|
151
162
|
return /*#__PURE__*/ _jsx(TextField, {
|
|
152
163
|
...params,
|
|
153
|
-
label: value.
|
|
164
|
+
label: value.operator === '=~' || value.operator === '!~' ? 'Label Values' : 'Label Value',
|
|
154
165
|
variant: "outlined",
|
|
155
166
|
fullWidth: true,
|
|
156
167
|
size: "medium",
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
168
|
+
sx: {
|
|
169
|
+
'& .MuiOutlinedInput-root': {
|
|
170
|
+
borderTopLeftRadius: 0,
|
|
171
|
+
borderBottomLeftRadius: 0
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
slotProps: {
|
|
175
|
+
input: {
|
|
176
|
+
...params.InputProps,
|
|
177
|
+
style: {
|
|
178
|
+
maxHeight: '53.13px'
|
|
179
|
+
},
|
|
180
|
+
endAdornment: /*#__PURE__*/ _jsxs(InputAdornment, {
|
|
181
|
+
position: "end",
|
|
182
|
+
children: [
|
|
183
|
+
isLabelValuesOptionsLoading ? /*#__PURE__*/ _jsx(CircularProgress, {
|
|
184
|
+
color: "inherit",
|
|
185
|
+
size: 20
|
|
186
|
+
}) : null,
|
|
187
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
188
|
+
"aria-label": "delete label filter",
|
|
189
|
+
onClick: ()=>onDelete(),
|
|
190
|
+
edge: "end",
|
|
191
|
+
children: /*#__PURE__*/ _jsx(DeleteIcon, {})
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
})
|
|
195
|
+
}
|
|
183
196
|
}
|
|
184
197
|
});
|
|
185
198
|
},
|
|
186
|
-
|
|
187
|
-
if (
|
|
199
|
+
onInputChange: (_, newValue)=>{
|
|
200
|
+
if (value.operator === '=' || value.operator === '!=') {
|
|
188
201
|
onChange({
|
|
189
202
|
label: value.label,
|
|
190
203
|
labelValues: [
|
|
@@ -193,6 +206,8 @@ export function RawFilterInput({ value, labelOptions, labelValuesOptions, isLabe
|
|
|
193
206
|
operator: value.operator
|
|
194
207
|
});
|
|
195
208
|
}
|
|
209
|
+
},
|
|
210
|
+
onChange: (_, newValue)=>{
|
|
196
211
|
if (Array.isArray(newValue)) {
|
|
197
212
|
onChange({
|
|
198
213
|
label: value.label,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/explore/PrometheusMetricsFinder/filter/FilterInputs.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.\n\nimport {\n cloneElement,\n forwardRef,\n HTMLAttributes,\n ReactElement,\n SyntheticEvent,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Autocomplete, CircularProgress, IconButton, InputAdornment, TextField } from '@mui/material';\nimport CheckIcon from 'mdi-material-ui/Check';\nimport DeleteIcon from 'mdi-material-ui/Delete';\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { Virtuoso } from 'react-virtuoso';\nimport { LabelFilter } from '../types';\nimport { useLabels, useLabelValues } from '../utils';\n\nexport interface LabelFilterInputProps {\n datasource: DatasourceSelector;\n value: LabelFilter;\n filters: LabelFilter[];\n onChange: (next: LabelFilter) => void;\n onDelete: () => void;\n}\n\n// TODO: fix when a filter is deleted => refresh data\nexport function LabelFilterInput({\n datasource,\n value,\n filters,\n onChange,\n onDelete,\n}: LabelFilterInputProps): ReactElement {\n const filtersWithoutCurrent = useMemo(\n () => filters.filter((filter) => filter.label !== value.label),\n [filters, value.label]\n );\n\n const { data: labelOptions, isLoading: isLabelOptionsLoading } = useLabels(filtersWithoutCurrent, datasource);\n const { data: labelValuesOptions, isLoading: isLabelValuesOptionsLoading } = useLabelValues(\n value.label,\n filtersWithoutCurrent,\n datasource\n );\n\n return (\n <RawFilterInput\n value={value}\n labelOptions={labelOptions?.data ?? []}\n labelValuesOptions={labelValuesOptions?.data ?? []}\n isLabelOptionsLoading={isLabelOptionsLoading}\n isLabelValuesOptionsLoading={isLabelValuesOptionsLoading}\n onChange={onChange}\n onDelete={onDelete}\n />\n );\n}\n\n// https://stackoverflow.com/questions/69060738/material-ui-autocomplete-virtualization-w-react-virtuoso\nexport const ListboxComponent = forwardRef<HTMLUListElement, HTMLAttributes<HTMLUListElement>>(\n ({ children, ...rest }, ref) => {\n const data = children as ReactElement[];\n const localRef = useRef<string>('500px');\n\n const [height, setHeight] = useState(0);\n\n return (\n <ul\n style={{ overflow: 'hidden', padding: '0', height: height ? `min(40vh, ${height}px)` : '40vh' }}\n ref={(reference) => {\n const maxHeight = reference ? getComputedStyle(reference).maxHeight : null;\n if (maxHeight && maxHeight !== localRef.current) {\n localRef.current = maxHeight;\n }\n\n if (typeof ref === 'function') {\n ref(reference);\n }\n }}\n {...rest}\n >\n <Virtuoso\n style={{ height: localRef.current, padding: '10px 0' }}\n data={data}\n totalListHeightChanged={setHeight}\n itemContent={(index, child) => {\n return cloneElement(child, { index, title: child.props.children });\n }}\n />\n </ul>\n );\n }\n);\nListboxComponent.displayName = 'ListboxComponent';\n\nexport interface RawFilterInputProps {\n value: LabelFilter;\n labelOptions?: string[];\n labelValuesOptions?: string[];\n isLabelOptionsLoading?: boolean;\n isLabelValuesOptionsLoading?: boolean;\n onChange: (next: LabelFilter) => void;\n onDelete: () => void;\n}\n\nexport function RawFilterInput({\n value,\n labelOptions,\n labelValuesOptions,\n isLabelOptionsLoading,\n isLabelValuesOptionsLoading,\n onChange,\n onDelete,\n}: RawFilterInputProps): ReactElement {\n const [isEditingLabelName, setIsEditingLabelName] = useState(value.labelValues.length === 0);\n const [labelName, setLabelName] = useState(value.label);\n\n function handleLabelConfirmation(): void {\n setIsEditingLabelName(false);\n onChange({ label: labelName, labelValues: value.labelValues, operator: value.operator });\n }\n\n function handleKeyPress(event: { key: string }): void {\n if (isEditingLabelName && event.key === 'Enter') {\n handleLabelConfirmation();\n }\n }\n\n return (\n <>\n <Autocomplete\n freeSolo\n disableClearable\n options={labelOptions ?? []}\n value={value.label}\n sx={{ minWidth: 250, display: isEditingLabelName ? 'block' : 'none' }}\n ListboxComponent={ListboxComponent}\n loading={isLabelOptionsLoading}\n renderInput={(params) => {\n return (\n <TextField\n {...params}\n label=\"Label Name\"\n variant=\"outlined\"\n fullWidth\n size=\"medium\"\n InputProps={{\n ...params.InputProps,\n endAdornment: (\n <InputAdornment position=\"end\">\n {isLabelOptionsLoading ? <CircularProgress color=\"inherit\" size={20} /> : null}\n <IconButton aria-label=\"validate label name\" onClick={() => handleLabelConfirmation()} edge=\"end\">\n <CheckIcon />\n </IconButton>\n </InputAdornment>\n ),\n }}\n />\n );\n }}\n onKeyDown={handleKeyPress}\n onInputChange={(_: SyntheticEvent, newValue: string | null) => {\n setLabelName(newValue ?? '');\n }}\n />\n <Autocomplete\n freeSolo\n multiple={value.operator === '=~' || value.operator === '!~'}\n limitTags={1}\n disableClearable\n options={labelValuesOptions ?? []}\n value={value.labelValues}\n ListboxComponent={ListboxComponent}\n sx={{ minWidth: 250, display: isEditingLabelName ? 'none' : 'block' }}\n loading={isLabelValuesOptionsLoading}\n renderInput={(params) => {\n return (\n <TextField\n {...params}\n label={value.label}\n variant=\"outlined\"\n fullWidth\n size=\"medium\"\n InputProps={{\n ...params.InputProps,\n startAdornment: (\n <>\n <InputAdornment position=\"start\">{value.operator}</InputAdornment>\n {params.InputProps.startAdornment}\n </>\n ),\n endAdornment: (\n <InputAdornment position=\"end\">\n {isLabelValuesOptionsLoading ? <CircularProgress color=\"inherit\" size={20} /> : null}\n <IconButton aria-label=\"delete label filter\" onClick={() => onDelete()} edge=\"end\">\n <DeleteIcon />\n </IconButton>\n </InputAdornment>\n ),\n }}\n />\n );\n }}\n onChange={(_, newValue) => {\n if (typeof newValue === 'string') {\n onChange({ label: value.label, labelValues: [newValue], operator: value.operator });\n }\n if (Array.isArray(newValue)) {\n onChange({ label: value.label, labelValues: newValue, operator: value.operator });\n }\n }}\n />\n </>\n );\n}\n"],"names":["cloneElement","forwardRef","useMemo","useRef","useState","Autocomplete","CircularProgress","IconButton","InputAdornment","TextField","CheckIcon","DeleteIcon","Virtuoso","useLabels","useLabelValues","LabelFilterInput","datasource","value","filters","onChange","onDelete","filtersWithoutCurrent","filter","label","data","labelOptions","isLoading","isLabelOptionsLoading","labelValuesOptions","isLabelValuesOptionsLoading","RawFilterInput","ListboxComponent","children","rest","ref","localRef","height","setHeight","ul","style","overflow","padding","reference","maxHeight","getComputedStyle","current","totalListHeightChanged","itemContent","index","child","title","props","displayName","isEditingLabelName","setIsEditingLabelName","labelValues","length","labelName","setLabelName","handleLabelConfirmation","operator","handleKeyPress","event","key","freeSolo","disableClearable","options","sx","minWidth","display","loading","renderInput","params","variant","fullWidth","size","InputProps","endAdornment","position","color","aria-label","onClick","edge","onKeyDown","onInputChange","_","newValue","multiple","limitTags","startAdornment","Array","isArray"],"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,SACEA,YAAY,EACZC,UAAU,EAIVC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH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kE,GAAGC;oBACZ,IAAI,OAAOA,aAAa,UAAU;wBAChCnE,SAAS;4BAAEI,OAAON,MAAMM,KAAK;4BAAEgC,aAAa;gCAAC+B;6BAAS;4BAAE1B,UAAU3C,MAAM2C,QAAQ;wBAAC;oBACnF;oBACA,IAAI8B,MAAMC,OAAO,CAACL,WAAW;wBAC3BnE,SAAS;4BAAEI,OAAON,MAAMM,KAAK;4BAAEgC,aAAa+B;4BAAU1B,UAAU3C,MAAM2C,QAAQ;wBAAC;oBACjF;gBACF;;;;AAIR"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/explore/PrometheusMetricsFinder/filter/FilterInputs.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.\n\nimport {\n cloneElement,\n forwardRef,\n HTMLAttributes,\n ReactElement,\n SyntheticEvent,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport {\n Autocomplete,\n CircularProgress,\n IconButton,\n InputAdornment,\n MenuItem,\n Select,\n SelectChangeEvent,\n Stack,\n TextField,\n} from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/Delete';\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { Virtuoso } from 'react-virtuoso';\nimport { LabelFilter, Operator } from '../types';\nimport { useLabels, useLabelValues } from '../utils';\n\nexport interface LabelFilterInputProps {\n datasource: DatasourceSelector;\n value: LabelFilter;\n filters: LabelFilter[];\n onChange: (next: LabelFilter) => void;\n onDelete: () => void;\n}\n\nexport function LabelFilterInput({\n datasource,\n value,\n filters,\n onChange,\n onDelete,\n}: LabelFilterInputProps): ReactElement {\n const filtersWithoutCurrent = useMemo(\n () => filters.filter((filter) => filter.label !== value.label),\n [filters, value.label]\n );\n\n const { data: labelOptions, isLoading: isLabelOptionsLoading } = useLabels(filtersWithoutCurrent, datasource);\n const { data: labelValuesOptions, isLoading: isLabelValuesOptionsLoading } = useLabelValues(\n value.label,\n filtersWithoutCurrent,\n datasource\n );\n\n return (\n <RawFilterInput\n value={value}\n labelOptions={labelOptions?.data ?? []}\n labelValuesOptions={labelValuesOptions?.data ?? []}\n isLabelOptionsLoading={isLabelOptionsLoading}\n isLabelValuesOptionsLoading={isLabelValuesOptionsLoading}\n onChange={onChange}\n onDelete={onDelete}\n />\n );\n}\n\n// https://stackoverflow.com/questions/69060738/material-ui-autocomplete-virtualization-w-react-virtuoso\nexport const ListboxComponent = forwardRef<HTMLUListElement, HTMLAttributes<HTMLUListElement>>(\n ({ children, ...rest }, ref) => {\n const data = children as ReactElement[];\n const localRef = useRef<string>('500px');\n\n const [height, setHeight] = useState(0);\n\n return (\n <ul\n style={{ overflow: 'hidden', padding: '0', height: height ? `min(40vh, ${height}px)` : '40vh' }}\n ref={(reference) => {\n const maxHeight = reference ? getComputedStyle(reference).maxHeight : null;\n if (maxHeight && maxHeight !== localRef.current) {\n localRef.current = maxHeight;\n }\n\n if (typeof ref === 'function') {\n ref(reference);\n }\n }}\n {...rest}\n >\n <Virtuoso\n style={{ height: localRef.current, padding: '10px 0' }}\n data={data}\n totalListHeightChanged={setHeight}\n itemContent={(index, child) => {\n return cloneElement(child, { index, title: child.props.children });\n }}\n />\n </ul>\n );\n }\n);\nListboxComponent.displayName = 'ListboxComponent';\n\nexport interface RawFilterInputProps {\n value: LabelFilter;\n labelOptions?: string[];\n labelValuesOptions?: string[];\n isLabelOptionsLoading?: boolean;\n isLabelValuesOptionsLoading?: boolean;\n onChange: (next: LabelFilter) => void;\n onDelete: () => void;\n}\n\nexport function RawFilterInput({\n value,\n labelOptions,\n labelValuesOptions,\n isLabelOptionsLoading,\n isLabelValuesOptionsLoading,\n onChange,\n onDelete,\n}: RawFilterInputProps): ReactElement {\n return (\n <Stack gap={0} flexDirection=\"row\" alignItems=\"center\">\n <Autocomplete\n freeSolo\n disableClearable\n options={labelOptions ?? []}\n value={value.label}\n sx={{ minWidth: 200 }}\n ListboxComponent={ListboxComponent}\n loading={isLabelOptionsLoading}\n renderInput={(params) => {\n return (\n <TextField\n {...params}\n label=\"Label Name\"\n variant=\"outlined\"\n fullWidth\n size=\"medium\"\n sx={{\n '& .MuiOutlinedInput-root': {\n borderTopRightRadius: 0,\n borderBottomRightRadius: 0,\n },\n }}\n />\n );\n }}\n onInputChange={(_: SyntheticEvent, newValue: string | null) => {\n onChange({ label: newValue ?? '', labelValues: value.labelValues, operator: value.operator });\n }}\n />\n <Select\n value={value.operator}\n variant=\"outlined\"\n onChange={(event: SelectChangeEvent) => {\n onChange({ label: value.label, labelValues: value.labelValues, operator: event.target.value as Operator });\n }}\n size=\"medium\"\n sx={{ borderTopLeftRadius: 0, borderBottomLeftRadius: 0, borderTopRightRadius: 0, borderBottomRightRadius: 0 }}\n >\n <MenuItem value=\"=\">=</MenuItem>\n <MenuItem value=\"!=\">!=</MenuItem>\n <MenuItem value=\"=~\">=~</MenuItem>\n <MenuItem value=\"!~\">!~</MenuItem>\n </Select>\n <Autocomplete\n freeSolo\n multiple={value.operator === '=~' || value.operator === '!~'}\n limitTags={1}\n disableClearable\n options={labelValuesOptions ?? []}\n value={value.labelValues}\n ListboxComponent={ListboxComponent}\n sx={{ minWidth: 200 }}\n loading={isLabelValuesOptionsLoading}\n renderInput={(params) => {\n return (\n <TextField\n {...params}\n label={value.operator === '=~' || value.operator === '!~' ? 'Label Values' : 'Label Value'}\n variant=\"outlined\"\n fullWidth\n size=\"medium\"\n sx={{\n '& .MuiOutlinedInput-root': {\n borderTopLeftRadius: 0,\n borderBottomLeftRadius: 0,\n },\n }}\n slotProps={{\n input: {\n ...params.InputProps,\n style: {\n maxHeight: '53.13px', // TODO: the input height is larger when a value is selected in multiple mode. Probably a bug fixed in newer version, could not replicate on their demo\n },\n endAdornment: (\n <InputAdornment position=\"end\">\n {isLabelValuesOptionsLoading ? <CircularProgress color=\"inherit\" size={20} /> : null}\n <IconButton aria-label=\"delete label filter\" onClick={() => onDelete()} edge=\"end\">\n <DeleteIcon />\n </IconButton>\n </InputAdornment>\n ),\n },\n }}\n />\n );\n }}\n onInputChange={(_, newValue) => {\n if (value.operator === '=' || value.operator === '!=') {\n onChange({ label: value.label, labelValues: [newValue], operator: value.operator });\n }\n }}\n onChange={(_, newValue) => {\n if (Array.isArray(newValue)) {\n onChange({ label: value.label, labelValues: newValue, operator: value.operator });\n }\n }}\n />\n </Stack>\n );\n}\n"],"names":["cloneElement","forwardRef","useMemo","useRef","useState","Autocomplete","CircularProgress","IconButton","InputAdornment","MenuItem","Select","Stack","TextField","DeleteIcon","Virtuoso","useLabels","useLabelValues","LabelFilterInput","datasource","value","filters","onChange","onDelete","filtersWithoutCurrent","filter","label","data","labelOptions","isLoading","isLabelOptionsLoading","labelValuesOptions","isLabelValuesOptionsLoading","RawFilterInput","ListboxComponent","children","rest","ref","localRef","height","setHeight","ul","style","overflow","padding","reference","maxHeight","getComputedStyle","current","totalListHeightChanged","itemContent","index","child","title","props","displayName","gap","flexDirection","alignItems","freeSolo","disableClearable","options","sx","minWidth","loading","renderInput","params","variant","fullWidth","size","borderTopRightRadius","borderBottomRightRadius","onInputChange","_","newValue","labelValues","operator","event","target","borderTopLeftRadius","borderBottomLeftRadius","multiple","limitTags","slotProps","input","InputProps","endAdornment","position","color","aria-label","onClick","edge","Array","isArray"],"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,SACEA,YAAY,EACZC,UAAU,EAIVC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,QAAQ;AACf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