@perses-dev/dashboards 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatterplot-fix-imports-95e1b59

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 (411) hide show
  1. package/dist/cjs/components/AddGroupButton/AddGroupButton.js +11 -8
  2. package/dist/cjs/components/AddGroupButton/index.js +10 -8
  3. package/dist/cjs/components/AddPanelButton/AddPanelButton.js +12 -13
  4. package/dist/cjs/components/AddPanelButton/index.js +10 -8
  5. package/dist/cjs/components/Dashboard/Dashboard.js +12 -10
  6. package/dist/cjs/components/Dashboard/index.js +10 -8
  7. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +53 -22
  8. package/dist/cjs/components/DashboardStickyToolbar/index.js +10 -8
  9. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +82 -103
  10. package/dist/cjs/components/DashboardToolbar/index.js +10 -8
  11. package/dist/cjs/components/Datasources/DatasourceEditor.js +236 -0
  12. package/dist/cjs/components/Datasources/EditDatasourcesButton.js +112 -0
  13. package/dist/cjs/components/{ToolbarIconButton → Datasources}/index.js +11 -8
  14. package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +16 -14
  15. package/dist/cjs/components/DeletePanelDialog/index.js +10 -8
  16. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +18 -16
  17. package/dist/cjs/components/DeletePanelGroupDialog/index.js +10 -8
  18. package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +6 -4
  19. package/dist/cjs/components/DiscardChangesConfirmationDialog/index.js +10 -8
  20. package/dist/cjs/components/DownloadButton/DownloadButton.js +13 -12
  21. package/dist/cjs/components/DownloadButton/index.js +10 -8
  22. package/dist/cjs/components/EditButton/EditButton.js +9 -7
  23. package/dist/cjs/components/EditButton/index.js +10 -8
  24. package/dist/cjs/components/EditJsonButton/EditJsonButton.js +15 -12
  25. package/dist/cjs/components/EditJsonButton/index.js +10 -8
  26. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +54 -25
  27. package/dist/cjs/components/EditJsonDialog/index.js +10 -8
  28. package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +21 -19
  29. package/dist/cjs/components/EmptyDashboard/index.js +10 -8
  30. package/dist/cjs/components/GridLayout/GridContainer.js +6 -4
  31. package/dist/cjs/components/GridLayout/GridItemContent.js +37 -19
  32. package/dist/cjs/components/GridLayout/GridLayout.js +21 -19
  33. package/dist/cjs/components/GridLayout/GridTitle.js +40 -39
  34. package/dist/cjs/components/GridLayout/index.js +13 -11
  35. package/dist/cjs/components/Panel/Panel.js +19 -23
  36. package/dist/cjs/components/Panel/PanelContent.js +11 -8
  37. package/dist/cjs/components/Panel/PanelHeader.js +35 -33
  38. package/dist/cjs/components/Panel/index.js +10 -8
  39. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +25 -77
  40. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +237 -144
  41. package/dist/cjs/components/PanelDrawer/PanelPreview.js +13 -12
  42. package/dist/cjs/components/PanelDrawer/index.js +11 -8
  43. package/dist/cjs/components/PanelDrawer/usePanelEditor.js +5 -3
  44. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +18 -16
  45. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +16 -12
  46. package/dist/cjs/components/PanelGroupDialog/index.js +10 -8
  47. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +48 -46
  48. package/dist/cjs/components/QuerySummaryTable/index.js +10 -8
  49. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +26 -24
  50. package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +10 -8
  51. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +14 -14
  52. package/dist/cjs/components/SaveDashboardButton/index.js +10 -8
  53. package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +141 -0
  54. package/dist/cjs/components/Variables/EditVariablesButton.js +19 -17
  55. package/dist/cjs/components/Variables/TemplateVariable.js +261 -107
  56. package/dist/cjs/components/Variables/VariableEditor.js +282 -207
  57. package/dist/cjs/components/Variables/VariableList.js +24 -22
  58. package/dist/cjs/components/Variables/index.js +14 -11
  59. package/dist/cjs/components/index.js +30 -29
  60. package/dist/cjs/constants/grid-layout-config.js +6 -2
  61. package/dist/cjs/constants/index.js +12 -9
  62. package/dist/cjs/constants/styles.js +42 -0
  63. package/dist/cjs/constants/user-interface-text.js +8 -3
  64. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +48 -35
  65. package/dist/cjs/context/DashboardProvider/common.js +6 -2
  66. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +81 -49
  67. package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +4 -2
  68. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +8 -6
  69. package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +3 -1
  70. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +4 -2
  71. package/dist/cjs/context/DashboardProvider/edit-json-dialog-slice.js +3 -1
  72. package/dist/cjs/context/DashboardProvider/index.js +12 -10
  73. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +17 -17
  74. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +8 -6
  75. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +16 -8
  76. package/dist/cjs/context/DashboardProvider/panel-slice.js +3 -1
  77. package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +3 -1
  78. package/dist/cjs/context/DatasourceStoreProvider.js +177 -50
  79. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +150 -39
  80. package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +12 -10
  81. package/dist/cjs/context/TemplateVariableProvider/index.js +10 -8
  82. package/dist/cjs/context/TemplateVariableProvider/query-params.js +17 -7
  83. package/dist/cjs/context/TemplateVariableProvider/utils.js +15 -7
  84. package/dist/cjs/context/index.js +13 -11
  85. package/dist/cjs/context/useDashboard.js +30 -11
  86. package/dist/cjs/index.js +12 -10
  87. package/dist/cjs/stories/decorators/WithDashboard.js +6 -4
  88. package/dist/cjs/stories/decorators/WithDatasourceStore.js +6 -4
  89. package/dist/cjs/stories/decorators/WithTemplateVariables.js +6 -4
  90. package/dist/cjs/stories/decorators/constants.js +5 -3
  91. package/dist/cjs/stories/decorators/index.js +13 -11
  92. package/dist/cjs/test/dashboard-provider.js +8 -4
  93. package/dist/cjs/test/datasource-provider.js +16 -12
  94. package/dist/cjs/test/index.js +13 -11
  95. package/dist/cjs/test/plugin-registry.js +6 -4
  96. package/dist/cjs/test/render.js +28 -21
  97. package/dist/cjs/test/setup-tests.js +2 -2
  98. package/dist/cjs/test/testDashboard.js +13 -11
  99. package/dist/cjs/utils/index.js +10 -9
  100. package/dist/cjs/utils/panelUtils.js +11 -5
  101. package/dist/cjs/{components/TimeRangeControls → validation}/index.js +10 -8
  102. package/dist/cjs/{utils/time.js → validation/panel.js} +11 -9
  103. package/dist/cjs/views/ViewDashboard/DashboardApp.js +32 -18
  104. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +64 -21
  105. package/dist/cjs/views/ViewDashboard/index.js +10 -8
  106. package/dist/cjs/views/index.js +10 -8
  107. package/dist/components/AddGroupButton/AddGroupButton.d.ts +1 -2
  108. package/dist/components/AddGroupButton/AddGroupButton.d.ts.map +1 -1
  109. package/dist/components/AddGroupButton/AddGroupButton.js +3 -2
  110. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
  111. package/dist/components/AddGroupButton/index.js.map +1 -1
  112. package/dist/components/AddPanelButton/AddPanelButton.d.ts +1 -2
  113. package/dist/components/AddPanelButton/AddPanelButton.d.ts.map +1 -1
  114. package/dist/components/AddPanelButton/AddPanelButton.js +4 -7
  115. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  116. package/dist/components/AddPanelButton/index.js.map +1 -1
  117. package/dist/components/Dashboard/Dashboard.d.ts +2 -3
  118. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  119. package/dist/components/Dashboard/Dashboard.js +1 -1
  120. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  121. package/dist/components/Dashboard/index.js.map +1 -1
  122. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +1 -2
  123. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  124. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +38 -9
  125. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  126. package/dist/components/DashboardStickyToolbar/index.js.map +1 -1
  127. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -1
  128. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  129. package/dist/components/DashboardToolbar/DashboardToolbar.js +63 -86
  130. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  131. package/dist/components/DashboardToolbar/index.js.map +1 -1
  132. package/dist/components/Datasources/DatasourceEditor.d.ts +7 -0
  133. package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -0
  134. package/dist/components/Datasources/DatasourceEditor.js +223 -0
  135. package/dist/components/Datasources/DatasourceEditor.js.map +1 -0
  136. package/dist/components/Datasources/EditDatasourcesButton.d.ts +2 -0
  137. package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -0
  138. package/dist/components/Datasources/EditDatasourcesButton.js +99 -0
  139. package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -0
  140. package/dist/components/Datasources/index.d.ts +3 -0
  141. package/dist/components/Datasources/index.d.ts.map +1 -0
  142. package/dist/components/{TimeRangeControls → Datasources}/index.js +2 -1
  143. package/dist/components/Datasources/index.js.map +1 -0
  144. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +1 -2
  145. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -1
  146. package/dist/components/DeletePanelDialog/DeletePanelDialog.js +4 -4
  147. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  148. package/dist/components/DeletePanelDialog/index.js.map +1 -1
  149. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts +1 -2
  150. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  151. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +3 -3
  152. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  153. package/dist/components/DeletePanelGroupDialog/index.js.map +1 -1
  154. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +1 -2
  155. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
  156. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +1 -1
  157. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  158. package/dist/components/DiscardChangesConfirmationDialog/index.js.map +1 -1
  159. package/dist/components/DownloadButton/DownloadButton.d.ts +1 -2
  160. package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -1
  161. package/dist/components/DownloadButton/DownloadButton.js +3 -4
  162. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  163. package/dist/components/DownloadButton/index.js.map +1 -1
  164. package/dist/components/EditButton/EditButton.d.ts +1 -2
  165. package/dist/components/EditButton/EditButton.d.ts.map +1 -1
  166. package/dist/components/EditButton/EditButton.js +1 -1
  167. package/dist/components/EditButton/EditButton.js.map +1 -1
  168. package/dist/components/EditButton/index.js.map +1 -1
  169. package/dist/components/EditJsonButton/EditJsonButton.d.ts +4 -2
  170. package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -1
  171. package/dist/components/EditJsonButton/EditJsonButton.js +7 -6
  172. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  173. package/dist/components/EditJsonButton/index.js.map +1 -1
  174. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +5 -2
  175. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  176. package/dist/components/EditJsonDialog/EditJsonDialog.js +43 -16
  177. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  178. package/dist/components/EditJsonDialog/index.js.map +1 -1
  179. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts +1 -1
  180. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts.map +1 -1
  181. package/dist/components/EmptyDashboard/EmptyDashboard.js +3 -3
  182. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
  183. package/dist/components/EmptyDashboard/index.js.map +1 -1
  184. package/dist/components/GridLayout/GridContainer.d.ts +1 -1
  185. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -1
  186. package/dist/components/GridLayout/GridContainer.js +1 -1
  187. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  188. package/dist/components/GridLayout/GridItemContent.d.ts +1 -2
  189. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  190. package/dist/components/GridLayout/GridItemContent.js +31 -15
  191. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  192. package/dist/components/GridLayout/GridLayout.d.ts +1 -2
  193. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  194. package/dist/components/GridLayout/GridLayout.js +6 -6
  195. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  196. package/dist/components/GridLayout/GridTitle.d.ts +1 -2
  197. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  198. package/dist/components/GridLayout/GridTitle.js +5 -6
  199. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  200. package/dist/components/GridLayout/index.js.map +1 -1
  201. package/dist/components/Panel/Panel.d.ts +2 -2
  202. package/dist/components/Panel/Panel.d.ts.map +1 -1
  203. package/dist/components/Panel/Panel.js +7 -13
  204. package/dist/components/Panel/Panel.js.map +1 -1
  205. package/dist/components/Panel/PanelContent.d.ts +3 -3
  206. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  207. package/dist/components/Panel/PanelContent.js +4 -3
  208. package/dist/components/Panel/PanelContent.js.map +1 -1
  209. package/dist/components/Panel/PanelHeader.d.ts +2 -2
  210. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  211. package/dist/components/Panel/PanelHeader.js +2 -2
  212. package/dist/components/Panel/PanelHeader.js.map +1 -1
  213. package/dist/components/Panel/index.js.map +1 -1
  214. package/dist/components/PanelDrawer/PanelDrawer.d.ts +1 -2
  215. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  216. package/dist/components/PanelDrawer/PanelDrawer.js +22 -76
  217. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  218. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +5 -3
  219. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  220. package/dist/components/PanelDrawer/PanelEditorForm.js +231 -142
  221. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  222. package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -2
  223. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  224. package/dist/components/PanelDrawer/PanelPreview.js +4 -5
  225. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  226. package/dist/components/PanelDrawer/index.d.ts +1 -0
  227. package/dist/components/PanelDrawer/index.d.ts.map +1 -1
  228. package/dist/components/PanelDrawer/index.js +1 -0
  229. package/dist/components/PanelDrawer/index.js.map +1 -1
  230. package/dist/components/PanelDrawer/usePanelEditor.js +2 -2
  231. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
  232. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +1 -2
  233. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  234. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  235. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +1 -2
  236. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
  237. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +1 -1
  238. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  239. package/dist/components/PanelGroupDialog/index.js.map +1 -1
  240. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts +1 -2
  241. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts.map +1 -1
  242. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +8 -8
  243. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  244. package/dist/components/QuerySummaryTable/index.js.map +1 -1
  245. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +1 -2
  246. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  247. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +8 -8
  248. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  249. package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -1
  250. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +1 -2
  251. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  252. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +8 -10
  253. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  254. package/dist/components/SaveDashboardButton/index.js.map +1 -1
  255. package/dist/components/Variables/BuiltinVariableAccordions.d.ts +7 -0
  256. package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -0
  257. package/dist/components/Variables/BuiltinVariableAccordions.js +128 -0
  258. package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -0
  259. package/dist/components/Variables/EditVariablesButton.d.ts +1 -2
  260. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  261. package/dist/components/Variables/EditVariablesButton.js +7 -7
  262. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  263. package/dist/components/Variables/TemplateVariable.d.ts +12 -4
  264. package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
  265. package/dist/components/Variables/TemplateVariable.js +244 -100
  266. package/dist/components/Variables/TemplateVariable.js.map +1 -1
  267. package/dist/components/Variables/VariableEditor.d.ts +4 -4
  268. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  269. package/dist/components/Variables/VariableEditor.js +232 -161
  270. package/dist/components/Variables/VariableEditor.js.map +1 -1
  271. package/dist/components/Variables/VariableList.d.ts +2 -3
  272. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  273. package/dist/components/Variables/VariableList.js +11 -13
  274. package/dist/components/Variables/VariableList.js.map +1 -1
  275. package/dist/components/Variables/index.d.ts +1 -0
  276. package/dist/components/Variables/index.d.ts.map +1 -1
  277. package/dist/components/Variables/index.js +1 -0
  278. package/dist/components/Variables/index.js.map +1 -1
  279. package/dist/components/index.d.ts +1 -2
  280. package/dist/components/index.d.ts.map +1 -1
  281. package/dist/components/index.js +1 -2
  282. package/dist/components/index.js.map +1 -1
  283. package/dist/constants/grid-layout-config.js.map +1 -1
  284. package/dist/constants/index.d.ts +1 -0
  285. package/dist/constants/index.d.ts.map +1 -1
  286. package/dist/constants/index.js +1 -0
  287. package/dist/constants/index.js.map +1 -1
  288. package/dist/constants/styles.d.ts +5 -0
  289. package/dist/constants/styles.d.ts.map +1 -0
  290. package/dist/{utils/time.js → constants/styles.js} +10 -10
  291. package/dist/constants/styles.js.map +1 -0
  292. package/dist/constants/user-interface-text.d.ts +2 -1
  293. package/dist/constants/user-interface-text.d.ts.map +1 -1
  294. package/dist/constants/user-interface-text.js +2 -1
  295. package/dist/constants/user-interface-text.js.map +1 -1
  296. package/dist/context/DashboardProvider/DashboardProvider.d.ts +7 -4
  297. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  298. package/dist/context/DashboardProvider/DashboardProvider.js +16 -9
  299. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  300. package/dist/context/DashboardProvider/common.d.ts +3 -3
  301. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  302. package/dist/context/DashboardProvider/common.js.map +1 -1
  303. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -1
  304. package/dist/context/DashboardProvider/dashboard-provider-api.js +17 -17
  305. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  306. package/dist/context/DashboardProvider/delete-panel-group-slice.js +1 -1
  307. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  308. package/dist/context/DashboardProvider/delete-panel-slice.js +5 -5
  309. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  310. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
  311. package/dist/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  312. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  313. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
  314. package/dist/context/DashboardProvider/index.js.map +1 -1
  315. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -2
  316. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  317. package/dist/context/DashboardProvider/panel-editor-slice.js +11 -13
  318. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  319. package/dist/context/DashboardProvider/panel-group-editor-slice.js +2 -2
  320. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  321. package/dist/context/DashboardProvider/panel-group-slice.d.ts +2 -2
  322. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  323. package/dist/context/DashboardProvider/panel-group-slice.js +4 -4
  324. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  325. package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
  326. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  327. package/dist/context/DatasourceStoreProvider.d.ts +17 -12
  328. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  329. package/dist/context/DatasourceStoreProvider.js +172 -47
  330. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  331. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +15 -8
  332. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  333. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +115 -23
  334. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  335. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
  336. package/dist/context/TemplateVariableProvider/hydrationUtils.js +7 -7
  337. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
  338. package/dist/context/TemplateVariableProvider/index.js.map +1 -1
  339. package/dist/context/TemplateVariableProvider/query-params.js.map +1 -1
  340. package/dist/context/TemplateVariableProvider/utils.js +3 -3
  341. package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
  342. package/dist/context/index.js.map +1 -1
  343. package/dist/context/useDashboard.d.ts +3 -3
  344. package/dist/context/useDashboard.d.ts.map +1 -1
  345. package/dist/context/useDashboard.js +24 -7
  346. package/dist/context/useDashboard.js.map +1 -1
  347. package/dist/index.js.map +1 -1
  348. package/dist/stories/decorators/WithDashboard.js.map +1 -1
  349. package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
  350. package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
  351. package/dist/stories/decorators/constants.js +2 -2
  352. package/dist/stories/decorators/constants.js.map +1 -1
  353. package/dist/stories/decorators/index.js.map +1 -1
  354. package/dist/test/dashboard-provider.js.map +1 -1
  355. package/dist/test/datasource-provider.d.ts.map +1 -1
  356. package/dist/test/datasource-provider.js +5 -7
  357. package/dist/test/datasource-provider.js.map +1 -1
  358. package/dist/test/index.js.map +1 -1
  359. package/dist/test/plugin-registry.js.map +1 -1
  360. package/dist/test/render.d.ts.map +1 -1
  361. package/dist/test/render.js +9 -4
  362. package/dist/test/render.js.map +1 -1
  363. package/dist/test/setup-tests.js.map +1 -1
  364. package/dist/test/testDashboard.js +10 -10
  365. package/dist/test/testDashboard.js.map +1 -1
  366. package/dist/utils/index.d.ts +0 -1
  367. package/dist/utils/index.d.ts.map +1 -1
  368. package/dist/utils/index.js +0 -1
  369. package/dist/utils/index.js.map +1 -1
  370. package/dist/utils/panelUtils.d.ts +1 -1
  371. package/dist/utils/panelUtils.d.ts.map +1 -1
  372. package/dist/utils/panelUtils.js +2 -2
  373. package/dist/utils/panelUtils.js.map +1 -1
  374. package/dist/validation/index.d.ts +2 -0
  375. package/dist/validation/index.d.ts.map +1 -0
  376. package/dist/{components/ToolbarIconButton → validation}/index.js +1 -1
  377. package/dist/validation/index.js.map +1 -0
  378. package/dist/validation/panel.d.ts +19 -0
  379. package/dist/validation/panel.d.ts.map +1 -0
  380. package/dist/validation/panel.js +21 -0
  381. package/dist/validation/panel.js.map +1 -0
  382. package/dist/views/ViewDashboard/DashboardApp.d.ts +4 -3
  383. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  384. package/dist/views/ViewDashboard/DashboardApp.js +19 -7
  385. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  386. package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -2
  387. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  388. package/dist/views/ViewDashboard/ViewDashboard.js +53 -12
  389. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  390. package/dist/views/ViewDashboard/index.js.map +1 -1
  391. package/dist/views/index.js.map +1 -1
  392. package/package.json +8 -7
  393. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +0 -183
  394. package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +0 -38
  395. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +0 -14
  396. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +0 -1
  397. package/dist/components/TimeRangeControls/TimeRangeControls.js +0 -165
  398. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +0 -1
  399. package/dist/components/TimeRangeControls/index.d.ts +0 -2
  400. package/dist/components/TimeRangeControls/index.d.ts.map +0 -1
  401. package/dist/components/TimeRangeControls/index.js.map +0 -1
  402. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts +0 -6
  403. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts.map +0 -1
  404. package/dist/components/ToolbarIconButton/ToolbarIconButton.js +0 -32
  405. package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +0 -1
  406. package/dist/components/ToolbarIconButton/index.d.ts +0 -2
  407. package/dist/components/ToolbarIconButton/index.d.ts.map +0 -1
  408. package/dist/components/ToolbarIconButton/index.js.map +0 -1
  409. package/dist/utils/time.d.ts +0 -5
  410. package/dist/utils/time.d.ts.map +0 -1
  411. package/dist/utils/time.js.map +0 -1
