@perses-dev/dashboards 0.21.1 → 0.23.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 (329) hide show
  1. package/dist/cjs/components/AddGroupButton/AddGroupButton.js +43 -0
  2. package/dist/cjs/components/AddGroupButton/index.js +28 -0
  3. package/dist/cjs/components/AddPanelButton/AddPanelButton.js +43 -0
  4. package/dist/cjs/components/AddPanelButton/index.js +28 -0
  5. package/dist/cjs/components/Dashboard/Dashboard.js +1 -1
  6. package/dist/cjs/components/Dashboard/index.js +1 -1
  7. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +50 -22
  8. package/dist/cjs/components/DashboardToolbar/index.js +1 -1
  9. package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +9 -31
  10. package/dist/cjs/components/DeletePanelDialog/index.js +1 -1
  11. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -1
  12. package/dist/cjs/components/DeletePanelGroupDialog/index.js +1 -1
  13. package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +2 -1
  14. package/dist/cjs/components/DiscardChangesConfirmationDialog/index.js +1 -1
  15. package/dist/cjs/components/DownloadButton/DownloadButton.js +17 -53
  16. package/dist/cjs/components/DownloadButton/index.js +1 -1
  17. package/dist/cjs/components/GridLayout/GridContainer.js +2 -1
  18. package/dist/cjs/components/GridLayout/GridItemContent.js +3 -2
  19. package/dist/cjs/components/GridLayout/GridLayout.js +6 -8
  20. package/dist/cjs/components/GridLayout/GridTitle.js +14 -11
  21. package/dist/cjs/components/GridLayout/index.js +1 -1
  22. package/dist/cjs/components/Panel/Panel.js +6 -6
  23. package/dist/cjs/components/Panel/Panel.test.js +11 -3
  24. package/dist/cjs/components/Panel/PanelContent.js +3 -2
  25. package/dist/cjs/components/Panel/PanelHeader.js +26 -8
  26. package/dist/cjs/components/Panel/index.js +1 -1
  27. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +2 -1
  28. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +1 -1
  29. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +1 -1
  30. package/dist/cjs/components/PanelDrawer/PanelPreview.js +1 -1
  31. package/dist/cjs/components/PanelDrawer/index.js +1 -1
  32. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +4 -1
  33. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +1 -1
  34. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +1 -1
  35. package/dist/cjs/components/PanelGroupDialog/index.js +1 -1
  36. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +14 -16
  37. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +3 -3
  38. package/dist/cjs/components/TimeRangeControls/index.js +1 -1
  39. package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +35 -0
  40. package/dist/cjs/components/ToolbarIconButton/index.js +28 -0
  41. package/dist/cjs/components/Variables/EditVariablesButton.js +75 -0
  42. package/dist/cjs/components/Variables/Variable.js +1 -1
  43. package/dist/cjs/components/Variables/VariableEditor.js +10 -6
  44. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +6 -7
  45. package/dist/cjs/components/Variables/VariableEditorForm/index.js +1 -1
  46. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +1 -1
  47. package/dist/cjs/components/Variables/VariableList.js +45 -111
  48. package/dist/cjs/components/Variables/index.js +4 -2
  49. package/dist/cjs/components/Variables/variable-model.js +1 -1
  50. package/dist/cjs/components/Variables/variable-model.test.js +1 -1
  51. package/dist/cjs/components/index.js +5 -2
  52. package/dist/cjs/{utils/functions.js → constants/grid-layout-config.js} +14 -6
  53. package/dist/cjs/constants/index.js +29 -0
  54. package/dist/cjs/constants/user-interface-text.js +61 -0
  55. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +28 -3
  56. package/dist/cjs/context/DashboardProvider/common.js +1 -1
  57. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +7 -5
  58. package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +1 -1
  59. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -1
  60. package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +1 -1
  61. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +62 -0
  62. package/dist/cjs/context/DashboardProvider/index.js +1 -1
  63. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +9 -38
  64. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +1 -1
  65. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -1
  66. package/dist/cjs/context/DashboardProvider/panel-slice.js +1 -1
  67. package/dist/cjs/context/DatasourceStoreProvider.js +1 -1
  68. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +8 -8
  69. package/dist/cjs/context/TemplateVariableProvider/index.js +1 -1
  70. package/dist/cjs/context/TemplateVariableProvider/query-params.js +1 -1
  71. package/dist/cjs/context/TemplateVariableProvider/query-params.test.js +1 -1
  72. package/dist/cjs/context/index.js +1 -1
  73. package/dist/cjs/context/useDashboard.js +5 -3
  74. package/dist/cjs/index.js +1 -1
  75. package/dist/cjs/test/dashboard-provider.js +1 -1
  76. package/dist/cjs/test/index.js +1 -1
  77. package/dist/cjs/test/plugin-registry.js +1 -1
  78. package/dist/cjs/test/render.js +1 -1
  79. package/dist/cjs/test/setup-tests.js +1 -1
  80. package/dist/cjs/test/testDashboard.js +1 -1
  81. package/dist/cjs/utils/index.js +28 -0
  82. package/dist/cjs/utils/panelUtils.js +168 -0
  83. package/dist/cjs/utils/panelUtils.test.js +195 -0
  84. package/dist/cjs/views/ViewDashboard/DashboardApp.js +5 -2
  85. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -3
  86. package/dist/cjs/views/ViewDashboard/index.js +1 -1
  87. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +1 -1
  88. package/dist/cjs/views/index.js +1 -1
  89. package/dist/components/AddGroupButton/AddGroupButton.d.ts +3 -0
  90. package/dist/components/AddGroupButton/AddGroupButton.d.ts.map +1 -0
  91. package/dist/components/AddGroupButton/AddGroupButton.js +32 -0
  92. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -0
  93. package/dist/components/AddGroupButton/index.d.ts +2 -0
  94. package/dist/components/AddGroupButton/index.d.ts.map +1 -0
  95. package/dist/{utils/functions.js → components/AddGroupButton/index.js} +3 -5
  96. package/dist/components/AddGroupButton/index.js.map +1 -0
  97. package/dist/components/AddPanelButton/AddPanelButton.d.ts +3 -0
  98. package/dist/components/AddPanelButton/AddPanelButton.d.ts.map +1 -0
  99. package/dist/components/AddPanelButton/AddPanelButton.js +32 -0
  100. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -0
  101. package/dist/components/AddPanelButton/index.d.ts +2 -0
  102. package/dist/components/AddPanelButton/index.d.ts.map +1 -0
  103. package/dist/components/AddPanelButton/index.js +15 -0
  104. package/dist/components/AddPanelButton/index.js.map +1 -0
  105. package/dist/components/Dashboard/Dashboard.js +1 -1
  106. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  107. package/dist/components/Dashboard/index.js +1 -1
  108. package/dist/components/Dashboard/index.js.map +1 -1
  109. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  110. package/dist/components/DashboardToolbar/DashboardToolbar.js +51 -23
  111. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  112. package/dist/components/DashboardToolbar/index.js +1 -1
  113. package/dist/components/DashboardToolbar/index.js.map +1 -1
  114. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -1
  115. package/dist/components/DeletePanelDialog/DeletePanelDialog.js +8 -25
  116. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  117. package/dist/components/DeletePanelDialog/index.js +1 -1
  118. package/dist/components/DeletePanelDialog/index.js.map +1 -1
  119. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -1
  120. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  121. package/dist/components/DeletePanelGroupDialog/index.js +1 -1
  122. package/dist/components/DeletePanelGroupDialog/index.js.map +1 -1
  123. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +2 -1
  124. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  125. package/dist/components/DiscardChangesConfirmationDialog/index.js +1 -1
  126. package/dist/components/DiscardChangesConfirmationDialog/index.js.map +1 -1
  127. package/dist/components/DownloadButton/DownloadButton.d.ts +5 -1
  128. package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -1
  129. package/dist/components/DownloadButton/DownloadButton.js +18 -15
  130. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  131. package/dist/components/DownloadButton/index.js +1 -1
  132. package/dist/components/DownloadButton/index.js.map +1 -1
  133. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -1
  134. package/dist/components/GridLayout/GridContainer.js +2 -1
  135. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  136. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  137. package/dist/components/GridLayout/GridItemContent.js +3 -2
  138. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  139. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  140. package/dist/components/GridLayout/GridLayout.js +6 -8
  141. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  142. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  143. package/dist/components/GridLayout/GridTitle.js +14 -11
  144. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  145. package/dist/components/GridLayout/index.js +1 -1
  146. package/dist/components/GridLayout/index.js.map +1 -1
  147. package/dist/components/Panel/Panel.js +7 -7
  148. package/dist/components/Panel/Panel.js.map +1 -1
  149. package/dist/components/Panel/Panel.test.js +11 -3
  150. package/dist/components/Panel/Panel.test.js.map +1 -1
  151. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  152. package/dist/components/Panel/PanelContent.js +3 -2
  153. package/dist/components/Panel/PanelContent.js.map +1 -1
  154. package/dist/components/Panel/PanelHeader.d.ts +1 -0
  155. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  156. package/dist/components/Panel/PanelHeader.js +26 -8
  157. package/dist/components/Panel/PanelHeader.js.map +1 -1
  158. package/dist/components/Panel/index.js +1 -1
  159. package/dist/components/Panel/index.js.map +1 -1
  160. package/dist/components/PanelDrawer/PanelDrawer.js +2 -1
  161. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  162. package/dist/components/PanelDrawer/PanelDrawer.test.js +1 -1
  163. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
  164. package/dist/components/PanelDrawer/PanelEditorForm.js +1 -1
  165. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  166. package/dist/components/PanelDrawer/PanelPreview.js +1 -1
  167. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  168. package/dist/components/PanelDrawer/index.js +1 -1
  169. package/dist/components/PanelDrawer/index.js.map +1 -1
  170. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  171. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +4 -1
  172. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  173. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +1 -1
  174. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
  175. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +1 -1
  176. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  177. package/dist/components/PanelGroupDialog/index.js +1 -1
  178. package/dist/components/PanelGroupDialog/index.js.map +1 -1
  179. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  180. package/dist/components/TimeRangeControls/TimeRangeControls.js +15 -17
  181. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  182. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +3 -3
  183. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  184. package/dist/components/TimeRangeControls/index.js +1 -1
  185. package/dist/components/TimeRangeControls/index.js.map +1 -1
  186. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts +6 -0
  187. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts.map +1 -0
  188. package/dist/components/ToolbarIconButton/ToolbarIconButton.js +29 -0
  189. package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -0
  190. package/dist/components/ToolbarIconButton/index.d.ts +2 -0
  191. package/dist/components/ToolbarIconButton/index.d.ts.map +1 -0
  192. package/dist/components/ToolbarIconButton/index.js +15 -0
  193. package/dist/components/ToolbarIconButton/index.js.map +1 -0
  194. package/dist/components/Variables/EditVariablesButton.d.ts +3 -0
  195. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -0
  196. package/dist/components/Variables/EditVariablesButton.js +64 -0
  197. package/dist/components/Variables/EditVariablesButton.js.map +1 -0
  198. package/dist/components/Variables/Variable.js +1 -1
  199. package/dist/components/Variables/Variable.js.map +1 -1
  200. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  201. package/dist/components/Variables/VariableEditor.js +10 -6
  202. package/dist/components/Variables/VariableEditor.js.map +1 -1
  203. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  204. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +8 -9
  205. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  206. package/dist/components/Variables/VariableEditorForm/index.js +1 -1
  207. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
  208. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +1 -1
  209. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  210. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  211. package/dist/components/Variables/VariableList.js +47 -74
  212. package/dist/components/Variables/VariableList.js.map +1 -1
  213. package/dist/components/Variables/index.d.ts +3 -1
  214. package/dist/components/Variables/index.d.ts.map +1 -1
  215. package/dist/components/Variables/index.js +4 -2
  216. package/dist/components/Variables/index.js.map +1 -1
  217. package/dist/components/Variables/variable-model.js +1 -1
  218. package/dist/components/Variables/variable-model.js.map +1 -1
  219. package/dist/components/Variables/variable-model.test.js +1 -1
  220. package/dist/components/Variables/variable-model.test.js.map +1 -1
  221. package/dist/components/index.d.ts +4 -1
  222. package/dist/components/index.d.ts.map +1 -1
  223. package/dist/components/index.js +5 -2
  224. package/dist/components/index.js.map +1 -1
  225. package/dist/constants/grid-layout-config.d.ts +6 -0
  226. package/dist/constants/grid-layout-config.d.ts.map +1 -0
  227. package/dist/constants/grid-layout-config.js +19 -0
  228. package/dist/constants/grid-layout-config.js.map +1 -0
  229. package/dist/constants/index.d.ts +3 -0
  230. package/dist/constants/index.d.ts.map +1 -0
  231. package/dist/constants/index.js +16 -0
  232. package/dist/constants/index.js.map +1 -0
  233. package/dist/constants/user-interface-text.d.ts +30 -0
  234. package/dist/constants/user-interface-text.d.ts.map +1 -0
  235. package/dist/constants/user-interface-text.js +49 -0
  236. package/dist/constants/user-interface-text.js.map +1 -0
  237. package/dist/context/DashboardProvider/DashboardProvider.d.ts +6 -4
  238. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  239. package/dist/context/DashboardProvider/DashboardProvider.js +29 -4
  240. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  241. package/dist/context/DashboardProvider/common.js +1 -1
  242. package/dist/context/DashboardProvider/common.js.map +1 -1
  243. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -0
  244. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  245. package/dist/context/DashboardProvider/dashboard-provider-api.js +7 -5
  246. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  247. package/dist/context/DashboardProvider/delete-panel-group-slice.js +1 -1
  248. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  249. package/dist/context/DashboardProvider/delete-panel-slice.js +1 -1
  250. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  251. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js +1 -1
  252. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
  253. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts +19 -0
  254. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts.map +1 -0
  255. package/dist/context/DashboardProvider/duplicate-panel-slice.js +58 -0
  256. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -0
  257. package/dist/context/DashboardProvider/index.d.ts +1 -1
  258. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  259. package/dist/context/DashboardProvider/index.js +1 -1
  260. package/dist/context/DashboardProvider/index.js.map +1 -1
  261. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +4 -0
  262. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  263. package/dist/context/DashboardProvider/panel-editor-slice.js +7 -36
  264. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  265. package/dist/context/DashboardProvider/panel-group-editor-slice.js +1 -1
  266. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  267. package/dist/context/DashboardProvider/panel-group-slice.js +1 -1
  268. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  269. package/dist/context/DashboardProvider/panel-slice.js +1 -1
  270. package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
  271. package/dist/context/DatasourceStoreProvider.js +1 -1
  272. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  273. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +8 -8
  274. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  275. package/dist/context/TemplateVariableProvider/index.js +1 -1
  276. package/dist/context/TemplateVariableProvider/index.js.map +1 -1
  277. package/dist/context/TemplateVariableProvider/query-params.js +1 -1
  278. package/dist/context/TemplateVariableProvider/query-params.js.map +1 -1
  279. package/dist/context/TemplateVariableProvider/query-params.test.js +1 -1
  280. package/dist/context/TemplateVariableProvider/query-params.test.js.map +1 -1
  281. package/dist/context/index.js +1 -1
  282. package/dist/context/index.js.map +1 -1
  283. package/dist/context/useDashboard.d.ts.map +1 -1
  284. package/dist/context/useDashboard.js +5 -3
  285. package/dist/context/useDashboard.js.map +1 -1
  286. package/dist/index.js +1 -1
  287. package/dist/index.js.map +1 -1
  288. package/dist/test/dashboard-provider.js +1 -1
  289. package/dist/test/dashboard-provider.js.map +1 -1
  290. package/dist/test/index.js +1 -1
  291. package/dist/test/index.js.map +1 -1
  292. package/dist/test/plugin-registry.js +1 -1
  293. package/dist/test/plugin-registry.js.map +1 -1
  294. package/dist/test/render.js +1 -1
  295. package/dist/test/render.js.map +1 -1
  296. package/dist/test/setup-tests.js +1 -1
  297. package/dist/test/setup-tests.js.map +1 -1
  298. package/dist/test/testDashboard.js +1 -1
  299. package/dist/test/testDashboard.js.map +1 -1
  300. package/dist/utils/index.d.ts +2 -0
  301. package/dist/utils/index.d.ts.map +1 -0
  302. package/dist/utils/index.js +15 -0
  303. package/dist/utils/index.js.map +1 -0
  304. package/dist/utils/panelUtils.d.ts +27 -0
  305. package/dist/utils/panelUtils.d.ts.map +1 -0
  306. package/dist/utils/panelUtils.js +174 -0
  307. package/dist/utils/panelUtils.js.map +1 -0
  308. package/dist/utils/panelUtils.test.d.ts +2 -0
  309. package/dist/utils/panelUtils.test.d.ts.map +1 -0
  310. package/dist/utils/panelUtils.test.js +193 -0
  311. package/dist/utils/panelUtils.test.js.map +1 -0
  312. package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
  313. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  314. package/dist/views/ViewDashboard/DashboardApp.js +5 -2
  315. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  316. package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -0
  317. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  318. package/dist/views/ViewDashboard/ViewDashboard.js +5 -3
  319. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  320. package/dist/views/ViewDashboard/index.js +1 -1
  321. package/dist/views/ViewDashboard/index.js.map +1 -1
  322. package/dist/views/ViewDashboard/tests/panelGroups.test.js +1 -1
  323. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
  324. package/dist/views/index.js +1 -1
  325. package/dist/views/index.js.map +1 -1
  326. package/package.json +4 -4
  327. package/dist/utils/functions.d.ts +0 -2
  328. package/dist/utils/functions.d.ts.map +0 -1
  329. package/dist/utils/functions.js.map +0 -1
