@perses-dev/dashboards 0.8.1 → 0.10.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 (258) hide show
  1. package/dist/cjs/components/Dashboard.js +25 -14
  2. package/dist/cjs/components/DashboardToolbar.js +148 -20
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +25 -19
  4. package/dist/cjs/components/GridLayout/GridLayout.js +92 -27
  5. package/dist/cjs/components/GridLayout/GridTitle.js +91 -31
  6. package/dist/cjs/components/GridLayout/index.js +18 -19
  7. package/dist/cjs/components/Panel/DeletePanelDialog.js +91 -0
  8. package/dist/cjs/components/Panel/Panel.js +156 -55
  9. package/dist/cjs/components/Panel/Panel.test.js +58 -41
  10. package/dist/cjs/components/Panel/PanelContent.js +41 -12
  11. package/dist/cjs/components/Panel/index.js +16 -17
  12. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +84 -108
  13. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +87 -92
  14. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +194 -0
  15. package/dist/cjs/components/PanelDrawer/PanelPreview.js +48 -0
  16. package/dist/cjs/components/PanelDrawer/index.js +28 -0
  17. package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +86 -0
  18. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +121 -39
  19. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +74 -88
  20. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +120 -38
  21. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +42 -27
  22. package/dist/cjs/components/TimeRangeControls/index.js +16 -17
  23. package/dist/cjs/components/Variables/Variable.js +195 -36
  24. package/dist/cjs/components/Variables/VariableEditor.js +207 -0
  25. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +236 -0
  26. package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
  27. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +88 -0
  28. package/dist/cjs/components/Variables/VariableList.js +81 -13
  29. package/dist/cjs/components/Variables/index.js +18 -18
  30. package/dist/cjs/components/index.js +21 -21
  31. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +70 -0
  32. package/dist/cjs/context/DashboardProvider/common.js +18 -0
  33. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +71 -0
  34. package/dist/cjs/context/DashboardProvider/index.js +29 -0
  35. package/dist/cjs/context/DashboardProvider/layout-slice.js +200 -0
  36. package/dist/cjs/context/DashboardProvider/panel-editing-slice.js +156 -0
  37. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +38 -0
  38. package/dist/cjs/context/DatasourceStoreProvider.js +170 -0
  39. package/dist/cjs/context/QueryStringProvider.js +69 -15
  40. package/dist/cjs/context/TemplateVariableProvider.js +135 -136
  41. package/dist/cjs/context/TimeRangeProvider.js +79 -30
  42. package/dist/cjs/context/index.js +20 -22
  43. package/dist/cjs/css/styles.js +43 -39
  44. package/dist/cjs/index.js +19 -20
  45. package/dist/cjs/test/dashboard-provider.js +51 -0
  46. package/dist/cjs/test/index.js +18 -18
  47. package/dist/cjs/test/plugin-registry.js +52 -25
  48. package/dist/cjs/test/render.js +25 -22
  49. package/dist/cjs/test/setup-tests.js +4 -2
  50. package/dist/cjs/test/testDashboard.js +203 -107
  51. package/dist/cjs/utils/functions.js +9 -5
  52. package/dist/cjs/views/ViewDashboard/DashboardApp.js +49 -23
  53. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +62 -31
  54. package/dist/cjs/views/ViewDashboard/index.js +16 -17
  55. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +165 -0
  56. package/dist/cjs/views/index.js +16 -17
  57. package/dist/components/Dashboard.d.ts +1 -4
  58. package/dist/components/Dashboard.d.ts.map +1 -1
  59. package/dist/components/Dashboard.js +34 -1
  60. package/dist/components/Dashboard.js.map +1 -0
  61. package/dist/components/DashboardToolbar.d.ts.map +1 -1
  62. package/dist/components/DashboardToolbar.js +154 -1
  63. package/dist/components/DashboardToolbar.js.map +1 -0
  64. package/dist/components/GridLayout/GridItemContent.d.ts +3 -3
  65. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  66. package/dist/components/GridLayout/GridItemContent.js +35 -1
  67. package/dist/components/GridLayout/GridItemContent.js.map +1 -0
  68. package/dist/components/GridLayout/GridLayout.d.ts +2 -3
  69. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  70. package/dist/components/GridLayout/GridLayout.js +102 -1
  71. package/dist/components/GridLayout/GridLayout.js.map +1 -0
  72. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  73. package/dist/components/GridLayout/GridTitle.js +99 -1
  74. package/dist/components/GridLayout/GridTitle.js.map +1 -0
  75. package/dist/components/GridLayout/index.js +16 -1
  76. package/dist/components/GridLayout/index.js.map +1 -0
  77. package/dist/components/Panel/DeletePanelDialog.d.ts +5 -0
  78. package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -0
  79. package/dist/components/Panel/DeletePanelDialog.js +80 -0
  80. package/dist/components/Panel/DeletePanelDialog.js.map +1 -0
  81. package/dist/components/Panel/Panel.d.ts +1 -1
  82. package/dist/components/Panel/Panel.d.ts.map +1 -1
  83. package/dist/components/Panel/Panel.js +181 -1
  84. package/dist/components/Panel/Panel.js.map +1 -0
  85. package/dist/components/Panel/Panel.test.js +74 -1
  86. package/dist/components/Panel/Panel.test.js.map +1 -0
  87. package/dist/components/Panel/PanelContent.d.ts +5 -4
  88. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  89. package/dist/components/Panel/PanelContent.js +41 -1
  90. package/dist/components/Panel/PanelContent.js.map +1 -0
  91. package/dist/components/Panel/index.js +15 -1
  92. package/dist/components/Panel/index.js.map +1 -0
  93. package/dist/components/PanelDrawer/PanelDrawer.d.ts +4 -2
  94. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  95. package/dist/components/PanelDrawer/PanelDrawer.js +96 -1
  96. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -0
  97. package/dist/components/PanelDrawer/PanelDrawer.test.js +99 -1
  98. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -0
  99. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +12 -0
  100. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -0
  101. package/dist/components/PanelDrawer/PanelEditorForm.js +184 -0
  102. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -0
  103. package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
  104. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
  105. package/dist/components/PanelDrawer/PanelPreview.js +42 -0
  106. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
  107. package/dist/components/PanelDrawer/index.d.ts +2 -0
  108. package/dist/components/PanelDrawer/index.d.ts.map +1 -0
  109. package/dist/components/PanelDrawer/index.js +15 -0
  110. package/dist/components/PanelDrawer/index.js.map +1 -0
  111. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +4 -0
  112. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
  113. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +75 -0
  114. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
  115. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  116. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +131 -1
  117. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
  118. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +74 -1
  119. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -0
  120. package/dist/components/TimeRangeControls/TimeRangeControls.js +137 -1
  121. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
  122. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +59 -1
  123. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -0
  124. package/dist/components/TimeRangeControls/index.js +15 -1
  125. package/dist/components/TimeRangeControls/index.js.map +1 -0
  126. package/dist/components/Variables/Variable.d.ts.map +1 -1
  127. package/dist/components/Variables/Variable.js +210 -1
  128. package/dist/components/Variables/Variable.js.map +1 -0
  129. package/dist/components/Variables/VariableEditor.d.ts +8 -0
  130. package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
  131. package/dist/components/Variables/VariableEditor.js +196 -0
  132. package/dist/components/Variables/VariableEditor.js.map +1 -0
  133. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
  134. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
  135. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +225 -0
  136. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
  137. package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
  138. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
  139. package/dist/components/Variables/VariableEditorForm/index.js +15 -0
  140. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
  141. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +21 -0
  142. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
  143. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +76 -0
  144. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
  145. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  146. package/dist/components/Variables/VariableList.js +84 -1
  147. package/dist/components/Variables/VariableList.js.map +1 -0
  148. package/dist/components/Variables/index.d.ts +1 -0
  149. package/dist/components/Variables/index.d.ts.map +1 -1
  150. package/dist/components/Variables/index.js +17 -1
  151. package/dist/components/Variables/index.js.map +1 -0
  152. package/dist/components/index.d.ts +1 -0
  153. package/dist/components/index.d.ts.map +1 -1
  154. package/dist/components/index.js +20 -1
  155. package/dist/components/index.js.map +1 -0
  156. package/dist/context/DashboardProvider/DashboardProvider.d.ts +23 -0
  157. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
  158. package/dist/context/DashboardProvider/DashboardProvider.js +52 -0
  159. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
  160. package/dist/context/DashboardProvider/common.d.ts +5 -0
  161. package/dist/context/DashboardProvider/common.d.ts.map +1 -0
  162. package/dist/context/DashboardProvider/common.js +17 -0
  163. package/dist/context/DashboardProvider/common.js.map +1 -0
  164. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +32 -0
  165. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
  166. package/dist/context/DashboardProvider/dashboard-provider-api.js +56 -0
  167. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
  168. package/dist/context/DashboardProvider/index.d.ts +3 -0
  169. package/dist/context/DashboardProvider/index.d.ts.map +1 -0
  170. package/dist/context/DashboardProvider/index.js +16 -0
  171. package/dist/context/DashboardProvider/index.js.map +1 -0
  172. package/dist/context/DashboardProvider/layout-slice.d.ts +57 -0
  173. package/dist/context/DashboardProvider/layout-slice.d.ts.map +1 -0
  174. package/dist/context/DashboardProvider/layout-slice.js +196 -0
  175. package/dist/context/DashboardProvider/layout-slice.js.map +1 -0
  176. package/dist/context/DashboardProvider/panel-editing-slice.d.ts +70 -0
  177. package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +1 -0
  178. package/dist/context/DashboardProvider/panel-editing-slice.js +152 -0
  179. package/dist/context/DashboardProvider/panel-editing-slice.js.map +1 -0
  180. package/dist/context/DashboardProvider/panel-group-slice.d.ts +15 -0
  181. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
  182. package/dist/context/DashboardProvider/panel-group-slice.js +32 -0
  183. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
  184. package/dist/context/DatasourceStoreProvider.d.ts +24 -0
  185. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -0
  186. package/dist/context/DatasourceStoreProvider.js +166 -0
  187. package/dist/context/DatasourceStoreProvider.js.map +1 -0
  188. package/dist/context/QueryStringProvider.js +40 -1
  189. package/dist/context/QueryStringProvider.js.map +1 -0
  190. package/dist/context/TemplateVariableProvider.d.ts +8 -3
  191. package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
  192. package/dist/context/TemplateVariableProvider.js +199 -1
  193. package/dist/context/TemplateVariableProvider.js.map +1 -0
  194. package/dist/context/TimeRangeProvider.js +72 -1
  195. package/dist/context/TimeRangeProvider.js.map +1 -0
  196. package/dist/context/index.d.ts +3 -4
  197. package/dist/context/index.d.ts.map +1 -1
  198. package/dist/context/index.js +19 -1
  199. package/dist/context/index.js.map +1 -0
  200. package/dist/css/styles.js +186 -1
  201. package/dist/css/styles.js.map +1 -0
  202. package/dist/index.js +17 -1
  203. package/dist/index.js.map +1 -0
  204. package/dist/test/dashboard-provider.d.ts +19 -0
  205. package/dist/test/dashboard-provider.d.ts.map +1 -0
  206. package/dist/test/dashboard-provider.js +40 -0
  207. package/dist/test/dashboard-provider.js.map +1 -0
  208. package/dist/test/index.d.ts +1 -0
  209. package/dist/test/index.d.ts.map +1 -1
  210. package/dist/test/index.js +17 -1
  211. package/dist/test/index.js.map +1 -0
  212. package/dist/test/plugin-registry.d.ts +3 -4
  213. package/dist/test/plugin-registry.d.ts.map +1 -1
  214. package/dist/test/plugin-registry.js +74 -1
  215. package/dist/test/plugin-registry.js.map +1 -0
  216. package/dist/test/render.d.ts +1 -2
  217. package/dist/test/render.d.ts.map +1 -1
  218. package/dist/test/render.js +34 -1
  219. package/dist/test/render.js.map +1 -0
  220. package/dist/test/setup-tests.js +18 -1
  221. package/dist/test/setup-tests.js.map +1 -0
  222. package/dist/test/testDashboard.d.ts.map +1 -1
  223. package/dist/test/testDashboard.js +286 -1
  224. package/dist/test/testDashboard.js.map +1 -0
  225. package/dist/utils/functions.js +17 -1
  226. package/dist/utils/functions.js.map +1 -0
  227. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  228. package/dist/views/ViewDashboard/DashboardApp.js +55 -1
  229. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -0
  230. package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -0
  231. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  232. package/dist/views/ViewDashboard/ViewDashboard.js +79 -1
  233. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -0
  234. package/dist/views/ViewDashboard/index.js +15 -1
  235. package/dist/views/ViewDashboard/index.js.map +1 -0
  236. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
  237. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
  238. package/dist/views/ViewDashboard/tests/panelGroups.test.js +158 -0
  239. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
  240. package/dist/views/index.js +15 -1
  241. package/dist/views/index.js.map +1 -0
  242. package/package.json +13 -7
  243. package/dist/cjs/components/PanelDrawer/PanelOptionsEditor.js +0 -19
  244. package/dist/cjs/context/DashboardAppSlice.js +0 -45
  245. package/dist/cjs/context/DashboardProvider.js +0 -98
  246. package/dist/cjs/context/LayoutsSlice.js +0 -42
  247. package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts +0 -9
  248. package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts.map +0 -1
  249. package/dist/components/PanelDrawer/PanelOptionsEditor.js +0 -1
  250. package/dist/context/DashboardAppSlice.d.ts +0 -26
  251. package/dist/context/DashboardAppSlice.d.ts.map +0 -1
  252. package/dist/context/DashboardAppSlice.js +0 -1
  253. package/dist/context/DashboardProvider.d.ts +0 -34
  254. package/dist/context/DashboardProvider.d.ts.map +0 -1
  255. package/dist/context/DashboardProvider.js +0 -1
  256. package/dist/context/LayoutsSlice.d.ts +0 -12
  257. package/dist/context/LayoutsSlice.d.ts.map +0 -1
  258. package/dist/context/LayoutsSlice.js +0 -1
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsx_runtime_1 = require("react/jsx-runtime");
4
1
  // Copyright 2022 The Perses Authors
