@perses-dev/plugin-system 0.27.0 → 0.29.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/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +75 -0
- package/dist/cjs/components/PanelSpecEditor/index.js +28 -0
- package/dist/cjs/components/PluginEditor/PluginEditor.js +2 -2
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +27 -6
- package/dist/cjs/components/{PluginKindSelect.js → PluginKindSelect/PluginKindSelect.js} +1 -1
- package/dist/cjs/components/PluginKindSelect/index.js +28 -0
- package/dist/cjs/components/{PluginSpecEditor.js → PluginSpecEditor/PluginSpecEditor.js} +2 -30
- package/dist/cjs/components/PluginSpecEditor/index.js +28 -0
- package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +142 -0
- package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +94 -0
- package/dist/cjs/components/TimeSeriesQueryEditor/index.js +28 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +88 -0
- package/dist/cjs/runtime/DataQueriesProvider/index.js +29 -0
- package/dist/cjs/runtime/DataQueriesProvider/model.js +16 -0
- package/dist/cjs/runtime/index.js +1 -0
- package/dist/cjs/test/render.js +4 -1
- package/dist/cjs/test/test-plugins/bert/index.js +27 -20
- package/dist/cjs/test/test-plugins/ernie/index.js +37 -4
- package/dist/cjs/test-utils/mock-plugin-registry.js +4 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +10 -0
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -0
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +69 -0
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -0
- package/dist/components/PanelSpecEditor/index.d.ts +2 -0
- package/dist/components/PanelSpecEditor/index.d.ts.map +1 -0
- package/dist/components/PanelSpecEditor/index.js +15 -0
- package/dist/components/PanelSpecEditor/index.js.map +1 -0
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +2 -2
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +4 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +27 -6
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/{PluginKindSelect.d.ts → PluginKindSelect/PluginKindSelect.d.ts} +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -0
- package/dist/components/{PluginKindSelect.js → PluginKindSelect/PluginKindSelect.js} +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -0
- package/dist/components/PluginKindSelect/index.d.ts +2 -0
- package/dist/components/PluginKindSelect/index.d.ts.map +1 -0
- package/dist/components/PluginKindSelect/index.js +15 -0
- package/dist/components/PluginKindSelect/index.js.map +1 -0
- package/dist/components/PluginRegistry/PluginRegistry.d.ts +2 -2
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/{PluginSpecEditor.d.ts → PluginSpecEditor/PluginSpecEditor.d.ts} +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -0
- package/dist/components/{PluginSpecEditor.js → PluginSpecEditor/PluginSpecEditor.js} +3 -31
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -0
- package/dist/components/PluginSpecEditor/index.d.ts +2 -0
- package/dist/components/PluginSpecEditor/index.d.ts.map +1 -0
- package/dist/components/PluginSpecEditor/index.js +15 -0
- package/dist/components/PluginSpecEditor/index.js.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +8 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +131 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +13 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +83 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/index.d.ts +2 -0
- package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/index.js +15 -0
- package/dist/components/TimeSeriesQueryEditor/index.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/model/panels.d.ts +6 -5
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.d.ts +7 -0
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugins.d.ts +3 -1
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +8 -0
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -0
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +74 -0
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -0
- package/dist/runtime/DataQueriesProvider/index.d.ts +3 -0
- package/dist/runtime/DataQueriesProvider/index.d.ts.map +1 -0
- package/dist/runtime/DataQueriesProvider/index.js +16 -0
- package/dist/runtime/DataQueriesProvider/index.js.map +1 -0
- package/dist/runtime/DataQueriesProvider/model.d.ts +27 -0
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -0
- package/dist/runtime/DataQueriesProvider/model.js +15 -0
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +1 -1
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +4 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js +27 -20
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.d.ts +4 -1
- package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +28 -1
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +4 -1
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/package.json +3 -3
- package/dist/cjs/components/TimeSeriesQueryEditor.js +0 -42
- package/dist/components/PluginKindSelect.d.ts.map +0 -1
- package/dist/components/PluginKindSelect.js.map +0 -1
- package/dist/components/PluginSpecEditor.d.ts.map +0 -1
- package/dist/components/PluginSpecEditor.js.map +0 -1
- package/dist/components/TimeSeriesQueryEditor.d.ts +0 -14
- package/dist/components/TimeSeriesQueryEditor.d.ts.map +0 -1
- package/dist/components/TimeSeriesQueryEditor.js +0 -38
- package/dist/components/TimeSeriesQueryEditor.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./DataQueriesProvider"), exports);
|
|
18
|
+
_exportStar(require("./model"), exports);
|
|
19
|
+
function _exportStar(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return from;
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
@@ -19,6 +19,7 @@ _exportStar(require("./plugin-registry"), exports);
|
|
|
19
19
|
_exportStar(require("./template-variables"), exports);
|
|
20
20
|
_exportStar(require("./TimeRangeProvider"), exports);
|
|
21
21
|
_exportStar(require("./time-series-queries"), exports);
|
|
22
|
+
_exportStar(require("./DataQueriesProvider"), exports);
|
|
22
23
|
function _exportStar(from, to) {
|
|
23
24
|
Object.keys(from).forEach(function(k) {
|
|
24
25
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
package/dist/cjs/test/render.js
CHANGED
|
@@ -41,11 +41,14 @@ function renderWithContext(ui, renderOptions, contextOptions) {
|
|
|
41
41
|
},
|
|
42
42
|
logger: testLogger
|
|
43
43
|
});
|
|
44
|
+
var ref;
|
|
44
45
|
return (0, _react.render)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_reactQuery.QueryClientProvider, {
|
|
45
46
|
client: queryClient,
|
|
46
47
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginRegistry.PluginRegistry, {
|
|
47
48
|
pluginLoader: _testPlugins.testPluginLoader,
|
|
48
|
-
defaultPluginKinds: contextOptions === null || contextOptions === void 0 ? void 0 : contextOptions.defaultPluginKinds
|
|
49
|
+
defaultPluginKinds: (ref = contextOptions === null || contextOptions === void 0 ? void 0 : contextOptions.defaultPluginKinds) !== null && ref !== void 0 ? ref : {
|
|
50
|
+
TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
|
|
51
|
+
},
|
|
49
52
|
children: ui
|
|
50
53
|
})
|
|
51
54
|
}), renderOptions);
|
|
@@ -25,27 +25,33 @@ _export(exports, {
|
|
|
25
25
|
BertPanel2: ()=>BertPanel2
|
|
26
26
|
});
|
|
27
27
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
+
function BertPanel1Editor({ value , onChange }) {
|
|
29
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
30
|
+
children: [
|
|
31
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("label", {
|
|
32
|
+
htmlFor: "editor-input",
|
|
33
|
+
children: "BertPanel1 editor"
|
|
34
|
+
}),
|
|
35
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("input", {
|
|
36
|
+
type: "text",
|
|
37
|
+
id: "editor-input",
|
|
38
|
+
value: value.option1,
|
|
39
|
+
onChange: (e)=>onChange({
|
|
40
|
+
...value,
|
|
41
|
+
option1: e.target.value
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
28
47
|
const BertPanel1 = {
|
|
29
48
|
PanelComponent: ()=>null,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}),
|
|
37
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)("input", {
|
|
38
|
-
type: "text",
|
|
39
|
-
id: "editor-input",
|
|
40
|
-
value: value.option1,
|
|
41
|
-
onChange: (e)=>onChange({
|
|
42
|
-
...value,
|
|
43
|
-
option1: e.target.value
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
]
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
+
panelOptionsEditorComponents: [
|
|
50
|
+
{
|
|
51
|
+
label: 'Editor',
|
|
52
|
+
content: BertPanel1Editor
|
|
53
|
+
}
|
|
54
|
+
],
|
|
49
55
|
createInitialOptions: ()=>({
|
|
50
56
|
option1: ''
|
|
51
57
|
})
|
|
@@ -86,5 +92,6 @@ const BertPanel2 = {
|
|
|
86
92
|
],
|
|
87
93
|
createInitialOptions: ()=>({
|
|
88
94
|
option2: ''
|
|
89
|
-
})
|
|
95
|
+
}),
|
|
96
|
+
hideQueryEditor: true
|
|
90
97
|
};
|
|
@@ -14,9 +14,15 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
ErnieVariable1: ()=>ErnieVariable1,
|
|
25
|
+
ErnieVariable2: ()=>ErnieVariable2
|
|
20
26
|
});
|
|
21
27
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
28
|
const data = [
|
|
@@ -29,7 +35,7 @@ const data = [
|
|
|
29
35
|
value: 'Snuffleupagus'
|
|
30
36
|
}
|
|
31
37
|
];
|
|
32
|
-
const
|
|
38
|
+
const ErnieVariable1 = {
|
|
33
39
|
getVariableOptions: async ()=>({
|
|
34
40
|
data
|
|
35
41
|
}),
|
|
@@ -56,3 +62,30 @@ const ErnieVariable = {
|
|
|
56
62
|
variableOption: ''
|
|
57
63
|
})
|
|
58
64
|
};
|
|
65
|
+
const ErnieVariable2 = {
|
|
66
|
+
getVariableOptions: async ()=>({
|
|
67
|
+
data
|
|
68
|
+
}),
|
|
69
|
+
OptionsEditorComponent: function ErnieVariableEditor({ value , onChange }) {
|
|
70
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("label", {
|
|
73
|
+
htmlFor: "editor-input",
|
|
74
|
+
children: "ErnieVariable2 editor"
|
|
75
|
+
}),
|
|
76
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("input", {
|
|
77
|
+
type: "text",
|
|
78
|
+
id: "editor-input",
|
|
79
|
+
value: value.variableOption2,
|
|
80
|
+
onChange: (e)=>onChange({
|
|
81
|
+
...value,
|
|
82
|
+
variableOption2: e.target.value
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
createInitialOptions: ()=>({
|
|
89
|
+
variableOption2: ''
|
|
90
|
+
})
|
|
91
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PanelDefinition, QueryDefinition, UnknownSpec } from '@perses-dev/core';
|
|
3
|
+
export interface PanelSpecEditorProps {
|
|
4
|
+
panelDefinition: PanelDefinition;
|
|
5
|
+
onQueriesChange: (queries: QueryDefinition[]) => void;
|
|
6
|
+
onPluginSpecChange: (spec: UnknownSpec) => void;
|
|
7
|
+
onJSONChange: (panelDefinition: PanelDefinition) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function PanelSpecEditor(props: PanelSpecEditorProps): JSX.Element | null;
|
|
10
|
+
//# sourceMappingURL=PanelSpecEditor.d.ts.map
|
|
@@ -0,0 +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;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,eAAe,EAAE,eAAe,KAAK,IAAI,CAAC;CAC1D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,sBA0C1D"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { ErrorAlert, JSONEditor } from '@perses-dev/components';
|
|
15
|
+
import { usePlugin } from '../../runtime';
|
|
16
|
+
import { OptionsEditorTabs } from '../OptionsEditorTabs';
|
|
17
|
+
import { TimeSeriesQueryEditor } from '../TimeSeriesQueryEditor';
|
|
18
|
+
export function PanelSpecEditor(props) {
|
|
19
|
+
const { panelDefinition , onJSONChange , onQueriesChange , onPluginSpecChange } = props;
|
|
20
|
+
const { kind } = panelDefinition.spec.plugin;
|
|
21
|
+
const { data: plugin , isLoading , error } = usePlugin('Panel', kind);
|
|
22
|
+
if (error) {
|
|
23
|
+
return /*#__PURE__*/ _jsx(ErrorAlert, {
|
|
24
|
+
error: error
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// TODO: Proper loading indicator
|
|
28
|
+
if (isLoading) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
if (plugin === undefined) {
|
|
32
|
+
throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);
|
|
33
|
+
}
|
|
34
|
+
const { panelOptionsEditorComponents , hideQueryEditor } = plugin;
|
|
35
|
+
let tabs = [];
|
|
36
|
+
if (!hideQueryEditor) {
|
|
37
|
+
var _queries;
|
|
38
|
+
// Since we only support TimeSeriesQuery for now, we will always show a TimeSeriesQueryEditor
|
|
39
|
+
tabs.push({
|
|
40
|
+
label: 'Query',
|
|
41
|
+
content: /*#__PURE__*/ _jsx(TimeSeriesQueryEditor, {
|
|
42
|
+
queries: (_queries = panelDefinition.spec.queries) !== null && _queries !== void 0 ? _queries : [],
|
|
43
|
+
onChange: onQueriesChange
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (panelOptionsEditorComponents !== undefined) {
|
|
48
|
+
tabs = tabs.concat(panelOptionsEditorComponents.map(({ label , content: OptionsEditorComponent })=>({
|
|
49
|
+
label,
|
|
50
|
+
content: /*#__PURE__*/ _jsx(OptionsEditorComponent, {
|
|
51
|
+
value: panelDefinition.spec.plugin.spec,
|
|
52
|
+
onChange: onPluginSpecChange
|
|
53
|
+
})
|
|
54
|
+
})));
|
|
55
|
+
}
|
|
56
|
+
// always show json editor by default
|
|
57
|
+
tabs.push({
|
|
58
|
+
label: 'JSON',
|
|
59
|
+
content: /*#__PURE__*/ _jsx(JSONEditor, {
|
|
60
|
+
value: panelDefinition,
|
|
61
|
+
onChange: onJSONChange
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
return /*#__PURE__*/ _jsx(OptionsEditorTabs, {
|
|
65
|
+
tabs: tabs
|
|
66
|
+
}, tabs.length);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=PanelSpecEditor.js.map
|
|
@@ -0,0 +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 { TimeSeriesQueryEditor } from '../TimeSeriesQueryEditor';\n\nexport interface PanelSpecEditorProps {\n panelDefinition: PanelDefinition;\n onQueriesChange: (queries: QueryDefinition[]) => void;\n onPluginSpecChange: (spec: UnknownSpec) => void;\n onJSONChange: (panelDefinition: PanelDefinition) => 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 // Since we only support TimeSeriesQuery for now, we will always show a TimeSeriesQueryEditor\n tabs.push({\n label: 'Query',\n content: <TimeSeriesQueryEditor queries={panelDefinition.spec.queries ?? []} onChange={onQueriesChange} />,\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 by default\n tabs.push({ label: 'JSON', content: <JSONEditor value={panelDefinition} onChange={onJSONChange} /> });\n\n return <OptionsEditorTabs key={tabs.length} tabs={tabs} />;\n}\n"],"names":["ErrorAlert","JSONEditor","usePlugin","OptionsEditorTabs","TimeSeriesQueryEditor","PanelSpecEditor","props","panelDefinition","onJSONChange","onQueriesChange","onPluginSpecChange","kind","spec","plugin","data","isLoading","error","undefined","Error","panelOptionsEditorComponents","hideQueryEditor","tabs","push","label","content","queries","onChange","concat","map","OptionsEditorComponent","value","length"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;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,KAAK,EAAE,OAAO;YACdC,OAAO,gBAAE,KAACpB,qBAAqB;gBAACqB,OAAO,EAAElB,CAAAA,QAA4B,GAA5BA,eAAe,CAACK,IAAI,CAACa,OAAO,cAA5BlB,QAA4B,cAA5BA,QAA4B,GAAI,EAAE;gBAAEmB,QAAQ,EAAEjB,eAAe;cAAI;SAC3G,CAAC,CAAC;IACL,CAAC;IAED,IAAIU,4BAA4B,KAAKF,SAAS,EAAE;QAC9CI,IAAI,GAAGA,IAAI,CAACM,MAAM,CAChBR,4BAA4B,CAACS,GAAG,CAAC,CAAC,EAAEL,KAAK,CAAA,EAAEC,OAAO,EAAEK,sBAAsB,CAAA,EAAE,GAAM,CAAA;gBAChFN,KAAK;gBACLC,OAAO,gBAAE,KAACK,sBAAsB;oBAACC,KAAK,EAAEvB,eAAe,CAACK,IAAI,CAACC,MAAM,CAACD,IAAI;oBAAEc,QAAQ,EAAEhB,kBAAkB;kBAAI;aAC3G,CAAA,AAAC,CAAC,CACJ,CAAC;IACJ,CAAC;IAED,qCAAqC;IACrCW,IAAI,CAACC,IAAI,CAAC;QAAEC,KAAK,EAAE,MAAM;QAAEC,OAAO,gBAAE,KAACvB,UAAU;YAAC6B,KAAK,EAAEvB,eAAe;YAAEmB,QAAQ,EAAElB,YAAY;UAAI;KAAE,CAAC,CAAC;IAEtG,qBAAO,KAACL,iBAAiB;QAAmBkB,IAAI,EAAEA,IAAI;OAAvBA,IAAI,CAACU,MAAM,CAAgB,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PanelSpecEditor/index.tsx"],"names":[],"mappings":"AAaA,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './PanelSpecEditor';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelSpecEditor/index.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\nexport * from './PanelSpecEditor';\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,mBAAmB,CAAC"}
|
|
@@ -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,eAqBpD"}
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { Box, FormControl, FormHelperText, InputLabel } from '@mui/material';
|
|
15
|
-
import { PluginKindSelect } from '../PluginKindSelect';
|
|
16
|
-
import { PluginSpecEditor } from '../PluginSpecEditor';
|
|
15
|
+
import { PluginKindSelect } from '../PluginKindSelect/PluginKindSelect';
|
|
16
|
+
import { PluginSpecEditor } from '../PluginSpecEditor/PluginSpecEditor';
|
|
17
17
|
import { usePluginEditor } from './plugin-editor-api';
|
|
18
18
|
/**
|
|
19
19
|
* A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property
|
|
@@ -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, FormControl, FormHelperText, InputLabel } 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, pluginType, pluginKindLabel, onChange: _, ...others } = props;\n const { pendingKind, isLoading, error, onKindChange, onSpecChange } = usePluginEditor(props);\n return (\n <Box {...others}>\n <FormControl margin=\"dense\" fullWidth={false} disabled={isLoading} error={error !== null} sx={{ mb: 1 }}>\n {/* TODO: How to ensure ids are unique? */}\n <InputLabel id=\"plugin-kind-label\">{pluginKindLabel}</InputLabel>\n <PluginKindSelect\n labelId=\"plugin-kind-label\"\n label={pluginKindLabel}\n pluginType={pluginType}\n value={pendingKind !== '' ? pendingKind : value.kind}\n onChange={onKindChange}\n />\n <FormHelperText>{error?.message ?? ''}</FormHelperText>\n </FormControl>\n
|
|
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, FormControl, FormHelperText, InputLabel } from '@mui/material';\nimport { PluginKindSelect } from '../PluginKindSelect/PluginKindSelect';\nimport { PluginSpecEditor } from '../PluginSpecEditor/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, pluginType, pluginKindLabel, onChange: _, ...others } = props;\n const { pendingKind, isLoading, error, onKindChange, onSpecChange } = usePluginEditor(props);\n return (\n <Box {...others}>\n <FormControl margin=\"dense\" fullWidth={false} disabled={isLoading} error={error !== null} sx={{ mb: 1 }}>\n {/* TODO: How to ensure ids are unique? */}\n <InputLabel id=\"plugin-kind-label\">{pluginKindLabel}</InputLabel>\n <PluginKindSelect\n labelId=\"plugin-kind-label\"\n label={pluginKindLabel}\n pluginType={pluginType}\n value={pendingKind !== '' ? pendingKind : value.kind}\n onChange={onKindChange}\n />\n <FormHelperText>{error?.message ?? ''}</FormHelperText>\n </FormControl>\n <PluginSpecEditor pluginType={pluginType} pluginKind={value.kind} value={value.spec} onChange={onSpecChange} />\n </Box>\n );\n}\n"],"names":["Box","FormControl","FormHelperText","InputLabel","PluginKindSelect","PluginSpecEditor","usePluginEditor","PluginEditor","props","value","pluginType","pluginKindLabel","onChange","_","others","pendingKind","isLoading","error","onKindChange","onSpecChange","margin","fullWidth","disabled","sx","mb","id","labelId","label","kind","message","pluginKind","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;AAAA,SAASA,GAAG,EAAEC,WAAW,EAAEC,cAAc,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC7E,SAASC,gBAAgB,QAAQ,sCAAsC,CAAC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AAU;gBAAEoB,UAAU,EAAErB,KAAK,CAACmB,IAAI;gBAAEnB,KAAK,EAAEA,KAAK,CAACsB,IAAI;gBAAEnB,QAAQ,EAAEO,YAAY;cAAI;;MAC3G,CACN;AACJ,CAAC"}
|
|
@@ -12,7 +12,9 @@ export interface PluginEditorProps extends Omit<BoxProps, OmittedMuiProps> {
|
|
|
12
12
|
/**
|
|
13
13
|
* Props needed by the usePluginEditor hook.
|
|
14
14
|
*/
|
|
15
|
-
export declare type UsePluginEditorProps = Pick<PluginEditorProps, 'pluginType' | 'value' | 'onChange'
|
|
15
|
+
export declare type UsePluginEditorProps = Pick<PluginEditorProps, 'pluginType' | 'value' | 'onChange'> & {
|
|
16
|
+
onHideQueryEditorChange?: (isHidden: boolean) => void;
|
|
17
|
+
};
|
|
16
18
|
/**
|
|
17
19
|
* Returns the state/handlers that power the `PluginEditor` component. Useful for custom components that want to provide
|
|
18
20
|
* a different UI, but want the same behavior of changing `kind` and `spec` together on plugin kind changes. Also
|
|
@@ -25,6 +27,7 @@ export declare function usePluginEditor(props: UsePluginEditorProps): {
|
|
|
25
27
|
error: Error | null;
|
|
26
28
|
onKindChange: (event: import("@mui/material").SelectChangeEvent<string>, child: import("react").ReactNode) => void;
|
|
27
29
|
onSpecChange: (next: UnknownSpec) => void;
|
|
30
|
+
rememberCurrentSpecState: () => void;
|
|
28
31
|
};
|
|
29
32
|
export {};
|
|
30
33
|
//# sourceMappingURL=plugin-editor-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,UAAU,EAAE,WAAW,EAAY,MAAM,kBAAkB,CAAC;AAGrE,OAAO,
|
|
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,UAAU,EAAE,WAAW,EAAY,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EAAe,UAAU,EAAE,MAAM,aAAa,CAAC;AAOtD,aAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC;IACxE,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/B,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACnD;AAKD;;GAEG;AACH,oBAAY,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC,GAAG;IAChG,uBAAuB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CACvD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB;;;;;;;EAqG1D"}
|
|
@@ -20,9 +20,11 @@ import { usePlugin, usePluginRegistry } from '../../runtime';
|
|
|
20
20
|
* remembers previous `spec` values that it's seen, allowing and restores those values if a user switches the plugin
|
|
21
21
|
* kind back.
|
|
22
22
|
*/ export function usePluginEditor(props) {
|
|
23
|
-
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
24
|
+
const { pluginType , value , onHideQueryEditorChange =()=>{} } = props; // setting onHideQueryEditorChange to empty function here because useEvent requires a function
|
|
24
25
|
// Keep a stable reference so we don't run the effect below when we don't need to
|
|
25
26
|
const onChange = useEvent(props.onChange);
|
|
27
|
+
const onHideQuery = useEvent(onHideQueryEditorChange);
|
|
26
28
|
// The previous spec state for PluginType and kind and a helper function for remembering current values
|
|
27
29
|
const prevSpecState = useRef({
|
|
28
30
|
[pluginType]: {
|
|
@@ -37,6 +39,10 @@ import { usePlugin, usePluginRegistry } from '../../runtime';
|
|
|
37
39
|
}
|
|
38
40
|
byPluginType[value.kind] = value.spec;
|
|
39
41
|
});
|
|
42
|
+
// The previous hide query state for each panel kind
|
|
43
|
+
const hideQueryState = useRef({
|
|
44
|
+
[value.kind]: false
|
|
45
|
+
});
|
|
40
46
|
const { defaultPluginKinds } = usePluginRegistry();
|
|
41
47
|
const defaultPluginKind = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds[pluginType];
|
|
42
48
|
const initPendingKind = !value.kind && defaultPluginKind ? defaultPluginKind : '';
|
|
@@ -55,12 +61,23 @@ import { usePlugin, usePluginRegistry } from '../../runtime';
|
|
|
55
61
|
kind: pendingKind,
|
|
56
62
|
spec: plugin.createInitialOptions()
|
|
57
63
|
});
|
|
64
|
+
if (pluginType === 'Panel') {
|
|
65
|
+
const panelPlugin = plugin;
|
|
66
|
+
hideQueryState.current[pendingKind] = !!panelPlugin.hideQueryEditor;
|
|
67
|
+
if (!!panelPlugin.hideQueryEditor !== hideQueryState.current[value.kind]) {
|
|
68
|
+
onHideQuery(!!panelPlugin.hideQueryEditor);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
58
71
|
setPendingKind('');
|
|
59
72
|
}, [
|
|
60
73
|
pendingKind,
|
|
61
74
|
plugin,
|
|
62
75
|
rememberCurrentSpecState,
|
|
63
|
-
onChange
|
|
76
|
+
onChange,
|
|
77
|
+
onHideQuery,
|
|
78
|
+
hideQueryState,
|
|
79
|
+
pluginType,
|
|
80
|
+
value.kind
|
|
64
81
|
]);
|
|
65
82
|
/**
|
|
66
83
|
* When the user tries to change the plugin kind, make sure we have the correct spec for that plugin kind before we
|
|
@@ -76,10 +93,13 @@ import { usePlugin, usePluginRegistry } from '../../runtime';
|
|
|
76
93
|
kind: nextKind,
|
|
77
94
|
spec: previousState
|
|
78
95
|
});
|
|
79
|
-
|
|
96
|
+
} else {
|
|
97
|
+
// Otherwise, kick off the async loading process
|
|
98
|
+
setPendingKind(nextKind);
|
|
99
|
+
}
|
|
100
|
+
if (pluginType === 'Panel' && hideQueryState.current[nextKind] !== undefined && hideQueryState.current[value.kind] !== hideQueryState.current[nextKind]) {
|
|
101
|
+
onHideQuery(!!hideQueryState.current[nextKind]);
|
|
80
102
|
}
|
|
81
|
-
// Otherwise, kick off the async loading process
|
|
82
|
-
setPendingKind(nextKind);
|
|
83
103
|
};
|
|
84
104
|
/**
|
|
85
105
|
* Spec changes are independent and always just set the spec state.
|
|
@@ -93,7 +113,8 @@ import { usePlugin, usePluginRegistry } from '../../runtime';
|
|
|
93
113
|
isLoading: isFetching,
|
|
94
114
|
error,
|
|
95
115
|
onKindChange,
|
|
96
|
-
onSpecChange
|
|
116
|
+
onSpecChange,
|
|
117
|
+
rememberCurrentSpecState
|
|
97
118
|
};
|
|
98
119
|
}
|
|
99
120
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PluginEditor/plugin-editor-api.ts"],"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 { BoxProps } from '@mui/material';\nimport { Definition, UnknownSpec, useEvent } from '@perses-dev/core';\nimport { useState, useRef, useEffect } from 'react';\nimport { produce } from 'immer';\nimport { PluginType } from '../../model';\nimport { PluginKindSelectProps } from '../PluginKindSelect';\nimport { PluginSpecEditorProps } from '../PluginSpecEditor';\nimport { usePlugin, usePluginRegistry } from '../../runtime';\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';\n\nexport interface PluginEditorProps extends Omit<BoxProps, OmittedMuiProps> {\n pluginType: PluginType;\n pluginKindLabel: string;\n value: Definition<UnknownSpec>;\n onChange: (next: Definition<UnknownSpec>) => void;\n}\n\ntype PreviousSpecState = Record<string, Record<string, UnknownSpec>>;\n\n/**\n * Props needed by the usePluginEditor hook.\n */\nexport type UsePluginEditorProps = Pick<PluginEditorProps, 'pluginType' | 'value' | 'onChange'>;\n\n/**\n * Returns the state/handlers that power the `PluginEditor` component. Useful for custom components that want to provide\n * a different UI, but want the same behavior of changing `kind` and `spec` together on plugin kind changes. Also\n * remembers previous `spec` values that it's seen, allowing and restores those values if a user switches the plugin\n * kind back.\n */\nexport function usePluginEditor(props: UsePluginEditorProps) {\n const { pluginType, value } = props;\n\n // Keep a stable reference so we don't run the effect below when we don't need to\n const onChange = useEvent(props.onChange);\n\n // The previous spec state for PluginType and kind and a helper function for remembering current values\n const prevSpecState = useRef<PreviousSpecState>({\n [pluginType]: { [value.kind]: value.spec },\n });\n\n const rememberCurrentSpecState = useEvent(() => {\n let byPluginType = prevSpecState.current[pluginType];\n if (byPluginType === undefined) {\n byPluginType = {};\n prevSpecState.current[pluginType] = byPluginType;\n }\n byPluginType[value.kind] = value.spec;\n });\n\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPluginKind = defaultPluginKinds?.[pluginType];\n const initPendingKind = !value.kind && defaultPluginKind ? defaultPluginKind : '';\n\n // When kind changes and we haven't loaded that plugin before, we will need to enter a \"pending\" state so that we\n // can generate proper initial spec values that match the new plugin kind\n const [pendingKind, setPendingKind] = useState(initPendingKind);\n const { data: plugin, isFetching, error } = usePlugin(pluginType, pendingKind);\n\n useEffect(() => {\n // Nothing to do if no new plugin kind is pending\n if (pendingKind === '') return;\n\n // Can't get spec value until we have a plugin\n if (plugin === undefined) return;\n\n // Fire an onChange to change to the pending kind with initial values from the plugin\n rememberCurrentSpecState();\n onChange({\n kind: pendingKind,\n spec: plugin.createInitialOptions(),\n });\n setPendingKind('');\n }, [pendingKind, plugin, rememberCurrentSpecState, onChange]);\n\n /**\n * When the user tries to change the plugin kind, make sure we have the correct spec for that plugin kind before we\n * make the switch.\n */\n const onKindChange: PluginKindSelectProps['onChange'] = (e) => {\n const nextKind = e.target.value;\n\n // If we already have state for this plugin type/kind from a previous selection, just use it\n const previousState = prevSpecState.current[pluginType]?.[nextKind];\n if (previousState !== undefined) {\n rememberCurrentSpecState();\n onChange({\n kind: nextKind,\n spec: previousState,\n });\n return;\n }\n\n // Otherwise, kick off the async loading process\n setPendingKind(nextKind);\n };\n\n /**\n * Spec changes are independent and always just set the spec state.\n */\n const onSpecChange: PluginSpecEditorProps['onChange'] = (next) => {\n onChange(\n produce(value, (draft) => {\n draft.spec = next;\n })\n );\n };\n\n return { pendingKind, isLoading: isFetching, error, onKindChange, onSpecChange };\n}\n"],"names":["useEvent","useState","useRef","useEffect","produce","usePlugin","usePluginRegistry","usePluginEditor","props","pluginType","value","onChange","prevSpecState","kind","spec","rememberCurrentSpecState","byPluginType","current","undefined","defaultPluginKinds","defaultPluginKind","initPendingKind","pendingKind","setPendingKind","data","plugin","isFetching","error","createInitialOptions","onKindChange","e","nextKind","target","previousState","onSpecChange","next","draft","isLoading"],"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;AAGjC,SAAkCA,QAAQ,QAAQ,kBAAkB,CAAC;AACrE,SAASC,QAAQ,EAAEC,MAAM,EAAEC,SAAS,QAAQ,OAAO,CAAC;AACpD,SAASC,OAAO,QAAQ,OAAO,CAAC;AAIhC,SAASC,SAAS,EAAEC,iBAAiB,QAAQ,eAAe,CAAC;AAoB7D;;;;;CAKC,GACD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,IAAI,GAAGqB,IAAI,CAAC;QACpB,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,AAAC;IAEF,OAAO;QAAEb,WAAW;QAAEe,SAAS,EAAEX,UAAU;QAAEC,KAAK;QAAEE,YAAY;QAAEK,YAAY;KAAE,CAAC;AACnF,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PluginEditor/plugin-editor-api.ts"],"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 { BoxProps } from '@mui/material';\nimport { Definition, UnknownSpec, useEvent } from '@perses-dev/core';\nimport { useState, useRef, useEffect } from 'react';\nimport { produce } from 'immer';\nimport { PanelPlugin, PluginType } from '../../model';\nimport { PluginKindSelectProps } from '../PluginKindSelect/PluginKindSelect';\nimport { PluginSpecEditorProps } from '../PluginSpecEditor/PluginSpecEditor';\nimport { usePlugin, usePluginRegistry } from '../../runtime';\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';\n\nexport interface PluginEditorProps extends Omit<BoxProps, OmittedMuiProps> {\n pluginType: PluginType;\n pluginKindLabel: string;\n value: Definition<UnknownSpec>;\n onChange: (next: Definition<UnknownSpec>) => void;\n}\n\ntype PreviousSpecState = Record<string, Record<string, UnknownSpec>>;\ntype HideQueryEditorState = Record<string, boolean>;\n\n/**\n * Props needed by the usePluginEditor hook.\n */\nexport type UsePluginEditorProps = Pick<PluginEditorProps, 'pluginType' | 'value' | 'onChange'> & {\n onHideQueryEditorChange?: (isHidden: boolean) => void;\n};\n\n/**\n * Returns the state/handlers that power the `PluginEditor` component. Useful for custom components that want to provide\n * a different UI, but want the same behavior of changing `kind` and `spec` together on plugin kind changes. Also\n * remembers previous `spec` values that it's seen, allowing and restores those values if a user switches the plugin\n * kind back.\n */\nexport function usePluginEditor(props: UsePluginEditorProps) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const { pluginType, value, onHideQueryEditorChange = () => {} } = props; // setting onHideQueryEditorChange to empty function here because useEvent requires a function\n\n // Keep a stable reference so we don't run the effect below when we don't need to\n const onChange = useEvent(props.onChange);\n const onHideQuery = useEvent(onHideQueryEditorChange);\n\n // The previous spec state for PluginType and kind and a helper function for remembering current values\n const prevSpecState = useRef<PreviousSpecState>({\n [pluginType]: { [value.kind]: value.spec },\n });\n const rememberCurrentSpecState = useEvent(() => {\n let byPluginType = prevSpecState.current[pluginType];\n if (byPluginType === undefined) {\n byPluginType = {};\n prevSpecState.current[pluginType] = byPluginType;\n }\n byPluginType[value.kind] = value.spec;\n });\n\n // The previous hide query state for each panel kind\n const hideQueryState = useRef<HideQueryEditorState>({\n [value.kind]: false,\n });\n\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPluginKind = defaultPluginKinds?.[pluginType];\n const initPendingKind = !value.kind && defaultPluginKind ? defaultPluginKind : '';\n\n // When kind changes and we haven't loaded that plugin before, we will need to enter a \"pending\" state so that we\n // can generate proper initial spec values that match the new plugin kind\n const [pendingKind, setPendingKind] = useState(initPendingKind);\n const { data: plugin, isFetching, error } = usePlugin(pluginType, pendingKind);\n\n useEffect(() => {\n // Nothing to do if no new plugin kind is pending\n if (pendingKind === '') return;\n\n // Can't get spec value until we have a plugin\n if (plugin === undefined) return;\n\n // Fire an onChange to change to the pending kind with initial values from the plugin\n rememberCurrentSpecState();\n onChange({\n kind: pendingKind,\n spec: plugin.createInitialOptions(),\n });\n\n if (pluginType === 'Panel') {\n const panelPlugin = plugin as PanelPlugin;\n hideQueryState.current[pendingKind] = !!panelPlugin.hideQueryEditor;\n if (!!panelPlugin.hideQueryEditor !== hideQueryState.current[value.kind]) {\n onHideQuery(!!panelPlugin.hideQueryEditor);\n }\n }\n\n setPendingKind('');\n }, [pendingKind, plugin, rememberCurrentSpecState, onChange, onHideQuery, hideQueryState, pluginType, value.kind]);\n\n /**\n * When the user tries to change the plugin kind, make sure we have the correct spec for that plugin kind before we\n * make the switch.\n */\n const onKindChange: PluginKindSelectProps['onChange'] = (e) => {\n const nextKind = e.target.value;\n\n // If we already have state for this plugin type/kind from a previous selection, just use it\n const previousState = prevSpecState.current[pluginType]?.[nextKind];\n if (previousState !== undefined) {\n rememberCurrentSpecState();\n onChange({\n kind: nextKind,\n spec: previousState,\n });\n } else {\n // Otherwise, kick off the async loading process\n setPendingKind(nextKind);\n }\n\n if (\n pluginType === 'Panel' &&\n hideQueryState.current[nextKind] !== undefined &&\n hideQueryState.current[value.kind] !== hideQueryState.current[nextKind]\n ) {\n onHideQuery(!!hideQueryState.current[nextKind]);\n }\n };\n\n /**\n * Spec changes are independent and always just set the spec state.\n */\n const onSpecChange: PluginSpecEditorProps['onChange'] = (next) => {\n onChange(\n produce(value, (draft) => {\n draft.spec = next;\n })\n );\n };\n\n return { pendingKind, isLoading: isFetching, error, onKindChange, onSpecChange, rememberCurrentSpecState };\n}\n"],"names":["useEvent","useState","useRef","useEffect","produce","usePlugin","usePluginRegistry","usePluginEditor","props","pluginType","value","onHideQueryEditorChange","onChange","onHideQuery","prevSpecState","kind","spec","rememberCurrentSpecState","byPluginType","current","undefined","hideQueryState","defaultPluginKinds","defaultPluginKind","initPendingKind","pendingKind","setPendingKind","data","plugin","isFetching","error","createInitialOptions","panelPlugin","hideQueryEditor","onKindChange","e","nextKind","target","previousState","onSpecChange","next","draft","isLoading"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCA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GAAGwB,IAAI,CAAC;QACpB,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,AAAC;IAEF,OAAO;QAAEf,WAAW;QAAEiB,SAAS,EAAEb,UAAU;QAAEC,KAAK;QAAEI,YAAY;QAAEK,YAAY;QAAEtB,wBAAwB;KAAE,CAAC;AAC7G,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SelectProps } from '@mui/material';
|
|
3
|
-
import { PluginType } from '
|
|
3
|
+
import { PluginType } from '../../model';
|
|
4
4
|
export interface PluginKindSelectProps extends Omit<SelectProps<string>, 'children'> {
|
|
5
5
|
pluginType: PluginType;
|
|
6
6
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginKindSelect.d.ts","sourceRoot":"","sources":["../../../src/components/PluginKindSelect/PluginKindSelect.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,WAAW,EAAY,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAClF,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,eAiB5D"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Select, MenuItem } from '@mui/material';
|
|
15
|
-
import { useListPluginMetadata } from '
|
|
15
|
+
import { useListPluginMetadata } from '../../runtime';
|
|
16
16
|
/**
|
|
17
17
|
* Displays a MUI Select input for selecting a plugin's kind from a list of all the available plugins of a specific
|
|
18
18
|
* plugin type. (e.g. "Show a list of all the Panel plugins" or "Show a list of all the Variable plugins").
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PluginKindSelect/PluginKindSelect.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 { Select, SelectProps, MenuItem } from '@mui/material';\nimport { PluginType } from '../../model';\nimport { useListPluginMetadata } from '../../runtime';\n\nexport interface PluginKindSelectProps extends Omit<SelectProps<string>, 'children'> {\n pluginType: PluginType;\n}\n\n/**\n * Displays a MUI Select input for selecting a plugin's kind from a list of all the available plugins of a specific\n * plugin type. (e.g. \"Show a list of all the Panel plugins\" or \"Show a list of all the Variable plugins\").\n */\nexport function PluginKindSelect(props: PluginKindSelectProps) {\n const { pluginType, value: propValue, ...others } = props;\n const { data, isLoading } = useListPluginMetadata(pluginType);\n\n // Pass an empty value while options are still loading so MUI doesn't complain about us using an \"out of range\" value\n const value = propValue !== '' && isLoading ? '' : propValue;\n\n // TODO: Does this need a loading indicator of some kind?\n return (\n <Select sx={{ minWidth: 120 }} {...others} value={value}>\n {data?.map((metadata) => (\n <MenuItem key={metadata.kind} value={metadata.kind}>\n {metadata.display.name}\n </MenuItem>\n ))}\n </Select>\n );\n}\n"],"names":["Select","MenuItem","useListPluginMetadata","PluginKindSelect","props","pluginType","value","propValue","others","data","isLoading","sx","minWidth","map","metadata","kind","display","name"],"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;AAAA,SAASA,MAAM,EAAeC,QAAQ,QAAQ,eAAe,CAAC;AAE9D,SAASC,qBAAqB,QAAQ,eAAe,CAAC;AAMtD;;;CAGC,GACD,OAAO,SAASC,gBAAgB,CAACC,KAA4B,EAAE;IAC7D,MAAM,EAAEC,UAAU,CAAA,EAAEC,KAAK,EAAEC,SAAS,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGJ,KAAK,AAAC;IAC1D,MAAM,EAAEK,IAAI,CAAA,EAAEC,SAAS,CAAA,EAAE,GAAGR,qBAAqB,CAACG,UAAU,CAAC,AAAC;IAE9D,qHAAqH;IACrH,MAAMC,KAAK,GAAGC,SAAS,KAAK,EAAE,IAAIG,SAAS,GAAG,EAAE,GAAGH,SAAS,AAAC;IAE7D,yDAAyD;IACzD,qBACE,KAACP,MAAM;QAACW,EAAE,EAAE;YAAEC,QAAQ,EAAE,GAAG;SAAE;QAAG,GAAGJ,MAAM;QAAEF,KAAK,EAAEA,KAAK;kBACpDG,IAAI,aAAJA,IAAI,WAAK,GAATA,KAAAA,CAAS,GAATA,IAAI,CAAEI,GAAG,CAAC,CAACC,QAAQ,iBAClB,KAACb,QAAQ;gBAAqBK,KAAK,EAAEQ,QAAQ,CAACC,IAAI;0BAC/CD,QAAQ,CAACE,OAAO,CAACC,IAAI;eADTH,QAAQ,CAACC,IAAI,CAEjB,AACZ,CAAC;MACK,CACT;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PluginKindSelect/index.tsx"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './PluginKindSelect';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PluginKindSelect/index.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\nexport * from './PluginKindSelect';\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,oBAAoB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PluginLoader, DefaultPluginKinds } from '../../model';
|
|
3
3
|
export interface PluginRegistryProps {
|
|
4
|
-
children?: React.ReactNode;
|
|
5
4
|
pluginLoader: PluginLoader;
|
|
6
|
-
defaultPluginKinds
|
|
5
|
+
defaultPluginKinds: DefaultPluginKinds;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginRegistry.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"names":[],"mappings":";AAeA,OAAO,EAKL,YAAY,EACZ,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,mBAAmB;IAClC,
|
|
1
|
+
{"version":3,"file":"PluginRegistry.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"names":[],"mappings":";AAeA,OAAO,EAKL,YAAY,EACZ,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,eAoExD"}
|