@perses-dev/dashboards 0.10.0 → 0.11.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 (193) hide show
  1. package/dist/cjs/components/Dashboard.js +4 -5
  2. package/dist/cjs/components/DashboardToolbar.js +11 -5
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +3 -11
  4. package/dist/cjs/components/GridLayout/GridLayout.js +8 -6
  5. package/dist/cjs/components/GridLayout/GridTitle.js +9 -11
  6. package/dist/cjs/components/Panel/DeletePanelDialog.js +12 -8
  7. package/dist/cjs/components/Panel/Panel.js +4 -13
  8. package/dist/cjs/components/Panel/Panel.test.js +4 -3
  9. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +1 -1
  10. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +3 -3
  11. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +21 -15
  12. package/dist/cjs/components/PanelDrawer/PanelPreview.js +9 -3
  13. package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
  14. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +70 -111
  15. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +22 -16
  16. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
  17. package/dist/cjs/components/PanelGroupDialog/index.js +29 -0
  18. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +8 -11
  19. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +20 -13
  20. package/dist/cjs/components/Variables/Variable.js +1 -0
  21. package/dist/cjs/components/Variables/VariableEditor.js +33 -0
  22. package/dist/cjs/components/Variables/VariableList.js +0 -1
  23. package/dist/cjs/components/index.js +1 -0
  24. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +20 -8
  25. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +122 -29
  26. package/dist/cjs/context/DashboardProvider/{panel-editing-slice.js → panel-editor-slice.js} +32 -13
  27. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +102 -0
  28. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +187 -17
  29. package/dist/cjs/context/TimeRangeProvider.js +20 -44
  30. package/dist/cjs/context/index.js +1 -1
  31. package/dist/cjs/context/useDashboardSpec.js +61 -0
  32. package/dist/cjs/index.js +1 -0
  33. package/dist/cjs/test/render.js +25 -5
  34. package/dist/cjs/test/setup-tests.js +4 -1
  35. package/dist/cjs/test/testDashboard.js +11 -10
  36. package/dist/cjs/utils/index.js +28 -0
  37. package/dist/cjs/utils/time-range-params.js +145 -0
  38. package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -4
  39. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -22
  40. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +42 -93
  41. package/dist/components/Dashboard.js +5 -6
  42. package/dist/components/Dashboard.js.map +1 -1
  43. package/dist/components/DashboardToolbar.d.ts.map +1 -1
  44. package/dist/components/DashboardToolbar.js +13 -7
  45. package/dist/components/DashboardToolbar.js.map +1 -1
  46. package/dist/components/GridLayout/GridItemContent.d.ts +2 -4
  47. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  48. package/dist/components/GridLayout/GridItemContent.js +4 -12
  49. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  50. package/dist/components/GridLayout/GridLayout.d.ts +2 -3
  51. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  52. package/dist/components/GridLayout/GridLayout.js +9 -7
  53. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  54. package/dist/components/GridLayout/GridTitle.d.ts +2 -1
  55. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  56. package/dist/components/GridLayout/GridTitle.js +10 -12
  57. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  58. package/dist/components/Panel/DeletePanelDialog.d.ts +1 -1
  59. package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -1
  60. package/dist/components/Panel/DeletePanelDialog.js +13 -9
  61. package/dist/components/Panel/DeletePanelDialog.js.map +1 -1
  62. package/dist/components/Panel/Panel.d.ts +2 -2
  63. package/dist/components/Panel/Panel.d.ts.map +1 -1
  64. package/dist/components/Panel/Panel.js +5 -14
  65. package/dist/components/Panel/Panel.js.map +1 -1
  66. package/dist/components/Panel/Panel.test.d.ts +1 -1
  67. package/dist/components/Panel/Panel.test.d.ts.map +1 -1
  68. package/dist/components/Panel/Panel.test.js +4 -3
  69. package/dist/components/Panel/Panel.test.js.map +1 -1
  70. package/dist/components/PanelDrawer/PanelDrawer.js +2 -2
  71. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  72. package/dist/components/PanelDrawer/PanelDrawer.test.js +3 -3
  73. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
  74. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
  75. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  76. package/dist/components/PanelDrawer/PanelEditorForm.js +22 -16
  77. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  78. package/dist/components/PanelDrawer/PanelPreview.d.ts +2 -2
  79. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  80. package/dist/components/PanelDrawer/PanelPreview.js +9 -3
  81. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  82. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +1 -2
  83. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  84. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
  85. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  86. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +4 -2
  87. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  88. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +73 -112
  89. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  90. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +21 -15
  91. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
  92. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
  93. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
  94. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
  95. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
  96. package/dist/components/PanelGroupDialog/index.d.ts +3 -0
  97. package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
  98. package/dist/components/PanelGroupDialog/index.js +16 -0
  99. package/dist/components/PanelGroupDialog/index.js.map +1 -0
  100. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  101. package/dist/components/TimeRangeControls/TimeRangeControls.js +11 -14
  102. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  103. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +21 -14
  104. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  105. package/dist/components/Variables/Variable.js +1 -0
  106. package/dist/components/Variables/Variable.js.map +1 -1
  107. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  108. package/dist/components/Variables/VariableEditor.js +33 -0
  109. package/dist/components/Variables/VariableEditor.js.map +1 -1
  110. package/dist/components/Variables/VariableList.js +0 -1
  111. package/dist/components/Variables/VariableList.js.map +1 -1
  112. package/dist/components/index.d.ts +1 -0
  113. package/dist/components/index.d.ts.map +1 -1
  114. package/dist/components/index.js +1 -0
  115. package/dist/components/index.js.map +1 -1
  116. package/dist/context/DashboardProvider/DashboardProvider.d.ts +7 -5
  117. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  118. package/dist/context/DashboardProvider/DashboardProvider.js +19 -7
  119. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  120. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +64 -22
  121. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  122. package/dist/context/DashboardProvider/dashboard-provider-api.js +133 -26
  123. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  124. package/dist/context/DashboardProvider/index.d.ts +2 -0
  125. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  126. package/dist/context/DashboardProvider/index.js.map +1 -1
  127. package/dist/context/DashboardProvider/{panel-editing-slice.d.ts → panel-editor-slice.d.ts} +28 -13
  128. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
  129. package/dist/context/DashboardProvider/{panel-editing-slice.js → panel-editor-slice.js} +33 -14
  130. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
  131. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +40 -0
  132. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
  133. package/dist/context/DashboardProvider/panel-group-editor-slice.js +96 -0
  134. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
  135. package/dist/context/DashboardProvider/panel-group-slice.d.ts +75 -10
  136. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  137. package/dist/context/DashboardProvider/panel-group-slice.js +189 -17
  138. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  139. package/dist/context/TimeRangeProvider.d.ts +9 -2
  140. package/dist/context/TimeRangeProvider.d.ts.map +1 -1
  141. package/dist/context/TimeRangeProvider.js +15 -43
  142. package/dist/context/TimeRangeProvider.js.map +1 -1
  143. package/dist/context/index.d.ts +1 -1
  144. package/dist/context/index.d.ts.map +1 -1
  145. package/dist/context/index.js +1 -1
  146. package/dist/context/index.js.map +1 -1
  147. package/dist/context/useDashboardSpec.d.ts +3 -0
  148. package/dist/context/useDashboardSpec.d.ts.map +1 -0
  149. package/dist/context/useDashboardSpec.js +55 -0
  150. package/dist/context/useDashboardSpec.js.map +1 -0
  151. package/dist/index.d.ts +1 -0
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +1 -0
  154. package/dist/index.js.map +1 -1
  155. package/dist/test/render.d.ts +2 -1
  156. package/dist/test/render.d.ts.map +1 -1
  157. package/dist/test/render.js +25 -5
  158. package/dist/test/render.js.map +1 -1
  159. package/dist/test/setup-tests.d.ts.map +1 -1
  160. package/dist/test/setup-tests.js +4 -0
  161. package/dist/test/setup-tests.js.map +1 -1
  162. package/dist/test/testDashboard.d.ts.map +1 -1
  163. package/dist/test/testDashboard.js +11 -10
  164. package/dist/test/testDashboard.js.map +1 -1
  165. package/dist/utils/index.d.ts +2 -0
  166. package/dist/utils/index.d.ts.map +1 -0
  167. package/dist/utils/index.js +15 -0
  168. package/dist/utils/index.js.map +1 -0
  169. package/dist/utils/time-range-params.d.ts +25 -0
  170. package/dist/utils/time-range-params.d.ts.map +1 -0
  171. package/dist/utils/time-range-params.js +137 -0
  172. package/dist/utils/time-range-params.js.map +1 -0
  173. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  174. package/dist/views/ViewDashboard/DashboardApp.js +1 -3
  175. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  176. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  177. package/dist/views/ViewDashboard/ViewDashboard.js +5 -22
  178. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  179. package/dist/views/ViewDashboard/tests/panelGroups.test.js +45 -96
  180. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
  181. package/package.json +5 -4
  182. package/dist/cjs/context/DashboardProvider/layout-slice.js +0 -200
  183. package/dist/cjs/context/QueryStringProvider.js +0 -89
  184. package/dist/context/DashboardProvider/layout-slice.d.ts +0 -57
  185. package/dist/context/DashboardProvider/layout-slice.d.ts.map +0 -1
  186. package/dist/context/DashboardProvider/layout-slice.js +0 -196
  187. package/dist/context/DashboardProvider/layout-slice.js.map +0 -1
  188. package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +0 -1
  189. package/dist/context/DashboardProvider/panel-editing-slice.js.map +0 -1
  190. package/dist/context/QueryStringProvider.d.ts +0 -13
  191. package/dist/context/QueryStringProvider.d.ts.map +0 -1
  192. package/dist/context/QueryStringProvider.js +0 -40
  193. package/dist/context/QueryStringProvider.js.map +0 -1