5
2
  // Licensed under the Apache License, Version 2.0 (the "License");
6
3
  // you may not use this file except in compliance with the License.
@@ -13,112 +10,91 @@ const jsx_runtime_1 = require("react/jsx-runtime");
13
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
11
  // See the License for the specific language governing permissions and
15
12
  // limitations under the License.
16
- const material_1 = require("@mui/material");
17
- const components_1 = require("@perses-dev/components");
18
- const plugin_system_1 = require("@perses-dev/plugin-system");
19
- const react_1 = require("react");
20
- const context_1 = require("../../context");
21
- const functions_1 = require("../../utils/functions");
22
- const PanelOptionsEditor_1 = require("./PanelOptionsEditor");
23
- const PanelDrawer = () => {
24
- var _a, _b, _c, _d;
25
- const { layouts } = (0, context_1.useLayouts)();
26
- const { panels, updatePanel } = (0, context_1.usePanels)();
27
- const { panelDrawer, closePanelDrawer } = (0, context_1.useDashboardApp)();
28
- let defaultPanelName = '';
29
- let defaultDescription = '';
30
- if (panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.panelKey) {
31
- // editing an existing panel
32
- defaultPanelName = (_b = (_a = panels[panelDrawer.panelKey]) === null || _a === void 0 ? void 0 : _a.display.name) !== null && _b !== void 0 ? _b : '';
33
- defaultDescription = (_d = (_c = panels[panelDrawer.panelKey]) === null || _c === void 0 ? void 0 : _c.display.description) !== null && _d !== void 0 ? _d : '';
34
- }
35
- const [group, setGroup] = (0, react_1.useState)(panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.groupIndex);
36
- const [panelName, setPanelName] = (0, react_1.useState)(defaultPanelName);
37
- const [panelDescription, setPanelDescription] = (0, react_1.useState)(defaultDescription);
38
- const [kind, setKind] = (0, react_1.useState)('');
39
- const [options, setOptions] = (0, react_1.useState)({});
40
- // TO DO: we might want to make the form a sub component we don't need this useEffect
41
- // currently, we need to reset the states whenever panelDrawer is reopened
42
- // since this component does not get remounted when it open/closes (otherwise we lose the animation of sliding in/out)
43
- (0, react_1.useEffect)(() => {
44
- var _a, _b, _c, _d;
45
- setGroup(panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.groupIndex);
46
- if (panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.panelKey) {
47
- // display panel name and description in text fields when editing an existing panel
48
- setPanelName((_b = (_a = panels[panelDrawer.panelKey]) === null || _a === void 0 ? void 0 : _a.display.name) !== null && _b !== void 0 ? _b : '');
49
- setPanelDescription((_d = (_c = panels[panelDrawer.panelKey]) === null || _c === void 0 ? void 0 : _c.display.description) !== null && _d !== void 0 ? _d : '');
50
- }
51
- else {
52
- setPanelName('');
53
- setPanelDescription('');
54
- }
55
- }, [panelDrawer, panels]);
56
- const handleGroupChange = (e) => {
57
- const { value } = e.target;
58
- // Handle string (which would be empty string but shouldn't happen since we don't allow a "None" option) by
59
- // just ignoring it
60
- if (typeof value === 'string')
61
- return;
62
- setGroup(value);
63
- };
64
- const handlePanelNameChange = (e) => {
65
- setPanelName(e.target.value);
66
- };
67
- const handlePanelDescriptionChange = (e) => {
68
- setPanelDescription(e.target.value);
69
- };
70
- const handleKindChange = (e) => {
71
- setKind(e.target.value);
72
- };
73
- const handleOptionsChange = (next) => {
74
- setOptions(next);
75
- };
76
- const handleSubmit = (e) => {
77
- e.preventDefault();
78
- if ((panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.groupIndex) !== undefined && !(panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.panelKey)) {
79
- addNewPanel();
80
- }
81
- else if (panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.panelKey) {
82
- editPanel();
83
- }
84
- closePanelDrawer();
85
- };
86
- const addNewPanel = () => {
87
- if ((panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.groupIndex) === undefined) {
88
- return;
89
- }
90
- const panelKey = (0, functions_1.removeWhiteSpacesAndSpecialCharacters)(panelName);
91
- updatePanel(panelKey, {
92
- kind,
93
- options,
94
- display: { name: panelName, description: panelDescription },
95
- }, panelDrawer.groupIndex);
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "PanelDrawer", {
18
+ enumerable: true,
19
+ get: ()=>PanelDrawer
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = require("react");
23
+ const _material = require("@mui/material");
24
+ const _components = require("@perses-dev/components");
25
+ const _context = require("../../context");
26
+ const _panelEditorForm = require("./PanelEditorForm");
27
+ const PanelDrawer = ()=>{
28
+ const { panelEditor } = (0, _context.usePanels)();
29
+ // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
30
+ const [isClosing, setIsClosing] = (0, _react.useState)(false);
31
+ const handleClose = ()=>setIsClosing(true);
32
+ // Don't call closeDrawer on the store until the Drawer has completely transitioned out
33
+ const handleExited = ()=>{
34
+ panelEditor === null || panelEditor === void 0 ? void 0 : panelEditor.close();
35
+ setIsClosing(false);
96
36
  };
97
- const editPanel = () => {
98
- if ((panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.panelKey) === undefined) {
99
- return;
37
+ // Drawer is open if we have a model and we're not transitioning out
38
+ const isOpen = panelEditor !== undefined && isClosing === false;
39
+ const handleSubmit = (values)=>{
40
+ // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy
41
+ if (panelEditor === undefined) {
42
+ throw new Error('Cannot apply changes');
100
43
  }
101
- updatePanel(panelDrawer.panelKey, {
102
- ...panels[panelDrawer.panelKey],
103
- kind,
104
- options,
105
- display: { name: panelName !== null && panelName !== void 0 ? panelName : '', description: panelDescription },
106
- });
107
- // TO DO: need to move panel if panel group changes
44
+ panelEditor.applyChanges(values);
45
+ handleClose();
108
46
  };
109
- return ((0, jsx_runtime_1.jsx)(components_1.Drawer, { isOpen: !!panelDrawer, onClose: () => closePanelDrawer(), children: (0, jsx_runtime_1.jsxs)("form", { onSubmit: handleSubmit, children: [(0, jsx_runtime_1.jsx)(PanelDrawerHeader, { panelKey: panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.panelKey, onClose: () => closePanelDrawer() }), (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, spacing: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "select-group", children: "Group" }), (0, jsx_runtime_1.jsx)(material_1.Select, { required: true, labelId: "select-group", label: "Group", value: group !== null && group !== void 0 ? group : 0, onChange: handleGroupChange, children: layouts.map((layout, index) => {
110
- var _a;
111
- return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: index, children: ((_a = layout.spec.display) === null || _a === void 0 ? void 0 : _a.title) || `Group ${index + 1}` }, index));
112
- }) })] }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 8, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 2, sx: { flexGrow: '1' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, label: "Panel Name", value: panelName, variant: "outlined", onChange: handlePanelNameChange }), (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Description", value: panelDescription, variant: "outlined", onChange: handlePanelDescriptionChange })] }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { id: "panel-type-label", children: "Panel Type" }), (0, jsx_runtime_1.jsxs)(material_1.Select, { required: true, labelId: "panel-type-label", label: "Panel Type", value: kind, onChange: handleKindChange, children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: "LineChart", children: "Line Chart" }), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: "GaugeChart", children: "Gauge Chart" }), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: "StatChart", children: "Stat Chart" })] })] }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 8, children: (0, jsx_runtime_1.jsx)(plugin_system_1.PluginBoundary, { loadingFallback: "Loading...", ErrorFallbackComponent: components_1.ErrorAlert, children: kind !== '' && (0, jsx_runtime_1.jsx)(PanelOptionsEditor_1.PanelOptionsEditor, { kind: kind, value: options, onChange: handleOptionsChange }) }) })] })] }) }));
113
- };
114
- const PanelDrawerHeader = ({ panelKey, onClose }) => {
115
- const action = panelKey ? 'Edit' : 'Add';
116
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
117
- display: 'flex',
118
- alignItems: 'center',
119
- marginBottom: (theme) => theme.spacing(2),
120
- paddingBottom: (theme) => theme.spacing(2),
121
- borderBottom: (theme) => `1px solid ${theme.palette.grey[100]}`,
122
- }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h2", children: `${action} Panel` }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, sx: { marginLeft: 'auto' }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { type: "submit", variant: "contained", children: panelKey ? 'Apply' : 'Add' }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", onClick: onClose, children: "Cancel" })] })] }));
47
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Drawer, {
48
+ isOpen: isOpen,
49
+ onClose: handleClose,
50
+ SlideProps: {
51
+ onExited: handleExited
52
+ },
53
+ children: panelEditor !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
54
+ children: [
55
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
56
+ sx: {
57
+ display: 'flex',
58
+ alignItems: 'center',
59
+ marginBottom: (theme)=>theme.spacing(2),
60
+ paddingBottom: (theme)=>theme.spacing(2),
61
+ borderBottom: (theme)=>`1px solid ${theme.palette.grey[100]}`
62
+ },
63
+ children: [
64
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Typography, {
65
+ variant: "h2",
66
+ children: [
67
+ panelEditor.mode,
68
+ " Panel"
69
+ ]
70
+ }),
71
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
72
+ direction: "row",
73
+ spacing: 1,
74
+ sx: {
75
+ marginLeft: 'auto'
76
+ },
77
+ children: [
78
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
79
+ type: "submit",
80
+ variant: "contained",
81
+ form: _panelEditorForm.panelEditorFormId,
82
+ children: panelEditor.mode === 'Add' ? 'Add' : 'Apply'
83
+ }),
84
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
85
+ variant: "outlined",
86
+ onClick: handleClose,
87
+ children: "Cancel"
88
+ })
89
+ ]
90
+ })
91
+ ]
92
+ }),
93
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelEditorForm.PanelEditorForm, {
94
+ onSubmit: handleSubmit,
95
+ initialValues: panelEditor.initialValues
96
+ })
97
+ ]
98
+ })
99
+ });
123
100
  };
