@perses-dev/dashboards 0.11.0 → 0.13.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 (231) hide show
  1. package/dist/cjs/components/{Dashboard.js → Dashboard/Dashboard.js} +2 -2
  2. package/dist/cjs/components/Dashboard/index.js +28 -0
  3. package/dist/cjs/components/{DashboardToolbar.js → DashboardToolbar/DashboardToolbar.js} +9 -16
  4. package/dist/cjs/components/DashboardToolbar/index.js +28 -0
  5. package/dist/cjs/components/{Panel → DeletePanelDialog}/DeletePanelDialog.js +4 -7
  6. package/dist/cjs/components/DeletePanelDialog/index.js +28 -0
  7. package/dist/cjs/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.js +0 -0
  8. package/dist/cjs/components/DeletePanelGroupDialog/index.js +28 -0
  9. package/dist/cjs/components/GridLayout/GridItemContent.js +11 -1
  10. package/dist/cjs/components/GridLayout/GridLayout.js +14 -16
  11. package/dist/cjs/components/Panel/Panel.js +30 -90
  12. package/dist/cjs/components/Panel/Panel.test.js +93 -46
  13. package/dist/cjs/components/Panel/PanelHeader.js +116 -0
  14. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +21 -19
  15. package/dist/cjs/components/PanelDrawer/PanelPreview.js +13 -20
  16. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +16 -16
  17. package/dist/cjs/components/PanelGroupDialog/index.js +0 -1
  18. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +1 -1
  19. package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +67 -0
  20. package/dist/cjs/components/UnsavedChangesConfirmationDialog/index.js +28 -0
  21. package/dist/cjs/components/Variables/Variable.js +18 -11
  22. package/dist/cjs/components/Variables/VariableEditor.js +7 -6
  23. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +9 -5
  24. package/dist/cjs/components/index.js +4 -0
  25. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +32 -20
  26. package/dist/cjs/context/DashboardProvider/common.js +10 -0
  27. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +14 -16
  28. package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +70 -0
  29. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +85 -0
  30. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +74 -67
  31. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +6 -19
  32. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +54 -164
  33. package/dist/cjs/context/DashboardProvider/panel-slice.js +25 -0
  34. package/dist/cjs/context/{TemplateVariableProvider.js → TemplateVariableProvider/TemplateVariableProvider.js} +25 -12
  35. package/dist/cjs/context/TemplateVariableProvider/index.js +28 -0
  36. package/dist/cjs/context/TemplateVariableProvider/query-params.js +79 -0
  37. package/dist/cjs/context/TemplateVariableProvider/query-params.test.js +82 -0
  38. package/dist/cjs/context/index.js +1 -1
  39. package/dist/cjs/context/useDashboard.js +94 -0
  40. package/dist/cjs/test/plugin-registry.js +14 -54
  41. package/dist/cjs/test/render.js +6 -1
  42. package/dist/cjs/utils/component-ids.js +31 -0
  43. package/dist/cjs/utils/time-range-params.js +14 -8
  44. package/dist/cjs/views/ViewDashboard/DashboardApp.js +40 -11
  45. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +1 -1
  46. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +1 -1
  47. package/dist/components/{Dashboard.d.ts → Dashboard/Dashboard.d.ts} +0 -0
  48. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -0
  49. package/dist/components/{Dashboard.js → Dashboard/Dashboard.js} +2 -2
  50. package/dist/components/Dashboard/Dashboard.js.map +1 -0
  51. package/dist/components/Dashboard/index.d.ts +2 -0
  52. package/dist/components/Dashboard/index.d.ts.map +1 -0
  53. package/dist/components/Dashboard/index.js +15 -0
  54. package/dist/components/Dashboard/index.js.map +1 -0
  55. package/dist/components/{DashboardToolbar.d.ts → DashboardToolbar/DashboardToolbar.d.ts} +2 -0
  56. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -0
  57. package/dist/components/{DashboardToolbar.js → DashboardToolbar/DashboardToolbar.js} +5 -12
  58. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -0
  59. package/dist/components/DashboardToolbar/index.d.ts +2 -0
  60. package/dist/components/DashboardToolbar/index.d.ts.map +1 -0
  61. package/dist/components/DashboardToolbar/index.js +15 -0
  62. package/dist/components/DashboardToolbar/index.js.map +1 -0
  63. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +3 -0
  64. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -0
  65. package/dist/components/{Panel → DeletePanelDialog}/DeletePanelDialog.js +3 -6
  66. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -0
  67. package/dist/components/DeletePanelDialog/index.d.ts +2 -0
  68. package/dist/components/DeletePanelDialog/index.d.ts.map +1 -0
  69. package/dist/components/DeletePanelDialog/index.js +15 -0
  70. package/dist/components/DeletePanelDialog/index.js.map +1 -0
  71. package/dist/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.d.ts +0 -0
  72. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
  73. package/dist/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.js +0 -0
  74. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
  75. package/dist/components/DeletePanelGroupDialog/index.d.ts +2 -0
  76. package/dist/components/DeletePanelGroupDialog/index.d.ts.map +1 -0
  77. package/dist/components/DeletePanelGroupDialog/index.js +15 -0
  78. package/dist/components/DeletePanelGroupDialog/index.js.map +1 -0
  79. package/dist/components/GridLayout/GridItemContent.d.ts +2 -2
  80. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  81. package/dist/components/GridLayout/GridItemContent.js +12 -2
  82. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  83. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  84. package/dist/components/GridLayout/GridLayout.js +16 -18
  85. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  86. package/dist/components/Panel/Panel.d.ts +3 -3
  87. package/dist/components/Panel/Panel.d.ts.map +1 -1
  88. package/dist/components/Panel/Panel.js +32 -92
  89. package/dist/components/Panel/Panel.js.map +1 -1
  90. package/dist/components/Panel/Panel.test.js +95 -48
  91. package/dist/components/Panel/Panel.test.js.map +1 -1
  92. package/dist/components/Panel/PanelHeader.d.ts +16 -0
  93. package/dist/components/Panel/PanelHeader.d.ts.map +1 -0
  94. package/dist/components/Panel/PanelHeader.js +105 -0
  95. package/dist/components/Panel/PanelHeader.js.map +1 -0
  96. package/dist/components/PanelDrawer/PanelDrawer.test.js +22 -20
  97. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
  98. package/dist/components/PanelDrawer/PanelPreview.d.ts +2 -2
  99. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  100. package/dist/components/PanelDrawer/PanelPreview.js +13 -20
  101. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  102. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +16 -16
  103. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
  104. package/dist/components/PanelGroupDialog/index.d.ts +0 -1
  105. package/dist/components/PanelGroupDialog/index.d.ts.map +1 -1
  106. package/dist/components/PanelGroupDialog/index.js +0 -1
  107. package/dist/components/PanelGroupDialog/index.js.map +1 -1
  108. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +1 -1
  109. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  110. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +8 -0
  111. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +1 -0
  112. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +56 -0
  113. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +1 -0
  114. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +2 -0
  115. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +1 -0
  116. package/dist/components/UnsavedChangesConfirmationDialog/index.js +15 -0
  117. package/dist/components/UnsavedChangesConfirmationDialog/index.js.map +1 -0
  118. package/dist/components/Variables/Variable.d.ts.map +1 -1
  119. package/dist/components/Variables/Variable.js +19 -12
  120. package/dist/components/Variables/Variable.js.map +1 -1
  121. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  122. package/dist/components/Variables/VariableEditor.js +7 -6
  123. package/dist/components/Variables/VariableEditor.js.map +1 -1
  124. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  125. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +9 -5
  126. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  127. package/dist/components/index.d.ts +4 -0
  128. package/dist/components/index.d.ts.map +1 -1
  129. package/dist/components/index.js +4 -0
  130. package/dist/components/index.js.map +1 -1
  131. package/dist/context/DashboardProvider/DashboardProvider.d.ts +8 -5
  132. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  133. package/dist/context/DashboardProvider/DashboardProvider.js +34 -22
  134. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  135. package/dist/context/DashboardProvider/common.d.ts +7 -0
  136. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  137. package/dist/context/DashboardProvider/common.js +8 -1
  138. package/dist/context/DashboardProvider/common.js.map +1 -1
  139. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +6 -6
  140. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  141. package/dist/context/DashboardProvider/dashboard-provider-api.js +14 -16
  142. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  143. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +23 -0
  144. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts.map +1 -0
  145. package/dist/context/DashboardProvider/delete-panel-group-slice.js +64 -0
  146. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -0
  147. package/dist/context/DashboardProvider/delete-panel-slice.d.ts +36 -0
  148. package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -0
  149. package/dist/context/DashboardProvider/delete-panel-slice.js +81 -0
  150. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -0
  151. package/dist/context/DashboardProvider/index.d.ts +3 -1
  152. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  153. package/dist/context/DashboardProvider/index.js.map +1 -1
  154. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +6 -35
  155. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  156. package/dist/context/DashboardProvider/panel-editor-slice.js +74 -67
  157. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  158. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -8
  159. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
  160. package/dist/context/DashboardProvider/panel-group-editor-slice.js +6 -19
  161. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  162. package/dist/context/DashboardProvider/panel-group-slice.d.ts +14 -44
  163. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  164. package/dist/context/DashboardProvider/panel-group-slice.js +46 -162
  165. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  166. package/dist/context/DashboardProvider/panel-slice.d.ts +14 -0
  167. package/dist/context/DashboardProvider/panel-slice.d.ts.map +1 -0
  168. package/dist/context/DashboardProvider/panel-slice.js +21 -0
  169. package/dist/context/DashboardProvider/panel-slice.js.map +1 -0
  170. package/dist/context/{TemplateVariableProvider.d.ts → TemplateVariableProvider/TemplateVariableProvider.d.ts} +0 -0
  171. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -0
  172. package/dist/context/{TemplateVariableProvider.js → TemplateVariableProvider/TemplateVariableProvider.js} +25 -12
  173. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -0
  174. package/dist/context/TemplateVariableProvider/index.d.ts +2 -0
  175. package/dist/context/TemplateVariableProvider/index.d.ts.map +1 -0
  176. package/dist/context/TemplateVariableProvider/index.js +15 -0
  177. package/dist/context/TemplateVariableProvider/index.js.map +1 -0
  178. package/dist/context/TemplateVariableProvider/query-params.d.ts +12 -0
  179. package/dist/context/TemplateVariableProvider/query-params.d.ts.map +1 -0
  180. package/dist/context/TemplateVariableProvider/query-params.js +64 -0
  181. package/dist/context/TemplateVariableProvider/query-params.js.map +1 -0
  182. package/dist/context/TemplateVariableProvider/query-params.test.d.ts +2 -0
  183. package/dist/context/TemplateVariableProvider/query-params.test.d.ts.map +1 -0
  184. package/dist/context/TemplateVariableProvider/query-params.test.js +80 -0
  185. package/dist/context/TemplateVariableProvider/query-params.test.js.map +1 -0
  186. package/dist/context/index.d.ts +1 -1
  187. package/dist/context/index.d.ts.map +1 -1
  188. package/dist/context/index.js +1 -1
  189. package/dist/context/index.js.map +1 -1
  190. package/dist/context/useDashboard.d.ts +6 -0
  191. package/dist/context/useDashboard.d.ts.map +1 -0
  192. package/dist/context/useDashboard.js +88 -0
  193. package/dist/context/useDashboard.js.map +1 -0
  194. package/dist/test/plugin-registry.d.ts +2 -11
  195. package/dist/test/plugin-registry.d.ts.map +1 -1
  196. package/dist/test/plugin-registry.js +12 -49
  197. package/dist/test/plugin-registry.js.map +1 -1
  198. package/dist/test/render.d.ts.map +1 -1
  199. package/dist/test/render.js +6 -1
  200. package/dist/test/render.js.map +1 -1
  201. package/dist/utils/component-ids.d.ts +8 -0
  202. package/dist/utils/component-ids.d.ts.map +1 -0
  203. package/dist/utils/component-ids.js +27 -0
  204. package/dist/utils/component-ids.js.map +1 -0
  205. package/dist/utils/time-range-params.d.ts.map +1 -1
  206. package/dist/utils/time-range-params.js +15 -9
  207. package/dist/utils/time-range-params.js.map +1 -1
  208. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  209. package/dist/views/ViewDashboard/DashboardApp.js +40 -6
  210. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  211. package/dist/views/ViewDashboard/ViewDashboard.js +1 -1
  212. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  213. package/dist/views/ViewDashboard/tests/panelGroups.test.js +1 -1
  214. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
  215. package/package.json +4 -4
  216. package/dist/cjs/context/useDashboardSpec.js +0 -61
  217. package/dist/components/Dashboard.d.ts.map +0 -1
  218. package/dist/components/Dashboard.js.map +0 -1
  219. package/dist/components/DashboardToolbar.d.ts.map +0 -1
  220. package/dist/components/DashboardToolbar.js.map +0 -1
  221. package/dist/components/Panel/DeletePanelDialog.d.ts +0 -5
  222. package/dist/components/Panel/DeletePanelDialog.d.ts.map +0 -1
  223. package/dist/components/Panel/DeletePanelDialog.js.map +0 -1
  224. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +0 -1
  225. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +0 -1
  226. package/dist/context/TemplateVariableProvider.d.ts.map +0 -1
  227. package/dist/context/TemplateVariableProvider.js.map +0 -1
  228. package/dist/context/useDashboardSpec.d.ts +0 -3
  229. package/dist/context/useDashboardSpec.d.ts.map +0 -1
  230. package/dist/context/useDashboardSpec.js +0 -55
  231. package/dist/context/useDashboardSpec.js.map +0 -1