@@ -24,15 +24,14 @@ const _components = require("@perses-dev/components");
24
24
  const _context = require("../context");
25
25
  const _gridLayout = require("./GridLayout");
26
26
  function Dashboard(props) {
27
- const { layouts } = (0, _context.useLayouts)();
27
+ const panelGroupIds = (0, _context.usePanelGroupIds)();
28
28
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
29
29
  ...props,
30
30
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
31
31
  FallbackComponent: _components.ErrorAlert,
32
- children: layouts.map((layout, groupIndex)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridLayout.GridLayout, {
33
- groupIndex: groupIndex,
34
- groupDefinition: layout
35
- }, layout.id))
32
+ children: panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridLayout.GridLayout, {
33
+ panelGroupId: panelGroupId
34
+ }, panelGroupId))
36
35
  })
37
36
  });
38
37
  }
@@ -34,12 +34,17 @@ function _interopRequireDefault(obj) {
34
34
  const DashboardToolbar = (props)=>{
35
35
  const { dashboardName } = props;
36
36
  const { isEditMode , setEditMode } = (0, _context.useEditMode)();
37
- const { openPanelGroupDialog } = (0, _context.usePanelGroupDialog)();
38
- const { addPanel } = (0, _context.usePanels)();
37
+ const { openAddPanelGroup , openAddPanel , reset , save } = (0, _context.useDashboardActions)();
38
+ const isLaptopSize = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('sm'));
39
39
  const onEditButtonClick = ()=>{
40
40
  setEditMode(true);
41
41
  };
42
42
  const onCancelButtonClick = ()=>{
43
+ reset();
44
+ setEditMode(false);
45
+ };
46
+ const onSave = ()=>{
47
+ save();
43
48
  setEditMode(false);
44
49
  };
45
50
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
@@ -70,6 +75,7 @@ const DashboardToolbar = (props)=>{
70
75
  children: [
71
76
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
72
77
  variant: "contained",
78
+ onClick: onSave,
73
79
  children: "Save"
74
80
  }),
75
81
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
@@ -103,12 +109,12 @@ const DashboardToolbar = (props)=>{
103
109
  children: [
104
110
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
105
111
  startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_plusBoxOutline.default, {}),
106
- onClick: ()=>openPanelGroupDialog(),
112
+ onClick: openAddPanelGroup,
107
113
  children: "Add Panel Group"
108
114
  }),
