@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.
Files changed (242) hide show
  1. package/LICENSE +201 -0
  2. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +52 -0
  3. package/dist/cjs/components/CalculationSelector/CalculationSelector.test.js +65 -0
  4. package/dist/cjs/components/CalculationSelector/index.js +28 -0
  5. package/dist/cjs/components/DatasourceSelect.js +76 -0
  6. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +102 -0
  7. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.test.js +167 -0
  8. package/dist/cjs/components/OptionsEditorTabs/TabPanel.js +37 -0
  9. package/dist/cjs/components/OptionsEditorTabs/index.js +28 -0
  10. package/dist/cjs/components/PluginEditor/PluginEditor.js +67 -0
  11. package/dist/cjs/components/PluginEditor/PluginEditor.test.js +150 -0
  12. package/dist/cjs/components/PluginEditor/index.js +29 -0
  13. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +101 -0
  14. package/dist/cjs/components/PluginKindSelect.js +41 -0
  15. package/dist/cjs/components/PluginKindSelect.test.js +86 -0
  16. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +85 -0
  17. package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +144 -0
  18. package/dist/cjs/components/PluginRegistry/index.js +28 -0
  19. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +78 -0
  20. package/dist/cjs/components/PluginSpecEditor.js +43 -0
  21. package/dist/cjs/components/PluginSpecEditor.test.js +70 -0
  22. package/dist/cjs/components/TimeSeriesQueryEditor.js +42 -0
  23. package/dist/cjs/components/index.js +35 -0
  24. package/dist/cjs/index.js +31 -0
  25. package/dist/cjs/model/calculations.js +77 -0
  26. package/dist/cjs/model/datasource.js +16 -0
  27. package/dist/cjs/model/index.js +35 -0
  28. package/dist/cjs/model/panels.js +16 -0
  29. package/dist/cjs/model/plugin-base.js +22 -0
  30. package/dist/cjs/model/plugin-loading.js +38 -0
  31. package/dist/cjs/model/plugins.js +16 -0
  32. package/dist/cjs/model/time-series-queries.js +16 -0
  33. package/dist/cjs/model/variables.js +16 -0
  34. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +118 -0
  35. package/dist/cjs/runtime/TimeRangeProvider/index.js +29 -0
  36. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +161 -0
  37. package/dist/cjs/runtime/datasources.js +44 -0
  38. package/dist/cjs/runtime/index.js +32 -0
  39. package/dist/cjs/runtime/plugin-registry.js +75 -0
  40. package/dist/cjs/runtime/template-variables.js +57 -0
  41. package/dist/cjs/runtime/time-series-queries.js +140 -0
  42. package/dist/cjs/test/index.js +28 -0
  43. package/dist/cjs/test/render.js +52 -0
  44. package/dist/cjs/test/setup-tests.js +20 -0
  45. package/dist/cjs/test/test-plugins/bert/index.js +77 -0
  46. package/dist/cjs/test/test-plugins/ernie/index.js +58 -0
  47. package/dist/cjs/test/test-plugins/index.js +77 -0
  48. package/dist/cjs/test-utils/index.js +28 -0
  49. package/dist/cjs/test-utils/mock-plugin-registry.js +68 -0
  50. package/dist/components/CalculationSelector/CalculationSelector.d.ts +8 -0
  51. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -0
  52. package/dist/components/CalculationSelector/CalculationSelector.js +46 -0
  53. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -0
  54. package/dist/components/CalculationSelector/CalculationSelector.test.d.ts +2 -0
  55. package/dist/components/CalculationSelector/CalculationSelector.test.d.ts.map +1 -0
  56. package/dist/components/CalculationSelector/CalculationSelector.test.js +58 -0
  57. package/dist/components/CalculationSelector/CalculationSelector.test.js.map +1 -0
  58. package/dist/components/CalculationSelector/index.d.ts +2 -0
  59. package/dist/components/CalculationSelector/index.d.ts.map +1 -0
  60. package/dist/components/CalculationSelector/index.js +15 -0
  61. package/dist/components/CalculationSelector/index.js.map +1 -0
  62. package/dist/components/DatasourceSelect.d.ts +16 -0
  63. package/dist/components/DatasourceSelect.d.ts.map +1 -0
  64. package/dist/components/DatasourceSelect.js +73 -0
  65. package/dist/components/DatasourceSelect.js.map +1 -0
  66. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +34 -0
  67. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -0
  68. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +96 -0
  69. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -0
  70. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.d.ts +2 -0
  71. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.d.ts.map +1 -0
  72. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js +160 -0
  73. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js.map +1 -0
  74. package/dist/components/OptionsEditorTabs/TabPanel.d.ts +9 -0
  75. package/dist/components/OptionsEditorTabs/TabPanel.d.ts.map +1 -0
  76. package/dist/components/OptionsEditorTabs/TabPanel.js +31 -0
  77. package/dist/components/OptionsEditorTabs/TabPanel.js.map +1 -0
  78. package/dist/components/OptionsEditorTabs/index.d.ts +2 -0
  79. package/dist/components/OptionsEditorTabs/index.d.ts.map +1 -0
  80. package/dist/components/OptionsEditorTabs/index.js +15 -0
  81. package/dist/components/OptionsEditorTabs/index.js.map +1 -0
  82. package/dist/components/PluginEditor/PluginEditor.d.ts +12 -0
  83. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -0
  84. package/dist/components/PluginEditor/PluginEditor.js +68 -0
  85. package/dist/components/PluginEditor/PluginEditor.js.map +1 -0
  86. package/dist/components/PluginEditor/PluginEditor.test.d.ts +2 -0
  87. package/dist/components/PluginEditor/PluginEditor.test.d.ts.map +1 -0
  88. package/dist/components/PluginEditor/PluginEditor.test.js +143 -0
  89. package/dist/components/PluginEditor/PluginEditor.test.js.map +1 -0
  90. package/dist/components/PluginEditor/index.d.ts +3 -0
  91. package/dist/components/PluginEditor/index.d.ts.map +1 -0
  92. package/dist/components/PluginEditor/index.js +16 -0
  93. package/dist/components/PluginEditor/index.js.map +1 -0
  94. package/dist/components/PluginEditor/plugin-editor-api.d.ts +30 -0
  95. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -0
  96. package/dist/components/PluginEditor/plugin-editor-api.js +100 -0
  97. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -0
  98. package/dist/components/PluginKindSelect.d.ts +12 -0
  99. package/dist/components/PluginKindSelect.d.ts.map +1 -0
  100. package/dist/components/PluginKindSelect.js +38 -0
  101. package/dist/components/PluginKindSelect.js.map +1 -0
  102. package/dist/components/PluginKindSelect.test.d.ts +2 -0
  103. package/dist/components/PluginKindSelect.test.d.ts.map +1 -0
  104. package/dist/components/PluginKindSelect.test.js +79 -0
  105. package/dist/components/PluginKindSelect.test.js.map +1 -0
  106. package/dist/components/PluginRegistry/PluginRegistry.d.ts +13 -0
  107. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -0
  108. package/dist/components/PluginRegistry/PluginRegistry.js +82 -0
  109. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -0
  110. package/dist/components/PluginRegistry/PluginRegistry.test.d.ts +2 -0
  111. package/dist/components/PluginRegistry/PluginRegistry.test.d.ts.map +1 -0
  112. package/dist/components/PluginRegistry/PluginRegistry.test.js +137 -0
  113. package/dist/components/PluginRegistry/PluginRegistry.test.js.map +1 -0
  114. package/dist/components/PluginRegistry/index.d.ts +2 -0
  115. package/dist/components/PluginRegistry/index.d.ts.map +1 -0
  116. package/dist/components/PluginRegistry/index.js +15 -0
  117. package/dist/components/PluginRegistry/index.js.map +1 -0
  118. package/dist/components/PluginRegistry/plugin-indexes.d.ts +14 -0
  119. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -0
  120. package/dist/components/PluginRegistry/plugin-indexes.js +70 -0
  121. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -0
  122. package/dist/components/PluginSpecEditor.d.ts +9 -0
  123. package/dist/components/PluginSpecEditor.d.ts.map +1 -0
  124. package/dist/components/PluginSpecEditor.js +37 -0
  125. package/dist/components/PluginSpecEditor.js.map +1 -0
  126. package/dist/components/PluginSpecEditor.test.d.ts +2 -0
  127. package/dist/components/PluginSpecEditor.test.d.ts.map +1 -0
  128. package/dist/components/PluginSpecEditor.test.js +63 -0
  129. package/dist/components/PluginSpecEditor.test.js.map +1 -0
  130. package/dist/components/TimeSeriesQueryEditor.d.ts +14 -0
  131. package/dist/components/TimeSeriesQueryEditor.d.ts.map +1 -0
  132. package/dist/components/TimeSeriesQueryEditor.js +38 -0
  133. package/dist/components/TimeSeriesQueryEditor.js.map +1 -0
  134. package/dist/components/index.d.ts +9 -0
  135. package/dist/components/index.d.ts.map +1 -0
  136. package/dist/components/index.js +22 -0
  137. package/dist/components/index.js.map +1 -0
  138. package/dist/index.d.ts +5 -0
  139. package/dist/index.d.ts.map +1 -0
  140. package/dist/index.js +18 -0
  141. package/dist/index.js.map +1 -0
  142. package/dist/model/calculations.d.ts +21 -0
  143. package/dist/model/calculations.d.ts.map +1 -0
  144. package/dist/model/calculations.js +64 -0
  145. package/dist/model/calculations.js.map +1 -0
  146. package/dist/model/datasource.d.ts +12 -0
  147. package/dist/model/datasource.d.ts.map +1 -0
  148. package/dist/model/datasource.js +15 -0
  149. package/dist/model/datasource.js.map +1 -0
  150. package/dist/model/index.d.ts +9 -0
  151. package/dist/model/index.d.ts.map +1 -0
  152. package/dist/model/index.js +22 -0
  153. package/dist/model/index.js.map +1 -0
  154. package/dist/model/panels.d.ts +20 -0
  155. package/dist/model/panels.d.ts.map +1 -0
  156. package/dist/model/panels.js +15 -0
  157. package/dist/model/panels.js.map +1 -0
  158. package/dist/model/plugin-base.d.ts +22 -0
  159. package/dist/model/plugin-base.d.ts.map +1 -0
  160. package/dist/model/plugin-base.js +15 -0
  161. package/dist/model/plugin-base.js.map +1 -0
  162. package/dist/model/plugin-loading.d.ts +22 -0
  163. package/dist/model/plugin-loading.d.ts.map +1 -0
  164. package/dist/model/plugin-loading.js +35 -0
  165. package/dist/model/plugin-loading.js.map +1 -0
  166. package/dist/model/plugins.d.ts +54 -0
  167. package/dist/model/plugins.d.ts.map +1 -0
  168. package/dist/model/plugins.js +15 -0
  169. package/dist/model/plugins.js.map +1 -0
  170. package/dist/model/time-series-queries.d.ts +42 -0
  171. package/dist/model/time-series-queries.d.ts.map +1 -0
  172. package/dist/model/time-series-queries.js +15 -0
  173. package/dist/model/time-series-queries.js.map +1 -0
  174. package/dist/model/variables.d.ts +35 -0
  175. package/dist/model/variables.d.ts.map +1 -0
  176. package/dist/model/variables.js +15 -0
  177. package/dist/model/variables.js.map +1 -0
  178. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +25 -0
  179. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -0
  180. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +69 -0
  181. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -0
  182. package/dist/runtime/TimeRangeProvider/index.d.ts +3 -0
  183. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -0
  184. package/dist/runtime/TimeRangeProvider/index.js +16 -0
  185. package/dist/runtime/TimeRangeProvider/index.js.map +1 -0
  186. package/dist/runtime/TimeRangeProvider/query-params.d.ts +25 -0
  187. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -0
  188. package/dist/runtime/TimeRangeProvider/query-params.js +153 -0
  189. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -0
  190. package/dist/runtime/datasources.d.ts +25 -0
  191. package/dist/runtime/datasources.d.ts.map +1 -0
  192. package/dist/runtime/datasources.js +34 -0
  193. package/dist/runtime/datasources.js.map +1 -0
  194. package/dist/runtime/index.d.ts +6 -0
  195. package/dist/runtime/index.d.ts.map +1 -0
  196. package/dist/runtime/index.js +19 -0
  197. package/dist/runtime/index.js.map +1 -0
  198. package/dist/runtime/plugin-registry.d.ts +32 -0
  199. package/dist/runtime/plugin-registry.d.ts.map +1 -0
  200. package/dist/runtime/plugin-registry.js +69 -0
  201. package/dist/runtime/plugin-registry.js.map +1 -0
  202. package/dist/runtime/template-variables.d.ts +17 -0
  203. package/dist/runtime/template-variables.d.ts.map +1 -0
  204. package/dist/runtime/template-variables.js +44 -0
  205. package/dist/runtime/template-variables.js.map +1 -0
  206. package/dist/runtime/time-series-queries.d.ts +13 -0
  207. package/dist/runtime/time-series-queries.d.ts.map +1 -0
  208. package/dist/runtime/time-series-queries.js +132 -0
  209. package/dist/runtime/time-series-queries.js.map +1 -0
  210. package/dist/test/index.d.ts +2 -0
  211. package/dist/test/index.d.ts.map +1 -0
  212. package/dist/test/index.js +15 -0
  213. package/dist/test/index.js.map +1 -0
  214. package/dist/test/render.d.ts +13 -0
  215. package/dist/test/render.d.ts.map +1 -0
  216. package/dist/test/render.js +49 -0
  217. package/dist/test/render.js.map +1 -0
  218. package/dist/test/setup-tests.d.ts +2 -0
  219. package/dist/test/setup-tests.d.ts.map +1 -0
  220. package/dist/test/setup-tests.js +18 -0
  221. package/dist/test/setup-tests.js.map +1 -0
  222. package/dist/test/test-plugins/bert/index.d.ts +8 -0
  223. package/dist/test/test-plugins/bert/index.d.ts.map +1 -0
  224. package/dist/test/test-plugins/bert/index.js +66 -0
  225. package/dist/test/test-plugins/bert/index.js.map +1 -0
  226. package/dist/test/test-plugins/ernie/index.d.ts +5 -0
  227. package/dist/test/test-plugins/ernie/index.d.ts.map +1 -0
  228. package/dist/test/test-plugins/ernie/index.js +53 -0
  229. package/dist/test/test-plugins/ernie/index.js.map +1 -0
  230. package/dist/test/test-plugins/index.d.ts +6 -0
  231. package/dist/test/test-plugins/index.d.ts.map +1 -0
  232. package/dist/test/test-plugins/index.js +29 -0
  233. package/dist/test/test-plugins/index.js.map +1 -0
  234. package/dist/test-utils/index.d.ts +2 -0
  235. package/dist/test-utils/index.d.ts.map +1 -0
  236. package/dist/test-utils/index.js +15 -0
  237. package/dist/test-utils/index.js.map +1 -0
  238. package/dist/test-utils/mock-plugin-registry.d.ts +20 -0
  239. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -0
  240. package/dist/test-utils/mock-plugin-registry.js +62 -0
  241. package/dist/test-utils/mock-plugin-registry.js.map +1 -0
  242. package/package.json +45 -0
