@perses-dev/plugin-system 0.0.0-snapshot-time-range-height-80d08fc
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/LICENSE +201 -0
- package/dist/cjs/components/CalculationSelector/CalculationSelector.js +52 -0
- package/dist/cjs/components/CalculationSelector/CalculationSelector.test.js +65 -0
- package/dist/cjs/components/CalculationSelector/index.js +28 -0
- package/dist/cjs/components/DatasourceSelect.js +76 -0
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +102 -0
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.test.js +167 -0
- package/dist/cjs/components/OptionsEditorTabs/TabPanel.js +37 -0
- package/dist/cjs/components/OptionsEditorTabs/index.js +28 -0
- package/dist/cjs/components/PluginEditor/PluginEditor.js +67 -0
- package/dist/cjs/components/PluginEditor/PluginEditor.test.js +150 -0
- package/dist/cjs/components/PluginEditor/index.js +29 -0
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +101 -0
- package/dist/cjs/components/PluginKindSelect.js +41 -0
- package/dist/cjs/components/PluginKindSelect.test.js +86 -0
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +85 -0
- package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +144 -0
- package/dist/cjs/components/PluginRegistry/index.js +28 -0
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +78 -0
- package/dist/cjs/components/PluginSpecEditor.js +43 -0
- package/dist/cjs/components/PluginSpecEditor.test.js +70 -0
- package/dist/cjs/components/TimeSeriesQueryEditor.js +42 -0
- package/dist/cjs/components/index.js +35 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/model/calculations.js +77 -0
- package/dist/cjs/model/datasource.js +16 -0
- package/dist/cjs/model/index.js +35 -0
- package/dist/cjs/model/panels.js +16 -0
- package/dist/cjs/model/plugin-base.js +22 -0
- package/dist/cjs/model/plugin-loading.js +38 -0
- package/dist/cjs/model/plugins.js +16 -0
- package/dist/cjs/model/time-series-queries.js +16 -0
- package/dist/cjs/model/variables.js +16 -0
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +118 -0
- package/dist/cjs/runtime/TimeRangeProvider/index.js +29 -0
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +161 -0
- package/dist/cjs/runtime/datasources.js +44 -0
- package/dist/cjs/runtime/index.js +32 -0
- package/dist/cjs/runtime/plugin-registry.js +75 -0
- package/dist/cjs/runtime/template-variables.js +57 -0
- package/dist/cjs/runtime/time-series-queries.js +140 -0
- package/dist/cjs/test/index.js +28 -0
- package/dist/cjs/test/render.js +52 -0
- package/dist/cjs/test/setup-tests.js +20 -0
- package/dist/cjs/test/test-plugins/bert/index.js +77 -0
- package/dist/cjs/test/test-plugins/ernie/index.js +58 -0
- package/dist/cjs/test/test-plugins/index.js +77 -0
- package/dist/cjs/test-utils/index.js +28 -0
- package/dist/cjs/test-utils/mock-plugin-registry.js +68 -0
- package/dist/components/CalculationSelector/CalculationSelector.d.ts +8 -0
- package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -0
- package/dist/components/CalculationSelector/CalculationSelector.js +46 -0
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -0
- package/dist/components/CalculationSelector/CalculationSelector.test.d.ts +2 -0
- package/dist/components/CalculationSelector/CalculationSelector.test.d.ts.map +1 -0
- package/dist/components/CalculationSelector/CalculationSelector.test.js +58 -0
- package/dist/components/CalculationSelector/CalculationSelector.test.js.map +1 -0
- package/dist/components/CalculationSelector/index.d.ts +2 -0
- package/dist/components/CalculationSelector/index.d.ts.map +1 -0
- package/dist/components/CalculationSelector/index.js +15 -0
- package/dist/components/CalculationSelector/index.js.map +1 -0
- package/dist/components/DatasourceSelect.d.ts +16 -0
- package/dist/components/DatasourceSelect.d.ts.map +1 -0
- package/dist/components/DatasourceSelect.js +73 -0
- package/dist/components/DatasourceSelect.js.map +1 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +34 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +96 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.d.ts +2 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.d.ts.map +1 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js +160 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js.map +1 -0
- package/dist/components/OptionsEditorTabs/TabPanel.d.ts +9 -0
- package/dist/components/OptionsEditorTabs/TabPanel.d.ts.map +1 -0
- package/dist/components/OptionsEditorTabs/TabPanel.js +31 -0
- package/dist/components/OptionsEditorTabs/TabPanel.js.map +1 -0
- package/dist/components/OptionsEditorTabs/index.d.ts +2 -0
- package/dist/components/OptionsEditorTabs/index.d.ts.map +1 -0
- package/dist/components/OptionsEditorTabs/index.js +15 -0
- package/dist/components/OptionsEditorTabs/index.js.map +1 -0
- package/dist/components/PluginEditor/PluginEditor.d.ts +12 -0
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -0
- package/dist/components/PluginEditor/PluginEditor.js +68 -0
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -0
- package/dist/components/PluginEditor/PluginEditor.test.d.ts +2 -0
- package/dist/components/PluginEditor/PluginEditor.test.d.ts.map +1 -0
- package/dist/components/PluginEditor/PluginEditor.test.js +143 -0
- package/dist/components/PluginEditor/PluginEditor.test.js.map +1 -0
- package/dist/components/PluginEditor/index.d.ts +3 -0
- package/dist/components/PluginEditor/index.d.ts.map +1 -0
- package/dist/components/PluginEditor/index.js +16 -0
- package/dist/components/PluginEditor/index.js.map +1 -0
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +30 -0
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -0
- package/dist/components/PluginEditor/plugin-editor-api.js +100 -0
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -0
- package/dist/components/PluginKindSelect.d.ts +12 -0
- package/dist/components/PluginKindSelect.d.ts.map +1 -0
- package/dist/components/PluginKindSelect.js +38 -0
- package/dist/components/PluginKindSelect.js.map +1 -0
- package/dist/components/PluginKindSelect.test.d.ts +2 -0
- package/dist/components/PluginKindSelect.test.d.ts.map +1 -0
- package/dist/components/PluginKindSelect.test.js +79 -0
- package/dist/components/PluginKindSelect.test.js.map +1 -0
- package/dist/components/PluginRegistry/PluginRegistry.d.ts +13 -0
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -0
- package/dist/components/PluginRegistry/PluginRegistry.js +82 -0
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -0
- package/dist/components/PluginRegistry/PluginRegistry.test.d.ts +2 -0
- package/dist/components/PluginRegistry/PluginRegistry.test.d.ts.map +1 -0
- package/dist/components/PluginRegistry/PluginRegistry.test.js +137 -0
- package/dist/components/PluginRegistry/PluginRegistry.test.js.map +1 -0
- package/dist/components/PluginRegistry/index.d.ts +2 -0
- package/dist/components/PluginRegistry/index.d.ts.map +1 -0
- package/dist/components/PluginRegistry/index.js +15 -0
- package/dist/components/PluginRegistry/index.js.map +1 -0
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +14 -0
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -0
- package/dist/components/PluginRegistry/plugin-indexes.js +70 -0
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -0
- package/dist/components/PluginSpecEditor.d.ts +9 -0
- package/dist/components/PluginSpecEditor.d.ts.map +1 -0
- package/dist/components/PluginSpecEditor.js +37 -0
- package/dist/components/PluginSpecEditor.js.map +1 -0
- package/dist/components/PluginSpecEditor.test.d.ts +2 -0
- package/dist/components/PluginSpecEditor.test.d.ts.map +1 -0
- package/dist/components/PluginSpecEditor.test.js +63 -0
- package/dist/components/PluginSpecEditor.test.js.map +1 -0
- package/dist/components/TimeSeriesQueryEditor.d.ts +14 -0
- package/dist/components/TimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/components/TimeSeriesQueryEditor.js +38 -0
- package/dist/components/TimeSeriesQueryEditor.js.map +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +22 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/model/calculations.d.ts +21 -0
- package/dist/model/calculations.d.ts.map +1 -0
- package/dist/model/calculations.js +64 -0
- package/dist/model/calculations.js.map +1 -0
- package/dist/model/datasource.d.ts +12 -0
- package/dist/model/datasource.d.ts.map +1 -0
- package/dist/model/datasource.js +15 -0
- package/dist/model/datasource.js.map +1 -0
- package/dist/model/index.d.ts +9 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +22 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/panels.d.ts +20 -0
- package/dist/model/panels.d.ts.map +1 -0
- package/dist/model/panels.js +15 -0
- package/dist/model/panels.js.map +1 -0
- package/dist/model/plugin-base.d.ts +22 -0
- package/dist/model/plugin-base.d.ts.map +1 -0
- package/dist/model/plugin-base.js +15 -0
- package/dist/model/plugin-base.js.map +1 -0
- package/dist/model/plugin-loading.d.ts +22 -0
- package/dist/model/plugin-loading.d.ts.map +1 -0
- package/dist/model/plugin-loading.js +35 -0
- package/dist/model/plugin-loading.js.map +1 -0
- package/dist/model/plugins.d.ts +54 -0
- package/dist/model/plugins.d.ts.map +1 -0
- package/dist/model/plugins.js +15 -0
- package/dist/model/plugins.js.map +1 -0
- package/dist/model/time-series-queries.d.ts +42 -0
- package/dist/model/time-series-queries.d.ts.map +1 -0
- package/dist/model/time-series-queries.js +15 -0
- package/dist/model/time-series-queries.js.map +1 -0
- package/dist/model/variables.d.ts +35 -0
- package/dist/model/variables.d.ts.map +1 -0
- package/dist/model/variables.js +15 -0
- package/dist/model/variables.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +25 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +69 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts +3 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/index.js +16 -0
- package/dist/runtime/TimeRangeProvider/index.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/query-params.d.ts +25 -0
- package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/query-params.js +153 -0
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -0
- package/dist/runtime/datasources.d.ts +25 -0
- package/dist/runtime/datasources.d.ts.map +1 -0
- package/dist/runtime/datasources.js +34 -0
- package/dist/runtime/datasources.js.map +1 -0
- package/dist/runtime/index.d.ts +6 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +19 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/plugin-registry.d.ts +32 -0
- package/dist/runtime/plugin-registry.d.ts.map +1 -0
- package/dist/runtime/plugin-registry.js +69 -0
- package/dist/runtime/plugin-registry.js.map +1 -0
- package/dist/runtime/template-variables.d.ts +17 -0
- package/dist/runtime/template-variables.d.ts.map +1 -0
- package/dist/runtime/template-variables.js +44 -0
- package/dist/runtime/template-variables.js.map +1 -0
- package/dist/runtime/time-series-queries.d.ts +13 -0
- package/dist/runtime/time-series-queries.d.ts.map +1 -0
- package/dist/runtime/time-series-queries.js +132 -0
- package/dist/runtime/time-series-queries.js.map +1 -0
- package/dist/test/index.d.ts +2 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +15 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/render.d.ts +13 -0
- package/dist/test/render.d.ts.map +1 -0
- package/dist/test/render.js +49 -0
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.d.ts +2 -0
- package/dist/test/setup-tests.d.ts.map +1 -0
- package/dist/test/setup-tests.js +18 -0
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/test/test-plugins/bert/index.d.ts +8 -0
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -0
- package/dist/test/test-plugins/bert/index.js +66 -0
- package/dist/test/test-plugins/bert/index.js.map +1 -0
- package/dist/test/test-plugins/ernie/index.d.ts +5 -0
- package/dist/test/test-plugins/ernie/index.d.ts.map +1 -0
- package/dist/test/test-plugins/ernie/index.js +53 -0
- package/dist/test/test-plugins/ernie/index.js.map +1 -0
- package/dist/test/test-plugins/index.d.ts +6 -0
- package/dist/test/test-plugins/index.d.ts.map +1 -0
- package/dist/test/test-plugins/index.js +29 -0
- package/dist/test/test-plugins/index.js.map +1 -0
- package/dist/test-utils/index.d.ts +2 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/test-utils/index.js +15 -0
- package/dist/test-utils/index.js.map +1 -0
- package/dist/test-utils/mock-plugin-registry.d.ts +20 -0
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -0
- package/dist/test-utils/mock-plugin-registry.js +62 -0
- package/dist/test-utils/mock-plugin-registry.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Copyright 2022 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
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
|
|
19
|
+
const _react = require("@testing-library/react");
|
|
20
|
+
const _test = require("../test");
|
|
21
|
+
const _pluginKindSelect = require("./PluginKindSelect");
|
|
22
|
+
function _interopRequireDefault(obj) {
|
|
23
|
+
return obj && obj.__esModule ? obj : {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
describe('PluginKindSelect', ()=>{
|
|
28
|
+
const renderComponent = (props)=>{
|
|
29
|
+
return (0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginKindSelect.PluginKindSelect, {
|
|
30
|
+
...props
|
|
31
|
+
}));
|
|
32
|
+
};
|
|
33
|
+
// Opens the select and waits for loading to finish (i.e. options to appear)
|
|
34
|
+
const openSelect = async ()=>{
|
|
35
|
+
const select = _react.screen.getByRole('button');
|
|
36
|
+
_userEvent.default.click(select);
|
|
37
|
+
const options = await _react.screen.findAllByRole('option');
|
|
38
|
+
return options;
|
|
39
|
+
};
|
|
40
|
+
it('displays the list of plugins for a plugin type', async ()=>{
|
|
41
|
+
renderComponent({
|
|
42
|
+
pluginType: 'Panel',
|
|
43
|
+
value: ''
|
|
44
|
+
});
|
|
45
|
+
// Open the select and verify the list of options from the test plugin data
|
|
46
|
+
const options = await openSelect();
|
|
47
|
+
expect(options).toHaveLength(2);
|
|
48
|
+
let option = _react.screen.queryByRole('option', {
|
|
49
|
+
name: 'Bert Panel 1'
|
|
50
|
+
});
|
|
51
|
+
expect(option).toBeInTheDocument();
|
|
52
|
+
option = _react.screen.queryByRole('option', {
|
|
53
|
+
name: 'Bert Panel 2'
|
|
54
|
+
});
|
|
55
|
+
expect(option).toBeInTheDocument();
|
|
56
|
+
});
|
|
57
|
+
it('shows the correct selected value', async ()=>{
|
|
58
|
+
renderComponent({
|
|
59
|
+
pluginType: 'Variable',
|
|
60
|
+
value: 'ErnieVariable'
|
|
61
|
+
});
|
|
62
|
+
// Use findByRole to wait for loading to finish and selected value to appear
|
|
63
|
+
const select = await _react.screen.findByRole('button', {
|
|
64
|
+
name: 'Ernie Variable'
|
|
65
|
+
});
|
|
66
|
+
expect(select).toBeInTheDocument();
|
|
67
|
+
});
|
|
68
|
+
it('can select new value', async ()=>{
|
|
69
|
+
let onChangeValue = undefined;
|
|
70
|
+
const onChange = jest.fn((e)=>{
|
|
71
|
+
onChangeValue = e.target.value;
|
|
72
|
+
});
|
|
73
|
+
renderComponent({
|
|
74
|
+
pluginType: 'Variable',
|
|
75
|
+
value: 'ErnieVariable',
|
|
76
|
+
onChange
|
|
77
|
+
});
|
|
78
|
+
await openSelect();
|
|
79
|
+
const newOption = _react.screen.getByRole('option', {
|
|
80
|
+
name: 'Bert Variable'
|
|
81
|
+
});
|
|
82
|
+
_userEvent.default.click(newOption);
|
|
83
|
+
expect(onChange).toHaveBeenCalledTimes(1);
|
|
84
|
+
expect(onChangeValue).toBe('BertVariable');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Copyright 2022 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
|
+
Object.defineProperty(exports, "PluginRegistry", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>PluginRegistry
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _core = require("@perses-dev/core");
|
|
23
|
+
const _react = require("react");
|
|
24
|
+
const _runtime = require("../../runtime");
|
|
25
|
+
const _pluginIndexes = require("./plugin-indexes");
|
|
26
|
+
function PluginRegistry(props) {
|
|
27
|
+
const { pluginLoader: { getInstalledPlugins , importPluginModule } , children , defaultPluginKinds , } = props;
|
|
28
|
+
const getPluginIndexes = (0, _pluginIndexes.usePluginIndexes)(getInstalledPlugins);
|
|
29
|
+
// De-dupe calls to import plugin modules
|
|
30
|
+
const importCache = (0, _react.useRef)(new Map());
|
|
31
|
+
// Do useEvent here since this accesses the importPluginModule prop and we want a stable reference to it for the
|
|
32
|
+
// callback below
|
|
33
|
+
const loadPluginModule = (0, _core.useEvent)((resource)=>{
|
|
34
|
+
let request = importCache.current.get(resource);
|
|
35
|
+
if (request === undefined) {
|
|
36
|
+
request = importPluginModule(resource);
|
|
37
|
+
importCache.current.set(resource, request);
|
|
38
|
+
// Remove failed requests from the cache so they can potentially be retried
|
|
39
|
+
request.catch(()=>importCache.current.delete(resource));
|
|
40
|
+
}
|
|
41
|
+
return request;
|
|
42
|
+
});
|
|
43
|
+
const getPlugin = (0, _react.useCallback)(async (pluginType, kind)=>{
|
|
44
|
+
// Get the indexes of the installed plugins
|
|
45
|
+
const pluginIndexes = await getPluginIndexes();
|
|
46
|
+
// Figure out what module the plugin is in by looking in the index
|
|
47
|
+
const typeAndKindKey = (0, _pluginIndexes.getTypeAndKindKey)(pluginType, kind);
|
|
48
|
+
const resource = pluginIndexes.pluginResourcesByTypeAndKind.get(typeAndKindKey);
|
|
49
|
+
if (resource === undefined) {
|
|
50
|
+
throw new Error(`A ${pluginType} plugin for kind '${kind}' is not installed`);
|
|
51
|
+
}
|
|
52
|
+
// Treat the plugin module as a bunch of named exports that have plugins
|
|
53
|
+
const pluginModule = await loadPluginModule(resource);
|
|
54
|
+
// We currently assume that plugin modules will have named exports that match the kinds they handle
|
|
55
|
+
const plugin = pluginModule[kind];
|
|
56
|
+
if (plugin === undefined) {
|
|
57
|
+
throw new Error(`The ${pluginType} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`);
|
|
58
|
+
}
|
|
59
|
+
return plugin;
|
|
60
|
+
}, [
|
|
61
|
+
getPluginIndexes,
|
|
62
|
+
loadPluginModule
|
|
63
|
+
]);
|
|
64
|
+
const listPluginMetadata = (0, _react.useCallback)(async (pluginType)=>{
|
|
65
|
+
const pluginIndexes = await getPluginIndexes();
|
|
66
|
+
var ref;
|
|
67
|
+
return (ref = pluginIndexes.pluginMetadataByType.get(pluginType)) !== null && ref !== void 0 ? ref : [];
|
|
68
|
+
}, [
|
|
69
|
+
getPluginIndexes
|
|
70
|
+
]);
|
|
71
|
+
// Create the registry's context value and render
|
|
72
|
+
const context = (0, _react.useMemo)(()=>({
|
|
73
|
+
getPlugin,
|
|
74
|
+
listPluginMetadata,
|
|
75
|
+
defaultPluginKinds
|
|
76
|
+
}), [
|
|
77
|
+
getPlugin,
|
|
78
|
+
listPluginMetadata,
|
|
79
|
+
defaultPluginKinds
|
|
80
|
+
]);
|
|
81
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_runtime.PluginRegistryContext.Provider, {
|
|
82
|
+
value: context,
|
|
83
|
+
children: children
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Copyright 2022 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
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
|
|
19
|
+
const _react1 = require("@testing-library/react");
|
|
20
|
+
const _runtime = require("../../runtime");
|
|
21
|
+
const _test = require("../../test");
|
|
22
|
+
function _interopRequireDefault(obj) {
|
|
23
|
+
return obj && obj.__esModule ? obj : {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
describe('PluginRegistry', ()=>{
|
|
28
|
+
const renderPluginRegistry = (children)=>{
|
|
29
|
+
(0, _test.renderWithContext)(children);
|
|
30
|
+
};
|
|
31
|
+
it('can load a plugin that exists', async ()=>{
|
|
32
|
+
renderPluginRegistry(/*#__PURE__*/ (0, _jsxRuntime.jsx)(PluginConsumer, {
|
|
33
|
+
pluginType: "Variable",
|
|
34
|
+
kind: "ErnieVariable"
|
|
35
|
+
}));
|
|
36
|
+
const hasPlugin = await _react1.screen.findByText('Has plugin: true', undefined, {
|
|
37
|
+
timeout: 3000
|
|
38
|
+
});
|
|
39
|
+
expect(hasPlugin).toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
it('errors when plugin is not installed', async ()=>{
|
|
42
|
+
// This plugin is not in the test metadata at all
|
|
43
|
+
renderPluginRegistry(/*#__PURE__*/ (0, _jsxRuntime.jsx)(PluginConsumer, {
|
|
44
|
+
pluginType: "TimeSeriesQuery",
|
|
45
|
+
kind: "NotInstalled"
|
|
46
|
+
}));
|
|
47
|
+
const error = await _react1.screen.findByText(/error:/i);
|
|
48
|
+
expect(error).toBeInTheDocument();
|
|
49
|
+
expect(error).toHaveTextContent(/not installed/i);
|
|
50
|
+
});
|
|
51
|
+
it('errors when plugin is missing from the module', async ()=>{
|
|
52
|
+
// This plugin is in the test metadata, but the code is missing from the module
|
|
53
|
+
renderPluginRegistry(/*#__PURE__*/ (0, _jsxRuntime.jsx)(PluginConsumer, {
|
|
54
|
+
pluginType: "Variable",
|
|
55
|
+
kind: "MissingErnieVariable"
|
|
56
|
+
}));
|
|
57
|
+
const error = await _react1.screen.findByText(/error:/i);
|
|
58
|
+
expect(error).toBeInTheDocument();
|
|
59
|
+
expect(error).toHaveTextContent(/missing/i);
|
|
60
|
+
});
|
|
61
|
+
it('lists metadata for plugin metadata that exists', async ()=>{
|
|
62
|
+
// There should be 3 variable plugins across both test modules
|
|
63
|
+
renderPluginRegistry(/*#__PURE__*/ (0, _jsxRuntime.jsx)(MetadataConsumer, {
|
|
64
|
+
pluginType: "Variable"
|
|
65
|
+
}));
|
|
66
|
+
const table = await _react1.screen.findByRole('table');
|
|
67
|
+
expect(table).toBeInTheDocument();
|
|
68
|
+
const rows = _react1.screen.getAllByRole('row');
|
|
69
|
+
expect(rows).toHaveLength(3);
|
|
70
|
+
});
|
|
71
|
+
it('lists metadata for plugin types with no plugins available', async ()=>{
|
|
72
|
+
// There are no TimeSeriesQuery plugins in any of the test modules
|
|
73
|
+
renderPluginRegistry(/*#__PURE__*/ (0, _jsxRuntime.jsx)(MetadataConsumer, {
|
|
74
|
+
pluginType: "TimeSeriesQuery"
|
|
75
|
+
}));
|
|
76
|
+
const table = await _react1.screen.findByRole('table');
|
|
77
|
+
expect(table).toBeInTheDocument();
|
|
78
|
+
const rows = _react1.screen.queryAllByRole('row');
|
|
79
|
+
expect(rows).toHaveLength(0);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
// A helper component for testing the PluginRegistry by calling usePlugin to load a plugin
|
|
83
|
+
const PluginConsumer = (props)=>{
|
|
84
|
+
const { data: plugin , isLoading , error } = (0, _runtime.usePlugin)(props.pluginType, props.kind);
|
|
85
|
+
if (error) {
|
|
86
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
87
|
+
children: [
|
|
88
|
+
"Error: ",
|
|
89
|
+
error.message
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (isLoading) {
|
|
94
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
95
|
+
children: "Loading"
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
99
|
+
children: [
|
|
100
|
+
"Has plugin: ",
|
|
101
|
+
(plugin !== undefined).toString()
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
// A helper component for testing the PluginRegistry metadata APIs by calling useListPluginMetadata
|
|
106
|
+
const MetadataConsumer = (props)=>{
|
|
107
|
+
const { data: pluginMetadata , isLoading , error } = (0, _runtime.useListPluginMetadata)(props.pluginType);
|
|
108
|
+
if (error) {
|
|
109
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
110
|
+
children: [
|
|
111
|
+
"Error: ",
|
|
112
|
+
error.message
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (isLoading) {
|
|
117
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
118
|
+
children: "Loading"
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (pluginMetadata === undefined) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("table", {
|
|
125
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)("tbody", {
|
|
126
|
+
children: pluginMetadata.map((item)=>/*#__PURE__*/ (0, _jsxRuntime.jsxs)("tr", {
|
|
127
|
+
children: [
|
|
128
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("td", {
|
|
129
|
+
children: item.pluginType
|
|
130
|
+
}),
|
|
131
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("td", {
|
|
132
|
+
children: item.kind
|
|
133
|
+
}),
|
|
134
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("td", {
|
|
135
|
+
children: item.display.name
|
|
136
|
+
}),
|
|
137
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("td", {
|
|
138
|
+
children: item.display.description
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
}, item.kind))
|
|
142
|
+
})
|
|
143
|
+
});
|
|
144
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2022 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("./PluginRegistry"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright 2022 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
|
+
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
|
+
usePluginIndexes: ()=>usePluginIndexes,
|
|
25
|
+
getTypeAndKindKey: ()=>getTypeAndKindKey
|
|
26
|
+
});
|
|
27
|
+
const _core = require("@perses-dev/core");
|
|
28
|
+
const _react = require("react");
|
|
29
|
+
function usePluginIndexes(getInstalledPlugins) {
|
|
30
|
+
// Creates indexes from the installed plugins data (does useEvent because this accesses the getInstalledPlugins prop
|
|
31
|
+
// and we want a stable reference for the callback below)
|
|
32
|
+
const createPluginIndexes = (0, _core.useEvent)(async ()=>{
|
|
33
|
+
const installedPlugins = await getInstalledPlugins();
|
|
34
|
+
// Create the two indexes from the installed plugins
|
|
35
|
+
const pluginResourcesByTypeAndKind = new Map();
|
|
36
|
+
const pluginMetadataByType = new Map();
|
|
37
|
+
for (const resource of installedPlugins){
|
|
38
|
+
for (const pluginMetadata of resource.spec.plugins){
|
|
39
|
+
const { pluginType , kind } = pluginMetadata;
|
|
40
|
+
// Index the plugin by type and kind to point at the module that contains it
|
|
41
|
+
const key = getTypeAndKindKey(pluginType, kind);
|
|
42
|
+
if (pluginResourcesByTypeAndKind.has(key)) {
|
|
43
|
+
console.warn(`Got more than one ${pluginType} plugin for kind ${kind}`);
|
|
44
|
+
}
|
|
45
|
+
pluginResourcesByTypeAndKind.set(key, resource);
|
|
46
|
+
// Index the metadata by plugin type
|
|
47
|
+
let list = pluginMetadataByType.get(pluginType);
|
|
48
|
+
if (list === undefined) {
|
|
49
|
+
list = [];
|
|
50
|
+
pluginMetadataByType.set(pluginType, list);
|
|
51
|
+
}
|
|
52
|
+
list.push(pluginMetadata);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
pluginResourcesByTypeAndKind,
|
|
57
|
+
pluginMetadataByType
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
// De-dupe creating plugin indexes (i.e. requests to get installed plugins)
|
|
61
|
+
const pluginIndexesCache = (0, _react.useRef)(undefined);
|
|
62
|
+
const getPluginIndexes = (0, _react.useCallback)(()=>{
|
|
63
|
+
let request = pluginIndexesCache.current;
|
|
64
|
+
if (request === undefined) {
|
|
65
|
+
request = createPluginIndexes();
|
|
66
|
+
pluginIndexesCache.current = request;
|
|
67
|
+
// Remove failed requests from the cache so they can potentially be retried
|
|
68
|
+
request.catch(()=>pluginIndexesCache.current === undefined);
|
|
69
|
+
}
|
|
70
|
+
return request;
|
|
71
|
+
}, [
|
|
72
|
+
createPluginIndexes
|
|
73
|
+
]);
|
|
74
|
+
return getPluginIndexes;
|
|
75
|
+
}
|
|
76
|
+
function getTypeAndKindKey(pluginType, kind) {
|
|
77
|
+
return `${pluginType}:${kind}`;
|
|
78
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Copyright 2022 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
|
+
Object.defineProperty(exports, "PluginSpecEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>PluginSpecEditor
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _components = require("@perses-dev/components");
|
|
23
|
+
const _runtime = require("../runtime");
|
|
24
|
+
function PluginSpecEditor(props) {
|
|
25
|
+
const { pluginType , pluginKind , ...others } = props;
|
|
26
|
+
const { data: plugin , isLoading , error } = (0, _runtime.usePlugin)(pluginType, pluginKind);
|
|
27
|
+
if (error) {
|
|
28
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorAlert, {
|
|
29
|
+
error: error
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// TODO: Proper loading indicator
|
|
33
|
+
if (isLoading) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (plugin === undefined) {
|
|
37
|
+
throw new Error(`Missing OptionsEditorComponent for ${pluginType} plugin with kind '${pluginKind}'`);
|
|
38
|
+
}
|
|
39
|
+
const { OptionsEditorComponent } = plugin;
|
|
40
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(OptionsEditorComponent, {
|
|
41
|
+
...others
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Copyright 2022 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
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
|
|
19
|
+
const _react = require("@testing-library/react");
|
|
20
|
+
const _test = require("../test");
|
|
21
|
+
const _pluginSpecEditor = require("./PluginSpecEditor");
|
|
22
|
+
function _interopRequireDefault(obj) {
|
|
23
|
+
return obj && obj.__esModule ? obj : {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
describe('PluginSpecEditor', ()=>{
|
|
28
|
+
const renderComponent = (props)=>{
|
|
29
|
+
(0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSpecEditor.PluginSpecEditor, {
|
|
30
|
+
...props
|
|
31
|
+
}));
|
|
32
|
+
};
|
|
33
|
+
it('shows the options editor component for a plugin', async ()=>{
|
|
34
|
+
renderComponent({
|
|
35
|
+
pluginType: 'Panel',
|
|
36
|
+
pluginKind: 'BertPanel1',
|
|
37
|
+
value: {},
|
|
38
|
+
onChange: jest.fn()
|
|
39
|
+
});
|
|
40
|
+
const editor = await _react.screen.findByLabelText('BertPanel1 editor');
|
|
41
|
+
expect(editor).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
it('propagates value changes', async ()=>{
|
|
44
|
+
const onChange = jest.fn();
|
|
45
|
+
renderComponent({
|
|
46
|
+
pluginType: 'Panel',
|
|
47
|
+
pluginKind: 'BertPanel1',
|
|
48
|
+
value: {
|
|
49
|
+
option1: 'Option1Value'
|
|
50
|
+
},
|
|
51
|
+
onChange
|
|
52
|
+
});
|
|
53
|
+
const editor = await _react.screen.findByLabelText('BertPanel1 editor');
|
|
54
|
+
expect(editor).toHaveValue('Option1Value');
|
|
55
|
+
_userEvent.default.clear(editor);
|
|
56
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
57
|
+
option1: ''
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
it('shows an error if plugin fails to load', async ()=>{
|
|
61
|
+
renderComponent({
|
|
62
|
+
pluginType: 'Variable',
|
|
63
|
+
pluginKind: 'DoesNotExist',
|
|
64
|
+
value: {},
|
|
65
|
+
onChange: jest.fn()
|
|
66
|
+
});
|
|
67
|
+
const errorAlert = await _react.screen.findByRole('alert');
|
|
68
|
+
expect(errorAlert).toHaveTextContent(/doesnotexist/i);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright 2022 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
|
+
Object.defineProperty(exports, "TimeSeriesQueryEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>TimeSeriesQueryEditor
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _immer = require("immer");
|
|
24
|
+
const _pluginEditor = require("./PluginEditor");
|
|
25
|
+
function TimeSeriesQueryEditor(props) {
|
|
26
|
+
const { value , onChange , ...others } = props;
|
|
27
|
+
const { spec: { plugin } , } = value;
|
|
28
|
+
const handlePluginChange = (next)=>{
|
|
29
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
30
|
+
draft.spec.plugin = next;
|
|
31
|
+
}));
|
|
32
|
+
};
|
|
33
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
34
|
+
...others,
|
|
35
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginEditor.PluginEditor, {
|
|
36
|
+
pluginType: "TimeSeriesQuery",
|
|
37
|
+
pluginKindLabel: "Query Type",
|
|
38
|
+
value: plugin,
|
|
39
|
+
onChange: handlePluginChange
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright 2022 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("./CalculationSelector"), exports);
|
|
18
|
+
_exportStar(require("./DatasourceSelect"), exports);
|
|
19
|
+
_exportStar(require("./OptionsEditorTabs"), exports);
|
|
20
|
+
_exportStar(require("./PluginEditor"), exports);
|
|
21
|
+
_exportStar(require("./PluginKindSelect"), exports);
|
|
22
|
+
_exportStar(require("./PluginRegistry"), exports);
|
|
23
|
+
_exportStar(require("./PluginSpecEditor"), exports);
|
|
24
|
+
_exportStar(require("./TimeSeriesQueryEditor"), exports);
|
|
25
|
+
function _exportStar(from, to) {
|
|
26
|
+
Object.keys(from).forEach(function(k) {
|
|
27
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function() {
|
|
30
|
+
return from[k];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
return from;
|
|
35
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2022 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("./components"), exports);
|
|
18
|
+
_exportStar(require("./model"), exports);
|
|
19
|
+
_exportStar(require("./runtime"), exports);
|
|
20
|
+
_exportStar(require("./test-utils"), exports);
|
|
21
|
+
function _exportStar(from, to) {
|
|
22
|
+
Object.keys(from).forEach(function(k) {
|
|
23
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return from[k];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
return from;
|
|
31
|
+
}
|