124
- exports.default = PanelDrawer;
@@ -1,32 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const jsx_runtime_1 = require("react/jsx-runtime");
30
1
  // Copyright 2022 The Perses Authors
31
2
  // Licensed under the Apache License, Version 2.0 (the "License");
32
3
  // you may not use this file except in compliance with the License.
@@ -39,73 +10,97 @@ const jsx_runtime_1 = require("react/jsx-runtime");
39
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40
11
  // See the License for the specific language governing permissions and
41
12
  // limitations under the License.
42
- const plugin_system_1 = require("@perses-dev/plugin-system");
43
- const react_1 = require("@testing-library/react");
44
- const user_event_1 = __importDefault(require("@testing-library/user-event"));
45
- const dashboardAppSlice = __importStar(require("../../context/DashboardAppSlice"));
46
- const layoutsSlice = __importStar(require("../../context/LayoutsSlice"));
47
- const context = __importStar(require("../../context/DashboardProvider"));
48
- const test_1 = require("../../test");
49
- const testDashboard_1 = __importDefault(require("../../test/testDashboard"));
50
- const PanelDrawer_1 = __importDefault(require("./PanelDrawer"));
51
- const updatePanel = jest.fn();
52
- jest.spyOn(context, 'usePanels').mockReturnValue({
53
- updatePanel,
54
- panels: {},
55
- });
56
- const addItemToLayout = jest.fn();
57
- jest.spyOn(layoutsSlice, 'useLayouts').mockReturnValue({
58
- addItemToLayout,
59
- updateLayout: jest.fn(),
60
- layouts: testDashboard_1.default.spec.layouts,
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
61
16
  });