@@ -21,8 +21,8 @@ Object.defineProperty(exports, "Dashboard", {
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _material = require("@mui/material");
23
23
  const _components = require("@perses-dev/components");
24
- const _context = require("../context");
25
- const _gridLayout = require("./GridLayout");
24
+ const _context = require("../../context");
25
+ const _gridLayout = require("../GridLayout");
26
26
  function Dashboard(props) {
27
27
  const panelGroupIds = (0, _context.usePanelGroupIds)();
28
28
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
@@ -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("./Dashboard"), 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
+ }
@@ -24,27 +24,20 @@ const _pencilOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-materia
24
24
  const _plusBoxOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PlusBoxOutline"));
25
25
  const _chartBoxPlusOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ChartBoxPlusOutline"));
26
26
  const _components = require("@perses-dev/components");
27
- const _context = require("../context");
28
- const _components1 = require("../components");
27
+ const _context = require("../../context");
28
+ const _variables = require("../Variables");
29
+ const _timeRangeControls = require("../TimeRangeControls");
29
30
  function _interopRequireDefault(obj) {
30
31
  return obj && obj.__esModule ? obj : {
31
32
  default: obj
32
33
  };
33
34
  }
34
35
  const DashboardToolbar = (props)=>{
35
- const { dashboardName } = props;
36
+ const { dashboardName , onEditButtonClick , onCancelButtonClick } = props;
36
37
  const { isEditMode , setEditMode } = (0, _context.useEditMode)();
37
- const { openAddPanelGroup , openAddPanel , reset , save } = (0, _context.useDashboardActions)();
38
+ const { openAddPanelGroup , openAddPanel } = (0, _context.useDashboardActions)();
38
39
  const isLaptopSize = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('sm'));
39
- const onEditButtonClick = ()=>{
40
- setEditMode(true);
41
- };
42
- const onCancelButtonClick = ()=>{
43
- reset();
44
- setEditMode(false);
45
- };
46
40
  const onSave = ()=>{
47
- save();
48
41
  setEditMode(false);
49
42
  };
50
43
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
@@ -98,7 +91,7 @@ const DashboardToolbar = (props)=>{
98
91
  children: [
99
92
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
100
93
  FallbackComponent: _components.ErrorAlert,
101
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.TemplateVariableList, {})
94
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {})
102
95
  }),
