@perses-dev/dashboards 0.0.0-snapshot-color-palette-gen-test-0ebddd6 → 0.0.0-snapshot-saving-defaults-refinements-1b25cec

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 (212) hide show
  1. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +79 -0
  2. package/dist/cjs/{stories/decorators/WithQueryParams.js → components/DashboardStickyToolbar/index.js} +11 -12
  3. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +8 -24
  4. package/dist/cjs/components/EditJsonButton/EditJsonButton.js +1 -0
  5. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +5 -0
  6. package/dist/cjs/components/GridLayout/GridItemContent.js +22 -4
  7. package/dist/cjs/components/GridLayout/GridLayout.js +31 -2
  8. package/dist/cjs/components/GridLayout/GridTitle.js +30 -9
  9. package/dist/cjs/components/Panel/Panel.js +2 -2
  10. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +41 -34
  11. package/dist/cjs/components/PanelDrawer/PanelPreview.js +32 -18
  12. package/dist/cjs/components/PanelDrawer/usePanelEditor.js +87 -0
  13. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +92 -0
  14. package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +28 -0
  15. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +81 -0
  16. package/dist/cjs/components/SaveDashboardButton/index.js +28 -0
  17. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +5 -5
  18. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +124 -198
  19. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +178 -0
  20. package/dist/cjs/components/Variables/VariableEditorForm/index.js +1 -0
  21. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
  22. package/dist/cjs/components/Variables/VariableList.js +16 -55
  23. package/dist/cjs/components/Variables/index.js +1 -0
  24. package/dist/cjs/components/index.js +3 -0
  25. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +9 -8
  26. package/dist/cjs/context/DashboardProvider/common.js +26 -6
  27. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +13 -4
  28. package/dist/cjs/context/DashboardProvider/index.js +1 -0
  29. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +8 -32
  30. package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +33 -0
  31. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +56 -7
  32. package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +2 -0
  33. package/dist/cjs/context/TemplateVariableProvider/utils.js +44 -0
  34. package/dist/cjs/context/useDashboard.js +4 -4
  35. package/dist/cjs/stories/decorators/WithDatasourceStore.js +2 -47
  36. package/dist/cjs/stories/decorators/index.js +0 -4
  37. package/dist/cjs/test/datasource-provider.js +70 -0
  38. package/dist/cjs/test/index.js +1 -0
  39. package/dist/cjs/test/plugin-registry.js +11 -5
  40. package/dist/cjs/test/render.js +35 -13
  41. package/dist/cjs/test/testDashboard.js +79 -79
  42. package/dist/cjs/utils/index.js +1 -0
  43. package/dist/cjs/{stories/decorators/WithQueryClient.js → utils/time.js} +9 -11
  44. package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
  45. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +9 -0
  46. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -0
  47. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +68 -0
  48. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -0
  49. package/dist/components/DashboardStickyToolbar/index.d.ts +2 -0
  50. package/dist/components/DashboardStickyToolbar/index.d.ts.map +1 -0
  51. package/dist/{stories/decorators/WithQueryClient.js → components/DashboardStickyToolbar/index.js} +2 -10
  52. package/dist/components/DashboardStickyToolbar/index.js.map +1 -0
  53. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
  54. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  55. package/dist/components/DashboardToolbar/DashboardToolbar.js +10 -26
  56. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  57. package/dist/components/EditJsonButton/EditJsonButton.js +1 -0
  58. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  59. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  60. package/dist/components/EditJsonDialog/EditJsonDialog.js +5 -0
  61. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  62. package/dist/components/GridLayout/GridItemContent.d.ts +1 -0
  63. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  64. package/dist/components/GridLayout/GridItemContent.js +22 -4
  65. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  66. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  67. package/dist/components/GridLayout/GridLayout.js +31 -2
  68. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  69. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  70. package/dist/components/GridLayout/GridTitle.js +30 -9
  71. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  72. package/dist/components/Panel/Panel.d.ts +1 -1
  73. package/dist/components/Panel/Panel.d.ts.map +1 -1
  74. package/dist/components/Panel/Panel.js +3 -3
  75. package/dist/components/Panel/Panel.js.map +1 -1
  76. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  77. package/dist/components/PanelDrawer/PanelEditorForm.js +42 -35
  78. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  79. package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -1
  80. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  81. package/dist/components/PanelDrawer/PanelPreview.js +32 -18
  82. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  83. package/dist/components/PanelDrawer/usePanelEditor.d.ts +15 -0
  84. package/dist/components/PanelDrawer/usePanelEditor.d.ts.map +1 -0
  85. package/dist/components/PanelDrawer/usePanelEditor.js +84 -0
  86. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -0
  87. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +3 -0
  88. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -0
  89. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +86 -0
  90. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -0
  91. package/dist/components/SaveChangesConfirmationDialog/index.d.ts +2 -0
  92. package/dist/components/SaveChangesConfirmationDialog/index.d.ts.map +1 -0
  93. package/dist/{stories/decorators/WithQueryParams.js → components/SaveChangesConfirmationDialog/index.js} +2 -10
  94. package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -0
  95. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +10 -0
  96. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -0
  97. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +75 -0
  98. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -0
  99. package/dist/components/SaveDashboardButton/index.d.ts +2 -0
  100. package/dist/components/SaveDashboardButton/index.d.ts.map +1 -0
  101. package/dist/components/SaveDashboardButton/index.js +15 -0
  102. package/dist/components/SaveDashboardButton/index.js.map +1 -0
  103. package/dist/components/TimeRangeControls/TimeRangeControls.js +6 -6
  104. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  105. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +4 -2
  106. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  107. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +127 -196
  108. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  109. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +16 -0
  110. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -0
  111. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +122 -0
  112. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -0
  113. package/dist/components/Variables/VariableEditorForm/index.d.ts +1 -0
  114. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -1
  115. package/dist/components/Variables/VariableEditorForm/index.js +1 -0
  116. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
  117. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  118. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
  119. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  120. package/dist/components/Variables/VariableList.d.ts +1 -7
  121. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  122. package/dist/components/Variables/VariableList.js +18 -52
  123. package/dist/components/Variables/VariableList.js.map +1 -1
  124. package/dist/components/Variables/index.d.ts +1 -0
  125. package/dist/components/Variables/index.d.ts.map +1 -1
  126. package/dist/components/Variables/index.js +1 -0
  127. package/dist/components/Variables/index.js.map +1 -1
  128. package/dist/components/index.d.ts +3 -0
  129. package/dist/components/index.d.ts.map +1 -1
  130. package/dist/components/index.js +3 -0
  131. package/dist/components/index.js.map +1 -1
  132. package/dist/context/DashboardProvider/DashboardProvider.d.ts +4 -3
  133. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  134. package/dist/context/DashboardProvider/DashboardProvider.js +9 -8
  135. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  136. package/dist/context/DashboardProvider/common.d.ts +3 -0
  137. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  138. package/dist/context/DashboardProvider/common.js +17 -2
  139. package/dist/context/DashboardProvider/common.js.map +1 -1
  140. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +6 -1
  141. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  142. package/dist/context/DashboardProvider/dashboard-provider-api.js +11 -3
  143. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  144. package/dist/context/DashboardProvider/index.d.ts +1 -0
  145. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  146. package/dist/context/DashboardProvider/index.js +1 -0
  147. package/dist/context/DashboardProvider/index.js.map +1 -1
  148. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +3 -6
  149. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  150. package/dist/context/DashboardProvider/panel-editor-slice.js +9 -33
  151. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  152. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +15 -0
  153. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -0
  154. package/dist/context/DashboardProvider/save-changes-dialog-slice.js +27 -0
  155. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -0
  156. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +10 -0
  157. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  158. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +51 -7
  159. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  160. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
  161. package/dist/context/TemplateVariableProvider/hydrationUtils.js +2 -0
  162. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
  163. package/dist/context/TemplateVariableProvider/utils.d.ts +7 -0
  164. package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -0
  165. package/dist/context/TemplateVariableProvider/utils.js +40 -0
  166. package/dist/context/TemplateVariableProvider/utils.js.map +1 -0
  167. package/dist/context/useDashboard.d.ts.map +1 -1
  168. package/dist/context/useDashboard.js +4 -4
  169. package/dist/context/useDashboard.js.map +1 -1
  170. package/dist/stories/decorators/WithDashboard.js.map +1 -1
  171. package/dist/stories/decorators/WithDatasourceStore.js +1 -46
  172. package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
  173. package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
  174. package/dist/stories/decorators/index.js +0 -4
  175. package/dist/stories/decorators/index.js.map +1 -1
  176. package/dist/test/datasource-provider.d.ts +6 -0
  177. package/dist/test/datasource-provider.d.ts.map +1 -0
  178. package/dist/test/datasource-provider.js +60 -0
  179. package/dist/test/datasource-provider.js.map +1 -0
  180. package/dist/test/index.d.ts +1 -0
  181. package/dist/test/index.d.ts.map +1 -1
  182. package/dist/test/index.js +1 -0
  183. package/dist/test/index.js.map +1 -1
  184. package/dist/test/plugin-registry.d.ts.map +1 -1
  185. package/dist/test/plugin-registry.js +11 -5
  186. package/dist/test/plugin-registry.js.map +1 -1
  187. package/dist/test/render.d.ts.map +1 -1
  188. package/dist/test/render.js +35 -13
  189. package/dist/test/render.js.map +1 -1
  190. package/dist/test/testDashboard.js +79 -79
  191. package/dist/test/testDashboard.js.map +1 -1
  192. package/dist/utils/index.d.ts +1 -0
  193. package/dist/utils/index.d.ts.map +1 -1
  194. package/dist/utils/index.js +1 -0
  195. package/dist/utils/index.js.map +1 -1
  196. package/dist/utils/time.d.ts +5 -0
  197. package/dist/utils/time.d.ts.map +1 -0
  198. package/dist/utils/time.js +23 -0
  199. package/dist/utils/time.js.map +1 -0
  200. package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -1
  201. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  202. package/dist/views/ViewDashboard/DashboardApp.js +3 -2
  203. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  204. package/package.json +7 -6
  205. package/dist/cjs/stories/decorators/WithPluginRegistry.js +0 -91
  206. package/dist/cjs/stories/decorators/WithTimeRange.js +0 -38
  207. package/dist/stories/decorators/WithPluginRegistry.js +0 -46
  208. package/dist/stories/decorators/WithPluginRegistry.js.map +0 -1
  209. package/dist/stories/decorators/WithQueryClient.js.map +0 -1
  210. package/dist/stories/decorators/WithQueryParams.js.map +0 -1
  211. package/dist/stories/decorators/WithTimeRange.js +0 -32
  212. package/dist/stories/decorators/WithTimeRange.js.map +0 -1
