@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
@@ -0,0 +1,28 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./PanelDrawer"), exports);
18
+ function _exportStar(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ });
27
+ return from;
28
+ }
@@ -0,0 +1,86 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "default", {
18
+ enumerable: true,
19
+ get: ()=>_default
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const _close = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Close"));
24
+ const _context = require("../../context");
25
+ function _interopRequireDefault(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
30
+ const DeletePanelGroupDialog = ()=>{
31
+ var ref;
32
+ const { layouts , deletePanelGroup } = (0, _context.useLayouts)();
33
+ const { deletePanelGroupDialog , closeDeletePanelGroupDialog } = (0, _context.usePanelGroupDialog)();
34
+ const groupIndex = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.groupIndex;
35
+ const handleDelete = (e)=>{
36
+ e.preventDefault();
37
+ if (groupIndex == undefined) {
38
+ throw new Error('group index is undefined');
39
+ }
40
+ deletePanelGroup(groupIndex);
41
+ closeDeletePanelGroupDialog();
42
+ };
43
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Dialog, {
44
+ open: deletePanelGroupDialog !== undefined,
45
+ children: [
46
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogTitle, {
47
+ children: "Delete Panel Group"
48
+ }),
49
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
50
+ "aria-label": "Close",
51
+ onClick: ()=>closeDeletePanelGroupDialog(),
52
+ sx: (theme)=>({
53
+ position: 'absolute',
54
+ top: theme.spacing(0.5),
55
+ right: theme.spacing(0.5)
56
+ }),
57
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_close.default, {})
58
+ }),
59
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)("form", {
60
+ onSubmit: handleDelete,
61
+ children: [
62
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogContent, {
63
+ sx: {
64
+ width: '500px'
65
+ },
66
+ children: `Are you sure you want to delete ${groupIndex !== undefined && layouts[groupIndex] !== undefined ? (ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.title : 'panel group'}? This will delete all the panels within the group.`
67
+ }),
68
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
69
+ children: [
70
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
71
+ variant: "contained",
72
+ type: "submit",
73
+ children: "Delete"
74
+ }),
75
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
76
+ onClick: ()=>closeDeletePanelGroupDialog(),
77
+ children: "Cancel"
78
+ })
79
+ ]
80
+ })
81
+ ]
82
+ })
83
+ ]
84
+ });
85
+ };
86
+ const _default = DeletePanelGroupDialog;
@@ -1,9 +1,3 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const jsx_runtime_1 = require("react/jsx-runtime");
7
1
  // Copyright 2022 The Perses Authors
8
2
  // Licensed under the Apache License, Version 2.0 (the "License");
9
3
  // you may not use this file except in compliance with the License.
@@ -16,45 +10,133 @@ const jsx_runtime_1 = require("react/jsx-runtime");
16
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
11
  // See the License for the specific language governing permissions and
18
12
  // limitations under the License.