103
96
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
104
97
  direction: 'row',
@@ -117,7 +110,7 @@ const DashboardToolbar = (props)=>{
117
110
  onClick: openAddPanel,
118
111
  children: "Add Panel"
119
112
  }),
120
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.TimeRangeControls, {})
113
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {})
121
114
  ]
122
115
  })
123
116
  ]
@@ -144,7 +137,7 @@ const DashboardToolbar = (props)=>{
144
137
  marginLeft: 'auto'
145
138
  },
146
139
  children: [
147
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.TimeRangeControls, {}),
140
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {}),
148
141
  isLaptopSize && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
149
142
  variant: "outlined",
150
143
  startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencilOutline.default, {}),
@@ -162,7 +155,7 @@ const DashboardToolbar = (props)=>{
162
155
  paddingY: 2,
163
156
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
164
157
  FallbackComponent: _components.ErrorAlert,
165
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.TemplateVariableList, {})
158
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {})
166
159
  })
167
160
  })
168
161
  ]
@@ -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("./DashboardToolbar"), 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
+ }
@@ -14,9 +14,9 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "default", {
17
+ Object.defineProperty(exports, "DeletePanelDialog", {
18
18
  enumerable: true,
19
- get: ()=>_default
19
+ get: ()=>DeletePanelDialog
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _material = require("@mui/material");
@@ -52,13 +52,11 @@ const DeletePanelDialog = ()=>{
52
52
  });
53
53
  };
54
54
  const DeletePanelForm = ({ deletePanelDialog })=>{
55
- const { deletePanels , closeDeletePanelDialog } = (0, _context.useDeletePanelDialog)();
55
+ const { deletePanel , closeDeletePanelDialog } = (0, _context.useDeletePanelDialog)();
56
56
  const handleDelete = (e)=>{
57
57
  e.preventDefault();
58
58
  const { panelGroupItemId } = deletePanelDialog;
59
- deletePanels([
60
- panelGroupItemId
61
- ]);
59
+ deletePanel(panelGroupItemId);
62
60
  closeDeletePanelDialog();
63
61
  };
64
62
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("form", {
@@ -92,4 +90,3 @@ const DeletePanelForm = ({ deletePanelDialog })=>{
92
90
  ]
93
91
  });
94
92
  };
95
- const _default = DeletePanelDialog;
@@ -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("./DeletePanelDialog"), 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,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("./DeletePanelGroupDialog"), 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
+ }
@@ -24,8 +24,18 @@ const _panel = require("../Panel/Panel");
24
24
  function GridItemContent(props) {
25
25
  const { panelGroupItemId } = props;
26
26
  const panelDefinition = (0, _context.usePanel)(panelGroupItemId);
27
+ const { isEditMode } = (0, _context.useEditMode)();
28
+ const { openEditPanel , openDeletePanelDialog } = (0, _context.usePanelActions)(panelGroupItemId);
29
+ // Provide actions to the panel when in edit mode
30
+ let editHandlers = undefined;
31
+ if (isEditMode) {
32
+ editHandlers = {
33
+ onEditPanelClick: openEditPanel,
34
+ onDeletePanelClick: openDeletePanelDialog
35
+ };
36
+ }
27
37
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
28
38
  definition: panelDefinition,
29
- panelGroupItemId: panelGroupItemId
39
+ editHandlers: editHandlers
30
40
  });