62
- const dashboardApp = {
63
- panelDrawer: {
64
- groupIndex: 0,
65
- },
66
- openPanelDrawer: jest.fn(),
67
- closePanelDrawer: jest.fn(),
68
- panelGroupDialog: undefined,
69
- openPanelGroupDialog: jest.fn(),
70
- closePanelGroupDialog: jest.fn(),
71
- };
72
- describe('Panel Drawer', () => {
73
- beforeEach(() => {
74
- jest.clearAllMocks();
75
- });
76
- const renderPanelDrawer = () => {
77
- const { addMockPlugin, pluginRegistryProps } = (0, test_1.mockPluginRegistryProps)();
78
- addMockPlugin('Panel', 'FakePanel', test_1.FAKE_PANEL_PLUGIN);
79
- (0, test_1.renderWithContext)((0, jsx_runtime_1.jsxs)(plugin_system_1.PluginRegistry, { ...pluginRegistryProps, children: [(0, jsx_runtime_1.jsx)(PanelDrawer_1.default, {}), ","] }));
17
+ const _jsxRuntime = require("react/jsx-runtime");
18
+ const _pluginSystem = require("@perses-dev/plugin-system");
19
+ const _react = require("@testing-library/react");
20
+ const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
21
+ const _testUtils = require("react-dom/test-utils");
22
+ const _test = require("../../test");
23
+ const _dashboardProvider = require("../../context/DashboardProvider");
24
+ const _panelDrawer = require("./PanelDrawer");
25
+ function _interopRequireDefault(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
30
+ describe('Panel Drawer', ()=>{
31
+ const renderPanelDrawer = ()=>{
32
+ const { addMockPlugin , pluginRegistryProps } = (0, _test.mockPluginRegistryProps)();
33
+ addMockPlugin('Panel', 'TimeSeriesChart', _test.FAKE_PANEL_PLUGIN);
34
+ const { store , DashboardProviderSpy } = (0, _test.createDashboardProviderSpy)();
35
+ (0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
36
+ ...pluginRegistryProps,
37
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_dashboardProvider.DashboardProvider, {
38
+ initialState: {
39
+ dashboardSpec: (0, _test.getTestDashboard)().spec,
40
+ isEditMode: true
41
+ },
42
+ children: [
43
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardProviderSpy, {}),
44
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelDrawer.PanelDrawer, {})
45
+ ]
46
+ })
47
+ }));
48
+ const { value: storeApi } = store;
49
+ if (storeApi === undefined) {
50
+ throw new Error('Expected dashboard store to be set after initial render');
51
+ }
52
+ return storeApi;
80
53
  };
81
- it('should add new panel', () => {
82
- jest.spyOn(dashboardAppSlice, 'useDashboardApp').mockReturnValue(dashboardApp);
83
- renderPanelDrawer();
84
- const nameInput = react_1.screen.getByLabelText(/Panel Name/);
85
- user_event_1.default.type(nameInput, 'New Panel');
86
- user_event_1.default.click(react_1.screen.getByText('Add'));
87
- expect(updatePanel).toHaveBeenCalledWith('NewPanel', {
88
- kind: '',
89
- display: { name: 'New Panel', description: '' },
90
- options: {},
91
- }, 0);
54
+ it('should add new panel', async ()=>{
55
+ const storeApi = renderPanelDrawer();
56
+ // Open the drawer for a new panel (i.e. no panel key)
57
+ (0, _testUtils.act)(()=>storeApi.getState().addPanel(0));
58
+ const nameInput = await _react.screen.findByLabelText(/Name/);
59
+ _userEvent.default.type(nameInput, 'New Panel');
60
+ _userEvent.default.click(_react.screen.getByText('Add'));
61
+ // TODO: Assert drawer is closed?
62
+ const panels = storeApi.getState().panels;
63
+ expect(panels).toMatchObject({
64
+ // Should have the new panel in the store
65
+ NewPanel: {
66
+ kind: 'Panel',
67
+ spec: {
68
+ display: {
69
+ name: 'New Panel'
70
+ },
71
+ plugin: {
72
+ kind: '',
73
+ spec: {}
74
+ }
75
+ }
76
+ }
77
+ });
92
78
  });
93
- it('should edit an existing panel', () => {
94
- jest.spyOn(dashboardAppSlice, 'useDashboardApp').mockReturnValue({
95
- ...dashboardApp,
96
- panelDrawer: {
79
+ it('should edit an existing panel', async ()=>{
80
+ const storeApi = renderPanelDrawer();
81
+ // Open the drawer for an existing panel
82
+ (0, _testUtils.act)(()=>storeApi.getState().editPanel({
97
83
  groupIndex: 0,
98
- panelKey: 'cpu',
99
- },
100
- });
101
- renderPanelDrawer();
102
- const nameInput = react_1.screen.getByLabelText(/Panel Name/);
103
- user_event_1.default.type(nameInput, 'cpu usage');
104
- user_event_1.default.click(react_1.screen.getByText('Apply'));
105
- expect(updatePanel).toHaveBeenCalledWith('cpu', {
106
- display: { name: 'cpu usage', description: '' },
107
- kind: '',
108
- options: {},
84
+ itemIndex: 0
85
+ }));
86
+ const nameInput = await _react.screen.findByLabelText(/Name/);
87
+ _userEvent.default.clear(nameInput);
88
+ _userEvent.default.type(nameInput, 'cpu usage');
89
+ _userEvent.default.click(_react.screen.getByText('Apply'));
90
+ const panels = storeApi.getState().panels;
91
+ expect(panels).toMatchObject({
92
+ cpu: {
93
+ kind: 'Panel',
94
+ spec: {
95
+ display: {
96
+ name: 'cpu usage'
97
+ },
98
+ plugin: {
99
+ kind: 'TimeSeriesChart',
100
+ spec: {}
101
+ }
102
+ }
103
+ }
109
104
  });
110
105
  });
111
106
  });
@@ -0,0 +1,194 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ PanelEditorForm: ()=>PanelEditorForm,
25
+ panelEditorFormId: ()=>panelEditorFormId
26
+ });
27
+ const _jsxRuntime = require("react/jsx-runtime");
28
+ const _react = require("react");
29
+ const _material = require("@mui/material");
30
+ const _components = require("@perses-dev/components");
31
+ const _pluginSystem = require("@perses-dev/plugin-system");
32
+ const _context = require("../../context");
33
+ const _panelPreview = require("./PanelPreview");
34
+ function PanelEditorForm(props) {
35
+ var ref;
36
+ const { initialValues , onSubmit } = props;
37
+ const { layouts } = (0, _context.useLayouts)();
38
+ const [name, setName] = (0, _react.useState)(initialValues.name);
39
+ const [description, setDescription] = (0, _react.useState)(initialValues.description);
40
+ const [groupIndex, setGroupIndex] = (0, _react.useState)(initialValues.groupIndex);
41
+ const [kind, setKind] = (0, _react.useState)(initialValues.kind);
42
+ const [spec, setSpec] = (0, _react.useState)(initialValues.spec);
43
+ // Use common plugin editor logic even though we've split the inputs up in this form
44
+ const pluginEditor = (0, _pluginSystem.usePluginEditor)({
45
+ pluginType: 'Panel',
46
+ value: {
47
+ kind,
48
+ spec
49
+ },
50
+ onChange: (plugin)=>{
51
+ setKind(plugin.kind);
52
+ setSpec(plugin.spec);
53
+ }
54
+ });
55
+ // Ignore string values (which would be an "empty" value from the Select) since we don't allow them to unset it
56
+ const handleGroupChange = (e)=>{
57
+ const { value } = e.target;
58
+ if (typeof value === 'string') {
59
+ return;
60
+ }
61
+ setGroupIndex(value);
62
+ };
63
+ const handleSubmit = (e)=>{
64
+ e.preventDefault();
65
+ if (spec === undefined) {
66
+ throw new Error('Cannot submit without a plugin spec');
67
+ }
68
+ const values = {
69
+ name,
70
+ description,
71
+ groupIndex,
72
+ kind,
73
+ spec
74
+ };
75
+ onSubmit(values);
76
+ };
77
+ var _title, ref1;
78
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)("form", {
79
+ id: panelEditorFormId,
80
+ onSubmit: handleSubmit,
81
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
82
+ container: true,
83
+ spacing: 2,
84
+ children: [
85
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
86
+ item: true,
87
+ xs: 8,
88
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
89
+ required: true,
90
+ label: "Name",
91
+ value: name,
92
+ variant: "outlined",
93
+ onChange: (e)=>setName(e.target.value)
94
+ })
95
+ }),
96
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
97
+ item: true,
98
+ xs: 4,
99
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
100
+ children: [
101
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
102
+ id: "select-group",
103
+ children: "Group"
104
+ }),
105
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Select, {
106
+ required: true,
107
+ labelId: "select-group",
108
+ label: "Group",
109
+ value: groupIndex !== null && groupIndex !== void 0 ? groupIndex : 0,
110
+ onChange: handleGroupChange,
111
+ children: layouts.map((layout, index)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
112
+ value: index,
113
+ children: (_title = layout.title) !== null && _title !== void 0 ? _title : `Group ${index + 1}`
114
+ }, index))
115
+ })
116
+ ]
117
+ })
118
+ }),
119
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
120
+ item: true,
121
+ xs: 8,
122
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
123
+ label: "Description",
124
+ value: description,
125
+ variant: "outlined",
126
+ onChange: (e)=>setDescription(e.target.value)
127
+ })
128
+ }),
129
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
130
+ item: true,
131
+ xs: 4,
132
+ children: [
133
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
134
+ disabled: pluginEditor.isLoading,
135
+ error: pluginEditor.error !== null,
136
+ children: [
137
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
138
+ id: "panel-type-label",
139
+ children: "Type"
140
+ }),
141
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginKindSelect, {
142
+ pluginType: "Panel",
143
+ required: true,
144
+ labelId: "panel-type-label",
145
+ label: "Type",
146
+ value: pluginEditor.pendingKind ? pluginEditor.pendingKind : kind,
147
+ onChange: pluginEditor.onKindChange
148
+ })
149
+ ]
150
+ }),
151
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormHelperText, {
152
+ children: (ref1 = (ref = pluginEditor.error) === null || ref === void 0 ? void 0 : ref.message) !== null && ref1 !== void 0 ? ref1 : ''
153
+ })
154
+ ]
155
+ }),
156
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
157
+ item: true,
158
+ xs: 12,
159
+ children: [
160
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
161
+ variant: "h4",
162
+ marginBottom: 1,
163
+ children: "Preview"
164
+ }),
165
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
166
+ FallbackComponent: _components.ErrorAlert,
167
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelPreview.PanelPreview, {
168
+ kind: kind,
169
+ name: name,
170
+ description: description,
171
+ spec: spec,
172
+ groupIndex: groupIndex
173
+ })
174
+ })
175
+ ]
176
+ }),
177
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
178
+ item: true,
179
+ xs: 12,
180
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
181
+ FallbackComponent: _components.ErrorAlert,
182
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginSpecEditor, {
183
+ pluginType: "Panel",
184
+ pluginKind: kind,
185
+ value: spec,
186
+ onChange: pluginEditor.onSpecChange
187
+ })
188
+ })
189
+ })
190
+ ]
191
+ })
192
+ });
193
+ }
194
+ const panelEditorFormId = 'panel-editor-form';
@@ -0,0 +1,48 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "PanelPreview", {
18
+ enumerable: true,
19
+ get: ()=>PanelPreview
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const _panel = require("../Panel");
24
+ function PanelPreview({ name , description , kind , spec , groupIndex }) {
25
+ const previewValues = {
26
+ definition: {
27
+ kind: 'Panel',
28
+ spec: {
29
+ display: {
30
+ name,
31
+ description
32
+ },
33
+ plugin: {
34
+ kind,
35
+ spec
36
+ }
37
+ }
38
+ },
39
+ groupIndex,
40
+ itemIndex: 0
41
+ };
42
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
43
+ height: 300,
44
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
45
+ ...previewValues
46
+ })
47
+ });
48
+ }