109
115
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
110
116
  startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_chartBoxPlusOutline.default, {}),
111
- onClick: ()=>addPanel(0),
117
+ onClick: openAddPanel,
112
118
  children: "Add Panel"
113
119
  }),
114
120
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.TimeRangeControls, {})
@@ -139,7 +145,7 @@ const DashboardToolbar = (props)=>{
139
145
  },
140
146
  children: [
141
147
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.TimeRangeControls, {}),
142
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
148
+ isLaptopSize && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
143
149
  variant: "outlined",
144
150
  startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencilOutline.default, {}),
145
151
  onClick: onEditButtonClick,
@@ -19,21 +19,13 @@ Object.defineProperty(exports, "GridItemContent", {
19
19
  get: ()=>GridItemContent
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
- const _core = require("@perses-dev/core");
23
22
  const _context = require("../../context");
24
23
  const _panel = require("../Panel/Panel");
25
24
  function GridItemContent(props) {
26
- const { content , groupIndex , itemIndex } = props;
27
- // Find the panel referenced in content in the store
28
- const { panels } = (0, _context.usePanels)();
29
- const panelKey = (0, _core.getPanelKeyFromRef)(content);
30
- const panelDefinition = panels[panelKey];
31
- if (panelDefinition === undefined) {
32
- throw new Error(`Panel with key '${panelKey}' was not found`);
33
- }
25
+ const { panelGroupItemId } = props;
26
+ const panelDefinition = (0, _context.usePanel)(panelGroupItemId);
34
27
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
35
28
  definition: panelDefinition,
36
- groupIndex: groupIndex,
37
- itemIndex: itemIndex
29
+ panelGroupItemId: panelGroupItemId
38
30
  });
39
31
  }