@@ -0,0 +1,3 @@
1
+ export * from './grid-layout-config';
2
+ export * from './user-interface-text';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAaA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,16 @@
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
+ export * from './grid-layout-config';
14
+ export * from './user-interface-text';
15
+
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/constants/index.ts"],"sourcesContent":["// Copyright 2023 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 './grid-layout-config';\nexport * from './user-interface-text';\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,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,30 @@
1
+ export declare const TOOLTIP_TEXT: {
2
+ addPanel: string;
3
+ addGroup: string;
4
+ downloadDashboard: string;
5
+ editVariables: string;
6
+ refreshDashboard: string;
7
+ addPanelToGroup: string;
8
+ deleteGroup: string;
9
+ editGroup: string;
10
+ moveGroupDown: string;
11
+ moveGroupUp: string;
12
+ editPanel: string;
13
+ duplicatePanel: string;
14
+ deletePanel: string;
15
+ movePanel: string;
16
+ refreshVariableValues: string;
17
+ copyVariableValues: string;
18
+ };
19
+ export declare const ARIA_LABEL_TEXT: {
20
+ addPanelToGroup: (groupName: string) => string;
21
+ deleteGroup: (groupName: string) => string;
22
+ editGroup: (groupName: string) => string;
23
+ moveGroupDown: (groupName: string) => string;
24
+ moveGroupUp: (groupName: string) => string;
25
+ editPanel: (panelName: string) => string;
26
+ duplicatePanel: (panelName: string) => string;
27
+ deletePanel: (panelName: string) => string;
28
+ movePanel: (panelName: string) => string;
29
+ };
30
+ //# sourceMappingURL=user-interface-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-interface-text.d.ts","sourceRoot":"","sources":["../../src/constants/user-interface-text.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;CAqBxB,CAAC;AAEF,eAAO,MAAM,eAAe;iCAEG,MAAM;6BACV,MAAM;2BACR,MAAM;+BACF,MAAM;6BACR,MAAM;2BAER,MAAM;gCACD,MAAM;6BACT,MAAM;2BACR,MAAM;CAC9B,CAAC"}
@@ -0,0 +1,49 @@
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
+ export const TOOLTIP_TEXT = {
14
+ // Toolbar buttons
15
+ addPanel: 'Add panel',
16
+ addGroup: 'Add panel group',
17
+ downloadDashboard: 'Download JSON',
18
+ editVariables: 'Edit variables',
19
+ refreshDashboard: 'Refresh dashboard',
20
+ // Group buttons
21
+ addPanelToGroup: 'Add panel to group',
22
+ deleteGroup: 'Delete group',
23
+ editGroup: 'Edit group',
24
+ moveGroupDown: 'Move group down',
25
+ moveGroupUp: 'Move group up',
26
+ // Panel buttons
27
+ editPanel: 'Edit',
28
+ duplicatePanel: 'Duplicate',
29
+ deletePanel: 'Delete',
30
+ movePanel: 'Move',
31
+ // Variable editor buttons
32
+ refreshVariableValues: 'Refresh values',
33
+ copyVariableValues: 'Copy values to clipboard'
34
+ };
35
+ export const ARIA_LABEL_TEXT = {
36
+ // Group buttons
37
+ addPanelToGroup: (groupName)=>`add panel to group ${groupName}`,
38
+ deleteGroup: (groupName)=>`delete group ${groupName}`,
39
+ editGroup: (groupName)=>`edit group ${groupName}`,
40
+ moveGroupDown: (groupName)=>`move group ${groupName} down`,
41
+ moveGroupUp: (groupName)=>`move group ${groupName} up`,
42
+ // Panel buttons
43
+ editPanel: (panelName)=>`edit panel ${panelName}`,
44
+ duplicatePanel: (panelName)=>`duplicate panel ${panelName}`,
45
+ deletePanel: (panelName)=>`delete panel ${panelName}`,
46
+ movePanel: (panelName)=>`move panel ${panelName}`
47
+ };
48
+
49
+ //# sourceMappingURL=user-interface-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/constants/user-interface-text.ts"],"sourcesContent":["// Copyright 2023 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 const TOOLTIP_TEXT = {\n // Toolbar buttons\n addPanel: 'Add panel',\n addGroup: 'Add panel group',\n downloadDashboard: 'Download JSON',\n editVariables: 'Edit variables',\n refreshDashboard: 'Refresh dashboard',\n // Group buttons\n addPanelToGroup: 'Add panel to group',\n deleteGroup: 'Delete group',\n editGroup: 'Edit group',\n moveGroupDown: 'Move group down',\n moveGroupUp: 'Move group up',\n // Panel buttons\n editPanel: 'Edit',\n duplicatePanel: 'Duplicate',\n deletePanel: 'Delete',\n movePanel: 'Move',\n // Variable editor buttons\n refreshVariableValues: 'Refresh values',\n copyVariableValues: 'Copy values to clipboard',\n};\n\nexport const ARIA_LABEL_TEXT = {\n // Group buttons\n addPanelToGroup: (groupName: string) => `add panel to group ${groupName}`,\n deleteGroup: (groupName: string) => `delete group ${groupName}`,\n editGroup: (groupName: string) => `edit group ${groupName}`,\n moveGroupDown: (groupName: string) => `move group ${groupName} down`,\n moveGroupUp: (groupName: string) => `move group ${groupName} up`,\n // Panel buttons\n editPanel: (panelName: string) => `edit panel ${panelName}`,\n duplicatePanel: (panelName: string) => `duplicate panel ${panelName}`,\n deletePanel: (panelName: string) => `delete panel ${panelName}`,\n movePanel: (panelName: string) => `move panel ${panelName}`,\n};\n"],"names":["TOOLTIP_TEXT","addPanel","addGroup","downloadDashboard","editVariables","refreshDashboard","addPanelToGroup","deleteGroup","editGroup","moveGroupDown","moveGroupUp","editPanel","duplicatePanel","deletePanel","movePanel","refreshVariableValues","copyVariableValues","ARIA_LABEL_TEXT","groupName","panelName"],"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,OAAO,MAAMA,YAAY,GAAG;IAC1B,kBAAkB;IAClBC,QAAQ,EAAE,WAAW;IACrBC,QAAQ,EAAE,iBAAiB;IAC3BC,iBAAiB,EAAE,eAAe;IAClCC,aAAa,EAAE,gBAAgB;IAC/BC,gBAAgB,EAAE,mBAAmB;IACrC,gBAAgB;IAChBC,eAAe,EAAE,oBAAoB;IACrCC,WAAW,EAAE,cAAc;IAC3BC,SAAS,EAAE,YAAY;IACvBC,aAAa,EAAE,iBAAiB;IAChCC,WAAW,EAAE,eAAe;IAC5B,gBAAgB;IAChBC,SAAS,EAAE,MAAM;IACjBC,cAAc,EAAE,WAAW;IAC3BC,WAAW,EAAE,QAAQ;IACrBC,SAAS,EAAE,MAAM;IACjB,0BAA0B;IAC1BC,qBAAqB,EAAE,gBAAgB;IACvCC,kBAAkB,EAAE,0BAA0B;CAC/C,CAAC;AAEF,OAAO,MAAMC,eAAe,GAAG;IAC7B,gBAAgB;IAChBX,eAAe,EAAE,CAACY,SAAiB,GAAK,CAAC,mBAAmB,EAAEA,SAAS,CAAC,CAAC;IACzEX,WAAW,EAAE,CAACW,SAAiB,GAAK,CAAC,aAAa,EAAEA,SAAS,CAAC,CAAC;IAC/DV,SAAS,EAAE,CAACU,SAAiB,GAAK,CAAC,WAAW,EAAEA,SAAS,CAAC,CAAC;IAC3DT,aAAa,EAAE,CAACS,SAAiB,GAAK,CAAC,WAAW,EAAEA,SAAS,CAAC,KAAK,CAAC;IACpER,WAAW,EAAE,CAACQ,SAAiB,GAAK,CAAC,WAAW,EAAEA,SAAS,CAAC,GAAG,CAAC;IAChE,gBAAgB;IAChBP,SAAS,EAAE,CAACQ,SAAiB,GAAK,CAAC,WAAW,EAAEA,SAAS,CAAC,CAAC;IAC3DP,cAAc,EAAE,CAACO,SAAiB,GAAK,CAAC,gBAAgB,EAAEA,SAAS,CAAC,CAAC;IACrEN,WAAW,EAAE,CAACM,SAAiB,GAAK,CAAC,aAAa,EAAEA,SAAS,CAAC,CAAC;IAC/DL,SAAS,EAAE,CAACK,SAAiB,GAAK,CAAC,WAAW,EAAEA,SAAS,CAAC,CAAC;CAC5D,CAAC"}
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
1
  import type { StoreApi } from 'zustand';