19
- const react_1 = require("react");
20
- const material_1 = require("@mui/material");
21
- const Close_1 = __importDefault(require("mdi-material-ui/Close"));
22
- const context_1 = require("../../context");
23
- const PanelGroupDialog = () => {
24
- var _a, _b, _c, _d, _e;
25
- const { layouts, updateLayout } = (0, context_1.useLayouts)();
26
- const { panelGroupDialog, closePanelGroupDialog } = (0, context_1.useDashboardApp)();
27
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
28
- const { groupIndex } = panelGroupDialog; // PanelGroupDialog is only mounted if panelGroupDialog is defined
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "default", {
18
+ enumerable: true,
19
+ get: ()=>_default
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = require("react");
23
+ const _material = require("@mui/material");
24
+ const _close = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Close"));
25
+ const _context = require("../../context");
26
+ function _interopRequireDefault(obj) {
27
+ return obj && obj.__esModule ? obj : {
28
+ default: obj
29
+ };
30
+ }
31
+ const PanelGroupDialog = ()=>{
32
+ var ref, ref1;
33
+ const { layouts , updatePanelGroup } = (0, _context.useLayouts)();
34
+ const { panelGroupDialog , closePanelGroupDialog } = (0, _context.usePanelGroupDialog)();
35
+ const groupIndex = panelGroupDialog === null || panelGroupDialog === void 0 ? void 0 : panelGroupDialog.groupIndex;
29
36
  const isEditingPanelGroup = groupIndex !== undefined;
30
- const [isCollapsed, setIsCollapsed] = (0, react_1.useState)(isEditingPanelGroup && !((_c = (_b = (_a = layouts[groupIndex]) === null || _a === void 0 ? void 0 : _a.spec.display) === null || _b === void 0 ? void 0 : _b.collapse) === null || _c === void 0 ? void 0 : _c.open));
31
- const [name, setName] = (0, react_1.useState)(isEditingPanelGroup ? (_e = (_d = layouts[groupIndex]) === null || _d === void 0 ? void 0 : _d.spec.display) === null || _e === void 0 ? void 0 : _e.title : '');
32
- const handleSubmit = (e) => {
33
- var _a, _b;
37
+ const [isCollapsed, setIsCollapsed] = (0, _react.useState)(isEditingPanelGroup && ((ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.isCollapsed));
38
+ const [name, setName] = (0, _react.useState)(isEditingPanelGroup ? (ref1 = layouts[groupIndex]) === null || ref1 === void 0 ? void 0 : ref1.title : '');
39
+ const handleSubmit = (e)=>{
40
+ var ref;
34
41
  e.preventDefault();
35
- const newLayout = {
36
- kind: 'Grid',
37
- spec: {
38
- display: {
39
- title: name !== null && name !== void 0 ? name : '',
40
- collapse: {
41
- open: !isCollapsed,
42
- },
43
- },
44
- items: groupIndex === undefined ? [] : (_b = (_a = layouts[groupIndex]) === null || _a === void 0 ? void 0 : _a.spec.items) !== null && _b !== void 0 ? _b : [],
45
- },
42
+ var ref1;
43
+ const newGroup = {
44
+ isCollapsed,
45
+ title: name !== null && name !== void 0 ? name : '',
46
+ items: groupIndex === undefined ? [] : (ref1 = (ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.items) !== null && ref1 !== void 0 ? ref1 : []
46
47
  };
47
- updateLayout(newLayout, groupIndex);
48
+ updatePanelGroup(newGroup, groupIndex);
48
49
  closePanelGroupDialog();
49
50
  };
50
- const handleSelectCollapsedStateChange = (e) => {
51
+ const handleSelectCollapsedStateChange = (e)=>{
51
52
  const isCollapsed = e.target.value === 'Close';
52
53
  setIsCollapsed(isCollapsed);
53
54
  };
54
- return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { open: true, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { children: "Panel Group" }), (0, jsx_runtime_1.jsx)(material_1.IconButton, { "aria-label": "Close", onClick: () => closePanelGroupDialog(), sx: (theme) => ({
55
- position: 'absolute',
56
- top: theme.spacing(0.5),
57
- right: theme.spacing(0.5),
58
- }), children: (0, jsx_runtime_1.jsx)(Close_1.default, {}) }), (0, jsx_runtime_1.jsxs)("form", { onSubmit: handleSubmit, children: [(0, jsx_runtime_1.jsx)(material_1.DialogContent, { sx: { width: '500px' }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 2, children: [(0, jsx_runtime_1.jsx)(material_1.FormControl, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, label: "Name", variant: "outlined", value: name, onChange: (e) => setName(e.target.value) }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', alignItems: 'center', width: '100%', justifyContent: 'space-between' }, children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: "Collapse State" }), (0, jsx_runtime_1.jsxs)(material_1.Select, { required: true, displayEmpty: true, labelId: "select-collapse-state", size: "small", value: isCollapsed ? 'Close' : 'Open', onChange: handleSelectCollapsedStateChange, children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: 'Open', children: "Open" }, 'open'), (0, jsx_runtime_1.jsx)(material_1.MenuItem, { value: 'Close', children: "Close" }, 'close')] })] })] }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", type: "submit", children: isEditingPanelGroup ? 'Apply' : 'Add' }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: () => closePanelGroupDialog(), children: "Cancel" })] })] })] }));
55
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Dialog, {
56
+ open: panelGroupDialog !== undefined,
57
+ children: [
58
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogTitle, {
59
+ children: "Panel Group"
60
+ }),
61
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
62
+ "aria-label": "Close",
63
+ onClick: ()=>closePanelGroupDialog(),
64
+ sx: (theme)=>({
65
+ position: 'absolute',
66
+ top: theme.spacing(0.5),
67
+ right: theme.spacing(0.5)
68
+ }),
69
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_close.default, {})
70
+ }),
71
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)("form", {
72
+ onSubmit: handleSubmit,
73
+ children: [
74
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogContent, {
75
+ sx: {
76
+ width: '500px'
77
+ },
78
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
79
+ spacing: 2,
80
+ children: [
81
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControl, {
82
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
83
+ required: true,
84
+ label: "Name",
85
+ variant: "outlined",
86
+ value: name,
87
+ onChange: (e)=>setName(e.target.value)
88
+ })
89
+ }),
90
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
91
+ sx: {
92
+ display: 'flex',
93
+ alignItems: 'center',
94
+ width: '100%',
95
+ justifyContent: 'space-between'
96
+ },
97
+ children: [
98
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
99
+ children: "Collapse State"
100
+ }),
101
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Select, {
102
+ required: true,
103
+ displayEmpty: true,
104
+ labelId: "select-collapse-state",
105
+ size: "small",
106
+ value: isCollapsed ? 'Close' : 'Open',
107
+ onChange: handleSelectCollapsedStateChange,
108
+ children: [
109
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
110
+ value: 'Open',
111
+ children: "Open"
112
+ }, 'open'),
113
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
114
+ value: 'Close',
115
+ children: "Close"
116
+ }, 'close')
117
+ ]
118
+ })
119
+ ]
120
+ })
121
+ ]
122
+ })
123
+ }),
124
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
125
+ children: [
126
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
127
+ variant: "contained",
128
+ type: "submit",
129
+ children: isEditingPanelGroup ? 'Apply' : 'Add'
130
+ }),
131
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
132
+ onClick: ()=>closePanelGroupDialog(),
133
+ children: "Cancel"
134
+ })
135
+ ]
136
+ })
137
+ ]
138
+ })
139
+ ]
140
+ });
59
141
  };
