@perses-dev/dashboards 0.0.0-snapshot-time-range-height-80d08fc

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 (372) hide show
  1. package/LICENSE +201 -0
  2. package/dist/cjs/components/Dashboard/Dashboard.js +37 -0
  3. package/dist/cjs/components/Dashboard/index.js +28 -0
  4. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +176 -0
  5. package/dist/cjs/components/DashboardToolbar/index.js +28 -0
  6. package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +92 -0
  7. package/dist/cjs/components/DeletePanelDialog/index.js +28 -0
  8. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +88 -0
  9. package/dist/cjs/components/DeletePanelGroupDialog/index.js +28 -0
  10. package/dist/cjs/components/DownloadButton/DownloadButton.js +109 -0
  11. package/dist/cjs/components/DownloadButton/index.js +28 -0
  12. package/dist/cjs/components/GridLayout/GridContainer.js +219 -0
  13. package/dist/cjs/components/GridLayout/GridItemContent.js +41 -0
  14. package/dist/cjs/components/GridLayout/GridLayout.js +104 -0
  15. package/dist/cjs/components/GridLayout/GridTitle.js +100 -0
  16. package/dist/cjs/components/GridLayout/index.js +29 -0
  17. package/dist/cjs/components/Panel/Panel.js +123 -0
  18. package/dist/cjs/components/Panel/Panel.test.js +129 -0
  19. package/dist/cjs/components/Panel/PanelContent.js +44 -0
  20. package/dist/cjs/components/Panel/PanelHeader.js +120 -0
  21. package/dist/cjs/components/Panel/index.js +28 -0
  22. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +98 -0
  23. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +131 -0
  24. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +202 -0
  25. package/dist/cjs/components/PanelDrawer/PanelPreview.js +47 -0
  26. package/dist/cjs/components/PanelDrawer/index.js +28 -0
  27. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +101 -0
  28. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +87 -0
  29. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
  30. package/dist/cjs/components/PanelGroupDialog/index.js +28 -0
  31. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +136 -0
  32. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +95 -0
  33. package/dist/cjs/components/TimeRangeControls/index.js +28 -0
  34. package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +67 -0
  35. package/dist/cjs/components/UnsavedChangesConfirmationDialog/index.js +28 -0
  36. package/dist/cjs/components/Variables/Variable.js +194 -0
  37. package/dist/cjs/components/Variables/VariableEditor.js +276 -0
  38. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +459 -0
  39. package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
  40. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +89 -0
  41. package/dist/cjs/components/Variables/VariableList.js +150 -0
  42. package/dist/cjs/components/Variables/index.js +30 -0
  43. package/dist/cjs/components/Variables/variable-model.js +117 -0
  44. package/dist/cjs/components/Variables/variable-model.test.js +106 -0
  45. package/dist/cjs/components/index.js +39 -0
  46. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +95 -0
  47. package/dist/cjs/context/DashboardProvider/common.js +28 -0
  48. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +191 -0
  49. package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +70 -0
  50. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +85 -0
  51. package/dist/cjs/context/DashboardProvider/index.js +29 -0
  52. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +205 -0
  53. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +85 -0
  54. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +113 -0
  55. package/dist/cjs/context/DashboardProvider/panel-slice.js +25 -0
  56. package/dist/cjs/context/DatasourceStoreProvider.js +170 -0
  57. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +228 -0
  58. package/dist/cjs/context/TemplateVariableProvider/index.js +28 -0
  59. package/dist/cjs/context/TemplateVariableProvider/query-params.js +81 -0
  60. package/dist/cjs/context/TemplateVariableProvider/query-params.test.js +82 -0
  61. package/dist/cjs/context/index.js +31 -0
  62. package/dist/cjs/context/useDashboard.js +94 -0
  63. package/dist/cjs/index.js +30 -0
  64. package/dist/cjs/test/dashboard-provider.js +51 -0
  65. package/dist/cjs/test/index.js +30 -0
  66. package/dist/cjs/test/plugin-registry.js +42 -0
  67. package/dist/cjs/test/render.js +62 -0
  68. package/dist/cjs/test/setup-tests.js +23 -0
  69. package/dist/cjs/test/testDashboard.js +293 -0
  70. package/dist/cjs/utils/functions.js +23 -0
  71. package/dist/cjs/views/ViewDashboard/DashboardApp.js +96 -0
  72. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +68 -0
  73. package/dist/cjs/views/ViewDashboard/index.js +28 -0
  74. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +110 -0
  75. package/dist/cjs/views/index.js +28 -0
  76. package/dist/components/Dashboard/Dashboard.d.ts +8 -0
  77. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -0
  78. package/dist/components/Dashboard/Dashboard.js +33 -0
  79. package/dist/components/Dashboard/Dashboard.js.map +1 -0
  80. package/dist/components/Dashboard/index.d.ts +2 -0
  81. package/dist/components/Dashboard/index.d.ts.map +1 -0
  82. package/dist/components/Dashboard/index.js +15 -0
  83. package/dist/components/Dashboard/index.js.map +1 -0
  84. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +11 -0
  85. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -0
  86. package/dist/components/DashboardToolbar/DashboardToolbar.js +165 -0
  87. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -0
  88. package/dist/components/DashboardToolbar/index.d.ts +2 -0
  89. package/dist/components/DashboardToolbar/index.d.ts.map +1 -0
  90. package/dist/components/DashboardToolbar/index.js +15 -0
  91. package/dist/components/DashboardToolbar/index.js.map +1 -0
  92. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +3 -0
  93. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -0
  94. package/dist/components/DeletePanelDialog/DeletePanelDialog.js +81 -0
  95. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -0
  96. package/dist/components/DeletePanelDialog/index.d.ts +2 -0
  97. package/dist/components/DeletePanelDialog/index.d.ts.map +1 -0
  98. package/dist/components/DeletePanelDialog/index.js +15 -0
  99. package/dist/components/DeletePanelDialog/index.js.map +1 -0
  100. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts +3 -0
  101. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
  102. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +77 -0
  103. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
  104. package/dist/components/DeletePanelGroupDialog/index.d.ts +2 -0
  105. package/dist/components/DeletePanelGroupDialog/index.d.ts.map +1 -0
  106. package/dist/components/DeletePanelGroupDialog/index.js +15 -0
  107. package/dist/components/DeletePanelGroupDialog/index.js.map +1 -0
  108. package/dist/components/DownloadButton/DownloadButton.d.ts +3 -0
  109. package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -0
  110. package/dist/components/DownloadButton/DownloadButton.js +60 -0
  111. package/dist/components/DownloadButton/DownloadButton.js.map +1 -0
  112. package/dist/components/DownloadButton/index.d.ts +2 -0
  113. package/dist/components/DownloadButton/index.d.ts.map +1 -0
  114. package/dist/components/DownloadButton/index.js +15 -0
  115. package/dist/components/DownloadButton/index.js.map +1 -0
  116. package/dist/components/GridLayout/GridContainer.d.ts +6 -0
  117. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -0
  118. package/dist/components/GridLayout/GridContainer.js +213 -0
  119. package/dist/components/GridLayout/GridContainer.js.map +1 -0
  120. package/dist/components/GridLayout/GridItemContent.d.ts +10 -0
  121. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -0
  122. package/dist/components/GridLayout/GridItemContent.js +37 -0
  123. package/dist/components/GridLayout/GridItemContent.js.map +1 -0
  124. package/dist/components/GridLayout/GridLayout.d.ts +10 -0
  125. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -0
  126. package/dist/components/GridLayout/GridLayout.js +100 -0
  127. package/dist/components/GridLayout/GridLayout.js.map +1 -0
  128. package/dist/components/GridLayout/GridTitle.d.ts +16 -0
  129. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -0
  130. package/dist/components/GridLayout/GridTitle.js +92 -0
  131. package/dist/components/GridLayout/GridTitle.js.map +1 -0
  132. package/dist/components/GridLayout/index.d.ts +3 -0
  133. package/dist/components/GridLayout/index.d.ts.map +1 -0
  134. package/dist/components/GridLayout/index.js +16 -0
  135. package/dist/components/GridLayout/index.js.map +1 -0
  136. package/dist/components/Panel/Panel.d.ts +13 -0
  137. package/dist/components/Panel/Panel.d.ts.map +1 -0
  138. package/dist/components/Panel/Panel.js +114 -0
  139. package/dist/components/Panel/Panel.js.map +1 -0
  140. package/dist/components/Panel/Panel.test.d.ts +2 -0
  141. package/dist/components/Panel/Panel.test.d.ts.map +1 -0
  142. package/dist/components/Panel/Panel.test.js +122 -0
  143. package/dist/components/Panel/Panel.test.js.map +1 -0
  144. package/dist/components/Panel/PanelContent.d.ts +12 -0
  145. package/dist/components/Panel/PanelContent.d.ts.map +1 -0
  146. package/dist/components/Panel/PanelContent.js +41 -0
  147. package/dist/components/Panel/PanelContent.js.map +1 -0
  148. package/dist/components/Panel/PanelHeader.d.ts +16 -0
  149. package/dist/components/Panel/PanelHeader.d.ts.map +1 -0
  150. package/dist/components/Panel/PanelHeader.js +109 -0
  151. package/dist/components/Panel/PanelHeader.js.map +1 -0
  152. package/dist/components/Panel/index.d.ts +2 -0
  153. package/dist/components/Panel/index.d.ts.map +1 -0
  154. package/dist/components/Panel/index.js +15 -0
  155. package/dist/components/Panel/index.js.map +1 -0
  156. package/dist/components/PanelDrawer/PanelDrawer.d.ts +6 -0
  157. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -0
  158. package/dist/components/PanelDrawer/PanelDrawer.js +94 -0
  159. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -0
  160. package/dist/components/PanelDrawer/PanelDrawer.test.d.ts +2 -0
  161. package/dist/components/PanelDrawer/PanelDrawer.test.d.ts.map +1 -0
  162. package/dist/components/PanelDrawer/PanelDrawer.test.js +124 -0
  163. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -0
  164. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +12 -0
  165. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -0
  166. package/dist/components/PanelDrawer/PanelEditorForm.js +192 -0
  167. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -0
  168. package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
  169. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
  170. package/dist/components/PanelDrawer/PanelPreview.js +41 -0
  171. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
  172. package/dist/components/PanelDrawer/index.d.ts +2 -0
  173. package/dist/components/PanelDrawer/index.d.ts.map +1 -0
  174. package/dist/components/PanelDrawer/index.js +15 -0
  175. package/dist/components/PanelDrawer/index.js.map +1 -0
  176. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +6 -0
  177. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -0
  178. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +92 -0
  179. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
  180. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts +2 -0
  181. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts.map +1 -0
  182. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +80 -0
  183. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -0
  184. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
  185. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
  186. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
  187. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
  188. package/dist/components/PanelGroupDialog/index.d.ts +2 -0
  189. package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
  190. package/dist/components/PanelGroupDialog/index.js +15 -0
  191. package/dist/components/PanelGroupDialog/index.js.map +1 -0
  192. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +9 -0
  193. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
  194. package/dist/components/TimeRangeControls/TimeRangeControls.js +119 -0
  195. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
  196. package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts +2 -0
  197. package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts.map +1 -0
  198. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +88 -0
  199. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -0
  200. package/dist/components/TimeRangeControls/index.d.ts +2 -0
  201. package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
  202. package/dist/components/TimeRangeControls/index.js +15 -0
  203. package/dist/components/TimeRangeControls/index.js.map +1 -0
  204. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +8 -0
  205. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +1 -0
  206. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +56 -0
  207. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +1 -0
  208. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +2 -0
  209. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +1 -0
  210. package/dist/components/UnsavedChangesConfirmationDialog/index.js +15 -0
  211. package/dist/components/UnsavedChangesConfirmationDialog/index.js.map +1 -0
  212. package/dist/components/Variables/Variable.d.ts +8 -0
  213. package/dist/components/Variables/Variable.d.ts.map +1 -0
  214. package/dist/components/Variables/Variable.js +188 -0
  215. package/dist/components/Variables/Variable.js.map +1 -0
  216. package/dist/components/Variables/VariableEditor.d.ts +8 -0
  217. package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
  218. package/dist/components/Variables/VariableEditor.js +265 -0
  219. package/dist/components/Variables/VariableEditor.js.map +1 -0
  220. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
  221. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
  222. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +409 -0
  223. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
  224. package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
  225. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
  226. package/dist/components/Variables/VariableEditorForm/index.js +15 -0
  227. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
  228. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +22 -0
  229. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
  230. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +77 -0
  231. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
  232. package/dist/components/Variables/VariableList.d.ts +9 -0
  233. package/dist/components/Variables/VariableList.d.ts.map +1 -0
  234. package/dist/components/Variables/VariableList.js +100 -0
  235. package/dist/components/Variables/VariableList.js.map +1 -0
  236. package/dist/components/Variables/index.d.ts +4 -0
  237. package/dist/components/Variables/index.d.ts.map +1 -0
  238. package/dist/components/Variables/index.js +17 -0
  239. package/dist/components/Variables/index.js.map +1 -0
  240. package/dist/components/Variables/variable-model.d.ts +16 -0
  241. package/dist/components/Variables/variable-model.d.ts.map +1 -0
  242. package/dist/components/Variables/variable-model.js +105 -0
  243. package/dist/components/Variables/variable-model.js.map +1 -0
  244. package/dist/components/Variables/variable-model.test.d.ts +2 -0
  245. package/dist/components/Variables/variable-model.test.d.ts.map +1 -0
  246. package/dist/components/Variables/variable-model.test.js +104 -0
  247. package/dist/components/Variables/variable-model.test.js.map +1 -0
  248. package/dist/components/index.d.ts +13 -0
  249. package/dist/components/index.d.ts.map +1 -0
  250. package/dist/components/index.js +26 -0
  251. package/dist/components/index.js.map +1 -0
  252. package/dist/context/DashboardProvider/DashboardProvider.d.ts +28 -0
  253. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
  254. package/dist/context/DashboardProvider/DashboardProvider.js +77 -0
  255. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
  256. package/dist/context/DashboardProvider/common.d.ts +12 -0
  257. package/dist/context/DashboardProvider/common.d.ts.map +1 -0
  258. package/dist/context/DashboardProvider/common.js +24 -0
  259. package/dist/context/DashboardProvider/common.js.map +1 -0
  260. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +74 -0
  261. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
  262. package/dist/context/DashboardProvider/dashboard-provider-api.js +190 -0
  263. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
  264. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +23 -0
  265. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts.map +1 -0
  266. package/dist/context/DashboardProvider/delete-panel-group-slice.js +64 -0
  267. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -0
  268. package/dist/context/DashboardProvider/delete-panel-slice.d.ts +36 -0
  269. package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -0
  270. package/dist/context/DashboardProvider/delete-panel-slice.js +81 -0
  271. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -0
  272. package/dist/context/DashboardProvider/index.d.ts +7 -0
  273. package/dist/context/DashboardProvider/index.d.ts.map +1 -0
  274. package/dist/context/DashboardProvider/index.js +16 -0
  275. package/dist/context/DashboardProvider/index.js.map +1 -0
  276. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +56 -0
  277. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
  278. package/dist/context/DashboardProvider/panel-editor-slice.js +201 -0
  279. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
  280. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +33 -0
  281. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
  282. package/dist/context/DashboardProvider/panel-group-editor-slice.js +79 -0
  283. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
  284. package/dist/context/DashboardProvider/panel-group-slice.d.ts +59 -0
  285. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
  286. package/dist/context/DashboardProvider/panel-group-slice.js +105 -0
  287. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
  288. package/dist/context/DashboardProvider/panel-slice.d.ts +14 -0
  289. package/dist/context/DashboardProvider/panel-slice.d.ts.map +1 -0
  290. package/dist/context/DashboardProvider/panel-slice.js +21 -0
  291. package/dist/context/DashboardProvider/panel-slice.js.map +1 -0
  292. package/dist/context/DatasourceStoreProvider.d.ts +24 -0
  293. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -0
  294. package/dist/context/DatasourceStoreProvider.js +166 -0
  295. package/dist/context/DatasourceStoreProvider.js.map +1 -0
  296. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +30 -0
  297. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -0
  298. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +212 -0
  299. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -0
  300. package/dist/context/TemplateVariableProvider/index.d.ts +2 -0
  301. package/dist/context/TemplateVariableProvider/index.d.ts.map +1 -0
  302. package/dist/context/TemplateVariableProvider/index.js +15 -0
  303. package/dist/context/TemplateVariableProvider/index.js.map +1 -0
  304. package/dist/context/TemplateVariableProvider/query-params.d.ts +12 -0
  305. package/dist/context/TemplateVariableProvider/query-params.d.ts.map +1 -0
  306. package/dist/context/TemplateVariableProvider/query-params.js +66 -0
  307. package/dist/context/TemplateVariableProvider/query-params.js.map +1 -0
  308. package/dist/context/TemplateVariableProvider/query-params.test.d.ts +2 -0
  309. package/dist/context/TemplateVariableProvider/query-params.test.d.ts.map +1 -0
  310. package/dist/context/TemplateVariableProvider/query-params.test.js +80 -0
  311. package/dist/context/TemplateVariableProvider/query-params.test.js.map +1 -0
  312. package/dist/context/index.d.ts +5 -0
  313. package/dist/context/index.d.ts.map +1 -0
  314. package/dist/context/index.js +18 -0
  315. package/dist/context/index.js.map +1 -0
  316. package/dist/context/useDashboard.d.ts +6 -0
  317. package/dist/context/useDashboard.d.ts.map +1 -0
  318. package/dist/context/useDashboard.js +88 -0
  319. package/dist/context/useDashboard.js.map +1 -0
  320. package/dist/index.d.ts +4 -0
  321. package/dist/index.d.ts.map +1 -0
  322. package/dist/index.js +17 -0
  323. package/dist/index.js.map +1 -0
  324. package/dist/test/dashboard-provider.d.ts +19 -0
  325. package/dist/test/dashboard-provider.d.ts.map +1 -0
  326. package/dist/test/dashboard-provider.js +40 -0
  327. package/dist/test/dashboard-provider.js.map +1 -0
  328. package/dist/test/index.d.ts +4 -0
  329. package/dist/test/index.d.ts.map +1 -0
  330. package/dist/test/index.js +17 -0
  331. package/dist/test/index.js.map +1 -0
  332. package/dist/test/plugin-registry.d.ts +3 -0
  333. package/dist/test/plugin-registry.d.ts.map +1 -0
  334. package/dist/test/plugin-registry.js +37 -0
  335. package/dist/test/plugin-registry.js.map +1 -0
  336. package/dist/test/render.d.ts +8 -0
  337. package/dist/test/render.d.ts.map +1 -0
  338. package/dist/test/render.js +58 -0
  339. package/dist/test/render.js.map +1 -0
  340. package/dist/test/setup-tests.d.ts +2 -0
  341. package/dist/test/setup-tests.d.ts.map +1 -0
  342. package/dist/test/setup-tests.js +22 -0
  343. package/dist/test/setup-tests.js.map +1 -0
  344. package/dist/test/testDashboard.d.ts +4 -0
  345. package/dist/test/testDashboard.d.ts.map +1 -0
  346. package/dist/test/testDashboard.js +287 -0
  347. package/dist/test/testDashboard.js.map +1 -0
  348. package/dist/utils/functions.d.ts +2 -0
  349. package/dist/utils/functions.d.ts.map +1 -0
  350. package/dist/utils/functions.js +17 -0
  351. package/dist/utils/functions.js.map +1 -0
  352. package/dist/views/ViewDashboard/DashboardApp.d.ts +10 -0
  353. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -0
  354. package/dist/views/ViewDashboard/DashboardApp.js +90 -0
  355. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -0
  356. package/dist/views/ViewDashboard/ViewDashboard.d.ts +16 -0
  357. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -0
  358. package/dist/views/ViewDashboard/ViewDashboard.js +64 -0
  359. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -0
  360. package/dist/views/ViewDashboard/index.d.ts +2 -0
  361. package/dist/views/ViewDashboard/index.d.ts.map +1 -0
  362. package/dist/views/ViewDashboard/index.js +15 -0
  363. package/dist/views/ViewDashboard/index.js.map +1 -0
  364. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
  365. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
  366. package/dist/views/ViewDashboard/tests/panelGroups.test.js +103 -0
  367. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
  368. package/dist/views/index.d.ts +2 -0
  369. package/dist/views/index.d.ts.map +1 -0
  370. package/dist/views/index.js +15 -0
  371. package/dist/views/index.js.map +1 -0
  372. package/package.json +57 -0
