@perses-dev/dashboards 0.52.0-beta.0 → 0.52.0-beta.2

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 (420) hide show
  1. package/dist/cjs/{components → src/components}/Panel/Panel.js +83 -0
  2. package/dist/cjs/{components → src/components}/Panel/PanelActions.js +12 -6
  3. package/dist/cjs/{components → src/components}/Panel/PanelHeader.js +6 -3
  4. package/dist/cjs/{components → src/components}/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -1
  5. package/dist/components/Panel/Panel.d.ts.map +1 -1
  6. package/dist/components/Panel/PanelActions.d.ts +2 -1
  7. package/dist/components/Panel/PanelActions.d.ts.map +1 -1
  8. package/dist/components/Panel/PanelHeader.d.ts +2 -1
  9. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  10. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  11. package/dist/src/components/AddGroupButton/AddGroupButton.js.map +1 -0
  12. package/dist/{components/QuerySummaryTable → src/components/AddGroupButton}/index.js.map +1 -1
  13. package/dist/src/components/AddPanelButton/AddPanelButton.js.map +1 -0
  14. package/dist/src/components/AddPanelButton/index.js.map +1 -0
  15. package/dist/src/components/Dashboard/Dashboard.js.map +1 -0
  16. package/dist/src/components/Dashboard/index.js.map +1 -0
  17. package/dist/src/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -0
  18. package/dist/src/components/DashboardStickyToolbar/index.js.map +1 -0
  19. package/dist/src/components/DashboardToolbar/DashboardToolbar.js.map +1 -0
  20. package/dist/src/components/DashboardToolbar/index.js.map +1 -0
  21. package/dist/src/components/Datasources/DatasourceEditor.js.map +1 -0
  22. package/dist/src/components/Datasources/EditDatasourcesButton.js.map +1 -0
  23. package/dist/{components/AddPanelButton → src/components/Datasources}/index.js.map +1 -1
  24. package/dist/src/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -0
  25. package/dist/{components/SaveDashboardButton → src/components/DeletePanelDialog}/index.js.map +1 -1
  26. package/dist/src/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
  27. package/dist/src/components/DeletePanelGroupDialog/index.js.map +1 -0
  28. package/dist/src/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -0
  29. package/dist/src/components/DiscardChangesConfirmationDialog/index.js.map +1 -0
  30. package/dist/src/components/DownloadButton/DownloadButton.js.map +1 -0
  31. package/dist/src/components/DownloadButton/index.js.map +1 -0
  32. package/dist/src/components/DownloadButton/serializeDashboard.js.map +1 -0
  33. package/dist/src/components/EditButton/EditButton.js.map +1 -0
  34. package/dist/{context/VariableProvider → src/components/EditButton}/index.js.map +1 -1
  35. package/dist/src/components/EditJsonButton/EditJsonButton.js.map +1 -0
  36. package/dist/src/components/EditJsonButton/index.js.map +1 -0
  37. package/dist/src/components/EditJsonDialog/EditJsonDialog.js.map +1 -0
  38. package/dist/{components/DeletePanelDialog → src/components/EditJsonDialog}/index.js.map +1 -1
  39. package/dist/src/components/EmptyDashboard/EmptyDashboard.js.map +1 -0
  40. package/dist/src/components/EmptyDashboard/index.js.map +1 -0
  41. package/dist/src/components/GridLayout/GridContainer.js.map +1 -0
  42. package/dist/src/components/GridLayout/GridItemContent.js.map +1 -0
  43. package/dist/src/components/GridLayout/GridLayout.js.map +1 -0
  44. package/dist/src/components/GridLayout/GridTitle.js.map +1 -0
  45. package/dist/src/components/GridLayout/index.js.map +1 -0
  46. package/dist/src/components/Panel/HeaderIconButton.js.map +1 -0
  47. package/dist/{components → src/components}/Panel/Panel.js +85 -2
  48. package/dist/src/components/Panel/Panel.js.map +1 -0
  49. package/dist/{components → src/components}/Panel/PanelActions.js +12 -6
  50. package/dist/src/components/Panel/PanelActions.js.map +1 -0
  51. package/dist/src/components/Panel/PanelContent.js.map +1 -0
  52. package/dist/{components → src/components}/Panel/PanelHeader.js +6 -3
  53. package/dist/src/components/Panel/PanelHeader.js.map +1 -0
  54. package/dist/src/components/Panel/PanelLinks.js.map +1 -0
  55. package/dist/src/components/Panel/PanelPluginLoader.js.map +1 -0
  56. package/dist/{views/ViewDashboard → src/components/Panel}/index.js.map +1 -1
  57. package/dist/src/components/PanelDrawer/PanelDrawer.js.map +1 -0
  58. package/dist/src/components/PanelDrawer/PanelEditorForm.js.map +1 -0
  59. package/dist/src/components/PanelDrawer/PanelPreview.js.map +1 -0
  60. package/dist/{components/AddGroupButton → src/components/PanelDrawer}/index.js.map +1 -1
  61. package/dist/src/components/PanelDrawer/usePanelEditor.js.map +1 -0
  62. package/dist/src/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
  63. package/dist/src/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
  64. package/dist/src/components/PanelGroupDialog/index.js.map +1 -0
  65. package/dist/src/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -0
  66. package/dist/src/components/QuerySummaryTable/index.js.map +1 -0
  67. package/dist/{components → src/components}/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -1
  68. package/dist/src/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -0
  69. package/dist/{components/DiscardChangesConfirmationDialog → src/components/SaveChangesConfirmationDialog}/index.js.map +1 -1
  70. package/dist/src/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -0
  71. package/dist/src/components/SaveDashboardButton/index.js.map +1 -0
  72. package/dist/src/components/Variables/BuiltinVariableAccordions.js.map +1 -0
  73. package/dist/src/components/Variables/EditVariablesButton.js.map +1 -0
  74. package/dist/src/components/Variables/Variable.js.map +1 -0
  75. package/dist/src/components/Variables/VariableEditor.js.map +1 -0
  76. package/dist/src/components/Variables/VariableList.js.map +1 -0
  77. package/dist/src/components/Variables/index.js.map +1 -0
  78. package/dist/src/components/index.js.map +1 -0
  79. package/dist/{components/Datasources/index.js.map → src/constants/grid-layout-config.js.map} +1 -1
  80. package/dist/src/constants/index.js.map +1 -0
  81. package/dist/src/constants/styles.js.map +1 -0
  82. package/dist/src/constants/user-interface-text.js.map +1 -0
  83. package/dist/src/context/DashboardProvider/DashboardProvider.js.map +1 -0
  84. package/dist/src/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -0
  85. package/dist/src/context/DashboardProvider/common.js.map +1 -0
  86. package/dist/src/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
  87. package/dist/src/context/DashboardProvider/delete-panel-group-slice.js.map +1 -0
  88. package/dist/src/context/DashboardProvider/delete-panel-slice.js.map +1 -0
  89. package/dist/src/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -0
  90. package/dist/src/context/DashboardProvider/duplicate-panel-slice.js.map +1 -0
  91. package/dist/src/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -0
  92. package/dist/src/context/DashboardProvider/index.js.map +1 -0
  93. package/dist/src/context/DashboardProvider/panel-editor-slice.js.map +1 -0
  94. package/dist/src/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
  95. package/dist/src/context/DashboardProvider/panel-group-slice.js.map +1 -0
  96. package/dist/src/context/DashboardProvider/panel-slice.js.map +1 -0
  97. package/dist/src/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -0
  98. package/dist/src/context/DashboardProvider/view-panel-slice.js.map +1 -0
  99. package/dist/src/context/DatasourceStoreProvider.js.map +1 -0
  100. package/dist/src/context/VariableProvider/VariableProvider.js.map +1 -0
  101. package/dist/src/context/VariableProvider/hydrationUtils.js.map +1 -0
  102. package/dist/{components/DashboardToolbar → src/context/VariableProvider}/index.js.map +1 -1
  103. package/dist/src/context/VariableProvider/query-params.js.map +1 -0
  104. package/dist/src/context/VariableProvider/utils.js.map +1 -0
  105. package/dist/src/context/index.js.map +1 -0
  106. package/dist/src/context/useDashboard.js.map +1 -0
  107. package/dist/src/index.js.map +1 -0
  108. package/dist/src/test/dashboard-provider.js.map +1 -0
  109. package/dist/src/test/datasource-provider.js.map +1 -0
  110. package/dist/src/test/index.js.map +1 -0
  111. package/dist/src/test/plugin-registry.js.map +1 -0
  112. package/dist/src/test/render.js.map +1 -0
  113. package/dist/src/test/setup-tests.js.map +1 -0
  114. package/dist/src/test/testDashboard.js.map +1 -0
  115. package/dist/src/utils/index.js.map +1 -0
  116. package/dist/src/utils/panelUtils.js.map +1 -0
  117. package/dist/src/views/ViewDashboard/DashboardApp.js.map +1 -0
  118. package/dist/src/views/ViewDashboard/ViewDashboard.js.map +1 -0
  119. package/dist/{components/PanelDrawer → src/views/ViewDashboard}/index.js.map +1 -1
  120. package/dist/src/views/index.js.map +1 -0
  121. package/package.json +5 -5
  122. package/dist/components/AddGroupButton/AddGroupButton.js.map +0 -1
  123. package/dist/components/AddPanelButton/AddPanelButton.js.map +0 -1
  124. package/dist/components/Dashboard/Dashboard.js.map +0 -1
  125. package/dist/components/Dashboard/index.js.map +0 -1
  126. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +0 -1
  127. package/dist/components/DashboardStickyToolbar/index.js.map +0 -1
  128. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +0 -1
  129. package/dist/components/Datasources/DatasourceEditor.js.map +0 -1
  130. package/dist/components/Datasources/EditDatasourcesButton.js.map +0 -1
  131. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +0 -1
  132. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +0 -1
  133. package/dist/components/DeletePanelGroupDialog/index.js.map +0 -1
  134. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +0 -1
  135. package/dist/components/DownloadButton/DownloadButton.js.map +0 -1
  136. package/dist/components/DownloadButton/index.js.map +0 -1
  137. package/dist/components/DownloadButton/serializeDashboard.js.map +0 -1
  138. package/dist/components/EditButton/EditButton.js.map +0 -1
  139. package/dist/components/EditButton/index.js.map +0 -1
  140. package/dist/components/EditJsonButton/EditJsonButton.js.map +0 -1
  141. package/dist/components/EditJsonButton/index.js.map +0 -1
  142. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +0 -1
  143. package/dist/components/EditJsonDialog/index.js.map +0 -1
  144. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +0 -1
  145. package/dist/components/EmptyDashboard/index.js.map +0 -1
  146. package/dist/components/GridLayout/GridContainer.js.map +0 -1
  147. package/dist/components/GridLayout/GridItemContent.js.map +0 -1
  148. package/dist/components/GridLayout/GridLayout.js.map +0 -1
  149. package/dist/components/GridLayout/GridTitle.js.map +0 -1
  150. package/dist/components/GridLayout/index.js.map +0 -1
  151. package/dist/components/Panel/HeaderIconButton.js.map +0 -1
  152. package/dist/components/Panel/Panel.js.map +0 -1
  153. package/dist/components/Panel/PanelActions.js.map +0 -1
  154. package/dist/components/Panel/PanelContent.js.map +0 -1
  155. package/dist/components/Panel/PanelHeader.js.map +0 -1
  156. package/dist/components/Panel/PanelLinks.js.map +0 -1
  157. package/dist/components/Panel/PanelPluginLoader.js.map +0 -1
  158. package/dist/components/Panel/index.js.map +0 -1
  159. package/dist/components/PanelDrawer/PanelDrawer.js.map +0 -1
  160. package/dist/components/PanelDrawer/PanelEditorForm.js.map +0 -1
  161. package/dist/components/PanelDrawer/PanelPreview.js.map +0 -1
  162. package/dist/components/PanelDrawer/usePanelEditor.js.map +0 -1
  163. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +0 -1
  164. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +0 -1
  165. package/dist/components/PanelGroupDialog/index.js.map +0 -1
  166. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +0 -1
  167. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +0 -1
  168. package/dist/components/SaveChangesConfirmationDialog/index.js.map +0 -1
  169. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +0 -1
  170. package/dist/components/Variables/BuiltinVariableAccordions.js.map +0 -1
  171. package/dist/components/Variables/EditVariablesButton.js.map +0 -1
  172. package/dist/components/Variables/Variable.js.map +0 -1
  173. package/dist/components/Variables/VariableEditor.js.map +0 -1
  174. package/dist/components/Variables/VariableList.js.map +0 -1
  175. package/dist/components/Variables/index.js.map +0 -1
  176. package/dist/components/index.js.map +0 -1
  177. package/dist/constants/grid-layout-config.js.map +0 -1
  178. package/dist/constants/index.js.map +0 -1
  179. package/dist/constants/styles.js.map +0 -1
  180. package/dist/constants/user-interface-text.js.map +0 -1
  181. package/dist/context/DashboardProvider/DashboardProvider.js.map +0 -1
  182. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +0 -1
  183. package/dist/context/DashboardProvider/common.js.map +0 -1
  184. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +0 -1
  185. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +0 -1
  186. package/dist/context/DashboardProvider/delete-panel-slice.js.map +0 -1
  187. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +0 -1
  188. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +0 -1
  189. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +0 -1
  190. package/dist/context/DashboardProvider/index.js.map +0 -1
  191. package/dist/context/DashboardProvider/panel-editor-slice.js.map +0 -1
  192. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +0 -1
  193. package/dist/context/DashboardProvider/panel-group-slice.js.map +0 -1
  194. package/dist/context/DashboardProvider/panel-slice.js.map +0 -1
  195. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +0 -1
  196. package/dist/context/DashboardProvider/view-panel-slice.js.map +0 -1
  197. package/dist/context/DatasourceStoreProvider.js.map +0 -1
  198. package/dist/context/VariableProvider/VariableProvider.js.map +0 -1
  199. package/dist/context/VariableProvider/hydrationUtils.js.map +0 -1
  200. package/dist/context/VariableProvider/query-params.js.map +0 -1
  201. package/dist/context/VariableProvider/utils.js.map +0 -1
  202. package/dist/context/index.js.map +0 -1
  203. package/dist/context/useDashboard.js.map +0 -1
  204. package/dist/index.js.map +0 -1
  205. package/dist/test/dashboard-provider.js.map +0 -1
  206. package/dist/test/datasource-provider.js.map +0 -1
  207. package/dist/test/index.js.map +0 -1
  208. package/dist/test/plugin-registry.js.map +0 -1
  209. package/dist/test/render.js.map +0 -1
  210. package/dist/test/setup-tests.js.map +0 -1
  211. package/dist/test/testDashboard.js.map +0 -1
  212. package/dist/utils/index.js.map +0 -1
  213. package/dist/utils/panelUtils.js.map +0 -1
  214. package/dist/views/ViewDashboard/DashboardApp.js.map +0 -1
  215. package/dist/views/ViewDashboard/ViewDashboard.js.map +0 -1
  216. package/dist/views/index.js.map +0 -1
  217. /package/dist/cjs/{components → src/components}/AddGroupButton/AddGroupButton.js +0 -0
  218. /package/dist/cjs/{components → src/components}/AddGroupButton/index.js +0 -0
  219. /package/dist/cjs/{components → src/components}/AddPanelButton/AddPanelButton.js +0 -0
  220. /package/dist/cjs/{components → src/components}/AddPanelButton/index.js +0 -0
  221. /package/dist/cjs/{components → src/components}/Dashboard/Dashboard.js +0 -0
  222. /package/dist/cjs/{components → src/components}/Dashboard/index.js +0 -0
  223. /package/dist/cjs/{components → src/components}/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -0
  224. /package/dist/cjs/{components → src/components}/DashboardStickyToolbar/index.js +0 -0
  225. /package/dist/cjs/{components → src/components}/DashboardToolbar/DashboardToolbar.js +0 -0
  226. /package/dist/cjs/{components → src/components}/DashboardToolbar/index.js +0 -0
  227. /package/dist/cjs/{components → src/components}/Datasources/DatasourceEditor.js +0 -0
  228. /package/dist/cjs/{components → src/components}/Datasources/EditDatasourcesButton.js +0 -0
  229. /package/dist/cjs/{components → src/components}/Datasources/index.js +0 -0
  230. /package/dist/cjs/{components → src/components}/DeletePanelDialog/DeletePanelDialog.js +0 -0
  231. /package/dist/cjs/{components → src/components}/DeletePanelDialog/index.js +0 -0
  232. /package/dist/cjs/{components → src/components}/DeletePanelGroupDialog/DeletePanelGroupDialog.js +0 -0
  233. /package/dist/cjs/{components → src/components}/DeletePanelGroupDialog/index.js +0 -0
  234. /package/dist/cjs/{components → src/components}/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +0 -0
  235. /package/dist/cjs/{components → src/components}/DiscardChangesConfirmationDialog/index.js +0 -0
  236. /package/dist/cjs/{components → src/components}/DownloadButton/DownloadButton.js +0 -0
  237. /package/dist/cjs/{components → src/components}/DownloadButton/index.js +0 -0
  238. /package/dist/cjs/{components → src/components}/DownloadButton/serializeDashboard.js +0 -0
  239. /package/dist/cjs/{components → src/components}/EditButton/EditButton.js +0 -0
  240. /package/dist/cjs/{components → src/components}/EditButton/index.js +0 -0
  241. /package/dist/cjs/{components → src/components}/EditJsonButton/EditJsonButton.js +0 -0
  242. /package/dist/cjs/{components → src/components}/EditJsonButton/index.js +0 -0
  243. /package/dist/cjs/{components → src/components}/EditJsonDialog/EditJsonDialog.js +0 -0
  244. /package/dist/cjs/{components → src/components}/EditJsonDialog/index.js +0 -0
  245. /package/dist/cjs/{components → src/components}/EmptyDashboard/EmptyDashboard.js +0 -0
  246. /package/dist/cjs/{components → src/components}/EmptyDashboard/index.js +0 -0
  247. /package/dist/cjs/{components → src/components}/GridLayout/GridContainer.js +0 -0
  248. /package/dist/cjs/{components → src/components}/GridLayout/GridItemContent.js +0 -0
  249. /package/dist/cjs/{components → src/components}/GridLayout/GridLayout.js +0 -0
  250. /package/dist/cjs/{components → src/components}/GridLayout/GridTitle.js +0 -0
  251. /package/dist/cjs/{components → src/components}/GridLayout/index.js +0 -0
  252. /package/dist/cjs/{components → src/components}/Panel/HeaderIconButton.js +0 -0
  253. /package/dist/cjs/{components → src/components}/Panel/PanelContent.js +0 -0
  254. /package/dist/cjs/{components → src/components}/Panel/PanelLinks.js +0 -0
  255. /package/dist/cjs/{components → src/components}/Panel/PanelPluginLoader.js +0 -0
  256. /package/dist/cjs/{components → src/components}/Panel/index.js +0 -0
  257. /package/dist/cjs/{components → src/components}/PanelDrawer/PanelDrawer.js +0 -0
  258. /package/dist/cjs/{components → src/components}/PanelDrawer/PanelEditorForm.js +0 -0
  259. /package/dist/cjs/{components → src/components}/PanelDrawer/PanelPreview.js +0 -0
  260. /package/dist/cjs/{components → src/components}/PanelDrawer/index.js +0 -0
  261. /package/dist/cjs/{components → src/components}/PanelDrawer/usePanelEditor.js +0 -0
  262. /package/dist/cjs/{components → src/components}/PanelGroupDialog/PanelGroupDialog.js +0 -0
  263. /package/dist/cjs/{components → src/components}/PanelGroupDialog/PanelGroupEditorForm.js +0 -0
  264. /package/dist/cjs/{components → src/components}/PanelGroupDialog/index.js +0 -0
  265. /package/dist/cjs/{components → src/components}/QuerySummaryTable/QuerySummaryTable.js +0 -0
  266. /package/dist/cjs/{components → src/components}/QuerySummaryTable/index.js +0 -0
  267. /package/dist/cjs/{components → src/components}/SaveChangesConfirmationDialog/index.js +0 -0
  268. /package/dist/cjs/{components → src/components}/SaveDashboardButton/SaveDashboardButton.js +0 -0
  269. /package/dist/cjs/{components → src/components}/SaveDashboardButton/index.js +0 -0
  270. /package/dist/cjs/{components → src/components}/Variables/BuiltinVariableAccordions.js +0 -0
  271. /package/dist/cjs/{components → src/components}/Variables/EditVariablesButton.js +0 -0
  272. /package/dist/cjs/{components → src/components}/Variables/Variable.js +0 -0
  273. /package/dist/cjs/{components → src/components}/Variables/VariableEditor.js +0 -0
  274. /package/dist/cjs/{components → src/components}/Variables/VariableList.js +0 -0
  275. /package/dist/cjs/{components → src/components}/Variables/index.js +0 -0
  276. /package/dist/cjs/{components → src/components}/index.js +0 -0
  277. /package/dist/cjs/{constants → src/constants}/grid-layout-config.js +0 -0
  278. /package/dist/cjs/{constants → src/constants}/index.js +0 -0
  279. /package/dist/cjs/{constants → src/constants}/styles.js +0 -0
  280. /package/dist/cjs/{constants → src/constants}/user-interface-text.js +0 -0
  281. /package/dist/cjs/{context → src/context}/DashboardProvider/DashboardProvider.js +0 -0
  282. /package/dist/cjs/{context → src/context}/DashboardProvider/DashboardProviderWithQueryParams.js +0 -0
  283. /package/dist/cjs/{context → src/context}/DashboardProvider/common.js +0 -0
  284. /package/dist/cjs/{context → src/context}/DashboardProvider/dashboard-provider-api.js +0 -0
  285. /package/dist/cjs/{context → src/context}/DashboardProvider/delete-panel-group-slice.js +0 -0
  286. /package/dist/cjs/{context → src/context}/DashboardProvider/delete-panel-slice.js +0 -0
  287. /package/dist/cjs/{context → src/context}/DashboardProvider/discard-changes-dialog-slice.js +0 -0
  288. /package/dist/cjs/{context → src/context}/DashboardProvider/duplicate-panel-slice.js +0 -0
  289. /package/dist/cjs/{context → src/context}/DashboardProvider/edit-json-dialog-slice.js +0 -0
  290. /package/dist/cjs/{context → src/context}/DashboardProvider/index.js +0 -0
  291. /package/dist/cjs/{context → src/context}/DashboardProvider/panel-editor-slice.js +0 -0
  292. /package/dist/cjs/{context → src/context}/DashboardProvider/panel-group-editor-slice.js +0 -0
  293. /package/dist/cjs/{context → src/context}/DashboardProvider/panel-group-slice.js +0 -0
  294. /package/dist/cjs/{context → src/context}/DashboardProvider/panel-slice.js +0 -0
  295. /package/dist/cjs/{context → src/context}/DashboardProvider/save-changes-dialog-slice.js +0 -0
  296. /package/dist/cjs/{context → src/context}/DashboardProvider/view-panel-slice.js +0 -0
  297. /package/dist/cjs/{context → src/context}/DatasourceStoreProvider.js +0 -0
  298. /package/dist/cjs/{context → src/context}/VariableProvider/VariableProvider.js +0 -0
  299. /package/dist/cjs/{context → src/context}/VariableProvider/hydrationUtils.js +0 -0
  300. /package/dist/cjs/{context → src/context}/VariableProvider/index.js +0 -0
  301. /package/dist/cjs/{context → src/context}/VariableProvider/query-params.js +0 -0
  302. /package/dist/cjs/{context → src/context}/VariableProvider/utils.js +0 -0
  303. /package/dist/cjs/{context → src/context}/index.js +0 -0
  304. /package/dist/cjs/{context → src/context}/useDashboard.js +0 -0
  305. /package/dist/cjs/{index.js → src/index.js} +0 -0
  306. /package/dist/cjs/{test → src/test}/dashboard-provider.js +0 -0
  307. /package/dist/cjs/{test → src/test}/datasource-provider.js +0 -0
  308. /package/dist/cjs/{test → src/test}/index.js +0 -0
  309. /package/dist/cjs/{test → src/test}/plugin-registry.js +0 -0
  310. /package/dist/cjs/{test → src/test}/render.js +0 -0
  311. /package/dist/cjs/{test → src/test}/setup-tests.js +0 -0
  312. /package/dist/cjs/{test → src/test}/testDashboard.js +0 -0
  313. /package/dist/cjs/{utils → src/utils}/index.js +0 -0
  314. /package/dist/cjs/{utils → src/utils}/panelUtils.js +0 -0
  315. /package/dist/cjs/{views → src/views}/ViewDashboard/DashboardApp.js +0 -0
  316. /package/dist/cjs/{views → src/views}/ViewDashboard/ViewDashboard.js +0 -0
  317. /package/dist/cjs/{views → src/views}/ViewDashboard/index.js +0 -0
  318. /package/dist/cjs/{views → src/views}/index.js +0 -0
  319. /package/dist/{components → src/components}/AddGroupButton/AddGroupButton.js +0 -0
  320. /package/dist/{components → src/components}/AddGroupButton/index.js +0 -0
  321. /package/dist/{components → src/components}/AddPanelButton/AddPanelButton.js +0 -0
  322. /package/dist/{components → src/components}/AddPanelButton/index.js +0 -0
  323. /package/dist/{components → src/components}/Dashboard/Dashboard.js +0 -0
  324. /package/dist/{components → src/components}/Dashboard/index.js +0 -0
  325. /package/dist/{components → src/components}/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -0
  326. /package/dist/{components → src/components}/DashboardStickyToolbar/index.js +0 -0
  327. /package/dist/{components → src/components}/DashboardToolbar/DashboardToolbar.js +0 -0
  328. /package/dist/{components → src/components}/DashboardToolbar/index.js +0 -0
  329. /package/dist/{components → src/components}/Datasources/DatasourceEditor.js +0 -0
  330. /package/dist/{components → src/components}/Datasources/EditDatasourcesButton.js +0 -0
  331. /package/dist/{components → src/components}/Datasources/index.js +0 -0
  332. /package/dist/{components → src/components}/DeletePanelDialog/DeletePanelDialog.js +0 -0
  333. /package/dist/{components → src/components}/DeletePanelDialog/index.js +0 -0
  334. /package/dist/{components → src/components}/DeletePanelGroupDialog/DeletePanelGroupDialog.js +0 -0
  335. /package/dist/{components → src/components}/DeletePanelGroupDialog/index.js +0 -0
  336. /package/dist/{components → src/components}/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +0 -0
  337. /package/dist/{components → src/components}/DiscardChangesConfirmationDialog/index.js +0 -0
  338. /package/dist/{components → src/components}/DownloadButton/DownloadButton.js +0 -0
  339. /package/dist/{components → src/components}/DownloadButton/index.js +0 -0
  340. /package/dist/{components → src/components}/DownloadButton/serializeDashboard.js +0 -0
  341. /package/dist/{components → src/components}/EditButton/EditButton.js +0 -0
  342. /package/dist/{components → src/components}/EditButton/index.js +0 -0
  343. /package/dist/{components → src/components}/EditJsonButton/EditJsonButton.js +0 -0
  344. /package/dist/{components → src/components}/EditJsonButton/index.js +0 -0
  345. /package/dist/{components → src/components}/EditJsonDialog/EditJsonDialog.js +0 -0
  346. /package/dist/{components → src/components}/EditJsonDialog/index.js +0 -0
  347. /package/dist/{components → src/components}/EmptyDashboard/EmptyDashboard.js +0 -0
  348. /package/dist/{components → src/components}/EmptyDashboard/index.js +0 -0
  349. /package/dist/{components → src/components}/GridLayout/GridContainer.js +0 -0
  350. /package/dist/{components → src/components}/GridLayout/GridItemContent.js +0 -0
  351. /package/dist/{components → src/components}/GridLayout/GridLayout.js +0 -0
  352. /package/dist/{components → src/components}/GridLayout/GridTitle.js +0 -0
  353. /package/dist/{components → src/components}/GridLayout/index.js +0 -0
  354. /package/dist/{components → src/components}/Panel/HeaderIconButton.js +0 -0
  355. /package/dist/{components → src/components}/Panel/PanelContent.js +0 -0
  356. /package/dist/{components → src/components}/Panel/PanelLinks.js +0 -0
  357. /package/dist/{components → src/components}/Panel/PanelPluginLoader.js +0 -0
  358. /package/dist/{components → src/components}/Panel/index.js +0 -0
  359. /package/dist/{components → src/components}/PanelDrawer/PanelDrawer.js +0 -0
  360. /package/dist/{components → src/components}/PanelDrawer/PanelEditorForm.js +0 -0
  361. /package/dist/{components → src/components}/PanelDrawer/PanelPreview.js +0 -0
  362. /package/dist/{components → src/components}/PanelDrawer/index.js +0 -0
  363. /package/dist/{components → src/components}/PanelDrawer/usePanelEditor.js +0 -0
  364. /package/dist/{components → src/components}/PanelGroupDialog/PanelGroupDialog.js +0 -0
  365. /package/dist/{components → src/components}/PanelGroupDialog/PanelGroupEditorForm.js +0 -0
  366. /package/dist/{components → src/components}/PanelGroupDialog/index.js +0 -0
  367. /package/dist/{components → src/components}/QuerySummaryTable/QuerySummaryTable.js +0 -0
  368. /package/dist/{components → src/components}/QuerySummaryTable/index.js +0 -0
  369. /package/dist/{components → src/components}/SaveChangesConfirmationDialog/index.js +0 -0
  370. /package/dist/{components → src/components}/SaveDashboardButton/SaveDashboardButton.js +0 -0
  371. /package/dist/{components → src/components}/SaveDashboardButton/index.js +0 -0
  372. /package/dist/{components → src/components}/Variables/BuiltinVariableAccordions.js +0 -0
  373. /package/dist/{components → src/components}/Variables/EditVariablesButton.js +0 -0
  374. /package/dist/{components → src/components}/Variables/Variable.js +0 -0
  375. /package/dist/{components → src/components}/Variables/VariableEditor.js +0 -0
  376. /package/dist/{components → src/components}/Variables/VariableList.js +0 -0
  377. /package/dist/{components → src/components}/Variables/index.js +0 -0
  378. /package/dist/{components → src/components}/index.js +0 -0
  379. /package/dist/{constants → src/constants}/grid-layout-config.js +0 -0
  380. /package/dist/{constants → src/constants}/index.js +0 -0
  381. /package/dist/{constants → src/constants}/styles.js +0 -0
  382. /package/dist/{constants → src/constants}/user-interface-text.js +0 -0
  383. /package/dist/{context → src/context}/DashboardProvider/DashboardProvider.js +0 -0
  384. /package/dist/{context → src/context}/DashboardProvider/DashboardProviderWithQueryParams.js +0 -0
  385. /package/dist/{context → src/context}/DashboardProvider/common.js +0 -0
  386. /package/dist/{context → src/context}/DashboardProvider/dashboard-provider-api.js +0 -0
  387. /package/dist/{context → src/context}/DashboardProvider/delete-panel-group-slice.js +0 -0
  388. /package/dist/{context → src/context}/DashboardProvider/delete-panel-slice.js +0 -0
  389. /package/dist/{context → src/context}/DashboardProvider/discard-changes-dialog-slice.js +0 -0
  390. /package/dist/{context → src/context}/DashboardProvider/duplicate-panel-slice.js +0 -0
  391. /package/dist/{context → src/context}/DashboardProvider/edit-json-dialog-slice.js +0 -0
  392. /package/dist/{context → src/context}/DashboardProvider/index.js +0 -0
  393. /package/dist/{context → src/context}/DashboardProvider/panel-editor-slice.js +0 -0
  394. /package/dist/{context → src/context}/DashboardProvider/panel-group-editor-slice.js +0 -0
  395. /package/dist/{context → src/context}/DashboardProvider/panel-group-slice.js +0 -0
  396. /package/dist/{context → src/context}/DashboardProvider/panel-slice.js +0 -0
  397. /package/dist/{context → src/context}/DashboardProvider/save-changes-dialog-slice.js +0 -0
  398. /package/dist/{context → src/context}/DashboardProvider/view-panel-slice.js +0 -0
  399. /package/dist/{context → src/context}/DatasourceStoreProvider.js +0 -0
  400. /package/dist/{context → src/context}/VariableProvider/VariableProvider.js +0 -0
  401. /package/dist/{context → src/context}/VariableProvider/hydrationUtils.js +0 -0
  402. /package/dist/{context → src/context}/VariableProvider/index.js +0 -0
  403. /package/dist/{context → src/context}/VariableProvider/query-params.js +0 -0
  404. /package/dist/{context → src/context}/VariableProvider/utils.js +0 -0
  405. /package/dist/{context → src/context}/index.js +0 -0
  406. /package/dist/{context → src/context}/useDashboard.js +0 -0
  407. /package/dist/{index.js → src/index.js} +0 -0
  408. /package/dist/{test → src/test}/dashboard-provider.js +0 -0
  409. /package/dist/{test → src/test}/datasource-provider.js +0 -0
  410. /package/dist/{test → src/test}/index.js +0 -0
  411. /package/dist/{test → src/test}/plugin-registry.js +0 -0
  412. /package/dist/{test → src/test}/render.js +0 -0
  413. /package/dist/{test → src/test}/setup-tests.js +0 -0
  414. /package/dist/{test → src/test}/testDashboard.js +0 -0
  415. /package/dist/{utils → src/utils}/index.js +0 -0
  416. /package/dist/{utils → src/utils}/panelUtils.js +0 -0
  417. /package/dist/{views → src/views}/ViewDashboard/DashboardApp.js +0 -0
  418. /package/dist/{views → src/views}/ViewDashboard/ViewDashboard.js +0 -0
  419. /package/dist/{views → src/views}/ViewDashboard/index.js +0 -0
  420. /package/dist/{views → src/views}/index.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/DashboardProvider/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './common';\nexport * from './dashboard-provider-api';\nexport * from './DashboardProvider';\nexport type {\n PanelGroupDefinition,\n PanelGroupItemId,\n PanelGroupItemLayoutId,\n PanelGroupItemLayout,\n} from './panel-group-slice';\nexport type { PanelGroupEditor, PanelGroupEditorValues } from './panel-group-editor-slice';\nexport type { DeletePanelDialogState } from './delete-panel-slice';\nexport type { DiscardChangesConfirmationDialogState } from './discard-changes-dialog-slice';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,WAAW;AACzB,cAAc,2BAA2B;AACzC,cAAc,sBAAsB"}
