@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
@@ -14,69 +14,29 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- mockPluginRegistryProps: ()=>mockPluginRegistryProps,
25
- FAKE_PANEL_PLUGIN: ()=>FAKE_PANEL_PLUGIN
17
+ Object.defineProperty(exports, "MOCK_PLUGINS", {
18
+ enumerable: true,
19
+ get: ()=>MOCK_PLUGINS
26
20
  });
27
21
  const _jsxRuntime = require("react/jsx-runtime");
28
- function mockPluginRegistryProps() {
29
- const mockPluginResource = {
30
- kind: 'PluginModule',
31
- metadata: {
32
- name: 'Fake Plugin Module for Tests',
33
- created_at: '',
34
- updated_at: '',
35
- version: 0
36
- },
37
- spec: {
38
- plugins: []
39
- }
40
- };
41
- const mockPluginModule = {};
42
- // Allow adding mock plugins in tests
43
- const addMockPlugin = (pluginType, kind, plugin)=>{
44
- mockPluginResource.spec.plugins.push({
45
- pluginType,
46
- kind,
47
- display: {
48
- name: `Fake ${pluginType} Plugin for ${kind}`
49
- }
50
- });
51
- // "Export" on the module under the same name as the kind the plugin handles
52
- mockPluginModule[kind] = plugin;
53
- };
54
- const pluginRegistryProps = {
55
- getInstalledPlugins () {
56
- return Promise.resolve([
57
- mockPluginResource
58
- ]);
59
- },
60
- importPluginModule () {
61
- return Promise.resolve(mockPluginModule);
62
- }
63
- };
64
- return {
65
- pluginRegistryProps,
66
- addMockPlugin
67
- };
68
- }
69
- const FAKE_PANEL_PLUGIN = {
22
+ const FakeTimeSeriesPlugin = {
70
23
  PanelComponent: ()=>{
71
24
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
72
- role: "figure",
73
- children: "FakePanel chart"
25
+ children: "TimeSeriesChart panel"
74
26
  });
75
27
  },
76
28
  OptionsEditorComponent: ()=>{
77
29
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
78
- children: "Edit options here"
30
+ children: "TimeSeriesChart options"
79
31
  });
80
32
  },
81
33
  createInitialOptions: ()=>({})
82
34
  };
35
+ const MOCK_TIME_SERIES_PANEL = {
36
+ pluginType: 'Panel',
37
+ kind: 'TimeSeriesChart',
38
+ plugin: FakeTimeSeriesPlugin
39
+ };
40
+ const MOCK_PLUGINS = [
41
+ MOCK_TIME_SERIES_PANEL
42
+ ];
@@ -26,6 +26,8 @@ const _useQueryParams = require("use-query-params");
26
26
  const _reactRouter6 = require("use-query-params/adapters/react-router-6");
27
27
  const _reactQuery = require("@tanstack/react-query");
28
28
  const _components = require("@perses-dev/components");
29
+ const _pluginSystem = require("@perses-dev/plugin-system");
30
+ const _pluginRegistry = require("./plugin-registry");
29
31
  function renderWithContext(ui, options, history) {
30
32
  // Create a new QueryClient for each test to avoid caching issues
31
33
  const queryClient = new _reactQuery.QueryClient({
@@ -48,7 +50,10 @@ function renderWithContext(ui, options, history) {
48
50
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ChartsThemeProvider, {
49
51
  themeName: "perses",
50
52
  chartsTheme: _components.testChartsTheme,
51
- children: ui
53
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
54
+ ...(0, _pluginSystem.mockPluginRegistry)(..._pluginRegistry.MOCK_PLUGINS),
55
+ children: ui
56
+ })
52
57
  })
53
58
  })
54
59
  })