@@ -0,0 +1,56 @@
1
+ import { UnknownSpec } from '@perses-dev/core';
2
+ import { StateCreator } from 'zustand';
3
+ import { Middleware } from './common';
4
+ import { PanelGroupSlice, PanelGroupItemId, PanelGroupId } from './panel-group-slice';
5
+ import { PanelSlice } from './panel-slice';
6
+ /**
7
+ * Slice that handles the visual editor state and actions for adding or editing Panels.
8
+ */
9
+ export interface PanelEditorSlice {
10
+ /**
11
+ * State for the panel editor when its open, otherwise undefined when it's closed.
12
+ */
13
+ panelEditor?: PanelEditorState;
14
+ /**
15
+ * Opens the editor for editing an existing panel by providing its layout coordinates.
16
+ */
17
+ openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;
18
+ /**
19
+ * Opens the editor for adding a new Panel to a panel group.
20
+ */
21
+ openAddPanel: (panelGroupId?: PanelGroupId) => void;
22
+ }
23
+ export interface PanelEditorState {
24
+ /**
25
+ * Whether we're adding a new panel, or editing an existing panel.
26
+ */
27
+ mode: 'Add' | 'Edit';
28
+ /**
29
+ * Initial values for the things that can be edited about a panel.
30
+ */
31
+ initialValues: PanelEditorValues;
32
+ /**
33
+ * Applies changes, but doesn't close the editor.
34
+ */
35
+ applyChanges: (next: PanelEditorValues) => void;
36
+ /**
37
+ * Close the editor.
38
+ */
39
+ close: () => void;
40
+ }
41
+ /**
42
+ * Panel values that can be edited in the panel editor.
43
+ */
44
+ export interface PanelEditorValues {
45
+ name: string;
46
+ description: string;
47
+ groupId: PanelGroupId;
48
+ kind: string;
49
+ spec: UnknownSpec;
50
+ }
51
+ /**
52
+ * Curried function for creating the PanelEditorSlice.
53
+ */
54
+ export declare function createPanelEditorSlice(): StateCreator<PanelEditorSlice & PanelSlice & PanelGroupSlice, Middleware, [
55
+ ], PanelEditorSlice>;
56
+ //# sourceMappingURL=panel-editor-slice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-editor-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAmB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAE/B;;OAEG;IACH,aAAa,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE5D;;OAEG;IACH,YAAY,EAAE,CAAC,YAAY,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IAErB;;OAEG;IACH,aAAa,EAAE,iBAAiB,CAAC;IAEjC;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAEhD;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CAEpD,gBAAgB,GAAG,UAAU,GAAG,eAAe,EAC/C,UAAU,EACV;CAAE,EACF,gBAAgB,CACjB,CAuJA"}
@@ -0,0 +1,201 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { removeWhiteSpacesAndSpecialCharacters } from '../../utils/functions';
14
+ import { generateId } from './common';
15
+ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
16
+ /**
17
+ * Curried function for creating the PanelEditorSlice.
18
+ */ export function createPanelEditorSlice() {
19
+ // Return the state creator function for Zustand that uses the panels provided as intitial state
20
+ return (set, get)=>{
21
+ return {
22
+ panelEditor: undefined,
23
+ openEditPanel (panelGroupItemId) {
24
+ var ref;
25
+ const { panels , panelGroups } = get();
26
+ // Figure out the panel key at that location
27
+ const { panelGroupId , panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
28
+ const panelKey = (ref = panelGroups[panelGroupId]) === null || ref === void 0 ? void 0 : ref.itemPanelKeys[panelGroupLayoutId];
29
+ if (panelKey === undefined) {
30
+ throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);
31
+ }
32
+ // Find the panel to edit
33
+ const panelToEdit = panels[panelKey];
34
+ if (panelToEdit === undefined) {
35
+ throw new Error(`Cannot find Panel with key '${panelKey}'`);
36
+ }
37
+ var _description;
38
+ const editorState = {
39
+ mode: 'Edit',
40
+ initialValues: {
41
+ name: panelToEdit.spec.display.name,
42
+ description: (_description = panelToEdit.spec.display.description) !== null && _description !== void 0 ? _description : '',
43
+ groupId: panelGroupItemId.panelGroupId,
44
+ kind: panelToEdit.spec.plugin.kind,
45
+ spec: panelToEdit.spec.plugin.spec
46
+ },
47
+ applyChanges: (next)=>{
48
+ const panelDefinititon = createPanelDefinitionFromEditorValues(next);
49
+ set((state)=>{
50
+ state.panels[panelKey] = panelDefinititon;
51
+ // If the panel didn't change groups, nothing else to do
52
+ if (next.groupId === panelGroupId) {
53
+ return;
54
+ }
55
+ // Move panel to the new group
56
+ const existingGroup = state.panelGroups[panelGroupId];
57
+ if (existingGroup === undefined) {
58
+ throw new Error(`Missing panel group ${panelGroupId}`);
59
+ }
60
+ const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout)=>layout.i === panelGroupLayoutId);
61
+ const existingLayout = existingGroup.itemLayouts[existingLayoutIdx];
62
+ const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];
63
+ if (existingLayoutIdx === -1 || existingLayout === undefined || existingPanelKey === undefined) {
64
+ throw new Error(`Missing panel group item ${panelGroupLayoutId}`);
65
+ }
66
+ // Remove item from the old group
67
+ existingGroup.itemLayouts.splice(existingLayoutIdx, 1);
68
+ delete existingGroup.itemPanelKeys[panelGroupLayoutId];
69
+ // Add item to the end of the new group
70
+ const newGroup = state.panelGroups[next.groupId];
71
+ if (newGroup === undefined) {
72
+ throw new Error(`Could not find new group ${next.groupId}`);
73
+ }
74
+ newGroup.itemLayouts.push({
75
+ i: existingLayout.i,
76
+ x: 0,
77
+ y: getYForNewRow(newGroup),
78
+ w: existingLayout.w,
79
+ h: existingLayout.h
80
+ });
81
+ newGroup.itemPanelKeys[existingLayout.i] = existingPanelKey;
82
+ });
83
+ },
84
+ close: ()=>{
85
+ set((state)=>{
86
+ state.panelEditor = undefined;
87
+ });
88
+ }
89
+ };
90
+ // Open the editor with the new state
91
+ set((state)=>{
92
+ state.panelEditor = editorState;
93
+ });
94
+ },
95
+ openAddPanel (panelGroupId) {
96
+ // If a panel group isn't supplied, add to the first group or create a group if there aren't any
97
+ let newGroup = undefined;
98
+ panelGroupId !== null && panelGroupId !== void 0 ? panelGroupId : panelGroupId = get().panelGroupOrder[0];
99
+ if (panelGroupId === undefined) {
100
+ newGroup = createEmptyPanelGroup();
101
+ newGroup.title = 'Panel Group';
102
+ panelGroupId = newGroup.id;
103
+ }
104
+ const editorState = {
105
+ mode: 'Add',
106
+ initialValues: {
107
+ name: '',
108
+ description: '',
109
+ groupId: panelGroupId,
110
+ kind: '',
111
+ spec: {}
112
+ },
113
+ applyChanges: (next)=>{
114
+ const panelDef = createPanelDefinitionFromEditorValues(next);
115
+ const uniquePanelKeys = getUniquePanelKeys(get().panels);
116
+ let panelKey = removeWhiteSpacesAndSpecialCharacters(next.name);
117
+ // append count if panel key already exists
118
+ if (uniquePanelKeys[panelKey]) {
119
+ panelKey += `-${uniquePanelKeys[panelKey]}`;
120
+ }
121
+ set((state)=>{
122
+ // Add a panel
123
+ state.panels[panelKey] = panelDef;
124
+ // Also add a panel group item referencing the panel
125
+ const group = state.panelGroups[next.groupId];
126
+ if (group === undefined) {
127
+ throw new Error(`Missing panel group ${next.groupId}`);
128
+ }
129
+ const layout = {
130
+ i: generateId().toString(),
131
+ x: 0,
132
+ y: getYForNewRow(group),
133
+ w: 12,
134
+ h: 6
135
+ };
136
+ group.itemLayouts.push(layout);
137
+ group.itemPanelKeys[layout.i] = panelKey;
138
+ });
139
+ },
140
+ close: ()=>{
141
+ set((state)=>{
142
+ state.panelEditor = undefined;
143
+ });
144
+ }
145
+ };
146
+ set((state)=>{
147
+ // Add the new panel group if one was created for the panel
148
+ if (newGroup !== undefined) {
149
+ addPanelGroup(state, newGroup);
150
+ }
151
+ // Open the editor with the new state
152
+ state.panelEditor = editorState;
153
+ });
154
+ }
155
+ };
156
+ };
157
+ }
158
+ // Helper to create PanelDefinitions when saving
159
+ function createPanelDefinitionFromEditorValues(editorValues) {
160
+ return {
161
+ kind: 'Panel',
162
+ spec: {
163
+ display: {
164
+ name: editorValues.name,
165
+ description: editorValues.description !== '' ? editorValues.description : undefined
166
+ },
167
+ plugin: {
168
+ kind: editorValues.kind,
169
+ spec: editorValues.spec
170
+ }
171
+ }
172
+ };
173
+ }
174
+ // Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present
175
+ function getYForNewRow(group) {
176
+ let newRowY = 0;
177
+ for (const layout of group.itemLayouts){
178
+ const itemMaxY = layout.y + layout.h;
179
+ if (itemMaxY > newRowY) {
180
+ newRowY = itemMaxY;
181
+ }
182
+ }
183
+ return newRowY;
184
+ }
185
+ // Find all the unique panel keys
186
+ // ex: cpu, cpu-1, cpu-2 count as the same panel key since these panels have the same name
187
+ function getUniquePanelKeys(panels) {
188
+ const uniquePanelKeys = {};
189
+ Object.keys(panels).forEach((panelKey)=>{
190
+ const key = panelKey.replace(/-([0-9]+)/, '');
191
+ const count = uniquePanelKeys[key];
192
+ if (count) {
193
+ uniquePanelKeys[key] = count + 1;
194
+ } else {
195
+ uniquePanelKeys[key] = 1;
196
+ }
197
+ });
198
+ return uniquePanelKeys;
199
+ }
200
+
201
+ //# sourceMappingURL=panel-editor-slice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/panel-editor-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 { PanelDefinition, UnknownSpec } from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { removeWhiteSpacesAndSpecialCharacters } from '../../utils/functions';\nimport { generateId, Middleware } from './common';\nimport {\n PanelGroupSlice,\n PanelGroupItemId,\n PanelGroupId,\n PanelGroupDefinition,\n PanelGroupItemLayout,\n addPanelGroup,\n createEmptyPanelGroup,\n} from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for adding or editing Panels.\n */\nexport interface PanelEditorSlice {\n /**\n * State for the panel editor when its open, otherwise undefined when it's closed.\n */\n panelEditor?: PanelEditorState;\n\n /**\n * Opens the editor for editing an existing panel by providing its layout coordinates.\n */\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Opens the editor for adding a new Panel to a panel group.\n */\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n}\n\nexport interface PanelEditorState {\n /**\n * Whether we're adding a new panel, or editing an existing panel.\n */\n mode: 'Add' | 'Edit';\n\n /**\n * Initial values for the things that can be edited about a panel.\n */\n initialValues: PanelEditorValues;\n\n /**\n * Applies changes, but doesn't close the editor.\n */\n applyChanges: (next: PanelEditorValues) => void;\n\n /**\n * Close the editor.\n */\n close: () => void;\n}\n\n/**\n * Panel values that can be edited in the panel editor.\n */\nexport interface PanelEditorValues {\n name: string;\n description: string;\n groupId: PanelGroupId;\n kind: string;\n spec: UnknownSpec;\n}\n\n/**\n * Curried function for creating the PanelEditorSlice.\n */\nexport function createPanelEditorSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n PanelEditorSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n PanelEditorSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n panelEditor: undefined,\n\n openEditPanel(panelGroupItemId) {\n const { panels, panelGroups } = get();\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panelKey = panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToEdit = panels[panelKey];\n if (panelToEdit === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n const editorState: PanelEditorState = {\n mode: 'Edit',\n initialValues: {\n name: panelToEdit.spec.display.name,\n description: panelToEdit.spec.display.description ?? '',\n groupId: panelGroupItemId.panelGroupId,\n kind: panelToEdit.spec.plugin.kind,\n spec: panelToEdit.spec.plugin.spec,\n },\n applyChanges: (next) => {\n const panelDefinititon = createPanelDefinitionFromEditorValues(next);\n set((state) => {\n state.panels[panelKey] = panelDefinititon;\n\n // If the panel didn't change groups, nothing else to do\n if (next.groupId === panelGroupId) {\n return;\n }\n\n // Move panel to the new group\n const existingGroup = state.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingLayout = existingGroup.itemLayouts[existingLayoutIdx];\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingLayout === undefined || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // Remove item from the old group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // Add item to the end of the new group\n const newGroup = state.panelGroups[next.groupId];\n if (newGroup === undefined) {\n throw new Error(`Could not find new group ${next.groupId}`);\n }\n\n newGroup.itemLayouts.push({\n i: existingLayout.i,\n x: 0,\n y: getYForNewRow(newGroup),\n w: existingLayout.w,\n h: existingLayout.h,\n });\n newGroup.itemPanelKeys[existingLayout.i] = existingPanelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n // Open the editor with the new state\n set((state) => {\n state.panelEditor = editorState;\n });\n },\n\n openAddPanel(panelGroupId) {\n // If a panel group isn't supplied, add to the first group or create a group if there aren't any\n let newGroup: PanelGroupDefinition | undefined = undefined;\n panelGroupId ??= get().panelGroupOrder[0];\n if (panelGroupId === undefined) {\n newGroup = createEmptyPanelGroup();\n newGroup.title = 'Panel Group';\n panelGroupId = newGroup.id;\n }\n\n const editorState: PanelEditorState = {\n mode: 'Add',\n initialValues: {\n name: '',\n description: '',\n groupId: panelGroupId,\n kind: '',\n spec: {},\n },\n applyChanges: (next) => {\n const panelDef = createPanelDefinitionFromEditorValues(next);\n const uniquePanelKeys = getUniquePanelKeys(get().panels);\n let panelKey = removeWhiteSpacesAndSpecialCharacters(next.name);\n // append count if panel key already exists\n if (uniquePanelKeys[panelKey]) {\n panelKey += `-${uniquePanelKeys[panelKey]}`;\n }\n set((state) => {\n // Add a panel\n state.panels[panelKey] = panelDef;\n\n // Also add a panel group item referencing the panel\n const group = state.panelGroups[next.groupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${next.groupId}`);\n }\n const layout: PanelGroupItemLayout = {\n i: generateId().toString(),\n x: 0,\n y: getYForNewRow(group),\n w: 12,\n h: 6,\n };\n group.itemLayouts.push(layout);\n group.itemPanelKeys[layout.i] = panelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n set((state) => {\n // Add the new panel group if one was created for the panel\n if (newGroup !== undefined) {\n addPanelGroup(state, newGroup);\n }\n\n // Open the editor with the new state\n state.panelEditor = editorState;\n });\n },\n });\n}\n\n// Helper to create PanelDefinitions when saving\nfunction createPanelDefinitionFromEditorValues(editorValues: PanelEditorValues): PanelDefinition {\n return {\n kind: 'Panel',\n spec: {\n display: {\n name: editorValues.name,\n description: editorValues.description !== '' ? editorValues.description : undefined,\n },\n plugin: {\n kind: editorValues.kind,\n spec: editorValues.spec,\n },\n },\n };\n}\n\n// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present\nfunction getYForNewRow(group: PanelGroupDefinition) {\n let newRowY = 0;\n for (const layout of group.itemLayouts) {\n const itemMaxY = layout.y + layout.h;\n if (itemMaxY > newRowY) {\n newRowY = itemMaxY;\n }\n }\n return newRowY;\n}\n\n// Find all the unique panel keys\n// ex: cpu, cpu-1, cpu-2 count as the same panel key since these panels have the same name\nfunction getUniquePanelKeys(panels: Record<string, PanelDefinition>): Record<string, number> {\n const uniquePanelKeys: Record<string, number> = {};\n Object.keys(panels).forEach((panelKey) => {\n const key = panelKey.replace(/-([0-9]+)/, '');\n const count = uniquePanelKeys[key];\n if (count) {\n uniquePanelKeys[key] = count + 1;\n } else {\n uniquePanelKeys[key] = 1;\n }\n });\n return uniquePanelKeys;\n}\n"],"names":["removeWhiteSpacesAndSpecialCharacters","generateId","addPanelGroup","createEmptyPanelGroup","createPanelEditorSlice","set","get","panelEditor","undefined","openEditPanel","panelGroupItemId","panelGroups","panels","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","panelKey","itemPanelKeys","Error","panelToEdit","editorState","mode","initialValues","name","spec","display","description","groupId","kind","plugin","applyChanges","next","panelDefinititon","createPanelDefinitionFromEditorValues","state","existingGroup","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingLayout","existingPanelKey","splice","newGroup","push","x","y","getYForNewRow","w","h","close","openAddPanel","panelGroupOrder","title","id","panelDef","uniquePanelKeys","getUniquePanelKeys","group","toString","editorValues","newRowY","itemMaxY","Object","keys","forEach","key","replace","count"],"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;AAIjC,SAASA,qCAAqC,QAAQ,uBAAuB,CAAC;AAC9E,SAASC,UAAU,QAAoB,UAAU,CAAC;AAClD,SAMEC,aAAa,EACbC,qBAAqB,QAChB,qBAAqB,CAAC;AAwD7B;;CAEC,GACD,OAAO,SAASC,sBAAsB,GAMpC;IACA,gGAAgG;IAChG,OAAO,CAACC,GAAG,EAAEC,GAAG;QAAM,OAAA;YACpBC,WAAW,EAAEC,SAAS;YAEtBC,aAAa,EAACC,gBAAgB,EAAE;oBAKbC,GAAyB;gBAJ1C,MAAM,EAAEC,MAAM,CAAA,EAAED,WAAW,CAAA,EAAE,GAAGL,GAAG,EAAE,AAAC;gBAEtC,4CAA4C;gBAC5C,MAAM,EAAEO,YAAY,CAAA,EAAEC,sBAAsB,EAAEC,kBAAkB,CAAA,EAAE,GAAGL,gBAAgB,AAAC;gBACtF,MAAMM,QAAQ,GAAGL,CAAAA,GAAyB,GAAzBA,WAAW,CAACE,Y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AAkB,CAAC9C,MAAuC,EAA0B;IAC3F,MAAM6C,eAAe,GAA2B,EAAE,AAAC;IACnDO,MAAM,CAACC,IAAI,CAACrD,MAAM,CAAC,CAACsD,OAAO,CAAC,CAAClD,QAAQ,GAAK;QACxC,MAAMmD,GAAG,GAAGnD,QAAQ,CAACoD,OAAO,cAAc,EAAE,CAAC,AAAC;QAC9C,MAAMC,KAAK,GAAGZ,eAAe,CAACU,GAAG,CAAC,AAAC;QACnC,IAAIE,KAAK,EAAE;YACTZ,eAAe,CAACU,GAAG,CAAC,GAAGE,KAAK,GAAG,CAAC,CAAC;QACnC,OAAO;YACLZ,eAAe,CAACU,GAAG,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAOV,eAAe,CAAC;AACzB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { StateCreator } from 'zustand';
2
+ import { Middleware } from './common';
3
+ import { PanelGroupSlice, PanelGroupId } from './panel-group-slice';
4
+ export interface PanelGroupEditor {
5
+ mode: 'Add' | 'Edit';
6
+ initialValues: PanelGroupEditorValues;
7
+ applyChanges: (next: PanelGroupEditorValues) => void;
8
+ close: () => void;
9
+ }
10
+ export interface PanelGroupEditorValues {
11
+ title: string;
12
+ isCollapsed: boolean;
13
+ }
14
+ /**
15
+ * Slice that handles the visual editor state and related actions for adding or editing Panel Groups.
16
+ */
17
+ export interface PanelGroupEditorSlice {
18
+ /**
19
+ * State that's present when the panel group editor is open.
20
+ */
21
+ panelGroupEditor?: PanelGroupEditor;
22
+ /**
23
+ * Opens the panel group editor to add a new panel group.
24
+ */
25
+ openAddPanelGroup: () => void;
26
+ /**
27
+ * Opens the panel group editor to edit an existing panel group.
28
+ */
29
+ openEditPanelGroup: (panelGroupId: PanelGroupId) => void;
30
+ }
31
+ export declare const createPanelGroupEditorSlice: StateCreator<PanelGroupEditorSlice & PanelGroupSlice, Middleware, [
32
+ ], PanelGroupEditorSlice>;
33
+ //# sourceMappingURL=panel-group-editor-slice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-group-editor-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-group-editor-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAwC,MAAM,qBAAqB,CAAC;AAE1G,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB,aAAa,EAAE,sBAAsB,CAAC;IACtC,YAAY,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACrD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;OAEG;IACH,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAE9B;;OAEG;IACH,kBAAkB,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;CAC1D;AAED,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAEpD,qBAAqB,GAAG,eAAe,EACvC,UAAU,EACV;CAAE,EACF,qBAAqB,CAoErB,CAAC"}
@@ -0,0 +1,79 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
14
+ export const createPanelGroupEditorSlice = (set, get)=>({
15
+ panelGroupEditor: undefined,
16
+ openAddPanelGroup: ()=>{
17
+ // Create the editor state
18
+ const editor = {
19
+ mode: 'Add',
20
+ initialValues: {
21
+ title: '',
22
+ isCollapsed: false
23
+ },
24
+ applyChanges (next) {
25
+ const newGroup = createEmptyPanelGroup();
26
+ newGroup.title = next.title;
27
+ newGroup.isCollapsed = next.isCollapsed;
28
+ set((draft)=>{
29
+ addPanelGroup(draft, newGroup);
30
+ });
31
+ },
32
+ close () {
33
+ set((draft)=>{
34
+ draft.panelGroupEditor = undefined;
35
+ });
36
+ }
37
+ };
38
+ // Open the editor
39
+ set((draft)=>{
40
+ draft.panelGroupEditor = editor;
41
+ });
42
+ },
43
+ openEditPanelGroup: (panelGroupId)=>{
44
+ const existingGroup = get().panelGroups[panelGroupId];
45
+ if (existingGroup === undefined) {
46
+ throw new Error(`Panel group with Id ${panelGroupId} does not exist`);
47
+ }
48
+ var _title;
49
+ // Create the editor state
50
+ const editor = {
51
+ mode: 'Edit',
52
+ initialValues: {
53
+ title: (_title = existingGroup.title) !== null && _title !== void 0 ? _title : '',
54
+ isCollapsed: existingGroup.isCollapsed
55
+ },
56
+ applyChanges (next) {
57
+ set((draft)=>{
58
+ const group = draft.panelGroups[panelGroupId];
59
+ if (group === undefined) {
60
+ throw new Error(`Panel group with Id ${panelGroupId} does not exist`);
61
+ }
62
+ group.title = next.title;
63
+ group.isCollapsed = next.isCollapsed;
64
+ });
65
+ },
66
+ close () {
67
+ set((draft)=>{
68
+ draft.panelGroupEditor = undefined;
69
+ });
70
+ }
71
+ };
72
+ // Open the editor
73
+ set((draft)=>{
74
+ draft.panelGroupEditor = editor;
75
+ });
76
+ }
77
+ });
78
+
79
+ //# sourceMappingURL=panel-group-editor-slice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/panel-group-editor-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, PanelGroupId, addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';\n\nexport interface PanelGroupEditor {\n mode: 'Add' | 'Edit';\n initialValues: PanelGroupEditorValues;\n applyChanges: (next: PanelGroupEditorValues) => void;\n close: () => void;\n}\n\nexport interface PanelGroupEditorValues {\n title: string;\n isCollapsed: boolean;\n}\n\n/**\n * Slice that handles the visual editor state and related actions for adding or editing Panel Groups.\n */\nexport interface PanelGroupEditorSlice {\n /**\n * State that's present when the panel group editor is open.\n */\n panelGroupEditor?: PanelGroupEditor;\n\n /**\n * Opens the panel group editor to add a new panel group.\n */\n openAddPanelGroup: () => void;\n\n /**\n * Opens the panel group editor to edit an existing panel group.\n */\n openEditPanelGroup: (panelGroupId: PanelGroupId) => void;\n}\n\nexport const createPanelGroupEditorSlice: StateCreator<\n // Actions in here need to modify Panel Group state\n PanelGroupEditorSlice & PanelGroupSlice,\n Middleware,\n [],\n PanelGroupEditorSlice\n> = (set, get) => ({\n panelGroupEditor: undefined,\n\n openAddPanelGroup: () => {\n // Create the editor state\n const editor: PanelGroupEditor = {\n mode: 'Add',\n initialValues: {\n title: '',\n isCollapsed: false,\n },\n applyChanges(next) {\n const newGroup = createEmptyPanelGroup();\n newGroup.title = next.title;\n newGroup.isCollapsed = next.isCollapsed;\n set((draft) => {\n addPanelGroup(draft, newGroup);\n });\n },\n close() {\n set((draft) => {\n draft.panelGroupEditor = undefined;\n });\n },\n };\n\n // Open the editor\n set((draft) => {\n draft.panelGroupEditor = editor;\n });\n },\n\n openEditPanelGroup: (panelGroupId) => {\n const existingGroup = get().panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} does not exist`);\n }\n\n // Create the editor state\n const editor: PanelGroupEditor = {\n mode: 'Edit',\n initialValues: {\n title: existingGroup.title ?? '',\n isCollapsed: existingGroup.isCollapsed,\n },\n applyChanges(next) {\n set((draft) => {\n const group = draft.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} does not exist`);\n }\n group.title = next.title;\n group.isCollapsed = next.isCollapsed;\n });\n },\n close() {\n set((draft) => {\n draft.panelGroupEditor = undefined;\n });\n },\n };\n\n // Open the editor\n set((draft) => {\n draft.panelGroupEditor = editor;\n });\n },\n});\n"],"names":["addPanelGroup","createEmptyPanelGroup","createPanelGroupEditorSlice","set","get","panelGroupEditor","undefined","openAddPanelGroup","editor","mode","initialValues","title","isCollapsed","applyChanges","next","newGroup","draft","close","openEditPanelGroup","panelGroupId","existingGroup","panelGroups","Error","group"],"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;AAIjC,SAAwCA,aAAa,EAAEC,qBAAqB,QAAQ,qBAAqB,CAAC;AAkC1G,OAAO,MAAMC,2BAA2B,GAMpC,CAACC,GAAG,EAAEC,GAAG,GAAM,CAAA;QACjBC,gBAAgB,EAAEC,SAAS;QAE3BC,iBAAiB,EAAE,IAAM;YACvB,0BAA0B;YAC1B,MAAMC,MAAM,GAAqB;gBAC/BC,IAAI,EAAE,KAAK;gBACXC,aAAa,EAAE;oBACbC,KAAK,EAAE,EAAE;oBACTC,WAAW,EAAE,KAAK;iBACnB;g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AK,CAACK,WAAW,CAACF,YAAY,CAAC,AAAC;wBAC9C,IAAII,KAAK,KAAKjB,SAAS,EAAE;4BACvB,MAAM,IAAIgB,KAAK,CAAC,CAAC,oBAAoB,EAAEH,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC;wBACxE,CAAC;wBACDI,KAAK,CAACZ,KAAK,GAAGG,IAAI,CAACH,KAAK,CAAC;wBACzBY,KAAK,CAACX,WAAW,GAAGE,IAAI,CAACF,WAAW,CAAC;oBACvC,CAAC,CAAC,CAAC;gBACL,CAAC;gBACDK,KAAK,IAAG;oBACNd,GAAG,CAAC,CAACa,KAAK,GAAK;wBACbA,KAAK,CAACX,gBAAgB,GAAGC,SAAS,CAAC;oBACrC,CAAC,CAAC,CAAC;gBACL,CAAC;aACF,AAAC;YAEF,kBAAkB;YAClBH,GAAG,CAAC,CAACa,KAAK,GAAK;gBACbA,KAAK,CAACX,gBAAgB,GAAGG,MAAM,CAAC;YAClC,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAA,AAAC,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { LayoutDefinition } from '@perses-dev/core';
2
+ import { WritableDraft } from 'immer/dist/internal';
3
+ import { Layout } from 'react-grid-layout';
4
+ import { StateCreator } from 'zustand';
5
+ import { Middleware } from './common';
6
+ /**
7
+ * Slice with the state of Panel Groups, as well as any actions that modify only Panel Group state.
8
+ */
9
+ export interface PanelGroupSlice {
10
+ /**
11
+ * Panel groups indexed by their ID.
12
+ */
13
+ panelGroups: Record<PanelGroupId, PanelGroupDefinition>;
14
+ /**
15
+ * An array of panel group IDs, representing their order in the dashboard.
16
+ */
17
+ panelGroupOrder: PanelGroupId[];
18
+ /**
19
+ * Rearrange the order of panel groups by swapping the positions
20
+ */
21
+ swapPanelGroups: (xIndex: number, yIndex: number) => void;
22
+ /**
23
+ * Update the item layouts for a panel group when, for example, a panel is moved or resized.
24
+ */
25
+ updatePanelGroupLayouts: (panelGroupId: PanelGroupId, itemLayouts: PanelGroupDefinition['itemLayouts']) => void;
26
+ }
27
+ export declare type PanelGroupId = number;
28
+ export interface PanelGroupDefinition {
29
+ id: PanelGroupId;
30
+ isCollapsed: boolean;
31
+ title?: string;
32
+ itemLayouts: PanelGroupItemLayout[];
33
+ itemPanelKeys: Record<PanelGroupItemLayoutId, string>;
34
+ }
35
+ export interface PanelGroupItemLayout extends Layout {
36
+ i: PanelGroupItemLayoutId;
37
+ }
38
+ export declare type PanelGroupItemLayoutId = string;
39
+ /**
40
+ * Uniquely identifies an item in a PanelGroup.
41
+ */
42
+ export interface PanelGroupItemId {
43
+ panelGroupId: PanelGroupId;
44
+ panelGroupItemLayoutId: PanelGroupItemLayoutId;
45
+ }
46
+ /**
47
+ * Curried function for creating a PanelGroupSlice.
48
+ */
49
+ export declare function createPanelGroupSlice(layouts: LayoutDefinition[]): StateCreator<PanelGroupSlice, Middleware, [], PanelGroupSlice>;
50
+ export declare function convertLayoutsToPanelGroups(layouts: LayoutDefinition[]): Pick<PanelGroupSlice, 'panelGroups' | 'panelGroupOrder'>;
51
+ /**
52
+ * Private helper function for creating an empty panel group.
53
+ */
54
+ export declare function createEmptyPanelGroup(): PanelGroupDefinition;
55
+ /**
56
+ * Private helper function that modifies panel group state to add a new panel
57
+ */
58
+ export declare function addPanelGroup(draft: WritableDraft<PanelGroupSlice>, newGroup: PanelGroupDefinition): void;
59
+ //# sourceMappingURL=panel-group-slice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-group-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-group-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAsB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAc,UAAU,EAAE,MAAM,U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aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,oBAAoB,QAGlG"}
@@ -0,0 +1,105 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { getPanelKeyFromRef } from '@perses-dev/core';
14
+ import { generateId } from './common';
15
+ /**
16
+ * Curried function for creating a PanelGroupSlice.
17
+ */ export function createPanelGroupSlice(layouts) {
18
+ const { panelGroups , panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
19
+ // Return the state creator function for Zustand
20
+ return (set)=>({
21
+ panelGroups,
22
+ panelGroupOrder,
23
+ swapPanelGroups (x, y) {
24
+ set((state)=>{
25
+ if (x < 0 || x >= state.panelGroupOrder.length || y < 0 || y >= state.panelGroupOrder.length) {
26
+ throw new Error('index out of bound');
27
+ }
28
+ const xPanelGroup = state.panelGroupOrder[x];
29
+ const yPanelGroup = state.panelGroupOrder[y];
30
+ if (xPanelGroup === undefined || yPanelGroup === undefined) {
31
+ throw new Error('panel group is undefined');
32
+ }
33
+ // assign yPanelGroup to layouts[x] and assign xGroup to layouts[y], swapping two panel groups
34
+ [state.panelGroupOrder[x], state.panelGroupOrder[y]] = [
35
+ yPanelGroup,
36
+ xPanelGroup
37
+ ];
38
+ });
39
+ },
40
+ updatePanelGroupLayouts (panelGroupId, itemLayouts) {
41
+ set((state)=>{
42
+ const group = state.panelGroups[panelGroupId];
43
+ if (group === undefined) {
44
+ throw new Error(`Cannot find panel group ${panelGroupId}`);
45
+ }
46
+ group.itemLayouts = itemLayouts;
47
+ });
48
+ }
49
+ });
50
+ }
51
+ export function convertLayoutsToPanelGroups(layouts) {
52
+ // Convert the initial layouts from the JSON
53
+ const panelGroups = {};
54
+ const panelGroupIdOrder = [];
55
+ for (const layout of layouts){
56
+ var ref, ref1, ref2;
57
+ const itemLayouts = [];
58
+ const itemPanelKeys = {};
59
+ // Split layout information from panel keys to make it easier to update just layouts on move/resize of panels
60
+ for (const item of layout.spec.items){
61
+ const panelGroupLayoutId = generateId().toString();
62
+ itemLayouts.push({
63
+ i: panelGroupLayoutId,
64
+ w: item.width,
65
+ h: item.height,
66
+ x: item.x,
67
+ y: item.y
68
+ });
69
+ itemPanelKeys[panelGroupLayoutId] = getPanelKeyFromRef(item.content);
70
+ }
71
+ // Create the panel group and keep track of the ID order
72
+ const panelGroupId = generateId();
73
+ panelGroups[panelGroupId] = {
74
+ id: panelGroupId,
75
+ isCollapsed: ((ref = layout.spec.display) === null || ref === void 0 ? void 0 : (ref1 = ref.collapse) === null || ref1 === void 0 ? void 0 : ref1.open) === false,
76
+ title: (ref2 = layout.spec.display) === null || ref2 === void 0 ? void 0 : ref2.title,
77
+ itemLayouts,
78
+ itemPanelKeys
79
+ };
80
+ panelGroupIdOrder.push(panelGroupId);
81
+ }
82
+ return {
83
+ panelGroups,
84
+ panelGroupOrder: panelGroupIdOrder
85
+ };
86
+ }
87
+ /**
88
+ * Private helper function for creating an empty panel group.
89
+ */ export function createEmptyPanelGroup() {
90
+ return {
91
+ id: generateId(),
92
+ title: undefined,
93
+ isCollapsed: false,
94
+ itemLayouts: [],
95
+ itemPanelKeys: {}
96
+ };
97
+ }
98
+ /**
99
+ * Private helper function that modifies panel group state to add a new panel
100
+ */ export function addPanelGroup(draft, newGroup) {
101
+ draft.panelGroups[newGroup.id] = newGroup;
102
+ draft.panelGroupOrder.unshift(newGroup.id);
103
+ }
104
+
105
+ //# sourceMappingURL=panel-group-slice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/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 { getPanelKeyFromRef, LayoutDefinition } from '@perses-dev/core';\nimport { WritableDraft } from 'immer/dist/internal';\nimport { Layout } from 'react-grid-layout';\nimport { StateCreator } from 'zustand';\nimport { generateId, Middleware } from './common';\n\n/**\n * Slice with the state of Panel Groups, as well as any actions that modify only Panel Group state.\n */\nexport interface PanelGroupSlice {\n /**\n * Panel groups indexed by their ID.\n */\n panelGroups: Record<PanelGroupId, PanelGroupDefinition>;\n\n /**\n * An array of panel group IDs, representing their order in the dashboard.\n */\n panelGroupOrder: PanelGroupId[];\n\n /**\n * Rearrange the order of panel groups by swapping the positions\n */\n swapPanelGroups: (xIndex: number, yIndex: number) => void;\n\n /**\n * Update the item layouts for a panel group when, for example, a panel is moved or resized.\n */\n updatePanelGroupLayouts: (panelGroupId: PanelGroupId, itemLayouts: PanelGroupDefinition['itemLayouts']) => void;\n}\n\nexport type PanelGroupId = number;\n\nexport interface PanelGroupDefinition {\n id: PanelGroupId;\n isCollapsed: boolean;\n title?: string;\n itemLayouts: PanelGroupItemLayout[];\n itemPanelKeys: Record<PanelGroupItemLayoutId, string>;\n}\n\nexport interface PanelGroupItemLayout extends Layout {\n i: PanelGroupItemLayoutId;\n}\n\nexport type PanelGroupItemLayoutId = string;\n\n/**\n * Uniquely identifies an item in a PanelGroup.\n */\nexport interface PanelGroupItemId {\n panelGroupId: PanelGroupId;\n panelGroupItemLayoutId: PanelGroupItemLayoutId;\n}\n\n/**\n * Curried function for creating a PanelGroupSlice.\n */\nexport function createPanelGroupSlice(\n layouts: LayoutDefinition[]\n): StateCreator<PanelGroupSlice, Middleware, [], PanelGroupSlice> {\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n\n // Return the state creator function for Zustand\n return (set) => ({\n panelGroups,\n panelGroupOrder,\n\n swapPanelGroups(x, y) {\n set((state) => {\n if (x < 0 || x >= state.panelGroupOrder.length || y < 0 || y >= state.panelGroupOrder.length) {\n throw new Error('index out of bound');\n }\n const xPanelGroup = state.panelGroupOrder[x];\n const yPanelGroup = state.panelGroupOrder[y];\n\n if (xPanelGroup === undefined || yPanelGroup === undefined) {\n throw new Error('panel group is undefined');\n }\n // assign yPanelGroup to layouts[x] and assign xGroup to layouts[y], swapping two panel groups\n [state.panelGroupOrder[x], state.panelGroupOrder[y]] = [yPanelGroup, xPanelGroup];\n });\n },\n\n updatePanelGroupLayouts(panelGroupId, itemLayouts) {\n set((state) => {\n const group = state.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Cannot find panel group ${panelGroupId}`);\n }\n group.itemLayouts = itemLayouts;\n });\n },\n });\n}\n\nexport function convertLayoutsToPanelGroups(\n layouts: LayoutDefinition[]\n): Pick<PanelGroupSlice, 'panelGroups' | 'panelGroupOrder'> {\n // Convert the initial layouts from the JSON\n const panelGroups: PanelGroupSlice['panelGroups'] = {};\n const panelGroupIdOrder: PanelGroupSlice['panelGroupOrder'] = [];\n for (const layout of layouts) {\n const itemLayouts: PanelGroupDefinition['itemLayouts'] = [];\n const itemPanelKeys: PanelGroupDefinition['itemPanelKeys'] = {};\n\n // Split layout information from panel keys to make it easier to update just layouts on move/resize of panels\n for (const item of layout.spec.items) {\n const panelGroupLayoutId = generateId().toString();\n itemLayouts.push({\n i: panelGroupLayoutId,\n w: item.width,\n h: item.height,\n x: item.x,\n y: item.y,\n });\n itemPanelKeys[panelGroupLayoutId] = getPanelKeyFromRef(item.content);\n }\n\n // Create the panel group and keep track of the ID order\n const panelGroupId = generateId();\n panelGroups[panelGroupId] = {\n id: panelGroupId,\n isCollapsed: layout.spec.display?.collapse?.open === false,\n title: layout.spec.display?.title,\n itemLayouts,\n itemPanelKeys,\n };\n panelGroupIdOrder.push(panelGroupId);\n }\n return {\n panelGroups,\n panelGroupOrder: panelGroupIdOrder,\n };\n}\n\n/**\n * Private helper function for creating an empty panel group.\n */\nexport function createEmptyPanelGroup(): PanelGroupDefinition {\n return {\n id: generateId(),\n title: undefined,\n isCollapsed: false,\n itemLayouts: [],\n itemPanelKeys: {},\n };\n}\n\n/**\n * Private helper function that modifies panel group state to add a new panel\n */\nexport function addPanelGroup(draft: WritableDraft<PanelGroupSlice>, newGroup: PanelGroupDefinition) {\n draft.panelGroups[newGroup.id] = newGroup;\n draft.panelGroupOrder.unshift(newGroup.id);\n}\n"],"names":["getPanelKeyFromRef","generateId","createPanelGroupSlice","layouts","panelGroups","panelGroupOrder","convertLayoutsToPanelGroups","set","swapPanelGroups","x","y","state","length","Error","xPanelGroup","yPanelGroup","undefined","updatePanelGroupLayouts","panelGroupId","itemLayouts","group","panelGroupIdOrder","layout","itemPanelKeys","item","spec","items","panelGroupLayoutId","toString","push","i","w","width","h","height","content","id","isCollapsed","display","collapse","open","title","createEmptyPanelGroup","addPanelGroup","draft","newGroup","unshift"],"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,kBAAkB,QAA0B,kBAAkB,CAAC;AAIxE,SAASC,UAAU,QAAoB,UAAU,CAAC;AAmDlD;;CAEC,GACD,OAAO,SAASC,qBAAqB,CACnCC,OAA2B,EACqC;IAChE,MAAM,EAAEC,WAAW,CAAA,EAAEC,eAAe,CAAA,EAAE,GAAGC,2BAA2B,CAACH,OAAO,CAAC,AAAC;IAE9E,gDAAgD;IAChD,OAAO,CAACI,GAAG,GAAM,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B,WAAO,GAA1BA,KAAAA,CAA0B,GAA1BA,IAAmB,CAAEmB,KAAK;YACjCtB,WAAW;YACXI,aAAa;SACd,CAAC;QACFF,iBAAiB,CAACQ,IAAI,CAACX,YAAY,CAAC,CAAC;IACvC,CAAC;IACD,OAAO;QACLd,WAAW;QACXC,eAAe,EAAEgB,iBAAiB;KACnC,CAAC;AACJ,CAAC;AAED;;CAEC,GACD,OAAO,SAASqB,qBAAqB,GAAyB;IAC5D,OAAO;QACLN,EAAE,EAAEnC,UAAU,EAAE;QAChBwC,KAAK,EAAEzB,SAAS;QAChBqB,WAAW,EAAE,KAAK;QAClBlB,WAAW,EAAE,EAAE;QACfI,aAAa,EAAE,EAAE;KAClB,CAAC;AACJ,CAAC;AAED;;CAEC,GACD,OAAO,SAASoB,aAAa,CAACC,KAAqC,EAAEC,QAA8B,EAAE;IACnGD,KAAK,CAACxC,WAAW,CAACyC,QAAQ,CAACT,EAAE,CAAC,GAAGS,QAAQ,CAAC;IAC1CD,KAAK,CAACvC,eAAe,CAACyC,OAAO,CAACD,QAAQ,CAACT,EAAE,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { PanelDefinition } from '@perses-dev/core';
2
+ import { StateCreator } from 'zustand';
3
+ import { Middleware } from './common';
4
+ /**
5
+ * Slice with the state of Panels, along with any actions that modify only the Panels state.
6
+ */
7
+ export interface PanelSlice {
8
+ panels: Record<string, PanelDefinition>;
9
+ }
10
+ /**
11
+ * Curried function for creating the PanelSlice.
12
+ */
13
+ export declare function createPanelSlice(panels: PanelSlice['panels']): StateCreator<PanelSlice, Middleware, [], PanelSlice>;
14
+ //# sourceMappingURL=panel-slice.d.ts.map