@@ -17,15 +17,14 @@ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
17
17
  * Curried function for creating the PanelEditorSlice.
18
18
  */ export function createPanelEditorSlice() {
19
19
  // Return the state creator function for Zustand that uses the panels provided as intitial state
20
- return (set, get)=>{
21
- return {
20
+ return (set, get)=>({
22
21
  panelEditor: undefined,
23
22
  openEditPanel (panelGroupItemId) {
24
- var ref;
25
- const { panels , panelGroups } = get();
23
+ var _panelGroups_panelGroupId;
24
+ const { panels, panelGroups } = get();
26
25
  // 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];
26
+ const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
27
+ const panelKey = (_panelGroups_panelGroupId = panelGroups[panelGroupId]) === null || _panelGroups_panelGroupId === void 0 ? void 0 : _panelGroups_panelGroupId.itemPanelKeys[panelGroupLayoutId];
29
28
  if (panelKey === undefined) {
30
29
  throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);
31
30
  }
@@ -35,7 +34,7 @@ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
35
34
  throw new Error(`Cannot find Panel with key '${panelKey}'`);
36
35
  }
37
36
  const editorState = {
38
- mode: 'Edit',
37
+ mode: 'update',
39
38
  initialValues: {
40
39
  groupId: panelGroupItemId.panelGroupId,
41
40
  panelDefinition: panelToEdit
@@ -88,7 +87,7 @@ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
88
87
  });
89
88
  },
90
89
  openAddPanel (panelGroupId) {
91
- var ref;
90
+ var _get_initialValues;
92
91
  // If a panel group isn't supplied, add to the first group or create a group if there aren't any
93
92
  let newGroup = undefined;
94
93
  panelGroupId !== null && panelGroupId !== void 0 ? panelGroupId : panelGroupId = get().panelGroupOrder[0];
@@ -97,12 +96,12 @@ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
97
96
  newGroup.title = 'Panel Group';
98
97
  panelGroupId = newGroup.id;
99
98
  }
100
- var ref1;
99
+ var _get_initialValues_panelDefinition;
101
100
  const editorState = {
102
- mode: 'Add',
101
+ mode: 'create',
103
102
  initialValues: {
104
103
  groupId: panelGroupId,
105
- panelDefinition: (ref1 = (ref = get().initialValues) === null || ref === void 0 ? void 0 : ref.panelDefinition) !== null && ref1 !== void 0 ? ref1 : createPanelDefinition()
104
+ panelDefinition: (_get_initialValues_panelDefinition = (_get_initialValues = get().initialValues) === null || _get_initialValues === void 0 ? void 0 : _get_initialValues.panelDefinition) !== null && _get_initialValues_panelDefinition !== void 0 ? _get_initialValues_panelDefinition : createPanelDefinition()
106
105
  },
107
106
  applyChanges: (next)=>{
108
107
  const name = next.panelDefinition.spec.display.name;
@@ -141,8 +140,7 @@ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
141
140
  state.panelEditor = editorState;
142
141
  });
143
142
  }
144
- };
145
- };
143
+ });
146
144
  }