@@ -0,0 +1,79 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "DashboardStickyToolbar", {
18
+ enumerable: true,
19
+ get: ()=>DashboardStickyToolbar
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = require("react");
23
+ const _material = require("@mui/material");
24
+ const _pinOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PinOutline"));
25
+ const _pinOffOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PinOffOutline"));
26
+ const _variables = require("../Variables");
27
+ const _timeRangeControls = require("../TimeRangeControls");
28
+ function _interopRequireDefault(obj) {
29
+ return obj && obj.__esModule ? obj : {
30
+ default: obj
31
+ };
32
+ }
33
+ function DashboardStickyToolbar(props) {
34
+ const [isPin, setIsPin] = (0, _react.useState)(props.initialVariableIsSticky);
35
+ const scrollTrigger = (0, _material.useScrollTrigger)({
36
+ disableHysteresis: true
37
+ });
38
+ const isSticky = scrollTrigger && props.initialVariableIsSticky && isPin;
39
+ return(// marginBottom={-1} counteracts the marginBottom={1} on every variable input.
40
+ // The margin on the inputs is for spacing between inputs, but is not meant to add space to bottom of the container.
41
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
42
+ marginBottom: -1,
43
+ "data-testid": "variable-list",
44
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.AppBar, {
45
+ color: "inherit",
46
+ position: isSticky ? 'fixed' : 'static',
47
+ elevation: isSticky ? 4 : 0,
48
+ sx: {
49
+ backgroundColor: 'inherit',
50
+ ...props.sx
51
+ },
52
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
53
+ display: "flex",
54
+ justifyContent: "space-between",
55
+ children: [
56
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
57
+ display: "flex",
58
+ flexWrap: "wrap",
59
+ alignItems: "start",
60
+ my: isSticky ? 2 : 0,
61
+ ml: isSticky ? 2 : 0,
62
+ children: [
63
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {}),
64
+ props.initialVariableIsSticky && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
65
+ onClick: ()=>setIsPin(!isPin),
66
+ children: isPin ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pinOutline.default, {}) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pinOffOutline.default, {})
67
+ })
68
+ ]
69
+ }),
70
+ isSticky && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
71
+ my: 2,
72
+ mr: 2,
73
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {})
74
+ })
75
+ ]
76
+ })
77
+ })
78
+ }));
79
+ }
@@ -14,16 +14,15 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "WithQueryParams", {
18
- enumerable: true,
19
- get: ()=>WithQueryParams
20
- });
21
- const _jsxRuntime = require("react/jsx-runtime");
22
- const _window = require("use-query-params/adapters/window");
23
- const _useQueryParams = require("use-query-params");
24
- const WithQueryParams = (Story)=>{
25
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_useQueryParams.QueryParamProvider, {
26
- adapter: _window.WindowHistoryAdapter,
27
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
17
+ _exportStar(require("./DashboardStickyToolbar"), exports);
18
+ function _exportStar(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
28
26
  });
29
- };
27
+ return from;
28
+ }
@@ -19,7 +19,6 @@ Object.defineProperty(exports, "DashboardToolbar", {
19
19
  get: ()=>DashboardToolbar
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
- const _react = require("react");
23
22
  const _material = require("@mui/material");
24
23
  const _components = require("@perses-dev/components");
25
24
  const _context = require("../../context");
@@ -30,30 +29,17 @@ const _timeRangeControls = require("../TimeRangeControls");
30
29
  const _variables = require("../Variables");
31
30
  const _editButton = require("../EditButton");
32
31
  const _editJsonButton = require("../EditJsonButton");
32
+ const _saveDashboardButton = require("../SaveDashboardButton");
33
+ const _dashboardStickyToolbar = require("../DashboardStickyToolbar");
33
34
  const DashboardToolbar = (props)=>{
34
35
  const { dashboardName , dashboardTitleComponent , initialVariableIsSticky , isReadonly , onEditButtonClick , onCancelButtonClick , onSave , } = props;
35
- const dashboard = (0, _context.useDashboard)();
36
- const { isEditMode , setEditMode } = (0, _context.useEditMode)();
36
+ const { isEditMode } = (0, _context.useEditMode)();
37
37
  const isBiggerThanMd = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('md'));
38
38
  const isBiggerThanSm = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('sm'));
39
- const [isSavingDashboard, setSavingDashboard] = (0, _react.useState)(false);
40
39
  const dashboardTitle = dashboardTitleComponent ? dashboardTitleComponent : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
41
40
  variant: "h2",
42
41
  children: dashboardName
43
42
  });