31
41
  }
@@ -30,7 +30,9 @@ const _gridItemContent = require("./GridItemContent");
30
30
  const ResponsiveGridLayout = (0, _reactGridLayout.WidthProvider)(_reactGridLayout.Responsive);
31
31
  function GridLayout(props) {
32
32
  const { panelGroupId , ...others } = props;
33
+ const theme = (0, _material.useTheme)();
33
34
  const groupDefinition = (0, _context.usePanelGroup)(panelGroupId);
35
+ const { updatePanelGroupLayouts } = (0, _context.usePanelGroupActions)(panelGroupId);
34
36
  var ref;
35
37
  const [isOpen, setIsOpen] = (0, _react.useState)((ref = !groupDefinition.isCollapsed) !== null && ref !== void 0 ? ref : true);
36
38
  const { isEditMode } = (0, _context.useEditMode)();
@@ -62,17 +64,11 @@ function GridLayout(props) {
62
64
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(ResponsiveGridLayout, {
63
65
  className: "layout",
64
66
  breakpoints: {
65
- lg: 1200,
66
- md: 996,
67
- sm: 768,
68
- xs: 480,
67
+ sm: theme.breakpoints.values.sm,
69
68
  xxs: 0
70
69
  },
71
70
  cols: {
72
- lg: 24,
73
- md: 24,
74
71
  sm: 24,
75
- xs: 24,
76
72
  xxs: 2
77
73
  },
78
74
  rowHeight: 30,
@@ -82,23 +78,25 @@ function GridLayout(props) {
82
78
  ],
83
79
  isDraggable: isEditMode,
84
80
  isResizable: isEditMode,
85
- children: groupDefinition.items.map(({ x , y , width , height }, itemIndex)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
86
- "data-grid": {
87
- x,
88
- y,
89
- w: width,
90
- h: height
91
- },
81
+ containerPadding: [
82
+ 0,
83
+ 10
84
+ ],
85
+ layouts: {
86
+ sm: groupDefinition.itemLayouts
87
+ },
88
+ onLayoutChange: updatePanelGroupLayouts,
89
+ children: groupDefinition.itemLayouts.map(({ i })=>/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
92
90
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
93
91
  FallbackComponent: _components.ErrorAlert,
94
92
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridItemContent.GridItemContent, {
95
93
  panelGroupItemId: {
96
94
  panelGroupId,
97
- itemIndex
95
+ panelGroupItemLayoutId: i
98
96
  }
99
97
  })
100
98
  })
101
- }, itemIndex))
99
+ }, i))
102
100
  })