147
145
 
148
146
  //# sourceMappingURL=panel-editor-slice.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/panel-editor-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 { PanelDefinition } from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { getYForNewRow, getValidPanelKey } from '../../utils/panelUtils';\nimport { generateId, Middleware, createPanelDefinition } 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 * Initial values for add panel if default panel kind is defined\n */\n initialValues?: Pick<PanelEditorValues, 'panelDefinition'>;\n\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 groupId: PanelGroupId;\n panelDefinition: PanelDefinition;\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 groupId: panelGroupItemId.panelGroupId,\n panelDefinition: panelToEdit,\n },\n applyChanges: (next) => {\n set((state) => {\n state.panels[panelKey] = next.panelDefinition;\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 groupId: panelGroupId,\n panelDefinition: get().initialValues?.panelDefinition ?? createPanelDefinition(),\n },\n applyChanges: (next) => {\n const name = next.panelDefinition.spec.display.name;\n const panelKey = getValidPanelKey(name, get().panels);\n\n set((state) => {\n // Add a panel\n state.panels[panelKey] = next.panelDefinition;\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"],"names":["getYForNewRow","getValidPanelKey","generateId","createPanelDefinition","addPanelGroup","createEmptyPanelGroup","createPanelEditorSlice","set","get","panelEditor","undefined","openEditPanel","panelGroupItemId","panelGroups","panels","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","panelKey","itemPanelKeys","Error","panelToEdit","editorState","mode","initialValues","groupId","panelDefinition","applyChanges","next","state","existingGroup","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingLayout","existingPanelKey","splice","newGroup","push","x","y","w","h","close","openAddPanel","panelGroupOrder","title","id","name","spec","display","group","toString"],"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,aAAa,EAAEC,gBAAgB,QAAQ,wBAAwB,CAAC;AACzE,SAASC,UAAU,EAAcC,qBAAqB,QAAQ,UAAU,CAAC;AACzE,SAMEC,aAAa,EACbC,qBAAqB,QAChB,qBAAqB,CAAC;AA0D7B;;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,YAAY,CAAC,cAAzBF,GAAyB,WAAe,GAAxCA,KAAAA,CAAwC,GAAxCA,GAAyB,CAAEM,aAAa,CAACF,kBAAkB,CAAC,AAAC;gBAC9E,IAAIC,QAAQ,KAAKR,SAA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,KAAK,CAAChB,WAAW,CAACe,IAAI,CAACH,OAAO,CAAC,AAAC;4BAC9C,IAAI4B,KAAK,KAAK3C,SAAS,EAAE;gCACvB,MAAM,IAAIU,KAAK,CAAC,CAAC,oBAAoB,EAAEQ,IAAI,CAACH,OAAO,CAAC,CAAC,CAAC,CAAC;4BACzD,CAAC;4BACD,MAAMS,MAAM,GAAyB;gCACnCC,CAAC,EAAEjC,UAAU,EAAE,CAACoD,QAAQ,EAAE;gCAC1Bb,CAAC,EAAE,CAAC;gCACJC,CAAC,EAAE1C,aAAa,CAACqD,KAAK,CAAC;gCACvBV,CAAC,EAAE,EAAE;gCACLC,CAAC,EAAE,CAAC;6BACL,AAAC;4BACFS,KAAK,CAACrB,WAAW,CAACQ,IAAI,CAACN,MAAM,CAAC,CAAC;4BAC/BmB,KAAK,CAAClC,aAAa,CAACe,MAAM,CAACC,CAAC,CAAC,GAAGjB,QAAQ,CAAC;wBAC3C,CAAC,CAAC,CAAC;oBACL,CAAC;oBACD2B,KAAK,EAAE,IAAM;wBACXtC,GAAG,CAAC,CAACsB,KAAK,GAAK;4BACbA,KAAK,CAACpB,WAAW,GAAGC,SAAS,CAAC;wBAChC,CAAC,CAAC,CAAC;oBACL,CAAC;iBACF,AAAC;gBAEFH,GAAG,CAAC,CAACsB,KAAK,GAAK;oBACb,2DAA2D;oBAC3D,IAAIU,QAAQ,KAAK7B,SAAS,EAAE;wBAC1BN,aAAa,CAACyB,KAAK,EAAEU,QAAQ,CAAC,CAAC;oBACjC,CAAC;oBAED,qCAAqC;oBACrCV,KAAK,CAACpB,WAAW,GAAGa,WAAW,CAAC;gBAClC,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAA;KAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/panel-editor-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 { Action, PanelDefinition } from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { getYForNewRow, getValidPanelKey } from '../../utils/panelUtils';\nimport { generateId, Middleware, createPanelDefinition } 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 * Initial values for add panel if default panel kind is defined\n */\n initialValues?: Pick<PanelEditorValues, 'panelDefinition'>;\n\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: Action;\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 groupId: PanelGroupId;\n panelDefinition: PanelDefinition;\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: 'update',\n initialValues: {\n groupId: panelGroupItemId.panelGroupId,\n panelDefinition: panelToEdit,\n },\n applyChanges: (next) => {\n set((state) => {\n state.panels[panelKey] = next.panelDefinition;\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: 'create',\n initialValues: {\n groupId: panelGroupId,\n panelDefinition: get().initialValues?.panelDefinition ?? createPanelDefinition(),\n },\n applyChanges: (next) => {\n const name = next.panelDefinition.spec.display.name;\n const panelKey = getValidPanelKey(name, get().panels);\n\n set((state) => {\n // Add a panel\n state.panels[panelKey] = next.panelDefinition;\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"],"names":["getYForNewRow","getValidPanelKey","generateId","createPanelDefinition","addPanelGroup","createEmptyPanelGroup","createPanelEditorSlice","set","get","panelEditor","undefined","openEditPanel","panelGroupItemId","panelGroups","panels","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","panelKey","itemPanelKeys","Error","panelToEdit","editorState","mode","initialValues","groupId","panelDefinition","applyChanges","next","state","existingGroup","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingLayout","existingPanelKey","splice","newGroup","push","x","y","w","h","close","openAddPanel","panelGroupOrder","title","id","name","spec","display","group","toString"],"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,aAAa,EAAEC,gBAAgB,QAAQ,yBAAyB;AACzE,SAASC,UAAU,EAAcC,qBAAqB,QAAQ,WAAW;AACzE,SAMEC,aAAa,EACbC,qBAAqB,QAChB,sBAAsB;AA0D7B;;CAEC,GACD,OAAO,SAASC;IAOd,gGAAgG;IAChG,OAAO,CAACC,KAAKC,MAAS,CAAA;YACpBC,aAAaC;YAEbC,eAAcC,gBAAgB;oBAKXC;gBAJjB,MAAM,EAAEC,MAAM,EAAED,WAAW,EAAE,GAAGL;gBAEhC,4CAA4C;gBAC5C,MAAM,EAAEO,YAAY,EAAEC,wBAAwBC,kBAAkB,EAAE,GAAGL;gBACrE,MAAMM,YAAWL,4BAAAA,WAAW,CAACE,aAAa,cAAzBF,gDAAAA,0BAA2BM,aAAa,CAACF,mBAAmB;gBAC7E,IAAIC,aAAaR,WAAW;oBAC1B,MAAM,IAAIU,MAAM,CAAC,gCAAgC,EAAER,iBAAiB,CAAC;gBACvE;gBAEA,yBAAyB;gBACzB,MAAMS,cAAcP,MAAM,CAACI,SAAS;gBACpC,IAAIG,gBAAgBX,WAAW;oBAC7B,MAAM,IAAIU,MAAM,CAAC,4BAA4B,EAAEF,SAAS,CAAC,CAAC;gBAC5D;gBAEA,MAAMI,cAAgC;oBACpCC,MAAM;oBACNC,eAAe;wBACbC,SAASb,iBAAiBG,YAAY;wBACtCW,iBAAiBL;oBACnB;oBACAM,cAAc,CAACC;wBACbrB,IAAI,CAACsB;4BACHA,MAAMf,MAAM,CAACI,S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;4BACHA,MAAMpB,WAAW,GAAGC;wBACtB;oBACF;gBACF;gBAEAH,IAAI,CAACsB;oBACH,2DAA2D;oBAC3D,IAAIU,aAAa7B,WAAW;wBAC1BN,cAAcyB,OAAOU;oBACvB;oBAEA,qCAAqC;oBACrCV,MAAMpB,WAAW,GAAGa;gBACtB;YACF;QACF,CAAA;AACF"}