44
- const onSaveButtonClick = ()=>{
45
- if (onSave !== undefined) {
46
- setSavingDashboard(true);
47
- onSave(dashboard.dashboard).then(()=>{
48
- setSavingDashboard(false);
49
- setEditMode(false);
50
- }).catch(()=>{
51
- setSavingDashboard(false);
52
- });
53
- } else {
54
- setEditMode(false);
55
- }
56
- };
57
43
  const testId = 'dashboard-toolbar';
58
44
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
59
45
  children: isEditMode ? /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
@@ -81,11 +67,9 @@ const DashboardToolbar = (props)=>{
81
67
  },
82
68
  children: "Dashboard managed via code only. Download JSON and commit changes to save."
83
69
  }),
84
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
85
- variant: "contained",
86
- onClick: onSaveButtonClick,
87
- disabled: isReadonly || isSavingDashboard,
88
- children: "Save"
70
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_saveDashboardButton.SaveDashboardButton, {
71
+ onSave: onSave,
72
+ isDisabled: isReadonly
89
73
  }),
90
74
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
91
75
  variant: "outlined",
@@ -106,7 +90,7 @@ const DashboardToolbar = (props)=>{
106
90
  children: [
107
91
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
108
92
  FallbackComponent: _components.ErrorAlert,
109
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {
93
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardStickyToolbar.DashboardStickyToolbar, {
110
94
  initialVariableIsSticky: initialVariableIsSticky,
111
95
  sx: {
112
96
  backgroundColor: ({ palette })=>palette.mode === 'dark' ? palette.background.default : palette.background.paper
@@ -194,7 +178,7 @@ const DashboardToolbar = (props)=>{
194
178
  paddingY: 2,
195
179
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
196
180
  FallbackComponent: _components.ErrorAlert,
197
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {
181
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardStickyToolbar.DashboardStickyToolbar, {
198
182
  initialVariableIsSticky: initialVariableIsSticky,
199
183
  sx: {
200
184
  backgroundColor: ({ palette })=>palette.mode === 'dark' ? palette.background.default : palette.background.paper
@@ -34,6 +34,7 @@ const EditJsonButton = ()=>{
34
34
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
35
35
  description: _constants.TOOLTIP_TEXT.editJson,
36
36
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_toolbarIconButton.ToolbarIconButton, {
37
+ "aria-label": _constants.TOOLTIP_TEXT.editJson,
37
38
  variant: "outlined",
38
39
  onClick: ()=>openEditJsonDialog(),
39
40
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_codeBraces.default, {})
@@ -22,6 +22,7 @@ const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _react = require("react");
23
23
  const _material = require("@mui/material");
24
24
  const _components = require("@perses-dev/components");
25
+ const _pluginSystem = require("@perses-dev/plugin-system");
25
26
  const _dashboardProvider = require("../../context/DashboardProvider");
26
27
  const _useDashboard = require("../../context/useDashboard");
27
28
  const EditJsonDialog = ()=>{
@@ -42,11 +43,15 @@ const EditJsonDialog = ()=>{
42
43
  };
43
44
  const EditJsonDialogForm = ()=>{
44
45
  const { closeEditJsonDialog } = (0, _dashboardProvider.useEditJsonDialog)();
46
+ const { setTimeRange } = (0, _pluginSystem.useTimeRange)();
45
47
  const { dashboard , setDashboard } = (0, _useDashboard.useDashboard)();
46
48
  const [draftDashboard, setDraftDashboard] = (0, _react.useState)(dashboard);
47
49
  const handleApply = (e)=>{
48
50
  e.preventDefault();
49
51
  setDashboard(draftDashboard);
52
+ setTimeRange({
53
+ pastDuration: draftDashboard.spec.duration
54
+ });
50
55
  closeEditJsonDialog();
51
56
  };
52
57
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.Dialog.Form, {
@@ -19,11 +19,14 @@ Object.defineProperty(exports, "GridItemContent", {
19
19
  get: ()=>GridItemContent
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
+ const _pluginSystem = require("@perses-dev/plugin-system");
22
23
  const _context = require("../../context");
24
+ const _utils = require("../../utils");
23
25
  const _panel = require("../Panel/Panel");
24
26
  function GridItemContent(props) {
25
- const { panelGroupItemId } = props;
27
+ const { panelGroupItemId , width } = props;
26
28
  const panelDefinition = (0, _context.usePanel)(panelGroupItemId);
29
+ const { spec: { queries } , } = panelDefinition;
27
30
  const { isEditMode } = (0, _context.useEditMode)();
28
31
  const { openEditPanel , openDeletePanelDialog , duplicatePanel } = (0, _context.usePanelActions)(panelGroupItemId);
29
32
  // Provide actions to the panel when in edit mode
@@ -35,8 +38,23 @@ function GridItemContent(props) {
35
38
  onDeletePanelClick: openDeletePanelDialog
36
39
  };
37
40
  }
38
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
39
- definition: panelDefinition,
40
- editHandlers: editHandlers
41
+ // map TimeSeriesQueryDefinition to Definition<UnknownSpec>
42
+ const suggestedStepMs = (0, _utils.useSuggestedStepMs)(width);
43
+ const queryDefinitions = queries !== null && queries !== void 0 ? queries : [];
44
+ const definitions = queryDefinitions.map((query)=>{
45
+ return {
46
+ kind: query.spec.plugin.kind,
47
+ spec: query.spec.plugin.spec
48
+ };
49
+ });
50
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DataQueriesProvider, {
51
+ definitions: definitions,
52
+ options: {
53
+ suggestedStepMs
54
+ },
55
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
56
+ definition: panelDefinition,
57
+ editHandlers: editHandlers
58
+ })
41
59
  });
42
60
  }
@@ -28,6 +28,7 @@ const _constants = require("../../constants");
28
28
  const _gridTitle = require("./GridTitle");
29
29
  const _gridItemContent = require("./GridItemContent");
30
30
  const _gridContainer = require("./GridContainer");
31
+ const DEFAULT_MARGIN = 10;
31
32
  const ResponsiveGridLayout = (0, _reactGridLayout.WidthProvider)(_reactGridLayout.Responsive);
32
33
  function GridLayout(props) {
33
34
  const { panelGroupId /*...others */ } = props;
@@ -37,6 +38,7 @@ function GridLayout(props) {
37
38
  var ref;
38
39
  const [isOpen, setIsOpen] = (0, _react.useState)((ref = !groupDefinition.isCollapsed) !== null && ref !== void 0 ? ref : true);
39
40
  const { isEditMode } = (0, _context.useEditMode)();
41
+ const [gridColWidth, setGridColWidth] = (0, _react.useState)(0);
40
42
  const handleLayoutChange = (currentLayout, allLayouts)=>{
41
43
  // Using the value from `allLayouts` instead of `currentLayout` because of
42
44
  // a bug in react-layout-grid where `currentLayout` does not adjust properly
@@ -47,6 +49,16 @@ function GridLayout(props) {
47
49
  updatePanelGroupLayouts(smallLayout);
48
50
  }
49
51
  };
52
+ /**
53
+ * Calculate the column width so we can determine the width of each panel for suggested step ms
54
+ * https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35
55
+ */ const handleWidthChange = (containerWidth, margin, cols, containerPadding)=>{
56
+ const marginX = margin[0];
57
+ const marginWidth = marginX * (cols - 1);
58
+ const containerPaddingWidth = containerPadding[0] * 2;
59
+ // exclude margin and padding from total width
60
+ setGridColWidth((containerWidth - marginWidth - containerPaddingWidth) / cols);
61
+ };
50
62
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_gridContainer.GridContainer, {
51
63
  children: [
52
64
  groupDefinition.title !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridTitle.GridTitle, {
@@ -76,6 +88,10 @@ function GridLayout(props) {
76
88
  ],
77
89
  isDraggable: isEditMode,
78
90
  isResizable: isEditMode,
91
+ margin: [
92
+ DEFAULT_MARGIN,
93
+ DEFAULT_MARGIN
94
+ ],
79
95
  containerPadding: [
80
96
  0,
81
97
  10
@@ -84,14 +100,16 @@ function GridLayout(props) {
84
100
  [_constants.GRID_LAYOUT_SMALL_BREAKPOINT]: groupDefinition.itemLayouts
85
101
  },
86
102
  onLayoutChange: handleLayoutChange,
87
- children: groupDefinition.itemLayouts.map(({ i })=>/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
103
+ onWidthChange: handleWidthChange,
104
+ children: groupDefinition.itemLayouts.map(({ i , w })=>/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
88
105
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
89
106
  FallbackComponent: _components.ErrorAlert,
90
107
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridItemContent.GridItemContent, {
91
108
  panelGroupItemId: {
92
109
  panelGroupId,
93
110
  panelGroupItemLayoutId: i
94
- }
111
+ },
112
+ width: calculateGridItemWidth(w, gridColWidth)
95
113
  })
96
114
  })
97
115
  }, i))
@@ -100,3 +118,14 @@ function GridLayout(props) {
100
118
  ]
101
119
  });
102
120
  }
121
+ /**
122
+ * Calculates grid item width
123
+ * @param w number of columns the grid item spans
124
+ * @param colWidth the width of each column in px
125
+ * @returns grid item's width in px
126
+ * https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35
127
+ */ const calculateGridItemWidth = (w, colWidth)=>{
128
+ // 0 * Infinity === NaN, which causes problems with resize contraints
129
+ if (!Number.isFinite(w)) return w;
130
+ return Math.round(colWidth * w + Math.max(0, w - 1) * DEFAULT_MARGIN);
131
+ };
@@ -42,24 +42,25 @@ function GridTitle(props) {
42
42
  const { isEditMode } = (0, _context.useEditMode)();
43
43
  const text = /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
44
44
  variant: "h2",
45
- sx: {
46
- marginLeft: collapse !== undefined ? 1 : undefined
47
- },
48
45
  children: title
49
46
  });
50
47
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
48
+ onClick: collapse === null || collapse === void 0 ? void 0 : collapse.onToggleOpen,
51
49
  sx: {
52
50
  display: 'flex',
53
51
  justifyContent: 'start',
54
52
  alignItems: 'center',
55
53
  padding: (theme)=>theme.spacing(1),
54
+ cursor: collapse ? 'pointer' : 'auto',
56
55
  backgroundColor: ({ palette })=>palette.mode === 'dark' ? palette.background.paper : palette.background.default
57
56
  },
58
57
  "data-testid": "panel-group-header",
59
58
  children: collapse ? /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
60
59
  children: [
61
60
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
62
- onClick: collapse.onToggleOpen,
61
+ sx: {
62
+ marginRight: 1
63
+ },
63
64
  "aria-label": `${collapse.isOpen ? 'collapse' : 'expand'} group ${title}`,
64
65
  children: collapse.isOpen ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_chevronDown.default, {}) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_chevronRight.default, {})
65
66
  }),
@@ -72,7 +73,11 @@ function GridTitle(props) {
72
73
  description: _constants.TOOLTIP_TEXT.addPanelToGroup,
73
74
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
74
75
  "aria-label": _constants.ARIA_LABEL_TEXT.addPanelToGroup(title),
75
- onClick: openAddPanel,
76
+ onClick: (e)=>{
77
+ // Don't trigger expand/collapse
78
+ e.stopPropagation();
79
+ openAddPanel();
80
+ },
76
81
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_chartBoxPlusOutline.default, {})
77
82
  })
78
83
  }),
@@ -80,7 +85,11 @@ function GridTitle(props) {
80
85
  description: _constants.TOOLTIP_TEXT.editGroup,
81
86
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
82
87
  "aria-label": _constants.ARIA_LABEL_TEXT.editGroup(title),
83
- onClick: openEditPanelGroup,
88
+ onClick: (e)=>{
89
+ // Don't trigger expand/collapse
90
+ e.stopPropagation();
91
+ openEditPanelGroup();
92
+ },
84
93
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencilOutline.default, {})
85
94
  })