60
- exports.default = PanelGroupDialog;
142
+ const _default = PanelGroupDialog;
@@ -1,95 +1,81 @@
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.
1
13
  "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;
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
17
16
  });
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
- const react_1 = require("@testing-library/react");
31
- const user_event_1 = __importDefault(require("@testing-library/user-event"));
32
- const immer_1 = __importDefault(require("immer"));
33
- const dashboardAppSlice = __importStar(require("../../context/DashboardAppSlice"));
34
- const layoutsSlice = __importStar(require("../../context/LayoutsSlice"));
35
- const test_1 = require("../../test");
36
- const testDashboard_1 = __importDefault(require("../../test/testDashboard"));
37
- const PanelGroupDialog_1 = __importDefault(require("./PanelGroupDialog"));
38
- const dashboardApp = {
39
- panelDrawer: undefined,
40
- openPanelDrawer: jest.fn(),
41
- closePanelDrawer: jest.fn(),
42
- panelGroupDialog: {
43
- groupIndex: undefined,
44
- },
45
- openPanelGroupDialog: jest.fn(),
46
- closePanelGroupDialog: jest.fn(),
47
- };
48
- const updateLayout = jest.fn();
49
- jest.spyOn(layoutsSlice, 'useLayouts').mockReturnValue({
50
- updateLayout,
51
- addItemToLayout: jest.fn(),
52
- layouts: testDashboard_1.default.spec.layouts,
53
- });
54
- describe('Add Panel Group', () => {
55
- beforeEach(() => {
56
- jest.clearAllMocks();
57
- });
58
- it('should add new panel group', () => {
59
- jest.spyOn(dashboardAppSlice, 'useDashboardApp').mockReturnValue(dashboardApp);
60
- (0, test_1.renderWithContext)((0, jsx_runtime_1.jsx)(PanelGroupDialog_1.default, {}));
61
- const nameInput = react_1.screen.getByLabelText(/Name/);
62
- user_event_1.default.type(nameInput, 'New Panel Group');
63
- user_event_1.default.click(react_1.screen.getByText('Add'));
64
- expect(updateLayout).toHaveBeenCalledWith({
65
- kind: 'Grid',
66
- spec: {
67
- display: {
68
- title: 'New Panel Group',
69
- collapse: {
70
- open: true,
71
- },
72
- },
73
- items: [],
17
+ const _jsxRuntime = require("react/jsx-runtime");
18
+ const _react = require("@testing-library/react");
19
+ const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
20
+ const _testUtils = require("react-dom/test-utils");
21
+ const _context = require("../../context");
22
+ const _test = require("../../test");
23
+ const _testDashboard = /*#__PURE__*/ _interopRequireDefault(require("../../test/testDashboard"));
24
+ const _panelGroupDialog = /*#__PURE__*/ _interopRequireDefault(require("./PanelGroupDialog"));
25
+ function _interopRequireDefault(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
30
+ describe('Add Panel Group', ()=>{
31
+ const renderDialog = ()=>{
32
+ const { store , DashboardProviderSpy } = (0, _test.createDashboardProviderSpy)();
33
+ (0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_context.DashboardProvider, {
34
+ initialState: {
35
+ dashboardSpec: (0, _test.getTestDashboard)().spec,
36
+ isEditMode: true
74
37
  },
75
- }, undefined);
38
+ children: [
39
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardProviderSpy, {}),
40
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelGroupDialog.default, {})
41
+ ]
42
+ }));
43
+ const { value: storeApi } = store;
44
+ if (storeApi === undefined) {
45
+ throw new Error('Expected dashboard store to be set after initial render');
46
+ }
47
+ return storeApi;
48
+ };
49
+ it('should add new panel group', async ()=>{
50
+ const storeApi = renderDialog();
51
+ // Open the dialog for a new panel group
52
+ (0, _testUtils.act)(()=>storeApi.getState().openPanelGroupDialog());
53
+ const nameInput = await _react.screen.findByLabelText(/Name/);
54
+ _userEvent.default.type(nameInput, 'New Panel Group');
55
+ _userEvent.default.click(_react.screen.getByText('Add'));
56
+ const layouts = storeApi.getState().layouts;
57
+ expect(layouts).toContainEqual({
58
+ id: 3,
59
+ title: 'New Panel Group',
60
+ isCollapsed: false,
61
+ items: []
62
+ });
76
63
  });
77
- it('should edit existing panel group', () => {
78
- jest.spyOn(dashboardAppSlice, 'useDashboardApp').mockReturnValue({
79
- ...dashboardApp,
80
- panelGroupDialog: {
81
- groupIndex: 0,
82
- },
64
+ it('should edit existing panel group', async ()=>{
65
+ var ref;
66
+ const storeApi = renderDialog();
67
+ // Open the dialog for an existing panel group
68
+ (0, _testUtils.act)(()=>storeApi.getState().openPanelGroupDialog(0));
69
+ const nameInput = await _react.screen.findByLabelText(/Name/);
70
+ _userEvent.default.clear(nameInput);
71
+ _userEvent.default.type(nameInput, 'New Name');
72
+ _userEvent.default.click(_react.screen.getByText('Apply'));
73
+ const layouts = storeApi.getState().layouts;
74
+ expect(layouts).toContainEqual({
75
+ id: 0,
76
+ title: 'New Name',
77
+ isCollapsed: false,
78
+ items: (ref = _testDashboard.default.spec.layouts[0]) === null || ref === void 0 ? void 0 : ref.spec.items
83
79
  });
84
- (0, test_1.renderWithContext)((0, jsx_runtime_1.jsx)(PanelGroupDialog_1.default, {}));
85
- const nameInput = react_1.screen.getByLabelText(/Name/);
86
- user_event_1.default.type(nameInput, 'New Name');
87
- user_event_1.default.click(react_1.screen.getByText('Apply'));
88
- expect(updateLayout).toHaveBeenCalledWith((0, immer_1.default)(testDashboard_1.default.spec.layouts[0], (draftState) => {
89
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
90
- draftState.spec.display.title += 'New Name';
91
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
92
- draftState.spec.display.collapse = { open: false };
93
- }), 0);
94
80
  });
95
81
  });
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TimeRangeControls = exports.TIME_OPTIONS = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
1
  // Copyright 2022 The Perses Authors
6
2
  // Licensed under the Apache License, Version 2.0 (the "License");
7
3
  // you may not use this file except in compliance with the License.
@@ -14,53 +10,139 @@ const jsx_runtime_1 = require("react/jsx-runtime");
14
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
11
  // See the License for the specific language governing permissions and
16
12
  // limitations under the License.
17
- const react_1 = require("react");
18
- const material_1 = require("@mui/material");
19
- const components_1 = require("@perses-dev/components");
20
- const core_1 = require("@perses-dev/core");
21
- const plugin_system_1 = require("@perses-dev/plugin-system");
22
- const context_1 = require("../../context");
23
- // TODO: add time shortcut if one does not match duration
24
- exports.TIME_OPTIONS = [
25
- { value: { pastDuration: '5m' }, display: 'Last 5 minutes' },
26
- { value: { pastDuration: '15m' }, display: 'Last 15 minutes' },
27
- { value: { pastDuration: '30m' }, display: 'Last 30 minutes' },
28
- { value: { pastDuration: '1h' }, display: 'Last 1 hour' },
29
- { value: { pastDuration: '6h' }, display: 'Last 6 hours' },
30
- { value: { pastDuration: '12h' }, display: 'Last 12 hours' },
31
- { value: { pastDuration: '24h' }, display: 'Last 1 day' },
32
- { value: { pastDuration: '7d' }, display: 'Last 7 days' },
33
- { value: { pastDuration: '14d' }, display: 'Last 14 days' },
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
+ TIME_OPTIONS: ()=>TIME_OPTIONS,
25
+ TimeRangeControls: ()=>TimeRangeControls
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 _core = require("@perses-dev/core");
32
+ const _pluginSystem = require("@perses-dev/plugin-system");
33
+ const _context = require("../../context");
34
+ const TIME_OPTIONS = [
35
+ {
36
+ value: {
37
+ pastDuration: '5m'
38
+ },
39
+ display: 'Last 5 minutes'
40
+ },
41
+ {
42
+ value: {
43
+ pastDuration: '15m'
44
+ },
45
+ display: 'Last 15 minutes'
46
+ },
47
+ {
48
+ value: {
49
+ pastDuration: '30m'
50
+ },
51
+ display: 'Last 30 minutes'
52
+ },
53
+ {
54
+ value: {
55
+ pastDuration: '1h'
56
+ },
57
+ display: 'Last 1 hour'
58
+ },
59
+ {
60
+ value: {
61
+ pastDuration: '6h'
62
+ },
63
+ display: 'Last 6 hours'
64
+ },
65
+ {
66
+ value: {
67
+ pastDuration: '12h'
68
+ },
69
+ display: 'Last 12 hours'
70
+ },
71
+ {
72
+ value: {
73
+ pastDuration: '24h'
74
+ },
75
+ display: 'Last 1 day'
76
+ },
77
+ {
78
+ value: {
79
+ pastDuration: '7d'
80
+ },
81
+ display: 'Last 7 days'
82
+ },
83
+ {
84
+ value: {
85
+ pastDuration: '14d'
86
+ },
87
+ display: 'Last 14 days'
88
+ }
34
89
  ];
35
90
  function TimeRangeControls() {
36
- const { timeRange, setTimeRange } = (0, plugin_system_1.useTimeRange)();
37
- const { dashboard } = (0, context_1.useDashboard)();
38
- const { queryString } = (0, plugin_system_1.useQueryString)();
39
- const defaultTimeRange = (0, core_1.getDefaultTimeRange)(dashboard.duration, queryString);
91
+ const { timeRange , setTimeRange } = (0, _pluginSystem.useTimeRange)();
92
+ const dashboardDefaultTimeRange = (0, _context.useDefaultTimeRange)();
93
+ const { queryString } = (0, _pluginSystem.useQueryString)();
94
+ const defaultTimeRange = (0, _core.getDefaultTimeRange)(dashboardDefaultTimeRange, queryString);
40
95
  // selected form value can be relative or absolute, timeRange from plugin-system is only absolute
41
- const [selectedTimeRange, setSelectedTimeRange] = (0, react_1.useState)(defaultTimeRange);
42
- const [showCustomDateSelector, setShowCustomDateSelector] = (0, react_1.useState)(false);
43
- const anchorEl = (0, react_1.useRef)();
44
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Popover, { anchorEl: anchorEl.current, anchorOrigin: {
96
+ const [selectedTimeRange, setSelectedTimeRange] = (0, _react.useState)(defaultTimeRange);
97
+ const [showCustomDateSelector, setShowCustomDateSelector] = (0, _react.useState)(false);
98
+ const anchorEl = (0, _react.useRef)();
99
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
100
+ direction: "row",
101
+ spacing: 1,
102
+ children: [
103
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Popover, {
104
+ anchorEl: anchorEl.current,
105
+ anchorOrigin: {
45
106
  vertical: 'bottom',
46
- horizontal: 'center',
47
- }, open: showCustomDateSelector, onClose: () => setShowCustomDateSelector(false), sx: (theme) => ({
48
- padding: theme.spacing(2),
49
- }), children: (0, jsx_runtime_1.jsx)(components_1.AbsoluteTimePicker, { initialTimeRange: timeRange, onChange: (timeRange) => {
107
+ horizontal: 'center'
108
+ },
109
+ open: showCustomDateSelector,
110
+ onClose: ()=>setShowCustomDateSelector(false),
111
+ sx: (theme)=>({
112
+ padding: theme.spacing(2)
113
+ }),
114
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.AbsoluteTimePicker, {
115
+ initialTimeRange: timeRange,
116
+ onChange: (timeRange)=>{
50
117
  setTimeRange(timeRange);
51
118
  setSelectedTimeRange(timeRange);
52
119
  setShowCustomDateSelector(false);
53
- } }) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, { fullWidth: true, children: (0, jsx_runtime_1.jsx)(material_1.Box, { ref: anchorEl, children: (0, jsx_runtime_1.jsx)(components_1.TimeRangeSelector, { timeOptions: exports.TIME_OPTIONS, value: selectedTimeRange, onSelectChange: (event) => {
120
+ }
121
+ })
122
+ }),
123
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControl, {
124
+ fullWidth: true,
125
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
126
+ ref: anchorEl,
127
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.TimeRangeSelector, {
128
+ timeOptions: TIME_OPTIONS,
129
+ value: selectedTimeRange,
130
+ onSelectChange: (event)=>{
54
131
  const duration = event.target.value;
55
132
  const relativeTimeInput = {
56
133
  pastDuration: duration,
57
- end: new Date(),
134
+ end: new Date()
58
135
  };
59
136
  setTimeRange(relativeTimeInput);
60
137
  setSelectedTimeRange(relativeTimeInput);
61
138
  setShowCustomDateSelector(false);
62
- }, onCustomClick: () => {
139
+ },
140
+ onCustomClick: ()=>{
63
141
  setShowCustomDateSelector(true);
64
- } }) }) })] }));
142
+ }
143
+ })
144
+ })
145
+ })
146
+ ]
147
+ });
65
148
  }
66
- exports.TimeRangeControls = TimeRangeControls;