@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.
Files changed (155) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +1 -1
  2. package/dist/cjs/components/CalculationSelector/CalculationSelector.test.js +1 -1
  3. package/dist/cjs/components/CalculationSelector/index.js +1 -1
  4. package/dist/cjs/components/DatasourceSelect.js +1 -1
  5. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +5 -48
  6. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.test.js +26 -86
  7. package/dist/cjs/components/OptionsEditorTabs/TabPanel.js +1 -1
  8. package/dist/cjs/components/OptionsEditorTabs/index.js +1 -1
  9. package/dist/cjs/components/PluginEditor/PluginEditor.js +1 -1
  10. package/dist/cjs/components/PluginEditor/PluginEditor.test.js +1 -1
  11. package/dist/cjs/components/PluginEditor/index.js +1 -1
  12. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +1 -1
  13. package/dist/cjs/components/PluginKindSelect.js +1 -1
  14. package/dist/cjs/components/PluginKindSelect.test.js +1 -1
  15. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
  16. package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +1 -1
  17. package/dist/cjs/components/PluginRegistry/index.js +1 -1
  18. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +1 -1
  19. package/dist/cjs/components/PluginSpecEditor.js +39 -5
  20. package/dist/cjs/components/PluginSpecEditor.test.js +31 -9
  21. package/dist/cjs/components/TimeSeriesQueryEditor.js +1 -1
  22. package/dist/cjs/components/index.js +1 -1
  23. package/dist/cjs/index.js +1 -1
  24. package/dist/cjs/model/calculations.js +1 -1
  25. package/dist/cjs/model/datasource.js +1 -1
  26. package/dist/cjs/model/index.js +1 -1
  27. package/dist/cjs/model/panels.js +7 -1
  28. package/dist/cjs/model/plugin-base.js +1 -1
  29. package/dist/cjs/model/plugin-loading.js +1 -1
  30. package/dist/cjs/model/plugins.js +1 -1
  31. package/dist/cjs/model/time-series-queries.js +1 -1
  32. package/dist/cjs/model/variables.js +1 -1
  33. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
  34. package/dist/cjs/runtime/TimeRangeProvider/index.js +1 -1
  35. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +1 -1
  36. package/dist/cjs/runtime/datasources.js +10 -2
  37. package/dist/cjs/runtime/index.js +1 -1
  38. package/dist/cjs/runtime/plugin-registry.js +1 -1
  39. package/dist/cjs/runtime/template-variables.js +1 -1
  40. package/dist/cjs/runtime/time-series-queries.js +1 -1
  41. package/dist/cjs/test/index.js +1 -1
  42. package/dist/cjs/test/render.js +1 -1
  43. package/dist/cjs/test/setup-tests.js +1 -1
  44. package/dist/cjs/test/test-plugins/bert/index.js +33 -20
  45. package/dist/cjs/test/test-plugins/ernie/index.js +1 -1
  46. package/dist/cjs/test/test-plugins/index.js +1 -1
  47. package/dist/cjs/test-utils/index.js +1 -1
  48. package/dist/cjs/test-utils/mock-plugin-registry.js +1 -1
  49. package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
  50. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  51. package/dist/components/CalculationSelector/CalculationSelector.test.js +1 -1
  52. package/dist/components/CalculationSelector/CalculationSelector.test.js.map +1 -1
  53. package/dist/components/CalculationSelector/index.js +1 -1
  54. package/dist/components/CalculationSelector/index.js.map +1 -1
  55. package/dist/components/DatasourceSelect.js +1 -1
  56. package/dist/components/DatasourceSelect.js.map +1 -1
  57. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -24
  58. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
  59. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +5 -48
  60. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  61. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js +26 -86
  62. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js.map +1 -1
  63. package/dist/components/OptionsEditorTabs/TabPanel.js +1 -1
  64. package/dist/components/OptionsEditorTabs/TabPanel.js.map +1 -1
  65. package/dist/components/OptionsEditorTabs/index.js +1 -1
  66. package/dist/components/OptionsEditorTabs/index.js.map +1 -1
  67. package/dist/components/PluginEditor/PluginEditor.js +1 -1
  68. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  69. package/dist/components/PluginEditor/PluginEditor.test.js +1 -1
  70. package/dist/components/PluginEditor/PluginEditor.test.js.map +1 -1
  71. package/dist/components/PluginEditor/index.js +1 -1
  72. package/dist/components/PluginEditor/index.js.map +1 -1
  73. package/dist/components/PluginEditor/plugin-editor-api.js +1 -1
  74. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  75. package/dist/components/PluginKindSelect.js +1 -1
  76. package/dist/components/PluginKindSelect.js.map +1 -1
  77. package/dist/components/PluginKindSelect.test.js +1 -1
  78. package/dist/components/PluginKindSelect.test.js.map +1 -1
  79. package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
  80. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  81. package/dist/components/PluginRegistry/PluginRegistry.test.js +1 -1
  82. package/dist/components/PluginRegistry/PluginRegistry.test.js.map +1 -1
  83. package/dist/components/PluginRegistry/index.js +1 -1
  84. package/dist/components/PluginRegistry/index.js.map +1 -1
  85. package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
  86. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  87. package/dist/components/PluginSpecEditor.d.ts.map +1 -1
  88. package/dist/components/PluginSpecEditor.js +40 -6
  89. package/dist/components/PluginSpecEditor.js.map +1 -1
  90. package/dist/components/PluginSpecEditor.test.js +31 -9
  91. package/dist/components/PluginSpecEditor.test.js.map +1 -1
  92. package/dist/components/TimeSeriesQueryEditor.js +1 -1
  93. package/dist/components/TimeSeriesQueryEditor.js.map +1 -1
  94. package/dist/components/index.js +1 -1
  95. package/dist/components/index.js.map +1 -1
  96. package/dist/index.js +1 -1
  97. package/dist/index.js.map +1 -1
  98. package/dist/model/calculations.js +1 -1
  99. package/dist/model/calculations.js.map +1 -1
  100. package/dist/model/datasource.js +1 -1
  101. package/dist/model/datasource.js.map +1 -1
  102. package/dist/model/index.js +1 -1
  103. package/dist/model/index.js.map +1 -1
  104. package/dist/model/panels.d.ts +14 -2
  105. package/dist/model/panels.d.ts.map +1 -1
  106. package/dist/model/panels.js +2 -2
  107. package/dist/model/panels.js.map +1 -1
  108. package/dist/model/plugin-base.d.ts +1 -1
  109. package/dist/model/plugin-base.d.ts.map +1 -1
  110. package/dist/model/plugin-base.js +1 -1
  111. package/dist/model/plugin-base.js.map +1 -1
  112. package/dist/model/plugin-loading.js +1 -1
  113. package/dist/model/plugin-loading.js.map +1 -1
  114. package/dist/model/plugins.js +1 -1
  115. package/dist/model/plugins.js.map +1 -1
  116. package/dist/model/time-series-queries.js +1 -1
  117. package/dist/model/time-series-queries.js.map +1 -1
  118. package/dist/model/variables.js +1 -1
  119. package/dist/model/variables.js.map +1 -1
  120. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
  121. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  122. package/dist/runtime/TimeRangeProvider/index.js +1 -1
  123. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  124. package/dist/runtime/TimeRangeProvider/query-params.js +1 -1
  125. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  126. package/dist/runtime/datasources.d.ts +4 -0
  127. package/dist/runtime/datasources.d.ts.map +1 -1
  128. package/dist/runtime/datasources.js +10 -1
  129. package/dist/runtime/datasources.js.map +1 -1
  130. package/dist/runtime/index.js +1 -1
  131. package/dist/runtime/index.js.map +1 -1
  132. package/dist/runtime/plugin-registry.js +1 -1
  133. package/dist/runtime/plugin-registry.js.map +1 -1
  134. package/dist/runtime/template-variables.js +1 -1
  135. package/dist/runtime/template-variables.js.map +1 -1
  136. package/dist/runtime/time-series-queries.js +1 -1
  137. package/dist/runtime/time-series-queries.js.map +1 -1
  138. package/dist/test/index.js +1 -1
  139. package/dist/test/index.js.map +1 -1
  140. package/dist/test/render.js +1 -1
  141. package/dist/test/render.js.map +1 -1
  142. package/dist/test/setup-tests.js +1 -1
  143. package/dist/test/setup-tests.js.map +1 -1
  144. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  145. package/dist/test/test-plugins/bert/index.js +33 -20
  146. package/dist/test/test-plugins/bert/index.js.map +1 -1
  147. package/dist/test/test-plugins/ernie/index.js +1 -1
  148. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  149. package/dist/test/test-plugins/index.js +1 -1
  150. package/dist/test/test-plugins/index.js.map +1 -1
  151. package/dist/test-utils/index.js +1 -1
  152. package/dist/test-utils/index.js.map +1 -1
  153. package/dist/test-utils/mock-plugin-registry.js +1 -1
  154. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  155. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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: normalizedTabs.map(({ id , label }, i)=>{
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
- }, id);
46
+ }, label);
90
47
  })
91
48
  })
92
49
  }),
93
- normalizedTabs.map(({ id , content }, i)=>{
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
- }, id);
55
+ }, label);
99
56
  })
100
57
  ]
101
58
  });
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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 custom tabs between visual tabs and json editor', ()=>{
113
- renderCustomTabs();
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(5);
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 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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 OptionsEditorComponent for ${pluginType} plugin with kind '${pluginKind}'`);
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
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(OptionsEditorComponent, {
41
- ...others
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 2022 The Perses Authors
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
- it('shows the options editor component for a plugin', async ()=>{
34
- renderComponent({
35
- pluginType: 'Panel',
36
- pluginKind: 'BertPanel1',
37
- value: {},
38
- onChange: jest.fn()
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();
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
package/dist/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
+ }
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
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