@@ -0,0 +1,31 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "useId", {
18
+ enumerable: true,
19
+ get: ()=>useId
20
+ });
21
+ const _react = require("react");
22
+ if (globalThis.useIdValue === undefined) {
23
+ globalThis.useIdValue = 0;
24
+ }
25
+ function useId(prefix) {
26
+ const id = (0, _react.useRef)(undefined);
27
+ if (id.current === undefined) {
28
+ id.current = `${prefix}-${globalThis.useIdValue++}`;
29
+ }
30
+ return id.current;
31
+ }
@@ -111,15 +111,21 @@ function useSetTimeRangeParams(initialTimeRange, paramsEnabled = true) {
111
111
  // fallback when app does not want query string as source of truth
112
112
  const [timeRangeState, setTimeRangeState] = (0, _react.useState)(initialTimeRange);
113
113
  const { start } = query;
114
- // set start param on page load if empty
115
- if (paramsEnabled && !start) {
116
- if ((0, _core.isRelativeTimeRange)(initialTimeRange)) {
117
- setQuery({
118
- start: initialTimeRange.pastDuration,
119
- end: undefined
120
- });
114
+ (0, _react.useEffect)(()=>{
115
+ if (paramsEnabled && !start) {
116
+ if ((0, _core.isRelativeTimeRange)(initialTimeRange)) {
117
+ setQuery({
118
+ start: initialTimeRange.pastDuration,
119
+ end: undefined
120
+ });
121
+ }
121
122
  }
122
- }
123
+ }, [
124
+ initialTimeRange,
125
+ paramsEnabled,
126
+ start,
127
+ setQuery
128
+ ]);
123
129
  const setTimeRange = (0, _react.useCallback)((value)=>{
124
130
  if ((0, _core.isRelativeTimeRange)(value)) {
125
131
  setQuery({
@@ -19,21 +19,43 @@ Object.defineProperty(exports, "DashboardApp", {
19
19
  get: ()=>DashboardApp
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = require("react");
22
23
  const _material = require("@mui/material");
23
24
  const _components = require("@perses-dev/components");
24
25
  const _components1 = require("../../components");
25
- const _dashboardToolbar = require("../../components/DashboardToolbar");
26
- const _deletePanelDialog = /*#__PURE__*/ _interopRequireDefault(require("../../components/Panel/DeletePanelDialog"));
27
- function _interopRequireDefault(obj) {
28
- return obj && obj.__esModule ? obj : {
29
- default: obj
30
- };
31
- }
26
+ const _context = require("../../context");
32
27
  const DashboardApp = (props)=>{
33
28
  const { dashboardResource } = props;
29
+ const { setEditMode } = (0, _context.useEditMode)();
30
+ const { dashboard , setDashboard } = (0, _context.useDashboard)();
31
+ const [originalDashboard, setOriginalDashboard] = (0, _react.useState)(undefined);
32
+ const [isUnsavedDashboardDialogOpen, setUnsavedDashboardDialogIsOpen] = (0, _react.useState)(false);
33
+ const saveDashboard = async ()=>{
34
+ setEditMode(false);
35
+ setUnsavedDashboardDialogIsOpen(false);
36
+ };
37
+ const cancelDashboard = ()=>{
38
+ // Reset to the original spec and exit edit mode
39
+ if (originalDashboard) {
40
+ setDashboard(originalDashboard);
41
+ }
42
+ setUnsavedDashboardDialogIsOpen(false);
43
+ setEditMode(false);
44
+ };
45
+ const onEditButtonClick = ()=>{
46
+ setEditMode(true);
47
+ setOriginalDashboard(dashboard);
48
+ };
49
+ const onCancelButtonClick = ()=>{
50
+ // check if dashboard has been modified
51
+ if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {
52
+ setEditMode(false);
53
+ } else {
54
+ setUnsavedDashboardDialogIsOpen(true);
55
+ }
56
+ };
34
57
  return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
35
58
  sx: {
36
- padding: (theme)=>theme.spacing(1, 0),
37
59
  flexGrow: 1,
38
60
  overflowX: 'hidden',
39
61
  overflowY: 'auto',
@@ -41,8 +63,10 @@ const DashboardApp = (props)=>{
41
63
  flexDirection: 'column'
42
64
  },
43
65
  children: [
44
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardToolbar.DashboardToolbar, {
45
- dashboardName: dashboardResource.metadata.name
66
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DashboardToolbar, {
67
+ dashboardName: dashboardResource.metadata.name,
68
+ onEditButtonClick: onEditButtonClick,
69
+ onCancelButtonClick: onCancelButtonClick
46
70
  }),
47
71
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
48
72
  sx: {
@@ -56,7 +80,12 @@ const DashboardApp = (props)=>{
56
80
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelDrawer, {}),
57
81
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.PanelGroupDialog, {}),
58
82
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelGroupDialog, {}),
59
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_deletePanelDialog.default, {})
83
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.DeletePanelDialog, {}),
84
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.UnsavedChangesConfirmationDialog, {
85
+ isOpen: isUnsavedDashboardDialogOpen,
86
+ onSave: saveDashboard,
87
+ onClose: cancelDashboard
88
+ })
60
89
  ]
61
90
  })
62
91
  ]
@@ -36,7 +36,7 @@ function ViewDashboard(props) {
36
36
  datasourceApi: datasourceApi,
37
37
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.DashboardProvider, {
38
38
  initialState: {
39
- dashboardSpec: spec
39
+ dashboardResource
40
40
  },
41
41
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TimeRangeProvider, {
42
42
  timeRange: timeRange,
@@ -34,7 +34,7 @@ describe('Panel Groups', ()=>{
34
34
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TemplateVariableProvider, {
35
35
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.DashboardProvider, {
36
36
  initialState: {
37
- dashboardSpec: (0, _test.getTestDashboard)().spec,
37
+ dashboardResource: (0, _test.getTestDashboard)(),
38
38
  isEditMode: true
39
39
  },
40
40
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardApp.DashboardApp, {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK9C,oBAAY,cAAc,GAAG,QAAQ,CAAC;AAEtC;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAW9C"}
@@ -13,8 +13,8 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
16
- import { usePanelGroupIds } from '../context';
17
- import { GridLayout } from './GridLayout';
16
+ import { usePanelGroupIds } from '../../context';
17
+ import { GridLayout } from '../GridLayout';
18
18
  /**
19
19
  * Renders a Dashboard for the provided Dashboard spec.
20
20
  */ export function Dashboard(props) {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Dashboard/Dashboard.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 { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\n\nexport type DashboardProps = BoxProps;\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard(props: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n return (\n <Box {...props}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {panelGroupIds.map((panelGroupId) => (\n <GridLayout key={panelGroupId} panelGroupId={panelGroupId} />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","Dashboard","props","panelGroupIds","FallbackComponent","map","panelGroupId"],"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,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,QAAQ,eAAe,CAAC;AACjD,SAASC,UAAU,QAAQ,eAAe,CAAC;AAI3C;;CAEC,GACD,OAAO,SAASC,SAAS,CAACC,KAAqB,EAAE;IAC/C,MAAMC,aAAa,GAAGJ,gBAAgB,EAAE,AAAC;IACzC,qBACE,KAACH,GAAG;QAAE,GAAGM,KAAK;kBACZ,cAAA,KAACL,aAAa;YAACO,iBAAiB,EAAEN,UAAU;sBACzCK,aAAa,CAACE,GAAG,CAAC,CAACC,YAAY,iBAC9B,KAACN,UAAU;oBAAoBM,YAAY,EAAEA,YAAY;mBAAxCA,YAAY,CAAgC,AAC9D,CAAC;UACY;MACZ,CACN;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './Dashboard';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './Dashboard';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Dashboard/index.ts"],"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\nexport * from './Dashboard';\n"],"names":[],"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,cAAc,aAAa,CAAC"}
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  export interface DashboardToolbarProps {
3
3
  dashboardName: string;
4
+ onEditButtonClick: () => void;
5
+ onCancelButtonClick: () => void;
4
6
  }
5
7
  export declare const DashboardToolbar: (props: DashboardToolbarProps) => JSX.Element;
6
8
  //# sourceMappingURL=DashboardToolbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":";AAsBA,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBA6E5D,CAAC"}
@@ -16,22 +16,15 @@ import PencilIcon from 'mdi-material-ui/PencilOutline';
16
16
  import AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';
17
17
  import AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';
18
18
  import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
19
- import { useDashboardActions, useEditMode } from '../context';
20
- import { TemplateVariableList, TimeRangeControls } from '../components';
19
+ import { useDashboardActions, useEditMode } from '../../context';
20
+ import { TemplateVariableList } from '../Variables';
21
+ import { TimeRangeControls } from '../TimeRangeControls';
21
22
  export const DashboardToolbar = (props)=>{
22
- const { dashboardName } = props;
23
+ const { dashboardName , onEditButtonClick , onCancelButtonClick } = props;
23
24
  const { isEditMode , setEditMode } = useEditMode();
24
- const { openAddPanelGroup , openAddPanel , reset , save } = useDashboardActions();
25
+ const { openAddPanelGroup , openAddPanel } = useDashboardActions();
25
26
  const isLaptopSize = useMediaQuery(useTheme().breakpoints.up('sm'));
26
- const onEditButtonClick = ()=>{
27
- setEditMode(true);
28
- };
29
- const onCancelButtonClick = ()=>{
30
- reset();
31
- setEditMode(false);
32
- };
33
27
  const onSave = ()=>{
34
- save();
35
28
  setEditMode(false);
36
29
  };
37
30
  return /*#__PURE__*/ _jsx(_Fragment, {
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/DashboardToolbar/DashboardToolbar.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 { Typography, Stack, Button, Box, useTheme, useMediaQuery } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { useDashboardActions, useEditMode } from '../../context';\nimport { TemplateVariableList } from '../Variables';\nimport { TimeRangeControls } from '../TimeRangeControls';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n onEditButtonClick: () => void;\n onCancelButtonClick: () => void;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps) => {\n const { dashboardName, onEditButtonClick, onCancelButtonClick } = props;\n\n const { isEditMode, setEditMode } = useEditMode();\n const { openAddPanelGroup, openAddPanel } = useDashboardActions();\n const isLaptopSize = useMediaQuery(useTheme().breakpoints.up('sm'));\n\n const onSave = () => {\n setEditMode(false);\n };\n\n return (\n <>\n {isEditMode ? (\n <Stack spacing={2}>\n <Box sx={{ backgroundColor: (theme) => theme.palette.primary.light + '20' }}>\n <Box padding={2} display=\"flex\">\n <Typography variant=\"h2\">Edit {dashboardName}</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n <Button variant=\"contained\" onClick={onSave}>\n Save\n </Button>\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n </Box>\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'flex-start',\n padding: (theme) => theme.spacing(2),\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList />\n </ErrorBoundary>\n <Stack direction={'row'} spacing={1} sx={{ marginLeft: 'auto' }}>\n <Button startIcon={<AddPanelGroupIcon />} onClick={openAddPanelGroup}>\n Add Panel Group\n </Button>\n <Button startIcon={<AddPanelIcon />} onClick={openAddPanel}>\n Add Panel\n </Button>\n <TimeRangeControls />\n </Stack>\n </Box>\n </Stack>\n ) : (\n <Stack spacing={2} padding={2}>\n <Box sx={{ display: 'flex', width: '100%' }}>\n <Typography variant=\"h2\">{dashboardName}</Typography>\n <Stack direction=\"row\" spacing={2} sx={{ marginLeft: 'auto' }}>\n <TimeRangeControls />\n {isLaptopSize && (\n <Button\n variant=\"outlined\"\n startIcon={<PencilIcon />}\n onClick={onEditButtonClick}\n sx={{ marginLeft: 'auto' }}\n >\n Edit\n </Button>\n )}\n </Stack>\n </Box>\n <Box paddingY={2}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList />\n </ErrorBoundary>\n </Box>\n </Stack>\n )}\n </>\n );\n};\n"],"names":["Typography","Stack","Button","Box","useTheme","useMediaQuery","PencilIcon","AddPanelGroupIcon","AddPanelIcon","ErrorBoundary","ErrorAlert","useDashboardActions","useEditMode","TemplateVariableList","TimeRangeControls","DashboardToolbar","props","dashboardName","onEditButtonClick","onCancelButtonClick","isEditMode","setEditMode","openAddPanelGroup","openAddPanel","isLaptopSize","breakpoints","up","onSave","spacing","sx","backgroundColor","theme","palette","primary","light","padding","display","variant","direction","marginLeft","onClick","width","alignItems","FallbackComponent","startIcon","paddingY"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export * from './DashboardToolbar';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './DashboardToolbar';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/DashboardToolbar/index.ts"],"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\nexport * from './DashboardToolbar';\n"],"names":[],"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,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const DeletePanelDialog: () => JSX.Element;
3
+ //# sourceMappingURL=DeletePanelDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeletePanelDialog.d.ts","sourceRoot":"","sources":["../../../src/components/DeletePanelDialog/DeletePanelDialog.tsx"],"names":[],"mappings":";AAkBA,eAAO,MAAM,iBAAiB,mBAoB7B,CAAC"}
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
15
15
  import CloseIcon from 'mdi-material-ui/Close';
16
16
  import { useDeletePanelDialog } from '../../context';
17
- const DeletePanelDialog = ()=>{
17
+ export const DeletePanelDialog = ()=>{
18
18
  const { deletePanelDialog , closeDeletePanelDialog } = useDeletePanelDialog();
19
19
  return /*#__PURE__*/ _jsxs(Dialog, {
20
20
  open: deletePanelDialog !== undefined,
@@ -39,13 +39,11 @@ const DeletePanelDialog = ()=>{
39
39
  });
40
40
  };
41
41
  const DeletePanelForm = ({ deletePanelDialog })=>{
42
- const { deletePanels , closeDeletePanelDialog } = useDeletePanelDialog();
42
+ const { deletePanel , closeDeletePanelDialog } = useDeletePanelDialog();
43
43
  const handleDelete = (e)=>{
44
44
  e.preventDefault();
45
45
  const { panelGroupItemId } = deletePanelDialog;
46
- deletePanels([
47
- panelGroupItemId
48
- ]);
46
+ deletePanel(panelGroupItemId);
49
47
  closeDeletePanelDialog();
50
48
  };
51
49
  return /*#__PURE__*/ _jsxs("form", {
@@ -79,6 +77,5 @@ const DeletePanelForm = ({ deletePanelDialog })=>{
79
77
  ]
80
78
  });
81
79
  };
82
- export default DeletePanelDialog;
83
80
 
84
81
  //# sourceMappingURL=DeletePanelDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/DeletePanelDialog/DeletePanelDialog.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 { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDeletePanelDialog, DeletePanelDialogState } from '../../context';\n\nexport const DeletePanelDialog = () => {\n const { deletePanelDialog, closeDeletePanelDialog } = useDeletePanelDialog();\n\n return (\n <Dialog open={deletePanelDialog !== undefined}>\n <DialogTitle>Delete Panel</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n {deletePanelDialog && <DeletePanelForm deletePanelDialog={deletePanelDialog} />}\n </Dialog>\n );\n};\n\ninterface DeletePanelFormProps {\n deletePanelDialog: DeletePanelDialogState;\n}\n\nconst DeletePanelForm = ({ deletePanelDialog }: DeletePanelFormProps) => {\n const { deletePanel, closeDeletePanelDialog } = useDeletePanelDialog();\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n const { panelGroupItemId } = deletePanelDialog;\n deletePanel(panelGroupItemId);\n closeDeletePanelDialog();\n };\n return (\n <form onSubmit={handleDelete}>\n <DialogContent sx={{ width: '500px' }}>\n Are you sure you want to delete {deletePanelDialog.panelName} from {deletePanelDialog.panelGroupName}? This\n action cannot be undone.\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button onClick={() => closeDeletePanelDialog()}>Cancel</Button>\n </DialogActions>\n </form>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useDeletePanelDialog","DeletePanelDialog","deletePanelDialog","closeDeletePanelDialog","open","undefined","aria-label","onClick","sx","theme","position","top","spacing","right","DeletePanelForm","deletePanel","handleDelete","e","preventDefault","panelGroupItemId","form","onSubmit","width","panelName","panelGroupName","variant","type"],"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;AACA,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,oBAAoB,QAAgC,eAAe,CAAC;AAE7E,OAAO,MAAMC,iBAAiB,GAAG,IAAM;IACrC,MAAM,EAAEC,iBAAiB,CAAA,EAAEC,sBAAsB,CAAA,EAAE,GAAGH,oBAAoB,EAAE,AAAC;IAE7E,qBACE,MAACN,MAAM;QAACU,IAAI,EAAEF,iBAAiB,KAAKG,SAAS;;0BAC3C,KAACV,WAAW;0BAAC,cAAY;cAAc;0BACvC,KAACF,UAAU;gBACTa,YAAU,EAAC,OAAO;gBAClBC,OAAO,EAAE,IAAMJ,sBAAsB,EAAE;gBACvCK,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdC,QAAQ,EAAE,UAAU;wBACpBC,GAAG,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;wBACvBC,KAAK,EAAEJ,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;qBAC1B,CAAA,AAAC;0BAEF,cAAA,KAACb,SAAS,KAAG;cACF;YACZG,iBAAiB,kBAAI,KAACY,eAAe;gBAACZ,iBAAiB,EAAEA,iBAAiB;cAAI;;MACxE,CACT;AACJ,CAAC,CAAC;AAMF,MAAMY,eAAe,GAAG,CAAC,EAAEZ,iBAAiB,CAAA,EAAwB,GAAK;IACvE,MAAM,EAAEa,WAAW,CAAA,EAAEZ,sBAAsB,CAAA,EAAE,GAAGH,oBAAoB,EAAE,AAAC;IAEvE,MAAMgB,YAAY,GAAG,CAACC,CAAY,GAAK;QACrCA,CAAC,CAACC,cAAc,EAAE,CAAC;QACnB,MAAM,EAAEC,gBAAgB,CAAA,EAAE,GAAGjB,iBAAiB,AAAC;QAC/Ca,WAAW,CAACI,gBAAgB,CAAC,CAAC;QAC9BhB,sBAAsB,EAAE,CAAC;IAC3B,CAAC,AAAC;IACF,qBACE,MAACiB,MAAI;QAACC,QAAQ,EAAEL,YAAY;;0BAC1B,MAACpB,aAAa;gBAACY,EAAE,EAAE;oBAAEc,KAAK,EAAE,OAAO;iBAAE;;oBAAE,kCACL;oBAACpB,iBAAiB,CAACqB,SAAS;oBAAC,QAAM;oBAACrB,iBAAiB,CAACsB,cAAc;oBAAC,iCAEvG;;cAAgB;0BAChB,MAAC3B,aAAa;;kCACZ,KAACC,MAAM;wBAAC2B,OAAO,EAAC,WAAW;wBAACC,IAAI,EAAC,QAAQ;kCAAC,QAE1C;sBAAS;kCACT,KAAC5B,MAAM;wBAACS,OAAO,EAAE,IAAMJ,sBAAsB,EAAE;kCAAE,QAAM;sBAAS;;cAClD;;MACX,CACP;AACJ,CAAC,AAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './DeletePanelDialog';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DeletePanelDialog/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './DeletePanelDialog';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/DeletePanelDialog/index.ts"],"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\nexport * from './DeletePanelDialog';\n"],"names":[],"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,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeletePanelGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/DeletePanelGroupDialog/DeletePanelGroupDialog.tsx"],"names":[],"mappings":";AAkBA,eAAO,MAAM,sBAAsB,mBA0ClC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/DeletePanelGroupDialog/DeletePanelGroupDialog.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 { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDeletePanelGroupDialog } from '../../context';\n\nexport const DeletePanelGroupDialog = () => {\n const { deletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } = useDeletePanelGroupDialog();\n\n const panelGroupId = deletePanelGroupDialog?.panelGroupId;\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n if (panelGroupId == undefined) {\n throw new Error('group index is undefined');\n }\n deletePanelGroup(panelGroupId);\n closeDeletePanelGroupDialog();\n };\n\n return (\n <Dialog open={deletePanelGroupDialog !== undefined}>\n <DialogTitle>Delete Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelGroupDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <form onSubmit={handleDelete}>\n <DialogContent sx={{ width: '500px' }}>\n Are you sure you want to delete {deletePanelGroupDialog?.panelGroupName ?? 'panel group'}? This will delete\n all the panels within the group.\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button onClick={() => closeDeletePanelGroupDialog()}>Cancel</Button>\n </DialogActions>\n </form>\n </Dialog>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useDeletePanelGroupDialog","DeletePanelGroupDialog","deletePanelGroupDialog","closeDeletePanelGroupDialog","deletePanelGroup","panelGroupId","handleDelete","e","preventDefault","undefined","Error","open","aria-label","onClick","sx","theme","position","top","spacing","right","form","onSubmit","width","panelGroupName","variant","type"],"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;AACA,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,yBAAyB,QAAQ,eAAe,CAAC;AAE1D,OAAO,MAAMC,sBAAsB,GAAG,IAAM;IAC1C,MAAM,EAAEC,sBAAsB,CAAA,EAAEC,2BAA2B,CAAA,EAAEC,gBAAgB,CAAA,EAAE,GAAGJ,yBAAyB,EAAE,AAAC;IAE9G,MAAMK,YAAY,GAAGH,sBAAsB,aAAtBA,sBAAsB,WAAc,GAApCA,KAAAA,CAAoC,GAApCA,sBAAsB,CAAEG,YAAY,AAAC;IAE1D,MAAMC,YAAY,GAAG,CAACC,CAAY,GAAK;QACrCA,CAAC,CAACC,cAAc,EAAE,CAAC;QACnB,IAAIH,YAAY,IAAII,SAAS,EAAE;YAC7B,MAAM,IAAIC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QACDN,gBAAgB,CAACC,YAAY,CAAC,CAAC;QAC/BF,2BAA2B,EAAE,CAAC;IAChC,CAAC,AAAC;QAkBuCD,GAAsC;IAhB/E,qBACE,MAACR,MAAM;QAACiB,IAAI,EAAET,sBAAsB,KAAKO,SAAS;;0BAChD,KAACd,WAAW;0BAAC,oBAAkB;cAAc;0BAC7C,KAACF,UAAU;gBACTmB,YAAU,EAAC,OAAO;gBAClBC,OAAO,EAAE,IAAMV,2BAA2B,EAAE;gBAC5CW,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdC,QAAQ,EAAE,UAAU;wBACpBC,GAAG,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;wBACvBC,KAAK,EAAEJ,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;qBAC1B,CAAA,AAAC;0BAEF,cAAA,KAACnB,SAAS,KAAG;cACF;0BACb,MAACqB,MAAI;gBAACC,QAAQ,EAAEf,YAAY;;kCAC1B,MAACV,aAAa;wBAACkB,EAAE,EAAE;4BAAEQ,KAAK,EAAE,OAAO;yBAAE;;4BAAE,kCACL;4BAACpB,CAAAA,GAAsC,GAAtCA,sBAAsB,aAAtBA,sBAAsB,WAAgB,GAAtCA,KAAAA,CAAsC,GAAtCA,sBAAsB,CAAEqB,cAAc,cAAtCrB,GAAsC,cAAtCA,GAAsC,GAAI,aAAa;4BAAC,qDAE3F;;sBAAgB;kCAChB,MAACL,aAAa;;0CACZ,KAACC,MAAM;gCAAC0B,OAAO,EAAC,WAAW;gCAACC,IAAI,EAAC,QAAQ;0CAAC,QAE1C;8BAAS;0CACT,KAAC3B,MAAM;gCAACe,OAAO,EAAE,IAAMV,2BAA2B,EAAE;0CAAE,QAAM;8BAAS;;sBACvD;;cACX;;MACA,CACT;AACJ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './DeletePanelGroupDialog';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DeletePanelGroupDialog/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './DeletePanelGroupDialog';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/DeletePanelGroupDialog/index.ts"],"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\nexport * from './DeletePanelGroupDialog';\n"],"names":[],"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,cAAc,0BAA0B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { LayoutItem } from '../../context';
2
+ import { PanelGroupItemId } from '../../context';
3
3
  export interface GridItemContentProps {
4
- panelGroupItemId: LayoutItem;
4
+ panelGroupItemId: PanelGroupItemId;
5
5
  }
6
6
  /**
7
7
  * Resolves the reference to panel content in a GridItemDefinition and renders the panel.
@@ -1 +1 @@
1
- {"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,UAAU,EAAY,MAAM,eAAe,CAAC;AAGrD,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,UAAU,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAI1D"}
1
+ {"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,gBAAgB,EAA0C,MAAM,eAAe,CAAC;AAGzF,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAgB1D"}
@@ -11,16 +11,26 @@
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 { usePanel } from '../../context';
14
+ import { useEditMode, usePanel, usePanelActions } from '../../context';
15
15
  import { Panel } from '../Panel/Panel';
16
16
  /**
17
17
  * Resolves the reference to panel content in a GridItemDefinition and renders the panel.
18
18
  */ export function GridItemContent(props) {
19
19
  const { panelGroupItemId } = props;
20
20
  const panelDefinition = usePanel(panelGroupItemId);
21
+ const { isEditMode } = useEditMode();
22
+ const { openEditPanel , openDeletePanelDialog } = usePanelActions(panelGroupItemId);
23
+ // Provide actions to the panel when in edit mode
24
+ let editHandlers = undefined;
25
+ if (isEditMode) {
26
+ editHandlers = {
27
+ onEditPanelClick: openEditPanel,
28
+ onDeletePanelClick: openDeletePanelDialog
29
+ };
30
+ }
21
31
  return /*#__PURE__*/ _jsx(Panel, {
22
32
  definition: panelDefinition,
23
- panelGroupItemId: panelGroupItemId
33
+ editHandlers: editHandlers
24
34
  });
25
35
  }
26
36
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.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 { LayoutItem, usePanel } from '../../context';\nimport { Panel } from '../Panel/Panel';\n\nexport interface GridItemContentProps {\n panelGroupItemId: LayoutItem;\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps) {\n const { panelGroupItemId } = props;\n const panelDefinition = usePanel(panelGroupItemId);\n return <Panel definition={panelDefinition} panelGroupItemId={panelGroupItemId} />;\n}\n"],"names":["usePanel","Panel","GridItemContent","props","panelGroupItemId","panelDefinition","definition"],"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,SAAqBA,QAAQ,QAAQ,eAAe,CAAC;AACrD,SAASC,KAAK,QAAQ,gBAAgB,CAAC;AAMvC;;CAEC,GACD,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;IAC3D,MAAM,EAAEC,gBAAgB,CAAA,EAAE,GAAGD,KAAK,AAAC;IACnC,MAAME,eAAe,GAAGL,QAAQ,CAACI,gBAAgB,CAAC,AAAC;IACnD,qBAAO,KAACH,KAAK;QAACK,UAAU,EAAED,eAAe;QAAED,gBAAgB,EAAEA,gBAAgB;MAAI,CAAC;AACpF,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.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 { PanelGroupItemId, useEditMode, usePanel, usePanelActions } from '../../context';\nimport { Panel, PanelProps } from '../Panel/Panel';\n\nexport interface GridItemContentProps {\n panelGroupItemId: PanelGroupItemId;\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps) {\n const { panelGroupItemId } = props;\n const panelDefinition = usePanel(panelGroupItemId);\n const { isEditMode } = useEditMode();\n const { openEditPanel, openDeletePanelDialog } = usePanelActions(panelGroupItemId);\n\n // Provide actions to the panel when in edit mode\n let editHandlers: PanelProps['editHandlers'] = undefined;\n if (isEditMode) {\n editHandlers = {\n onEditPanelClick: openEditPanel,\n onDeletePanelClick: openDeletePanelDialog,\n };\n }\n\n return <Panel definition={panelDefinition} editHandlers={editHandlers} />;\n}\n"],"names":["useEditMode","usePanel","usePanelActions","Panel","GridItemContent","props","panelGroupItemId","panelDefinition","isEditMode","openEditPanel","openDeletePanelDialog","editHandlers","undefined","onEditPanelClick","onDeletePanelClick","definition"],"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,SAA2BA,WAAW,EAAEC,QAAQ,EAAEC,eAAe,QAAQ,eAAe,CAAC;AACzF,SAASC,KAAK,QAAoB,gBAAgB,CAAC;AAMnD;;CAEC,GACD,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;IAC3D,MAAM,EAAEC,gBAAgB,CAAA,EAAE,GAAGD,KAAK,AAAC;IACnC,MAAME,eAAe,GAAGN,QAAQ,CAACK,gBAAgB,CAAC,AAAC;IACnD,MAAM,EAAEE,UAAU,CAAA,EAAE,GAAGR,WAAW,EAAE,AAAC;IACrC,MAAM,EAAES,aAAa,CAAA,EAAEC,qBAAqB,CAAA,EAAE,GAAGR,eAAe,CAACI,gBAAgB,CAAC,AAAC;IAEnF,iDAAiD;IACjD,IAAIK,YAAY,GAA+BC,SAAS,AAAC;IACzD,IAAIJ,UAAU,EAAE;QACdG,YAAY,GAAG;YACbE,gBAAgB,EAAEJ,aAAa;YAC/BK,kBAAkB,EAAEJ,qBAAqB;SAC1C,CAAC;IACJ,CAAC;IAED,qBAAO,KAACP,KAAK;QAACY,UAAU,EAAER,eAAe;QAAEI,YAAY,EAAEA,YAAY;MAAI,CAAC;AAC5E,CAAC"}