@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
@@ -1 +1 @@
1
- {"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAO,QAAQ,EAA0B,MAAM,eAAe,CAAC;AAGtE,OAAO,EAA8B,YAAY,EAAE,MAAM,eAAe,CAAC;AAMzE,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eA6ChD"}
1
+ {"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAO,QAAQ,EAAoC,MAAM,eAAe,CAAC;AAGhF,OAAO,EAAoD,YAAY,EAAE,MAAM,eAAe,CAAC;AAM/F,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eAkDhD"}
@@ -13,10 +13,10 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { useState } from 'react';
15
15
  import { Responsive, WidthProvider } from 'react-grid-layout';
16
- import { Box, Collapse, GlobalStyles } from '@mui/material';
16
+ import { Box, Collapse, GlobalStyles, useTheme } from '@mui/material';
17
17
  import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
18
18
  import { styles } from '../../css/styles';
19
- import { useEditMode, usePanelGroup } from '../../context';
19
+ import { useEditMode, usePanelGroup, usePanelGroupActions } from '../../context';
20
20
  import { GridTitle } from './GridTitle';
21
21
  import { GridItemContent } from './GridItemContent';
22
22
  const ResponsiveGridLayout = WidthProvider(Responsive);
@@ -24,7 +24,9 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
24
24
  * Layout component that arranges children in a Grid based on the definition.
25
25
  */ export function GridLayout(props) {
26
26
  const { panelGroupId , ...others } = props;
27
+ const theme = useTheme();
27
28
  const groupDefinition = usePanelGroup(panelGroupId);
29
+ const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);
28
30
  var ref;
29
31
  const [isOpen, setIsOpen] = useState((ref = !groupDefinition.isCollapsed) !== null && ref !== void 0 ? ref : true);
30
32
  const { isEditMode } = useEditMode();
@@ -56,17 +58,11 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
56
58
  children: /*#__PURE__*/ _jsx(ResponsiveGridLayout, {
57
59
  className: "layout",
58
60
  breakpoints: {
59
- lg: 1200,
60
- md: 996,
61
- sm: 768,
62
- xs: 480,
61
+ sm: theme.breakpoints.values.sm,
63
62
  xxs: 0
64
63
  },
65
64
  cols: {
66
- lg: 24,
67
- md: 24,
68
65
  sm: 24,
69
- xs: 24,
70
66
  xxs: 2
71
67
  },
72
68
  rowHeight: 30,
@@ -76,23 +72,25 @@ const ResponsiveGridLayout = WidthProvider(Responsive);
76
72
  ],
77
73
  isDraggable: isEditMode,
78
74
  isResizable: isEditMode,
79
- children: groupDefinition.items.map(({ x , y , width , height }, itemIndex)=>/*#__PURE__*/ _jsx("div", {
80
- "data-grid": {
81
- x,
82
- y,
83
- w: width,
84
- h: height
85
- },
75
+ containerPadding: [
76
+ 0,
77
+ 10
78
+ ],
79
+ layouts: {
80
+ sm: groupDefinition.itemLayouts
81
+ },
82
+ onLayoutChange: updatePanelGroupLayouts,
83
+ children: groupDefinition.itemLayouts.map(({ i })=>/*#__PURE__*/ _jsx("div", {
86
84
  children: /*#__PURE__*/ _jsx(ErrorBoundary, {
87
85
  FallbackComponent: ErrorAlert,
88
86
  children: /*#__PURE__*/ _jsx(GridItemContent, {
89
87
  panelGroupItemId: {
90
88
  panelGroupId,
91
- itemIndex
89
+ panelGroupItemLayoutId: i
92
90
  }
93
91
  })
94
92
  })
95
- }, itemIndex))
93
+ }, i))
96
94
  })
97
95
  })