@@ -0,0 +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 { Action, PanelEditorValues, PanelGroupId } from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { getYForNewRow, getValidPanelKey } from '../../utils';\nimport { generateId, Middleware, createPanelDefinition } from './common';\nimport {\n PanelGroupSlice,\n PanelGroupItemId,\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 * 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): void {\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): void {\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","panels","panelGroups","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,c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E,mBAAmBvB;oBAC3D;oBACAwB,cAAc,CAACC;wBACb,MAAMsB,OAAOtB,KAAKF,eAAe,CAACyB,IAAI,CAACC,OAAO,CAACF,IAAI;wBACnD,MAAMhC,WAAWjB,iBAAiBiD,MAAM1C,MAAMK,MAAM;wBAEpDN,IAAI,CAACsB;4BACH,cAAc;4BACdA,MAAMhB,MAAM,CAACK,SAAS,GAAGU,KAAKF,eAAe;4BAE7C,oDAAoD;4BACpD,MAAM2B,QAAQxB,MAAMf,WAAW,CAACc,KAAKH,OAAO,CAAC;4BAC7C,IAAI4B,UAAU3C,WAAW;gCACvB,MAAM,IAAIU,MAAM,CAAC,oBAAoB,EAAEQ,KAAKH,OAAO,EAAE;4BACvD;4BACA,MAAMS,SAA+B;gCACnCC,GAAGjC,aAAaoD,QAAQ;gCACxBb,GAAG;gCACHC,GAAG1C,cAAcqD;gCACjBV,GAAG;gCACHC,GAAG;4BACL;4BACAS,MAAMrB,WAAW,CAACQ,IAAI,CAACN;4BACvBmB,MAAMlC,aAAa,CAACe,OAAOC,CAAC,CAAC,GAAGjB;wBAClC;oBACF;oBACA2B,OAAO;wBACLtC,IAAI,CAACsB;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"}
@@ -0,0 +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 { PanelGroupId } from '@perses-dev/core';\nimport { Middleware } from './common';\nimport { PanelGroupSlice, 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: (): void => {\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): void => {\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;AAKjC,SAA0BA,aAAa,EAAEC,qBAAqB,QAAQ,sBAAsB;AAkC5F,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;YAEA,0BAA0B;YAC1B,MAAMX,SAA2B;gBAC/BC,MAAM;gBACNC,eAAe;oBACbC,OAAOS,cAAcT,KAAK,IAAI;oBAC9BC,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"}
@@ -0,0 +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, PanelGroupId } from '@perses-dev/core';\n\nimport { Layout } from 'react-grid-layout';\nimport { StateCreator } from 'zustand';\nimport { WritableDraft } from 'immer';\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 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 * Check if two PanelGroupItemId are equal\n */\nexport function isPanelGroupItemIdEqual(a?: PanelGroupItemId, b?: PanelGroupItemId): boolean {\n return a?.panelGroupId === b?.panelGroupId && a?.panelGroupItemLayoutId === b?.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): void {\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): void {\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): void {\n draft.panelGroups[newGroup.id] = newGroup;\n draft.panelGroupOrder.unshift(newGroup.id);\n}\n"],"names":["getPanelKeyFromRef","generateId","isPanelGroupItemIdEqual","a","b","panelGroupId","panelGroupItemLayoutId","createPanelGroupSlice","layouts","panelGroups","panelGroupOrder","convertLayoutsToPanelGroups","set","swapPanelGroups","x","y","state","length","Error","xPanelGroup","yPanelGroup","undefined","updatePanelGroupLayouts","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,QAAwC,mBAAmB;AAKtF,SAASC,UAAU,QAAoB,WAAW;AAiDlD;;CAEC,GACD,OAAO,SAASC,wBAAwBC,CAAoB,EAAEC,CAAoB;IAChF,OAAOD,GAAGE,iBAAiBD,GAAGC,gBAAgBF,GAAGG,2BAA2BF,GAAGE;AACjF;AAEA;;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,IAAI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Q,WAAW,CAACJ,aAAa,GAAG;YAC1BmC,IAAInC;YACJoC,aAAaf,OAAOG,IAAI,CAACa,OAAO,EAAEC,UAAUC,SAAS;YACrDC,OAAOnB,OAAOG,IAAI,CAACa,OAAO,EAAEG;YAC5BtB;YACAI;QACF;QACAF,kBAAkBQ,IAAI,CAAC5B;IACzB;IACA,OAAO;QACLI;QACAC,iBAAiBe;IACnB;AACF;AAEA;;CAEC,GACD,OAAO,SAASqB;IACd,OAAO;QACLN,IAAIvC;QACJ4C,OAAOxB;QACPoB,aAAa;QACblB,aAAa,EAAE;QACfI,eAAe,CAAC;IAClB;AACF;AAEA;;CAEC,GACD,OAAO,SAASoB,cAAcC,KAAqC,EAAEC,QAA8B;IACjGD,MAAMvC,WAAW,CAACwC,SAAST,EAAE,CAAC,GAAGS;IACjCD,MAAMtC,eAAe,CAACwC,OAAO,CAACD,SAAST,EAAE;AAC3C"}
@@ -0,0 +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,iBAAiBC,MAA4B;IAC3D,OAAO,IAAO,CAAA;YACZA;QACF,CAAA;AACF"}
@@ -0,0 +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): void {\n set(\n (state) => {\n state.saveChangesConfirmationDialog = dialog;\n },\n false,\n 'openSaveChangesConfirmationDialog'\n );\n },\n\n closeSaveChangesConfirmationDialog(): void {\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"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/DashboardProvider/view-panel-slice.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StateCreator } from 'zustand';\nimport { PanelGroupDefinition, PanelGroupItemId } from '@perses-dev/dashboards';\nimport { PanelGroupId } from '@perses-dev/core';\nimport { Middleware } from './common';\nimport { PanelGroupSlice } from './panel-group-slice';\n\n/**\n * Slice that handles viewing Panels in max size (\"full screen\").\n */\nexport interface ViewPanelSlice {\n viewPanel: ViewPanelState;\n getViewPanel: () => PanelGroupItemId | undefined;\n setViewPanel: (panelGroupItemId?: PanelGroupItemId) => void;\n}\n\nexport interface ViewPanelState {\n // Do not use directly, use `getViewPanel()` instead for getting the current viewed PanelGroupItemId!\n panelGroupItemId?: PanelGroupItemId;\n panelRef?: string;\n}\n\n/**\n * Curried function for viewing panel in max size (\"full screen\").\n */\nexport function createViewPanelSlice(\n viewPanelRef?: string,\n setViewPanelRef?: (ref: string | undefined) => void\n): StateCreator<ViewPanelSlice & PanelGroupSlice, Middleware, [], ViewPanelSlice> {\n return (set, get) => ({\n viewPanel: {\n panelGroupItemId: undefined,\n panelRef: viewPanelRef,\n },\n\n getViewPanel(): PanelGroupItemId | undefined {\n return getViewPanelGroupId(get().panelGroups, get().viewPanel.panelGroupItemId, get().viewPanel.panelRef);\n },\n\n setViewPanel(panelGroupItemId?: PanelGroupItemId): void {\n set((state) => {\n state.viewPanel = {\n panelRef: undefined,\n panelGroupItemId: panelGroupItemId,\n };\n const panelRef = findPanelRefOfPanelGroupItemId(get().panelGroups, panelGroupItemId);\n if (setViewPanelRef) {\n setViewPanelRef(panelRef);\n }\n });\n },\n });\n}\n\nfunction getViewPanelGroupId(\n panelGroups: Record<PanelGroupId, PanelGroupDefinition>,\n panelGroupItemId?: PanelGroupItemId,\n panelRef?: string\n): PanelGroupItemId | undefined {\n if (panelGroupItemId) {\n return panelGroupItemId;\n }\n\n if (panelRef) {\n return findPanelGroupItemIdOfPanelRef(panelGroups, panelRef);\n }\n\n return undefined;\n}\n\n// Find the PanelGroupItemId of a Panel from a PanelRef\nfunction findPanelGroupItemIdOfPanelRef(\n panelGroups: Record<PanelGroupId, PanelGroupDefinition>,\n panelRef?: string\n): PanelGroupItemId | undefined {\n for (const panelGroup of Object.values(panelGroups)) {\n const itemPanel = Object.entries(panelGroup.itemPanelKeys ?? []).find(([_, value]) => value === panelRef);\n if (itemPanel) {\n const [key] = itemPanel;\n return {\n panelGroupId: panelGroup.id,\n panelGroupItemLayoutId: key,\n };\n }\n }\n return undefined;\n}\n\n// Find the PanelRef from a PanelGroupItemId\nfunction findPanelRefOfPanelGroupItemId(\n panelGroups: Record<PanelGroupId, PanelGroupDefinition>,\n panelGroupItemId?: PanelGroupItemId\n): string | undefined {\n if (!panelGroupItemId) {\n return undefined;\n }\n const panelGroup = panelGroups[panelGroupItemId.panelGroupId];\n if (panelGroup) {\n return panelGroup.itemPanelKeys[panelGroupItemId.panelGroupItemLayoutId];\n }\n return undefined;\n}\n"],"names":["createViewPanelSlice","viewPanelRef","setViewPanelRef","set","get","viewPanel","panelGroupItemId","undefined","panelRef","getViewPanel","getViewPanelGroupId","panelGroups","setViewPanel","state","findPanelRefOfPanelGroupItemId","findPanelGroupItemIdOfPanelRef","panelGroup","Object","values","itemPanel","entries","itemPanelKeys","find","_","value","key","panelGroupId","id","panelGroupItemLayoutId"],"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;AAuBjC;;CAEC,GACD,OAAO,SAASA,qBACdC,YAAqB,EACrBC,eAAmD;IAEnD,OAAO,CAACC,KAAKC,MAAS,CAAA;YACpBC,WAAW;gBACTC,kBAAkBC;gBAClBC,UAAUP;YACZ;YAEAQ;gBACE,OAAOC,oBAAoBN,MAAMO,WAAW,EAAEP,MAAMC,SAAS,CAACC,gBAAgB,EAAEF,MAAMC,SAAS,CAACG,QAAQ;YAC1G;YAEAI,cAAaN,gBAAmC;gBAC9CH,IAAI,CAACU;oBACHA,MAAMR,SAAS,GAAG;wBAChBG,UAAUD;wBACVD,kBAAkBA;oBACpB;oBACA,MAAME,WAAWM,+BAA+BV,MAAMO,WAAW,EAAEL;oBACnE,IAAIJ,iBAAiB;wBACnBA,gBAAgBM;oBAClB;gBACF;YACF;QACF,CAAA;AACF;AAEA,SAASE,oBACPC,WAAuD,EACvDL,gBAAmC,EACnCE,QAAiB;IAEjB,IAAIF,kBAAkB;QACpB,OAAOA;IACT;IAEA,IAAIE,UAAU;QACZ,OAAOO,+BAA+BJ,aAAaH;IACrD;IAEA,OAAOD;AACT;AAEA,uDAAuD;AACvD,SAASQ,+BACPJ,WAAuD,EACvDH,QAAiB;IAEjB,KAAK,MAAMQ,cAAcC,OAAOC,MAAM,CAACP,aAAc;QACnD,MAAMQ,YAAYF,OAAOG,OAAO,CAACJ,WAAWK,aAAa,IAAI,EAAE,EAAEC,IAAI,CAAC,CAAC,CAACC,GAAGC,MAAM,GAAKA,UAAUhB;QAChG,IAAIW,WAAW;YACb,MAAM,CAACM,IAAI,GAAGN;YACd,OAAO;gBACLO,cAAcV,WAAWW,EAAE;gBAC3BC,wBAAwBH;YAC1B;QACF;IACF;IACA,OAAOlB;AACT;AAEA,4CAA4C;AAC5C,SAASO,+BACPH,WAAuD,EACvDL,gBAAmC;IAEnC,IAAI,CAACA,kBAAkB;QACrB,OAAOC;IACT;IACA,MAAMS,aAAaL,WAAW,CAACL,iBAAiBoB,YAAY,CAAC;IAC7D,IAAIV,YAAY;QACd,OAAOA,WAAWK,aAAa,CAACf,iBAAiBsB,sBAAsB,CAAC;IAC1E;IACA,OAAOrB;AACT"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/DatasourceStoreProvider.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 { ReactElement, ReactNode, useCallback, useMemo, useState } from 'react';\nimport {\n DashboardResource,\n DashboardSpec,\n DatasourceResource,\n DatasourceSelector,\n DatasourceSpec,\n GlobalDatasourceResource,\n useEvent,\n EphemeralDashboardResource,\n DatasourceDefinition,\n} from '@perses-dev/core';\nimport {\n DatasourceStoreContext,\n DatasourceStore,\n DatasourceSelectItemGroup,\n usePluginRegistry,\n DatasourceClient,\n DatasourceSelectItem,\n} from '@perses-dev/plugin-system';\n\nexport interface DatasourceStoreProviderProps {\n dashboardResource?: DashboardResource | EphemeralDashboardResource;\n projectName?: string;\n datasourceApi: DatasourceApi;\n children?: ReactNode;\n savedDatasources?: Record<string, DatasourceSpec>;\n onCreate?: (client: DatasourceClient) => DatasourceClient;\n}\n\nexport type BuildDatasourceProxyUrlParams = {\n project?: string;\n dashboard?: string;\n name: string;\n};\n\nexport type BuildDatasourceProxyUrlFunc = (p: BuildDatasourceProxyUrlParams) => string;\n\n/**\n * The external API for fetching datasource resources\n */\nexport interface DatasourceApi {\n buildProxyUrl?: BuildDatasourceProxyUrlFunc;\n getDatasource: (project: string, selector: DatasourceSelector) => Promise<DatasourceResource | undefined>;\n getGlobalDatasource: (selector: DatasourceSelector) => Promise<GlobalDatasourceResource | undefined>;\n listDatasources: (project: string, pluginKind?: string) => Promise<DatasourceResource[]>;\n listGlobalDatasources: (pluginKind?: string) => Promise<GlobalDatasourceResource[]>;\n}\n\n/**\n * A `DatasourceContext` provider that uses an external API to resolve datasource selectors.\n */\nexport function DatasourceStoreProvider(props: DatasourceStoreProviderProps): ReactElement {\n const { projectName, datasourceApi, onCreate, children } = props;\n const [dashboardResource, setDashboardResource] = useState(props.dashboardResource);\n const [savedDatasources, setSavedDatasources] = useState<Record<string, DatasourceSpec>>(\n props.savedDatasources ?? {}\n );\n const project = projectName ?? dashboardResource?.metadata.project;\n\n const { getPlugin, listPluginMetadata } = usePluginRegistry();\n\n const findDatasource = useEvent(async (selector: DatasourceSelector) => {\n // Try to find it in dashboard spec\n if (dashboardResource) {\n const { datasources } = dashboardResource.spec;\n const dashboardDatasource = findDashboardDatasource(datasources, selector);\n if (dashboardDatasource !== undefined) {\n return {\n spec: dashboardDatasource.spec,\n proxyUrl: buildDatasourceProxyUrl(datasourceApi, {\n project: dashboardResource.metadata.project,\n dashboard: dashboardResource.metadata.name,\n name: dashboardDatasource.name,\n }),\n };\n }\n }\n\n if (project) {\n // Try to find it at the project level as a Datasource resource\n const datasource = await datasourceApi.getDatasource(project, selector);\n if (datasource !== undefined) {\n return {\n spec: datasource.spec,\n proxyUrl: buildDatasourceProxyUrl(datasourceApi, {\n project: datasource.metadata.project,\n name: datasource.metadata.name,\n }),\n };\n }\n }\n\n // Try to find it at the global level as a GlobalDatasource resource\n const globalDatasource = await datasourceApi.getGlobalDatasource(selector);\n if (globalDatasource !== undefined) {\n return {\n spec: globalDatasource.spec,\n proxyUrl: buildDatasourceProxyUrl(datasourceApi, {\n name: globalDatasource.metadata.name,\n }),\n };\n }\n\n throw new Error(`No datasource found for kind '${selector.kind}' and name '${selector.name}'`);\n });\n\n // Gets a datasource spec for a given selector\n const getDatasource = useCallback(\n async (selector: DatasourceSelector): Promise<DatasourceSpec> => {\n const { spec } = await findDatasource(selector);\n return spec;\n },\n [findDatasource]\n );\n\n // Given a Datasource selector, finds the spec for it and then uses its corresponding plugin the create a client\n const getDatasourceClient = useCallback(\n async function getClient<Client extends DatasourceClient>(selector: DatasourceSelector): Promise<Client> {\n const { kind } = selector;\n const [{ spec, proxyUrl }, plugin] = await Promise.all([findDatasource(selector), getPlugin('Datasource', kind)]);\n\n // allows extending client\n const client = plugin.createClient(spec.plugin.spec, { proxyUrl }) as Client;\n if (onCreate !== undefined) {\n return onCreate(client) as Client;\n }\n return client;\n },\n [findDatasource, getPlugin, onCreate]\n );\n\n const listDatasourceSelectItems = useEvent(\n async (datasourcePluginName: string): Promise<DatasourceSelectItemGroup[]> => {\n const [pluginMetadata, datasources, globalDatasources] = await Promise.all([\n listPluginMetadata(['Datasource']),\n project ? datasourceApi.listDatasources(project, datasourcePluginName) : [],\n datasourceApi.listGlobalDatasources(datasourcePluginName),\n ]);\n\n // Find the metadata for the plugin type they asked for, so we can use it for the name of the default datasource\n const datasourcePluginMetadata = pluginMetadata.find((metadata) => metadata.spec.name === datasourcePluginName);\n if (datasourcePluginMetadata === undefined) {\n throw new Error(`Could not find a Datasource plugin with kind '${datasourcePluginName}'`);\n }\n\n // Get helper for computing results properly\n const { results, addItem } = buildDatasourceSelectItemGroups(datasourcePluginMetadata.spec.display.name);\n\n // Start with dashboard datasources with the highest precedence\n if (dashboardResource?.spec.datasources) {\n for (const selectorName in dashboardResource.spec.datasources) {\n const spec = dashboardResource.spec.datasources[selectorName];\n if (spec === undefined || spec.plugin.kind !== datasourcePluginName) continue;\n\n const saved = selectorName in savedDatasources;\n addItem({ spec, selectorName, selectorGroup: 'dashboard', saved });\n }\n }\n\n // Now look at project-level datasources\n for (const datasource of datasources) {\n const selectorName = datasource.metadata.name;\n addItem({\n spec: datasource.spec,\n selectorName,\n selectorGroup: 'project',\n editLink: `/projects/${project}/datasources`,\n });\n }\n\n // And finally global datasources\n for (const globalDatasource of globalDatasources) {\n const selectorName = globalDatasource.metadata.name;\n addItem({ spec: globalDatasource.spec, selectorName, selectorGroup: 'global', editLink: '/admin/datasources' });\n }\n\n return results;\n }\n );\n\n const getLocalDatasources = useCallback((): Record<string, DatasourceSpec> => {\n return dashboardResource?.spec.datasources ?? {};\n }, [dashboardResource]);\n\n const getSavedDatasources = useCallback((): Record<string, DatasourceSpec> => {\n return savedDatasources;\n }, [savedDatasources]);\n\n const setLocalDatasources = useCallback(\n (datasources: Record<string, DatasourceSpec>) => {\n if (dashboardResource) {\n setDashboardResource(\n dashboardResource.kind === 'Dashboard'\n ? ({\n ...dashboardResource,\n spec: {\n ...dashboardResource.spec,\n datasources: datasources,\n },\n } as DashboardResource)\n : ({\n ...dashboardResource,\n spec: {\n ...dashboardResource.spec,\n datasources: datasources,\n },\n } as EphemeralDashboardResource)\n );\n }\n },\n [dashboardResource]\n );\n\n const ctxValue: DatasourceStore = useMemo(\n () =>\n ({\n getDatasource,\n getDatasourceClient,\n getLocalDatasources,\n setLocalDatasources,\n setSavedDatasources,\n getSavedDatasources,\n listDatasourceSelectItems,\n }) as DatasourceStore,\n [\n getDatasource,\n getDatasourceClient,\n getLocalDatasources,\n setLocalDatasources,\n listDatasourceSelectItems,\n setSavedDatasources,\n getSavedDatasources,\n ]\n );\n\n return <DatasourceStoreContext.Provider value={ctxValue}>{children}</DatasourceStoreContext.Provider>;\n}\n\nfunction buildDatasourceProxyUrl(api: DatasourceApi, params: BuildDatasourceProxyUrlParams): string {\n return api.buildProxyUrl ? api.buildProxyUrl(params) : '';\n}\n\n// Helper to find a datasource in the list embedded in a dashboard spec\nfunction findDashboardDatasource(\n dashboardDatasources: DashboardSpec['datasources'],\n selector: DatasourceSelector\n): DatasourceDefinition | undefined {\n if (dashboardDatasources === undefined) return undefined;\n\n // If using a name in the selector...\n if (selector.name !== undefined) {\n const named = dashboardDatasources[selector.name];\n if (named === undefined) return undefined;\n return named.plugin.kind === selector.kind ? { name: selector.name, spec: named } : undefined;\n }\n\n // If only using a kind, try to find one with that kind that is the default\n const result = Object.entries(dashboardDatasources).find(\n (entry) => entry[1].plugin.kind === selector.kind && entry[1].default\n );\n if (!result) {\n return undefined;\n }\n return { name: result[0], spec: result[1] };\n}\n\ninterface AddDatasouceSelectItemParams {\n spec: DatasourceSpec;\n selectorName: string;\n selectorGroup?: string;\n editLink?: string;\n saved?: boolean;\n}\n\ntype AddDatasourceSelectItemFunc = (params: AddDatasouceSelectItemParams) => void;\n\n/**\n * Helper for building a list of DatasourceSelectItemGroup results.\n * @param pluginDisplayName\n */\nfunction buildDatasourceSelectItemGroups(pluginDisplayName: string): {\n results: DatasourceSelectItemGroup[];\n addItem: AddDatasourceSelectItemFunc;\n} {\n const results: DatasourceSelectItemGroup[] = [];\n const usedNames = new Set<string>();\n let isFirst = true;\n let explicitDefaultAdded = false;\n const groupIndices: Record<string, number> = {};\n let currentGroupIndex = 1; // 0 is the default group, always there as it contains at least the first item.\n\n const addItem = ({\n spec,\n selectorName,\n selectorGroup: group,\n editLink,\n saved,\n }: AddDatasouceSelectItemParams): void => {\n group = group ?? '';\n\n // Ensure the default group is always present as soon as an item is added.\n if (isFirst) {\n results.push({\n group: `Default ${pluginDisplayName}`,\n items: [],\n });\n }\n\n // Create the group if necessary\n let selectItemGroup = results[groupIndices[group] ?? -1];\n if (!selectItemGroup) {\n groupIndices[group] = currentGroupIndex;\n selectItemGroup = { items: [], group, editLink };\n results[currentGroupIndex] = selectItemGroup;\n currentGroupIndex++;\n }\n\n // Add item to the group\n const isOverridden = usedNames.has(selectorName);\n selectItemGroup.items.push({\n name: spec.display?.name ?? selectorName,\n overridden: isOverridden,\n saved,\n selector: {\n kind: spec.plugin.kind,\n name: selectorName,\n group,\n },\n });\n usedNames.add(selectorName);\n\n const isExplicitDefault = !isOverridden && spec.default && !explicitDefaultAdded;\n if (results[0] && (isFirst || isExplicitDefault)) {\n // If we haven't added a default yet and this is a default, add default option to the beginning of the results\n results[0].items = [\n {\n name: `Default (${selectorName} from ${group})`,\n selector: {\n kind: spec.plugin.kind,\n },\n },\n ];\n // We consider that we added the default datasource only if it has been explicitly set as default.\n // If we add this datasource as default just because it's the first, it still needs to be overridable by\n // another datasource explicitly set as default.\n explicitDefaultAdded = isExplicitDefault;\n }\n\n // At the end, we make sure the overriding item(s) is well flagged so\n if (isOverridden) {\n for (let i = explicitDefaultAdded ? 1 : 0; i < currentGroupIndex; i++) {\n (results[i]?.items ?? [])\n .filter((item: DatasourceSelectItem) => item.selector.name === selectorName)\n .forEach((item: DatasourceSelectItem) => {\n item.overriding = true;\n });\n }\n }\n\n isFirst = false;\n };\n\n return { results, addItem };\n}\n"],"names":["useCallback","useMemo","useState","useEvent","DatasourceStoreContext","usePluginRegistry","DatasourceStoreProvider","props","projectName","datasourceApi","onCreate","children","dashboardResource","setDashboardResource","savedDatasources","setSavedDatasources","project","metadata","getPlugin","listPluginMetadata","findDatasource","selector","datasources","spec","dashboardDatasource","findDashboardDatasource","undefined","proxyUrl","buildDatasourceProxyUrl","dashboard","name","datasource","getDatasource","globalDatasource","getGlobalDatasource","Error","kind","getDatasourceClient","getClient","plugin","Promise","all","client","createClient","listDatasourceSelectItems","datasourcePluginName","pluginMetadata","globalDatasources","listDatasources","listGlobalDatasources","datasourcePluginMetadata","find","results","addItem","buildDatasourceSelectItemGroups","display","selectorName","saved","selectorGroup","editLink","getLocalDatasources","getSavedDatasources","setLocalDatasources","ctxValue","Provider","value","api","params","buildProxyUrl","dashboardDatasources","named","result","Object","entries","entry","default","pluginDisplayName","usedNames","Set","isFirst","explicitDefaultAdded","groupIndices","currentGroupIndex","group","push","items","selectItemGroup","isOverridden","has","overridden","add","isExplicitDefault","i","filter","item","forEach","overriding"],"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,SAAkCA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAChF,SAOEC,QAAQ,QAGH,mBAAmB;AAC1B,SACEC,sBAAsB,EAGtBC,iBAAiB,QAGZ,4BAA4B;AA8BnC;;CAEC,GACD,OAAO,SAASC,wBAAwBC,KAAmC;IACzE,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGJ;IAC3D,MAAM,CAACK,mBAAmBC,qBAAqB,GAAGX,SAASK,MAAMK,iBAAiB;IAClF,MAAM,CAACE,kBAAkBC,oBAAoB,GAAGb,SAC9CK,MAAMO,gBAAgB,IAAI,CAAC;IAE7B,MAAME,UAAUR,eAAeI,mBAAmBK,SAASD;IAE3D,MAAM,EAAEE,SAAS,EAAEC,kBAAkB,EAAE,GAAGd;IAE1C,MAAMe,iBAAiBjB,SAAS,OAAOkB;QACrC,mCAAmC;QACnC,IAAIT,mBAAmB;YACrB,MAAM,EAAEU,WAAW,EAAE,GAAGV,kB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,IAAI,KAAK0B,cAC9DuC,OAAO,CAAC,CAACD;oBACRA,KAAKE,UAAU,GAAG;gBACpB;YACJ;QACF;QAEAjB,UAAU;IACZ;IAEA,OAAO;QAAE3B;QAASC;IAAQ;AAC5B"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/VariableProvider/VariableProvider.tsx"],"sourcesContent":["// Copyright 2024 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 { createContext, ReactElement, ReactNode, useContext, useMemo, useState } from 'react';\nimport { createStore, StoreApi, useStore } from 'zustand';\nimport { useStoreWithEqualityFn } from 'zustand/traditional';\nimport { immer } from 'zustand/middleware/immer';\nimport { devtools } from 'zustand/middleware';\nimport { shallow } from 'zustand/shallow';\nimport { produce } from 'immer';\nimport {\n VariableContext,\n VariableStateMap,\n VariableState,\n VariableStoreStateMap,\n VariableOption,\n BuiltinVariableContext,\n useTimeRange,\n} from '@perses-dev/plugin-system';\nimport {\n DEFAULT_ALL_VALUE as ALL_VALUE,\n VariableName,\n VariableValue,\n VariableDefinition,\n formatDuration,\n intervalToPrometheusDuration,\n BuiltinVariableDefinition,\n TextVariableDefinition,\n ListVariableDefinition,\n} from '@perses-dev/core';\nimport { checkSavedDefaultVariableStatus, findVariableDefinitionByName, mergeVariableDefinitions } from './utils';\nimport { hydrateVariableDefinitionStates as hydrateVariableDefinitionStates } from './hydrationUtils';\nimport { getInitalValuesFromQueryParameters, getURLQueryParamName, useVariableQueryParams } from './query-params';\n\n/**\n * This store is used to manipulate and read the definition of the variables and their state.\n * - being local or external variables.\n * - being text or list variables.\n * - being of any state (value, options, loading, error, ...) check {@VariableState}\n * Go and read each property documentation for more details.\n */\ntype VariableDefinitionStore = {\n /**\n * List of local variables definitions.\n * This is typically the variable definition that can be modified through the setVariableDefinition setter.\n *\n * In Perses App ecosystem, this is typically the dashboard scope variables, that's why we call them local.\n * Note that depending on the form, we can reuse this store to modify higher scope variables. For example,\n * when we modify the variable of a project, we'll set this field with project scope variables. To be able to modify\n * them.\n */\n variableDefinitions: VariableDefinition[];\n /**\n * List of external variable definitions.\n * This is static variable definitions that won´t be modified under this context.\n * You'll have to set one list of external variable definition by scope. See {@link ExternalVariableDefinition} for\n * more details.\n *\n * In Perses App ecosystem, this is typically the project or global scope variables.\n * Note that depending on the form, we can reuse this store to modify higher scope variables. For example,\n * when we modify the variable of a project, we'll set this field with global scope variables. Which means we\n * won't be able to modify them from this form.\n */\n externalVariableDefinitions: ExternalVariableDefinition[];\n /**\n * Additionally to definitions, we need to associate to each variable a state. That's what this map is meant for.\n * This can be heavily modified under this context, using the different setters available.\n * Note that the state of local AND external variables can be modified.\n */\n variableState: VariableStoreStateMap;\n /**\n * Allow to modify the `value` property of a variable in the state map.\n * @param variableName identify the variable\n * @param value new value\n * @param source identify the variable source if this is an external variable. See {@link ExternalVariableDefinition}\n */\n setVariableValue: (variableName: VariableName, value: VariableValue, source?: string) => void;\n /**\n * Allow to modify the `options` property of a variable in the state map.\n * @param variableName identify the variable\n * @param options new value\n * @param source identify the variable source if this is an external variable. See {@link ExternalVariableDefinition}\n */\n setVariableOptions: (name: VariableName, options: VariableOption[], source?: string) => void;\n /**\n * Allow to modify the `loading` property of a variable in the state map.\n * @param variableName identify the variable\n * @param laoding new value\n * @param source identify the variable source if this is an external variable. See {@link ExternalVariableDefinition}\n */\n setVariableLoading: (name: VariableName, loading: boolean, source?: string) => void;\n setVariableDefinitions: (definitions: VariableDefinition[]) => void;\n setVariableDefaultValues: () => VariableDefinition[];\n getSavedVariablesStatus: () => { isSavedVariableModified: boolean; modifiedVariableNames: string[] };\n};\n\n/**\n * Context object for {@link VariableDefinitionStore}.\n */\nconst VariableDefinitionStoreContext = createContext<StoreApi<VariableDefinitionStore> | undefined>(undefined);\nexport function useVariableDefinitionStoreCtx(): StoreApi<VariableDefinitionStore> {\n const context = useContext(VariableDefinitionStoreContext);\n if (!context) {\n throw new Error('VariableStoreContext not initialized');\n }\n return context;\n}\n\nexport function useVariableDefinitionStates(variableNames?: string[]): VariableStateMap {\n const store = useVariableDefinitionStoreCtx();\n return useStoreWithEqualityFn(\n store,\n (s) => {\n const varStates: VariableStateMap = {};\n\n // Collect values of local variables, from the variable state\n const names = variableNames ?? s.variableDefinitions.map((value) => value.spec.name);\n names.forEach((name) => {\n const varState = s.variableState.get({ name });\n if (!varState || varState.overridden) {\n return;\n }\n varStates[name] = varState;\n });\n\n // Collect values of external variables, from the variable state\n s.externalVariableDefinitions.forEach((d) => {\n const source = d.source;\n d.definitions.forEach((value) => {\n const name = value.spec.name;\n const varState = s.variableState.get({ name, source });\n if (!varState || varState.overridden) {\n return;\n }\n varStates[name] = varState;\n });\n });\n\n return varStates;\n },\n (left, right) => {\n return JSON.stringify(left) === JSON.stringify(right);\n }\n );\n}\n\n/**\n * Get the state and definition of a variable from the variables context.\n * @param name name of the variable\n * @param source if given, it searches in the external variables\n */\nexport function useVariableDefinitionAndState(\n name: string,\n source?: string\n): {\n definition: TextVariableDefinition | ListVariableDefinition | undefined;\n state: VariableState | undefined;\n} {\n const store = useVariableDefinitionStoreCtx();\n return useStore(store, (s) => {\n const state = s.variableState.get({ name, source });\n const definitions = source\n ? s.externalVariableDefinitions.find((v) => v.source === source)?.definitions\n : s.variableDefinitions;\n const definition = (definitions || []).find((v) => v.spec.name === name);\n\n return { state, definition };\n });\n}\n\nexport function useVariableDefinitionActions(): {\n setVariableLoading: (name: VariableName, loading: boolean, source?: string) => void;\n getSavedVariablesStatus: () => { isSavedVariableModified: boolean; modifiedVariableNames: string[] };\n setVariableDefaultValues: () => VariableDefinition[];\n setVariableValue: (variableName: VariableName, value: VariableValue, source?: string) => void;\n setVariableOptions: (name: VariableName, options: VariableOption[], source?: string) => void;\n setVariableDefinitions: (definitions: VariableDefinition[]) => void;\n} {\n const store = useVariableDefinitionStoreCtx();\n return useStoreWithEqualityFn(\n store,\n (s) => {\n return {\n setVariableValue: s.setVariableValue,\n setVariableLoading: s.setVariableLoading,\n setVariableOptions: s.setVariableOptions,\n setVariableDefinitions: s.setVariableDefinitions,\n setVariableDefaultValues: s.setVariableDefaultValues,\n getSavedVariablesStatus: s.getSavedVariablesStatus,\n };\n },\n shallow\n );\n}\n\nexport function useVariableDefinitions(): VariableDefinition[] {\n const store = useVariableDefinitionStoreCtx();\n return useStore(store, (s) => s.variableDefinitions);\n}\n\nexport function useExternalVariableDefinitions(): ExternalVariableDefinition[] {\n const store = useVariableDefinitionStoreCtx();\n return useStore(store, (s) => s.externalVariableDefinitions);\n}\n\ninterface PluginProviderProps {\n children: ReactNode;\n builtinVariables?: BuiltinVariableDefinition[];\n}\n\nfunction PluginProvider({ children, builtinVariables }: PluginProviderProps): ReactElement {\n const originalValues = useVariableDefinitionStates();\n const definitions = useVariableDefinitions();\n const externalDefinitions = useExternalVariableDefinitions();\n const { absoluteTimeRange } = useTimeRange();\n\n const values = useMemo(() => {\n const contextValues: VariableStateMap = {};\n\n // This will loop through all the current variables values\n // and update any variables that have ALL_VALUE as their current value\n // to include all options.\n Object.keys(originalValues).forEach((name) => {\n const v = { ...originalValues[name] } as VariableState;\n\n if (v.value === ALL_VALUE) {\n const definition = findVariableDefinitionByName(name, definitions, externalDefinitions);\n // If the variable is a list variable and has a custom all value, then use that value instead\n if (definition?.kind === 'ListVariable' && definition.spec.customAllValue) {\n v.value = definition.spec.customAllValue;\n } else {\n v.value = v.options?.map((o: { value: string }) => o.value) ?? null;\n }\n }\n contextValues[name] = v;\n });\n return contextValues;\n }, [originalValues, definitions, externalDefinitions]);\n\n const allBuiltinVariables: BuiltinVariableDefinition[] = useMemo(() => {\n const result: BuiltinVariableDefinition[] = [\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__from',\n value: () => absoluteTimeRange.start.valueOf().toString(),\n source: 'Dashboard',\n display: {\n name: '__from',\n description: 'Start time of the current time range in unix millisecond epoch',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__to',\n value: () => absoluteTimeRange.end.valueOf().toString(),\n source: 'Dashboard',\n display: {\n name: '__to',\n description: 'End time of the current time range in unix millisecond epoch',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range',\n value: () => formatDuration(intervalToPrometheusDuration(absoluteTimeRange)),\n source: 'Dashboard',\n display: {\n name: '__range',\n description: 'The range for the current dashboard in human readable format',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range_s',\n value: () => ((absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()) / 1000).toString(),\n source: 'Dashboard',\n display: {\n name: '__range_s',\n description: 'The range for the current dashboard in second',\n hidden: true,\n },\n },\n },\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__range_ms',\n value: () => (absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()).toString(),\n source: 'Dashboard',\n display: {\n name: '__range_ms',\n description: 'The range for the current dashboard in millisecond',\n hidden: true,\n },\n },\n },\n ];\n builtinVariables?.forEach((def) => result.push(def));\n return result;\n }, [absoluteTimeRange, builtinVariables]);\n\n return (\n <BuiltinVariableContext.Provider value={{ variables: allBuiltinVariables }}>\n <VariableContext.Provider value={{ state: values }}>{children}</VariableContext.Provider>\n </BuiltinVariableContext.Provider>\n );\n}\n\ninterface VariableDefinitionStoreArgs {\n initialVariableDefinitions?: VariableDefinition[];\n externalVariableDefinitions?: ExternalVariableDefinition[];\n queryParams?: ReturnType<typeof useVariableQueryParams>;\n}\n\nfunction createVariableDefinitionStore({\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n queryParams,\n}: VariableDefinitionStoreArgs): StoreApi<VariableDefinitionStore> {\n const initialParams = getInitalValuesFromQueryParameters(queryParams ? queryParams[0] : {});\n const store = createStore<VariableDefinitionStore>()(\n devtools(\n immer((set, get) => ({\n variableState: hydrateVariableDefinitionStates(\n initialVariableDefinitions,\n initialParams,\n externalVariableDefinitions\n ),\n variableDefinitions: initialVariableDefinitions,\n externalVariableDefinitions: externalVariableDefinitions,\n setVariableDefinitions(definitions: VariableDefinition[]): void {\n set(\n (state) => {\n state.variableDefinitions = definitions;\n state.variableState = hydrateVariableDefinitionStates(\n definitions,\n initialParams,\n externalVariableDefinitions\n );\n },\n false,\n '[Variables] setVariableDefinitions' // Used for action name in Redux devtools\n );\n },\n setVariableOptions(name, options, source?: string): void {\n set(\n (state) => {\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n varState.options = options;\n },\n false,\n '[Variables] setVariableOptions'\n );\n },\n setVariableLoading(name, loading, source?: string): void {\n set(\n (state) => {\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n varState.loading = loading;\n },\n false,\n '[Variables] setVariableLoading'\n );\n },\n setVariableValue: (name, value, source?: string): void =>\n set(\n (state) => {\n let val = value;\n const varState = state.variableState.get({ name, source });\n if (!varState) {\n return;\n }\n\n // Make sure there is only one all value\n if (Array.isArray(val) && val.includes(ALL_VALUE)) {\n if (val.at(-1) === ALL_VALUE) {\n val = ALL_VALUE;\n } else {\n val = val.filter((v) => v !== ALL_VALUE);\n }\n }\n if (queryParams) {\n const setQueryParams = queryParams[1];\n setQueryParams({ [getURLQueryParamName(name)]: val });\n }\n varState.value = val;\n },\n false,\n '[Variables] setVariableValue'\n ),\n setVariableDefaultValues: (): VariableDefinition[] => {\n const variableDefinitions = get().variableDefinitions;\n const variableState = get().variableState;\n const updatedVariables = produce(variableDefinitions, (draft) => {\n draft.forEach((variable, index) => {\n const name = variable.spec.name;\n if (variable.kind === 'ListVariable') {\n const currentVariable = variableState.get({ name });\n if (currentVariable?.value !== undefined) {\n draft[index] = {\n kind: 'ListVariable',\n spec: produce(variable.spec, (specDraft) => {\n specDraft.defaultValue = currentVariable.value;\n }),\n };\n }\n } else if (variable.kind === 'TextVariable') {\n const currentVariable = variableState.get({ name });\n const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';\n if (currentVariable?.value !== undefined) {\n draft[index] = {\n kind: 'TextVariable',\n spec: produce(variable.spec, (specDraft) => {\n specDraft.value = currentVariableValue;\n }),\n };\n }\n }\n });\n });\n set(\n (state) => {\n state.variableDefinitions = updatedVariables;\n },\n false,\n '[Variables] setVariableDefaultValues'\n );\n return updatedVariables;\n },\n getSavedVariablesStatus: (): {\n modifiedVariableNames: string[];\n isSavedVariableModified: boolean;\n } => {\n return checkSavedDefaultVariableStatus(get().variableDefinitions, get().variableState);\n },\n }))\n )\n );\n\n return store as unknown as StoreApi<VariableDefinitionStore>; // TODO: @Gladorme check if we can avoid this cast\n}\n\n/**\n * The external variables allow you to give to the provider some additional variables, not defined in the dashboard and static.\n * It means that you won´t be able to update them from the dashboard itself, but you will see them appear and will be able\n * to modify their runtime value as any other variable.\n * If one of the external variable has the same name as a local one, it will be marked as overridden.\n * You can define one list of variable definition by source and as many source as you want.\n * The order of the sources is important as first one will take precedence on the following ones, in case they have same names.\n */\nexport type ExternalVariableDefinition = {\n source: string;\n tooltip?: {\n title?: string;\n description?: string;\n };\n editLink?: string;\n definitions: VariableDefinition[];\n};\n\nexport interface VariableProviderProps {\n children: ReactNode;\n initialVariableDefinitions?: VariableDefinition[];\n externalVariableDefinitions?: ExternalVariableDefinition[];\n builtinVariableDefinitions?: BuiltinVariableDefinition[];\n}\n\n// TODO: merge the different providers related to Variables under a single one (and keep \"VariableProvider\" as a name)\nexport function VariableProvider({\n children,\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n builtinVariableDefinitions = [],\n}: VariableProviderProps): ReactElement {\n const [store] = useState(() =>\n createVariableDefinitionStore({ initialVariableDefinitions, externalVariableDefinitions })\n );\n\n return (\n <VariableDefinitionStoreContext.Provider value={store}>\n <PluginProvider builtinVariables={builtinVariableDefinitions}>{children}</PluginProvider>\n </VariableDefinitionStoreContext.Provider>\n );\n}\n\nexport function VariableProviderWithQueryParams({\n children,\n initialVariableDefinitions = [],\n externalVariableDefinitions = [],\n builtinVariableDefinitions: builtinVariables = [],\n}: VariableProviderProps): ReactElement {\n const allVariableDefs = mergeVariableDefinitions(initialVariableDefinitions, externalVariableDefinitions);\n const queryParams = useVariableQueryParams(allVariableDefs);\n const [store] = useState(() =>\n createVariableDefinitionStore({ initialVariableDefinitions, externalVariableDefinitions, queryParams })\n );\n\n return (\n <VariableDefinitionStoreContext.Provider value={store}>\n <PluginProvider builtinVariables={builtinVariables}>{children}</PluginProvider>\n </VariableDefinitionStoreContext.Provider>\n );\n}\n"],"names":["createContext","useContext","useMemo","useState","createStore","useStore","useStoreWithEqualityFn","immer","devtools","shallow","produce","VariableContext","BuiltinVariableContext","useTimeRange","DEFAULT_ALL_VALUE","ALL_VALUE","formatDuration","intervalToPrometheusDuration","checkSavedDefaultVariableStatus","findVariableDefinitionByName","mergeVariableDefinitions","hydrateVariableDefinitionStates","getInitalValuesFromQueryParameters","getURLQueryParamName","useVariableQueryParams","VariableDefinitionStoreContext","undefined","useVariableDefinitionStoreCtx","context","Error","useVariableDefinitionStates","variableNames","store","s","varStates","names","variableDefinitions","map","value","spec","name","forEach","varState","variableState","get","overridden","externalVariableDefinitions","d","source","definitions","left","right","JSON","stringify","useVariableDefinitionAndState","state","find","v","definition","useVariableDefinitionActions","setVariableValue","setVariableLoading","setVariableOptions","setVariableDefinitions","setVariableDefaultValues","getSavedVariablesStatus","useVariableDefinitions","useExternalVariableDefinitions","PluginProvider","children","builtinVariables","originalValues","externalDefinitions","absoluteTimeRange","values","contextValues","Object","keys","kind","customAllValue","options","o","allBuiltinVariables","result","start","valueOf","toString","display","description","hidden","end","def","push","Provider","variables","createVariableDefinitionStore","initialVariableDefinitions","queryParams","initialParams","set","loading","val","Array","isArray","includes","at","filter","setQueryParams","updatedVariables","draft","variable","index","currentVariable","specDraft","defaultValue","currentVariableValue","VariableProvider","builtinVariableDefinitions","VariableProviderWithQueryParams","allVariableDefs"],"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,aAAa,EAA2BC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAC9F,SAASC,WAAW,EAAYC,QAAQ,QAAQ,UAAU;AAC1D,SAASC,sBAAsB,QAAQ,sBAAsB;AAC7D,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,OAAO,QAAQ,QAAQ;AAChC,SACEC,eAAe,EAKfC,sBAAsB,EACtBC,YAAY,QACP,4BAA4B;AACnC,SACEC,qBAAqBC,SAAS,EAI9BC,cAAc,EACdC,4BAA4B,QAIvB,mBAAmB;AAC1B,SAASC,+BAA+B,EAAEC,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAU;AAClH,SAASC,mCAAmCA,+BAA+B,QAAQ,mBAAmB;AACtG,SAASC,kCAAkC,EAAEC,oBAAoB,EAAEC,sBAAsB,QAAQ,iBAAiB;AAgElH;;CAEC,GACD,MAAMC,+CAAiCzB,cAA6D0B;AACpG,OAAO,SAASC;IACd,MAAMC,UAAU3B,WAAWwB;IAC3B,IAAI,CAACG,SAAS;QACZ,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOD;AACT;AAEA,OAAO,SAASE,4BAA4BC,aAAwB;IAClE,MAAMC,QAAQL;IACd,OAAOrB,uBACL0B,OACA,CAACC;QACC,MAAMC,YAA8B,CAAC;QAErC,6DAA6D;QAC7D,MAAMC,QAAQJ,iBAAiBE,EAAEG,mBAAmB,CAAC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AA8B;YAAEC;YAA4BlD;YAA6BmD;QAAY;IAGvG,qBACE,KAACxE,+BAA+BoE,QAAQ;QAACvD,OAAON;kBAC9C,cAAA,KAACoC;YAAeE,kBAAkBA;sBAAmBD;;;AAG3D"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/VariableProvider/hydrationUtils.ts"],"sourcesContent":["// Copyright 2024 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 { DEFAULT_ALL_VALUE, VariableValue, VariableDefinition } from '@perses-dev/core';\nimport { VariableStoreStateMap, VariableState } from '@perses-dev/plugin-system';\nimport { ExternalVariableDefinition } from '@perses-dev/dashboards';\n\n// TODO: move to VariableProvider/utils.ts\nfunction hydrateVariableState(variable: VariableDefinition, initialValue?: VariableValue): VariableState {\n const varState: VariableState = {\n value: null,\n loading: false,\n overriding: false,\n overridden: false,\n };\n switch (variable.kind) {\n case 'TextVariable':\n varState.value = initialValue ?? variable.spec.value;\n break;\n case 'ListVariable':\n varState.options = [];\n varState.value = initialValue ?? variable.spec.defaultValue ?? null;\n // TODO: smarter fallbacks for defaultValue when allowAllValue is true\n if (varState.options.length > 0 && !varState.value) {\n const firstOptionValue = varState.options[0]?.value ?? null;\n if (firstOptionValue !== null) {\n varState.value = variable.spec.allowMultiple ? [firstOptionValue] : firstOptionValue;\n }\n }\n\n // \"all\" variable handling assumes the value is not in an array. This is\n // handled properly during internal variable interactions, but it is possible\n // to end up in a buggy state if the variables are initialized with an \"all\"\n // value inside an array. When hydrating variables, normalize this to minimize\n // bugs.\n if (Array.isArray(varState.value) && varState.value.length === 1 && varState.value[0] === DEFAULT_ALL_VALUE) {\n varState.value = DEFAULT_ALL_VALUE;\n }\n\n break;\n default:\n break;\n }\n return varState;\n}\n\n/**\n * Build the local variable states according to the given definitions\n * @param localDefinitions local variable definitions. Dynamic part.\n * @param externalDefinitions external variables definitions. Static part.\n * @param initialValues values coming from query parameters\n */\nexport function hydrateVariableDefinitionStates(\n localDefinitions: VariableDefinition[],\n initialValues: Record<string, VariableValue>,\n externalDefinitions: ExternalVariableDefinition[] = []\n): VariableStoreStateMap {\n const state: VariableStoreStateMap = new VariableStoreStateMap();\n\n // Collect the names used by local definitions\n let overridingNames: Record<string, boolean> = {};\n localDefinitions.forEach(\n (v) => {\n overridingNames[v.spec.name] = true;\n },\n {} as Record<string, boolean>\n );\n\n // Then populate the external variables state,\n // taking care of well flagging each name as used, so the overridden state can be filled accordingly.\n const overriddenNames: Record<string, boolean> = {};\n externalDefinitions.forEach(\n (externalDef) => {\n const source = externalDef.source;\n externalDef.definitions.forEach((v) => {\n const name = v.spec.name;\n const param = initialValues[name];\n const initialValue = param ? param : null;\n state.set(\n { source, name },\n {\n ...hydrateVariableState(v, initialValue),\n overridden: !!overridingNames[name],\n }\n );\n\n overridingNames[name] = true;\n overriddenNames[v.spec.name] = true;\n });\n },\n {} as Record<string, boolean>\n );\n\n // Then populate the local variables state,\n // taking care the overriding state is filled according to the names used in external variables.\n localDefinitions.forEach((v) => {\n const name = v.spec.name;\n const param = initialValues[name];\n const initialValue = param ? param : null;\n state.set(\n { name },\n {\n ...hydrateVariableState(v, initialValue),\n overriding: !!overriddenNames[name],\n }\n );\n });\n\n overridingNames = {};\n externalDefinitions\n .slice()\n .reverse()\n .forEach((externalDef) => {\n const source = externalDef.source;\n externalDef.definitions.forEach((v) => {\n const name = v.spec.name;\n const value = state.get({ source, name });\n if (value) {\n value.overriding = !!overridingNames[name];\n }\n overridingNames[name] = true;\n });\n });\n return state;\n}\n"],"names":["DEFAULT_ALL_VALUE","VariableStoreStateMap","hydrateVariableState","variable","initialValue","varState","value","loading","overriding","overridden","kind","spec","options","defaultValue","length","firstOptionValue","allowMultiple","Array","isArray","hydrateVariableDefinitionStates","localDefinitions","initialValues","externalDefinitions","state","overridingNames","forEach","v","name","overriddenNames","externalDef","source","definitions","param","set","slice","reverse","get"],"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,iBAAiB,QAA2C,mBAAmB;AACxF,SAASC,qBAAqB,QAAuB,4BAA4B;AAGjF,0CAA0C;AAC1C,SAASC,qBAAqBC,QAA4B,EAAEC,YAA4B;IACtF,MAAMC,WAA0B;QAC9BC,OAAO;QACPC,SAAS;QACTC,YAAY;QACZC,YAAY;IACd;IACA,OAAQN,SAASO,IAAI;QACnB,KAAK;YACHL,SAASC,KAAK,GAAGF,gBAAgBD,SAASQ,IAAI,CAACL,KAAK;YACpD;QACF,KAAK;YACHD,SAASO,OAAO,GAAG,EAAE;YACrBP,SAASC,KAAK,GAAGF,gBAAgBD,SAASQ,IAAI,CAACE,YAAY,IAAI;YAC/D,sEAAsE;YACtE,IAAIR,SAASO,OAAO,CAACE,MAAM,GAAG,KAAK,CAACT,SAASC,KAAK,EAAE;gBAClD,MAAMS,mBAAmBV,SAASO,OAAO,CAAC,EAAE,EAAEN,SAAS;gBACvD,IAAIS,qBAAqB,MAAM;oBAC7BV,SAASC,KAAK,GAAGH,SAASQ,IAAI,CAACK,aAAa,GAAG;wBAACD;qBAAiB,GAAGA;gBACtE;YACF;YAEA,wEAAwE;YACxE,6EAA6E;YAC7E,4EAA4E;YAC5E,8EAA8E;YAC9E,QAAQ;YACR,IAAIE,MAAMC,OAAO,CAACb,SAASC,KAAK,KAAKD,SAASC,KAAK,CAACQ,MAAM,KAAK,KAAKT,SAASC,KAAK,CAAC,EAAE,KAAKN,mBAAmB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B,CAAC;IACnBF,oBACGY,KAAK,GACLC,OAAO,GACPV,OAAO,CAAC,CAACI;QACR,MAAMC,SAASD,YAAYC,MAAM;QACjCD,YAAYE,WAAW,CAACN,OAAO,CAAC,CAACC;YAC/B,MAAMC,OAAOD,EAAEf,IAAI,CAACgB,IAAI;YACxB,MAAMrB,QAAQiB,MAAMa,GAAG,CAAC;gBAAEN;gBAAQH;YAAK;YACvC,IAAIrB,OAAO;gBACTA,MAAME,UAAU,GAAG,CAAC,CAACgB,eAAe,CAACG,KAAK;YAC5C;YACAH,eAAe,CAACG,KAAK,GAAG;QAC1B;IACF;IACF,OAAOJ;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DashboardToolbar/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './DashboardToolbar';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB"}
1
+ {"version":3,"sources":["../../../../src/context/VariableProvider/index.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './VariableProvider';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/VariableProvider/query-params.ts"],"sourcesContent":["// Copyright 2024 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 { VariableValue, VariableDefinition } from '@perses-dev/core';\nimport { QueryParamConfig, useQueryParams } from 'use-query-params';\n\nconst variableQueryParameterPrefix = 'var-';\n\nexport function getURLQueryParamName(name: string): string {\n return `${variableQueryParameterPrefix}${name}`;\n}\n\nexport function encodeVariableValue(value: VariableValue): string | null {\n if (Array.isArray(value)) {\n return value.join(',');\n }\n return value;\n}\n\nexport function decodeVariableValue(value: string): VariableValue {\n if (!value) {\n return null;\n }\n const values = value.split(',');\n if (values.length === 1) {\n return values[0] as string;\n }\n return values;\n}\n\nconst VariableValueParam: QueryParamConfig<VariableValue> = {\n encode: encodeVariableValue,\n decode: (v) => {\n if (typeof v === 'string') {\n return decodeVariableValue(v);\n }\n return '';\n },\n};\n\nexport function useVariableQueryParams(defs: VariableDefinition[]): ReturnType<typeof useQueryParams> {\n const config: Record<string, typeof VariableValueParam> = {};\n defs.forEach((def) => {\n const name = getURLQueryParamName(def.spec.name);\n config[name] = VariableValueParam;\n });\n return useQueryParams(config, { updateType: 'replaceIn' });\n}\n\nexport function getInitalValuesFromQueryParameters(\n queryParamValues: Record<string, VariableValue>\n): Record<string, VariableValue> {\n const values: Record<string, VariableValue> = {};\n Object.keys(queryParamValues).forEach((key) => {\n const value = queryParamValues[key];\n if (!value) {\n return;\n }\n const name = key.replace(variableQueryParameterPrefix, '');\n values[name] = value;\n });\n return values;\n}\n"],"names":["useQueryParams","variableQueryParameterPrefix","getURLQueryParamName","name","encodeVariableValue","value","Array","isArray","join","decodeVariableValue","values","split","length","VariableValueParam","encode","decode","v","useVariableQueryParams","defs","config","forEach","def","spec","updateType","getInitalValuesFromQueryParameters","queryParamValues","Object","keys","key","replace"],"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;AAGjC,SAA2BA,cAAc,QAAQ,mBAAmB;AAEpE,MAAMC,+BAA+B;AAErC,OAAO,SAASC,qBAAqBC,IAAY;IAC/C,OAAO,GAAGF,+BAA+BE,MAAM;AACjD;AAEA,OAAO,SAASC,oBAAoBC,KAAoB;IACtD,IAAIC,MAAMC,OAAO,CAACF,QAAQ;QACxB,OAAOA,MAAMG,IAAI,CAAC;IACpB;IACA,OAAOH;AACT;AAEA,OAAO,SAASI,oBAAoBJ,KAAa;IAC/C,IAAI,CAACA,OAAO;QACV,OAAO;IACT;IACA,MAAMK,SAASL,MAAMM,KAAK,CAAC;IAC3B,IAAID,OAAOE,MAAM,KAAK,GAAG;QACvB,OAAOF,MAAM,CAAC,EAAE;IAClB;IACA,OAAOA;AACT;AAEA,MAAMG,qBAAsD;IAC1DC,QAAQV;IACRW,QAAQ,CAACC;QACP,IAAI,OAAOA,MAAM,UAAU;YACzB,OAAOP,oBAAoBO;QAC7B;QACA,OAAO;IACT;AACF;AAEA,OAAO,SAASC,uBAAuBC,IAA0B;IAC/D,MAAMC,SAAoD,CAAC;IAC3DD,KAAKE,OAAO,CAAC,CAACC;QACZ,MAAMlB,OAAOD,qBAAqBmB,IAAIC,IAAI,CAACnB,IAAI;QAC/CgB,MAAM,CAAChB,KAAK,GAAGU;IACjB;IACA,OAAOb,eAAemB,QAAQ;QAAEI,YAAY;IAAY;AAC1D;AAEA,OAAO,SAASC,mCACdC,gBAA+C;IAE/C,MAAMf,SAAwC,CAAC;IAC/CgB,OAAOC,IAAI,CAACF,kBAAkBL,OAAO,CAAC,CAACQ;QACrC,MAAMvB,QAAQoB,gBAAgB,CAACG,IAAI;QACnC,IAAI,CAACvB,OAAO;YACV;QACF;QACA,MAAMF,OAAOyB,IAAIC,OAAO,CAAC5B,8BAA8B;QACvDS,MAAM,CAACP,KAAK,GAAGE;IACjB;IACA,OAAOK;AACT"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/VariableProvider/utils.ts"],"sourcesContent":["// Copyright 2024 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 { VariableDefinition } from '@perses-dev/core';\nimport { VariableStoreStateMap } from '@perses-dev/plugin-system';\nimport { ExternalVariableDefinition } from '@perses-dev/dashboards';\n\n/*\n * Check whether saved variable definitions are out of date with current default list values in Zustand store\n */\nexport function checkSavedDefaultVariableStatus(\n definitions: VariableDefinition[],\n varState: VariableStoreStateMap\n): {\n modifiedVariableNames: string[];\n isSavedVariableModified: boolean;\n} {\n let isSavedVariableModified = false;\n const modifiedVariableNames: string[] = [];\n for (const savedVariable of definitions) {\n const name = savedVariable.spec.name;\n if (savedVariable.kind === 'ListVariable') {\n const currentVariable = varState.get({ name });\n if (currentVariable?.value !== null && currentVariable?.value !== savedVariable.spec.defaultValue) {\n modifiedVariableNames.push(name);\n isSavedVariableModified = true;\n }\n } else if (savedVariable.kind === 'TextVariable') {\n const currentVariable = varState.get({ name });\n const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';\n if (savedVariable.spec.value !== currentVariableValue) {\n modifiedVariableNames.push(name);\n isSavedVariableModified = true;\n }\n }\n }\n return { isSavedVariableModified, modifiedVariableNames };\n}\n\n/**\n * Merge the different kind of variable definition into a list without any duplicates (same name).\n * Respects the order of priority explained in {@link forEachVariableDefinition}\n * @param locals\n * @param externals\n */\nexport function mergeVariableDefinitions(\n locals: VariableDefinition[],\n externals: ExternalVariableDefinition[]\n): VariableDefinition[] {\n const pushed: Record<string, boolean> = {};\n const result: VariableDefinition[] = [];\n\n // Append the value only if it's not already appended\n forEachVariableDefinition(locals, externals, (value: VariableDefinition, name: string) => {\n if (!pushed[name]) {\n result.push(value);\n pushed[name] = true;\n }\n });\n return result;\n}\n\n/**\n * Find a definition by its name.\n * Respects the order of priority explained in {@link forEachVariableDefinition}\n * @param name\n * @param localDefinitions\n * @param externalDefinitions\n */\nexport function findVariableDefinitionByName(\n name: string,\n localDefinitions: VariableDefinition[],\n externalDefinitions: ExternalVariableDefinition[]\n): VariableDefinition | undefined {\n return mergeVariableDefinitions(localDefinitions, externalDefinitions).find((d) => d.spec.name === name);\n}\n\n/**\n * Loop on local and external variable definitions, respecting the order of priority:\n * - local var defs override external var defs of same name\n * - each external var defs override the external var defs coming after.\n * @param locals\n * @param externals\n * @param callbackFn\n */\nexport function forEachVariableDefinition(\n locals: VariableDefinition[],\n externals: ExternalVariableDefinition[],\n callbackFn: (varDef: VariableDefinition, name: string, source?: string) => void\n): void {\n locals.forEach((v) => callbackFn(v, v.spec.name));\n externals.forEach((ext) => ext.definitions.forEach((v) => callbackFn(v, v.spec.name, ext.source)));\n}\n"],"names":["checkSavedDefaultVariableStatus","definitions","varState","isSavedVariableModified","modifiedVariableNames","savedVariable","name","spec","kind","currentVariable","get","value","defaultValue","push","currentVariableValue","mergeVariableDefinitions","locals","externals","pushed","result","forEachVariableDefinition","findVariableDefinitionByName","localDefinitions","externalDefinitions","find","d","callbackFn","forEach","v","ext","source"],"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;AAMjC;;CAEC,GACD,OAAO,SAASA,gCACdC,WAAiC,EACjCC,QAA+B;IAK/B,IAAIC,0BAA0B;IAC9B,MAAMC,wBAAkC,EAAE;IAC1C,KAAK,MAAMC,iBAAiBJ,YAAa;QACvC,MAAMK,OAAOD,cAAcE,IAAI,CAACD,IAAI;QACpC,IAAID,cAAcG,IAAI,KAAK,gBAAgB;YACzC,MAAMC,kBAAkBP,SAASQ,GAAG,CAAC;gBAAEJ;YAAK;YAC5C,IAAIG,iBAAiBE,UAAU,QAAQF,iBAAiBE,UAAUN,cAAcE,IAAI,CAACK,YAAY,EAAE;gBACjGR,sBAAsBS,IAAI,CAACP;gBAC3BH,0BAA0B;YAC5B;QACF,OAAO,IAAIE,cAAcG,IAAI,KAAK,gBAAgB;YAChD,MAAMC,kBAAkBP,SAASQ,GAAG,CAAC;gBAAEJ;YAAK;YAC5C,MAAMQ,uBAAuB,OAAOL,iBAAiBE,UAAU,WAAWF,gBAAgBE,KAAK,GAAG;YAClG,IAAIN,cAAcE,IAAI,CAACI,KAAK,KAAKG,sBAAsB;gBACrDV,sBAAsBS,IAAI,CAACP;gBAC3BH,0BAA0B;YAC5B;QACF;IACF;IACA,OAAO;QAAEA;QAAyBC;IAAsB;AAC1D;AAEA;;;;;CAKC,GACD,OAAO,SAASW,yBACdC,MAA4B,EAC5BC,SAAuC;IAEvC,MAAMC,SAAkC,CAAC;IACzC,MAAMC,SAA+B,EAAE;IAEvC,qDAAqD;IACrDC,0BAA0BJ,QAAQC,WAAW,CAACN,OAA2BL;QACvE,IAAI,CAACY,MAAM,CAACZ,KAAK,EAAE;YACjBa,OAAON,IAAI,CAACF;YACZO,MAAM,CAACZ,KAAK,GAAG;QACjB;IACF;IACA,OAAOa;AACT;AAEA;;;;;;CAMC,GACD,OAAO,SAASE,6BACdf,IAAY,EACZgB,gBAAsC,EACtCC,mBAAiD;IAEjD,OAAOR,yBAAyBO,kBAAkBC,qBAAqBC,IAAI,CAAC,CAACC,IAAMA,EAAElB,IAAI,CAACD,IAAI,KAAKA;AACrG;AAEA;;;;;;;CAOC,GACD,OAAO,SAASc,0BACdJ,MAA4B,EAC5BC,SAAuC,EACvCS,UAA+E;IAE/EV,OAAOW,OAAO,CAAC,CAACC,IAAMF,WAAWE,GAAGA,EAAErB,IAAI,CAACD,IAAI;IAC/CW,UAAUU,OAAO,CAAC,CAACE,MAAQA,IAAI5B,WAAW,CAAC0B,OAAO,CAAC,CAACC,IAAMF,WAAWE,GAAGA,EAAErB,IAAI,CAACD,IAAI,EAAEuB,IAAIC,MAAM;AACjG"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/index.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './DashboardProvider';\nexport * from './DatasourceStoreProvider';\nexport * from './VariableProvider';\nexport * from './useDashboard';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB;AACpC,cAAc,4BAA4B;AAC1C,cAAc,qBAAqB;AACnC,cAAc,iBAAiB"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/useDashboard.tsx"],"sourcesContent":["// Copyright 2024 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 {\n createPanelRef,\n DashboardResource,\n EphemeralDashboardResource,\n GridDefinition,\n PanelGroupId,\n} from '@perses-dev/core';\nimport { PanelGroupDefinition, useDashboardStore } from './DashboardProvider';\nimport { useVariableDefinitionActions, useVariableDefinitions } from './VariableProvider';\n\nexport function useDashboard(): {\n dashboard: DashboardResource | EphemeralDashboardResource;\n setDashboard: (dashboardResource: DashboardResource | EphemeralDashboardResource) => void;\n} {\n const {\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard: setDashboardResource,\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n } = useDashboardStore(\n ({\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard,\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n }) => ({\n panels,\n panelGroups,\n panelGroupOrder,\n setDashboard,\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n })\n );\n const { setVariableDefinitions } = useVariableDefinitionActions();\n const variables = useVariableDefinitions();\n const layouts = convertPanelGroupsToLayouts(panelGroups, panelGroupOrder);\n\n const dashboard =\n kind === 'Dashboard'\n ? ({\n kind,\n metadata,\n spec: {\n display,\n panels,\n layouts,\n variables,\n duration,\n refreshInterval,\n datasources,\n },\n } as DashboardResource)\n : ({\n kind,\n metadata,\n spec: {\n display,\n panels,\n layouts,\n variables,\n duration,\n refreshInterval,\n datasources,\n ttl,\n },\n } as EphemeralDashboardResource);\n\n const setDashboard = (dashboardResource: DashboardResource | EphemeralDashboardResource): void => {\n setVariableDefinitions(dashboardResource.spec.variables);\n setDashboardResource(dashboardResource);\n };\n\n return {\n dashboard,\n setDashboard,\n };\n}\n\nfunction convertPanelGroupsToLayouts(\n panelGroups: Record<number, PanelGroupDefinition>,\n panelGroupOrder: PanelGroupId[]\n): GridDefinition[] {\n const layouts: GridDefinition[] = [];\n panelGroupOrder.map((groupOrderId) => {\n const group = panelGroups[groupOrderId];\n if (group === undefined) {\n throw new Error('panel group not found');\n }\n const { title, isCollapsed, itemLayouts, itemPanelKeys } = group;\n let display = undefined;\n if (title) {\n display = {\n title,\n collapse: {\n open: !isCollapsed,\n },\n };\n }\n const layout: GridDefinition = {\n kind: 'Grid',\n spec: {\n display,\n items: itemLayouts.map((layout) => {\n const panelKey = itemPanelKeys[layout.i];\n if (panelKey === undefined) {\n throw new Error(`Missing panel key of layout ${layout.i}`);\n }\n return {\n x: layout.x,\n y: layout.y,\n width: layout.w,\n height: layout.h,\n content: createPanelRef(panelKey),\n };\n }),\n },\n };\n layouts.push(layout);\n });\n\n return layouts;\n}\n"],"names":["createPanelRef","useDashboardStore","useVariableDefinitionActions","useVariableDefinitions","useDashboard","panels","panelGroups","panelGroupOrder","setDashboard","setDashboardResource","kind","metadata","display","duration","refreshInterval","datasources","ttl","setVariableDefinitions","variables","layouts","convertPanelGroupsToLayouts","dashboard","spec","dashboardResource","map","groupOrderId","group","undefined","Error","title","isCollapsed","itemLayouts","itemPanelKeys","collapse","open","layout","items","panelKey","i","x","y","width","w","height","h","content","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE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QpB,WAAW,CAACmB,aAAa;QACvC,IAAIC,UAAUC,WAAW;YACvB,MAAM,IAAIC,MAAM;QAClB;QACA,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAEC,WAAW,EAAEC,aAAa,EAAE,GAAGN;QAC3D,IAAId,UAAUe;QACd,IAAIE,OAAO;YACTjB,UAAU;gBACRiB;gBACAI,UAAU;oBACRC,MAAM,CAACJ;gBACT;YACF;QACF;QACA,MAAMK,SAAyB;YAC7BzB,MAAM;YACNY,MAAM;gBACJV;gBACAwB,OAAOL,YAAYP,GAAG,CAAC,CAACW;oBACtB,MAAME,WAAWL,aAAa,CAACG,OAAOG,CAAC,CAAC;oBACxC,IAAID,aAAaV,WAAW;wBAC1B,MAAM,IAAIC,MAAM,CAAC,4BAA4B,EAAEO,OAAOG,CAAC,EAAE;oBAC3D;oBACA,OAAO;wBACLC,GAAGJ,OAAOI,CAAC;wBACXC,GAAGL,OAAOK,CAAC;wBACXC,OAAON,OAAOO,CAAC;wBACfC,QAAQR,OAAOS,CAAC;wBAChBC,SAAS7C,eAAeqC;oBAC1B;gBACF;YACF;QACF;QACAlB,QAAQ2B,IAAI,CAACX;IACf;IAEA,OAAOhB;AACT"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './components';\nexport * from './context';\nexport * from './views';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,UAAU"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/test/dashboard-provider.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 { DashboardResource } from '@perses-dev/core';\nimport { useContext } from 'react';\nimport { StoreApi } from 'zustand';\nimport { DashboardContext, DashboardStoreState } from '../context';\nimport testDashboard from './testDashboard';\n\n/**\n * Helper to get a test dashboard resource.\n */\nexport function getTestDashboard(): DashboardResource {\n // TODO: Should we be cloning this to create a new object each time?\n return testDashboard;\n}\n\n/**\n * Test helper to create a \"spy\" component that will capture the DashboardProvider's store, allowing you to inspect\n * its state in tests. Be sure to render the DashboardProviderSpy component that's returned in the component test\n * underneath the DashboardProvider.\n */\nexport function createDashboardProviderSpy(): {\n DashboardProviderSpy: () => null;\n store: { value?: StoreApi<DashboardStoreState> };\n} {\n const store: { value?: StoreApi<DashboardStoreState> } = {};\n\n // Spy component just captures the store value so it can be inspected in tests\n function DashboardProviderSpy(): null {\n const ctx = useContext(DashboardContext);\n store.value = ctx;\n return null;\n }\n\n return {\n DashboardProviderSpy,\n store,\n };\n}\n"],"names":["useContext","DashboardContext","testDashboard","getTestDashboard","createDashboardProviderSpy","store","DashboardProviderSpy","ctx","value"],"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;AAGjC,SAASA,UAAU,QAAQ,QAAQ;AAEnC,SAASC,gBAAgB,QAA6B,aAAa;AACnE,OAAOC,mBAAmB,kBAAkB;AAE5C;;CAEC,GACD,OAAO,SAASC;IACd,oEAAoE;IACpE,OAAOD;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASE;IAId,MAAMC,QAAmD,CAAC;IAE1D,8EAA8E;IAC9E,SAASC;QACP,MAAMC,MAAMP,WAAWC;QACvBI,MAAMG,KAAK,GAAGD;QACd,OAAO;IACT;IAEA,OAAO;QACLD;QACAD;IACF;AACF"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/test/datasource-provider.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 { GlobalDatasourceResource } from '@perses-dev/core';\nimport { DatasourceStoreProviderProps } from '../context';\nimport { getTestDashboard } from './dashboard-provider';\n\nexport const prometheusDemoUrl = 'https://prometheus.demo.prometheus.io';\nexport const prometheusDemo: GlobalDatasourceResource = {\n kind: 'GlobalDatasource',\n metadata: {\n name: 'PrometheusDemo',\n createdAt: '0001-01-01T00:00:00Z',\n updatedAt: '0001-01-01T00:00:00Z',\n version: 0,\n },\n spec: {\n default: true,\n plugin: {\n kind: 'PrometheusDatasource',\n spec: { directUrl: prometheusDemoUrl },\n },\n },\n} as const;\n\n// This default currently defines the bare minimum to get a story working in\n// the `Dashboard` storybook with the Prometheus demo api. We'll likely want\n// to expand it to do more in the future.\nexport const defaultDatasourceProps: Pick<DatasourceStoreProviderProps, 'datasourceApi' | 'dashboardResource'> = {\n dashboardResource: getTestDashboard(),\n datasourceApi: {\n buildProxyUrl: () => '',\n getDatasource: () => {\n return Promise.resolve(undefined);\n },\n getGlobalDatasource: (selector) => {\n if (selector.kind === 'PrometheusDatasource') {\n return Promise.resolve(prometheusDemo);\n }\n\n return Promise.resolve(undefined);\n },\n listDatasources: () => {\n return Promise.resolve([]);\n },\n listGlobalDatasources: () => {\n return Promise.resolve([]);\n },\n },\n};\n"],"names":["getTestDashboard","prometheusDemoUrl","prometheusDemo","kind","metadata","name","createdAt","updatedAt","version","spec","default","plugin","directUrl","defaultDatasourceProps","dashboardResource","datasourceApi","buildProxyUrl","getDatasource","Promise","resolve","undefined","getGlobalDatasource","selector","listDatasources","listGlobalDatasources"],"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,gBAAgB,QAAQ,uBAAuB;AAExD,OAAO,MAAMC,oBAAoB,wCAAwC;AACzE,OAAO,MAAMC,iBAA2C;IACtDC,MAAM;IACNC,UAAU;QACRC,MAAM;QACNC,WAAW;QACXC,WAAW;QACXC,SAAS;IACX;IACAC,MAAM;QACJC,SAAS;QACTC,QAAQ;YACNR,MAAM;YACNM,MAAM;gBAAEG,WAAWX;YAAkB;QACvC;IACF;AACF,EAAW;AAEX,4EAA4E;AAC5E,4EAA4E;AAC5E,yCAAyC;AACzC,OAAO,MAAMY,yBAAoG;IAC/GC,mBAAmBd;IACnBe,eAAe;QACbC,eAAe,IAAM;QACrBC,eAAe;YACb,OAAOC,QAAQC,OAAO,CAACC;QACzB;QACAC,qBAAqB,CAACC;YACpB,IAAIA,SAASnB,IAAI,KAAK,wBAAwB;gBAC5C,OAAOe,QAAQC,OAAO,CAACjB;YACzB;YAEA,OAAOgB,QAAQC,OAAO,CAACC;QACzB;QACAG,iBAAiB;YACf,OAAOL,QAAQC,OAAO,CAAC,EAAE;QAC3B;QACAK,uBAAuB;YACrB,OAAON,QAAQC,OAAO,CAAC,EAAE;QAC3B;IACF;AACF,EAAE"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/test/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './dashboard-provider';\nexport * from './datasource-provider';\nexport * from './plugin-registry';\nexport * from './render';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,uBAAuB;AACrC,cAAc,wBAAwB;AACtC,cAAc,oBAAoB;AAClC,cAAc,WAAW"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/test/plugin-registry.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 { UnknownSpec } from '@perses-dev/core';\nimport { PanelPlugin, MockPlugin } from '@perses-dev/plugin-system';\nimport { ReactElement } from 'react';\n\nconst FakeTimeSeriesChartOptionEditor = (): ReactElement => {\n return <div>TimeSeriesChart options</div>;\n};\n\nconst FakeTimeSeriesPlugin: PanelPlugin<UnknownSpec> = {\n PanelComponent: () => {\n return <div>TimeSeriesChart panel</div>;\n },\n panelOptionsEditorComponents: [\n {\n label: 'Settings',\n content: FakeTimeSeriesChartOptionEditor,\n },\n ],\n createInitialOptions: () => ({}),\n supportedQueryTypes: ['TimeSeriesQuery'],\n};\n\nconst MOCK_TIME_SERIES_PANEL: MockPlugin = {\n kind: 'Panel',\n spec: { name: 'TimeSeriesChart' },\n plugin: FakeTimeSeriesPlugin,\n};\n\n// Array of default mock plugins added to the PluginRegistry during test renders\nexport const MOCK_PLUGINS: MockPlugin[] = [MOCK_TIME_SERIES_PANEL];\n"],"names":["FakeTimeSeriesChartOptionEditor","div","FakeTimeSeriesPlugin","PanelComponent","panelOptionsEditorComponents","label","content","createInitialOptions","supportedQueryTypes","MOCK_TIME_SERIES_PANEL","kind","spec","name","plugin","MOCK_PLUGINS"],"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;;AAMjC,MAAMA,kCAAkC;IACtC,qBAAO,KAACC;kBAAI;;AACd;AAEA,MAAMC,uBAAiD;IACrDC,gBAAgB;QACd,qBAAO,KAACF;sBAAI;;IACd;IACAG,8BAA8B;QAC5B;YACEC,OAAO;YACPC,SAASN;QACX;KACD;IACDO,sBAAsB,IAAO,CAAA,CAAC,CAAA;IAC9BC,qBAAqB;QAAC;KAAkB;AAC1C;AAEA,MAAMC,yBAAqC;IACzCC,MAAM;IACNC,MAAM;QAAEC,MAAM;IAAkB;IAChCC,QAAQX;AACV;AAEA,gFAAgF;AAChF,OAAO,MAAMY,eAA6B;IAACL;CAAuB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/test/render.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 { ChartsProvider, SnackbarProvider, testChartsTheme } from '@perses-dev/components';\nimport { mockPluginRegistry, PluginRegistry } from '@perses-dev/plugin-system';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { render, RenderOptions, RenderResult } from '@testing-library/react';\nimport { createMemoryHistory, MemoryHistory } from 'history';\nimport { ReactElement, useLayoutEffect, useState } from 'react';\nimport { Router } from 'react-router-dom';\nimport { QueryParamProvider } from 'use-query-params';\nimport { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';\nimport { DatasourceStoreProvider } from '../context';\nimport { defaultDatasourceProps } from '../test';\nimport { MOCK_PLUGINS } from './plugin-registry';\n\ninterface CustomRouterProps {\n history: MemoryHistory;\n children: React.ReactNode;\n}\n\n/*\n * Workaround for React router upgrade type errors.\n * More details: https://stackoverflow.com/a/69948457/17575201\n */\nconst CustomRouter: React.FC<CustomRouterProps> = ({ history, children }) => {\n const [state, setState] = useState({\n action: history.action,\n location: history.location,\n });\n\n useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router location={state.location} navigationType={state.action} navigator={history}>\n {children}\n </Router>\n );\n};\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(\n ui: React.ReactElement,\n options?: Omit<RenderOptions, 'queries'>,\n history?: MemoryHistory\n): RenderResult {\n // Create a new QueryClient for each test to avoid caching issues\n const queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false, retry: false } } });\n\n const customHistory = history ?? createMemoryHistory();\n\n const mockRegistry = mockPluginRegistry(...MOCK_PLUGINS);\n\n const BaseRender = (): ReactElement => (\n <CustomRouter history={customHistory}>\n <QueryClientProvider client={queryClient}>\n <QueryParamProvider adapter={ReactRouter6Adapter}>\n <SnackbarProvider anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}>\n <ChartsProvider chartsTheme={testChartsTheme}>\n <PluginRegistry\n pluginLoader={mockRegistry.pluginLoader}\n defaultPluginKinds={mockRegistry.defaultPluginKinds}\n >\n <DatasourceStoreProvider {...defaultDatasourceProps}>{ui}</DatasourceStoreProvider>\n </PluginRegistry>\n </ChartsProvider>\n </SnackbarProvider>\n </QueryParamProvider>\n </QueryClientProvider>\n </CustomRouter>\n );\n\n return render(<BaseRender />, options);\n}\n"],"names":["ChartsProvider","SnackbarProvider","testChartsTheme","mockPluginRegistry","PluginRegistry","QueryClient","QueryClientProvider","render","createMemoryHistory","useLayoutEffect","useState","Router","QueryParamProvider","ReactRouter6Adapter","DatasourceStoreProvider","defaultDatasourceProps","MOCK_PLUGINS","CustomRouter","history","children","state","setState","action","location","listen","navigationType","navigator","renderWithContext","ui","options","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","customHistory","mockRegistry","BaseRender","client","adapter","anchorOrigin","vertical","horizontal","chartsTheme","pluginLoader","defaultPluginKinds"],"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,cAAc,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,yBAAyB;AAC3F,SAASC,kBAAkB,EAAEC,cAAc,QAAQ,4BAA4B;AAC/E,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,wBAAwB;A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AaQ,YAAY;gCACvCC,oBAAoBT,aAAaS,kBAAkB;0CAEnD,cAAA,KAAC/B;oCAAyB,GAAGC,sBAAsB;8CAAGa;;;;;;;;IASpE,OAAOrB,qBAAO,KAAC8B,iBAAeR;AAChC"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/test/setup-tests.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 { defaultFallbackInView } from 'react-intersection-observer';\n\n// Add testing library assertions\nimport '@testing-library/jest-dom/extend-expect';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n\n// Tell react-intersection-observer that everything should be considered in-view for tests (see package documentation\n// for other options)\ndefaultFallbackInView(true);\n"],"names":["defaultFallbackInView","jest","mock"],"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,qBAAqB,QAAQ,8BAA8B;AAEpE,iCAAiC;AACjC,OAAO,0CAA0C;AAEjD,iFAAiF;AACjFC,KAAKC,IAAI,CAAC;AAEV,qHAAqH;AACrH,qBAAqB;AACrBF,sBAAsB"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/test/testDashboard.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 { DashboardResource } from '@perses-dev/core';\n\nconst testDashboard: DashboardResource = {\n kind: 'Dashboard',\n metadata: {\n name: 'Node Stats',\n project: 'perses',\n createdAt: '2021-11-09',\n updatedAt: '2021-11-09',\n version: 0,\n },\n spec: {\n duration: '30m',\n refreshInterval: '0s',\n variables: [\n {\n kind: 'TextVariable',\n spec: {\n name: 'job',\n value: 'node',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'instance',\n value: 'demo.do.prometheus.io:9100',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'interval',\n value: '1m',\n },\n },\n ],\n panels: {\n cpu: {\n kind: 'Panel',\n spec: {\n display: { name: 'CPU' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: '%' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'avg without (cpu)(rate(node_cpu_seconds_total{job=\"node\",instance=\"$instance\",mode!=\"idle\"}[$interval]))',\n },\n },\n },\n },\n ],\n },\n },\n memory: {\n kind: 'Panel',\n spec: {\n display: { name: 'Memory' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'bytes' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'node_memory_MemTotal_bytes{job=\"node\",instance=\"$instance\"} - node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n },\n },\n // This panel is referenced in more than one layout below\n diskIO: {\n kind: 'Panel',\n spec: {\n display: { name: 'Disk I/O Utilization' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'percent' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'rate(node_disk_io_time_seconds_total{job=\"node\",instance=\"$instance\",device!~\"^(md\\\\\\\\d+$|dm-)\"}[$interval])',\n },\n },\n },\n },\n ],\n },\n },\n filesystemFullness: {\n kind: 'Panel',\n spec: {\n display: { name: 'Filesystem Fullness' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'percent' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n '1 - node_filesystem_free_bytes{job=\"node\",instance=\"$instance\",fstype!=\"rootfs\",mountpoint!~\"/(run|var).*\",mountpoint!=\"\"} / node_filesystem_size_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n },\n },\n },\n layouts: [\n // Regular Title, no collapse enabled\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'CPU Stats',\n collapse: {\n open: true,\n },\n },\n items: [\n // First Row\n {\n x: 0,\n y: 0,\n width: 12,\n height: 4,\n content: { $ref: '#/spec/panels/cpu' },\n },\n {\n x: 0,\n y: 5,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n ],\n },\n },\n // No title,\n {\n kind: 'Grid',\n spec: {\n items: [\n {\n x: 0,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n {\n x: 8,\n y: 0,\n width: 8,\n height: 3,\n content: { $ref: '#/spec/panels/memory' },\n },\n ],\n },\n },\n // Collapsed\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'Disk Stats',\n collapse: {\n open: false,\n },\n },\n items: [\n {\n x: 18,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/filesystemFullness' },\n },\n ],\n },\n },\n ],\n },\n};\n\nexport default testDashboard;\n"],"names":["testDashboard","kind","metadata","name","project","createdAt","updatedAt","version","spec","duration","refreshInterval","variables","value","panels","cpu","display","plugin","format","unit","queries","query","memory","diskIO","filesystemFullness","layouts","title","collapse","open","items","x","y","width","height","content","$ref"],"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,MAAMA,gBAAmC;IACvCC,MAAM;IACNC,UAAU;QACRC,MAAM;QACNC,SAAS;QACTC,WAAW;QACXC,WAAW;QACXC,SAAS;IACX;IACAC,MAAM;QACJC,UAAU;QACVC,iBAAiB;QACjBC,WAAW;YACT;gBACEV,MAAM;gBACNO,MAAM;oBACJL,MAAM;oBACNS,OAAO;gBACT;YACF;YACA;gBACEX,MAAM;gBACNO,MAAM;oBACJL,MAAM;oBACNS,OAAO;gBACT;YACF;YACA;gBACEX,MAAM;gBACNO,MAAM;oBACJL,MAAM;oBACNS,OAAO;gBACT;YACF;SACD;QACDC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ACRC,SAAS;gCAAEC,MAAM;4BAAmC;wBACtD;qBACD;gBACH;YACF;SACD;IACH;AACF;AAEA,eAAelC,cAAc"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './panelUtils';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/panelUtils.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 { PanelGroupDefinition, PanelGroupItemLayout } from '../context';\nimport { GRID_LAYOUT_SMALL_BREAKPOINT, GRID_LAYOUT_COLS } from '../constants';\n\n// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present\nexport function getYForNewRow(group: PanelGroupDefinition): number {\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\ntype PanelGroupItemBounds = {\n /**\n * Left horizontal position.\n */\n x1: number;\n /**\n * Right horizontal position.\n */\n x2: number;\n /**\n * Top vertical position.\n */\n y1: number;\n /**\n * Bottom vertical position\n */\n y2: number;\n};\n\nfunction getPanelBounds({ x, y, w, h }: PanelGroupItemLayout): PanelGroupItemBounds {\n return {\n x1: x,\n x2: x + w,\n y1: y,\n y2: y + h,\n };\n}\n\nexport type UnpositionedPanelGroupItemLayout = Omit<PanelGroupItemLayout, 'x' | 'y'>;\n\n/**\n * Inserts a new panel into the layout with placement determined by a specified\n * reference panel. The new panel is placed:\n * - To the right of the reference panel if there is space available without\n * moving other panels.\n * - Otherwise, directly below the reference panel. If other panels are below\n * this location, they will also shift downward because the grid uses\n * vertical-based compacting.\n *\n * @param newLayout - Layout for new panel to insert into the grid.\n * @param referenceLayout - Layout for reference panel used to determine the\n * placement of the new panel.\n * @param itemLayouts - Full grid layout.\n * @returns - Item layouts modified to insert the new panel.\n */\nexport function insertPanelInLayout(\n newLayout: UnpositionedPanelGroupItemLayout,\n referenceLayout: PanelGroupItemLayout,\n itemLayouts: PanelGroupItemLayout[]\n): PanelGroupItemLayout[] {\n const MAX_LAYOUT_WIDTH = GRID_LAYOUT_COLS[GRID_LAYOUT_SMALL_BREAKPOINT];\n\n const referenceBounds = getPanelBounds(referenceLayout);\n\n // Organize layouts based on vertical relation to the item being inserted\n // after.\n const aboveInsertRow: PanelGroupItemLayout[] = [];\n const insertRow: PanelGroupItemLayout[] = [];\n const belowInsertRow: PanelGroupItemLayout[] = [];\n itemLayouts.forEach((itemLayout) => {\n const itemBounds = getPanelBounds(itemLayout);\n\n if (itemBounds.y2 <= referenceBounds.y1) {\n aboveInsertRow.push(itemLayout);\n } else if (itemBounds.y1 >= referenceBounds.y2) {\n belowInsertRow.push(itemLayout);\n } else {\n insertRow.push(itemLayout);\n }\n });\n\n // Cannot safely assume that the order of item layouts array is strictly\n // left to right. Sorting the row by horizontal position to more easily find\n // gaps.\n insertRow.sort((a, b) => a.x - b.x);\n const insertAfterIndex = insertRow.findIndex((item) => item.i === referenceLayout.i);\n\n if (insertAfterIndex === insertRow.length - 1) {\n // Insert to the right when space is available and the reference is the last\n // item in the row.\n if (referenceBounds.x2 + newLayout.w <= MAX_LAYOUT_WIDTH) {\n return [\n ...aboveInsertRow,\n ...insertRow,\n {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n },\n ...belowInsertRow,\n ];\n }\n } else if (insertAfterIndex >= 0) {\n const nextItem = insertRow[insertAfterIndex + 1];\n\n if (nextItem && getPanelBounds(nextItem).x1 - referenceBounds.x2 >= newLayout.w) {\n // Insert to the right when space is available between the reference and\n // the next item in the row.\n insertRow.splice(insertAfterIndex + 1, 0, {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n });\n\n return [...aboveInsertRow, ...insertRow, ...belowInsertRow];\n }\n }\n\n // Insert the new item below the original and shift the items below the\n // row where the reference is located.\n return [\n ...aboveInsertRow,\n ...insertRow,\n { x: referenceBounds.x1, y: referenceBounds.y2, ...newLayout },\n ...belowInsertRow.map((itemLayout) => {\n // Note: the grid will not necessarily display all of these items shifted\n // all the way down because of vertical compacting, but shifing their\n // y position ensures the new item gets vertical precedence over items\n // below it in that compacting.\n return { ...itemLayout, y: itemLayout.y + newLayout.h };\n }),\n ];\n}\n\n/**\n * Get a valid panel key, where a valid key:\n * - does not include invalid characters\n * - is unique\n */\nexport function getValidPanelKey(panelKey: string, panels: Record<string, PanelDefinition>): string {\n const uniquePanelKeys = getUniquePanelKeys(panels);\n let normalizedPanelKey = getPanelKeyParts(removeWhiteSpaces(panelKey)).name;\n\n const matchingKey = uniquePanelKeys[normalizedPanelKey];\n if (typeof matchingKey === 'number') {\n normalizedPanelKey += `-${matchingKey + 1}`;\n }\n return normalizedPanelKey;\n}\n\ntype PanelKeyParts = {\n name: string;\n number?: number;\n};\n\nconst removeWhiteSpaces = (str: string): string => {\n return str.replace(/\\s+/g, '');\n};\n\n/**\n * Breaks the specified panel key into the name and the optional `-number` used\n * for deduping panels with the same name.\n */\nfunction getPanelKeyParts(panelKey: string): PanelKeyParts {\n const parts = panelKey.match(/(.+)-([0-9]+)/);\n if (parts && parts[1] && parts[2]) {\n return {\n name: parts[1],\n number: parseInt(parts[2], 10),\n };\n }\n\n return {\n name: panelKey,\n };\n}\n\n// Find all the unique panel keys and the largest number used for each.\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 { name, number } = getPanelKeyParts(panelKey);\n if (uniquePanelKeys[name] === undefined) {\n uniquePanelKeys[name] = 0;\n }\n const currentValue = uniquePanelKeys[name];\n if (typeof currentValue === 'number' && number) {\n // Check for the maximum value because we cannot rely on a sequential\n // set of numbers when panels are modified.\n uniquePanelKeys[name] = Math.max(currentValue, number);\n }\n });\n return uniquePanelKeys;\n}\n"],"names":["GRID_LAYOUT_SMALL_BREAKPOINT","GRID_LAYOUT_COLS","getYForNewRow","group","newRowY","layout","itemLayouts","itemMaxY","y","h","getPanelBounds","x","w","x1","x2","y1","y2","insertPanelInLayout","newLayout","referenceLayout","MAX_LAYOUT_WIDTH","referenceBounds","aboveInsertRow","insertRow","belowInsertRow","forEach","itemLayout","itemBounds","push","sort","a","b","insertAfterIndex","findIndex","item","i","length","nextItem","splice","map","getValidPanelKey","panelKey","panels","uniquePanelKeys","getUniquePanelKeys","normalizedPanelKey","getPanelKeyParts","removeWhiteSpaces","name","matchingKey","str","replace","parts","match","number","parseInt","Object","keys","undefined","currentValue","Math","max"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AA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AAqBC,iBAAiBC,kBAAkBN,WAAWO,IAAI;IAE3E,MAAMC,cAAcN,eAAe,CAACE,mBAAmB;IACvD,IAAI,OAAOI,gBAAgB,UAAU;QACnCJ,sBAAsB,CAAC,CAAC,EAAEI,cAAc,GAAG;IAC7C;IACA,OAAOJ;AACT;AAOA,MAAME,oBAAoB,CAACG;IACzB,OAAOA,IAAIC,OAAO,CAAC,QAAQ;AAC7B;AAEA;;;CAGC,GACD,SAASL,iBAAiBL,QAAgB;IACxC,MAAMW,QAAQX,SAASY,KAAK,CAAC;IAC7B,IAAID,SAASA,KAAK,CAAC,EAAE,IAAIA,KAAK,CAAC,EAAE,EAAE;QACjC,OAAO;YACLJ,MAAMI,KAAK,CAAC,EAAE;YACdE,QAAQC,SAASH,KAAK,CAAC,EAAE,EAAE;QAC7B;IACF;IAEA,OAAO;QACLJ,MAAMP;IACR;AACF;AAEA,uEAAuE;AACvE,0FAA0F;AAC1F,SAASG,mBAAmBF,MAAuC;IACjE,MAAMC,kBAA0C,CAAC;IACjDa,OAAOC,IAAI,CAACf,QAAQjB,OAAO,CAAC,CAACgB;QAC3B,MAAM,EAAEO,IAAI,EAAEM,MAAM,EAAE,GAAGR,iBAAiBL;QAC1C,IAAIE,eAAe,CAACK,KAAK,KAAKU,WAAW;YACvCf,eAAe,CAACK,KAAK,GAAG;QAC1B;QACA,MAAMW,eAAehB,eAAe,CAACK,KAAK;QAC1C,IAAI,OAAOW,iBAAiB,YAAYL,QAAQ;YAC9C,qEAAqE;YACrE,2CAA2C;YAC3CX,eAAe,CAACK,KAAK,GAAGY,KAAKC,GAAG,CAACF,cAAcL;QACjD;IACF;IACA,OAAOX;AACT"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/views/ViewDashboard/DashboardApp.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 { ReactElement, useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ChartsProvider, ErrorAlert, ErrorBoundary, useChartsTheme } from '@perses-dev/components';\nimport { DashboardResource, EphemeralDashboardResource } from '@perses-dev/core';\nimport { useDatasourceStore } from '@perses-dev/plugin-system';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n DashboardDiscardChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n EmptyDashboardProps,\n EditJsonDialog,\n SaveChangesConfirmationDialog,\n} from '../../components';\nimport { OnSaveDashboard, useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n emptyDashboardProps?: Partial<EmptyDashboardProps>;\n dashboardResource: DashboardResource | EphemeralDashboardResource;\n dashboardTitleComponent?: JSX.Element;\n onSave?: OnSaveDashboard;\n onDiscard?: (entity: DashboardResource) => void;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n isVariableEnabled: boolean;\n isDatasourceEnabled: boolean;\n isCreating?: boolean;\n}\n\nexport const DashboardApp = (props: DashboardAppProps): ReactElement => {\n const {\n dashboardResource,\n dashboardTitleComponent,\n emptyDashboardProps,\n onSave,\n onDiscard,\n initialVariableIsSticky,\n isReadonly,\n isVariableEnabled,\n isDatasourceEnabled,\n isCreating,\n } = props;\n\n const chartsTheme = useChartsTheme();\n\n const { isEditMode, setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<\n DashboardResource | EphemeralDashboardResource | undefined\n >(undefined);\n const { setSavedDatasources } = useDatasourceStore();\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleDiscardChanges = (): void => {\n // Reset to the original spec and exit edit mode\n if (originalDashboard) {\n setDashboard(originalDashboard);\n }\n setEditMode(false);\n closeDiscardChangesConfirmationDialog();\n if (onDiscard) {\n onDiscard(dashboard as unknown as DashboardResource);\n }\n };\n\n const onEditButtonClick = (): void => {\n setEditMode(true);\n setOriginalDashboard(dashboard);\n setSavedDatasources(dashboard.spec.datasources ?? {});\n };\n\n const onCancelButtonClick = (): void => {\n // check if dashboard has been modified\n if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {\n setEditMode(false);\n } else {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n handleDiscardChanges();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n });\n }\n };\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar\n dashboardName={dashboardResource.metadata.name}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n onSave={onSave}\n isReadonly={isReadonly}\n isVariableEnabled={isVariableEnabled}\n isDatasourceEnabled={isDatasourceEnabled}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ paddingTop: 2, paddingX: 2, height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard\n emptyDashboardProps={{\n onEditButtonClick,\n ...emptyDashboardProps,\n }}\n />\n </ErrorBoundary>\n <ChartsProvider chartsTheme={chartsTheme} enablePinning={false} enableSyncGrouping={false}>\n <PanelDrawer />\n </ChartsProvider>\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <DashboardDiscardChangesConfirmationDialog />\n <EditJsonDialog isReadonly={!isEditMode} disableMetadataEdition={!isCreating} />\n <SaveChangesConfirmationDialog />\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ChartsProvider","ErrorAlert","ErrorBoundary","useChartsTheme","useDatasourceStore","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","DashboardDiscardChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","EditJsonDialog","SaveChangesConfirmationDialog","useDashboard","useDiscardChangesConfirmationDialog","useEditMode","DashboardApp","props","dashboardResource","dashboardTitleComponent","emptyDashboardProps","onSave","onDiscard","initialVariableIsSticky","isReadonly","isVariableEnabled","isDatasourceEnabled","isCreating","chartsTheme","isEditMode","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","setSavedDatasources","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleDiscardChanges","onEditButtonClick","spec","datasources","onCancelButtonClick","JSON","stringify","onDiscardChanges","onCancel","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","paddingTop","paddingX","height","FallbackComponent","enablePinning","enableSyncGrouping","disableMetadataEdition"],"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,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,GAAG,QAAQ,gBAAgB;AACpC,SAASC,cAAc,EAAEC,UAAU,EAAEC,aAAa,EAAEC,cAAc,QAAQ,yBAAyB;AAEnG,SAASC,kBAAkB,QAAQ,4BAA4B;AAC/D,SACEC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,sBAAsB,EACtBC,yCAAyC,EACzCC,gBAAgB,EAChBC,iBAAiB,EAEjBC,cAAc,EACdC,6BAA6B,QACxB,mBAAmB;AAC1B,SAA0BC,YAAY,EAAEC,mCAAmC,EAAEC,WAAW,QAAQ,gBAAgB;AAehH,OAAO,MAAMC,eAAe,CAACC;IAC3B,MAAM,EACJC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D,IAAI;oBAAES,YAAY;oBAAGC,UAAU;oBAAGC,QAAQ;gBAAO;;kCACpD,KAAC1D;wBAAc2D,mBAAmB5D;kCAChC,cAAA,KAACK;4BACCe,qBAAqB;gCACnBoB;gCACA,GAAGpB,mBAAmB;4BACxB;;;kCAGJ,KAACrB;wBAAe6B,aAAaA;wBAAaiC,eAAe;wBAAOC,oBAAoB;kCAClF,cAAA,KAAC1D;;kCAEH,KAACE;kCACD,KAACC;kCACD,KAACG;kCACD,KAACF;kCACD,KAACG;wBAAea,YAAY,CAACK;wBAAYkC,wBAAwB,CAACpC;;kCAClE,KAACf;;;;;AAIT,EAAE"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/views/ViewDashboard/ViewDashboard.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { BuiltinVariableDefinition, DEFAULT_DASHBOARD_DURATION, DEFAULT_REFRESH_INTERVAL } from '@perses-dev/core';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport {\n TimeRangeProviderWithQueryParams,\n useInitialRefreshInterval,\n useInitialTimeRange,\n usePluginBuiltinVariableDefinitions,\n} from '@perses-dev/plugin-system';\nimport { ReactElement, useMemo } from 'react';\nimport {\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n VariableProviderProps,\n VariableProviderWithQueryParams,\n} from '../../context';\nimport { DashboardProviderWithQueryParams } from '../../context/DashboardProvider/DashboardProviderWithQueryParams';\nimport { DashboardApp, DashboardAppProps } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'>, DashboardAppProps {\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n externalVariableDefinitions?: VariableProviderProps['externalVariableDefinitions'];\n isEditing?: boolean;\n isCreating?: boolean;\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps): ReactElement {\n const {\n dashboardResource,\n datasourceApi,\n externalVariableDefinitions,\n dashboardTitleComponent,\n emptyDashboardProps,\n onSave,\n onDiscard,\n initialVariableIsSticky,\n isReadonly,\n isVariableEnabled,\n isDatasourceEnabled,\n isEditing,\n isCreating,\n sx,\n ...others\n } = props;\n const { spec } = dashboardResource;\n const dashboardDuration = spec.duration ?? DEFAULT_DASHBOARD_DURATION;\n const dashboardRefreshInterval = spec.refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n const initialTimeRange = useInitialTimeRange(dashboardDuration);\n const initialRefreshInterval = useInitialRefreshInterval(dashboardRefreshInterval);\n const { data } = usePluginBuiltinVariableDefinitions();\n\n const builtinVariables = useMemo(() => {\n const result = [\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__dashboard',\n value: () => dashboardResource.metadata.name,\n source: 'Dashboard',\n display: {\n name: '__dashboard',\n description: 'The name of the current dashboard',\n hidden: true,\n },\n },\n } as BuiltinVariableDefinition,\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__project',\n value: () => dashboardResource.metadata.project,\n source: 'Dashboard',\n display: {\n name: '__project',\n description: 'The name of the current dashboard project',\n hidden: true,\n },\n },\n } as BuiltinVariableDefinition,\n ];\n if (data) {\n data.forEach((def: BuiltinVariableDefinition) => result.push(def));\n }\n return result;\n }, [dashboardResource.metadata.name, dashboardResource.metadata.project, data]);\n\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProviderWithQueryParams\n initialState={{\n dashboardResource,\n isEditMode: !!isEditing,\n }}\n >\n <TimeRangeProviderWithQueryParams\n initialTimeRange={initialTimeRange}\n initialRefreshInterval={initialRefreshInterval}\n >\n <VariableProviderWithQueryParams\n initialVariableDefinitions={spec.variables}\n externalVariableDefinitions={externalVariableDefinitions}\n builtinVariableDefinitions={builtinVariables}\n >\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp\n dashboardResource={dashboardResource}\n dashboardTitleComponent={dashboardTitleComponent}\n emptyDashboardProps={emptyDashboardProps}\n onSave={onSave}\n onDiscard={onDiscard}\n initialVariableIsSticky={initialVariableIsSticky}\n isReadonly={isReadonly}\n isVariableEnabled={isVariableEnabled}\n isDatasourceEnabled={isDatasourceEnabled}\n isCreating={isCreating}\n />\n </ErrorBoundary>\n </Box>\n </VariableProviderWithQueryParams>\n </TimeRangeProviderWithQueryParams>\n </DashboardProviderWithQueryParams>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["Box","DEFAULT_DASHBOARD_DURATION","DEFAULT_REFRESH_INTERVAL","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProviderWithQueryParams","useInitialRefreshInterval","useInitialTimeRange","usePluginBuiltinVariableDefinitions","useMemo","DatasourceStoreProvider","VariableProviderWithQueryParams","DashboardProviderWithQueryParams","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","externalVariableDefinitions","dashboardTitleComponent","emptyDashboardProps","onSave","onDiscard","initialVariableIsSticky","isReadonly","isVariableEnabled","isDatasourceEnabled","isEditing","isCreating","sx","others","spec","dashboardDuration","duration","dashboardRefreshInterval","refreshInterval","initialTimeRange","initialRefreshInterval","data","builtinVariables","result","kind","name","value","metadata","source","display","description","hidden","project","forEach","def","push","initialState","isEditMode","initialVariableDefinitions","variables","builtinVariableDefinitions","width","height","position","overflow","FallbackComponent"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CA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ACNK,aAAa;wBACbC,QAAQ;oBACV;gBACF;YACF;YACA;gBACEP,MAAM;gBACNV,MAAM;oBACJW,MAAM;oBACNC,OAAO,IAAM3B,kBAAkB4B,QAAQ,CAACK,OAAO;oBAC/CJ,QAAQ;oBACRC,SAAS;wBACPJ,MAAM;wBACNK,aAAa;wBACbC,QAAQ;oBACV;gBACF;YACF;SACD;QACD,IAAIV,MAAM;YACRA,KAAKY,OAAO,CAAC,CAACC,MAAmCX,OAAOY,IAAI,CAACD;QAC/D;QACA,OAAOX;IACT,GAAG;QAACxB,kBAAkB4B,QAAQ,CAACF,IAAI;QAAE1B,kBAAkB4B,QAAQ,CAACK,OAAO;QAAEX;KAAK;IAE9E,qBACE,KAAC5B;QAAwBM,mBAAmBA;QAAmBC,eAAeA;kBAC5E,cAAA,KAACL;YACCyC,cAAc;gBACZrC;gBACAsC,YAAY,CAAC,CAAC3B;YAChB;sBAEA,cAAA,KAACtB;gBACC+B,kBAAkBA;gBAClBC,wBAAwBA;0BAExB,cAAA,KAAC1B;oBACC4C,4BAA4BxB,KAAKyB,SAAS;oBAC1CtC,6BAA6BA;oBAC7BuC,4BAA4BlB;8BAE5B,cAAA,KAACxC;wBACC8B,IAAIzB,UACF;4BACE0C,SAAS;4BACTY,OAAO;4BACPC,QAAQ;4BACRC,UAAU;4BACVC,UAAU;wBACZ,GACAhC;wBAED,GAAGC,MAAM;kCAEV,cAAA,KAAC5B;4BAAc4D,mBAAmB3D;sCAChC,cAAA,KAACU;gCACCG,mBAAmBA;gCACnBG,yBAAyBA;gCACzBC,qBAAqBA;gCACrBC,QAAQA;gCACRC,WAAWA;gCACXC,yBAAyBA;gCACzBC,YAAYA;gCACZC,mBAAmBA;gCACnBC,qBAAqBA;gCACrBE,YAAYA;;;;;;;;AAS9B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelDrawer/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './PanelDrawer';\nexport * from './PanelPreview';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,gBAAgB;AAC9B,cAAc,iBAAiB"}
1
+ {"version":3,"sources":["../../../../src/views/ViewDashboard/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './ViewDashboard';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,kBAAkB"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/views/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './ViewDashboard';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,kBAAkB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.52.0-beta.0",
3
+ "version": "0.52.0-beta.2",
4
4
  "description": "The dashboards feature in Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -29,9 +29,9 @@
29
29
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
30
30
  },
31
31
  "dependencies": {
32
- "@perses-dev/components": "0.52.0-beta.0",
33
- "@perses-dev/core": "0.52.0-beta.0",
34
- "@perses-dev/plugin-system": "0.52.0-beta.0",
32
+ "@perses-dev/components": "0.52.0-beta.2",
33
+ "@perses-dev/core": "0.52.0-beta.2",
34
+ "@perses-dev/plugin-system": "0.52.0-beta.2",
35
35
  "@types/react-grid-layout": "^1.3.2",
36
36
  "date-fns": "^4.1.0",
37
37
  "immer": "^10.1.1",
@@ -46,7 +46,7 @@
46
46
  "zustand": "^4.3.3"
47
47
  },
48
48
  "devDependencies": {
49
- "@perses-dev/internal-utils": "0.52.0-beta.0",
49
+ "@perses-dev/internal-utils": "0.52.0-beta.2",
50
50
  "history": "^5.3.0",
51
51
  "intersection-observer": "^0.12.2"
52
52
  },