@@ -29,7 +29,8 @@ const _gridTitle = require("./GridTitle");
29
29
  const _gridItemContent = require("./GridItemContent");
30
30
  const ResponsiveGridLayout = (0, _reactGridLayout.WidthProvider)(_reactGridLayout.Responsive);
31
31
  function GridLayout(props) {
32
- const { groupIndex , groupDefinition , ...others } = props;
32
+ const { panelGroupId , ...others } = props;
33
+ const groupDefinition = (0, _context.usePanelGroup)(panelGroupId);
33
34
  var ref;
34
35
  const [isOpen, setIsOpen] = (0, _react.useState)((ref = !groupDefinition.isCollapsed) !== null && ref !== void 0 ? ref : true);
35
36
  const { isEditMode } = (0, _context.useEditMode)();
@@ -48,7 +49,7 @@ function GridLayout(props) {
48
49
  },
49
50
  children: [
50
51
  groupDefinition.title !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridTitle.GridTitle, {
51
- groupIndex: groupIndex,
52
+ panelGroupId: panelGroupId,
52
53
  title: groupDefinition.title,
53
54
  collapse: groupDefinition.isCollapsed === undefined ? undefined : {
54
55
  isOpen,
@@ -81,7 +82,7 @@ function GridLayout(props) {
81
82
  ],
82
83
  isDraggable: isEditMode,
83
84
  isResizable: isEditMode,
84
- children: groupDefinition.items.map(({ x , y , width , height , content }, itemIndex)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
85
+ children: groupDefinition.items.map(({ x , y , width , height }, itemIndex)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
85
86
  "data-grid": {
86
87
  x,
87
88
  y,
@@ -91,9 +92,10 @@ function GridLayout(props) {
91
92
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
92
93
  FallbackComponent: _components.ErrorAlert,
93
94
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridItemContent.GridItemContent, {
94
- groupIndex: groupIndex,
95
- itemIndex: itemIndex,
96
- content: content
95
+ panelGroupItemId: {
96
+ panelGroupId,
97
+ itemIndex
98
+ }
97
99
  })
98
100
  })
99
101
  }, itemIndex))
@@ -35,12 +35,10 @@ function _interopRequireDefault(obj) {
35
35
  };
36
36
  }
37
37
  function GridTitle(props) {
38
- const { groupIndex , title , collapse } = props;
38
+ const { panelGroupId , title , collapse } = props;
39
39
  const [isHovered, setIsHovered] = (0, _react.useState)(false);
40
- const { openPanelGroupDialog , openDeletePanelGroupDialog } = (0, _context.usePanelGroupDialog)();
41
- const { addPanel } = (0, _context.usePanels)();
40
+ const { openAddPanel , openEditPanelGroup , deletePanelGroup , moveUp , moveDown } = (0, _context.usePanelGroupActions)(panelGroupId);
42
41
  const { isEditMode } = (0, _context.useEditMode)();
43
- const { layouts , swapPanelGroups } = (0, _context.useLayouts)();
44
42
  const text = /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
45
43
  variant: "h2",
46
44
  sx: {
@@ -73,29 +71,29 @@ function GridTitle(props) {
73
71
  children: [
74
72
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
75
73
  "aria-label": "add panel to group",
76
- onClick: ()=>addPanel(groupIndex),
74
+ onClick: openAddPanel,
77
75
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_plus.default, {})
78
76
  }),
79
77
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
80
78
  "aria-label": "edit group",
81
- onClick: ()=>openPanelGroupDialog(groupIndex),
79
+ onClick: openEditPanelGroup,
82
80
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencilOutline.default, {})
83
81
  }),