86
95
  }),
@@ -88,7 +97,11 @@ function GridTitle(props) {
88
97
  description: _constants.TOOLTIP_TEXT.deleteGroup,
89
98
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
90
99
  "aria-label": _constants.ARIA_LABEL_TEXT.deleteGroup(title),
91
- onClick: ()=>openDeletePanelGroupDialog(panelGroupId),
100
+ onClick: (e)=>{
101
+ // Don't trigger expand/collapse
102
+ e.stopPropagation();
103
+ openDeletePanelGroupDialog(panelGroupId);
104
+ },
92
105
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_deleteOutline.default, {})
93
106
  })
94
107
  }),
@@ -97,7 +110,11 @@ function GridTitle(props) {
97
110
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
98
111
  "aria-label": _constants.ARIA_LABEL_TEXT.moveGroupDown(title),
99
112
  disabled: moveDown === undefined,
100
- onClick: moveDown,
113
+ onClick: (e)=>{
114
+ // Don't trigger expand/collapse
115
+ e.stopPropagation();
116
+ moveDown && moveDown();
117
+ },
101
118
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowDown.default, {})
102
119
  })
103
120
  }),
@@ -106,7 +123,11 @@ function GridTitle(props) {
106
123
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
107
124
  "aria-label": _constants.ARIA_LABEL_TEXT.moveGroupUp(title),
108
125
  disabled: moveUp === undefined,
109
- onClick: moveUp,
126
+ onClick: (e)=>{
127
+ // Don't trigger expand/collapse
128
+ e.stopPropagation();
129
+ moveUp && moveUp();
130
+ },
110
131
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowUp.default, {})
111
132
  })