103
101
  })
104
102
  ]
@@ -24,11 +24,8 @@ const _useResizeObserver = /*#__PURE__*/ _interopRequireDefault(require("use-res
24
24
  const _reactIntersectionObserver = require("react-intersection-observer");
25
25
  const _components = require("@perses-dev/components");
26
26
  const _material = require("@mui/material");
27
- const _informationOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/InformationOutline"));
28
- const _pencil = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Pencil"));
29
- const _deleteOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/DeleteOutline"));
30
- const _dragVertical = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/DragVertical"));
31
- const _context = require("../../context");
27
+ const _componentIds = require("../../utils/component-ids");
28
+ const _panelHeader = require("./PanelHeader");
32
29
  const _panelContent = require("./PanelContent");
33
30
  function _interopRequireDefault(obj) {
34
31
  return obj && obj.__esModule ? obj : {
@@ -36,7 +33,10 @@ function _interopRequireDefault(obj) {
36
33
  };
37
34
  }
38
35
  function Panel(props) {
39
- const { definition , panelGroupItemId , ...others } = props;
36
+ const { definition , editHandlers , onMouseEnter , onMouseLeave , sx , ...others } = props;
37
+ // Make sure we have an ID we can use for aria attributes
38
+ const generatedPanelId = (0, _componentIds.useId)('Panel');
39
+ const headerId = `${generatedPanelId}-header`;
40
40
  const [contentElement, setContentElement] = (0, _react.useState)(null);
41
41
  const [isHovered, setIsHovered] = (0, _react.useState)(false);
42
42
  const { width , height } = (0, _useResizeObserver.default)({
@@ -59,103 +59,47 @@ function Panel(props) {
59
59
  });
60
60
  // TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart
61
61
  const panelPadding = 1.5;
62
- const { isEditMode } = (0, _context.useEditMode)();
63
- const { openEditPanel , openDeletePanelDialog } = (0, _context.usePanelActions)(panelGroupItemId);
62
+ const handleMouseEnter = (e)=>{
63
+ setIsHovered(true);
64
+ onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(e);
65
+ };
66
+ const handleMouseLeave = (e)=>{
67
+ setIsHovered(false);
68
+ onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(e);
69
+ };
64
70
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Card, {
65
71
  ref: ref,
66
- sx: {
67
- ...others.sx,
72
+ component: "section",
73
+ sx: (0, _components.combineSx)({
68
74
  width: '100%',
69
75
  height: '100%',
70
76
  display: 'flex',
71
77
  flexFlow: 'column nowrap'
72
- },
78
+ }, sx),
73
79
  variant: "outlined",
80
+ onMouseEnter: handleMouseEnter,
81
+ onMouseLeave: handleMouseLeave,
82
+ "aria-labelledby": headerId,
83
+ "aria-describedby": headerId,
74
84
  ...others,
75
- onMouseEnter: ()=>setIsHovered(true),
76
- onMouseLeave: ()=>setIsHovered(false),
77
85
  children: [
78
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.CardHeader, {
79
- title: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
80
- sx: {
81
- display: 'flex',
82
- alignItems: 'center',
83
- minHeight: '24px'
84
- },
85
- children: [
86
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
87
- component: "h2",
88
- variant: "body2",
89
- fontWeight: (theme)=>theme.typography.fontWeightMedium,
90
- whiteSpace: "nowrap",
91
- overflow: "hidden",
92
- textOverflow: "ellipsis",
93
- children: definition.spec.display.name
94
- }),
95
- /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
96
- sx: {
97
- display: 'flex',
98
- alignItems: 'center',
99
- marginLeft: 'auto'
100
- },
101
- children: [
102
- !isEditMode && isHovered && definition.spec.display.description && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
103
- id: "info-tooltip",
104
- description: definition.spec.display.description,
105
- placement: _components.TooltipPlacement.Bottom,
106
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_informationOutline.default, {
107
- "aria-describedby": "info-tooltip",
108
- "aria-hidden": false,
109
- fontSize: "small",
110
- sx: {
111
- cursor: 'pointer'
112
- }
113
- })
114
- }),
115
- isEditMode && isHovered && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
116
- direction: "row",
117
- alignItems: "center",
118
- spacing: 0.5,
119
- children: [
120
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(IconButton, {
121
- "aria-label": "edit panel",
122
- size: "small",
123
- onClick: openEditPanel,
124
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencil.default, {})
125
- }),
126
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(IconButton, {
127
- "aria-label": "delete panel",
128
- size: "small",
129
- onClick: openDeletePanelDialog,
130
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_deleteOutline.default, {})
131
- }),
132
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(IconButton, {
133
- "aria-label": "drag handle",
134
- size: "small",
135
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dragVertical.default, {
136
- className: "drag-handle",
137
- sx: {
138
- cursor: 'grab'
139
- }
140
- })
141
- })
142
- ]
143
- })
144
- ]
145
- })
146
- ]
147
- }),
86
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelHeader.PanelHeader, {
87
+ id: headerId,
88
+ title: definition.spec.display.name,
89
+ description: definition.spec.display.description,
90
+ editHandlers: editHandlers,
91
+ isHovered: isHovered,
148
92
  sx: {
149
- display: 'block',
150
- padding: (theme)=>theme.spacing(1, panelPadding),
151
- borderBottom: (theme)=>`solid 1px ${theme.palette.divider}`
93
+ paddingX: (theme)=>theme.spacing(panelPadding)
152
94
  }
153
95
  }),