@@ -45,12 +45,12 @@ export const createPanelGroupEditorSlice = (set, get)=>({
45
45
  if (existingGroup === undefined) {
46
46
  throw new Error(`Panel group with Id ${panelGroupId} does not exist`);
47
47
  }
48
- var _title;
48
+ var _existingGroup_title;
49
49
  // Create the editor state
50
50
  const editor = {
51
51
  mode: 'Edit',
52
52
  initialValues: {
53
- title: (_title = existingGroup.title) !== null && _title !== void 0 ? _title : '',
53
+ title: (_existingGroup_title = existingGroup.title) !== null && _existingGroup_title !== void 0 ? _existingGroup_title : '',
54
54
  isCollapsed: existingGroup.isCollapsed
55
55
  },
56
56
  applyChanges (next) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/panel-group-editor-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, 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;gBACDC,YAAY,EAACC,IAAI,EAAE;oBACjB,MAAMC,QAAQ,GAAGd,qBAAqB,EAAE,AAAC;oBACzCc,QAAQ,CAACJ,KAAK,GAAGG,IAAI,CAACH,KAAK,CAAC;oBAC5BI,QAAQ,CAACH,WAAW,GAAGE,IAAI,CAACF,WAAW,CAAC;oBACxCT,GAAG,CAAC,CAACa,KAAK,GAAK;wBACbhB,aAAa,CAACgB,KAAK,EAAED,QAAQ,CAAC,CAAC;oBACjC,CAAC,CAAC,CAAC;gBACL,CAAC;gBACDE,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,CAA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CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAA,AAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/panel-group-editor-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, 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,sBAAsB;AAkC1G,OAAO,MAAMC,8BAMT,CAACC,KAAKC,MAAS,CAAA;QACjBC,kBAAkBC;QAElBC,mBAAmB;YACjB,0BAA0B;YAC1B,MAAMC,SAA2B;gBAC/BC,MAAM;gBACNC,eAAe;oBACbC,OAAO;oBACPC,aAAa;gBACf;gBACAC,cAAaC,IAAI;oBACf,MAAMC,WAAWd;oBACjBc,SAASJ,KAAK,GAAGG,KAAKH,KAAK;oBAC3BI,SAASH,WAAW,GAAGE,KAAKF,WAAW;oBACvCT,IAAI,CAACa;wBACHhB,cAAcgB,OAAOD;oBACvB;gBACF;gBACAE;oBACEd,IAAI,CAACa;wBACHA,MAAMX,gBAAgB,GAAGC;oBAC3B;gBACF;YACF;YAEA,kBAAkB;YAClBH,IAAI,CAACa;gBACHA,MAAMX,gBAAgB,GAAGG;YAC3B;QACF;QAEAU,oBAAoB,CAACC;YACnB,MAAMC,gBAAgBhB,MAAMiB,WAAW,CAACF,aAAa;YACrD,IAAIC,kBAAkBd,WAAW;gBAC/B,MAAM,IAAIgB,MAAM,CAAC,oBAAoB,EAAEH,aAAa,eAAe,CAAC;YACtE;gBAMWC;YAJX,0BAA0B;YAC1B,MAAMZ,SAA2B;gBAC/BC,MAAM;gBACNC,eAAe;oBACbC,OAAOS,CAAAA,uBAAAA,cAAcT,KAAK,cAAnBS,kCAAAA,uBAAuB;oBAC9BR,aAAaQ,cAAcR,WAAW;gBACxC;gBACAC,cAAaC,IAAI;oBACfX,IAAI,CAACa;wBACH,MAAMO,QAAQP,MAAMK,WAAW,CAACF,aAAa;wBAC7C,IAAII,UAAUjB,WAAW;4BACvB,MAAM,IAAIgB,MAAM,CAAC,oBAAoB,EAAEH,aAAa,eAAe,CAAC;wBACtE;wBACAI,MAAMZ,KAAK,GAAGG,KAAKH,KAAK;wBACxBY,MAAMX,WAAW,GAAGE,KAAKF,WAAW;oBACtC;gBACF;gBACAK;oBACEd,IAAI,CAACa;wBACHA,MAAMX,gBAAgB,GAAGC;oBAC3B;gBACF;YACF;YAEA,kBAAkB;YAClBH,IAAI,CAACa;gBACHA,MAAMX,gBAAgB,GAAGG;YAC3B;QACF;IACF,CAAA,EAAG"}
@@ -24,7 +24,7 @@ export interface PanelGroupSlice {
24
24
  */
25
25
  updatePanelGroupLayouts: (panelGroupId: PanelGroupId, itemLayouts: PanelGroupDefinition['itemLayouts']) => void;
26
26
  }
27
- export declare type PanelGroupId = number;
27
+ export type PanelGroupId = number;
28
28
  export interface PanelGroupDefinition {
29
29
  id: PanelGroupId;
30
30
  isCollapsed: boolean;
@@ -35,7 +35,7 @@ export interface PanelGroupDefinition {
35
35
  export interface PanelGroupItemLayout extends Layout {
36
36
  i: PanelGroupItemLayoutId;
37
37
  }
38
- export declare type PanelGroupItemLayoutId = string;
38
+ export type PanelGroupItemLayoutId = string;
39
39
  /**
40
40
  * Uniquely identifies an item in a PanelGroup.
41
41
  */
@@ -1 +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,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IAExD;;OAEG;IACH,eAAe,EAAE,YAAY,EAAE,CAAC;IAEhC;;OAEG;IACH,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAE1D;;OAEG;IACH,uBAAuB,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;CACjH;AAED,oBAAY,YAAY,GAAG,MAAM,CAAC;AAElC,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,YAAY,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,oBAAqB,SAAQ,MAAM;IAClD,CAAC,EAAE,sBAAsB,CAAC;CAC3B;AAED,oBAAY,sBAAsB,GAAG,MAAM,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,sBAAsB,EAAE,sBAAsB,CAAC;CAChD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EAAE,GAC1B,YAAY,CAAC,eAAe,EAAE,UAAU,EAAE,EAAE,EAAE,eAAe,CAAC,CAkChE;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,gBAAgB,EAAE,GAC1B,IAAI,CAAC,eAAe,EAAE,aAAa,GAAG,iBAAiB,CAAC,CAoC1D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,oBAAoB,CAQ5D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,oBAAoB,QAGlG"}
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,UAAU,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IAExD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15
15
  /**
16
16
  * Curried function for creating a PanelGroupSlice.
17
17
  */ export function createPanelGroupSlice(layouts) {
18
- const { panelGroups , panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
18
+ const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
19
19
  // Return the state creator function for Zustand
20
20
  return (set)=>({
21
21
  panelGroups,
@@ -53,7 +53,7 @@ export function convertLayoutsToPanelGroups(layouts) {
53
53
  const panelGroups = {};
54
54
  const panelGroupIdOrder = [];
55
55
  for (const layout of layouts){
56
- var ref, ref1, ref2;
56
+ var _layout_spec_display_collapse, _layout_spec_display, _layout_spec_display1;
57
57
  const itemLayouts = [];
58
58
  const itemPanelKeys = {};
59
59
  // Split layout information from panel keys to make it easier to update just layouts on move/resize of panels
@@ -72,8 +72,8 @@ export function convertLayoutsToPanelGroups(layouts) {
72
72
  const panelGroupId = generateId();
73
73
  panelGroups[panelGroupId] = {
74
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,
75
+ isCollapsed: ((_layout_spec_display = layout.spec.display) === null || _layout_spec_display === void 0 ? void 0 : (_layout_spec_display_collapse = _layout_spec_display.collapse) === null || _layout_spec_display_collapse === void 0 ? void 0 : _layout_spec_display_collapse.open) === false,
76
+ title: (_layout_spec_display1 = layout.spec.display) === null || _layout_spec_display1 === void 0 ? void 0 : _layout_spec_display1.title,
77
77
  itemLayouts,
78
78
  itemPanelKeys
79
79
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/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 { 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,CAAA;YACfH,WAAW;YACXC,eAAe;YAEfG,eAAe,EAACC,CAAC,EAAEC,CAAC,EAAE;gBACpBH,GAAG,CAAC,CAACI,KAAK,GAAK;oBACb,IAAIF,CAAC,GAAG,CAAC,IAAIA,CAAC,IAAIE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ACD,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"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/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 { 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,mBAAmB;AAIxE,SAASC,UAAU,QAAoB,WAAW;AAmDlD;;CAEC,GACD,OAAO,SAASC,sBACdC,OAA2B;IAE3B,MAAM,EAAEC,WAAW,EAAEC,eAAe,EAAE,GAAGC,4BAA4BH;IAErE,gDAAgD;IAChD,OAAO,CAACI,MAAS,CAAA;YACfH;YACAC;YAEAG,iBAAgBC,CAAC,EAAEC,CAAC;gBAClBH,IAAI,CAACI;oBACH,IAAIF,IAAI,KAAKA,KAAKE,MAAMN,eAAe,CAACO,MAAM,IAAIF,IAAI,KAAKA,KAAKC,MAAMN,eAAe,CAACO,MAAM,EAAE;wBAC5F,MAAM,IAAIC,MAAM;oBAClB;oBACA,MAAMC,cAAcH,MAAMN,eAAe,CAACI,EAAE;oBAC5C,MAAMM,cAAcJ,MAAMN,eAAe,CAACK,EAAE;oBAE5C,IAAII,gBAAgBE,aAAaD,gBAAgBC,WAAW;wBAC1D,MAAM,IAAIH,MAAM;oBAClB;oBACA,8FAA8F;oBAC9F,CAACF,MAAMN,eAAe,CAACI,EAAE,EAAEE,MAAMN,eAAe,CAACK,EAAE,CAAC,GAAG;wBAACK;wBAAaD;qBAAY;gBACnF;YACF;YAEAG,yBAAwBC,YAAY,EAAEC,WAAW;gBAC/CZ,IAAI,CAACI;oBACH,MAAMS,QAAQT,MAAMP,WAAW,CAACc,aAAa;oBAC7C,IAAIE,UAAUJ,WAAW;wBACvB,MAAM,IAAIH,MAAM,CAAC,wBAAwB,EAAEK,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QAA8B;IACjGD,MAAMxC,WAAW,CAACyC,SAAST,EAAE,CAAC,GAAGS;IACjCD,MAAMvC,eAAe,CAACyC,OAAO,CAACD,SAAST,EAAE;AAC3C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/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 { PanelDefinition } from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { Middleware } from './common';\n\n/**\n * Slice with the state of Panels, along with any actions that modify only the Panels state.\n */\nexport interface PanelSlice {\n panels: Record<string, PanelDefinition>;\n}\n\n/**\n * Curried function for creating the PanelSlice.\n */\nexport function createPanelSlice(panels: PanelSlice['panels']): StateCreator<PanelSlice, Middleware, [], PanelSlice> {\n return () => ({\n panels,\n });\n}\n"],"names":["createPanelSlice","panels"],"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;AAajC;;CAEC,GACD,OAAO,SAASA,gBAAgB,CAACC,MAA4B,EAAwD;IACnH,OAAO,IAAO,CAAA;YACZA,MAAM;SACP,CAAA,AAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/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 { PanelDefinition } from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { Middleware } from './common';\n\n/**\n * Slice with the state of Panels, along with any actions that modify only the Panels state.\n */\nexport interface PanelSlice {\n panels: Record<string, PanelDefinition>;\n}\n\n/**\n * Curried function for creating the PanelSlice.\n */\nexport function createPanelSlice(panels: PanelSlice['panels']): StateCreator<PanelSlice, Middleware, [], PanelSlice> {\n return () => ({\n panels,\n });\n}\n"],"names":["createPanelSlice","panels"],"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;AAajC;;CAEC,GACD,OAAO,SAASA,iBAAiBC,MAA4B;IAC3D,OAAO,IAAO,CAAA;YACZA;QACF,CAAA;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/save-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 SaveChangesConfirmationDialogSlice {\n saveChangesConfirmationDialog?: SaveChangesConfirmationDialogState;\n openSaveChangesConfirmationDialog: (saveChangesConfirmationDialog: SaveChangesConfirmationDialogState) => void;\n closeSaveChangesConfirmationDialog: () => void;\n}\n\nexport interface SaveChangesConfirmationDialogState {\n onSaveChanges: (saveDefaultTimeRange: boolean, saveDefaultVariables: boolean) => void;\n onCancel: () => void;\n isSavedDurationModified: boolean;\n isSavedVariableModified: boolean;\n description?: string;\n}\n\nexport const createSaveChangesDialogSlice: StateCreator<\n SaveChangesConfirmationDialogSlice,\n Middleware,\n [],\n SaveChangesConfirmationDialogSlice\n> = (set) => ({\n isOpen: false,\n\n openSaveChangesConfirmationDialog(dialog) {\n set(\n (state) => {\n state.saveChangesConfirmationDialog = dialog;\n },\n false,\n 'openSaveChangesConfirmationDialog'\n );\n },\n\n closeSaveChangesConfirmationDialog() {\n set(\n (state) => {\n state.saveChangesConfirmationDialog = undefined;\n },\n false,\n 'closeSaveChangesConfirmationDialog'\n );\n },\n});\n"],"names":["createSaveChangesDialogSlice","set","isOpen","openSaveChangesConfirmationDialog","dialog","state","saveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","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,4BAA4B,GAKrC,CAACC,GAAG,GAAM,CAAA;QACZC,MAAM,EAAE,KAAK;QAEbC,iCAAiC,EAACC,MAAM,EAAE;YACxCH,GAAG,CACD,CAACI,KAAK,GAAK;gBACTA,KAAK,CAACC,6BAA6B,GAAGF,MAAM,CAAC;YAC/C,CAAC,EACD,KAAK,EACL,mCAAmC,CACpC,CAAC;QACJ,CAAC;QAEDG,kCAAkC,IAAG;YACnCN,GAAG,CACD,CAACI,KAAK,GAAK;gBACTA,KAAK,CAACC,6BAA6B,GAAGE,SAAS,CAAC;YAClD,CAAC,EACD,KAAK,EACL,oCAAoC,CACrC,CAAC;QACJ,CAAC;KACF,CAAA,AAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/save-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 SaveChangesConfirmationDialogSlice {\n saveChangesConfirmationDialog?: SaveChangesConfirmationDialogState;\n openSaveChangesConfirmationDialog: (saveChangesConfirmationDialog: SaveChangesConfirmationDialogState) => void;\n closeSaveChangesConfirmationDialog: () => void;\n}\n\nexport interface SaveChangesConfirmationDialogState {\n onSaveChanges: (saveDefaultTimeRange: boolean, saveDefaultVariables: boolean) => void;\n onCancel: () => void;\n isSavedDurationModified: boolean;\n isSavedVariableModified: boolean;\n description?: string;\n}\n\nexport const createSaveChangesDialogSlice: StateCreator<\n SaveChangesConfirmationDialogSlice,\n Middleware,\n [],\n SaveChangesConfirmationDialogSlice\n> = (set) => ({\n isOpen: false,\n\n openSaveChangesConfirmationDialog(dialog) {\n set(\n (state) => {\n state.saveChangesConfirmationDialog = dialog;\n },\n false,\n 'openSaveChangesConfirmationDialog'\n );\n },\n\n closeSaveChangesConfirmationDialog() {\n set(\n (state) => {\n state.saveChangesConfirmationDialog = undefined;\n },\n false,\n 'closeSaveChangesConfirmationDialog'\n );\n },\n});\n"],"names":["createSaveChangesDialogSlice","set","isOpen","openSaveChangesConfirmationDialog","dialog","state","saveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","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,+BAKT,CAACC,MAAS,CAAA;QACZC,QAAQ;QAERC,mCAAkCC,MAAM;YACtCH,IACE,CAACI;gBACCA,MAAMC,6BAA6B,GAAGF;YACxC,GACA,OACA;QAEJ;QAEAG;YACEN,IACE,CAACI;gBACCA,MAAMC,6BAA6B,GAAGE;YACxC,GACA,OACA;QAEJ;IACF,CAAA,EAAG"}
@@ -1,27 +1,32 @@
1
1
  import { ReactNode } from 'react';
2
- import { DashboardResource, Datasource, DatasourceSelector, GlobalDatasource } from '@perses-dev/core';
2
+ import { DashboardResource, ProjectDatasource, DatasourceSelector, DatasourceSpec, GlobalDatasource, EphemeralDashboardResource } from '@perses-dev/core';
3
3
  import { DatasourceClient } from '@perses-dev/plugin-system';
4
4
  export interface DatasourceStoreProviderProps {
5
- dashboardResource?: DashboardResource;
5
+ dashboardResource?: DashboardResource | EphemeralDashboardResource;
6
6
  projectName?: string;
7
7
  datasourceApi: DatasourceApi;
8
8
  children?: ReactNode;
9
+ savedDatasources?: Record<string, DatasourceSpec>;
9
10
  onCreate?: (client: DatasourceClient) => DatasourceClient;
10
11
  }
12
+ export type BuildDatasourceProxyUrlParams = {
13
+ project?: string;
14
+ dashboard?: string;
15
+ name: string;
16
+ };
17
+ export type BuildDatasourceProxyUrlFunc = (p: BuildDatasourceProxyUrlParams) => string;
18
+ /**
19
+ * The external API for fetching datasource resources
20
+ */
11
21
  export interface DatasourceApi {
12
- getDatasource: (project: string, selector: DatasourceSelector) => Promise<{
13
- resource: Datasource;
14
- proxyUrl: string;
15
- } | undefined>;
16
- getGlobalDatasource: (selector: DatasourceSelector) => Promise<{
17
- resource: GlobalDatasource;
18
- proxyUrl: string;
19
- } | undefined>;
20
- listDatasources: (project: string, pluginKind?: string) => Promise<Datasource[]>;
22
+ buildProxyUrl?: BuildDatasourceProxyUrlFunc;
23
+ getDatasource: (project: string, selector: DatasourceSelector) => Promise<ProjectDatasource | undefined>;
24
+ getGlobalDatasource: (selector: DatasourceSelector) => Promise<GlobalDatasource | undefined>;
25
+ listDatasources: (project: string, pluginKind?: string) => Promise<ProjectDatasource[]>;
21
26
  listGlobalDatasources: (pluginKind?: string) => Promise<GlobalDatasource[]>;
22
27
  }
23
28
  /**
24
29
  * A `DatasourceContext` provider that uses an external API to resolve datasource selectors.
25
30
  */
26
- export declare function DatasourceStoreProvider(props: DatasourceStoreProviderProps): JSX.Element;
31
+ export declare function DatasourceStoreProvider(props: DatasourceStoreProviderProps): import("react/jsx-runtime").JSX.Element;
27
32
  //# sourceMappingURL=DatasourceStoreProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatasourceStoreProvider.d.ts","sourceRoot":"","sources":["../../src/context/DatasourceStoreProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAwB,MAAM,OAAO,CAAC;AACxD,OAAO,EACL,iBAAiB,EAEjB,UAAU,EACV,kBAAkB,EAElB,gBAAgB,EAEjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAKL,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,gBAAgB,CAAC;CAC3D;AAGD,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,CACb,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,kBAAkB,KACzB,OAAO,CAAC;QAAE,QAAQ,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE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