84
82
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
85
83
  "aria-label": "delete group",
86
- onClick: ()=>openDeletePanelGroupDialog(groupIndex),
84
+ onClick: deletePanelGroup,
87
85
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_deleteOutline.default, {})
88
86
  }),
89
87
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
90
88
  "aria-label": "move group down",
91
- disabled: groupIndex === layouts.length - 1,
92
- onClick: ()=>swapPanelGroups(groupIndex, groupIndex + 1),
89
+ disabled: moveDown === undefined,
90
+ onClick: moveDown,
93
91
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowDown.default, {})
94
92
  }),
95
93
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
96
94
  "aria-label": "move group up",
97
- disabled: groupIndex === 0,
98
- onClick: ()=>swapPanelGroups(groupIndex, groupIndex - 1),
95
+ disabled: moveUp === undefined,
96
+ onClick: moveUp,
99
97
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowUp.default, {})
100
98
  })
101
99
  ]
@@ -28,7 +28,7 @@ function _interopRequireDefault(obj) {
28
28
  };
29
29
  }
30
30
  const DeletePanelDialog = ()=>{
31
- const { deletePanelDialog , closeDeletePanelDialog } = (0, _context.usePanels)();
31
+ const { deletePanelDialog , closeDeletePanelDialog } = (0, _context.useDeletePanelDialog)();
32
32
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Dialog, {
33
33
  open: deletePanelDialog !== undefined,
34
34
  children: [
@@ -52,25 +52,29 @@ const DeletePanelDialog = ()=>{
52
52
  });
53
53
  };
54
54
  const DeletePanelForm = ({ deletePanelDialog })=>{
55
- var ref;
56
- const { layouts } = (0, _context.useLayouts)();
57
- const { deletePanels , closeDeletePanelDialog } = (0, _context.usePanels)();
55
+ const { deletePanels , closeDeletePanelDialog } = (0, _context.useDeletePanelDialog)();
58
56
  const handleDelete = (e)=>{
59
57
  e.preventDefault();
60
- const { layoutItem } = deletePanelDialog;
58
+ const { panelGroupItemId } = deletePanelDialog;
61
59
  deletePanels([
62
- layoutItem
60
+ panelGroupItemId
63
61
  ]);
64
62
  closeDeletePanelDialog();
65
63
  };
66
64
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("form", {
67
65
  onSubmit: handleDelete,
68
66
  children: [
69
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogContent, {
67
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogContent, {
70
68
  sx: {
71
69
  width: '500px'
72
70
  },
73
- children: `Are you sure you want to delete ${deletePanelDialog.panelName} from ${(ref = layouts[deletePanelDialog.layoutItem.groupIndex]) === null || ref === void 0 ? void 0 : ref.title}? This action cannot be undone.`
71
+ children: [
72
+ "Are you sure you want to delete ",
73
+ deletePanelDialog.panelName,
74
+ " from ",
75
+ deletePanelDialog.panelGroupName,
76
+ "? This action cannot be undone."
77
+ ]
74
78
  }),
75
79
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
76
80
  children: [
@@ -36,7 +36,7 @@ function _interopRequireDefault(obj) {
36
36
  };
37
37
  }
38
38
  function Panel(props) {
39
- const { definition , groupIndex , itemIndex , ...others } = props;
39
+ const { definition , panelGroupItemId , ...others } = props;
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)({
@@ -60,13 +60,7 @@ function Panel(props) {
60
60
  // TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart
61
61
  const panelPadding = 1.5;
62
62
  const { isEditMode } = (0, _context.useEditMode)();
63
- const { editPanel , openDeletePanelDialog } = (0, _context.usePanels)();
64
- const handleEditButtonClick = ()=>{
65
- editPanel({
66
- groupIndex,
67
- itemIndex
68
- });
69
- };
63
+ const { openEditPanel , openDeletePanelDialog } = (0, _context.usePanelActions)(panelGroupItemId);
70
64
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Card, {
71
65
  ref: ref,
72
66
  sx: {
@@ -126,16 +120,13 @@ function Panel(props) {
126
120
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(IconButton, {
127
121
  "aria-label": "edit panel",
128
122
  size: "small",
129
- onClick: handleEditButtonClick,
123
+ onClick: openEditPanel,
130
124
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencil.default, {})
131
125
  }),
132
126
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(IconButton, {
133
127
  "aria-label": "delete panel",
134
128
  size: "small",
135
- onClick: ()=>openDeletePanelDialog({
136
- groupIndex,
137
- itemIndex
138
- }),
129
+ onClick: openDeletePanelDialog,
139
130
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_deleteOutline.default, {})
140
131
  }),
141
132
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(IconButton, {
@@ -16,7 +16,6 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  const _jsxRuntime = require("react/jsx-runtime");
18
18
  const _pluginSystem = require("@perses-dev/plugin-system");
19
- require("intersection-observer");
20
19
  const _react = require("@testing-library/react");
21
20
  const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
22
21
  const _test = require("../../test");
@@ -44,8 +43,10 @@ describe('Panel', ()=>{
44
43
  }
45
44
  }
46
45
  },
47
- groupIndex: 0,
48
- itemIndex: 0
46
+ panelGroupItemId: {
47
+ panelGroupId: 0,
48
+ itemIndex: 0
49
+ }
49
50
  };
50
51
  };
51
52
  // Helper to render the panel with some context set
@@ -25,7 +25,7 @@ const _components = require("@perses-dev/components");
25
25
  const _context = require("../../context");
26
26
  const _panelEditorForm = require("./PanelEditorForm");
27
27
  const PanelDrawer = ()=>{
28
- const { panelEditor } = (0, _context.usePanels)();
28
+ const panelEditor = (0, _context.usePanelEditor)();
29
29
  // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
30
30
  const [isClosing, setIsClosing] = (0, _react.useState)(false);
31
31
  const handleClose = ()=>setIsClosing(true);
@@ -54,7 +54,7 @@ describe('Panel Drawer', ()=>{
54
54
  it('should add new panel', async ()=>{
55
55
  const storeApi = renderPanelDrawer();
56
56
  // Open the drawer for a new panel (i.e. no panel key)
57
- (0, _testUtils.act)(()=>storeApi.getState().addPanel(0));
57
+ (0, _testUtils.act)(()=>storeApi.getState().openAddPanel(0));
58
58
  const nameInput = await _react.screen.findByLabelText(/Name/);
59
59
  _userEvent.default.type(nameInput, 'New Panel');
60
60
  _userEvent.default.click(_react.screen.getByText('Add'));
@@ -79,8 +79,8 @@ describe('Panel Drawer', ()=>{
79
79
  it('should edit an existing panel', async ()=>{
80
80
  const storeApi = renderPanelDrawer();
81
81
  // Open the drawer for an existing panel
82
- (0, _testUtils.act)(()=>storeApi.getState().editPanel({
83
- groupIndex: 0,
82
+ (0, _testUtils.act)(()=>storeApi.getState().openEditPanel({
83
+ panelGroupId: 0,
84
84
  itemIndex: 0
85
85
  }));
86
86
  const nameInput = await _react.screen.findByLabelText(/Name/);
@@ -34,10 +34,10 @@ const _panelPreview = require("./PanelPreview");
34
34
  function PanelEditorForm(props) {
35
35
  var ref;
36
36
  const { initialValues , onSubmit } = props;
37
- const { layouts } = (0, _context.useLayouts)();
37
+ const panelGroups = (0, _context.useListPanelGroups)();
38
38
  const [name, setName] = (0, _react.useState)(initialValues.name);
39
39
  const [description, setDescription] = (0, _react.useState)(initialValues.description);
40
- const [groupIndex, setGroupIndex] = (0, _react.useState)(initialValues.groupIndex);
40
+ const [groupId, setGroupId] = (0, _react.useState)(initialValues.groupId);
41
41
  const [kind, setKind] = (0, _react.useState)(initialValues.kind);
42
42
  const [spec, setSpec] = (0, _react.useState)(initialValues.spec);
43
43
  // Use common plugin editor logic even though we've split the inputs up in this form
@@ -58,35 +58,38 @@ function PanelEditorForm(props) {
58
58
  if (typeof value === 'string') {
59
59
  return;
60
60
  }
61
- setGroupIndex(value);
61
+ setGroupId(value);
62
62
  };
63
63
  const handleSubmit = (e)=>{
64
64
  e.preventDefault();
65
- if (spec === undefined) {
66
- throw new Error('Cannot submit without a plugin spec');
67
- }
68
65
  const values = {
69
66
  name,
70
67
  description,
71
- groupIndex,
68
+ groupId,
72
69
  kind,
73
70
  spec
74
71
  };
75
72
  onSubmit(values);
76
73
  };
77
74
  var _title, ref1;
78
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)("form", {
75
+ return(// Grid maxHeight allows user to scroll inside Drawer to see all content
76
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)("form", {
79
77
  id: panelEditorFormId,
80
78
  onSubmit: handleSubmit,
81
79
  children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
82
80
  container: true,
83
81
  spacing: 2,
82
+ sx: {
83
+ overflowY: 'scroll',
84
+ maxHeight: '90vh'
85
+ },
84
86
  children: [
85
87
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
86
88
  item: true,
87
89
  xs: 8,
88
90
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
89
91
  required: true,
92
+ fullWidth: true,
90
93
  label: "Name",
91
94
  value: name,
92
95
  variant: "outlined",
@@ -97,6 +100,7 @@ function PanelEditorForm(props) {
97
100
  item: true,
98
101
  xs: 4,
99
102
  children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
103
+ fullWidth: true,
100
104
  children: [
101
105
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
102
106
  id: "select-group",
@@ -106,12 +110,12 @@ function PanelEditorForm(props) {
106
110
  required: true,
107
111
  labelId: "select-group",
108
112
  label: "Group",
109
- value: groupIndex !== null && groupIndex !== void 0 ? groupIndex : 0,
113
+ value: groupId,
110
114
  onChange: handleGroupChange,
111
- children: layouts.map((layout, index)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
112
- value: index,
113
- children: (_title = layout.title) !== null && _title !== void 0 ? _title : `Group ${index + 1}`
114
- }, index))
115
+ children: panelGroups.map((panelGroup, index)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
116
+ value: panelGroup.id,
117
+ children: (_title = panelGroup.title) !== null && _title !== void 0 ? _title : `Group ${index + 1}`
118
+ }, panelGroup.id))
115
119
  })
116
120
  ]
117
121
  })
@@ -120,6 +124,7 @@ function PanelEditorForm(props) {
120
124
  item: true,
121
125
  xs: 8,
122
126
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
127
+ fullWidth: true,
123
128
  label: "Description",
124
129
  value: description,
125
130
  variant: "outlined",
@@ -131,6 +136,7 @@ function PanelEditorForm(props) {
131
136
  xs: 4,
132
137
  children: [
133
138
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
139
+ fullWidth: true,
134
140
  disabled: pluginEditor.isLoading,
135
141
  error: pluginEditor.error !== null,
136
142
  children: [
@@ -169,7 +175,7 @@ function PanelEditorForm(props) {
169
175
  name: name,
170
176
  description: description,
171
177
  spec: spec,
172
- groupIndex: groupIndex
178
+ groupId: groupId
173
179
  })
174
180
  })
175
181
  ]
@@ -189,6 +195,6 @@ function PanelEditorForm(props) {
189
195
  })
190
196
  ]
191
197
  })
192
- });
198
+ }));
193
199
  }
194
200
  const panelEditorFormId = 'panel-editor-form';
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "PanelPreview", {
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _material = require("@mui/material");
23
23
  const _panel = require("../Panel");
24
- function PanelPreview({ name , description , kind , spec , groupIndex }) {
24
+ function PanelPreview({ name , description , kind , spec , groupId }) {
25
25
  const previewValues = {
26
26
  definition: {
27
27
  kind: 'Panel',
@@ -36,9 +36,15 @@ function PanelPreview({ name , description , kind , spec , groupIndex }) {
36
36
  }
37
37
  }
38
38
  },
39
- groupIndex,
40
- itemIndex: 0
39
+ // TODO: what should itemIndex be?
40
+ panelGroupItemId: {
41
+ panelGroupId: groupId,
42
+ itemIndex: 0
43
+ }
41
44
  };
45
+ if (!kind) {
46
+ return null;
47
+ }
42
48
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
43
49
  height: 300,
44
50
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
@@ -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, "DeletePanelGroupDialog", {
18
18
  enumerable: true,
19
- get: ()=>_default
19
+ get: ()=>DeletePanelGroupDialog
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _material = require("@mui/material");
@@ -28,18 +28,17 @@ function _interopRequireDefault(obj) {
28
28
  };
29
29
  }
30
30
  const DeletePanelGroupDialog = ()=>{
31
- var ref;
32
- const { layouts , deletePanelGroup } = (0, _context.useLayouts)();
33
- const { deletePanelGroupDialog , closeDeletePanelGroupDialog } = (0, _context.usePanelGroupDialog)();
34
- const groupIndex = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.groupIndex;
31
+ const { deletePanelGroupDialog , closeDeletePanelGroupDialog , deletePanelGroup } = (0, _context.useDeletePanelGroupDialog)();
32
+ const panelGroupId = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.panelGroupId;
35
33
  const handleDelete = (e)=>{
36
34
  e.preventDefault();
37
- if (groupIndex == undefined) {
35
+ if (panelGroupId == undefined) {
38
36
  throw new Error('group index is undefined');
39
37
  }
40
- deletePanelGroup(groupIndex);
38
+ deletePanelGroup(panelGroupId);
41
39
  closeDeletePanelGroupDialog();
42
40
  };
41
+ var ref;
43
42
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Dialog, {
44
43
  open: deletePanelGroupDialog !== undefined,
45
44
  children: [
@@ -59,11 +58,15 @@ const DeletePanelGroupDialog = ()=>{
59
58
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)("form", {
60
59
  onSubmit: handleDelete,
61
60
  children: [
62
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogContent, {
61
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogContent, {
63
62
  sx: {
64
63
  width: '500px'
65
64
  },
66
- children: `Are you sure you want to delete ${groupIndex !== undefined && layouts[groupIndex] !== undefined ? (ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.title : 'panel group'}? This will delete all the panels within the group.`
65
+ children: [
66
+ "Are you sure you want to delete ",
67
+ (ref = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.panelGroupName) !== null && ref !== void 0 ? ref : 'panel group',
68
+ "? This will delete all the panels within the group."
69
+ ]
67
70
  }),
68
71
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
69
72
  children: [
@@ -83,4 +86,3 @@ const DeletePanelGroupDialog = ()=>{
83
86
  ]
84
87
  });
85
88
  };
86
- const _default = DeletePanelGroupDialog;