@perses-dev/plugin-system 0.44.0-rc2 → 0.45.0-rc0
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/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +12 -3
- package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +35 -37
- package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +22 -10
- package/dist/cjs/components/{TimeSeriesQueryEditor → MultiQueryEditor}/index.js +2 -2
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +12 -46
- package/dist/cjs/components/PluginEditor/PluginEditor.js +6 -7
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +43 -31
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +25 -5
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +5 -3
- package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
- package/dist/cjs/components/ProjectSelect.js +3 -2
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +192 -0
- package/dist/cjs/components/{TraceQueryEditor → TimeRangeControls}/index.js +1 -1
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +16 -4
- package/dist/cjs/components/index.js +2 -1
- package/dist/cjs/constants/user-interface-text.js +4 -1
- package/dist/cjs/runtime/DataQueriesProvider/model.js +6 -2
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +8 -0
- package/dist/cjs/runtime/plugin-registry.js +7 -5
- package/dist/cjs/validation/resource.js +1 -1
- package/dist/cjs/validation/user.js +46 -0
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +12 -3
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +16 -0
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -0
- package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +42 -37
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -0
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +28 -0
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -0
- package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +32 -9
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -0
- package/dist/components/MultiQueryEditor/index.d.ts +2 -0
- package/dist/components/MultiQueryEditor/index.d.ts.map +1 -0
- package/dist/components/{TimeSeriesQueryEditor → MultiQueryEditor}/index.js +2 -2
- package/dist/components/{TraceQueryEditor → MultiQueryEditor}/index.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +13 -47
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +6 -7
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +15 -9
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +43 -31
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +10 -4
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +31 -8
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +5 -3
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +3 -3
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/ProjectSelect.js +3 -2
- package/dist/components/ProjectSelect.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +13 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +168 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
- package/dist/components/TimeRangeControls/index.d.ts +2 -0
- package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
- package/dist/components/{TraceQueryEditor → TimeRangeControls}/index.js +1 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +16 -4
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -1
- package/dist/components/index.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +2 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +4 -1
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/model/panels.d.ts +7 -2
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.d.ts +0 -1
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +6 -2
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +4 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +8 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +5 -5
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +7 -5
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/validation/resource.js +1 -1
- package/dist/validation/resource.js.map +1 -1
- package/dist/validation/user.d.ts +93 -0
- package/dist/validation/user.d.ts.map +1 -0
- package/dist/validation/user.js +38 -0
- package/dist/validation/user.js.map +1 -0
- package/package.json +4 -4
- package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +0 -143
- package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +0 -96
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +0 -7
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +0 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +0 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +0 -12
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +0 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +0 -1
- package/dist/components/TimeSeriesQueryEditor/index.d.ts +0 -2
- package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +0 -1
- package/dist/components/TimeSeriesQueryEditor/index.js.map +0 -1
- package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +0 -8
- package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +0 -1
- package/dist/components/TraceQueryEditor/TraceQueryEditor.js +0 -130
- package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +0 -1
- package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +0 -12
- package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +0 -1
- package/dist/components/TraceQueryEditor/TraceQueryInput.js +0 -83
- package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +0 -1
- package/dist/components/TraceQueryEditor/index.d.ts +0 -2
- package/dist/components/TraceQueryEditor/index.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -15,20 +15,45 @@ import { useState } from 'react';
|
|
|
15
15
|
import { produce } from 'immer';
|
|
16
16
|
import { Button, Stack } from '@mui/material';
|
|
17
17
|
import AddIcon from 'mdi-material-ui/Plus';
|
|
18
|
-
import { usePlugin, usePluginRegistry } from '../../runtime';
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
import { useListPluginMetadata, usePlugin, usePluginRegistry } from '../../runtime';
|
|
19
|
+
import { QueryEditorContainer } from './QueryEditorContainer';
|
|
20
|
+
function useDefaultQueryDefinition(queryTypes) {
|
|
21
|
+
var _queryPlugins_;
|
|
22
|
+
// Build the default query plugin
|
|
23
|
+
// This will be used only if the queries are empty, to open a starting query
|
|
24
|
+
// Firs the default query type
|
|
25
|
+
const defaultQueryType = queryTypes[0];
|
|
26
|
+
// Then the default plugin kind
|
|
27
|
+
// Use as default the plugin kind explicitly set as default or the first in the list
|
|
28
|
+
const { data: queryPlugins } = useListPluginMetadata(queryTypes);
|
|
23
29
|
const { defaultPluginKinds } = usePluginRegistry();
|
|
24
|
-
var
|
|
25
|
-
const
|
|
26
|
-
const { data: defaultQueryPlugin } = usePlugin(
|
|
30
|
+
var _defaultPluginKinds_defaultQueryType, _ref;
|
|
31
|
+
const defaultQueryKind = (_ref = (_defaultPluginKinds_defaultQueryType = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds[defaultQueryType]) !== null && _defaultPluginKinds_defaultQueryType !== void 0 ? _defaultPluginKinds_defaultQueryType : queryPlugins === null || queryPlugins === void 0 ? void 0 : (_queryPlugins_ = queryPlugins[0]) === null || _queryPlugins_ === void 0 ? void 0 : _queryPlugins_.kind) !== null && _ref !== void 0 ? _ref : '';
|
|
32
|
+
const { data: defaultQueryPlugin } = usePlugin(defaultQueryType, defaultQueryKind, {
|
|
27
33
|
useErrorBoundary: true,
|
|
28
34
|
enabled: true
|
|
29
35
|
});
|
|
36
|
+
// This default query definition is used if no query is provided initially or when we add a new query
|
|
37
|
+
return {
|
|
38
|
+
kind: defaultQueryType,
|
|
39
|
+
spec: {
|
|
40
|
+
plugin: {
|
|
41
|
+
kind: defaultQueryKind,
|
|
42
|
+
spec: (defaultQueryPlugin === null || defaultQueryPlugin === void 0 ? void 0 : defaultQueryPlugin.createInitialOptions()) || {}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A component render a list of {@link QueryEditor} for the given query definitions.
|
|
49
|
+
* It allows adding, removing and editing queries.
|
|
50
|
+
* @param queryTypes The list of query types that the underlying editor will propose
|
|
51
|
+
* @param queries The list of query definitions to render
|
|
52
|
+
* @param onChange The callback to call when the queries are modified
|
|
53
|
+
* @constructor
|
|
54
|
+
*/ export function MultiQueryEditor({ queryTypes, queries = [], onChange }) {
|
|
55
|
+
const defaultInitialQueryDefinition = useDefaultQueryDefinition(queryTypes);
|
|
30
56
|
// State for which queries are collapsed
|
|
31
|
-
// TODO: Would be easier if we had IDs for queries.
|
|
32
57
|
const [queriesCollapsed, setQueriesCollapsed] = useState(queries.map(()=>false));
|
|
33
58
|
// Query handlers
|
|
34
59
|
const handleQueryChange = (index, queryDef)=>{
|
|
@@ -43,23 +68,13 @@ export function TimeSeriesQueryEditor({ queries = [], onChange }) {
|
|
|
43
68
|
}));
|
|
44
69
|
};
|
|
45
70
|
const handleQueryAdd = ()=>{
|
|
46
|
-
if (!defaultQueryPlugin) return;
|
|
47
71
|
onChange(produce(queries, (draft)=>{
|
|
48
|
-
const queryDef = {
|
|
49
|
-
kind: DEFAULT_QUERY_PLUGIN_TYPE,
|
|
50
|
-
spec: {
|
|
51
|
-
plugin: {
|
|
52
|
-
kind: defaultTimeSeriesQueryKind,
|
|
53
|
-
spec: defaultQueryPlugin.createInitialOptions()
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
72
|
if (draft) {
|
|
58
|
-
draft.push(
|
|
73
|
+
draft.push(defaultInitialQueryDefinition);
|
|
59
74
|
} else {
|
|
60
75
|
draft = [
|
|
61
76
|
...queries,
|
|
62
|
-
|
|
77
|
+
defaultInitialQueryDefinition
|
|
63
78
|
];
|
|
64
79
|
}
|
|
65
80
|
}));
|
|
@@ -89,31 +104,21 @@ export function TimeSeriesQueryEditor({ queries = [], onChange }) {
|
|
|
89
104
|
];
|
|
90
105
|
});
|
|
91
106
|
};
|
|
92
|
-
var _defaultPluginKinds_TimeSeriesQuery;
|
|
93
107
|
// show one query input if queries is empty
|
|
94
108
|
const queryDefinitions = queries.length ? queries : [
|
|
95
|
-
|
|
96
|
-
kind: 'TimeSeriesQuery',
|
|
97
|
-
spec: {
|
|
98
|
-
plugin: {
|
|
99
|
-
kind: (_defaultPluginKinds_TimeSeriesQuery = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds['TimeSeriesQuery']) !== null && _defaultPluginKinds_TimeSeriesQuery !== void 0 ? _defaultPluginKinds_TimeSeriesQuery : '',
|
|
100
|
-
spec: {
|
|
101
|
-
query: ''
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
109
|
+
defaultInitialQueryDefinition
|
|
106
110
|
];
|
|
107
111
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
108
112
|
children: [
|
|
109
113
|
/*#__PURE__*/ _jsx(Stack, {
|
|
110
114
|
spacing: 1,
|
|
111
|
-
children: queryDefinitions.map((query, i)=>/*#__PURE__*/ _jsx(
|
|
115
|
+
children: queryDefinitions.map((query, i)=>/*#__PURE__*/ _jsx(QueryEditorContainer, {
|
|
116
|
+
queryTypes: queryTypes,
|
|
112
117
|
index: i,
|
|
113
118
|
query: query,
|
|
114
119
|
isCollapsed: !!queriesCollapsed[i],
|
|
115
120
|
onChange: handleQueryChange,
|
|
116
|
-
onDelete:
|
|
121
|
+
onDelete: queries.length > 1 ? handleQueryDelete : undefined,
|
|
117
122
|
onCollapseExpand: handleQueryCollapseExpand
|
|
118
123
|
}, i))
|
|
119
124
|
}),
|
|
@@ -130,4 +135,4 @@ export function TimeSeriesQueryEditor({ queries = [], onChange }) {
|
|
|
130
135
|
});
|
|
131
136
|
}
|
|
132
137
|
|
|
133
|
-
//# sourceMappingURL=
|
|
138
|
+
//# sourceMappingURL=MultiQueryEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/MultiQueryEditor/MultiQueryEditor.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 { useState } from 'react';\nimport { produce } from 'immer';\nimport { Button, Stack } from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { TimeSeriesQueryDefinition, QueryDefinition, QueryPluginType } from '@perses-dev/core';\nimport { useListPluginMetadata, usePlugin, usePluginRegistry } from '../../runtime';\nimport { QueryEditorContainer } from './QueryEditorContainer';\n\nexport interface MultiQueryEditorProps {\n queryTypes: QueryPluginType[];\n queries?: QueryDefinition[];\n onChange: (queries: QueryDefinition[]) => void;\n}\n\nfunction useDefaultQueryDefinition(queryTypes: QueryPluginType[]): QueryDefinition {\n // Build the default query plugin\n // This will be used only if the queries are empty, to open a starting query\n\n // Firs the default query type\n const defaultQueryType = queryTypes[0]!;\n\n // Then the default plugin kind\n // Use as default the plugin kind explicitly set as default or the first in the list\n const { data: queryPlugins } = useListPluginMetadata(queryTypes);\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.kind ?? '';\n\n const { data: defaultQueryPlugin } = usePlugin(defaultQueryType, defaultQueryKind, {\n useErrorBoundary: true,\n enabled: true,\n });\n\n // This default query definition is used if no query is provided initially or when we add a new query\n return {\n kind: defaultQueryType,\n spec: {\n plugin: { kind: defaultQueryKind, spec: defaultQueryPlugin?.createInitialOptions() || {} },\n },\n };\n}\n\n/**\n * A component render a list of {@link QueryEditor} for the given query definitions.\n * It allows adding, removing and editing queries.\n * @param queryTypes The list of query types that the underlying editor will propose\n * @param queries The list of query definitions to render\n * @param onChange The callback to call when the queries are modified\n * @constructor\n */\nexport function MultiQueryEditor({ queryTypes, queries = [], onChange }: MultiQueryEditorProps) {\n const defaultInitialQueryDefinition = useDefaultQueryDefinition(queryTypes);\n\n // State for which queries are collapsed\n const [queriesCollapsed, setQueriesCollapsed] = useState(queries.map(() => false));\n\n // Query handlers\n const handleQueryChange = (index: number, queryDef: TimeSeriesQueryDefinition) => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft[index] = queryDef;\n } else {\n draft = [queryDef];\n }\n })\n );\n };\n\n const handleQueryAdd = () => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft.push(defaultInitialQueryDefinition);\n } else {\n draft = [...queries, defaultInitialQueryDefinition];\n }\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.push(false);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryDelete = (index: number) => {\n onChange(\n produce(queries, (draft) => {\n draft.splice(index, 1);\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.splice(index, 1);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryCollapseExpand = (index: number) => {\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed[index] = !queriesCollapsed[index];\n return [...queriesCollapsed];\n });\n };\n\n // show one query input if queries is empty\n const queryDefinitions: TimeSeriesQueryDefinition[] = queries.length ? queries : [defaultInitialQueryDefinition];\n\n return (\n <>\n <Stack spacing={1}>\n {queryDefinitions.map((query: QueryDefinition, i: number) => (\n <QueryEditorContainer\n queryTypes={queryTypes}\n key={i}\n index={i}\n query={query}\n isCollapsed={!!queriesCollapsed[i]}\n onChange={handleQueryChange}\n onDelete={queries.length > 1 ? handleQueryDelete : undefined}\n onCollapseExpand={handleQueryCollapseExpand}\n />\n ))}\n </Stack>\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleQueryAdd}>\n Add Query\n </Button>\n </>\n );\n}\n"],"names":["useState","produce","Button","Stack","AddIcon","useListPluginMetadata","usePlugin","usePluginRegistry","QueryEditorContainer","useDefaultQueryDefinition","queryTypes","queryPlugins","defaultQueryType","data","defaultPluginKinds","defaultQueryKind","kind","defaultQueryPlugin","useErrorBoundary","enabled","spec","plugin","createInitialOptions","MultiQueryEditor","queries","onChange","defaultInitialQueryDefinition","queriesCollapsed","setQueriesCollapsed","map","handleQueryChange","index","queryDef","draft","handleQueryAdd","push","handleQueryDelete","splice","handleQueryCollapseExpand","queryDefinitions","length","spacing","query","i","isCollapsed","onDelete","undefined","onCollapseExpand","variant","startIcon","sx","marginTop","onClick"],"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,QAAQ,QAAQ,QAAQ;AACjC,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,MAAM,EAAEC,KAAK,QAAQ,gBAAgB;AAC9C,OAAOC,aAAa,uBAAuB;AAE3C,SAASC,qBAAqB,EAAEC,SAAS,EAAEC,iBAAiB,QAAQ,gBAAgB;AACpF,SAASC,oBAAoB,QAAQ,yBAAyB;AAQ9D,SAASC,0BAA0BC,UAA6B;QAWKC;IAVnE,iCAAiC;IACjC,4EAA4E;IAE5E,8BAA8B;IAC9B,MAAMC,mBAAmBF,UAAU,CAAC,EAAE;IAEtC,+BAA+B;IAC/B,oFAAoF;IACpF,MAAM,EAAEG,MAAMF,YAAY,EAAE,GAAGN,sBAAsBK;IACrD,MAAM,EAAEI,kBAAkB,EAAE,GAAGP;QACNO,sCAAAA;IAAzB,MAAMC,mBAAmBD,CAAAA,OAAAA,CAAAA,uCAAAA,+BAAAA,yCAAAA,kBAAoB,CAACF,iBAAiB,cAAtCE,kDAAAA,uCAA0CH,yBAAAA,oCAAAA,iBAAAA,YAAc,CAAC,EAAE,cAAjBA,qCAAAA,eAAmBK,IAAI,cAAjEF,kBAAAA,OAAqE;IAE9F,MAAM,EAAED,MAAMI,kBAAkB,EAAE,GAAGX,UAAUM,kBAAkBG,kBAAkB;QACjFG,kBAAkB;QAClBC,SAAS;IACX;IAEA,qGAAqG;IACrG,OAAO;QACLH,MAAMJ;QACNQ,MAAM;YACJC,QAAQ;gBAAEL,MAAMD;gBAAkBK,MAAMH,CAAAA,+BAAAA,yCAAAA,mBAAoBK,oBAAoB,OAAM,CAAC;YAAE;QAC3F;IACF;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC,iBAAiB,EAAEb,UAAU,EAAEc,UAAU,EAAE,EAAEC,QAAQ,EAAyB;IAC5F,MAAMC,gCAAgCjB,0BAA0BC;IAEhE,wCAAwC;IACxC,MAAM,CAACiB,kBAAkBC,oBAAoB,GAAG5B,SAASwB,QAAQK,GAAG,CAAC,IAAM;IAE3E,iBAAiB;IACjB,MAAMC,oBAAoB,CAACC,OAAeC;QACxCP,SACExB,QAAQuB,SAAS,CAACS;YAChB,IAAIA,OAAO;gBACTA,KAAK,CAACF,MAAM,GAAGC;YACjB,OAAO;gBACLC,QAAQ;oBAACD;iBAAS;YACpB;QACF;IAEJ;IAEA,MAAME,iBAAiB;QACrBT,SACExB,QAAQuB,SAAS,CAACS;YAChB,IAAIA,OAAO;gBACTA,MAAME,IAAI,CAACT;YACb,OAAO;gBACLO,QAAQ;uBAAIT;oBAASE;iBAA8B;YACrD;QACF;QAEFE,oBAAoB,CAACD;YACnBA,iBAAiBQ,IAAI,CAAC;YACtB,OAAO;mBAAIR;aAAiB;QAC9B;IACF;IAEA,MAAMS,oBAAoB,CAACL;QACzBN,SACExB,QAAQuB,SAAS,CAACS;YAChBA,MAAMI,MAAM,CAACN,OAAO;QACtB;QAEFH,oBAAoB,CAACD;YACnBA,iBAAiBU,MAAM,CAACN,OAAO;YAC/B,OAAO;mBAAIJ;aAAiB;QAC9B;IACF;IAEA,MAAMW,4BAA4B,CAACP;QACjCH,oBAAoB,CAACD;YACnBA,gBAAgB,CAACI,MAAM,GAAG,CAACJ,gBAAgB,CAACI,MAAM;YAClD,OAAO;mBAAIJ;aAAiB;QAC9B;IACF;IAEA,2CAA2C;IAC3C,MAAMY,mBAAgDf,QAAQgB,MAAM,GAAGhB,UAAU;QAACE;KAA8B;IAEhH,qBACE;;0BACE,KAACvB;gBAAMsC,SAAS;0BACbF,iBAAiBV,GAAG,CAAC,CAACa,OAAwBC,kBAC7C,KAACnC;wBACCE,YAAYA;wBAEZqB,OAAOY;wBACPD,OAAOA;wBACPE,aAAa,CAAC,CAACjB,gBAAgB,CAACgB,EAAE;wBAClClB,UAAUK;wBACVe,UAAUrB,QAAQgB,MAAM,GAAG,IAAIJ,oBAAoBU;wBACnDC,kBAAkBT;uBANbK;;0BAUX,KAACzC;gBAAO8C,SAAQ;gBAAYC,yBAAW,KAAC7C;gBAAY8C,IAAI;oBAAEC,WAAW;gBAAE;gBAAGC,SAASlB;0BAAgB;;;;AAKzG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { QueryDefinition, QueryPluginType } from '@perses-dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Properties for {@link QueryEditorContainer}
|
|
4
|
+
*/
|
|
5
|
+
interface QueryEditorContainerProps {
|
|
6
|
+
queryTypes: QueryPluginType[];
|
|
7
|
+
index: number;
|
|
8
|
+
query: QueryDefinition;
|
|
9
|
+
onChange: (index: number, query: QueryDefinition) => void;
|
|
10
|
+
onCollapseExpand: (index: number) => void;
|
|
11
|
+
isCollapsed?: boolean;
|
|
12
|
+
onDelete?: (index: number) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Container for a query editor. This component is responsible for rendering the query editor, and make it collapsible
|
|
16
|
+
* to not take too much space.
|
|
17
|
+
* @param queryTypes the supported query types
|
|
18
|
+
* @param index the index of the query in the list
|
|
19
|
+
* @param query the query definition
|
|
20
|
+
* @param isCollapsed whether the query editor is collapsed or not
|
|
21
|
+
* @param onDelete callback when the query is deleted
|
|
22
|
+
* @param onChange callback when the query is changed
|
|
23
|
+
* @param onCollapseExpand callback when the query is collapsed or expanded
|
|
24
|
+
* @constructor
|
|
25
|
+
*/
|
|
26
|
+
export declare const QueryEditorContainer: ({ queryTypes, index, query, isCollapsed, onDelete, onChange, onCollapseExpand, }: QueryEditorContainerProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=QueryEditorContainer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryEditorContainer.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/QueryEditorContainer.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOpE;;GAEG;AACH,UAAU,yBAAyB;IACjC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1D,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,qFAQ9B,yBAAyB,4CAsB3B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -17,7 +17,18 @@ import DeleteIcon from 'mdi-material-ui/DeleteOutline';
|
|
|
17
17
|
import ChevronDown from 'mdi-material-ui/ChevronDown';
|
|
18
18
|
import ChevronRight from 'mdi-material-ui/ChevronRight';
|
|
19
19
|
import { PluginEditor } from '../PluginEditor';
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Container for a query editor. This component is responsible for rendering the query editor, and make it collapsible
|
|
22
|
+
* to not take too much space.
|
|
23
|
+
* @param queryTypes the supported query types
|
|
24
|
+
* @param index the index of the query in the list
|
|
25
|
+
* @param query the query definition
|
|
26
|
+
* @param isCollapsed whether the query editor is collapsed or not
|
|
27
|
+
* @param onDelete callback when the query is deleted
|
|
28
|
+
* @param onChange callback when the query is changed
|
|
29
|
+
* @param onCollapseExpand callback when the query is collapsed or expanded
|
|
30
|
+
* @constructor
|
|
31
|
+
*/ export const QueryEditorContainer = ({ queryTypes, index, query, isCollapsed, onDelete, onChange, onCollapseExpand })=>{
|
|
21
32
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
22
33
|
spacing: 1,
|
|
23
34
|
children: [
|
|
@@ -53,6 +64,7 @@ export const TimeSeriesQueryInput = ({ index, query, isCollapsed, onDelete, onCh
|
|
|
53
64
|
]
|
|
54
65
|
}),
|
|
55
66
|
!isCollapsed && /*#__PURE__*/ _jsx(QueryEditor, {
|
|
67
|
+
queryTypes: queryTypes,
|
|
56
68
|
value: query,
|
|
57
69
|
onChange: (next)=>onChange(index, next)
|
|
58
70
|
})
|
|
@@ -60,24 +72,35 @@ export const TimeSeriesQueryInput = ({ index, query, isCollapsed, onDelete, onCh
|
|
|
60
72
|
}, index);
|
|
61
73
|
};
|
|
62
74
|
/**
|
|
63
|
-
*
|
|
75
|
+
* Editor for a query definition. This component is responsible for rendering the plugin editor for the given query.
|
|
76
|
+
* This will allow user to select a plugin extending from the given supported query types, and then edit the plugin
|
|
77
|
+
* spec for this plugin.
|
|
78
|
+
* @param props
|
|
79
|
+
* @constructor
|
|
64
80
|
*/ function QueryEditor(props) {
|
|
65
|
-
const { value, onChange, ...others } = props;
|
|
66
|
-
const { spec: { plugin } } = value;
|
|
81
|
+
const { value, onChange, queryTypes, ...others } = props;
|
|
67
82
|
const handlePluginChange = (next)=>{
|
|
68
83
|
onChange(produce(value, (draft)=>{
|
|
69
|
-
draft.
|
|
84
|
+
draft.kind = next.selection.type;
|
|
85
|
+
draft.spec.plugin.kind = next.selection.kind;
|
|
86
|
+
draft.spec.plugin.spec = next.spec;
|
|
70
87
|
}));
|
|
71
88
|
};
|
|
72
89
|
return /*#__PURE__*/ _jsx(Box, {
|
|
73
90
|
...others,
|
|
74
91
|
children: /*#__PURE__*/ _jsx(PluginEditor, {
|
|
75
|
-
|
|
92
|
+
pluginTypes: queryTypes,
|
|
76
93
|
pluginKindLabel: "Query Type",
|
|
77
|
-
value:
|
|
94
|
+
value: {
|
|
95
|
+
selection: {
|
|
96
|
+
kind: value.spec.plugin.kind,
|
|
97
|
+
type: value.kind
|
|
98
|
+
},
|
|
99
|
+
spec: value.spec.plugin.spec
|
|
100
|
+
},
|
|
78
101
|
onChange: handlePluginChange
|
|
79
102
|
})
|
|
80
103
|
});
|
|
81
104
|
}
|
|
82
105
|
|
|
83
|
-
//# sourceMappingURL=
|
|
106
|
+
//# sourceMappingURL=QueryEditorContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/MultiQueryEditor/QueryEditorContainer.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 produce from 'immer';\nimport { QueryDefinition, QueryPluginType } from '@perses-dev/core';\nimport { Stack, IconButton, Typography, BoxProps, Box } from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport ChevronDown from 'mdi-material-ui/ChevronDown';\nimport ChevronRight from 'mdi-material-ui/ChevronRight';\nimport { PluginEditor, PluginEditorProps } from '../PluginEditor';\n\n/**\n * Properties for {@link QueryEditorContainer}\n */\ninterface QueryEditorContainerProps {\n queryTypes: QueryPluginType[];\n index: number;\n query: QueryDefinition;\n onChange: (index: number, query: QueryDefinition) => void;\n onCollapseExpand: (index: number) => void;\n isCollapsed?: boolean;\n onDelete?: (index: number) => void;\n}\n\n/**\n * Container for a query editor. This component is responsible for rendering the query editor, and make it collapsible\n * to not take too much space.\n * @param queryTypes the supported query types\n * @param index the index of the query in the list\n * @param query the query definition\n * @param isCollapsed whether the query editor is collapsed or not\n * @param onDelete callback when the query is deleted\n * @param onChange callback when the query is changed\n * @param onCollapseExpand callback when the query is collapsed or expanded\n * @constructor\n */\nexport const QueryEditorContainer = ({\n queryTypes,\n index,\n query,\n isCollapsed,\n onDelete,\n onChange,\n onCollapseExpand,\n}: QueryEditorContainerProps) => {\n return (\n <Stack key={index} spacing={1}>\n <Stack direction=\"row\" alignItems=\"center\" borderBottom={1} borderColor={(theme) => theme.palette.divider}>\n <IconButton size=\"small\" onClick={() => onCollapseExpand(index)}>\n {isCollapsed ? <ChevronRight /> : <ChevronDown />}\n </IconButton>\n <Typography variant=\"overline\" component=\"h4\">\n Query {index + 1}\n </Typography>\n <IconButton\n size=\"small\"\n // Use `visibility` to ensure that the row has the same height when delete button is visible or not visible\n sx={{ marginLeft: 'auto', visibility: `${onDelete ? 'visible' : 'hidden'}` }}\n onClick={() => onDelete && onDelete(index)}\n >\n <DeleteIcon />\n </IconButton>\n </Stack>\n {!isCollapsed && <QueryEditor queryTypes={queryTypes} value={query} onChange={(next) => onChange(index, next)} />}\n </Stack>\n );\n};\n\n// Props on MUI Box that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\ninterface QueryEditorProps extends Omit<BoxProps, OmittedMuiProps> {\n queryTypes: QueryPluginType[];\n value: QueryDefinition;\n onChange: (next: QueryDefinition) => void;\n}\n\n/**\n * Editor for a query definition. This component is responsible for rendering the plugin editor for the given query.\n * This will allow user to select a plugin extending from the given supported query types, and then edit the plugin\n * spec for this plugin.\n * @param props\n * @constructor\n */\nfunction QueryEditor(props: QueryEditorProps) {\n const { value, onChange, queryTypes, ...others } = props;\n\n const handlePluginChange: PluginEditorProps['onChange'] = (next) => {\n onChange(\n produce(value, (draft) => {\n draft.kind = next.selection.type;\n draft.spec.plugin.kind = next.selection.kind;\n draft.spec.plugin.spec = next.spec;\n })\n );\n };\n\n return (\n <Box {...others}>\n <PluginEditor\n pluginTypes={queryTypes}\n pluginKindLabel=\"Query Type\"\n value={{\n selection: {\n kind: value.spec.plugin.kind,\n type: value.kind,\n },\n spec: value.spec.plugin.spec,\n }}\n onChange={handlePluginChange}\n />\n </Box>\n );\n}\n"],"names":["produce","Stack","IconButton","Typography","Box","DeleteIcon","ChevronDown","ChevronRight","PluginEditor","QueryEditorContainer","queryTypes","index","query","isCollapsed","onDelete","onChange","onCollapseExpand","spacing","direction","alignItems","borderBottom","borderColor","theme","palette","divider","size","onClick","variant","component","sx","marginLeft","visibility","QueryEditor","value","next","props","others","handlePluginChange","draft","kind","selection","type","spec","plugin","pluginTypes","pluginKindLabel"],"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,aAAa,QAAQ;AAE5B,SAASC,KAAK,EAAEC,UAAU,EAAEC,UAAU,EAAYC,GAAG,QAAQ,gBAAgB;AAC7E,OAAOC,gBAAgB,gCAAgC;AACvD,OAAOC,iBAAiB,8BAA8B;AACtD,OAAOC,kBAAkB,+BAA+B;AACxD,SAASC,YAAY,QAA2B,kBAAkB;AAelE;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,UAAU,EACVC,KAAK,EACLC,KAAK,EACLC,WAAW,EACXC,QAAQ,EACRC,QAAQ,EACRC,gBAAgB,EACU;IAC1B,qBACE,MAACf;QAAkBgB,SAAS;;0BAC1B,MAAChB;gBAAMiB,WAAU;gBAAMC,YAAW;gBAASC,cAAc;gBAAGC,aAAa,CAACC,QAAUA,MAAMC,OAAO,CAACC,OAAO;;kCACvG,KAACtB;wBAAWuB,MAAK;wBAAQC,SAAS,IAAMV,iBAAiBL;kCACtDE,4BAAc,KAACN,kCAAkB,KAACD;;kCAErC,MAACH;wBAAWwB,SAAQ;wBAAWC,WAAU;;4BAAK;4BACrCjB,QAAQ;;;kCAEjB,KAACT;wBACCuB,MAAK;wBACL,2GAA2G;wBAC3GI,IAAI;4BAAEC,YAAY;4BAAQC,YAAY,CAAC,EAAEjB,WAAW,YAAY,SAAS,CAAC;wBAAC;wBAC3EY,SAAS,IAAMZ,YAAYA,SAASH;kCAEpC,cAAA,KAACN;;;;YAGJ,CAACQ,6BAAe,KAACmB;gBAAYtB,YAAYA;gBAAYuB,OAAOrB;gBAAOG,UAAU,CAACmB,OAASnB,SAASJ,OAAOuB;;;OAjB9FvB;AAoBhB,EAAE;AAWF;;;;;;CAMC,GACD,SAASqB,YAAYG,KAAuB;IAC1C,MAAM,EAAEF,KAAK,EAAElB,QAAQ,EAAEL,UAAU,EAAE,GAAG0B,QAAQ,GAAGD;IAEnD,MAAME,qBAAoD,CAACH;QACzDnB,SACEf,QAAQiC,OAAO,CAACK;YACdA,MAAMC,IAAI,GAAGL,KAAKM,SAAS,CAACC,IAAI;YAChCH,MAAMI,IAAI,CAACC,MAAM,CAACJ,IAAI,GAAGL,KAAKM,SAAS,CAACD,IAAI;YAC5CD,MAAMI,IAAI,CAACC,MAAM,CAACD,IAAI,GAAGR,KAAKQ,IAAI;QACpC;IAEJ;IAEA,qBACE,KAACtC;QAAK,GAAGgC,MAAM;kBACb,cAAA,KAAC5B;YACCoC,aAAalC;YACbmC,iBAAgB;YAChBZ,OAAO;gBACLO,WAAW;oBACTD,MAAMN,MAAMS,IAAI,CAACC,MAAM,CAACJ,IAAI;oBAC5BE,MAAMR,MAAMM,IAAI;gBAClB;gBACAG,MAAMT,MAAMS,IAAI,CAACC,MAAM,CAACD,IAAI;YAC9B;YACA3B,UAAUsB;;;AAIlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/MultiQueryEditor/index.tsx"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -10,6 +10,6 @@
|
|
|
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
|
-
export * from './
|
|
13
|
+
export * from './MultiQueryEditor';
|
|
14
14
|
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/
|
|
1
|
+
{"version":3,"sources":["../../../src/components/MultiQueryEditor/index.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\nexport * from './MultiQueryEditor';\n"],"names":[],"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,cAAc,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"PanelSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAMjF,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IACtD,kBAAkB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAChD,YAAY,EAAE,CAAC,kBAAkB,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,kDAsD1D"}
|
|
@@ -11,11 +11,10 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { ErrorAlert, JSONEditor } from '@perses-dev/components';
|
|
14
|
+
import { ErrorAlert, JSONEditor, LinksEditor } from '@perses-dev/components';
|
|
15
15
|
import { usePlugin } from '../../runtime';
|
|
16
16
|
import { OptionsEditorTabs } from '../OptionsEditorTabs';
|
|
17
|
-
import {
|
|
18
|
-
import { TraceQueryEditor } from '../TraceQueryEditor';
|
|
17
|
+
import { MultiQueryEditor } from '../MultiQueryEditor';
|
|
19
18
|
export function PanelSpecEditor(props) {
|
|
20
19
|
const { panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;
|
|
21
20
|
const { kind } = panelDefinition.spec.plugin;
|
|
@@ -32,54 +31,17 @@ export function PanelSpecEditor(props) {
|
|
|
32
31
|
if (plugin === undefined) {
|
|
33
32
|
throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);
|
|
34
33
|
}
|
|
35
|
-
const getQueryType = ()=>{
|
|
36
|
-
var _panelDefinition_spec, _queriesList_;
|
|
37
|
-
const queriesList = panelDefinition === null || panelDefinition === void 0 ? void 0 : (_panelDefinition_spec = panelDefinition.spec) === null || _panelDefinition_spec === void 0 ? void 0 : _panelDefinition_spec.queries;
|
|
38
|
-
if (queriesList === undefined) {
|
|
39
|
-
return '';
|
|
40
|
-
}
|
|
41
|
-
const queryType = (_queriesList_ = queriesList[0]) === null || _queriesList_ === void 0 ? void 0 : _queriesList_.kind;
|
|
42
|
-
return queryType;
|
|
43
|
-
};
|
|
44
|
-
// Get the corresponding queryEditor depending on the queryType
|
|
45
|
-
const getQueryEditorComponent = ()=>{
|
|
46
|
-
const queryType = getQueryType();
|
|
47
|
-
// default case handles cause where there is no queryType yet (e.g. UI > 'editing' mode > 'Add Panel')
|
|
48
|
-
switch(queryType){
|
|
49
|
-
case 'TimeSeriesQuery':
|
|
50
|
-
var _panelDefinition_spec_queries;
|
|
51
|
-
return /*#__PURE__*/ _jsx(TimeSeriesQueryEditor, {
|
|
52
|
-
queries: (_panelDefinition_spec_queries = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries !== void 0 ? _panelDefinition_spec_queries : [],
|
|
53
|
-
onChange: onQueriesChange
|
|
54
|
-
});
|
|
55
|
-
case 'TraceQuery':
|
|
56
|
-
var _panelDefinition_spec_queries1;
|
|
57
|
-
return /*#__PURE__*/ _jsx(TraceQueryEditor, {
|
|
58
|
-
queries: (_panelDefinition_spec_queries1 = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries1 !== void 0 ? _panelDefinition_spec_queries1 : [],
|
|
59
|
-
onChange: onQueriesChange
|
|
60
|
-
});
|
|
61
|
-
default:
|
|
62
|
-
// ScatterChart only handles trace queries for now
|
|
63
|
-
if (kind === 'ScatterChart') {
|
|
64
|
-
var _panelDefinition_spec_queries2;
|
|
65
|
-
return /*#__PURE__*/ _jsx(TraceQueryEditor, {
|
|
66
|
-
queries: (_panelDefinition_spec_queries2 = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries2 !== void 0 ? _panelDefinition_spec_queries2 : [],
|
|
67
|
-
onChange: onQueriesChange
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
var _panelDefinition_spec_queries3;
|
|
71
|
-
return /*#__PURE__*/ _jsx(TimeSeriesQueryEditor, {
|
|
72
|
-
queries: (_panelDefinition_spec_queries3 = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries3 !== void 0 ? _panelDefinition_spec_queries3 : [],
|
|
73
|
-
onChange: onQueriesChange
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
34
|
const { panelOptionsEditorComponents, hideQueryEditor } = plugin;
|
|
78
35
|
let tabs = [];
|
|
79
36
|
if (!hideQueryEditor) {
|
|
37
|
+
var _plugin_supportedQueryTypes, _panelDefinition_spec_queries;
|
|
80
38
|
tabs.push({
|
|
81
39
|
label: 'Query',
|
|
82
|
-
content:
|
|
40
|
+
content: /*#__PURE__*/ _jsx(MultiQueryEditor, {
|
|
41
|
+
queryTypes: (_plugin_supportedQueryTypes = plugin.supportedQueryTypes) !== null && _plugin_supportedQueryTypes !== void 0 ? _plugin_supportedQueryTypes : [],
|
|
42
|
+
queries: (_panelDefinition_spec_queries = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries !== void 0 ? _panelDefinition_spec_queries : [],
|
|
43
|
+
onChange: onQueriesChange
|
|
44
|
+
})
|
|
83
45
|
});
|
|
84
46
|
}
|
|
85
47
|
if (panelOptionsEditorComponents !== undefined) {
|
|
@@ -91,7 +53,7 @@ export function PanelSpecEditor(props) {
|
|
|
91
53
|
})
|
|
92
54
|
})));
|
|
93
55
|
}
|
|
94
|
-
// always show json editor by default
|
|
56
|
+
// always show json editor and links editor by default
|
|
95
57
|
tabs.push({
|
|
96
58
|
label: 'JSON',
|
|
97
59
|
content: /*#__PURE__*/ _jsx(JSONEditor, {
|
|
@@ -100,6 +62,10 @@ export function PanelSpecEditor(props) {
|
|
|
100
62
|
onChange: onJSONChange
|
|
101
63
|
})
|
|
102
64
|
});
|
|
65
|
+
tabs.push({
|
|
66
|
+
label: 'Links',
|
|
67
|
+
content: /*#__PURE__*/ _jsx(LinksEditor, {})
|
|
68
|
+
});
|
|
103
69
|
return /*#__PURE__*/ _jsx(OptionsEditorTabs, {
|
|
104
70
|
tabs: tabs
|
|
105
71
|
}, tabs.length);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.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 { ErrorAlert, JSONEditor } from '@perses-dev/components';\nimport { PanelDefinition, QueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { usePlugin } from '../../runtime';\nimport { PanelPlugin } from '../../model';\nimport { OptionsEditorTabsProps, OptionsEditorTabs } from '../OptionsEditorTabs';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.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 { ErrorAlert, JSONEditor, LinksEditor } from '@perses-dev/components';\nimport { PanelDefinition, QueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { usePlugin } from '../../runtime';\nimport { PanelPlugin } from '../../model';\nimport { OptionsEditorTabsProps, OptionsEditorTabs } from '../OptionsEditorTabs';\nimport { MultiQueryEditor } from '../MultiQueryEditor';\n\nexport interface PanelSpecEditorProps {\n panelDefinition: PanelDefinition;\n onQueriesChange: (queries: QueryDefinition[]) => void;\n onPluginSpecChange: (spec: UnknownSpec) => void;\n onJSONChange: (panelDefinitionStr: string) => void;\n}\n\nexport function PanelSpecEditor(props: PanelSpecEditorProps) {\n const { panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;\n const { kind } = panelDefinition.spec.plugin;\n const { data: plugin, isLoading, error } = usePlugin('Panel', kind);\n\n if (error) {\n return <ErrorAlert error={error} />;\n }\n\n // TODO: Proper loading indicator\n if (isLoading) {\n return null;\n }\n\n if (plugin === undefined) {\n throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);\n }\n\n const { panelOptionsEditorComponents, hideQueryEditor } = plugin as PanelPlugin;\n let tabs: OptionsEditorTabsProps['tabs'] = [];\n\n if (!hideQueryEditor) {\n tabs.push({\n label: 'Query',\n content: (\n <MultiQueryEditor\n queryTypes={plugin.supportedQueryTypes ?? []}\n queries={panelDefinition.spec.queries ?? []}\n onChange={onQueriesChange}\n />\n ),\n });\n }\n\n if (panelOptionsEditorComponents !== undefined) {\n tabs = tabs.concat(\n panelOptionsEditorComponents.map(({ label, content: OptionsEditorComponent }) => ({\n label,\n content: <OptionsEditorComponent value={panelDefinition.spec.plugin.spec} onChange={onPluginSpecChange} />,\n }))\n );\n }\n\n // always show json editor and links editor by default\n tabs.push({\n label: 'JSON',\n content: <JSONEditor maxHeight=\"80vh\" value={panelDefinition} onChange={onJSONChange} />,\n });\n tabs.push({\n label: 'Links',\n content: <LinksEditor />,\n });\n\n return <OptionsEditorTabs key={tabs.length} tabs={tabs} />;\n}\n"],"names":["ErrorAlert","JSONEditor","LinksEditor","usePlugin","OptionsEditorTabs","MultiQueryEditor","PanelSpecEditor","props","panelDefinition","onJSONChange","onQueriesChange","onPluginSpecChange","kind","spec","plugin","data","isLoading","error","undefined","Error","panelOptionsEditorComponents","hideQueryEditor","tabs","push","label","content","queryTypes","supportedQueryTypes","queries","onChange","concat","map","OptionsEditorComponent","value","maxHeight","length"],"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,UAAU,EAAEC,UAAU,EAAEC,WAAW,QAAQ,yBAAyB;AAE7E,SAASC,SAAS,QAAQ,gBAAgB;AAE1C,SAAiCC,iBAAiB,QAAQ,uBAAuB;AACjF,SAASC,gBAAgB,QAAQ,sBAAsB;AASvD,OAAO,SAASC,gBAAgBC,KAA2B;IACzD,MAAM,EAAEC,eAAe,EAAEC,YAAY,EAAEC,eAAe,EAAEC,kBAAkB,EAAE,GAAGJ;IAC/E,MAAM,EAAEK,IAAI,EAAE,GAAGJ,gBAAgBK,IAAI,CAACC,MAAM;IAC5C,MAAM,EAAEC,MAAMD,MAAM,EAAEE,SAAS,EAAEC,KAAK,EAAE,GAAGd,UAAU,SAASS;IAE9D,IAAIK,OAAO;QACT,qBAAO,KAACjB;YAAWiB,OAAOA;;IAC5B;IAEA,iCAAiC;IACjC,IAAID,WAAW;QACb,OAAO;IACT;IAEA,IAAIF,WAAWI,WAAW;QACxB,MAAM,IAAIC,MAAM,CAAC,mDAAmD,EAAEP,KAAK,CAAC,CAAC;IAC/E;IAEA,MAAM,EAAEQ,4BAA4B,EAAEC,eAAe,EAAE,GAAGP;IAC1D,IAAIQ,OAAuC,EAAE;IAE7C,IAAI,CAACD,iBAAiB;YAKFP,6BACHN;QALfc,KAAKC,IAAI,CAAC;YACRC,OAAO;YACPC,uBACE,KAACpB;gBACCqB,YAAYZ,CAAAA,8BAAAA,OAAOa,mBAAmB,cAA1Bb,yCAAAA,8BAA8B,EAAE;gBAC5Cc,SAASpB,CAAAA,gCAAAA,gBAAgBK,IAAI,CAACe,OAAO,cAA5BpB,2CAAAA,gCAAgC,EAAE;gBAC3CqB,UAAUnB;;QAGhB;IACF;IAEA,IAAIU,iCAAiCF,WAAW;QAC9CI,OAAOA,KAAKQ,MAAM,CAChBV,6BAA6BW,GAAG,CAAC,CAAC,EAAEP,KAAK,EAAEC,SAASO,sBAAsB,EAAE,GAAM,CAAA;gBAChFR;gBACAC,uBAAS,KAACO;oBAAuBC,OAAOzB,gBAAgBK,IAAI,CAACC,MAAM,CAACD,IAAI;oBAAEgB,UAAUlB;;YACtF,CAAA;IAEJ;IAEA,sDAAsD;IACtDW,KAAKC,IAAI,CAAC;QACRC,OAAO;QACPC,uBAAS,KAACxB;YAAWiC,WAAU;YAAOD,OAAOzB;YAAiBqB,UAAUpB;;IAC1E;IACAa,KAAKC,IAAI,CAAC;QACRC,OAAO;QACPC,uBAAS,KAACvB;IACZ;IAEA,qBAAO,KAACE;QAAoCkB,MAAMA;OAAnBA,KAAKa,MAAM;AAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,qBAAqB,CAAC;AAEzE;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"PluginEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,qBAAqB,CAAC;AAEzE;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CA2BpD"}
|
|
@@ -24,8 +24,8 @@ import { usePluginEditor } from './plugin-editor-api';
|
|
|
24
24
|
* `usePluginEditor` hook that powers this component.
|
|
25
25
|
*/ export function PluginEditor(props) {
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
-
const { value,
|
|
28
|
-
const {
|
|
27
|
+
const { value, pluginTypes, pluginKindLabel, onChange: _, isReadonly, ...others } = props;
|
|
28
|
+
const { pendingSelection, isLoading, error, onSelectionChange, onSpecChange } = usePluginEditor(props);
|
|
29
29
|
return /*#__PURE__*/ _jsxs(Box, {
|
|
30
30
|
...others,
|
|
31
31
|
children: [
|
|
@@ -37,19 +37,18 @@ import { usePluginEditor } from './plugin-editor-api';
|
|
|
37
37
|
},
|
|
38
38
|
margin: "dense",
|
|
39
39
|
label: pluginKindLabel,
|
|
40
|
-
|
|
40
|
+
pluginTypes: pluginTypes,
|
|
41
41
|
disabled: isLoading,
|
|
42
|
-
value:
|
|
42
|
+
value: pendingSelection ? pendingSelection : value.selection,
|
|
43
43
|
InputProps: {
|
|
44
44
|
readOnly: isReadonly
|
|
45
45
|
},
|
|
46
46
|
error: !!error,
|
|
47
47
|
helperText: error === null || error === void 0 ? void 0 : error.message,
|
|
48
|
-
onChange:
|
|
48
|
+
onChange: onSelectionChange
|
|
49
49
|
}),
|
|
50
50
|
/*#__PURE__*/ _jsx(PluginSpecEditor, {
|
|
51
|
-
|
|
52
|
-
pluginKind: value.kind,
|
|
51
|
+
pluginSelection: value.selection,
|
|
53
52
|
value: value.spec,
|
|
54
53
|
onChange: onSpecChange,
|
|
55
54
|
isReadonly: isReadonly
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PluginEditor/PluginEditor.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 { Box } from '@mui/material';\nimport { PluginKindSelect } from '../PluginKindSelect';\nimport { PluginSpecEditor } from '../PluginSpecEditor';\nimport { PluginEditorProps, usePluginEditor } from './plugin-editor-api';\n\n/**\n * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property\n * that's common in our JSON specs where a user selects a plugin `kind` and then edits the `spec` via that plugin's\n * editor component. It takes care of transitioning from one plugin kind to another \"all at once\" so that when the\n * plugin's kind changes, the spec is also changed at the same time so those options editor components don't see a\n * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the\n * `usePluginEditor` hook that powers this component.\n */\nexport function PluginEditor(props: PluginEditorProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { value,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PluginEditor/PluginEditor.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 { Box } from '@mui/material';\nimport { PluginKindSelect } from '../PluginKindSelect';\nimport { PluginSpecEditor } from '../PluginSpecEditor';\nimport { PluginEditorProps, usePluginEditor } from './plugin-editor-api';\n\n/**\n * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property\n * that's common in our JSON specs where a user selects a plugin `kind` and then edits the `spec` via that plugin's\n * editor component. It takes care of transitioning from one plugin kind to another \"all at once\" so that when the\n * plugin's kind changes, the spec is also changed at the same time so those options editor components don't see a\n * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the\n * `usePluginEditor` hook that powers this component.\n */\nexport function PluginEditor(props: PluginEditorProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { value, pluginTypes, pluginKindLabel, onChange: _, isReadonly, ...others } = props;\n const { pendingSelection, isLoading, error, onSelectionChange, onSpecChange } = usePluginEditor(props);\n return (\n <Box {...others}>\n <PluginKindSelect\n fullWidth={false}\n sx={{ mb: 1, minWidth: 120 }}\n margin=\"dense\"\n label={pluginKindLabel}\n pluginTypes={pluginTypes}\n disabled={isLoading}\n value={pendingSelection ? pendingSelection : value.selection}\n InputProps={{ readOnly: isReadonly }}\n error={!!error}\n helperText={error?.message}\n onChange={onSelectionChange}\n />\n <PluginSpecEditor\n pluginSelection={value.selection}\n value={value.spec}\n onChange={onSpecChange}\n isReadonly={isReadonly}\n />\n </Box>\n );\n}\n"],"names":["Box","PluginKindSelect","PluginSpecEditor","usePluginEditor","PluginEditor","props","value","pluginTypes","pluginKindLabel","onChange","_","isReadonly","others","pendingSelection","isLoading","error","onSelectionChange","onSpecChange","fullWidth","sx","mb","minWidth","margin","label","disabled","selection","InputProps","readOnly","helperText","message","pluginSelection","spec"],"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,GAAG,QAAQ,gBAAgB;AACpC,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAA4BC,eAAe,QAAQ,sBAAsB;AAEzE;;;;;;;CAOC,GACD,OAAO,SAASC,aAAaC,KAAwB;IACnD,6DAA6D;IAC7D,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,eAAe,EAAEC,UAAUC,CAAC,EAAEC,UAAU,EAAE,GAAGC,QAAQ,GAAGP;IACpF,MAAM,EAAEQ,gBAAgB,EAAEC,SAAS,EAAEC,KAAK,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGd,gBAAgBE;IAChG,qBACE,MAACL;QAAK,GAAGY,MAAM;;0BACb,KAACX;gBACCiB,WAAW;gBACXC,IAAI;oBAAEC,IAAI;oBAAGC,UAAU;gBAAI;gBAC3BC,QAAO;gBACPC,OAAOf;gBACPD,aAAaA;gBACbiB,UAAUV;gBACVR,OAAOO,mBAAmBA,mBAAmBP,MAAMmB,SAAS;gBAC5DC,YAAY;oBAAEC,UAAUhB;gBAAW;gBACnCI,OAAO,CAAC,CAACA;gBACTa,UAAU,EAAEb,kBAAAA,4BAAAA,MAAOc,OAAO;gBAC1BpB,UAAUO;;0BAEZ,KAACd;gBACC4B,iBAAiBxB,MAAMmB,SAAS;gBAChCnB,OAAOA,MAAMyB,IAAI;gBACjBtB,UAAUQ;gBACVN,YAAYA;;;;AAIpB"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { BoxProps } from '@mui/material';
|
|
3
|
-
import {
|
|
2
|
+
import { UnknownSpec } from '@perses-dev/core';
|
|
4
3
|
import { PluginType } from '../../model';
|
|
4
|
+
export interface PluginEditorSelection {
|
|
5
|
+
type: PluginType;
|
|
6
|
+
kind: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PluginEditorValue {
|
|
9
|
+
selection: PluginEditorSelection;
|
|
10
|
+
spec: UnknownSpec;
|
|
11
|
+
}
|
|
5
12
|
type OmittedMuiProps = 'children' | 'value' | 'onChange';
|
|
6
13
|
export interface PluginEditorProps extends Omit<BoxProps, OmittedMuiProps> {
|
|
7
|
-
|
|
14
|
+
pluginTypes: PluginType[];
|
|
8
15
|
pluginKindLabel: string;
|
|
9
|
-
value:
|
|
16
|
+
value: PluginEditorValue;
|
|
10
17
|
isReadonly?: boolean;
|
|
11
|
-
|
|
12
|
-
onChange: (next: Definition<UnknownSpec>) => void;
|
|
18
|
+
onChange: (next: PluginEditorValue) => void;
|
|
13
19
|
}
|
|
14
20
|
/**
|
|
15
21
|
* Props needed by the usePluginEditor hook.
|
|
16
22
|
*/
|
|
17
|
-
export type UsePluginEditorProps = Pick<PluginEditorProps, '
|
|
23
|
+
export type UsePluginEditorProps = Pick<PluginEditorProps, 'pluginTypes' | 'value' | 'onChange'> & {
|
|
18
24
|
onHideQueryEditorChange?: (isHidden: boolean) => void;
|
|
19
25
|
};
|
|
20
26
|
/**
|
|
@@ -24,10 +30,10 @@ export type UsePluginEditorProps = Pick<PluginEditorProps, 'pluginType' | 'value
|
|
|
24
30
|
* kind back.
|
|
25
31
|
*/
|
|
26
32
|
export declare function usePluginEditor(props: UsePluginEditorProps): {
|
|
27
|
-
|
|
33
|
+
pendingSelection: PluginEditorSelection | undefined;
|
|
28
34
|
isLoading: boolean;
|
|
29
35
|
error: Error | null;
|
|
30
|
-
|
|
36
|
+
onSelectionChange: (s: PluginEditorSelection) => void;
|
|
31
37
|
onSpecChange: (next: UnknownSpec) => void;
|
|
32
38
|
rememberCurrentSpecState: () => void;
|
|
33
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-editor-api.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/plugin-editor-api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-editor-api.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/plugin-editor-api.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAY,MAAM,kBAAkB,CAAC;AAGzD,OAAO,EAAe,UAAU,EAAE,MAAM,aAAa,CAAC;AAKtD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,qBAAqB,CAAC;IACjC,IAAI,EAAE,WAAW,CAAC;CACnB;AAID,KAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC;IACxE,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,iBAAiB,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC7C;AAKD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,OAAO,GAAG,UAAU,CAAC,GAAG;IACjG,uBAAuB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CACvD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB;;;;;;;EAyH1D"}
|