112
133
  })
@@ -31,7 +31,7 @@ function _interopRequireDefault(obj) {
31
31
  default: obj
32
32
  };
33
33
  }
34
- function Panel(props) {
34
+ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
35
35
  const { definition , editHandlers , onMouseEnter , onMouseLeave , sx , ...others } = props;
36
36
  // Make sure we have an ID we can use for aria attributes
37
37
  const generatedPanelId = (0, _components.useId)('Panel');
@@ -116,4 +116,4 @@ function Panel(props) {
116
116
  })
117
117
  ]
118
118
  });
119
- }
119
+ });
@@ -31,25 +31,26 @@ const _components = require("@perses-dev/components");
31
31
  const _pluginSystem = require("@perses-dev/plugin-system");
32
32
  const _context = require("../../context");
33
33
  const _panelPreview = require("./PanelPreview");
34
+ const _usePanelEditor = require("./usePanelEditor");
34
35
  function PanelEditorForm(props) {
35
36
  var ref;
36
- const { initialValues , onChange } = props;
37
+ const { initialValues: { panelDefinition: initialPanelDef , groupId: initialGroupId } , onChange , } = props;
37
38
  const panelGroups = (0, _context.useListPanelGroups)();
38
- const [name, setName] = (0, _react.useState)(initialValues.name);
39
- const [description, setDescription] = (0, _react.useState)(initialValues.description);
40
- const [groupId, setGroupId] = (0, _react.useState)(initialValues.groupId);
41
- const [kind, setKind] = (0, _react.useState)(initialValues.kind);
42
- const [spec, setSpec] = (0, _react.useState)(initialValues.spec);
39
+ const [groupId, setGroupId] = (0, _react.useState)(initialGroupId);
40
+ const { panelDefinition , setName , setDescription , setQueries , setPlugin , setPanelDefinition } = (0, _usePanelEditor.usePanelEditor)(initialPanelDef);
41
+ const { plugin } = panelDefinition.spec;
43
42
  // Use common plugin editor logic even though we've split the inputs up in this form
44
43
  const pluginEditor = (0, _pluginSystem.usePluginEditor)({
45
44
  pluginType: 'Panel',
46
45
  value: {
47
- kind,
48
- spec
46
+ kind: plugin.kind,
47
+ spec: plugin.spec
49
48
  },
50
49
  onChange: (plugin)=>{
51
- setKind(plugin.kind);
52
- setSpec(plugin.spec);
50
+ setPlugin(plugin);
51
+ },
52
+ onHideQueryEditorChange: (isHidden)=>{
53
+ setQueries(undefined, isHidden);
53
54
  }
54
55
  });
55
56
  // Ignore string values (which would be an "empty" value from the Select) since we don't allow them to unset it
@@ -60,24 +61,26 @@ function PanelEditorForm(props) {
60
61
  }
61
62
  setGroupId(value);
62
63
  };