@@ -0,0 +1,160 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { screen, render, getAllByRole } from '@testing-library/react';
15
+ import userEvent from '@testing-library/user-event';
16
+ import { OptionsEditorTabs } from './OptionsEditorTabs';
17
+ describe('OptionsEditorTabs', ()=>{
18
+ const renderTabs = (otherTabs)=>{
19
+ render(/*#__PURE__*/ _jsx(OptionsEditorTabs, {
20
+ tabs: {
21
+ query: {
22
+ content: /*#__PURE__*/ _jsx("div", {
23
+ children: "Edit query configuration"
24
+ })
25
+ },
26
+ settings: {
27
+ content: /*#__PURE__*/ _jsx("div", {
28
+ children: "Edit settings configuration"
29
+ })
30
+ },
31
+ json: {
32
+ content: /*#__PURE__*/ _jsx("div", {
33
+ children: "JSON editor"
34
+ })
35
+ },
36
+ other: otherTabs
37
+ }
38
+ }));
39
+ };
40
+ const renderCustomTabs = ()=>{
41
+ renderTabs([
42
+ {
43
+ id: 'tableCols',
44
+ label: 'Table columns',
45
+ content: /*#__PURE__*/ _jsx("div", {
46
+ children: "custom table column"
47
+ })
48
+ },
49
+ {
50
+ id: 'tableOpts',
51
+ label: 'Table options',
52
+ content: /*#__PURE__*/ _jsx("div", {
53
+ children: "custom table options"
54
+ })
55
+ }
56
+ ]);
57
+ };
58
+ it('renders all specified tabs in a tab list', ()=>{
59
+ renderTabs();
60
+ const tabList = screen.getByRole('tablist');
61
+ const tabs = getAllByRole(tabList, 'tab');
62
+ expect(tabs).toHaveLength(3);
63
+ expect(tabs[0]).toHaveTextContent('Query');
64
+ expect(tabs[1]).toHaveTextContent('Settings');
65
+ expect(tabs[2]).toHaveTextContent('JSON');
66
+ });
67
+ it('defaults to selecting the first tab', ()=>{
68
+ renderTabs();
69
+ const activeTab = screen.getByRole('tab', {
70
+ selected: true
71
+ });
72
+ expect(activeTab).toHaveTextContent('Query');
73
+ const activeTabPanel = screen.getByRole('tabpanel');
74
+ expect(activeTabPanel).toHaveTextContent('query configuration');
75
+ });
76
+ it('switches selected tab on click', ()=>{
77
+ renderTabs();
78
+ const jsonTab = screen.getByRole('tab', {
79
+ name: 'JSON'
80
+ });
81
+ userEvent.click(jsonTab);
82
+ const activeTab = screen.getByRole('tab', {
83
+ selected: true
84
+ });
85
+ expect(activeTab).toBe(jsonTab);
86
+ const activeTabPanel = screen.getByRole('tabpanel');
87
+ expect(activeTabPanel).toHaveTextContent('JSON editor');
88
+ });
89
+ it('switches selected tab on keyboard interactions', ()=>{
90
+ renderTabs();
91
+ const vizTab = screen.getByRole('tab', {
92
+ name: 'Settings'
93
+ });
94
+ userEvent.tab();
95
+ userEvent.keyboard('{arrowright}{space}');
96
+ const activeTab = screen.getByRole('tab', {
97
+ selected: true
98
+ });
99
+ expect(activeTab).toBe(vizTab);
100
+ const activeTabPanel = screen.getByRole('tabpanel');
101
+ expect(activeTabPanel).toHaveTextContent('settings configuration');
102
+ });
103
+ it('renders custom tabs between visual tabs and json editor', ()=>{
104
+ renderCustomTabs();
105
+ const tabList = screen.getByRole('tablist');
106
+ const tabs = getAllByRole(tabList, 'tab');
107
+ expect(tabs).toHaveLength(5);
108
+ expect(tabs[0]).toHaveTextContent('Query');
109
+ expect(tabs[1]).toHaveTextContent('Settings');
110
+ expect(tabs[2]).toHaveTextContent('Table column');
111
+ expect(tabs[3]).toHaveTextContent('Table options');
112
+ expect(tabs[4]).toHaveTextContent('JSON');
113
+ });
114
+ it('shows the correct content when selecting a custom tab', ()=>{
115
+ renderCustomTabs();
116
+ const tableColTab = screen.getByRole('tab', {
117
+ name: 'Table columns'
118
+ });
119
+ userEvent.click(tableColTab);
120
+ const activeTab = screen.getByRole('tab', {
121
+ selected: true
122
+ });
123
+ expect(activeTab).toBe(tableColTab);
124
+ const activeTabPanel = screen.getByRole('tabpanel');
125
+ expect(activeTabPanel).toHaveTextContent('custom table column');
126
+ });
127
+ it('only renders common tabs that are specified', ()=>{
128
+ render(/*#__PURE__*/ _jsx(OptionsEditorTabs, {
129
+ tabs: {
130
+ settings: {
131
+ content: /*#__PURE__*/ _jsx("div", {
132
+ children: "settings are alone"
133
+ })
134
+ },
135
+ json: {
136
+ content: /*#__PURE__*/ _jsx("div", {
137
+ children: "JSON is at the end"
138
+ })
139
+ },
140
+ other: [
141
+ {
142
+ id: 'custom',
143
+ label: 'Another tab',
144
+ content: /*#__PURE__*/ _jsx("div", {
145
+ children: "another tab content"
146
+ })
147
+ }
148
+ ]
149
+ }
150
+ }));
151
+ const tabList = screen.getByRole('tablist');
152
+ const tabs = getAllByRole(tabList, 'tab');
153
+ expect(tabs).toHaveLength(3);
154
+ expect(tabs[0]).toHaveTextContent('Settings');
155
+ expect(tabs[1]).toHaveTextContent('Another tab');
156
+ expect(tabs[2]).toHaveTextContent('JSON');
157
+ });
158
+ });
159
+
160
+ //# sourceMappingURL=OptionsEditorTabs.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/OptionsEditorTabs/OptionsEditorTabs.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { screen, render, getAllByRole } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\n\nimport { OptionsEditorTabs, OptionsEditorTabsProps } from './OptionsEditorTabs';\n\ndescribe('OptionsEditorTabs', () => {\n const renderTabs = (otherTabs?: OptionsEditorTabsProps['tabs']['other']) => {\n render(\n <OptionsEditorTabs\n tabs={{\n query: {\n content: <div>Edit query configuration</div>,\n },\n settings: {\n content: <div>Edit settings configuration</div>,\n },\n json: {\n content: <div>JSON editor</div>,\n },\n other: otherTabs,\n }}\n />\n );\n };\n\n const renderCustomTabs = () => {\n renderTabs([\n {\n id: 'tableCols',\n label: 'Table columns',\n content: <div>custom table column</div>,\n },\n {\n id: 'tableOpts',\n label: 'Table options',\n content: <div>custom table options</div>,\n },\n ]);\n };\n\n it('renders all specified tabs in a tab list', () => {\n renderTabs();\n\n const tabList = screen.getByRole('tablist');\n const tabs = getAllByRole(tabList, 'tab');\n expect(tabs).toHaveLength(3);\n expect(tabs[0]).toHaveTextContent('Query');\n expect(tabs[1]).toHaveTextContent('Settings');\n expect(tabs[2]).toHaveTextContent('JSON');\n });\n\n it('defaults to selecting the first tab', () => {\n renderTabs();\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toHaveTextContent('Query');\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('query configuration');\n });\n\n it('switches selected tab on click', () => {\n renderTabs();\n const jsonTab = screen.getByRole('tab', { name: 'JSON' });\n userEvent.click(jsonTab);\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toBe(jsonTab);\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('JSON editor');\n });\n\n it('switches selected tab on keyboard interactions', () => {\n renderTabs();\n const vizTab = screen.getByRole('tab', { name: 'Settings' });\n userEvent.tab();\n userEvent.keyboard('{arrowright}{space}');\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toBe(vizTab);\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('settings configuration');\n });\n\n it('renders custom tabs between visual tabs and json editor', () => {\n renderCustomTabs();\n\n const tabList = screen.getByRole('tablist');\n const tabs = getAllByRole(tabList, 'tab');\n expect(tabs).toHaveLength(5);\n expect(tabs[0]).toHaveTextContent('Query');\n expect(tabs[1]).toHaveTextContent('Settings');\n expect(tabs[2]).toHaveTextContent('Table column');\n expect(tabs[3]).toHaveTextContent('Table options');\n expect(tabs[4]).toHaveTextContent('JSON');\n });\n\n it('shows the correct content when selecting a custom tab', () => {\n renderCustomTabs();\n\n const tableColTab = screen.getByRole('tab', { name: 'Table columns' });\n userEvent.click(tableColTab);\n\n const activeTab = screen.getByRole('tab', {\n selected: true,\n });\n expect(activeTab).toBe(tableColTab);\n\n const activeTabPanel = screen.getByRole('tabpanel');\n expect(activeTabPanel).toHaveTextContent('custom table column');\n });\n\n it('only renders common tabs that are specified', () => {\n render(\n <OptionsEditorTabs\n tabs={{\n settings: {\n content: <div>settings are alone</div>,\n },\n json: {\n content: <div>JSON is at the end</div>,\n },\n other: [\n {\n id: 'custom',\n label: 'Another tab',\n content: <div>another tab content</div>,\n },\n ],\n }}\n />\n );\n const tabList = screen.getByRole('tablist');\n const tabs = getAllByRole(tabList, 'tab');\n expect(tabs).toHaveLength(3);\n expect(tabs[0]).toHaveTextContent('Settings');\n expect(tabs[1]).toHaveTextContent('Another tab');\n expect(tabs[2]).toHaveTextContent('JSON');\n });\n});\n"],"names":["screen","render","getAllByRole","userEvent","OptionsEditorTabs","describe","renderTabs","otherTabs","tabs","query","content","div","settings","json","other","renderCustomTabs","id","label","it","tabList","getByRole","expect","toHaveLength","toHaveTextContent","activeTab","selected","active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KAAK,EAAE;oBACL;wBACEE,EAAE,EAAE,QAAQ;wBACZC,KAAK,EAAE,aAAa;wBACpBP,OAAO,gBAAE,KAACC,KAAG;sCAAC,qBAAmB;0BAAM;qBACxC;iBACF;aACF;UACD,CACH,CAAC;QACF,MAAMQ,OAAO,GAAGnB,MAAM,CAACoB,SAAS,CAAC,SAAS,CAAC,AAAC;QAC5C,MAAMZ,IAAI,GAAGN,YAAY,CAACiB,OAAO,EAAE,KAAK,CAAC,AAAC;QAC1CE,MAAM,CAACb,IAAI,CAAC,CAACc,YAAY,CAAC,CAAC,CAAC,CAAC;QAC7BD,MAAM,CAACb,IAAI,CAAC,CAAC,CAAC,CAAC,CAACe,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC9CF,MAAM,CAACb,IAAI,CAAC,CAAC,CAAC,CAAC,CAACe,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACjDF,MAAM,CAACb,IAAI,CAAC,CAAC,CAAC,CAAC,CAACe,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ interface TabPanelProps {
3
+ children: React.ReactNode;
4
+ index: number;
5
+ value: number;
6
+ }
7
+ export declare function TabPanel(props: TabPanelProps): JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=TabPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabPanel.d.ts","sourceRoot":"","sources":["../../../src/components/OptionsEditorTabs/TabPanel.tsx"],"names":[],"mappings":";AAeA,UAAU,aAAa;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,eAgB5C"}
@@ -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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { Box } from '@mui/material';
15
+ export function TabPanel(props) {
16
+ const { children , value , index , ...other } = props;
17
+ const isActive = value === index;
18
+ return /*#__PURE__*/ _jsx("div", {
19
+ role: "tabpanel",
20
+ hidden: !isActive,
21
+ id: `options-editor-tabpanel-${index}`,
22
+ "aria-labelledby": `options-editor-tab-${index}`,
23
+ ...other,
24
+ children: isActive && /*#__PURE__*/ _jsx(Box, {
25
+ mt: 2,
26
+ children: children
27
+ })
28
+ });
29
+ }
30
+
31
+ //# sourceMappingURL=TabPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/OptionsEditorTabs/TabPanel.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\n\ninterface TabPanelProps {\n children: React.ReactNode;\n index: number;\n value: number;\n}\n\nexport function TabPanel(props: TabPanelProps) {\n const { children, value, index, ...other } = props;\n\n const isActive = value === index;\n\n return (\n <div\n role=\"tabpanel\"\n hidden={!isActive}\n id={`options-editor-tabpanel-${index}`}\n aria-labelledby={`options-editor-tab-${index}`}\n {...other}\n >\n {isActive && <Box mt={2}>{children}</Box>}\n </div>\n );\n}\n"],"names":["Box","TabPanel","props","children","value","index","other","isActive","div","role","hidden","id","aria-labelledby","mt"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AAQpC,OAAO,SAASC,QAAQ,CAACC,KAAoB,EAAE;IAC7C,MAAM,EAAEC,QAAQ,CAAA,EAAEC,KAAK,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGC,KAAK,EAAE,GAAGJ,KAAK,AAAC;IAEnD,MAAMK,QAAQ,GAAGH,KAAK,KAAKC,KAAK,AAAC;IAEjC,qBACE,KAACG,KAAG;QACFC,IAAI,EAAC,UAAU;QACfC,MAAM,EAAE,CAACH,QAAQ;QACjBI,EAAE,EAAE,CAAC,wBAAwB,EAAEN,KAAK,CAAC,CAAC;QACtCO,iBAAe,EAAE,CAAC,mBAAmB,EAAEP,KAAK,CAAC,CAAC;QAC7C,GAAGC,KAAK;kBAERC,QAAQ,kBAAI,KAACP,GAAG;YAACa,EAAE,EAAE,CAAC;sBAAGV,QAAQ;UAAO;MACrC,CACN;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './OptionsEditorTabs';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/OptionsEditorTabs/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,15 @@
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
+ export * from './OptionsEditorTabs';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/OptionsEditorTabs/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './OptionsEditorTabs';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { PluginEditorProps } from './plugin-editor-api';
3
+ /**
4
+ * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property
5
+ * that's common in our JSON specs where a user selects a plugin `kind` and then edits the `spec` via that plugin's
6
+ * editor component. It takes care of transitioning from one plugin kind to another "all at once" so that when the
7
+ * plugin's kind changes, the spec is also changed at the same time so those options editor components don't see a
8
+ * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the
9
+ * `usePluginEditor` hook that powers this component.
10
+ */
11
+ export declare function PluginEditor(props: PluginEditorProps): JSX.Element;
12
+ //# sourceMappingURL=PluginEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,qBAAqB,CAAC;AAEzE;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eAsBpD"}
@@ -0,0 +1,68 @@
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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Box, FormControl, FormHelperText, InputLabel } from '@mui/material';
15
+ import { PluginKindSelect } from '../PluginKindSelect';
16
+ import { PluginSpecEditor } from '../PluginSpecEditor';
17
+ import { usePluginEditor } from './plugin-editor-api';
18
+ /**
19
+ * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property
20
+ * that's common in our JSON specs where a user selects a plugin `kind` and then edits the `spec` via that plugin's
21
+ * editor component. It takes care of transitioning from one plugin kind to another "all at once" so that when the
22
+ * plugin's kind changes, the spec is also changed at the same time so those options editor components don't see a
23
+ * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the
24
+ * `usePluginEditor` hook that powers this component.
25
+ */ export function PluginEditor(props) {
26
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
+ const { value , pluginType , pluginKindLabel , onChange: _ , ...others } = props;
28
+ const { pendingKind , isLoading , error , onKindChange , onSpecChange } = usePluginEditor(props);
29
+ var ref;
30
+ return /*#__PURE__*/ _jsxs(Box, {
31
+ ...others,
32
+ children: [
33
+ /*#__PURE__*/ _jsxs(FormControl, {
34
+ margin: "dense",
35
+ fullWidth: false,
36
+ disabled: isLoading,
37
+ error: error !== null,
38
+ sx: {
39
+ mb: 1
40
+ },
41
+ children: [
42
+ /*#__PURE__*/ _jsx(InputLabel, {
43
+ id: "plugin-kind-label",
44
+ children: pluginKindLabel
45
+ }),
46
+ /*#__PURE__*/ _jsx(PluginKindSelect, {
47
+ labelId: "plugin-kind-label",
48
+ label: pluginKindLabel,
49
+ pluginType: pluginType,
50
+ value: pendingKind !== '' ? pendingKind : value.kind,
51
+ onChange: onKindChange
52
+ }),
53
+ /*#__PURE__*/ _jsx(FormHelperText, {
54
+ children: (ref = error === null || error === void 0 ? void 0 : error.message) !== null && ref !== void 0 ? ref : ''
55
+ })
56
+ ]
57
+ }),
58
+ /*#__PURE__*/ _jsx(PluginSpecEditor, {
59
+ pluginType: pluginType,
60
+ pluginKind: value.kind,
61
+ value: value.spec,
62
+ onChange: onSpecChange
63
+ })
64
+ ]
65
+ });
66
+ }
67
+
68
+ //# sourceMappingURL=PluginEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, FormControl, FormHelperText, InputLabel } from '@mui/material';\nimport { PluginKindSelect } from '../PluginKindSelect';\nimport { PluginSpecEditor } from '../PluginSpecEditor';\nimport { PluginEditorProps, usePluginEditor } from './plugin-editor-api';\n\n/**\n * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property\n * that's common in our JSON specs where a user selects a plugin `kind` and then edits the `spec` via that plugin's\n * editor component. It takes care of transitioning from one plugin kind to another \"all at once\" so that when the\n * plugin's kind changes, the spec is also changed at the same time so those options editor components don't see a\n * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the\n * `usePluginEditor` hook that powers this component.\n */\nexport function PluginEditor(props: PluginEditorProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { value, pluginType, pluginKindLabel, onChange: _, ...others } = props;\n const { pendingKind, isLoading, error, onKindChange, onSpecChange } = usePluginEditor(props);\n return (\n <Box {...others}>\n <FormControl margin=\"dense\" fullWidth={false} disabled={isLoading} error={error !== null} sx={{ mb: 1 }}>\n {/* TODO: How to ensure ids are unique? */}\n <InputLabel id=\"plugin-kind-label\">{pluginKindLabel}</InputLabel>\n <PluginKindSelect\n labelId=\"plugin-kind-label\"\n label={pluginKindLabel}\n pluginType={pluginType}\n value={pendingKind !== '' ? pendingKind : value.kind}\n onChange={onKindChange}\n />\n <FormHelperText>{error?.message ?? ''}</FormHelperText>\n </FormControl>\n\n <PluginSpecEditor pluginType={pluginType} pluginKind={value.kind} value={value.spec} onChange={onSpecChange} />\n </Box>\n );\n}\n"],"names":["Box","FormControl","FormHelperText","InputLabel","PluginKindSelect","PluginSpecEditor","usePluginEditor","PluginEditor","props","value","pluginType","pluginKindLabel","onChange","_","others","pendingKind","isLoading","error","onKindChange","onSpecChange","margin","fullWidth","disabled","sx","mb","id","labelId","label","kind","message","pluginKind","spec"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,EAAEC,WAAW,EAAEC,cAAc,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC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d,KAACZ,gBAAgB;gBAACK,UAAU,EAAEA,UAAU;gBAAEoB,UAAU,EAAErB,KAAK,CAACmB,IAAI;gBAAEnB,KAAK,EAAEA,KAAK,CAACsB,IAAI;gBAAEnB,QAAQ,EAAEO,YAAY;cAAI;;MAC3G,CACN;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PluginEditor.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginEditor.test.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/PluginEditor.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,143 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import userEvent from '@testing-library/user-event';
15
+ import { screen, waitFor } from '@testing-library/react';
16
+ import { useState } from 'react';
17
+ import { renderWithContext } from '../../test';
18
+ import { PluginEditor } from './PluginEditor';
19
+ describe('PluginEditor', ()=>{
20
+ const renderComponent = ({ pluginType ='Panel' , defaultPluginKinds , value } = {})=>{
21
+ const testValue = value || {
22
+ kind: 'BertPanel1',
23
+ spec: {
24
+ option1: 'Option1Value'
25
+ }
26
+ };
27
+ // A test helper component that includes the state that's controlled from outside
28
+ let onChange = jest.fn();
29
+ function TestHelperForm() {
30
+ const [value, setValue] = useState(testValue);
31
+ onChange = jest.fn((v)=>setValue(v));
32
+ return /*#__PURE__*/ _jsx(PluginEditor, {
33
+ pluginType: pluginType,
34
+ pluginKindLabel: "Panel Type",
35
+ value: value,
36
+ onChange: onChange
37
+ });
38
+ }
39
+ renderWithContext(/*#__PURE__*/ _jsx(TestHelperForm, {}), undefined, {
40
+ defaultPluginKinds
41
+ });
42
+ return {
43
+ onChange
44
+ };
45
+ };
46
+ // Opens the PluginKindSelect and waits for loading to finish (i.e. options to appear)
47
+ const openPluginKind = async ()=>{
48
+ const select = screen.getByRole('button', {
49
+ name: 'Panel Type'
50
+ });
51
+ userEvent.click(select);
52
+ const options = await screen.findAllByRole('option');
53
+ return options;
54
+ };
55
+ it('shows plugin kind and spec editor', async ()=>{
56
+ renderComponent();
57
+ const pluginKind = screen.getByRole('button', {
58
+ name: 'Panel Type'
59
+ });
60
+ await waitFor(()=>expect(pluginKind).toHaveTextContent('Bert Panel 1'));
61
+ const specEditor = await screen.findByLabelText('BertPanel1 editor');
62
+ expect(specEditor).toHaveValue('Option1Value');
63
+ });
64
+ it('initializes kind and spec together', async ()=>{
65
+ const { onChange } = renderComponent();
66
+ // Switch to a new plugin kind
67
+ await openPluginKind();
68
+ const newPluginKind = screen.getByRole('option', {
69
+ name: 'Bert Panel 2'
70
+ });
71
+ userEvent.click(newPluginKind);
72
+ // Wait for the editor of the other plugin
73
+ const newEditor = await screen.findByLabelText('BertPanel2 editor');
74
+ expect(newEditor).toBeInTheDocument();
75
+ expect(newEditor).toHaveValue('');
76
+ // Make sure onChange was only called once (i.e. initializes both kind and spec at the same time
77
+ expect(onChange).toHaveBeenCalledTimes(1);
78
+ expect(onChange).toHaveBeenCalledWith({
79
+ kind: 'BertPanel2',
80
+ spec: {
81
+ option2: ''
82
+ }
83
+ });
84
+ });
85
+ it('remembers previous spec values', async ()=>{
86
+ renderComponent();
87
+ // Use the current editor to make a change to the spec value
88
+ let editor = await screen.findByLabelText('BertPanel1 editor');
89
+ userEvent.clear(editor);
90
+ userEvent.type(editor, 'MyNewValue');
91
+ // Switch to a new plugin kind
92
+ await openPluginKind();
93
+ const newPluginKind = screen.getByRole('option', {
94
+ name: 'Bert Panel 2'
95
+ });
96
+ userEvent.click(newPluginKind);
97
+ // Wait for the other editor to appear, then switch back
98
+ const newEditor = await screen.findByLabelText('BertPanel2 editor');
99
+ expect(newEditor).toHaveValue('');
100
+ await openPluginKind();
101
+ const oldPluginKind = screen.getByRole('option', {
102
+ name: 'Bert Panel 1'
103
+ });
104
+ userEvent.click(oldPluginKind);
105
+ // Make sure the editor from the first plugin appears and has our modified value from before the switch
106
+ editor = await screen.findByLabelText('BertPanel1 editor');
107
+ expect(editor).toHaveValue('MyNewValue');
108
+ });
109
+ describe('when defaultPluginKinds specified in plugin registry', ()=>{
110
+ it('uses default kind when one is not provided', async ()=>{
111
+ renderComponent({
112
+ pluginType: 'Panel',
113
+ defaultPluginKinds: {
114
+ Panel: 'BertPanel2'
115
+ },
116
+ value: {
117
+ kind: '',
118
+ spec: {}
119
+ }
120
+ });
121
+ // Wait for default panel kind to load.
122
+ const pluginKind = screen.getByRole('button', {
123
+ name: 'Panel Type'
124
+ });
125
+ await waitFor(()=>expect(pluginKind).toHaveTextContent('Bert Panel 2'));
126
+ });
127
+ it('does not use default when kind is provided', async ()=>{
128
+ renderComponent({
129
+ pluginType: 'Panel',
130
+ defaultPluginKinds: {
131
+ Panel: 'BertPanel2'
132
+ }
133
+ });
134
+ // Wait for specified panel kind to load.
135
+ const pluginKind = screen.getByRole('button', {
136
+ name: 'Panel Type'
137
+ });
138
+ await waitFor(()=>expect(pluginKind).toHaveTextContent('Bert Panel 1'));
139
+ });
140
+ });
141
+ });
142
+
143
+ //# sourceMappingURL=PluginEditor.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/PluginEditor/PluginEditor.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport userEvent from '@testing-library/user-event';\nimport { screen, waitFor } from '@testing-library/react';\nimport { useState } from 'react';\nimport { renderWithContext } from '../../test';\nimport { DefaultPluginKinds } from '../../model';\nimport { PluginEditor } from './PluginEditor';\nimport { PluginEditorProps } from './plugin-editor-api';\n\ntype RenderComponentOptions = {\n pluginType?: PluginEditorProps['pluginType'];\n defaultPluginKinds?: DefaultPluginKinds;\n value?: PluginEditorProps['value'];\n};\n\ndescribe('PluginEditor', () => {\n const renderComponent = ({ pluginType = 'Panel', defaultPluginKinds, value }: RenderComponentOptions = {}) => {\n const testValue: PluginEditorProps['value'] = value || { kind: 'BertPanel1', spec: { option1: 'Option1Value' } };\n\n // A test helper component that includes the state that's controlled from outside\n let onChange: jest.Mocked<PluginEditorProps['onChange']> = jest.fn();\n function TestHelperForm() {\n const [value, setValue] = useState(testValue);\n onChange = jest.fn((v) => setValue(v));\n\n return <PluginEditor pluginType={pluginType} pluginKindLabel=\"Panel Type\" value={value} onChange={onChange} />;\n }\n\n renderWithContext(<TestHelperForm />, undefined, { defaultPluginKinds });\n return { onChange };\n };\n\n // Opens the PluginKindSelect and waits for loading to finish (i.e. options to appear)\n const openPluginKind = async () => {\n const select = screen.getByRole('button', { name: 'Panel Type' });\n userEvent.click(select);\n const options = await screen.findAllByRole('option');\n return options;\n };\n\n it('shows plugin kind and spec editor', async () => {\n renderComponent();\n\n const pluginKind = screen.getByRole('button', { name: 'Panel Type' });\n await waitFor(() => expect(pluginKind).toHaveTextContent('Bert Panel 1'));\n const specEditor = await screen.findByLabelText('BertPanel1 editor');\n expect(specEditor).toHaveValue('Option1Value');\n });\n\n it('initializes kind and spec together', async () => {\n const { onChange } = renderComponent();\n\n // Switch to a new plugin kind\n await openPluginKind();\n const newPluginKind = screen.getByRole('option', { name: 'Bert Panel 2' });\n userEvent.click(newPluginKind);\n\n // Wait for the editor of the other plugin\n const newEditor = await screen.findByLabelText('BertPanel2 editor');\n expect(newEditor).toBeInTheDocument();\n expect(newEditor).toHaveValue('');\n\n // Make sure onChange was only called once (i.e. initializes both kind and spec at the same time\n expect(onChange).toHaveBeenCalledTimes(1);\n expect(onChange).toHaveBeenCalledWith({ kind: 'BertPanel2', spec: { option2: '' } });\n });\n\n it('remembers previous spec values', async () => {\n renderComponent();\n\n // Use the current editor to make a change to the spec value\n let editor = await screen.findByLabelText('BertPanel1 editor');\n userEvent.clear(editor);\n userEvent.type(editor, 'MyNewValue');\n\n // Switch to a new plugin kind\n await openPluginKind();\n const newPluginKind = screen.getByRole('option', { name: 'Bert Panel 2' });\n userEvent.click(newPluginKind);\n\n // Wait for the other editor to appear, then switch back\n const newEditor = await screen.findByLabelText('BertPanel2 editor');\n expect(newEditor).toHaveValue('');\n await openPluginKind();\n const oldPluginKind = screen.getByRole('option', { name: 'Bert Panel 1' });\n userEvent.click(oldPluginKind);\n\n // Make sure the editor from the first plugin appears and has our modified value from before the switch\n editor = await screen.findByLabelText('BertPanel1 editor');\n expect(editor).toHaveValue('MyNewValue');\n });\n\n describe('when defaultPluginKinds specified in plugin registry', () => {\n it('uses default kind when one is not provided', async () => {\n renderComponent({\n pluginType: 'Panel',\n defaultPluginKinds: {\n Panel: 'BertPanel2',\n },\n value: { kind: '', spec: {} },\n });\n\n // Wait for default panel kind to load.\n const pluginKind = screen.getByRole('button', { name: 'Panel Type' });\n await waitFor(() => expect(pluginKind).toHaveTextContent('Bert Panel 2'));\n });\n\n it('does not use default when kind is provided', async () => {\n renderComponent({ pluginType: 'Panel', defaultPluginKinds: { Panel: 'BertPanel2' } });\n\n // Wait for specified panel kind to load.\n const pluginKind = screen.getByRole('button', { name: 'Panel Type' });\n await waitFor(() => expect(pluginKind).toHaveTextContent('Bert Panel 1'));\n });\n });\n});\n"],"names":["userEvent","screen","waitFor","useState","renderWithContext","PluginEditor","describe","renderComponent","pluginType","defaultPluginKinds","value","testValue","kind","spec","option1","onChange","jest","fn","TestHelperForm","setValue","v","pluginKindLabel","undefined","openPluginKind","select","getByRole","name","click","options","findAllByRole","it","pluginKind","expect","toHaveTextContent","specEditor","findByLabelText","toHaveValue","newPluginKind","newEditor","toBeInTheDocument","toHaveBeenCalledTimes","toHaveBeenCalledWith","option2","editor","clear","type","oldPluginKind","Panel"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,MAAM,EAAEC,OAAO,QAAQ,wBAAwB,CAAC;AACzD,SAASC,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,iBAAiB,QAAQ,YAAY,CAAC;AAE/C,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAS9CC,QAAQ,CAAC,cAAc,EAAE,IAAM;IAC7B,MAAMC,eAAe,GAAG,CAAC,EAAEC,UAAU,EAAG,OAAO,CAAA,EAAEC,kBAAkB,CAAA,EAAEC,KAAK,CAAA,EAA0B,GAAG,EAAE,GAAK;QAC5G,MAAMC,SAAS,GAA+BD,KAAK,IAAI;YAAEE,IAAI,EAAE,YAAY;YAAEC,IAAI,EAAE;gBAAEC,OAAO,EAAE,cAAc;aAAE;SAAE,AAAC;QAEjH,iFAAiF;QACjF,IAAIC,QAAQ,GAA+CC,IAAI,CAACC,EAAE,EAAE,AAAC;QACrE,SAASC,cAAc,GAAG;YACxB,MAAM,CAACR,KAAK,EAAES,QAAQ,CAAC,GAAGhB,QAAQ,CAACQ,SAAS,CAAC,AAAC;YAC9CI,QAAQ,GAAGC,IAAI,CAACC,EAAE,CAAC,CAACG,CAAC,GAAKD,QAAQ,CAACC,CAAC,CAAC,CAAC,CAAC;YAEvC,qBAAO,KAACf,YAAY;gBAACG,UA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EC,IAAI,EAAE,YAAY;aAAE,CAAC,AAAC;YACtE,MAAMxB,OAAO,CAAC,IAAM8B,MAAM,CAACD,UAAU,CAAC,CAACE,iBAAiB,CAAC,cAAc,CAAC,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './PluginEditor';
2
+ export * from './plugin-editor-api';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/index.ts"],"names":[],"mappings":"AAaA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,16 @@
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
+ export * from './PluginEditor';
14
+ export * from './plugin-editor-api';
15
+
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/PluginEditor/index.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './PluginEditor';\nexport * from './plugin-editor-api';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /// <reference types="react" />
2
+ import { BoxProps } from '@mui/material';
3
+ import { Definition, UnknownSpec } from '@perses-dev/core';
4
+ import { PluginType } from '../../model';
5
+ declare type OmittedMuiProps = 'children' | 'value' | 'onChange';
6
+ export interface PluginEditorProps extends Omit<BoxProps, OmittedMuiProps> {
7
+ pluginType: PluginType;
8
+ pluginKindLabel: string;
9
+ value: Definition<UnknownSpec>;
10
+ onChange: (next: Definition<UnknownSpec>) => void;
11
+ }
12
+ /**
13
+ * Props needed by the usePluginEditor hook.
14
+ */
15
+ export declare type UsePluginEditorProps = Pick<PluginEditorProps, 'pluginType' | 'value' | 'onChange'>;
16
+ /**
17
+ * Returns the state/handlers that power the `PluginEditor` component. Useful for custom components that want to provide
18
+ * a different UI, but want the same behavior of changing `kind` and `spec` together on plugin kind changes. Also
19
+ * remembers previous `spec` values that it's seen, allowing and restores those values if a user switches the plugin
20
+ * kind back.
21
+ */
22
+ export declare function usePluginEditor(props: UsePluginEditorProps): {
23
+ pendingKind: string;
24
+ isLoading: boolean;
25
+ error: Error | null;
26
+ onKindChange: (event: import("@mui/material").SelectChangeEvent<string>, child: import("react").ReactNode) => void;
27
+ onSpecChange: (next: UnknownSpec) => void;
28
+ };
29
+ export {};
30
+ //# sourceMappingURL=plugin-editor-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-editor-api.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/plugin-editor-api.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAY,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,aAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC;IACxE,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/B,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACnD;AAID;;GAEG;AACH,oBAAY,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC,CAAC;AAEhG;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB;;;;;;EA+E1D"}