3
- import { DashboardResource, ProjectMetadata, RelativeTimeRange } from '@perses-dev/core';
2
+ import { ReactNode } from 'react';
3
+ import { DashboardResource, Display, ProjectMetadata, RelativeTimeRange } from '@perses-dev/core';
4
4
  import { PanelGroupEditorSlice } from './panel-group-editor-slice';
5
5
  import { PanelGroupSlice } from './panel-group-slice';
6
6
  import { PanelEditorSlice } from './panel-editor-slice';
@@ -8,12 +8,14 @@ import { PanelSlice } from './panel-slice';
8
8
  import { DeletePanelGroupSlice } from './delete-panel-group-slice';
9
9
  import { DeletePanelSlice } from './delete-panel-slice';
10
10
  import { DiscardChangesConfirmationDialogSlice } from './discard-changes-dialog-slice';
11
- export interface DashboardStoreState extends PanelGroupSlice, PanelSlice, PanelGroupEditorSlice, DeletePanelGroupSlice, PanelEditorSlice, DeletePanelSlice, DiscardChangesConfirmationDialogSlice {
11
+ import { DuplicatePanelSlice } from './duplicate-panel-slice';
12
+ export interface DashboardStoreState extends PanelGroupSlice, PanelSlice, PanelGroupEditorSlice, DeletePanelGroupSlice, PanelEditorSlice, DeletePanelSlice, DiscardChangesConfirmationDialogSlice, DuplicatePanelSlice {
12
13
  isEditMode: boolean;
13
14
  setEditMode: (isEditMode: boolean) => void;
14
15
  defaultTimeRange: RelativeTimeRange;
15
16
  setDashboard: (dashboard: DashboardResource) => void;
16
17
  metadata: ProjectMetadata;
18
+ display?: Display;
17
19
  }
18
20
  export interface DashboardStoreProps {
19
21
  dashboardResource: DashboardResource;
@@ -21,7 +23,7 @@ export interface DashboardStoreProps {
21
23
  }
22
24
  export interface DashboardProviderProps {
23
25
  initialState: DashboardStoreProps;
24
- children?: React.ReactNode;
26
+ children?: ReactNode;
25
27
  }
26
28
  export declare const DashboardContext: import("react").Context<StoreApi<DashboardStoreState> | undefined>;
27
29
  export declare function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): T;
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKxC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAA+B,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAsD,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAA0B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAoB,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAA+B,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAA0B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAmC,qCAAqC,EAAE,MAAM,gCAAgC,CAAC;AAExH,MAAM,WAAW,mBACf,SAAQ,eAAe,EACrB,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,gBA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O,EAA0B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAmC,qCAAqC,EAAE,MAAM,gCAAgC,CAAC;AACxH,OAAO,EAA6B,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEzF,MAAM,WAAW,mBACf,SAAQ,eAAe,EACrB,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,qCAAqC,EACrC,mBAAmB;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,YAAY,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACrD,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,oEAAsE,CAAC;AAEpG,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,CAAC,KAM/E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAsB9D"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -15,7 +15,8 @@ import { createStore, useStore } from 'zustand';
15
15
  import { devtools } from 'zustand/middleware';
16
16
  import { immer } from 'zustand/middleware/immer';
17
17
  import shallow from 'zustand/shallow';
18
- import { createContext, useCallback, useContext, useState } from 'react';
18
+ import { createContext, useCallback, useContext, useEffect, useState } from 'react';
19
+ import { usePlugin, usePluginRegistry } from '@perses-dev/plugin-system';
19
20
  import { createPanelGroupEditorSlice } from './panel-group-editor-slice';
20
21
  import { convertLayoutsToPanelGroups, createPanelGroupSlice } from './panel-group-slice';
21
22
  import { createPanelEditorSlice } from './panel-editor-slice';
@@ -23,6 +24,7 @@ import { createPanelSlice } from './panel-slice';
23
24
  import { createDeletePanelGroupSlice } from './delete-panel-group-slice';
24
25
  import { createDeletePanelSlice } from './delete-panel-slice';
25
26
  import { createDiscardChangesDialogSlice } from './discard-changes-dialog-slice';
27
+ import { createDuplicatePanelSlice } from './duplicate-panel-slice';
26
28
  export const DashboardContext = /*#__PURE__*/ createContext(undefined);
27
29
  export function useDashboardStore(selector) {
28
30
  const store = useContext(DashboardContext);
@@ -35,7 +37,27 @@ export function DashboardProvider(props) {
35
37
  const createDashboardStore = useCallback(initStore, [
36
38
  props
37
39
  ]);
40
+ // load plugin to retrieve initial spec if default panel kind is defined
41
+ const { defaultPluginKinds } = usePluginRegistry();
42
+ var ref;
43
+ const defaultPanelKind = (ref = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds['Panel']) !== null && ref !== void 0 ? ref : '';
44
+ const { data: plugin } = usePlugin('Panel', defaultPanelKind);
38
45
  const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders
46
+ useEffect(()=>{
47
+ if (plugin === undefined) return;
48
+ const spec = plugin.createInitialOptions();
49
+ // set default panel kind and spec for add panel editor
50
+ store.setState({
51
+ initialValues: {
52
+ kind: defaultPanelKind,
53
+ spec
54
+ }
55
+ });
56
+ }, [
57
+ plugin,
58
+ store,
59
+ defaultPanelKind
60
+ ]);
39
61
  return /*#__PURE__*/ _jsx(DashboardContext.Provider, {
40
62
  value: store,
41
63
  children: props.children
@@ -43,7 +65,7 @@ export function DashboardProvider(props) {
43
65
  }
44
66
  function initStore(props) {
45
67
  const { initialState: { dashboardResource , isEditMode } , } = props;
46
- const { spec: { layouts , panels , duration } , metadata , } = dashboardResource;
68
+ const { spec: { display , layouts , panels , duration } , metadata , } = dashboardResource;
47
69
  const store = createStore()(immer(devtools((...args)=>{
48
70
  const [set] = args;
49
71
  return {
@@ -54,7 +76,9 @@ function initStore(props) {
54
76
  ...createPanelEditorSlice()(...args),
55
77
  ...createDeletePanelSlice()(...args),
56
78
  ...createDiscardChangesDialogSlice(...args),
79
+ ...createDuplicatePanelSlice()(...args),
57
80
  metadata,
81
+ display,
58
82
  defaultTimeRange: {
59
83
  pastDuration: duration
60
84
  },
@@ -62,9 +86,10 @@ function initStore(props) {
62
86
  setEditMode: (isEditMode)=>set({
63
87
  isEditMode
64
88
  }),
65
- setDashboard: ({ metadata , spec: { panels , layouts } })=>{
89
+ setDashboard: ({ metadata , spec: { display , panels , layouts } })=>{
66
90
  set((state)=>{
67
91
  state.metadata = metadata;
92
+ state.display = display;
68
93
  const { panelGroups , panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
69
94
  state.panels = panels;
70
95
  state.panelGroups = panelGroups;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.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 { createStore, useStore } from 'zustand';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport shallow from 'zustand/shallow';\nimport { createContext, useCallback, useContext, useState } from 'react';\nimport { DashboardResource, ProjectMetadata, RelativeTimeRange } from '@perses-dev/core';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { convertLayoutsToPanelGroups, createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\nimport { createPanelSlice, PanelSlice } from './panel-slice';\nimport { createDeletePanelGroupSlice, DeletePanelGroupSlice } from './delete-panel-group-slice';\nimport { createDeletePanelSlice, DeletePanelSlice } from './delete-panel-slice';\nimport { createDiscardChangesDialogSlice, DiscardChangesConfirmationDialogSlice } from './discard-changes-dialog-slice';\n\nexport interface DashboardStoreState\n extends PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice,\n DiscardChangesConfirmationDialogSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n defaultTimeRange: RelativeTimeRange;\n setDashboard: (dashboard: DashboardResource) => void;\n metadata: ProjectMetadata;\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource;\n isEditMode?: boolean;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: React.ReactNode;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T) {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStore(store, selector, shallow);\n}\n\nexport function DashboardProvider(props: DashboardProviderProps) {\n const createDashboardStore = useCallback(initStore, [props]);\n\n const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps) {\n const {\n initialState: { dashboardResource, isEditMode },\n } = props;\n\n const {\n spec: { layouts, panels, duration },\n metadata,\n } = dashboardResource;\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelSlice(panels)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n ...createDiscardChangesDialogSlice(...args),\n metadata,\n defaultTimeRange: { pastDuration: duration },\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean) => set({ isEditMode }),\n setDashboard: ({ metadata, spec: { panels, layouts } }) => {\n set((state) => {\n state.metadata = metadata;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panels = panels;\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStore","devtools","immer","shallow","createContext","useCallback","useContext","useState","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","createDiscardChangesDialogSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","Provider","value","children","initialState","dashboardResource","isEditMode","spec","layouts","panels","duration","metadata","args","set","defaultTimeRange","pastDuration","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"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,WAAW,EAAEC,QAAQ,QAAQ,SAAS,CAAC;AAEhD,SAASC,QAAQ,QAAQ,oBAAoB,CAAC;AAC9C,SAASC,KAAK,QAAQ,0BAA0B,CAAC;AACjD,OAAOC,OAAO,MAAM,iBAAiB,CAAC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AAM,CAAC;oBACtBS,KAAK,CAACC,WAAW,GAAGA,WAAW,CAAC;oBAChCD,KAAK,CAACE,eAAe,GAAGA,eAAe,CAAC;gBAC1C,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CACH,CACF,AAAC;IAEF,OAAOzB,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"sourcesContent":["// Copyright 2023 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 { createStore, useStore } from 'zustand';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport shallow from 'zustand/shallow';\nimport { createContext, ReactNode, useCallback, useContext, useEffect, useState } from 'react';\nimport { DashboardResource, Display, ProjectMetadata, RelativeTimeRange } from '@perses-dev/core';\nimport { usePlugin, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { convertLayoutsToPanelGroups, createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\nimport { createPanelSlice, PanelSlice } from './panel-slice';\nimport { createDeletePanelGroupSlice, DeletePanelGroupSlice } from './delete-panel-group-slice';\nimport { createDeletePanelSlice, DeletePanelSlice } from './delete-panel-slice';\nimport { createDiscardChangesDialogSlice, DiscardChangesConfirmationDialogSlice } from './discard-changes-dialog-slice';\nimport { createDuplicatePanelSlice, DuplicatePanelSlice } from './duplicate-panel-slice';\n\nexport interface DashboardStoreState\n extends PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice,\n DiscardChangesConfirmationDialogSlice,\n DuplicatePanelSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n defaultTimeRange: RelativeTimeRange;\n setDashboard: (dashboard: DashboardResource) => void;\n metadata: ProjectMetadata;\n display?: Display;\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource;\n isEditMode?: boolean;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: ReactNode;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T) {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStore(store, selector, shallow);\n}\n\nexport function DashboardProvider(props: DashboardProviderProps) {\n const createDashboardStore = useCallback(initStore, [props]);\n\n // load plugin to retrieve initial spec if default panel kind is defined\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';\n const { data: plugin } = usePlugin('Panel', defaultPanelKind);\n\n const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders\n\n useEffect(() => {\n if (plugin === undefined) return;\n const spec = plugin.createInitialOptions();\n // set default panel kind and spec for add panel editor\n store.setState({ initialValues: { kind: defaultPanelKind, spec } });\n }, [plugin, store, defaultPanelKind]);\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps) {\n const {\n initialState: { dashboardResource, isEditMode },\n } = props;\n\n const {\n spec: { display, layouts, panels, duration },\n metadata,\n } = dashboardResource;\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelSlice(panels)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n ...createDiscardChangesDialogSlice(...args),\n ...createDuplicatePanelSlice()(...args),\n metadata,\n display,\n defaultTimeRange: { pastDuration: duration },\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean) => set({ isEditMode }),\n setDashboard: ({ metadata, spec: { display, panels, layouts } }) => {\n set((state) => {\n state.metadata = metadata;\n state.display = display;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panels = panels;\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStore","devtools","immer","shallow","createContext","useCallback","useContext","useEffect","useState","usePlugin","usePluginRegistry","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","createDiscardChangesDialogSlice","createDuplicatePanelSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","defaultPluginKinds","defaultPanelKind","data","plugin","spec","createInitialOptions","setState","initialValues","kind","Provider","value","children","initialState","dashboardResource","isEditMode","display","layouts","panels","duration","metadata","args","set","defaultTimeRange","pastDuration","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"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,WAAW,EAAEC,QAAQ,QAAQ,SAAS,CAAC;AAEhD,SAASC,QAAQ,QAAQ,oBAAoB,CAAC;AAC9C,SAASC,KAAK,QAAQ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CAAC,CACH,CACF,AAAC;IAEF,OAAOlC,KAAK,CAAC;AACf,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/common.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\n/**\n * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).\n */\nexport type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];\n\ndeclare global {\n // eslint-disable-next-line no-var\n var dashboardStoreId: number;\n}\n\n/**\n * Helper function to generate unique IDs for things in the dashboard store that don't have a \"natural\" ID.\n */\nexport function generateId() {\n if (globalThis.dashboardStoreId === undefined) {\n globalThis.dashboardStoreId = 0;\n }\n return globalThis.dashboardStoreId++;\n}\n"],"names":["generateId","globalThis","dashboardStoreId","undefined"],"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;;CAEC,GACD,AAOA;;CAEC,GACD,OAAO,SAASA,UAAU,GAAG;IAC3B,IAAIC,UAAU,CAACC,gBAAgB,KAAKC,SAAS,EAAE;QAC7CF,UAAU,CAACC,gBAAgB,GAAG,CAAC,CAAC;IAClC,CAAC;IACD,OAAOD,UAAU,CAACC,gBAAgB,EAAE,CAAC;AACvC,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/common.ts"],"sourcesContent":["// Copyright 2023 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\n/**\n * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).\n */\nexport type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];\n\ndeclare global {\n // eslint-disable-next-line no-var\n var dashboardStoreId: number;\n}\n\n/**\n * Helper function to generate unique IDs for things in the dashboard store that don't have a \"natural\" ID.\n */\nexport function generateId() {\n if (globalThis.dashboardStoreId === undefined) {\n globalThis.dashboardStoreId = 0;\n }\n return globalThis.dashboardStoreId++;\n}\n"],"names":["generateId","globalThis","dashboardStoreId","undefined"],"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;;CAEC,GACD,AAOA;;CAEC,GACD,OAAO,SAASA,UAAU,GAAG;IAC3B,IAAIC,UAAU,CAACC,gBAAgB,KAAKC,SAAS,EAAE;QAC7CF,UAAU,CAACC,gBAAgB,GAAG,CAAC,CAAC;IAClC,CAAC;IACD,OAAOD,UAAU,CAACC,gBAAgB,EAAE,CAAC;AACvC,CAAC"}
@@ -57,6 +57,7 @@ export declare function usePanel(panelGroupItemId: PanelGroupItemId): import("@p
57
57
  export declare function usePanelActions(panelGroupItemId: PanelGroupItemId): {
58
58
  openEditPanel: () => void;
59
59
  openDeletePanelDialog: () => void;
60
+ duplicatePanel: () => void;
60
61
  };
61
62
  /**
62
63
  * Gets the state for the Panel Editor.
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard-provider-api.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3F,wBAAgB,WAAW;;;EAE1B;AAOD;;GAEG;AACH,wBAAgB,mBAAmB;;;;EAOlC;AAGD;;GAEG;AACH,wBAAgB,gBAAgB,aAE/B;AAGD;;GAEG;AACH,wBAAgB,kBAAkB,yDAYjC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,YAAY,sDAMvD;AAaD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY;;;;;;2CAWpB,oBAAoB,EAAE;EAGhE;AA4BD;;GAEG;AACH,wBAAgB,mBAAmB,sEAElC;AAaD;;GAEG;AACH,wBAAgB,yBAAyB;;;;;EASxC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,sFAiB1D;AAMD;;GAEG;AACH,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,gBAAgB;;;EAMjE;AAGD;;GAEG;AACH,wBAAgB,cAAc,gEAE7B;AAQD;;GAEG;AACH,wBAAgB,oBAAoB;;;;EAGnC;AAGD,wBAAgB,mBAAmB,iDAElC;AAWD,wBAAgB,mCAAmC;;;;EAElD"}
1
+ {"version":3,"file":"dashboard-provider-api.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3F,wBAAgB,WAAW;;;EAE1B;AAOD;;GAEG;AACH,wBAAgB,mBAAmB;;;;EAOlC;AAGD;;GAEG;AACH,wBAAgB,gBAAgB,aAE/B;AAGD;;GAEG;AACH,wBAAgB,kBAAkB,yDAYjC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,YAAY,sDAMvD;AAaD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY;;;;;;2CAWpB,oBAAoB,EAAE;EAGhE;AA4BD;;GAEG;AACH,wBAAgB,mBAAmB,sEAElC;AAaD;;GAEG;AACH,wBAAgB,yBAAyB;;;;;EASxC;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,sFAiB1D;AAQD;;GAEG;AACH,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,gBAAgB;;;;EAOjE;AAGD;;GAEG;AACH,wBAAgB,cAAc,gEAE7B;AAQD;;GAEG;AACH,wBAAgB,oBAAoB;;;;EAGnC;AAGD,wBAAgB,mBAAmB,iDAElC;AAWD,wBAAgB,mCAAmC;;;;EAElD"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -152,17 +152,19 @@ const selectDeletePanelGroupDialog = ({ deletePanelGroupDialog , openDeletePanel
152
152
  }
153
153
  return panel;
154
154
  }
155
- const selectPanelActions = ({ openEditPanel , openDeletePanelDialog })=>({
155
+ const selectPanelActions = ({ openEditPanel , openDeletePanelDialog , duplicatePanel })=>({
156
156
  openEditPanel,
157
- openDeletePanelDialog
157
+ openDeletePanelDialog,
158
+ duplicatePanel
158
159
  });
159
160
  /**
160
161
  * Returns actions that can be performed on the given Panel.
161
162
  */ export function usePanelActions(panelGroupItemId) {
162
- const { openEditPanel , openDeletePanelDialog } = useDashboardStore(selectPanelActions);
163
+ const { openEditPanel , openDeletePanelDialog , duplicatePanel } = useDashboardStore(selectPanelActions);
163
164
  return {
164
165
  openEditPanel: ()=>openEditPanel(panelGroupItemId),
165
- openDeletePanelDialog: ()=>openDeletePanelDialog(panelGroupItemId)
166
+ openDeletePanelDialog: ()=>openDeletePanelDialog(panelGroupItemId),
167
+ duplicatePanel: ()=>duplicatePanel(panelGroupItemId)
166
168
  };
167
169
  }
168
170
  const selectPanelEditor = (state)=>state.panelEditor;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/dashboard-provider-api.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\nimport { useCallback, useMemo } from 'react';\nimport { DashboardStoreState, useDashboardStore } from './DashboardProvider';\nimport { PanelGroupItemId, PanelGroupId, PanelGroupItemLayout } from './panel-group-slice';\n\nconst selectEditMode = ({ isEditMode, setEditMode }: DashboardStoreState) => ({ isEditMode, setEditMode });\nexport function useEditMode() {\n return useDashboardStore(selectEditMode);\n}\n\nconst selectDashboardActions = ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => ({\n setDashboard,\n openAddPanelGroup,\n openAddPanel,\n});\n/**\n * Returns actions that can be performed on the current dashboard.\n */\nexport function useDashboardActions() {\n const { setDashboard, openAddPanelGroup, openAddPanel } = useDashboardStore(selectDashboardActions);\n return {\n setDashboard,\n openAddPanelGroup: () => openAddPanelGroup(),\n openAddPanel: () => openAddPanel(),\n };\n}\n\nconst selectPanelGroupOrder = (state: DashboardStoreState) => state.panelGroupOrder;\n/**\n * Returns an array of PanelGroupIds in the order they appear in the dashboard.\n */\nexport function usePanelGroupIds() {\n return useDashboardStore(selectPanelGroupOrder);\n}\n\nconst selectPanelGroups = (state: DashboardStoreState) => state.panelGroups;\n/**\n * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.\n */\nexport function useListPanelGroups() {\n const panelGroupIds = usePanelGroupIds();\n const panelGroups = useDashboardStore(selectPanelGroups);\n return useMemo(() => {\n return panelGroupIds.map((id) => {\n const group = panelGroups[id];\n if (group === undefined) {\n throw new Error(`Invalid panel group Id found ${id}`);\n }\n return group;\n });\n }, [panelGroupIds, panelGroups]);\n}\n\n/**\n * Gets a specific panel group by its id. Throws if the panel group does not exist.\n */\nexport function usePanelGroup(panelGroupId: PanelGroupId) {\n const panelGroup = useDashboardStore(useCallback((state) => state.panelGroups[panelGroupId], [panelGroupId]));\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} was not found`);\n }\n return panelGroup;\n}\n\nconst selectPanelGroupActions = ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n}: DashboardStoreState) => ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n});\n/**\n * Returns actions that can be performed on the given panel group.\n */\nexport function usePanelGroupActions(panelGroupId: PanelGroupId) {\n const { moveUp, moveDown } = useMovePanelGroup(panelGroupId);\n const { openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts } =\n useDashboardStore(selectPanelGroupActions);\n\n return {\n openEditPanelGroup: () => openEditPanelGroup(panelGroupId),\n deletePanelGroup: () => deletePanelGroup(panelGroupId),\n openAddPanel: () => openAddPanel(panelGroupId),\n moveUp,\n moveDown,\n updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) =>\n updatePanelGroupLayouts(panelGroupId, itemLayouts),\n };\n}\n\nconst selectSwapPanelGroups = (state: DashboardStoreState) => state.swapPanelGroups;\nconst selectPanelGroupsLength = (state: DashboardStoreState) => state.panelGroupOrder.length;\n/**\n * Returns functions for moving a panel group up or down. A function will be undefined if the panel group can't be\n * moved in that direction.\n */\nfunction useMovePanelGroup(panelGroupId: PanelGroupId) {\n const currentIndex = useDashboardStore(\n useCallback((store) => store.panelGroupOrder.findIndex((id) => id === panelGroupId), [panelGroupId])\n );\n const panelGroupsLength = useDashboardStore(selectPanelGroupsLength);\n const swapPanelGroups = useDashboardStore(selectSwapPanelGroups);\n\n if (currentIndex < 0) {\n throw new Error(`Could not find panel group with Id ${panelGroupId} in order array`);\n }\n\n const moveUp = () => swapPanelGroups(currentIndex, currentIndex - 1);\n const moveDown = () => swapPanelGroups(currentIndex, currentIndex + 1);\n return {\n moveUp: currentIndex > 0 ? moveUp : undefined,\n moveDown: currentIndex < panelGroupsLength - 1 ? moveDown : undefined,\n };\n}\n\nconst selectPanelGroupEditor = (state: DashboardStoreState) => state.panelGroupEditor;\n/**\n * Gets the Panel Group editor state.\n */\nexport function usePanelGroupEditor() {\n return useDashboardStore(selectPanelGroupEditor);\n}\n\nconst selectDeletePanelGroupDialog = ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n});\n/**\n * Gets the Delete Panel Group dialog state.\n */\nexport function useDeletePanelGroupDialog() {\n const { deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } =\n useDashboardStore(selectDeletePanelGroupDialog);\n return {\n deletePanelGroupDialog,\n deletePanelGroup,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog: () => closeDeletePanelGroupDialog(),\n };\n}\n\n/**\n * Gets an individual panel in the store. Throws if the panel can't be found.\n */\nexport function usePanel(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panel = useDashboardStore(\n useCallback(\n (store) => {\n const panelKey = store.panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) return;\n return store.panels[panelKey];\n },\n [panelGroupId, panelGroupLayoutId]\n )\n );\n\n if (panel === undefined) {\n throw new Error(`Could not find panel for Id ${panelGroupItemId}`);\n }\n return panel;\n}\n\nconst selectPanelActions = ({ openEditPanel, openDeletePanelDialog }: DashboardStoreState) => ({\n openEditPanel,\n openDeletePanelDialog,\n});\n/**\n * Returns actions that can be performed on the given Panel.\n */\nexport function usePanelActions(panelGroupItemId: PanelGroupItemId) {\n const { openEditPanel, openDeletePanelDialog } = useDashboardStore(selectPanelActions);\n return {\n openEditPanel: () => openEditPanel(panelGroupItemId),\n openDeletePanelDialog: () => openDeletePanelDialog(panelGroupItemId),\n };\n}\n\nconst selectPanelEditor = (state: DashboardStoreState) => state.panelEditor;\n/**\n * Gets the state for the Panel Editor.\n */\nexport function usePanelEditor() {\n return useDashboardStore(selectPanelEditor);\n}\n\nconst selectDeletePanelDialog = ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => ({\n deletePanelDialog,\n deletePanel,\n closeDeletePanelDialog,\n});\n\n/**\n * Gets the state for the Delete Panel dialog.\n */\nexport function useDeletePanelDialog() {\n // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself\n return useDashboardStore(selectDeletePanelDialog);\n}\n\nconst selectDefaultTimeRange = (state: DashboardStoreState) => state.defaultTimeRange;\nexport function useDefaultTimeRange() {\n return useDashboardStore(selectDefaultTimeRange);\n}\n\nconst selectDiscardChangesConfirmationDialog = ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n});\nexport function useDiscardChangesConfirmationDialog() {\n return useDashboardStore(selectDiscardChangesConfirmationDialog);\n}\n"],"names":["useCallback","useMemo","useDashboardStore","selectEditMode","isEditMode","setEditMode","useEditMode","selectDashboardActions","setDashboard","openAddPanelGroup","openAddPanel","useDashboardActions","selectPanelGroupOrder","state","panelGroupOrder","usePanelGroupIds","selectPanelGroups","panelGroups","useListPanelGroups","panelGroupIds","map","id","group","undefined","Error","usePanelGroup","panelGroupId","panelGroup","selectPanelGroupActions","openEditPanelGroup","deletePanelGroup","updatePanelGroupLayouts","usePanelGroupActions","moveUp","moveDown","useMovePanelGroup","itemLayouts","selectSwapPanelGroups","swapPanelGroups","selectPanelGroupsLength","length","currentIndex","store","findIndex","panelGroupsLength","selectPanelGroupEditor","panelGroupEditor","usePanelGroupEditor","selectDeletePanelGroupDialog","deletePanelGroupDialog","openDeletePanelGroupDialog","closeDeletePanelGroupDialog","useDeletePanelGroupDialog","usePanel","panelGroupItemId","panelGroupItemLayoutId","panelGroupLayoutId","panel","panelKey","itemPanelKeys","panels","selectPanelActions","openEditPanel","openDeletePanelDialog","usePanelActions","selectPanelEditor","panelEditor","usePanelEditor","selectDeletePanelDialog","deletePanelDialog","deletePanel","closeDeletePanelDialog","useDeletePanelDialog","selectDefaultTimeRange","defaultTimeRange","useDefaultTimeRange","selectDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog"],"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,SAASA,WAAW,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAC7C,SAA8BC,iBAAiB,QAAQ,qBAAqB,CAAC;AAG7E,MAAMC,cAAc,GAAG,CAAC,EAAEC,UAAU,CAAA,EAAEC,WAAW,CAAA,EAAuB,GAAM,CAAA;QAAED,UAAU;QAAEC,WAAW;KAAE,CAAA,AAAC,AAAC;AAC3G,OAAO,SAASC,WAAW,GA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AC;AACtF,OAAO,SAASC,mBAAmB,GAAG;IACpC,OAAOzE,iBAAiB,CAACuE,sBAAsB,CAAC,CAAC;AACnD,CAAC;AAED,MAAMG,sCAAsC,GAAG,CAAC,EAC9CC,gCAAgC,CAAA,EAChCC,oCAAoC,CAAA,EACpCC,qCAAqC,CAAA,EACjB,GAAM,CAAA;QAC1BF,gCAAgC;QAChCC,oCAAoC;QACpCC,qCAAqC;KACtC,CAAA,AAAC,AAAC;AACH,OAAO,SAASC,mCAAmC,GAAG;IACpD,OAAO9E,iBAAiB,CAAC0E,sCAAsC,CAAC,CAAC;AACnE,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"sourcesContent":["// Copyright 2023 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 { useCallback, useMemo } from 'react';\nimport { DashboardStoreState, useDashboardStore } from './DashboardProvider';\nimport { PanelGroupItemId, PanelGroupId, PanelGroupItemLayout } from './panel-group-slice';\n\nconst selectEditMode = ({ isEditMode, setEditMode }: DashboardStoreState) => ({ isEditMode, setEditMode });\nexport function useEditMode() {\n return useDashboardStore(selectEditMode);\n}\n\nconst selectDashboardActions = ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => ({\n setDashboard,\n openAddPanelGroup,\n openAddPanel,\n});\n/**\n * Returns actions that can be performed on the current dashboard.\n */\nexport function useDashboardActions() {\n const { setDashboard, openAddPanelGroup, openAddPanel } = useDashboardStore(selectDashboardActions);\n return {\n setDashboard,\n openAddPanelGroup: () => openAddPanelGroup(),\n openAddPanel: () => openAddPanel(),\n };\n}\n\nconst selectPanelGroupOrder = (state: DashboardStoreState) => state.panelGroupOrder;\n/**\n * Returns an array of PanelGroupIds in the order they appear in the dashboard.\n */\nexport function usePanelGroupIds() {\n return useDashboardStore(selectPanelGroupOrder);\n}\n\nconst selectPanelGroups = (state: DashboardStoreState) => state.panelGroups;\n/**\n * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.\n */\nexport function useListPanelGroups() {\n const panelGroupIds = usePanelGroupIds();\n const panelGroups = useDashboardStore(selectPanelGroups);\n return useMemo(() => {\n return panelGroupIds.map((id) => {\n const group = panelGroups[id];\n if (group === undefined) {\n throw new Error(`Invalid panel group Id found ${id}`);\n }\n return group;\n });\n }, [panelGroupIds, panelGroups]);\n}\n\n/**\n * Gets a specific panel group by its id. Throws if the panel group does not exist.\n */\nexport function usePanelGroup(panelGroupId: PanelGroupId) {\n const panelGroup = useDashboardStore(useCallback((state) => state.panelGroups[panelGroupId], [panelGroupId]));\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} was not found`);\n }\n return panelGroup;\n}\n\nconst selectPanelGroupActions = ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n}: DashboardStoreState) => ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n});\n/**\n * Returns actions that can be performed on the given panel group.\n */\nexport function usePanelGroupActions(panelGroupId: PanelGroupId) {\n const { moveUp, moveDown } = useMovePanelGroup(panelGroupId);\n const { openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts } =\n useDashboardStore(selectPanelGroupActions);\n\n return {\n openEditPanelGroup: () => openEditPanelGroup(panelGroupId),\n deletePanelGroup: () => deletePanelGroup(panelGroupId),\n openAddPanel: () => openAddPanel(panelGroupId),\n moveUp,\n moveDown,\n updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) =>\n updatePanelGroupLayouts(panelGroupId, itemLayouts),\n };\n}\n\nconst selectSwapPanelGroups = (state: DashboardStoreState) => state.swapPanelGroups;\nconst selectPanelGroupsLength = (state: DashboardStoreState) => state.panelGroupOrder.length;\n/**\n * Returns functions for moving a panel group up or down. A function will be undefined if the panel group can't be\n * moved in that direction.\n */\nfunction useMovePanelGroup(panelGroupId: PanelGroupId) {\n const currentIndex = useDashboardStore(\n useCallback((store) => store.panelGroupOrder.findIndex((id) => id === panelGroupId), [panelGroupId])\n );\n const panelGroupsLength = useDashboardStore(selectPanelGroupsLength);\n const swapPanelGroups = useDashboardStore(selectSwapPanelGroups);\n\n if (currentIndex < 0) {\n throw new Error(`Could not find panel group with Id ${panelGroupId} in order array`);\n }\n\n const moveUp = () => swapPanelGroups(currentIndex, currentIndex - 1);\n const moveDown = () => swapPanelGroups(currentIndex, currentIndex + 1);\n return {\n moveUp: currentIndex > 0 ? moveUp : undefined,\n moveDown: currentIndex < panelGroupsLength - 1 ? moveDown : undefined,\n };\n}\n\nconst selectPanelGroupEditor = (state: DashboardStoreState) => state.panelGroupEditor;\n/**\n * Gets the Panel Group editor state.\n */\nexport function usePanelGroupEditor() {\n return useDashboardStore(selectPanelGroupEditor);\n}\n\nconst selectDeletePanelGroupDialog = ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n});\n/**\n * Gets the Delete Panel Group dialog state.\n */\nexport function useDeletePanelGroupDialog() {\n const { deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } =\n useDashboardStore(selectDeletePanelGroupDialog);\n return {\n deletePanelGroupDialog,\n deletePanelGroup,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog: () => closeDeletePanelGroupDialog(),\n };\n}\n\n/**\n * Gets an individual panel in the store. Throws if the panel can't be found.\n */\nexport function usePanel(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panel = useDashboardStore(\n useCallback(\n (store) => {\n const panelKey = store.panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) return;\n return store.panels[panelKey];\n },\n [panelGroupId, panelGroupLayoutId]\n )\n );\n\n if (panel === undefined) {\n throw new Error(`Could not find panel for Id ${panelGroupItemId}`);\n }\n return panel;\n}\n\nconst selectPanelActions = ({ openEditPanel, openDeletePanelDialog, duplicatePanel }: DashboardStoreState) => ({\n openEditPanel,\n openDeletePanelDialog,\n duplicatePanel,\n});\n\n/**\n * Returns actions that can be performed on the given Panel.\n */\nexport function usePanelActions(panelGroupItemId: PanelGroupItemId) {\n const { openEditPanel, openDeletePanelDialog, duplicatePanel } = useDashboardStore(selectPanelActions);\n return {\n openEditPanel: () => openEditPanel(panelGroupItemId),\n openDeletePanelDialog: () => openDeletePanelDialog(panelGroupItemId),\n duplicatePanel: () => duplicatePanel(panelGroupItemId),\n };\n}\n\nconst selectPanelEditor = (state: DashboardStoreState) => state.panelEditor;\n/**\n * Gets the state for the Panel Editor.\n */\nexport function usePanelEditor() {\n return useDashboardStore(selectPanelEditor);\n}\n\nconst selectDeletePanelDialog = ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => ({\n deletePanelDialog,\n deletePanel,\n closeDeletePanelDialog,\n});\n\n/**\n * Gets the state for the Delete Panel dialog.\n */\nexport function useDeletePanelDialog() {\n // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself\n return useDashboardStore(selectDeletePanelDialog);\n}\n\nconst selectDefaultTimeRange = (state: DashboardStoreState) => state.defaultTimeRange;\nexport function useDefaultTimeRange() {\n return useDashboardStore(selectDefaultTimeRange);\n}\n\nconst selectDiscardChangesConfirmationDialog = ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n});\nexport function useDiscardChangesConfirmationDialog() {\n return useDashboardStore(selectDiscardChangesConfirmationDialog);\n}\n"],"names":["useCallback","useMemo","useDashboardStore","selectEditMode","isEditMode","setEditMode","useEditMode","selectDashboardActions","setDashboard","openAddPanelGroup","openAddPanel","useDashboardActions","selectPanelGroupOrder","state","panelGroupOrder","usePanelGroupIds","selectPanelGroups","panelGroups","useListPanelGroups","panelGroupIds","map","id","group","undefined","Error","usePanelGroup","panelGroupId","panelGroup","selectPanelGroupActions","openEditPanelGroup","deletePanelGroup","updatePanelGroupLayouts","usePanelGroupActions","moveUp","moveDown","useMovePanelGroup","itemLayouts","selectSwapPanelGroups","swapPanelGroups","selectPanelGroupsLength","length","currentIndex","store","findIndex","panelGroupsLength","selectPanelGroupEditor","panelGroupEditor","usePanelGroupEditor","selectDeletePanelGroupDialog","deletePanelGroupDialog","openDeletePanelGroupDialog","closeDeletePanelGroupDialog","useDeletePanelGroupDialog","usePanel","panelGroupItemId","panelGroupItemLayoutId","panelGroupLayoutId","panel","panelKey","itemPanelKeys","panels","selectPanelActions","openEditPanel","openDeletePanelDialog","duplicatePanel","usePanelActions","selectPanelEditor","panelEditor","usePanelEditor","selectDeletePanelDialog","deletePanelDialog","deletePanel","closeDeletePanelDialog","useDeletePanelDialog","selectDefaultTimeRange","defaultTimeRange","useDefaultTimeRange","selectDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog"],"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,SAASA,WAAW,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAC7C,SAA8BC,iBAAiB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sB,CAAA,EAAuB,GAAM,CAAA;QACpHF,iBAAiB;QACjBC,WAAW;QACXC,sBAAsB;KACvB,CAAA,AAAC,AAAC;AAEH;;CAEC,GACD,OAAO,SAASC,oBAAoB,GAAG;IACrC,0FAA0F;IAC1F,OAAOvE,iBAAiB,CAACmE,uBAAuB,CAAC,CAAC;AACpD,CAAC;AAED,MAAMK,sBAAsB,GAAG,CAAC7D,KAA0B,GAAKA,KAAK,CAAC8D,gBAAgB,AAAC;AACtF,OAAO,SAASC,mBAAmB,GAAG;IACpC,OAAO1E,iBAAiB,CAACwE,sBAAsB,CAAC,CAAC;AACnD,CAAC;AAED,MAAMG,sCAAsC,GAAG,CAAC,EAC9CC,gCAAgC,CAAA,EAChCC,oCAAoC,CAAA,EACpCC,qCAAqC,CAAA,EACjB,GAAM,CAAA;QAC1BF,gCAAgC;QAChCC,oCAAoC;QACpCC,qCAAqC;KACtC,CAAA,AAAC,AAAC;AACH,OAAO,SAASC,mCAAmC,GAAG;IACpD,OAAO/E,iBAAiB,CAAC2E,sCAAsC,CAAC,CAAC;AACnE,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-group-slice.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\nimport { StateCreator } from 'zustand';\nimport { Middleware } from './common';\nimport { PanelGroupId, PanelGroupSlice } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and related actions for deleting a Panel Group.\n */\nexport interface DeletePanelGroupSlice {\n deletePanelGroupDialog?: DeletePanelGroupDialogState;\n\n /**\n * Delete panel group and all the panels within the group\n */\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n closeDeletePanelGroupDialog: () => void;\n}\n\nexport interface DeletePanelGroupDialogState {\n panelGroupId: PanelGroupId;\n panelGroupName?: string;\n}\n\nexport const createDeletePanelGroupSlice: StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelGroupSlice & PanelGroupSlice & PanelSlice,\n Middleware,\n [],\n DeletePanelGroupSlice\n> = (set, get) => ({\n deletePanelGroup(panelGroupId) {\n const { panelGroups, panelGroupOrder } = get();\n const group = panelGroups[panelGroupId];\n const idIndex = panelGroupOrder.findIndex((id) => id === panelGroupId);\n if (group === undefined || idIndex === -1) {\n throw new Error(`Panel group ${panelGroupId} not found`);\n }\n\n // Get the panel keys for all the panel items in the group we're going to delete\n const panelKeys = Object.values(group.itemPanelKeys);\n\n set((draft) => {\n // Delete the panel group which also deletes all its items\n delete draft.panelGroups[panelGroupId];\n draft.panelGroupOrder.splice(idIndex, 1);\n\n // Get all remaining panel keys in use\n const usedPanelKeys = getUsedPanelKeys(draft.panelGroups);\n\n // For the panel keys of the items that were just deleted, see if they're still used and if not, also delete the\n // panel definition\n for (const panelKey of panelKeys) {\n if (usedPanelKeys.has(panelKey)) continue;\n\n delete draft.panels[panelKey];\n }\n });\n },\n\n openDeletePanelGroupDialog: (panelGroupId) => {\n const panelGroup = get().panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} not found`);\n }\n set((state) => {\n state.deletePanelGroupDialog = { panelGroupId, panelGroupName: panelGroup.title };\n });\n },\n\n closeDeletePanelGroupDialog: () =>\n set((state) => {\n state.deletePanelGroupDialog = undefined;\n }),\n});\n\n// Helper to get the panel keys of all groups, returning a set to eliminate duplicates\nfunction getUsedPanelKeys(panelGroups: PanelGroupSlice['panelGroups']): Set<string> {\n const usedPanelKeys = new Set<string>();\n for (const group of Object.values(panelGroups)) {\n for (const panelKey of Object.values(group.itemPanelKeys)) {\n usedPanelKeys.add(panelKey);\n }\n }\n return usedPanelKeys;\n}\n"],"names":["createDeletePanelGroupSlice","set","get","deletePanelGroup","panelGroupId","panelGroups","panelGroupOrder","group","idIndex","findIndex","id","undefined","Error","panelKeys","Object","values","itemPanelKeys","draft","splice","usedPanelKeys","getUsedPanelKeys","panelKey","has","panels","openDeletePanelGroupDialog","panelGroup","state","deletePanelGroupDialog","panelGroupName","title","closeDeletePanelGroupDialog","Set","add"],"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;AA2BjC,OAAO,MAAMA,2BAA2B,GAMpC,CAACC,GAAG,EAAEC,GAAG,GAAM,CAAA;QACjBC,gBAAgB,EAACC,YAAY,EAAE;YAC7B,MAAM,EAAEC,WAAW,CAAA,EAAEC,eAAe,CAAA,EAAE,GAAGJ,GAAG,EAAE,AAAC;YAC/C,MAAMK,KAAK,GAAGF,WAAW,CAACD,YAAY,CAAC,AAAC;YACxC,MAAMI,OAAO,GAAGF,eAAe,CAACG,SAAS,CAAC,CAACC,EAAE,GAAKA,EAAE,KAAKN,YAAY,CAAC,AAAC;YACvE,IAAIG,KAAK,KAAKI,SAAS,IAAIH,OAAO,KAAK,CAAC,CAAC,EAAE;gBACzC,MAAM,IAAII,KAAK,CAAC,CAAC,YAAY,EAAER,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;YAC3D,CAAC;YAED,gFAAgF;YAChF,MAAMS,SAAS,GAA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ClF,MAAMc,aAAa,GAAG,IAAIY,GAAG,EAAU,AAAC;IACxC,KAAK,MAAMxB,KAAK,IAAIO,MAAM,CAACC,MAAM,CAACV,WAAW,CAAC,CAAE;QAC9C,KAAK,MAAMgB,QAAQ,IAAIP,MAAM,CAACC,MAAM,CAACR,KAAK,CAACS,aAAa,CAAC,CAAE;YACzDG,aAAa,CAACa,GAAG,CAACX,QAAQ,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAOF,aAAa,CAAC;AACvB,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-group-slice.ts"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\nimport { PanelGroupId, PanelGroupSlice } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and related actions for deleting a Panel Group.\n */\nexport interface DeletePanelGroupSlice {\n deletePanelGroupDialog?: DeletePanelGroupDialogState;\n\n /**\n * Delete panel group and all the panels within the group\n */\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n closeDeletePanelGroupDialog: () => void;\n}\n\nexport interface DeletePanelGroupDialogState {\n panelGroupId: PanelGroupId;\n panelGroupName?: string;\n}\n\nexport const createDeletePanelGroupSlice: StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelGroupSlice & PanelGroupSlice & PanelSlice,\n Middleware,\n [],\n DeletePanelGroupSlice\n> = (set, get) => ({\n deletePanelGroup(panelGroupId) {\n const { panelGroups, panelGroupOrder } = get();\n const group = panelGroups[panelGroupId];\n const idIndex = panelGroupOrder.findIndex((id) => id === panelGroupId);\n if (group === undefined || idIndex === -1) {\n throw new Error(`Panel group ${panelGroupId} not found`);\n }\n\n // Get the panel keys for all the panel items in the group we're going to delete\n const panelKeys = Object.values(group.itemPanelKeys);\n\n set((draft) => {\n // Delete the panel group which also deletes all its items\n delete draft.panelGroups[panelGroupId];\n draft.panelGroupOrder.splice(idIndex, 1);\n\n // Get all remaining panel keys in use\n const usedPanelKeys = getUsedPanelKeys(draft.panelGroups);\n\n // For the panel keys of the items that were just deleted, see if they're still used and if not, also delete the\n // panel definition\n for (const panelKey of panelKeys) {\n if (usedPanelKeys.has(panelKey)) continue;\n\n delete draft.panels[panelKey];\n }\n });\n },\n\n openDeletePanelGroupDialog: (panelGroupId) => {\n const panelGroup = get().panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} not found`);\n }\n set((state) => {\n state.deletePanelGroupDialog = { panelGroupId, panelGroupName: panelGroup.title };\n });\n },\n\n closeDeletePanelGroupDialog: () =>\n set((state) => {\n state.deletePanelGroupDialog = undefined;\n }),\n});\n\n// Helper to get the panel keys of all groups, returning a set to eliminate duplicates\nfunction getUsedPanelKeys(panelGroups: PanelGroupSlice['panelGroups']): Set<string> {\n const usedPanelKeys = new Set<string>();\n for (const group of Object.values(panelGroups)) {\n for (const panelKey of Object.values(group.itemPanelKeys)) {\n usedPanelKeys.add(panelKey);\n }\n }\n return usedPanelKeys;\n}\n"],"names":["createDeletePanelGroupSlice","set","get","deletePanelGroup","panelGroupId","panelGroups","panelGroupOrder","group","idIndex","findIndex","id","undefined","Error","panelKeys","Object","values","itemPanelKeys","draft","splice","usedPanelKeys","getUsedPanelKeys","panelKey","has","panels","openDeletePanelGroupDialog","panelGroup","state","deletePanelGroupDialog","panelGroupName","title","closeDeletePanelGroupDialog","Set","add"],"mappings":"AAAA,oCAAo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,QAAQ,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAEDG,0BAA0B,EAAE,CAACpB,YAAY,GAAK;YAC5C,MAAMqB,UAAU,GAAGvB,GAAG,EAAE,CAACG,WAAW,CAACD,YAAY,CAAC,AAAC;YACnD,IAAIqB,UAAU,KAAKd,SAAS,EAAE;gBAC5B,MAAM,IAAIC,KAAK,CAAC,CAAC,oBAAoB,EAAER,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;YACnE,CAAC;YACDH,GAAG,CAAC,CAACyB,KAAK,GAAK;gBACbA,KAAK,CAACC,sBAAsB,GAAG;oBAAEvB,YAAY;oBAAEwB,cAAc,EAAEH,UAAU,CAACI,KAAK;iBAAE,CAAC;YACpF,CAAC,CAAC,CAAC;QACL,CAAC;QAEDC,2BAA2B,EAAE,IAC3B7B,GAAG,CAAC,CAACyB,KAAK,GAAK;gBACbA,KAAK,CAACC,sBAAsB,GAAGhB,SAAS,CAAC;YAC3C,CAAC,CAAC;KACL,CAAA,AAAC,CAAC;AAEH,sFAAsF;AACtF,SAASS,gBAAgB,CAACf,WAA2C,EAAe;IAClF,MAAMc,aAAa,GAAG,IAAIY,GAAG,EAAU,AAAC;IACxC,KAAK,MAAMxB,KAAK,IAAIO,MAAM,CAACC,MAAM,CAACV,WAAW,CAAC,CAAE;QAC9C,KAAK,MAAMgB,QAAQ,IAAIP,MAAM,CAACC,MAAM,CAACR,KAAK,CAACS,aAAa,CAAC,CAAE;YACzDG,aAAa,CAACa,GAAG,CAACX,QAAQ,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAOF,aAAa,CAAC;AACvB,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-slice.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\nimport { StateCreator } from 'zustand';\nimport { Middleware } from './common';\nimport { PanelGroupSlice, PanelGroupItemId } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for deleting Panels.\n */\nexport interface DeletePanelSlice {\n /**\n * Delete panels\n */\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * State for the delete panel dialog when it's open, otherwise undefined when it's closed.\n */\n deletePanelDialog?: DeletePanelDialogState;\n\n /**\n * Open delete panel dialog\n */\n openDeletePanelDialog: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Close delete panel dialog\n */\n closeDeletePanelDialog: () => void;\n}\n\nexport interface DeletePanelDialogState {\n panelGroupItemId: PanelGroupItemId;\n panelName: string;\n panelGroupName: string;\n}\n\n/**\n * Curried function for creating the PanelDeleteSlice.\n */\nexport function createDeletePanelSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n DeletePanelSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n deletePanel(panelGroupItemId: PanelGroupItemId) {\n set((draft) => {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const existingGroup = draft.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // remove panel from panel group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // See if panel key is still used and if not, delete it\n if (isPanelKeyStillUsed(draft.panelGroups, existingPanelKey) === false) {\n delete draft.panels[existingPanelKey];\n }\n });\n },\n\n openDeletePanelDialog(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n\n const { panels, panelGroups } = get();\n const panelGroup = panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group not found ${panelGroupId}`);\n }\n\n const panelKey = panelGroup.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupLayoutId}`);\n }\n\n const panel = panels[panelKey];\n if (panel === undefined) {\n throw new Error(`Could not find panel ${panelKey}`);\n }\n\n set((state) => {\n state.deletePanelDialog = {\n panelGroupItemId: panelGroupItemId,\n panelName: panel.spec.display.name,\n panelGroupName: panelGroup.title ?? '',\n };\n });\n },\n\n closeDeletePanelDialog() {\n set((state) => {\n state.deletePanelDialog = undefined;\n });\n },\n });\n}\n\n// Helper function to determine if a panel key is still being used somewhere in Panel Groups\nfunction isPanelKeyStillUsed(panelGroups: PanelGroupSlice['panelGroups'], panelKey: string) {\n for (const group of Object.values(panelGroups)) {\n const found = Object.values(group.itemPanelKeys).find((key) => key === panelKey);\n if (found !== undefined) {\n return true;\n }\n }\n return false;\n}\n"],"names":["createDeletePanelSlice","set","get","deletePanel","panelGroupItemId","draft","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","existingGroup","panelGroups","undefined","Error","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingPanelKey","itemPanelKeys","splice","isPanelKeyStillUsed","panels","openDeletePanelDialog","panelGroup","panelKey","panel","state","deletePanelDialog","panelName","spec","display","name","panelGroupName","title","closeDeletePanelDialog","group","Object","values","found","find","key"],"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;AAsCjC;;CAEC,GACD,OAAO,SAASA,sBAAsB,GAMpC;IACA,gGAAgG;IAChG,OAAO,CAACC,GAAG,EAAEC,GAAG,GAAM,CAAA;YACpBC,WAAW,EAACC,gBAAkC,EAAE;gBAC9CH,GAAG,CAAC,CAACI,KAAK,GAAK;oBACb,MAAM,EAAEC,YAAY,CAAA,EAAEC,sBAAsB,EAAEC,kBAAkB,CAAA,EAAE,GAAGJ,gBAAgB,AAAC;oBACtF,MAAMK,aAAa,GAAGJ,KAAK,CAACK,WAAW,CAACJ,YAAY,CAAC,AAAC;oBACtD,IAAIG,aAAa,KAAKE,SAAS,EAAE;wBAC/B,MAAM,IAAIC,KAAK,CAAC,CAAC,oBAAoB,EAAEN,YAAY,CAAC,CAAC,CAAC,CAAC;oBACzD,CAAC;oBACD,MAAMO,iBAAiB,GAAGJ,aAAa,CAACK,WAAW,CAACC,SAAS,CAAC,CAACC,MAAM,GAAKA,MAAM,CAACC,CAAC,KAAKT,kBAAkB,CAAC,AAAC;oBAC3G,MAAMU,gBAAgB,GAAGT,aAAa,CAACU,aAAa,CAACX,kBAAkB,CAAC,AAAC;oBACzE,IAAIK,iBAAiB,KAAK,CAAC,CAAC,IAAIK,gBAAgB,KAAKP,SAAS,EAAE;wBAC9D,MAAM,IAAIC,KAAK,CAAC,CAAC,yBAAyB,EAAEJ,kBAAkB,CAAC,CAAC,CAAC,CAAC;oBACpE,CAAC;oBAED,gCAAgC;oBAChCC,aAAa,CAACK,WAAW,CAACM,MAAM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,CAACC,iBAAiB,GAAG;wBACxBxB,gBAAgB,EAAEA,gBAAgB;wBAClCyB,SAAS,EAAEH,KAAK,CAACI,IAAI,CAACC,OAAO,CAACC,IAAI;wBAClCC,cAAc,EAAET,CAAAA,MAAgB,GAAhBA,UAAU,CAACU,KAAK,cAAhBV,MAAgB,cAAhBA,MAAgB,GAAI,EAAE;qBACvC,CAAC;gBACJ,CAAC,CAAC,CAAC;YACL,CAAC;YAEDW,sBAAsB,IAAG;gBACvBlC,GAAG,CAAC,CAAC0B,KAAK,GAAK;oBACbA,KAAK,CAACC,iBAAiB,GAAGjB,SAAS,CAAC;gBACtC,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAA,AAAC,CAAC;AACL,CAAC;AAED,4FAA4F;AAC5F,SAASU,mBAAmB,CAACX,WAA2C,EAAEe,QAAgB,EAAE;IAC1F,KAAK,MAAMW,KAAK,IAAIC,MAAM,CAACC,MAAM,CAAC5B,WAAW,CAAC,CAAE;QAC9C,MAAM6B,KAAK,GAAGF,MAAM,CAACC,MAAM,CAACF,KAAK,CAACjB,aAAa,CAAC,CAACqB,IAAI,CAAC,CAACC,GAAG,GAAKA,GAAG,KAAKhB,QAAQ,CAAC,AAAC;QACjF,IAAIc,KAAK,KAAK5B,SAAS,EAAE;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-slice.ts"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\nimport { PanelGroupSlice, PanelGroupItemId } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for deleting Panels.\n */\nexport interface DeletePanelSlice {\n /**\n * Delete panels\n */\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * State for the delete panel dialog when it's open, otherwise undefined when it's closed.\n */\n deletePanelDialog?: DeletePanelDialogState;\n\n /**\n * Open delete panel dialog\n */\n openDeletePanelDialog: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Close delete panel dialog\n */\n closeDeletePanelDialog: () => void;\n}\n\nexport interface DeletePanelDialogState {\n panelGroupItemId: PanelGroupItemId;\n panelName: string;\n panelGroupName: string;\n}\n\n/**\n * Curried function for creating the PanelDeleteSlice.\n */\nexport function createDeletePanelSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n DeletePanelSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n deletePanel(panelGroupItemId: PanelGroupItemId) {\n set((draft) => {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const existingGroup = draft.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // remove panel from panel group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // See if panel key is still used and if not, delete it\n if (isPanelKeyStillUsed(draft.panelGroups, existingPanelKey) === false) {\n delete draft.panels[existingPanelKey];\n }\n });\n },\n\n openDeletePanelDialog(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n\n const { panels, panelGroups } = get();\n const panelGroup = panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group not found ${panelGroupId}`);\n }\n\n const panelKey = panelGroup.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupLayoutId}`);\n }\n\n const panel = panels[panelKey];\n if (panel === undefined) {\n throw new Error(`Could not find panel ${panelKey}`);\n }\n\n set((state) => {\n state.deletePanelDialog = {\n panelGroupItemId: panelGroupItemId,\n panelName: panel.spec.display.name,\n panelGroupName: panelGroup.title ?? '',\n };\n });\n },\n\n closeDeletePanelDialog() {\n set((state) => {\n state.deletePanelDialog = undefined;\n });\n },\n });\n}\n\n// Helper function to determine if a panel key is still being used somewhere in Panel Groups\nfunction isPanelKeyStillUsed(panelGroups: PanelGroupSlice['panelGroups'], panelKey: string) {\n for (const group of Object.values(panelGroups)) {\n const found = Object.values(group.itemPanelKeys).find((key) => key === panelKey);\n if (found !== undefined) {\n return true;\n }\n }\n return false;\n}\n"],"names":["createDeletePanelSlice","set","get","deletePanel","panelGroupItemId","draft","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","existingGroup","panelGroups","undefined","Error","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingPanelKey","itemPanelKeys","splice","isPanelKeyStillUsed","panels","openDeletePanelDialog","panelGroup","panelKey","panel","state","deletePanelDialog","panelName","spec","display","name","panelGroupName","title","closeDeletePanelDialog","group","Object","values","found","find","key"],"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;AAsCjC;;CAEC,GACD,OAAO,SAAS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AAK;oBACbA,KAAK,CAACC,iBAAiB,GAAGjB,SAAS,CAAC;gBACtC,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAA,AAAC,CAAC;AACL,CAAC;AAED,4FAA4F;AAC5F,SAASU,mBAAmB,CAACX,WAA2C,EAAEe,QAAgB,EAAE;IAC1F,KAAK,MAAMW,KAAK,IAAIC,MAAM,CAACC,MAAM,CAAC5B,WAAW,CAAC,CAAE;QAC9C,MAAM6B,KAAK,GAAGF,MAAM,CAACC,MAAM,CAACF,KAAK,CAACjB,aAAa,CAAC,CAACqB,IAAI,CAAC,CAACC,GAAG,GAAKA,GAAG,KAAKhB,QAAQ,CAAC,AAAC;QACjF,IAAIc,KAAK,KAAK5B,SAAS,EAAE;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/discard-changes-dialog-slice.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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\n\nexport interface DiscardChangesConfirmationDialogSlice {\n discardChangesConfirmationDialog?: DiscardChangesConfirmationDialogState;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n closeDiscardChangesConfirmationDialog: () => void;\n}\n\nexport interface DiscardChangesConfirmationDialogState {\n onDiscardChanges: () => void;\n onCancel: () => void;\n description?: string;\n}\n\nexport const createDiscardChangesDialogSlice: StateCreator<\n DiscardChangesConfirmationDialogSlice,\n Middleware,\n [],\n DiscardChangesConfirmationDialogSlice\n> = (set) => ({\n isOpen: false,\n\n openDiscardChangesConfirmationDialog(dialog) {\n set((state) => {\n state.discardChangesConfirmationDialog = dialog;\n });\n },\n\n closeDiscardChangesConfirmationDialog() {\n set((state) => {\n state.discardChangesConfirmationDialog = undefined;\n });\n },\n});\n"],"names":["createDiscardChangesDialogSlice","set","isOpen","openDiscardChangesConfirmationDialog","dialog","state","discardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","undefined"],"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;AAmBjC,OAAO,MAAMA,+BAA+B,GAKxC,CAACC,GAAG,GAAM,CAAA;QACZC,MAAM,EAAE,KAAK;QAEbC,oCAAoC,EAACC,MAAM,EAAE;YAC3CH,GAAG,CAAC,CAACI,KAAK,GAAK;gBACbA,KAAK,CAACC,gCAAgC,GAAGF,MAAM,CAAC;YAClD,CAAC,CAAC,CAAC;QACL,CAAC;QAEDG,qCAAqC,IAAG;YACtCN,GAAG,CAAC,CAACI,KAAK,GAAK;gBACbA,KAAK,CAACC,gCAAgC,GAAGE,SAAS,CAAC;YACrD,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAA,AAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/discard-changes-dialog-slice.tsx"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\n\nexport interface DiscardChangesConfirmationDialogSlice {\n discardChangesConfirmationDialog?: DiscardChangesConfirmationDialogState;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n closeDiscardChangesConfirmationDialog: () => void;\n}\n\nexport interface DiscardChangesConfirmationDialogState {\n onDiscardChanges: () => void;\n onCancel: () => void;\n description?: string;\n}\n\nexport const createDiscardChangesDialogSlice: StateCreator<\n DiscardChangesConfirmationDialogSlice,\n Middleware,\n [],\n DiscardChangesConfirmationDialogSlice\n> = (set) => ({\n isOpen: false,\n\n openDiscardChangesConfirmationDialog(dialog) {\n set((state) => {\n state.discardChangesConfirmationDialog = dialog;\n });\n },\n\n closeDiscardChangesConfirmationDialog() {\n set((state) => {\n state.discardChangesConfirmationDialog = undefined;\n });\n },\n});\n"],"names":["createDiscardChangesDialogSlice","set","isOpen","openDiscardChangesConfirmationDialog","dialog","state","discardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","undefined"],"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;AAmBjC,OAAO,MAAMA,+BAA+B,GAKxC,CAACC,GAAG,GAAM,CAAA;QACZC,MAAM,EAAE,KAAK;QAEbC,oCAAoC,EAACC,MAAM,EAAE;YAC3CH,GAAG,CAAC,CAACI,KAAK,GAAK;gBACbA,KAAK,CAACC,gCAAgC,GAAGF,MAAM,CAAC;YAClD,CAAC,CAAC,CAAC;QACL,CAAC;QAEDG,qCAAqC,IAAG;YACtCN,GAAG,CAAC,CAACI,KAAK,GAAK;gBACbA,KAAK,CAACC,gCAAgC,GAAGE,SAAS,CAAC;YACrD,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAA,AAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { StateCreator } from 'zustand';
2
+ import { Middleware } from './common';
3
+ import { PanelGroupSlice, PanelGroupItemId } from './panel-group-slice';
4
+ import { PanelSlice } from './panel-slice';
5
+ /**
6
+ * Slice that handles duplicating Panels.
7
+ */
8
+ export interface DuplicatePanelSlice {
9
+ /**
10
+ * Duplicate panel.
11
+ */
12
+ duplicatePanel: (panelGroupItemId: PanelGroupItemId) => void;
13
+ }
14
+ /**
15
+ * Curried function for duplicating a panel.
16
+ */
17
+ export declare function createDuplicatePanelSlice(): StateCreator<DuplicatePanelSlice & PanelSlice & PanelGroupSlice, Middleware, [
18
+ ], DuplicatePanelSlice>;
19
+ //# sourceMappingURL=duplicate-panel-slice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duplicate-panel-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/duplicate-panel-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,cAAc,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC9D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,YAAY,CAEvD,mBAAmB,GAAG,UAAU,GAAG,eAAe,EAClD,UAAU,EACV;CAAE,EACF,mBAAmB,CACpB,CAgDA"}