64
+ const handlePanelDefinitionChange = (nextPanelDef)=>{
65
+ const { kind: pluginKind , spec: pluginSpec } = nextPanelDef.spec.plugin;
66
+ // if panel plugin kind and spec are modified, then need to save current spec
67
+ if (panelDefinition.spec.plugin.kind !== pluginKind && JSON.stringify(panelDefinition.spec.plugin.spec) !== JSON.stringify(pluginSpec)) {
68
+ pluginEditor.rememberCurrentSpecState();
69
+ }
70
+ setPanelDefinition(nextPanelDef);
71
+ };
63
72
  (0, _react.useEffect)(()=>{
64
73
  const values = {
65
- name,
66
- description,
67
74
  groupId,
68
- kind,
69
- spec
75
+ panelDefinition
70
76
  };
71
77
  onChange(values);
72
78
  }, [
73
- name,
74
- description,
75
79
  groupId,
76
- kind,
77
- spec,
80
+ panelDefinition,
78
81
  onChange
79
82
  ]);
80
- var _title, ref1;
83
+ var _name, _title, _description, ref1;
81
84
  return(// Grid maxHeight allows user to scroll inside Drawer to see all content
82
85
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
83
86
  component: "form",
@@ -98,9 +101,11 @@ function PanelEditorForm(props) {
98
101
  required: true,
99
102
  fullWidth: true,
100
103
  label: "Name",
101
- value: name,
104
+ value: (_name = panelDefinition.spec.display.name) !== null && _name !== void 0 ? _name : '',
102
105
  variant: "outlined",
103
- onChange: (e)=>setName(e.target.value)
106
+ onChange: (e)=>{
107
+ setName(e.target.value);
108
+ }
104
109
  })
