@perses-dev/plugin-system 0.21.1 → 0.23.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/CalculationSelector/CalculationSelector.js +1 -1
- package/dist/cjs/components/CalculationSelector/CalculationSelector.test.js +1 -1
- package/dist/cjs/components/CalculationSelector/index.js +1 -1
- package/dist/cjs/components/DatasourceSelect.js +1 -1
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +5 -48
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.test.js +26 -86
- package/dist/cjs/components/OptionsEditorTabs/TabPanel.js +1 -1
- package/dist/cjs/components/OptionsEditorTabs/index.js +1 -1
- package/dist/cjs/components/PluginEditor/PluginEditor.js +1 -1
- package/dist/cjs/components/PluginEditor/PluginEditor.test.js +1 -1
- package/dist/cjs/components/PluginEditor/index.js +1 -1
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +1 -1
- package/dist/cjs/components/PluginKindSelect.js +1 -1
- package/dist/cjs/components/PluginKindSelect.test.js +1 -1
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
- package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +1 -1
- package/dist/cjs/components/PluginRegistry/index.js +1 -1
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +1 -1
- package/dist/cjs/components/PluginSpecEditor.js +39 -5
- package/dist/cjs/components/PluginSpecEditor.test.js +31 -9
- package/dist/cjs/components/TimeSeriesQueryEditor.js +1 -1
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/model/calculations.js +1 -1
- package/dist/cjs/model/datasource.js +1 -1
- package/dist/cjs/model/index.js +1 -1
- package/dist/cjs/model/panels.js +7 -1
- package/dist/cjs/model/plugin-base.js +1 -1
- package/dist/cjs/model/plugin-loading.js +1 -1
- package/dist/cjs/model/plugins.js +1 -1
- package/dist/cjs/model/time-series-queries.js +1 -1
- package/dist/cjs/model/variables.js +1 -1
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
- package/dist/cjs/runtime/TimeRangeProvider/index.js +1 -1
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +1 -1
- package/dist/cjs/runtime/datasources.js +10 -2
- package/dist/cjs/runtime/index.js +1 -1
- package/dist/cjs/runtime/plugin-registry.js +1 -1
- package/dist/cjs/runtime/template-variables.js +1 -1
- package/dist/cjs/runtime/time-series-queries.js +1 -1
- package/dist/cjs/test/index.js +1 -1
- package/dist/cjs/test/render.js +1 -1
- package/dist/cjs/test/setup-tests.js +1 -1
- package/dist/cjs/test/test-plugins/bert/index.js +33 -20
- package/dist/cjs/test/test-plugins/ernie/index.js +1 -1
- package/dist/cjs/test/test-plugins/index.js +1 -1
- package/dist/cjs/test-utils/index.js +1 -1
- package/dist/cjs/test-utils/mock-plugin-registry.js +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.test.js +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.test.js.map +1 -1
- package/dist/components/CalculationSelector/index.js +1 -1
- package/dist/components/CalculationSelector/index.js.map +1 -1
- package/dist/components/DatasourceSelect.js +1 -1
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -24
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +5 -48
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js +26 -86
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js.map +1 -1
- package/dist/components/OptionsEditorTabs/TabPanel.js +1 -1
- package/dist/components/OptionsEditorTabs/TabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabs/index.js +1 -1
- package/dist/components/OptionsEditorTabs/index.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +1 -1
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.test.js +1 -1
- package/dist/components/PluginEditor/PluginEditor.test.js.map +1 -1
- package/dist/components/PluginEditor/index.js +1 -1
- package/dist/components/PluginEditor/index.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect.js +1 -1
- package/dist/components/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginKindSelect.test.js +1 -1
- package/dist/components/PluginKindSelect.test.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.test.js +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.test.js.map +1 -1
- package/dist/components/PluginRegistry/index.js +1 -1
- package/dist/components/PluginRegistry/index.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor.js +40 -6
- package/dist/components/PluginSpecEditor.js.map +1 -1
- package/dist/components/PluginSpecEditor.test.js +31 -9
- package/dist/components/PluginSpecEditor.test.js.map +1 -1
- package/dist/components/TimeSeriesQueryEditor.js +1 -1
- package/dist/components/TimeSeriesQueryEditor.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/calculations.js +1 -1
- package/dist/model/calculations.js.map +1 -1
- package/dist/model/datasource.js +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/index.js +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/panels.d.ts +14 -2
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js +2 -2
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.d.ts +1 -1
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugin-loading.js +1 -1
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.js +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/time-series-queries.js +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/variables.js +1 -1
- package/dist/model/variables.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/index.js +1 -1
- package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/datasources.d.ts +4 -0
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js +10 -1
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/plugin-registry.js +1 -1
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/template-variables.js +1 -1
- package/dist/runtime/template-variables.js.map +1 -1
- package/dist/runtime/time-series-queries.js +1 -1
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/test/index.js +1 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.js +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js +33 -20
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +1 -1
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test/test-plugins/index.js +1 -1
- package/dist/test/test-plugins/index.js.map +1 -1
- package/dist/test-utils/index.js +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +1 -1
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -22,54 +22,11 @@ const _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _react = require("react");
|
|
24
24
|
const _tabPanel = require("./TabPanel");
|
|
25
|
-
// Configuration of the order and labeling for tabs across plugins to enforce a
|
|
26
|
-
// consistent UX.
|
|
27
|
-
const TAB_CONFIG = [
|
|
28
|
-
{
|
|
29
|
-
id: 'query',
|
|
30
|
-
label: 'Query'
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
id: 'settings',
|
|
34
|
-
label: 'Settings'
|
|
35
|
-
},
|
|
36
|
-
// Custom tabs go between the visual common tabs and the raw JSON editor.
|
|
37
|
-
'other',
|
|
38
|
-
{
|
|
39
|
-
id: 'json',
|
|
40
|
-
label: 'JSON'
|
|
41
|
-
}
|
|
42
|
-
];
|
|
43
25
|
const OptionsEditorTabs = ({ tabs })=>{
|
|
44
26
|
const [activeTab, setActiveTab] = (0, _react.useState)(0);
|
|
45
27
|
const handleChange = (_, newValue)=>{
|
|
46
28
|
setActiveTab(newValue);
|
|
47
29
|
};
|
|
48
|
-
// Normalize the common tabs that are managed via constants in this file
|
|
49
|
-
// and custom tabs that bring their own config into a consistent shape for
|
|
50
|
-
// rendering.
|
|
51
|
-
const normalizedTabs = TAB_CONFIG.reduce((combinedTabs, tabConfig)=>{
|
|
52
|
-
// Custom tabs
|
|
53
|
-
if (tabConfig === 'other') {
|
|
54
|
-
const otherTabs = (tabs === null || tabs === void 0 ? void 0 : tabs.other) || [];
|
|
55
|
-
return [
|
|
56
|
-
...combinedTabs,
|
|
57
|
-
...otherTabs
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
// Common tabs
|
|
61
|
-
const commonTab = tabs[tabConfig.id];
|
|
62
|
-
if (commonTab) {
|
|
63
|
-
return [
|
|
64
|
-
...combinedTabs,
|
|
65
|
-
{
|
|
66
|
-
...tabConfig,
|
|
67
|
-
...commonTab
|
|
68
|
-
}
|
|
69
|
-
];
|
|
70
|
-
}
|
|
71
|
-
return combinedTabs;
|
|
72
|
-
}, []);
|
|
73
30
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
74
31
|
children: [
|
|
75
32
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
@@ -81,21 +38,21 @@ const OptionsEditorTabs = ({ tabs })=>{
|
|
|
81
38
|
value: activeTab,
|
|
82
39
|
onChange: handleChange,
|
|
83
40
|
"aria-label": "Panel configuration tabs",
|
|
84
|
-
children:
|
|
41
|
+
children: tabs.map(({ label }, i)=>{
|
|
85
42
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Tab, {
|
|
86
43
|
label: label,
|
|
87
44
|
id: `options-editor-tab-${i}`,
|
|
88
45
|
"aria-controls": `options-editor-tabpanel-${i}`
|
|
89
|
-
},
|
|
46
|
+
}, label);
|
|
90
47
|
})
|
|
91
48
|
})
|
|
92
49
|
}),
|
|
93
|
-
|
|
50
|
+
tabs.map(({ label , content }, i)=>{
|
|
94
51
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tabPanel.TabPanel, {
|
|
95
52
|
value: activeTab,
|
|
96
53
|
index: i,
|
|
97
54
|
children: content
|
|
98
|
-
},
|
|
55
|
+
}, label);
|
|
99
56
|
})
|
|
100
57
|
]
|
|
101
58
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -24,46 +24,32 @@ function _interopRequireDefault(obj) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
describe('OptionsEditorTabs', ()=>{
|
|
27
|
+
const mockTabs = [
|
|
28
|
+
{
|
|
29
|
+
label: 'Query',
|
|
30
|
+
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
31
|
+
children: "Edit query configuration"
|
|
32
|
+
})
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: 'Settings',
|
|
36
|
+
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
37
|
+
children: "Edit settings configuration"
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'JSON',
|
|
42
|
+
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
43
|
+
children: "JSON editor"
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
];
|
|
27
47
|
const renderTabs = (otherTabs)=>{
|
|
48
|
+
const tabs = otherTabs !== null && otherTabs !== void 0 ? otherTabs : mockTabs;
|
|
28
49
|
(0, _react.render)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorTabs.OptionsEditorTabs, {
|
|
29
|
-
tabs:
|
|
30
|
-
query: {
|
|
31
|
-
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
32
|
-
children: "Edit query configuration"
|
|
33
|
-
})
|
|
34
|
-
},
|
|
35
|
-
settings: {
|
|
36
|
-
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
37
|
-
children: "Edit settings configuration"
|
|
38
|
-
})
|
|
39
|
-
},
|
|
40
|
-
json: {
|
|
41
|
-
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
42
|
-
children: "JSON editor"
|
|
43
|
-
})
|
|
44
|
-
},
|
|
45
|
-
other: otherTabs
|
|
46
|
-
}
|
|
50
|
+
tabs: tabs
|
|
47
51
|
}));
|
|
48
52
|
};
|
|
49
|
-
const renderCustomTabs = ()=>{
|
|
50
|
-
renderTabs([
|
|
51
|
-
{
|
|
52
|
-
id: 'tableCols',
|
|
53
|
-
label: 'Table columns',
|
|
54
|
-
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
55
|
-
children: "custom table column"
|
|
56
|
-
})
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: 'tableOpts',
|
|
60
|
-
label: 'Table options',
|
|
61
|
-
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
62
|
-
children: "custom table options"
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
]);
|
|
66
|
-
};
|
|
67
53
|
it('renders all specified tabs in a tab list', ()=>{
|
|
68
54
|
renderTabs();
|
|
69
55
|
const tabList = _react.screen.getByRole('tablist');
|
|
@@ -109,59 +95,13 @@ describe('OptionsEditorTabs', ()=>{
|
|
|
109
95
|
const activeTabPanel = _react.screen.getByRole('tabpanel');
|
|
110
96
|
expect(activeTabPanel).toHaveTextContent('settings configuration');
|
|
111
97
|
});
|
|
112
|
-
it('renders
|
|
113
|
-
|
|
98
|
+
it('renders tabs in correct order', ()=>{
|
|
99
|
+
renderTabs();
|
|
114
100
|
const tabList = _react.screen.getByRole('tablist');
|
|
115
101
|
const tabs = (0, _react.getAllByRole)(tabList, 'tab');
|
|
116
|
-
expect(tabs).toHaveLength(
|
|
102
|
+
expect(tabs).toHaveLength(3);
|
|
117
103
|
expect(tabs[0]).toHaveTextContent('Query');
|
|
118
104
|
expect(tabs[1]).toHaveTextContent('Settings');
|
|
119
|
-
expect(tabs[2]).toHaveTextContent('Table column');
|
|
120
|
-
expect(tabs[3]).toHaveTextContent('Table options');
|
|
121
|
-
expect(tabs[4]).toHaveTextContent('JSON');
|
|
122
|
-
});
|
|
123
|
-
it('shows the correct content when selecting a custom tab', ()=>{
|
|
124
|
-
renderCustomTabs();
|
|
125
|
-
const tableColTab = _react.screen.getByRole('tab', {
|
|
126
|
-
name: 'Table columns'
|
|
127
|
-
});
|
|
128
|
-
_userEvent.default.click(tableColTab);
|
|
129
|
-
const activeTab = _react.screen.getByRole('tab', {
|
|
130
|
-
selected: true
|
|
131
|
-
});
|
|
132
|
-
expect(activeTab).toBe(tableColTab);
|
|
133
|
-
const activeTabPanel = _react.screen.getByRole('tabpanel');
|
|
134
|
-
expect(activeTabPanel).toHaveTextContent('custom table column');
|
|
135
|
-
});
|
|
136
|
-
it('only renders common tabs that are specified', ()=>{
|
|
137
|
-
(0, _react.render)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorTabs.OptionsEditorTabs, {
|
|
138
|
-
tabs: {
|
|
139
|
-
settings: {
|
|
140
|
-
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
141
|
-
children: "settings are alone"
|
|
142
|
-
})
|
|
143
|
-
},
|
|
144
|
-
json: {
|
|
145
|
-
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
146
|
-
children: "JSON is at the end"
|
|
147
|
-
})
|
|
148
|
-
},
|
|
149
|
-
other: [
|
|
150
|
-
{
|
|
151
|
-
id: 'custom',
|
|
152
|
-
label: 'Another tab',
|
|
153
|
-
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
154
|
-
children: "another tab content"
|
|
155
|
-
})
|
|
156
|
-
}
|
|
157
|
-
]
|
|
158
|
-
}
|
|
159
|
-
}));
|
|
160
|
-
const tabList = _react.screen.getByRole('tablist');
|
|
161
|
-
const tabs = (0, _react.getAllByRole)(tabList, 'tab');
|
|
162
|
-
expect(tabs).toHaveLength(3);
|
|
163
|
-
expect(tabs[0]).toHaveTextContent('Settings');
|
|
164
|
-
expect(tabs[1]).toHaveTextContent('Another tab');
|
|
165
105
|
expect(tabs[2]).toHaveTextContent('JSON');
|
|
166
106
|
});
|
|
167
107
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "PluginSpecEditor", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _components = require("@perses-dev/components");
|
|
23
23
|
const _runtime = require("../runtime");
|
|
24
|
+
const _optionsEditorTabs = require("./OptionsEditorTabs");
|
|
24
25
|
function PluginSpecEditor(props) {
|
|
25
26
|
const { pluginType , pluginKind , ...others } = props;
|
|
26
27
|
const { data: plugin , isLoading , error } = (0, _runtime.usePlugin)(pluginType, pluginKind);
|
|
@@ -34,10 +35,43 @@ function PluginSpecEditor(props) {
|
|
|
34
35
|
return null;
|
|
35
36
|
}
|
|
36
37
|
if (plugin === undefined) {
|
|
37
|
-
throw new Error(`Missing
|
|
38
|
+
throw new Error(`Missing implementation for ${pluginType} plugin with kind '${pluginKind}'`);
|
|
39
|
+
}
|
|
40
|
+
if (pluginType === 'Panel') {
|
|
41
|
+
const { PanelQueryEditorComponent , panelOptionsEditorComponents } = plugin;
|
|
42
|
+
let tabs = [];
|
|
43
|
+
if (PanelQueryEditorComponent !== undefined) {
|
|
44
|
+
tabs.push({
|
|
45
|
+
label: 'Query',
|
|
46
|
+
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)(PanelQueryEditorComponent, {
|
|
47
|
+
...others
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (panelOptionsEditorComponents !== undefined) {
|
|
52
|
+
tabs = tabs.concat(panelOptionsEditorComponents.map(({ label , content: OptionsEditorComponent })=>({
|
|
53
|
+
label,
|
|
54
|
+
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)(OptionsEditorComponent, {
|
|
55
|
+
...others
|
|
56
|
+
})
|
|
57
|
+
})));
|
|
58
|
+
}
|
|
59
|
+
// always show json editor by default
|
|
60
|
+
tabs.push({
|
|
61
|
+
label: 'JSON',
|
|
62
|
+
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.JSONEditor, {
|
|
63
|
+
...others
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_optionsEditorTabs.OptionsEditorTabs, {
|
|
67
|
+
tabs: tabs
|
|
68
|
+
});
|
|
38
69
|
}
|
|
39
70
|
const { OptionsEditorComponent } = plugin;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
71
|
+
if (OptionsEditorComponent !== undefined) {
|
|
72
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(OptionsEditorComponent, {
|
|
73
|
+
...others
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
43
77
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -30,15 +30,37 @@ describe('PluginSpecEditor', ()=>{
|
|
|
30
30
|
...props
|
|
31
31
|
}));
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
describe('Panel plugin', ()=>{
|
|
34
|
+
it('should show query and json editors', async ()=>{
|
|
35
|
+
renderComponent({
|
|
36
|
+
pluginType: 'Panel',
|
|
37
|
+
pluginKind: 'BertPanel1',
|
|
38
|
+
value: {},
|
|
39
|
+
onChange: jest.fn()
|
|
40
|
+
});
|
|
41
|
+
const queryTab = await _react.screen.findByLabelText('Query');
|
|
42
|
+
expect(queryTab).toBeInTheDocument();
|
|
43
|
+
const editor = await _react.screen.findByLabelText('BertPanel1 editor');
|
|
44
|
+
expect(editor).toBeInTheDocument();
|
|
45
|
+
const jsonEditor = await _react.screen.findByLabelText('JSON');
|
|
46
|
+
expect(jsonEditor).toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
it('should display other options editor components', async ()=>{
|
|
49
|
+
renderComponent({
|
|
50
|
+
pluginType: 'Panel',
|
|
51
|
+
pluginKind: 'BertPanel2',
|
|
52
|
+
value: {},
|
|
53
|
+
onChange: jest.fn()
|
|
54
|
+
});
|
|
55
|
+
const settingsTab = await _react.screen.findByLabelText('Settings');
|
|
56
|
+
expect(settingsTab).toBeInTheDocument();
|
|
57
|
+
const editor = await _react.screen.findByLabelText('BertPanel2 editor');
|
|
58
|
+
expect(editor).toBeInTheDocument();
|
|
59
|
+
const customTab = await _react.screen.findByLabelText('Custom Tab');
|
|
60
|
+
expect(customTab).toBeInTheDocument();
|
|
61
|
+
const jsonEditor = await _react.screen.findByLabelText('JSON');
|
|
62
|
+
expect(jsonEditor).toBeInTheDocument();
|
|
39
63
|
});
|
|
40
|
-
const editor = await _react.screen.findByLabelText('BertPanel1 editor');
|
|
41
|
-
expect(editor).toBeInTheDocument();
|
|
42
64
|
});
|
|
43
65
|
it('propagates value changes', async ()=>{
|
|
44
66
|
const onChange = jest.fn();
|
package/dist/cjs/index.js
CHANGED
package/dist/cjs/model/index.js
CHANGED
package/dist/cjs/model/panels.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -14,3 +14,9 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
+
const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
|
|
18
|
+
function _interopRequireDefault(obj) {
|
|
19
|
+
return obj && obj.__esModule ? obj : {
|
|
20
|
+
default: obj
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -23,7 +23,8 @@ function _export(target, all) {
|
|
|
23
23
|
_export(exports, {
|
|
24
24
|
DatasourceStoreContext: ()=>DatasourceStoreContext,
|
|
25
25
|
useDatasourceStore: ()=>useDatasourceStore,
|
|
26
|
-
useListDatasources: ()=>useListDatasources
|
|
26
|
+
useListDatasources: ()=>useListDatasources,
|
|
27
|
+
useDatasourceClient: ()=>useDatasourceClient
|
|
27
28
|
});
|
|
28
29
|
const _reactQuery = require("@tanstack/react-query");
|
|
29
30
|
const _react = require("react");
|
|
@@ -42,3 +43,10 @@ function useListDatasources(datasourcePluginKind) {
|
|
|
42
43
|
datasourcePluginKind
|
|
43
44
|
], ()=>listDatasourceMetadata(datasourcePluginKind));
|
|
44
45
|
}
|
|
46
|
+
function useDatasourceClient(selector) {
|
|
47
|
+
const store = useDatasourceStore();
|
|
48
|
+
return (0, _reactQuery.useQuery)([
|
|
49
|
+
'getDatasourceClient',
|
|
50
|
+
selector
|
|
51
|
+
], ()=>store.getDatasourceClient(selector));
|
|
52
|
+
}
|
package/dist/cjs/test/index.js
CHANGED