98
96
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/GridLayout/GridLayout.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useState } from 'react';\nimport { Responsive, WidthProvider } from 'react-grid-layout';\nimport { Box, BoxProps, Collapse, GlobalStyles } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { styles } from '../../css/styles';\nimport { useEditMode, usePanelGroup, PanelGroupId } from '../../context';\nimport { GridTitle } from './GridTitle';\nimport { GridItemContent } from './GridItemContent';\n\nconst ResponsiveGridLayout = WidthProvider(Responsive);\n\nexport interface GridLayoutProps extends BoxProps {\n panelGroupId: PanelGroupId;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps) {\n const { panelGroupId, ...others } = props;\n const groupDefinition = usePanelGroup(panelGroupId);\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed ?? true);\n const { isEditMode } = useEditMode();\n\n return (\n <>\n <GlobalStyles styles={styles} />\n <Box {...others} component=\"section\" sx={{ '& + &': { marginTop: (theme) => theme.spacing(1) } }}>\n {groupDefinition.title !== undefined && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit>\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }}\n cols={{ lg: 24, md: 24, sm: 24, xs: 24, xxs: 2 }}\n rowHeight={30}\n draggableHandle={'.drag-handle'}\n resizeHandles={['se']}\n isDraggable={isEditMode}\n isResizable={isEditMode}\n >\n {groupDefinition.items.map(({ x, y, width, height }, itemIndex) => (\n <div key={itemIndex} data-grid={{ x, y, w: width, h: height }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent panelGroupItemId={{ panelGroupId, itemIndex }} />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </Box>\n </>\n );\n}\n"],"names":["useState","Responsive","WidthProvider","Box","Collapse","GlobalStyles","ErrorAlert","ErrorBoundary","styles","useEditMode","usePanelGroup","GridTitle","GridItemContent","ResponsiveGridLayout","GridLayout","props","panelGroupId","others","groupDefinition","isOpen","setIsOpen","isCollapsed","isEditMode","component","sx","marginTop","theme","spacing","title","undefined","collapse","onToggleOpen","current","in","unmountOnExit","className","breakpoints","lg","md","sm","xs","xxs","cols","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","items","map","x","y","width","height","itemIndex","div","data-grid","w","h","FallbackComponent","panelGroupItemId"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,UAAU,EAAEC,aAAa,QAAQ,mBAAmB,CAAC;AAC9D,SAASC,GAAG,EAAYC,QAAQ,EAAEC,YAAY,QAAQ,eAAe,CAAC;AACtE,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AACnE,SAASC,MAAM,QAAQ,kBAAkB,CAAC;AAC1C,SAASC,WAAW,EAAEC,aAAa,QAAsB,eAAe,CAAC;AACzE,SAASC,SAAS,QAAQ,aAAa,CAAC;AACxC,SAASC,eAAe,QAAQ,mBAAmB,CAAC;AAEpD,MAAMC,oBAAoB,GAAGX,aAAa,CAACD,UAAU,CAAC,AAAC;AAMvD;;CAEC,GACD,OAAO,SAASa,UAAU,CAACC,KAAsB,EAAE;IACjD,MAAM,EAAEC,YAAY,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGF,KAAK,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EAAE;gCAAEC,EAAE,EAAE,EAAE;gCAAEC,EAAE,EAAE,EAAE;gCAAEC,GAAG,EAAE,CAAC;6BAAE;4BAChDE,SAAS,EAAE,EAAE;4BACbC,eAAe,EAAE,cAAc;4BAC/BC,aAAa,EAAE;gCAAC,IAAI;6BAAC;4BACrBC,WAAW,EAAExB,UAAU;4BACvByB,WAAW,EAAEzB,UAAU;sCAEtBJ,eAAe,CAAC8B,KAAK,CAACC,GAAG,CAAC,CAAC,EAAEC,CAAC,CAAA,EAAEC,CAAC,CAAA,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAE,EAAEC,SAAS,iBAC5D,KAACC,KAAG;oCAAiBC,WAAS,EAAE;wCAAEN,CAAC;wCAAEC,CAAC;wCAAEM,CAAC,EAAEL,KAAK;wCAAEM,CAAC,EAAEL,MAAM;qCAAE;8CAC3D,cAAA,KAAC9C,aAAa;wCAACoD,iBAAiB,EAAErD,UAAU;kDAC1C,cAAA,KAACM,eAAe;4CAACgD,gBAAgB,EAAE;gDAAE5C,YAAY;gDAAEsC,SAAS;6CAAE;0CAAI;sCACpD;mCAHRA,SAAS,CAIb,AACP,CAAC;0BACmB;sBACd;;cACP;;MACL,CACH;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/GridLayout/GridLayout.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { useState } from 'react';\nimport { Responsive, WidthProvider } from 'react-grid-layout';\nimport { Box, BoxProps, Collapse, GlobalStyles, useTheme } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { styles } from '../../css/styles';\nimport { useEditMode, usePanelGroup, usePanelGroupActions, PanelGroupId } from '../../context';\nimport { GridTitle } from './GridTitle';\nimport { GridItemContent } from './GridItemContent';\n\nconst ResponsiveGridLayout = WidthProvider(Responsive);\n\nexport interface GridLayoutProps extends BoxProps {\n panelGroupId: PanelGroupId;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps) {\n const { panelGroupId, ...others } = props;\n const theme = useTheme();\n const groupDefinition = usePanelGroup(panelGroupId);\n const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed ?? true);\n const { isEditMode } = useEditMode();\n\n return (\n <>\n <GlobalStyles styles={styles} />\n <Box {...others} component=\"section\" sx={{ '& + &': { marginTop: (theme) => theme.spacing(1) } }}>\n {groupDefinition.title !== undefined && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit>\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ sm: theme.breakpoints.values.sm, xxs: 0 }}\n cols={{ sm: 24, xxs: 2 }}\n rowHeight={30}\n draggableHandle={'.drag-handle'}\n resizeHandles={['se']}\n isDraggable={isEditMode}\n isResizable={isEditMode}\n containerPadding={[0, 10]}\n layouts={{ sm: groupDefinition.itemLayouts }}\n onLayoutChange={updatePanelGroupLayouts}\n >\n {groupDefinition.itemLayouts.map(({ i }) => (\n <div key={i}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent panelGroupItemId={{ panelGroupId, panelGroupItemLayoutId: i }} />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </Box>\n </>\n );\n}\n"],"names":["useState","Responsive","WidthProvider","Box","Collapse","GlobalStyles","useTheme","ErrorAlert","ErrorBoundary","styles","useEditMode","usePanelGroup","usePanelGroupActions","GridTitle","GridItemContent","ResponsiveGridLayout","GridLayout","props","panelGroupId","others","theme","groupDefinition","updatePanelGroupLayouts","isOpen","setIsOpen","isCollapsed","isEditMode","component","sx","marginTop","spacing","title","undefined","collapse","onToggleOpen","current","in","unmountOnExit","className","breakpoints","sm","values","xxs","cols","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","containerPadding","layouts","itemLayouts","onLayoutChange","map","i","div","FallbackComponent","panelGroupItemId","panelGroupItemLayoutId"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,UAAU,EAAEC,aAAa,QAAQ,mBAAmB,CAAC;AAC9D,SAASC,GAAG,EAAYC,QAAQ,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,eAAe,CAAC;AAChF,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AACnE,SAASC,MAAM,QAAQ,kBAAkB,CAAC;AAC1C,SAASC,WAAW,EAAEC,aAAa,EAAEC,oBAAoB,QAAsB,eAAe,CAAC;AAC/F,SAASC,SAAS,QAAQ,aAAa,CAAC;AACxC,SAASC,eAAe,QAAQ,mBAAmB,CAAC;AAEpD,MAAMC,oBAAoB,GAAGb,aAAa,CAACD,UAAU,CAAC,AAAC;AAMvD;;CAEC,GACD,OAAO,SAASe,UAAU,CAACC,KAAsB,EAAE;IACjD,MAAM,EAAEC,YAAY,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGF,KAAK,AAAC;IAC1C,MAAMG,KAAK,GAAGd,QAAQ,EAAE,AAAC;IACzB,MAAMe,eAAe,GAAGV,aAAa,CAACO,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BAAE;4BACxBE,SAAS,EAAE,EAAE;4BACbC,eAAe,EAAE,cAAc;4BAC/BC,aAAa,EAAE;gCAAC,IAAI;6BAAC;4BACrBC,WAAW,EAAErB,UAAU;4BACvBsB,WAAW,EAAEtB,UAAU;4BACvBuB,gBAAgB,EAAE;AAAC,iCAAC;AAAE,kCAAE;6BAAC;4BACzBC,OAAO,EAAE;gCAAEV,EAAE,EAAEnB,eAAe,CAAC8B,WAAW;6BAAE;4BAC5CC,cAAc,EAAE9B,uBAAuB;sCAEtCD,eAAe,CAAC8B,WAAW,CAACE,GAAG,CAAC,CAAC,EAAEC,CAAC,CAAA,EAAE,iBACrC,KAACC,KAAG;8CACF,cAAA,KAAC/C,aAAa;wCAACgD,iBAAiB,EAAEjD,UAAU;kDAC1C,cAAA,KAACO,eAAe;4CAAC2C,gBAAgB,EAAE;gDAAEvC,YAAY;gDAAEwC,sBAAsB,EAAEJ,CAAC;6CAAE;0CAAI;sCACpE;mCAHRA,CAAC,CAIL,AACP,CAAC;0BACmB;sBACd;;cACP;;MACL,CACH;AACJ,CAAC"}
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { PanelDefinition } from '@perses-dev/core';
3
3
  import { CardProps } from '@mui/material';
4
- import { LayoutItem } from '../../context';
5
- export interface PanelProps extends CardProps {
4
+ import { PanelHeaderProps } from './PanelHeader';
5
+ export interface PanelProps extends CardProps<'section'> {
6
6
  definition: PanelDefinition;
7
- panelGroupItemId: LayoutItem;
7
+ editHandlers?: PanelHeaderProps['editHandlers'];
8
8
  }
9
9
  /**
10
10
  * Renders a PanelDefinition's content inside of a Card.
@@ -1 +1 @@
1
- {"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAGL,SAAS,EAOV,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAe,UAAU,EAAmB,MAAM,eAAe,CAAC;AAGzE,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,UAAU,EAAE,eAAe,CAAC;IAC5B,gBAAgB,EAAE,UAAU,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,eAgItC"}
1
+ {"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAQ,SAAS,EAAe,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG9D,MAAM,WAAW,UAAW,SAAQ,SAAS,CAAC,SAAS,CAAC;IACtD,UAAU,EAAE,eAAe,CAAC;IAC5B,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,eA2FtC"}
@@ -14,18 +14,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { useState, useMemo } from 'react';
15
15
  import useResizeObserver from 'use-resize-observer';
16
16
  import { useInView } from 'react-intersection-observer';
17
- import { ErrorBoundary, ErrorAlert, InfoTooltip, TooltipPlacement } from '@perses-dev/components';
18
- import { Box, Card, CardHeader, CardContent, Typography, IconButton as MuiIconButton, Stack, styled } from '@mui/material';
19
- import InformationOutlineIcon from 'mdi-material-ui/InformationOutline';
20
- import PencilIcon from 'mdi-material-ui/Pencil';
21
- import DeleteIcon from 'mdi-material-ui/DeleteOutline';
22
- import DragIcon from 'mdi-material-ui/DragVertical';
23
- import { useEditMode, usePanelActions } from '../../context';
17
+ import { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';
18
+ import { Card, CardContent } from '@mui/material';
19
+ import { useId } from '../../utils/component-ids';
20
+ import { PanelHeader } from './PanelHeader';
24
21
  import { PanelContent } from './PanelContent';
25
22
  /**
26
23
  * Renders a PanelDefinition's content inside of a Card.
27
24
  */ export function Panel(props) {
28
- const { definition , panelGroupItemId , ...others } = props;
25
+ const { definition , editHandlers , onMouseEnter , onMouseLeave , sx , ...others } = props;
26
+ // Make sure we have an ID we can use for aria attributes
27
+ const generatedPanelId = useId('Panel');
28
+ const headerId = `${generatedPanelId}-header`;
29
29
  const [contentElement, setContentElement] = useState(null);
30
30
  const [isHovered, setIsHovered] = useState(false);
31
31
  const { width , height } = useResizeObserver({
@@ -48,103 +48,47 @@ import { PanelContent } from './PanelContent';
48
48
  });
49
49
  // TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart
50
50
  const panelPadding = 1.5;
51
- const { isEditMode } = useEditMode();
52
- const { openEditPanel , openDeletePanelDialog } = usePanelActions(panelGroupItemId);
51
+ const handleMouseEnter = (e)=>{
52
+ setIsHovered(true);
53
+ onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(e);
54
+ };
55
+ const handleMouseLeave = (e)=>{
56
+ setIsHovered(false);
57
+ onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(e);
58
+ };
53
59
  return /*#__PURE__*/ _jsxs(Card, {
54
60
  ref: ref,
55
- sx: {
56
- ...others.sx,
61
+ component: "section",
62
+ sx: combineSx({
57
63
  width: '100%',
58
64
  height: '100%',
59
65
  display: 'flex',
60
66
  flexFlow: 'column nowrap'
61
- },
67
+ }, sx),
62
68
  variant: "outlined",
69
+ onMouseEnter: handleMouseEnter,
70
+ onMouseLeave: handleMouseLeave,
71
+ "aria-labelledby": headerId,
72
+ "aria-describedby": headerId,
63
73
  ...others,
64
- onMouseEnter: ()=>setIsHovered(true),
65
- onMouseLeave: ()=>setIsHovered(false),
66
74
  children: [
67
- /*#__PURE__*/ _jsx(CardHeader, {
68
- title: /*#__PURE__*/ _jsxs(Box, {
69
- sx: {
70
- display: 'flex',
71
- alignItems: 'center',
72
- minHeight: '24px'
73
- },
74
- children: [
75
- /*#__PURE__*/ _jsx(Typography, {
76
- component: "h2",
77
- variant: "body2",
78
- fontWeight: (theme)=>theme.typography.fontWeightMedium,
79
- whiteSpace: "nowrap",
80
- overflow: "hidden",
81
- textOverflow: "ellipsis",
82
- children: definition.spec.display.name
83
- }),
84
- /*#__PURE__*/ _jsxs(Box, {
85
- sx: {
86
- display: 'flex',
87
- alignItems: 'center',
88
- marginLeft: 'auto'
89
- },
90
- children: [
91
- !isEditMode && isHovered && definition.spec.display.description && /*#__PURE__*/ _jsx(InfoTooltip, {
92
- id: "info-tooltip",
93
- description: definition.spec.display.description,
94
- placement: TooltipPlacement.Bottom,
95
- children: /*#__PURE__*/ _jsx(InformationOutlineIcon, {
96
- "aria-describedby": "info-tooltip",
97
- "aria-hidden": false,
98
- fontSize: "small",
99
- sx: {
100
- cursor: 'pointer'
101
- }
102
- })
103
- }),
104
- isEditMode && isHovered && /*#__PURE__*/ _jsxs(Stack, {
105
- direction: "row",
106
- alignItems: "center",
107
- spacing: 0.5,
108
- children: [
109
- /*#__PURE__*/ _jsx(IconButton, {
110
- "aria-label": "edit panel",
111
- size: "small",
112
- onClick: openEditPanel,
113
- children: /*#__PURE__*/ _jsx(PencilIcon, {})
114
- }),
115
- /*#__PURE__*/ _jsx(IconButton, {
116
- "aria-label": "delete panel",
117
- size: "small",
118
- onClick: openDeletePanelDialog,
119
- children: /*#__PURE__*/ _jsx(DeleteIcon, {})
120
- }),
121
- /*#__PURE__*/ _jsx(IconButton, {
122
- "aria-label": "drag handle",
123
- size: "small",
124
- children: /*#__PURE__*/ _jsx(DragIcon, {
125
- className: "drag-handle",
126
- sx: {
127
- cursor: 'grab'
128
- }
129
- })
130
- })
131
- ]
132
- })
133
- ]
134
- })
135
- ]
136
- }),
75
+ /*#__PURE__*/ _jsx(PanelHeader, {
76
+ id: headerId,
77
+ title: definition.spec.display.name,
78
+ description: definition.spec.display.description,
79
+ editHandlers: editHandlers,
80
+ isHovered: isHovered,
137
81
  sx: {
138
- display: 'block',
139
- padding: (theme)=>theme.spacing(1, panelPadding),
140
- borderBottom: (theme)=>`solid 1px ${theme.palette.divider}`
82
+ paddingX: (theme)=>theme.spacing(panelPadding)
141
83
  }
142
84
  }),
143
85
  /*#__PURE__*/ _jsx(CardContent, {
86
+ component: "figure",
144
87
  sx: {
145
88
  position: 'relative',
146
89
  overflow: 'hidden',
147
90
  flexGrow: 1,
91
+ margin: 0,
148
92
  padding: (theme)=>theme.spacing(panelPadding),
149
93
  // Override MUI default style for last-child
150
94
  ':last-child': {
@@ -164,9 +108,5 @@ import { PanelContent } from './PanelContent';
164
108
  ]
165
109
  });
166
110
  }
167
- const IconButton = styled(MuiIconButton)(({ theme })=>({
168
- borderRadius: theme.shape.borderRadius,
169
- padding: '4px'
170
- }));
171
111
 
172
112
  //# sourceMappingURL=Panel.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Panel/Panel.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState, useMemo } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { useInView } from 'react-intersection-observer';\nimport { ErrorBoundary, ErrorAlert, InfoTooltip, TooltipPlacement } from '@perses-dev/components';\nimport { PanelDefinition } from '@perses-dev/core';\nimport {\n Box,\n Card,\n CardProps,\n CardHeader,\n CardContent,\n Typography,\n IconButton as MuiIconButton,\n Stack,\n styled,\n} from '@mui/material';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport PencilIcon from 'mdi-material-ui/Pencil';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\nimport { useEditMode, LayoutItem, usePanelActions } from '../../context';\nimport { PanelContent } from './PanelContent';\n\nexport interface PanelProps extends CardProps {\n definition: PanelDefinition;\n panelGroupItemId: LayoutItem;\n}\n\n/**\n * Renders a PanelDefinition's content inside of a Card.\n */\nexport function Panel(props: PanelProps) {\n const { definition, panelGroupItemId, ...others } = props;\n\n const [contentElement, setContentElement] = useState<HTMLDivElement | null>(null);\n const [isHovered, setIsHovered] = useState(false);\n\n const { width, height } = useResizeObserver({ ref: contentElement });\n\n const contentDimensions = useMemo(() => {\n if (width === undefined || height === undefined) return undefined;\n return { width, height };\n }, [width, height]);\n\n const { ref, inView } = useInView({\n threshold: 0.3,\n initialInView: false,\n triggerOnce: true,\n });\n\n // TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart\n const panelPadding = 1.5;\n\n const { isEditMode } = useEditMode();\n\n const { openEditPanel, openDeletePanelDialog } = usePanelActions(panelGroupItemId);\n\n return (\n <Card\n ref={ref}\n sx={{\n ...others.sx,\n width: '100%',\n height: '100%',\n display: 'flex',\n flexFlow: 'column nowrap',\n }}\n variant=\"outlined\"\n {...others}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n <CardHeader\n title={\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n minHeight: '24px',\n }}\n >\n <Typography\n component=\"h2\"\n variant=\"body2\"\n fontWeight={(theme) => theme.typography.fontWeightMedium}\n whiteSpace=\"nowrap\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n >\n {definition.spec.display.name}\n </Typography>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n marginLeft: 'auto',\n }}\n >\n {!isEditMode && isHovered && definition.spec.display.description && (\n <InfoTooltip\n id=\"info-tooltip\"\n description={definition.spec.display.description}\n placement={TooltipPlacement.Bottom}\n >\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n fontSize=\"small\"\n sx={{ cursor: 'pointer' }}\n />\n </InfoTooltip>\n )}\n {isEditMode && isHovered && (\n <Stack direction=\"row\" alignItems=\"center\" spacing={0.5}>\n <IconButton aria-label=\"edit panel\" size=\"small\" onClick={openEditPanel}>\n <PencilIcon />\n </IconButton>\n <IconButton aria-label=\"delete panel\" size=\"small\" onClick={openDeletePanelDialog}>\n <DeleteIcon />\n </IconButton>\n <IconButton aria-label=\"drag handle\" size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} />\n </IconButton>\n </Stack>\n )}\n </Box>\n </Box>\n }\n sx={{\n display: 'block',\n padding: (theme) => theme.spacing(1, panelPadding),\n borderBottom: (theme) => `solid 1px ${theme.palette.divider}`,\n }}\n />\n <CardContent\n sx={{\n position: 'relative',\n overflow: 'hidden',\n flexGrow: 1,\n padding: (theme) => theme.spacing(panelPadding),\n // Override MUI default style for last-child\n ':last-child': {\n padding: (theme) => theme.spacing(panelPadding),\n },\n }}\n ref={setContentElement}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {inView === true && (\n <PanelContent\n panelPluginKind={definition.spec.plugin.kind}\n spec={definition.spec.plugin.spec}\n contentDimensions={contentDimensions}\n />\n )}\n </ErrorBoundary>\n </CardContent>\n </Card>\n );\n}\n\nconst IconButton = styled(MuiIconButton)(({ theme }) => ({\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n}));\n"],"names":["useState","useMemo","useResizeObserver","useInView","ErrorBoundary","ErrorAlert","InfoTooltip","TooltipPlacement","Box","Card","CardHeader","CardContent","Typography","IconButton","MuiIconButton","Stack","styled","InformationOutlineIcon","PencilIcon","DeleteIcon","DragIcon","useEditMode","usePanelActions","PanelContent","Panel","props","definition","panelGroupItemId","others","contentElement","setContentElement","isHovered","setIsHovered","width","height","ref","contentDimensions","undefined","inView","threshold","initialInView","triggerOnce","panelPadding","isEditMode","openEditPanel","openDeletePanelDialog","sx","display","flexFlow","variant","onMouseEnter","onMouseLeave","title","alignItems","minHeight","component","fontWeight","theme","typography","fontWeightMedium","whiteSpace","overflow","textOverflow","spec","name","marginLeft","description","id","placement","Bottom","aria-describedby","aria-hidden","fontSize","cursor","direction","spacing","aria-label","size","onClick","className","padding","borderBottom","palette","divider","position","flexGrow","FallbackComponent","panelPluginKind","plugin","kind","borderRadius","shape"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAC1C,OAAOC,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,SAASC,SAAS,QAAQ,6BAA6B,CAAC;AACxD,SAASC,aAAa,EAAEC,UAAU,EAAEC,WAAW,EAAEC,gBAAgB,QAAQ,wBAAwB,CAAC;AAElG,SACEC,GAAG,EACHC,IAAI,EAEJC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,UAAU,IAAIC,aAAa,EAC3BC,KAAK,EACLC,MAAM,QACD,eAAe,CAAC;AACvB,OAAOC,sBAAsB,MAAM,oCAAoC,CAAC;AACxE,OAAOC,UAAU,MAAM,wBAAwB,CAAC;AAChD,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,QAAQ,MAAM,8BAA8B,CAAC;AACpD,SAASC,WAAW,EAAcC,eAAe,QAAQ,eAAe,CAAC;AACzE,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAO9C;;CAEC,GACD,OAAO,SAASC,KAAK,CAACC,KAAiB,EAAE;IACvC,MAAM,EAAEC,UAAU,CAAA,EAAEC,gBAAgB,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGH,KAAK,AAAC;IAE1D,MAAM,CAACI,cAAc,EAAEC,iBAAiB,CAAC,GAAG9B,QAAQ,CAAwB,IAAI,CAAC,A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qC,IAAI,CAACyB,MAAM,CAACzB,IAAI;wBACjC3B,iBAAiB,EAAEA,iBAAiB;sBACpC,AACH;kBACa;cACJ;;MACT,CACP;AACJ,CAAC;AAED,MAAMvB,UAAU,GAAGG,MAAM,CAACF,aAAa,CAAC,CAAC,CAAC,EAAE2C,KAAK,CAAA,EAAE,GAAM,CAAA;QACvDiC,YAAY,EAAEjC,KAAK,CAACkC,KAAK,CAACD,YAAY;QACtCV,OAAO,EAAE,KAAK;KACf,CAAA,AAAC,CAAC,AAAC"}
1
+ {"version":3,"sources":["../../../src/components/Panel/Panel.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState, useMemo } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { useInView } from 'react-intersection-observer';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport { PanelDefinition } from '@perses-dev/core';\nimport { Card, CardProps, CardContent } from '@mui/material';\nimport { useId } from '../../utils/component-ids';\nimport { PanelHeader, PanelHeaderProps } from './PanelHeader';\nimport { PanelContent } from './PanelContent';\n\nexport interface PanelProps extends CardProps<'section'> {\n definition: PanelDefinition;\n editHandlers?: PanelHeaderProps['editHandlers'];\n}\n\n/**\n * Renders a PanelDefinition's content inside of a Card.\n */\nexport function Panel(props: PanelProps) {\n const { definition, editHandlers, onMouseEnter, onMouseLeave, sx, ...others } = props;\n\n // Make sure we have an ID we can use for aria attributes\n const generatedPanelId = useId('Panel');\n const headerId = `${generatedPanelId}-header`;\n\n const [contentElement, setContentElement] = useState<HTMLElement | null>(null);\n const [isHovered, setIsHovered] = useState(false);\n\n const { width, height } = useResizeObserver({ ref: contentElement });\n\n const contentDimensions = useMemo(() => {\n if (width === undefined || height === undefined) return undefined;\n return { width, height };\n }, [width, height]);\n\n const { ref, inView } = useInView({\n threshold: 0.3,\n initialInView: false,\n triggerOnce: true,\n });\n\n // TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart\n const panelPadding = 1.5;\n\n const handleMouseEnter: CardProps['onMouseEnter'] = (e) => {\n setIsHovered(true);\n onMouseEnter?.(e);\n };\n\n const handleMouseLeave: CardProps['onMouseLeave'] = (e) => {\n setIsHovered(false);\n onMouseLeave?.(e);\n };\n\n return (\n <Card\n ref={ref}\n component=\"section\"\n sx={combineSx(\n {\n width: '100%',\n height: '100%',\n display: 'flex',\n flexFlow: 'column nowrap',\n },\n sx\n )}\n variant=\"outlined\"\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n aria-labelledby={headerId}\n aria-describedby={headerId}\n {...others}\n >\n <PanelHeader\n id={headerId}\n title={definition.spec.display.name}\n description={definition.spec.display.description}\n editHandlers={editHandlers}\n isHovered={isHovered}\n sx={{ paddingX: (theme) => theme.spacing(panelPadding) }}\n />\n <CardContent\n component=\"figure\"\n sx={{\n position: 'relative',\n overflow: 'hidden',\n flexGrow: 1,\n margin: 0,\n padding: (theme) => theme.spacing(panelPadding),\n // Override MUI default style for last-child\n ':last-child': {\n padding: (theme) => theme.spacing(panelPadding),\n },\n }}\n ref={setContentElement}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {inView === true && (\n <PanelContent\n panelPluginKind={definition.spec.plugin.kind}\n spec={definition.spec.plugin.spec}\n contentDimensions={contentDimensions}\n />\n )}\n </ErrorBoundary>\n </CardContent>\n </Card>\n );\n}\n"],"names":["useState","useMemo","useResizeObserver","useInView","ErrorBoundary","ErrorAlert","combineSx","Card","CardContent","useId","PanelHeader","PanelContent","Panel","props","definition","editHandlers","onMouseEnter","onMouseLeave","sx","others","generatedPanelId","headerId","contentElement","setContentElement","isHovered","setIsHovered","width","height","ref","contentDimensions","undefined","inView","threshold","initialInView","triggerOnce","panelPadding","handleMouseEnter","e","handleMouseLeave","component","display","flexFlow","variant","aria-labelledby","aria-describedby","id","title","spec","name","description","paddingX","theme","spacing","position","overflow","flexGrow","margin","padding","FallbackComponent","panelPluginKind","plugin","kind"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAC1C,OAAOC,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,SAASC,SAAS,QAAQ,6BAA6B,CAAC;AACxD,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAE9E,SAASC,IAAI,EAAaC,WAAW,QAAQ,eAAe,CAAC;AAC7D,SAASC,KAAK,QAAQ,2BAA2B,CAAC;AAClD,SAASC,WAAW,QAA0B,eAAe,CAAC;AAC9D,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAO9C;;CAEC,GACD,OAAO,SAASC,KAAK,CAACC,KAAiB,EAAE;IACvC,MAAM,EAAEC,UAAU,CAAA,EAAEC,YAAY,CAAA,EAAEC,YAAY,CAAA,EAAEC,YAAY,CAAA,EAAEC,EAAE,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGN,KAAK,AAAC;IAEtF,yDAAyD;IACzD,MAAMO,gBAAgB,GAAGX,KAAK,CAAC,OAAO,CAAC,AAAC;IACxC,MAAMY,QAAQ,GAAG,CAAC,EAAED,gBAAgB,CAAC,OAAO,CAAC,AAAC;IAE9C,MAAM,CAACE,cAAc,EAAEC,iBAAiB,CAAC,GAAGvB,QAAQ,CAAqB,IAAI,CAAC,AAAC;IAC/E,MAAM,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AAM,CAACb,IAAI;wBACjClB,iBAAiB,EAAEA,iBAAiB;sBACpC,AACH;kBACa;cACJ;;MACT,CACP;AACJ,CAAC"}
@@ -11,64 +11,111 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import { PluginRegistry } from '@perses-dev/plugin-system';
15
- import { screen } from '@testing-library/react';
14
+ import { screen, waitFor } from '@testing-library/react';
16
15
  import userEvent from '@testing-library/user-event';
17
- import { renderWithContext, mockPluginRegistryProps, FAKE_PANEL_PLUGIN, getTestDashboard } from '../../test';
18
- import { DashboardProvider } from '../../context';
16
+ import { renderWithContext } from '../../test';
19
17
  import { Panel } from './Panel';
20
18
  describe('Panel', ()=>{
21
- // Helper to create panel props for rendering tests
22
- const createPanelProps = ()=>{
23
- return {
24
- definition: {
25
- kind: 'Panel',
26
- spec: {
27
- display: {
28
- name: 'Fake Panel',
29
- description: 'This is a fake panel'
30
- },
31
- plugin: {
32
- kind: 'FakePanel',
33
- spec: {}
34
- }
19
+ const createTestPanel = ()=>({
20
+ kind: 'Panel',
21
+ spec: {
22
+ display: {
23
+ name: 'Fake Panel Title',
24
+ description: 'This is a fake panel'
25
+ },
26
+ plugin: {
27
+ kind: 'TimeSeriesChart',
28
+ spec: {}
35
29
  }
36
- },
37
- panelGroupItemId: {
38
- panelGroupId: 0,
39
- itemIndex: 0
40
30
  }
41
- };
42
- };
31
+ });
43
32
  // Helper to render the panel with some context set
44
- const renderPanel = (isEditMode = false)=>{
45
- const { addMockPlugin , pluginRegistryProps } = mockPluginRegistryProps();
46
- addMockPlugin('Panel', 'FakePanel', FAKE_PANEL_PLUGIN);
47
- renderWithContext(/*#__PURE__*/ _jsx(PluginRegistry, {
48
- ...pluginRegistryProps,
49
- children: /*#__PURE__*/ _jsx(DashboardProvider, {
50
- initialState: {
51
- dashboardSpec: getTestDashboard().spec,
52
- isEditMode
53
- },
54
- children: /*#__PURE__*/ _jsx(Panel, {
55
- ...createPanelProps()
56
- })
57
- })
33
+ const renderPanel = (definition, editHandlers)=>{
34
+ definition !== null && definition !== void 0 ? definition : definition = createTestPanel();
35
+ renderWithContext(/*#__PURE__*/ _jsx(Panel, {
36
+ definition: definition,
37
+ editHandlers: editHandlers
58
38
  }));
59
39
  };
60
- it('should render name and info icon', async ()=>{
40
+ // Helper to get the panel once rendered
41
+ const getPanel = ()=>screen.getByRole('region', {
42
+ name: 'Fake Panel Title'
43
+ });
44
+ it('should render panel', async ()=>{
61
45
  renderPanel();
62
- await screen.findByText('Fake Panel');
63
- screen.queryByLabelText('info-tooltip');
46
+ const panel = getPanel();
47
+ expect(panel).toBeInTheDocument();
48
+ // Should diplay header with panel's title
49
+ const header = screen.getByRole('banner');
50
+ expect(header).toHaveTextContent('Fake Panel Title');
51
+ // Should display chart's content from the fake panel plugin
52
+ const content = screen.getByRole('figure');
53
+ await waitFor(()=>{
54
+ expect(content).toHaveTextContent('TimeSeriesChart panel');
55
+ });
56
+ expect(content);
57
+ });
58
+ it('shows panel description', async ()=>{
59
+ renderPanel();
60
+ const panel = getPanel();
61
+ // Description button should not be visible until hover on panel
62
+ const missingButton = screen.queryByRole('button', {
63
+ name: /description/i
64
+ });
65
+ expect(missingButton).not.toBeInTheDocument();
66
+ userEvent.hover(panel);
67
+ const descriptionButton = screen.getByRole('button', {
68
+ name: /description/i
69
+ });
70
+ expect(descriptionButton).toBeInTheDocument();
71
+ // Can hover to see panel description in tooltip
72
+ userEvent.hover(descriptionButton);
73
+ const tooltip = await screen.findByRole('tooltip');
74
+ expect(tooltip).toHaveTextContent('This is a fake panel');
75
+ });
76
+ it('does not show description when panel does not have one', ()=>{
77
+ // Render a panel without a description set
78
+ const withoutDescription = createTestPanel();
79
+ withoutDescription.spec.display.description = undefined;
80
+ renderPanel(withoutDescription);
81
+ const panel = getPanel();
82
+ userEvent.hover(panel);
83
+ const descriptionButton = screen.queryByRole('button', {
84
+ name: /description/i
85
+ });
86
+ expect(descriptionButton).not.toBeInTheDocument();
87
+ });
88
+ it('does not show description in edit mode', ()=>{
89
+ renderPanel(undefined, {
90
+ onEditPanelClick: jest.fn(),
91
+ onDeletePanelClick: jest.fn()
92
+ });
93
+ const panel = getPanel();
94
+ userEvent.hover(panel);
95
+ const descriptionButton = screen.queryByRole('button', {
96
+ name: /description/i
97
+ });
98
+ expect(descriptionButton).not.toBeInTheDocument();
64
99
  });
65
- it('should render edit icons when in edit mode', ()=>{
66
- renderPanel(true);
67
- const panelTitle = screen.getByText('Fake Panel');
68
- userEvent.hover(panelTitle);
69
- screen.getByLabelText('drag handle');
70
- screen.getByLabelText('edit panel');
71
- screen.getByLabelText('delete panel');
100
+ it('can trigger panel actions in edit mode', ()=>{
101
+ const onEditPanelClick = jest.fn();
102
+ const onDeletePanelClick = jest.fn();
103
+ renderPanel(undefined, {
104
+ onEditPanelClick,
105
+ onDeletePanelClick
106
+ });
107
+ const panel = getPanel();
108
+ userEvent.hover(panel);
109
+ const editButton = screen.getByRole('button', {
110
+ name: /edit/i
111
+ });
112
+ userEvent.click(editButton);
113
+ const deleteButton = screen.getByRole('button', {
114
+ name: /delete/i
115
+ });
116
+ userEvent.click(deleteButton);
117
+ expect(onEditPanelClick).toHaveBeenCalledTimes(1);
118
+ expect(onDeletePanelClick).toHaveBeenCalledTimes(1);
72
119
  });
73
120
  });
74
121
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Panel/Panel.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginRegistry } from '@perses-dev/plugin-system';\nimport { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { renderWithContext, mockPluginRegistryProps, FAKE_PANEL_PLUGIN, getTestDashboard } from '../../test';\nimport { DashboardProvider } from '../../context';\nimport { Panel, PanelProps } from './Panel';\n\ndescribe('Panel', () => {\n // Helper to create panel props for rendering tests\n const createPanelProps = (): PanelProps => {\n return {\n definition: {\n kind: 'Panel',\n spec: {\n display: {\n name: 'Fake Panel',\n description: 'This is a fake panel',\n },\n plugin: {\n kind: 'FakePanel',\n spec: {},\n },\n },\n },\n panelGroupItemId: { panelGroupId: 0, itemIndex: 0 },\n };\n };\n\n // Helper to render the panel with some context set\n const renderPanel = (isEditMode = false) => {\n const { addMockPlugin, pluginRegistryProps } = mockPluginRegistryProps();\n addMockPlugin('Panel', 'FakePanel', FAKE_PANEL_PLUGIN);\n\n renderWithContext(\n <PluginRegistry {...pluginRegistryProps}>\n <DashboardProvider initialState={{ dashboardSpec: getTestDashboard().spec, isEditMode }}>\n <Panel {...createPanelProps()} />\n </DashboardProvider>\n </PluginRegistry>\n );\n };\n\n it('should render name and info icon', async () => {\n renderPanel();\n await screen.findByText('Fake Panel');\n screen.queryByLabelText('info-tooltip');\n });\n\n it('should render edit icons when in edit mode', () => {\n renderPanel(true);\n const panelTitle = screen.getByText('Fake Panel');\n userEvent.hover(panelTitle);\n screen.getByLabelText('drag handle');\n screen.getByLabelText('edit panel');\n screen.getByLabelText('delete panel');\n });\n});\n"],"names":["PluginRegistry","screen","userEvent","renderWithContext","mockPluginRegistryProps","FAKE_PANEL_PLUGIN","getTestDashboard","DashboardProvider","Panel","describe","createPanelProps","definition","kind","spec","display","name","description","plugin","panelGroupItemId","panelGroupId","itemIndex","renderPanel","isEditMode","addMockPlugin","pluginRegistryProps","initialState","dashboardSpec","it","findByText","queryByLabelText","panelTitle","getByText","hover","getByLabelText"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE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;oBAAE,GAAGE,gBAAgB,EAAE;kBAAI;cACf;UACL,CAClB,CAAC;IACJ,CAAC,AAAC;IAEFiB,EAAE,CAAC,kCAAkC,EAAE,UAAY;QACjDN,WAAW,EAAE,CAAC;QACd,MAAMpB,MAAM,CAAC2B,UAAU,CAAC,YAAY,CAAC,CAAC;QACtC3B,MAAM,CAAC4B,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEHF,EAAE,CAAC,4CAA4C,EAAE,IAAM;QACrDN,WAAW,CAAC,IAAI,CAAC,CAAC;QAClB,MAAMS,UAAU,GAAG7B,MAAM,CAAC8B,SAAS,CAAC,YAAY,CAAC,AAAC;QAClD7B,SAAS,CAAC8B,KAAK,CAACF,UAAU,CAAC,CAAC;QAC5B7B,MAAM,CAACgC,cAAc,CAAC,aAAa,CAAC,CAAC;QACrChC,MAAM,CAACgC,cAAc,CAAC,YAAY,CAAC,CAAC;QACpChC,MAAM,CAACgC,cAAc,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/Panel/Panel.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { screen, waitFor } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { PanelDefinition } from '@perses-dev/core';\nimport { renderWithContext } from '../../test';\nimport { Panel, PanelProps } from './Panel';\n\ndescribe('Panel', () => {\n const createTestPanel = (): PanelDefinition => ({\n kind: 'Panel',\n spec: {\n display: {\n name: 'Fake Panel Title',\n description: 'This is a fake panel',\n },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {},\n },\n },\n });\n\n // Helper to render the panel with some context set\n const renderPanel = (definition?: PanelDefinition, editHandlers?: PanelProps['editHandlers']) => {\n definition ??= createTestPanel();\n\n renderWithContext(<Panel definition={definition} editHandlers={editHandlers} />);\n };\n\n // Helper to get the panel once rendered\n const getPanel = () => screen.getByRole('region', { name: 'Fake Panel Title' });\n\n it('should render panel', async () => {\n renderPanel();\n\n const panel = getPanel();\n expect(panel).toBeInTheDocument();\n\n // Should diplay header with panel's title\n const header = screen.getByRole('banner');\n expect(header).toHaveTextContent('Fake Panel Title');\n\n // Should display chart's content from the fake panel plugin\n const content = screen.getByRole('figure');\n await waitFor(() => {\n expect(content).toHaveTextContent('TimeSeriesChart panel');\n });\n expect(content);\n });\n\n it('shows panel description', async () => {\n renderPanel();\n\n const panel = getPanel();\n\n // Description button should not be visible until hover on panel\n const missingButton = screen.queryByRole('button', { name: /description/i });\n expect(missingButton).not.toBeInTheDocument();\n userEvent.hover(panel);\n const descriptionButton = screen.getByRole('button', { name: /description/i });\n expect(descriptionButton).toBeInTheDocument();\n\n // Can hover to see panel description in tooltip\n userEvent.hover(descriptionButton);\n const tooltip = await screen.findByRole('tooltip');\n expect(tooltip).toHaveTextContent('This is a fake panel');\n });\n\n it('does not show description when panel does not have one', () => {\n // Render a panel without a description set\n const withoutDescription = createTestPanel();\n withoutDescription.spec.display.description = undefined;\n renderPanel(withoutDescription);\n\n const panel = getPanel();\n userEvent.hover(panel);\n const descriptionButton = screen.queryByRole('button', { name: /description/i });\n expect(descriptionButton).not.toBeInTheDocument();\n });\n\n it('does not show description in edit mode', () => {\n renderPanel(undefined, { onEditPanelClick: jest.fn(), onDeletePanelClick: jest.fn() });\n\n const panel = getPanel();\n userEvent.hover(panel);\n const descriptionButton = screen.queryByRole('button', { name: /description/i });\n expect(descriptionButton).not.toBeInTheDocument();\n });\n\n it('can trigger panel actions in edit mode', () => {\n const onEditPanelClick = jest.fn();\n const onDeletePanelClick = jest.fn();\n renderPanel(undefined, { onEditPanelClick, onDeletePanelClick });\n\n const panel = getPanel();\n userEvent.hover(panel);\n\n const editButton = screen.getByRole('button', { name: /edit/i });\n userEvent.click(editButton);\n\n const deleteButton = screen.getByRole('button', { name: /delete/i });\n userEvent.click(deleteButton);\n\n expect(onEditPanelClick).toHaveBeenCalledTimes(1);\n expect(onDeletePanelClick).toHaveBeenCalledTimes(1);\n });\n});\n"],"names":["screen","waitFor","userEvent","renderWithContext","Panel","describe","createTestPanel","kind","spec","display","name","description","plugin","renderPanel","definition","editHandlers","getPanel","getByRole","it","panel","expect","toBeInTheDocument","header","toHaveTextContent","content","missingButton","queryByRole","not","hover","descriptionButton","tooltip","findByRole","withoutDescription","undefined","onEditPanelClick","jest","fn","onDeletePanelClick","editButton","click","deleteButton","toHaveBeenCalledTimes"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,EAAEC,OAAO,QAAQ,wBAAwB,CAAC;AACzD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,iBAAiB,QAAQ,YAAY,CAAC;AAC/C,SAASC,KAAK,QAAoB,SAAS,CAAC;AAE5CC,QAAQ,CAAC,OAAO,EAAE,IAAM;IACtB,MAAMC,eAAe,GAAG,IAAwB,CAAA;YAC9CC,IAAI,EAAE,OAAO;YACbC,IAAI,EAAE;gBACJC,OAAO,EAAE;oBACPC,IAAI,EAAE,kBAAkB;oBACxBC,WAAW,EAAE,sBAAsB;iBACpC;gBACDC,MAAM,EAAE;oBACNL,IAAI,EAAE,iBAAiB;oBACvBC,IAAI,EAAE,EAAE;iBACT;aACF;SACF,CAAA,AAAC,AAAC;IAEH,mDAAmD;IACnD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Props } from '@mui/material';
3
+ declare type OmittedProps = 'children' | 'action' | 'title' | 'disableTypography';
4
+ export interface PanelHeaderProps extends Omit<CardHeaderProps, OmittedProps> {
5
+ id: string;
6
+ title: string;
7
+ description?: string;
8
+ editHandlers?: {
9
+ onEditPanelClick: () => void;
10
+ onDeletePanelClick: () => void;
11
+ };
12
+ isHovered: boolean;
13
+ }
14
+ export declare function PanelHeader({ id, title, description, editHandlers, isHovered, sx, ...rest }: PanelHeaderProps): JSX.Element;
15
+ export {};
16
+ //# sourceMappingURL=PanelHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PanelHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/PanelHeader.tsx"],"names":[],"mappings":";AAaA,OAAO,EAA6C,eAAe,EAAU,MAAM,eAAe,CAAC;AAOnG,aAAK,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,mBAAmB,CAAC;AAE1E,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC;IAC3E,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE;QACb,gBAAgB,EAAE,MAAM,IAAI,CAAC;QAC7B,kBAAkB,EAAE,MAAM,IAAI,CAAC;KAChC,CAAC;IACF,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,gBAAgB,eAiE7G"}