154
96
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.CardContent, {
97
+ component: "figure",
155
98
  sx: {
156
99
  position: 'relative',
157
100
  overflow: 'hidden',
158
101
  flexGrow: 1,
102
+ margin: 0,
159
103
  padding: (theme)=>theme.spacing(panelPadding),
160
104
  // Override MUI default style for last-child
161
105
  ':last-child': {
@@ -175,7 +119,3 @@ function Panel(props) {
175
119
  ]
176
120
  });
177
121
  }
178
- const IconButton = (0, _material.styled)(_material.IconButton)(({ theme })=>({
179
- borderRadius: theme.shape.borderRadius,
180
- padding: '4px'
181
- }));
@@ -15,11 +15,9 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  const _jsxRuntime = require("react/jsx-runtime");
18
- const _pluginSystem = require("@perses-dev/plugin-system");
19
18
  const _react = require("@testing-library/react");
20
19
  const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
21
20
  const _test = require("../../test");
22
- const _context = require("../../context");
23
21
  const _panel = require("./Panel");
24
22
  function _interopRequireDefault(obj) {
25
23
  return obj && obj.__esModule ? obj : {
@@ -27,56 +25,105 @@ function _interopRequireDefault(obj) {
27
25
  };
28
26
  }
29
27
  describe('Panel', ()=>{
30
- // Helper to create panel props for rendering tests
31
- const createPanelProps = ()=>{
32
- return {
33
- definition: {
34
- kind: 'Panel',
35
- spec: {
36
- display: {
37
- name: 'Fake Panel',
38
- description: 'This is a fake panel'
39
- },
40
- plugin: {
41
- kind: 'FakePanel',
42
- spec: {}
43
- }
28
+ const createTestPanel = ()=>({
29
+ kind: 'Panel',
30
+ spec: {
31
+ display: {
32
+ name: 'Fake Panel Title',
33
+ description: 'This is a fake panel'
34
+ },
35
+ plugin: {
36
+ kind: 'TimeSeriesChart',
37
+ spec: {}
44
38
  }
45
- },
46
- panelGroupItemId: {
47
- panelGroupId: 0,
48
- itemIndex: 0
49
39
  }
50
- };
51
- };
40
+ });
52
41
  // Helper to render the panel with some context set
53
- const renderPanel = (isEditMode = false)=>{
54
- const { addMockPlugin , pluginRegistryProps } = (0, _test.mockPluginRegistryProps)();
55
- addMockPlugin('Panel', 'FakePanel', _test.FAKE_PANEL_PLUGIN);
56
- (0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
57
- ...pluginRegistryProps,
58
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.DashboardProvider, {
59
- initialState: {
60
- dashboardSpec: (0, _test.getTestDashboard)().spec,
61
- isEditMode
62
- },
63
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
64
- ...createPanelProps()
65
- })
66
- })
42
+ const renderPanel = (definition, editHandlers)=>{
43
+ definition !== null && definition !== void 0 ? definition : definition = createTestPanel();
44
+ (0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
45
+ definition: definition,
46
+ editHandlers: editHandlers
67
47
  }));
68
48
  };
69
- it('should render name and info icon', async ()=>{
49
+ // Helper to get the panel once rendered
50
+ const getPanel = ()=>_react.screen.getByRole('region', {
51
+ name: 'Fake Panel Title'
52
+ });
53
+ it('should render panel', async ()=>{
70
54
  renderPanel();
71
- await _react.screen.findByText('Fake Panel');
72
- _react.screen.queryByLabelText('info-tooltip');
55
+ const panel = getPanel();
56
+ expect(panel).toBeInTheDocument();
57
+ // Should diplay header with panel's title
58
+ const header = _react.screen.getByRole('banner');
59
+ expect(header).toHaveTextContent('Fake Panel Title');
60
+ // Should display chart's content from the fake panel plugin
61
+ const content = _react.screen.getByRole('figure');
62
+ await (0, _react.waitFor)(()=>{
63
+ expect(content).toHaveTextContent('TimeSeriesChart panel');
64
+ });
65
+ expect(content);
66
+ });
67
+ it('shows panel description', async ()=>{
68
+ renderPanel();
69
+ const panel = getPanel();
70
+ // Description button should not be visible until hover on panel
71
+ const missingButton = _react.screen.queryByRole('button', {
72
+ name: /description/i
73
+ });
74
+ expect(missingButton).not.toBeInTheDocument();
75
+ _userEvent.default.hover(panel);
76
+ const descriptionButton = _react.screen.getByRole('button', {
77
+ name: /description/i
78
+ });
79
+ expect(descriptionButton).toBeInTheDocument();
80
+ // Can hover to see panel description in tooltip
81
+ _userEvent.default.hover(descriptionButton);
82
+ const tooltip = await _react.screen.findByRole('tooltip');
83
+ expect(tooltip).toHaveTextContent('This is a fake panel');
84
+ });
85
+ it('does not show description when panel does not have one', ()=>{
86
+ // Render a panel without a description set
87
+ const withoutDescription = createTestPanel();
88
+ withoutDescription.spec.display.description = undefined;
89
+ renderPanel(withoutDescription);
90
+ const panel = getPanel();
91
+ _userEvent.default.hover(panel);
92
+ const descriptionButton = _react.screen.queryByRole('button', {
93
+ name: /description/i
94
+ });
95
+ expect(descriptionButton).not.toBeInTheDocument();
96
+ });
97
+ it('does not show description in edit mode', ()=>{
98
+ renderPanel(undefined, {
99
+ onEditPanelClick: jest.fn(),
100
+ onDeletePanelClick: jest.fn()
101
+ });
102
+ const panel = getPanel();
103
+ _userEvent.default.hover(panel);
104
+ const descriptionButton = _react.screen.queryByRole('button', {
105
+ name: /description/i
106
+ });
107
+ expect(descriptionButton).not.toBeInTheDocument();
73
108
  });
74
- it('should render edit icons when in edit mode', ()=>{
75
- renderPanel(true);
76
- const panelTitle = _react.screen.getByText('Fake Panel');
77
- _userEvent.default.hover(panelTitle);
78
- _react.screen.getByLabelText('drag handle');
79
- _react.screen.getByLabelText('edit panel');
80
- _react.screen.getByLabelText('delete panel');
109
+ it('can trigger panel actions in edit mode', ()=>{
110
+ const onEditPanelClick = jest.fn();
111
+ const onDeletePanelClick = jest.fn();
112
+ renderPanel(undefined, {
113
+ onEditPanelClick,
114
+ onDeletePanelClick
115
+ });
116
+ const panel = getPanel();
117
+ _userEvent.default.hover(panel);
118
+ const editButton = _react.screen.getByRole('button', {
119
+ name: /edit/i
120
+ });
121
+ _userEvent.default.click(editButton);
122
+ const deleteButton = _react.screen.getByRole('button', {
123
+ name: /delete/i
124
+ });
125
+ _userEvent.default.click(deleteButton);
126
+ expect(onEditPanelClick).toHaveBeenCalledTimes(1);
127
+ expect(onDeletePanelClick).toHaveBeenCalledTimes(1);
81
128
  });
82
129
  });