105
110
  }),
106
111
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
@@ -133,9 +138,11 @@ function PanelEditorForm(props) {
133
138
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
134
139
  fullWidth: true,
135
140
  label: "Description",
136
- value: description,
141
+ value: (_description = panelDefinition.spec.display.description) !== null && _description !== void 0 ? _description : '',
137
142
  variant: "outlined",
138
- onChange: (e)=>setDescription(e.target.value)
143
+ onChange: (e)=>{
144
+ setDescription(e.target.value);
145
+ }
139
146
  })
140
147
  }),
141
148
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
@@ -156,7 +163,7 @@ function PanelEditorForm(props) {
156
163
  required: true,
157
164
  labelId: "panel-type-label",
158
165
  label: "Type",
159
- value: pluginEditor.pendingKind ? pluginEditor.pendingKind : kind,
166
+ value: pluginEditor.pendingKind ? pluginEditor.pendingKind : plugin.kind,
160
167
  onChange: pluginEditor.onKindChange
161
168
  })
162
169
  ]
@@ -178,11 +185,7 @@ function PanelEditorForm(props) {
178
185
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
179
186
  FallbackComponent: _components.ErrorAlert,
180
187
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelPreview.PanelPreview, {
181
- kind: kind,
182
- name: name,
183
- description: description,
184
- spec: spec,
185
- groupId: groupId
188
+ panelDefinition: panelDefinition
186
189
  })
187
190
  })
188
191
  ]
@@ -192,11 +195,15 @@ function PanelEditorForm(props) {
192
195
  xs: 12,
193
196
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
194
197
  FallbackComponent: _components.ErrorAlert,
195
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginSpecEditor, {
196
- pluginType: "Panel",
197
- pluginKind: kind,
198
- value: spec,
199
- onChange: pluginEditor.onSpecChange
198
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PanelSpecEditor, {
199
+ panelDefinition: panelDefinition,
200
+ onJSONChange: handlePanelDefinitionChange,
201
+ onQueriesChange: (queries)=>{
202
+ setQueries(queries);
203
+ },
204
+ onPluginSpecChange: (spec)=>{
205
+ pluginEditor.onSpecChange(spec);
206
+ }
200
207
  })
201
208
  })
202
209
  })
@@ -19,29 +19,43 @@ Object.defineProperty(exports, "PanelPreview", {
19
19
  get: ()=>PanelPreview
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = require("react");
22
23
  const _material = require("@mui/material");
24
+ const _pluginSystem = require("@perses-dev/plugin-system");
23
25
  const _panel = require("../Panel");
24
- function PanelPreview({ name , description , kind , spec }) {
25
- const definition = {
26
- kind: 'Panel',
27
- spec: {
28
- display: {
29
- name,
30
- description: description === '' ? undefined : description
31
- },
32
- plugin: {
33
- kind,
34
- spec
35
- }
36
- }
37
- };
38
- if (kind === '') {
26
+ const _utils = require("../../utils");
27
+ const PANEL_PREVIEW_HEIGHT = 300;
28
+ const PANEL_PREVIEW_DEFAULT_WIDTH = 840;
29
+ function PanelPreview({ panelDefinition }) {
30
+ const boxRef = (0, _react.useRef)(null);
31
+ let width = PANEL_PREVIEW_DEFAULT_WIDTH;
32
+ if (boxRef.current !== null) {
33
+ width = boxRef.current.getBoundingClientRect().width;
34
+ }
35
+ const suggestedStepMs = (0, _utils.useSuggestedStepMs)(width);
36
+ if (panelDefinition.spec.plugin.kind === '') {
39
37
  return null;
40
38
  }
39
+ var _queries;
40
+ const queries = (_queries = panelDefinition.spec.queries) !== null && _queries !== void 0 ? _queries : [];
41
+ // map TimeSeriesQueryDefinition to Definition<UnknownSpec>
42
+ const definitions = queries.length ? queries.map((query)=>{
43
+ return {
44
+ kind: query.spec.plugin.kind,
45
+ spec: query.spec.plugin.spec
46
+ };
47
+ }) : [];
41
48
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
42
- height: 300,
43
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
44
- definition: definition
49
+ ref: boxRef,
50
+ height: PANEL_PREVIEW_HEIGHT,
51
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DataQueriesProvider, {
52
+ definitions: definitions,
53
+ options: {
54
+ suggestedStepMs
55
+ },
56
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
57
+ definition: panelDefinition
58
+ })
45
59
  })
46
60
  });
47
61
  }