@perses-dev/dashboards 0.0.0-snapshot-scatterplot-fix-imports-95e1b59 → 0.0.0-snapshot-explorer-plugin-c4a7621

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 (348) hide show
  1. package/dist/cjs/components/Dashboard/Dashboard.js +8 -1
  2. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +2 -2
  3. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +1 -1
  4. package/dist/cjs/components/Datasources/DatasourceEditor.js +18 -18
  5. package/dist/cjs/components/Datasources/EditDatasourcesButton.js +2 -5
  6. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +3 -4
  7. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +10 -13
  8. package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +2 -2
  9. package/dist/cjs/components/GridLayout/GridContainer.js +15 -10
  10. package/dist/cjs/components/GridLayout/GridItemContent.js +19 -4
  11. package/dist/cjs/components/GridLayout/GridLayout.js +61 -12
  12. package/dist/cjs/components/GridLayout/GridTitle.js +3 -3
  13. package/dist/cjs/{validation/panel.js → components/Panel/HeaderIconButton.js} +8 -10
  14. package/dist/cjs/components/Panel/Panel.js +14 -10
  15. package/dist/cjs/components/Panel/PanelActions.js +216 -0
  16. package/dist/cjs/components/Panel/PanelContent.js +4 -4
  17. package/dist/cjs/components/Panel/PanelHeader.js +36 -103
  18. package/dist/cjs/components/Panel/PanelLinks.js +136 -0
  19. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +9 -6
  20. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +67 -65
  21. package/dist/cjs/components/PanelDrawer/PanelPreview.js +7 -3
  22. package/dist/cjs/components/PanelDrawer/usePanelEditor.js +9 -6
  23. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
  24. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
  25. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -6
  26. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +2 -2
  27. package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +7 -14
  28. package/dist/cjs/components/Variables/EditVariablesButton.js +4 -4
  29. package/dist/cjs/components/Variables/{TemplateVariable.js → Variable.js} +43 -60
  30. package/dist/cjs/components/Variables/VariableEditor.js +34 -40
  31. package/dist/cjs/components/Variables/VariableList.js +23 -22
  32. package/dist/cjs/components/Variables/index.js +2 -2
  33. package/dist/cjs/constants/styles.js +15 -7
  34. package/dist/cjs/constants/user-interface-text.js +3 -0
  35. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +10 -8
  36. package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +36 -0
  37. package/dist/cjs/context/DashboardProvider/common.js +2 -2
  38. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +14 -6
  39. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -2
  40. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +7 -10
  41. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +1 -2
  42. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +8 -3
  43. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +79 -0
  44. package/dist/cjs/context/DatasourceStoreProvider.js +18 -23
  45. package/dist/cjs/context/{TemplateVariableProvider/TemplateVariableProvider.js → VariableProvider/VariableProvider.js} +62 -69
  46. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.js +11 -14
  47. package/dist/cjs/{validation → context/VariableProvider}/index.js +2 -2
  48. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/query-params.js +1 -1
  49. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/utils.js +3 -3
  50. package/dist/cjs/context/index.js +2 -2
  51. package/dist/cjs/context/useDashboard.js +4 -4
  52. package/dist/cjs/stories/decorators/WithDashboard.js +1 -1
  53. package/dist/cjs/stories/decorators/WithDatasourceStore.js +1 -1
  54. package/dist/cjs/stories/decorators/{WithTemplateVariables.js → WithVariables.js} +9 -9
  55. package/dist/cjs/stories/decorators/index.js +2 -2
  56. package/dist/cjs/test/plugin-registry.js +4 -2
  57. package/dist/cjs/test/render.js +13 -11
  58. package/dist/cjs/views/ViewDashboard/DashboardApp.js +3 -3
  59. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +7 -8
  60. package/dist/components/AddGroupButton/AddGroupButton.d.ts +2 -1
  61. package/dist/components/AddGroupButton/AddGroupButton.d.ts.map +1 -1
  62. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
  63. package/dist/components/AddPanelButton/AddPanelButton.d.ts +2 -1
  64. package/dist/components/AddPanelButton/AddPanelButton.d.ts.map +1 -1
  65. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  66. package/dist/components/Dashboard/Dashboard.d.ts +2 -1
  67. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  68. package/dist/components/Dashboard/Dashboard.js +8 -1
  69. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  70. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +2 -1
  71. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  72. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +3 -3
  73. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  74. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
  75. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  76. package/dist/components/DashboardToolbar/DashboardToolbar.js +1 -1
  77. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  78. package/dist/components/Datasources/DatasourceEditor.d.ts +2 -1
  79. package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
  80. package/dist/components/Datasources/DatasourceEditor.js +19 -19
  81. package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
  82. package/dist/components/Datasources/EditDatasourcesButton.d.ts +2 -1
  83. package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -1
  84. package/dist/components/Datasources/EditDatasourcesButton.js +2 -5
  85. package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
  86. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +2 -1
  87. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -1
  88. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  89. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts +2 -1
  90. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  91. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +3 -4
  92. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  93. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +2 -1
  94. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
  95. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  96. package/dist/components/DownloadButton/DownloadButton.d.ts +2 -1
  97. package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -1
  98. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  99. package/dist/components/EditButton/EditButton.d.ts +2 -1
  100. package/dist/components/EditButton/EditButton.d.ts.map +1 -1
  101. package/dist/components/EditButton/EditButton.js.map +1 -1
  102. package/dist/components/EditJsonButton/EditJsonButton.d.ts +2 -1
  103. package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -1
  104. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  105. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +2 -1
  106. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  107. package/dist/components/EditJsonDialog/EditJsonDialog.js +7 -10
  108. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  109. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts +3 -3
  110. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts.map +1 -1
  111. package/dist/components/EmptyDashboard/EmptyDashboard.js +2 -2
  112. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
  113. package/dist/components/GridLayout/GridContainer.d.ts +5 -3
  114. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -1
  115. package/dist/components/GridLayout/GridContainer.js +15 -10
  116. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  117. package/dist/components/GridLayout/GridItemContent.d.ts +2 -1
  118. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  119. package/dist/components/GridLayout/GridItemContent.js +21 -6
  120. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  121. package/dist/components/GridLayout/GridLayout.d.ts +4 -2
  122. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  123. package/dist/components/GridLayout/GridLayout.js +63 -14
  124. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  125. package/dist/components/GridLayout/GridTitle.d.ts +3 -2
  126. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  127. package/dist/components/GridLayout/GridTitle.js +3 -3
  128. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  129. package/dist/components/Panel/HeaderIconButton.d.ts +5 -0
  130. package/dist/components/Panel/HeaderIconButton.d.ts.map +1 -0
  131. package/dist/{context/TemplateVariableProvider/index.js → components/Panel/HeaderIconButton.js} +7 -3
  132. package/dist/components/Panel/HeaderIconButton.js.map +1 -0
  133. package/dist/components/Panel/Panel.d.ts +11 -5
  134. package/dist/components/Panel/Panel.d.ts.map +1 -1
  135. package/dist/components/Panel/Panel.js +15 -11
  136. package/dist/components/Panel/Panel.js.map +1 -1
  137. package/dist/components/Panel/PanelActions.d.ts +16 -0
  138. package/dist/components/Panel/PanelActions.d.ts.map +1 -0
  139. package/dist/components/Panel/PanelActions.js +203 -0
  140. package/dist/components/Panel/PanelActions.js.map +1 -0
  141. package/dist/components/Panel/PanelContent.d.ts +2 -1
  142. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  143. package/dist/components/Panel/PanelContent.js +4 -4
  144. package/dist/components/Panel/PanelContent.js.map +1 -1
  145. package/dist/components/Panel/PanelHeader.d.ts +8 -8
  146. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  147. package/dist/components/Panel/PanelHeader.js +39 -106
  148. package/dist/components/Panel/PanelHeader.js.map +1 -1
  149. package/dist/components/Panel/PanelLinks.d.ts +6 -0
  150. package/dist/components/Panel/PanelLinks.d.ts.map +1 -0
  151. package/dist/components/Panel/PanelLinks.js +123 -0
  152. package/dist/components/Panel/PanelLinks.js.map +1 -0
  153. package/dist/components/PanelDrawer/PanelDrawer.d.ts +2 -1
  154. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  155. package/dist/components/PanelDrawer/PanelDrawer.js +10 -7
  156. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  157. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +3 -3
  158. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  159. package/dist/components/PanelDrawer/PanelEditorForm.js +70 -68
  160. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  161. package/dist/components/PanelDrawer/PanelPreview.d.ts +3 -2
  162. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  163. package/dist/components/PanelDrawer/PanelPreview.js +8 -4
  164. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  165. package/dist/components/PanelDrawer/usePanelEditor.d.ts +12 -10
  166. package/dist/components/PanelDrawer/usePanelEditor.d.ts.map +1 -1
  167. package/dist/components/PanelDrawer/usePanelEditor.js +9 -6
  168. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
  169. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +2 -1
  170. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  171. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
  172. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  173. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +2 -1
  174. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
  175. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  176. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts +2 -1
  177. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts.map +1 -1
  178. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
  179. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  180. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +2 -1
  181. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  182. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +5 -7
  183. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  184. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +2 -1
  185. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  186. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +3 -3
  187. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  188. package/dist/components/Variables/BuiltinVariableAccordions.d.ts +2 -1
  189. package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -1
  190. package/dist/components/Variables/BuiltinVariableAccordions.js +7 -14
  191. package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -1
  192. package/dist/components/Variables/EditVariablesButton.d.ts +2 -1
  193. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  194. package/dist/components/Variables/EditVariablesButton.js +5 -5
  195. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  196. package/dist/components/Variables/{TemplateVariable.d.ts → Variable.d.ts} +6 -5
  197. package/dist/components/Variables/Variable.d.ts.map +1 -0
  198. package/dist/components/Variables/{TemplateVariable.js → Variable.js} +44 -61
  199. package/dist/components/Variables/Variable.js.map +1 -0
  200. package/dist/components/Variables/VariableEditor.d.ts +3 -2
  201. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  202. package/dist/components/Variables/VariableEditor.js +35 -41
  203. package/dist/components/Variables/VariableEditor.js.map +1 -1
  204. package/dist/components/Variables/VariableList.d.ts +4 -3
  205. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  206. package/dist/components/Variables/VariableList.js +21 -20
  207. package/dist/components/Variables/VariableList.js.map +1 -1
  208. package/dist/components/Variables/index.d.ts +1 -1
  209. package/dist/components/Variables/index.d.ts.map +1 -1
  210. package/dist/components/Variables/index.js +2 -2
  211. package/dist/components/Variables/index.js.map +1 -1
  212. package/dist/constants/styles.d.ts +4 -2
  213. package/dist/constants/styles.d.ts.map +1 -1
  214. package/dist/constants/styles.js +5 -3
  215. package/dist/constants/styles.js.map +1 -1
  216. package/dist/constants/user-interface-text.d.ts +3 -0
  217. package/dist/constants/user-interface-text.d.ts.map +1 -1
  218. package/dist/constants/user-interface-text.js +3 -0
  219. package/dist/constants/user-interface-text.js.map +1 -1
  220. package/dist/context/DashboardProvider/DashboardProvider.d.ts +6 -3
  221. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  222. package/dist/context/DashboardProvider/DashboardProvider.js +11 -9
  223. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  224. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts +4 -0
  225. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts.map +1 -0
  226. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +28 -0
  227. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -0
  228. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  229. package/dist/context/DashboardProvider/common.js +2 -2
  230. package/dist/context/DashboardProvider/common.js.map +1 -1
  231. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +36 -23
  232. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  233. package/dist/context/DashboardProvider/dashboard-provider-api.js +13 -6
  234. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  235. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +2 -1
  236. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts.map +1 -1
  237. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  238. package/dist/context/DashboardProvider/delete-panel-slice.js +1 -2
  239. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  240. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
  241. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  242. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
  243. package/dist/context/DashboardProvider/index.d.ts +1 -2
  244. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  245. package/dist/context/DashboardProvider/index.js.map +1 -1
  246. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -9
  247. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  248. package/dist/context/DashboardProvider/panel-editor-slice.js +4 -7
  249. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  250. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +2 -1
  251. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
  252. package/dist/context/DashboardProvider/panel-group-editor-slice.js +1 -2
  253. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  254. package/dist/context/DashboardProvider/panel-group-slice.d.ts +2 -2
  255. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  256. package/dist/context/DashboardProvider/panel-group-slice.js +7 -3
  257. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  258. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  259. package/dist/context/DashboardProvider/view-panel-slice.d.ts +21 -0
  260. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -0
  261. package/dist/context/DashboardProvider/view-panel-slice.js +73 -0
  262. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -0
  263. package/dist/context/DatasourceStoreProvider.d.ts +7 -7
  264. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  265. package/dist/context/DatasourceStoreProvider.js +18 -23
  266. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  267. package/dist/context/VariableProvider/VariableProvider.d.ts +119 -0
  268. package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -0
  269. package/dist/context/{TemplateVariableProvider/TemplateVariableProvider.js → VariableProvider/VariableProvider.js} +51 -54
  270. package/dist/context/VariableProvider/VariableProvider.js.map +1 -0
  271. package/dist/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.d.ts +1 -1
  272. package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -0
  273. package/dist/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.js +9 -12
  274. package/dist/context/VariableProvider/hydrationUtils.js.map +1 -0
  275. package/dist/context/VariableProvider/index.d.ts +2 -0
  276. package/dist/context/VariableProvider/index.d.ts.map +1 -0
  277. package/dist/{validation → context/VariableProvider}/index.js +2 -2
  278. package/dist/context/VariableProvider/index.js.map +1 -0
  279. package/dist/context/{TemplateVariableProvider → VariableProvider}/query-params.d.ts +2 -6
  280. package/dist/context/VariableProvider/query-params.d.ts.map +1 -0
  281. package/dist/context/{TemplateVariableProvider → VariableProvider}/query-params.js +1 -1
  282. package/dist/context/VariableProvider/query-params.js.map +1 -0
  283. package/dist/context/{TemplateVariableProvider → VariableProvider}/utils.d.ts +1 -1
  284. package/dist/context/VariableProvider/utils.d.ts.map +1 -0
  285. package/dist/context/{TemplateVariableProvider → VariableProvider}/utils.js +3 -3
  286. package/dist/context/VariableProvider/utils.js.map +1 -0
  287. package/dist/context/index.d.ts +1 -1
  288. package/dist/context/index.d.ts.map +1 -1
  289. package/dist/context/index.js +2 -2
  290. package/dist/context/index.js.map +1 -1
  291. package/dist/context/useDashboard.d.ts.map +1 -1
  292. package/dist/context/useDashboard.js +4 -4
  293. package/dist/context/useDashboard.js.map +1 -1
  294. package/dist/stories/decorators/WithDashboard.js +1 -1
  295. package/dist/stories/decorators/WithDashboard.js.map +1 -1
  296. package/dist/stories/decorators/WithDatasourceStore.js +1 -1
  297. package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
  298. package/dist/stories/decorators/{WithTemplateVariables.js → WithVariables.js} +9 -9
  299. package/dist/stories/decorators/WithVariables.js.map +1 -0
  300. package/dist/stories/decorators/index.js +2 -2
  301. package/dist/stories/decorators/index.js.map +1 -1
  302. package/dist/test/dashboard-provider.d.ts +1 -1
  303. package/dist/test/dashboard-provider.d.ts.map +1 -1
  304. package/dist/test/dashboard-provider.js.map +1 -1
  305. package/dist/test/datasource-provider.d.ts +2 -2
  306. package/dist/test/datasource-provider.d.ts.map +1 -1
  307. package/dist/test/datasource-provider.js.map +1 -1
  308. package/dist/test/plugin-registry.d.ts.map +1 -1
  309. package/dist/test/plugin-registry.js +4 -2
  310. package/dist/test/plugin-registry.js.map +1 -1
  311. package/dist/test/render.d.ts +2 -2
  312. package/dist/test/render.d.ts.map +1 -1
  313. package/dist/test/render.js +9 -7
  314. package/dist/test/render.js.map +1 -1
  315. package/dist/utils/panelUtils.d.ts.map +1 -1
  316. package/dist/utils/panelUtils.js.map +1 -1
  317. package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -2
  318. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  319. package/dist/views/ViewDashboard/DashboardApp.js +3 -3
  320. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  321. package/dist/views/ViewDashboard/ViewDashboard.d.ts +4 -3
  322. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  323. package/dist/views/ViewDashboard/ViewDashboard.js +8 -9
  324. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  325. package/package.json +9 -9
  326. package/dist/cjs/context/TemplateVariableProvider/index.js +0 -30
  327. package/dist/components/Variables/TemplateVariable.d.ts.map +0 -1
  328. package/dist/components/Variables/TemplateVariable.js.map +0 -1
  329. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +0 -77
  330. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +0 -1
  331. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +0 -1
  332. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +0 -1
  333. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +0 -1
  334. package/dist/context/TemplateVariableProvider/index.d.ts +0 -2
  335. package/dist/context/TemplateVariableProvider/index.d.ts.map +0 -1
  336. package/dist/context/TemplateVariableProvider/index.js.map +0 -1
  337. package/dist/context/TemplateVariableProvider/query-params.d.ts.map +0 -1
  338. package/dist/context/TemplateVariableProvider/query-params.js.map +0 -1
  339. package/dist/context/TemplateVariableProvider/utils.d.ts.map +0 -1
  340. package/dist/context/TemplateVariableProvider/utils.js.map +0 -1
  341. package/dist/stories/decorators/WithTemplateVariables.js.map +0 -1
  342. package/dist/validation/index.d.ts +0 -2
  343. package/dist/validation/index.d.ts.map +0 -1
  344. package/dist/validation/index.js.map +0 -1
  345. package/dist/validation/panel.d.ts +0 -19
  346. package/dist/validation/panel.d.ts.map +0 -1
  347. package/dist/validation/panel.js +0 -21
  348. package/dist/validation/panel.js.map +0 -1
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -27,14 +27,13 @@ const _components = require("@perses-dev/components");
27
27
  const _pluginsystem = require("@perses-dev/plugin-system");
28
28
  const _react = require("react");
29
29
  const _context = require("../../context");
30
+ const _DashboardProviderWithQueryParams = require("../../context/DashboardProvider/DashboardProviderWithQueryParams");
30
31
  const _DashboardApp = require("./DashboardApp");
31
32
  function ViewDashboard(props) {
32
33
  const { dashboardResource, datasourceApi, externalVariableDefinitions, dashboardTitleComponent, emptyDashboardProps, onSave, onDiscard, initialVariableIsSticky, isReadonly, isEditing, isCreating, sx, ...others } = props;
33
34
  const { spec } = dashboardResource;
34
- var _spec_duration;
35
- const dashboardDuration = (_spec_duration = spec.duration) !== null && _spec_duration !== void 0 ? _spec_duration : _core.DEFAULT_DASHBOARD_DURATION;
36
- var _spec_refreshInterval;
37
- const dashboardRefreshInterval = (_spec_refreshInterval = spec.refreshInterval) !== null && _spec_refreshInterval !== void 0 ? _spec_refreshInterval : _core.DEFAULT_REFRESH_INTERVAL;
35
+ const dashboardDuration = spec.duration ?? _core.DEFAULT_DASHBOARD_DURATION;
36
+ const dashboardRefreshInterval = spec.refreshInterval ?? _core.DEFAULT_REFRESH_INTERVAL;
38
37
  const initialTimeRange = (0, _pluginsystem.useInitialTimeRange)(dashboardDuration);
39
38
  const initialRefreshInterval = (0, _pluginsystem.useInitialRefreshInterval)(dashboardRefreshInterval);
40
39
  const { data } = (0, _pluginsystem.usePluginBuiltinVariableDefinitions)();
@@ -79,7 +78,7 @@ function ViewDashboard(props) {
79
78
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_context.DatasourceStoreProvider, {
80
79
  dashboardResource: dashboardResource,
81
80
  datasourceApi: datasourceApi,
82
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_context.DashboardProvider, {
81
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardProviderWithQueryParams.DashboardProviderWithQueryParams, {
83
82
  initialState: {
84
83
  dashboardResource,
85
84
  isEditMode: !!isEditing
@@ -87,10 +86,10 @@ function ViewDashboard(props) {
87
86
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TimeRangeProviderWithQueryParams, {
88
87
  initialTimeRange: initialTimeRange,
89
88
  initialRefreshInterval: initialRefreshInterval,
90
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_context.TemplateVariableProviderWithQueryParams, {
89
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_context.VariableProviderWithQueryParams, {
91
90
  initialVariableDefinitions: spec.variables,
92
91
  externalVariableDefinitions: externalVariableDefinitions,
93
- builtinVariables: builtinVariables,
92
+ builtinVariableDefinitions: builtinVariables,
94
93
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
95
94
  sx: (0, _components.combineSx)({
96
95
  display: 'flex',
@@ -1,2 +1,3 @@
1
- export declare const AddGroupButton: () => import("react/jsx-runtime").JSX.Element;
1
+ import { ReactElement } from 'react';
2
+ export declare const AddGroupButton: () => ReactElement;
2
3
  //# sourceMappingURL=AddGroupButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AddGroupButton.d.ts","sourceRoot":"","sources":["../../../src/components/AddGroupButton/AddGroupButton.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,cAAc,+CAe1B,CAAC"}
1
+ {"version":3,"file":"AddGroupButton.d.ts","sourceRoot":"","sources":["../../../src/components/AddGroupButton/AddGroupButton.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAIrC,eAAO,MAAM,cAAc,QAAO,YAejC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/AddGroupButton/AddGroupButton.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 { Button } from '@mui/material';\nimport AddGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport const AddGroupButton = () => {\n const { openAddPanelGroup } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addGroup}>\n <Button\n startIcon={<AddGroupIcon />}\n onClick={openAddPanelGroup}\n aria-label={TOOLTIP_TEXT.addGroup}\n sx={editButtonStyle}\n >\n Panel Group\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddGroupIcon","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardActions","AddGroupButton","openAddPanelGroup","description","addGroup","startIcon","onClick","aria-label","sx"],"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,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,kBAAkB,iCAAiC;AAC1D,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,mBAAmB,QAAQ,gBAAgB;AAEpD,OAAO,MAAMC,iBAAiB;IAC5B,MAAM,EAAEC,iBAAiB,EAAE,GAAGF;IAE9B,qBACE,KAACH;QAAYM,aAAaL,aAAaM,QAAQ;kBAC7C,cAAA,KAACT;YACCU,yBAAW,KAACT;YACZU,SAASJ;YACTK,cAAYT,aAAaM,QAAQ;YACjCI,IAAIT;sBACL;;;AAKP,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/AddGroupButton/AddGroupButton.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 { Button } from '@mui/material';\nimport AddGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport const AddGroupButton = (): ReactElement => {\n const { openAddPanelGroup } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addGroup}>\n <Button\n startIcon={<AddGroupIcon />}\n onClick={openAddPanelGroup}\n aria-label={TOOLTIP_TEXT.addGroup}\n sx={editButtonStyle}\n >\n Panel Group\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddGroupIcon","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardActions","AddGroupButton","openAddPanelGroup","description","addGroup","startIcon","onClick","aria-label","sx"],"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,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,kBAAkB,iCAAiC;AAC1D,SAASC,WAAW,QAAQ,yBAAyB;AAErD,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,mBAAmB,QAAQ,gBAAgB;AAEpD,OAAO,MAAMC,iBAAiB;IAC5B,MAAM,EAAEC,iBAAiB,EAAE,GAAGF;IAE9B,qBACE,KAACH;QAAYM,aAAaL,aAAaM,QAAQ;kBAC7C,cAAA,KAACT;YACCU,yBAAW,KAACT;YACZU,SAASJ;YACTK,cAAYT,aAAaM,QAAQ;YACjCI,IAAIT;sBACL;;;AAKP,EAAE"}
@@ -1,4 +1,5 @@
1
1
  import { ButtonProps } from '@mui/material';
2
+ import { ReactElement } from 'react';
2
3
  export interface AddPanelButtonProps extends Pick<ButtonProps, 'fullWidth'> {
3
4
  /**
4
5
  * The variant to use to display the button.
@@ -13,5 +14,5 @@ export interface AddPanelButtonProps extends Pick<ButtonProps, 'fullWidth'> {
13
14
  */
14
15
  label?: string;
15
16
  }
16
- export declare const AddPanelButton: ({ variant, color, label, fullWidth, }: AddPanelButtonProps) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const AddPanelButton: ({ variant, color, label, fullWidth, }: AddPanelButtonProps) => ReactElement;
17
18
  //# sourceMappingURL=AddPanelButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AddPanelButton.d.ts","sourceRoot":"","sources":["../../../src/components/AddPanelButton/AddPanelButton.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAMpD,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IACzE;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,cAAc,0CAKxB,mBAAmB,4CAkBrB,CAAC"}
1
+ {"version":3,"file":"AddPanelButton.d.ts","sourceRoot":"","sources":["../../../src/components/AddPanelButton/AddPanelButton.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAIrC,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IACzE;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,cAAc,0CAKxB,mBAAmB,KAAG,YAkBxB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/AddPanelButton/AddPanelButton.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 { Button, ButtonProps } from '@mui/material';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport interface AddPanelButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport const AddPanelButton = ({\n variant = 'text',\n color = 'primary',\n label = 'Panel',\n fullWidth,\n}: AddPanelButtonProps) => {\n const { openAddPanel } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addPanel}>\n <Button\n startIcon={<AddPanelIcon />}\n onClick={openAddPanel}\n aria-label={TOOLTIP_TEXT.addPanel}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddPanelIcon","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardActions","AddPanelButton","variant","color","label","fullWidth","openAddPanel","description","addPanel","startIcon","onClick","aria-label","sx"],"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,MAAM,QAAqB,gBAAgB;AACpD,OAAOC,kBAAkB,sCAAsC;AAC/D,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,mBAAmB,QAAQ,gBAAgB;AAmBpD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,UAAU,MAAM,EAChBC,QAAQ,SAAS,EACjBC,QAAQ,OAAO,EACfC,SAAS,EACW;IACpB,MAAM,EAAEC,YAAY,EAAE,GAAGN;IAEzB,qBACE,KAACH;QAAYU,aAAaT,aAAaU,QAAQ;kBAC7C,cAAA,KAACb;YACCc,yBAAW,KAACb;YACZc,SAASJ;YACTK,cAAYb,aAAaU,QAAQ;YACjCN,SAASA;YACTC,OAAOA;YACPE,WAAWA;YACXO,IAAIb;sBAEHK;;;AAIT,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/AddPanelButton/AddPanelButton.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 { Button, ButtonProps } from '@mui/material';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { InfoTooltip } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardActions } from '../../context';\n\nexport interface AddPanelButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport const AddPanelButton = ({\n variant = 'text',\n color = 'primary',\n label = 'Panel',\n fullWidth,\n}: AddPanelButtonProps): ReactElement => {\n const { openAddPanel } = useDashboardActions();\n\n return (\n <InfoTooltip description={TOOLTIP_TEXT.addPanel}>\n <Button\n startIcon={<AddPanelIcon />}\n onClick={openAddPanel}\n aria-label={TOOLTIP_TEXT.addPanel}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n );\n};\n"],"names":["Button","AddPanelIcon","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardActions","AddPanelButton","variant","color","label","fullWidth","openAddPanel","description","addPanel","startIcon","onClick","aria-label","sx"],"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,MAAM,QAAqB,gBAAgB;AACpD,OAAOC,kBAAkB,sCAAsC;AAC/D,SAASC,WAAW,QAAQ,yBAAyB;AAErD,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,mBAAmB,QAAQ,gBAAgB;AAmBpD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,UAAU,MAAM,EAChBC,QAAQ,SAAS,EACjBC,QAAQ,OAAO,EACfC,SAAS,EACW;IACpB,MAAM,EAAEC,YAAY,EAAE,GAAGN;IAEzB,qBACE,KAACH;QAAYU,aAAaT,aAAaU,QAAQ;kBAC7C,cAAA,KAACb;YACCc,yBAAW,KAACb;YACZc,SAASJ;YACTK,cAAYb,aAAaU,QAAQ;YACjCN,SAASA;YACTC,OAAOA;YACPE,WAAWA;YACXO,IAAIb;sBAEHK;;;AAIT,EAAE"}
@@ -1,4 +1,5 @@
1
1
  import { BoxProps } from '@mui/material';
2
+ import { ReactElement } from 'react';
2
3
  import { EmptyDashboardProps } from '../EmptyDashboard';
3
4
  import { PanelOptions } from '../Panel';
4
5
  export type DashboardProps = BoxProps & {
@@ -13,5 +14,5 @@ export type DashboardProps = BoxProps & {
13
14
  /**
14
15
  * Renders a Dashboard for the provided Dashboard spec.
15
16
  */
16
- export declare function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps): import("react/jsx-runtime").JSX.Element;
17
+ export declare function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps): ReactElement;
17
18
  //# sourceMappingURL=Dashboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG;IACtC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,mBAAmB,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,EAAE,cAAc,2CAmB3F"}
1
+ {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../../src/components/Dashboard/Dashboard.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAU,MAAM,OAAO,CAAC;AAG7C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG;IACtC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAGF;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,mBAAmB,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,EAAE,cAAc,GAAG,YAAY,CA2B1G"}
@@ -13,19 +13,25 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
16
+ import { useRef } from 'react';
16
17
  import { usePanelGroupIds } from '../../context';
17
18
  import { GridLayout } from '../GridLayout';
18
19
  import { EmptyDashboard } from '../EmptyDashboard';
20
+ const HEADER_HEIGHT = 165; // Approximate height of the header in dashboard view (including the navbar and variables toolbar)
19
21
  /**
20
22
  * Renders a Dashboard for the provided Dashboard spec.
21
23
  */ export function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }) {
22
24
  const panelGroupIds = usePanelGroupIds();
25
+ const boxRef = useRef(null);
23
26
  const isEmpty = !panelGroupIds.length;
27
+ const dashboardTopPosition = boxRef.current?.getBoundingClientRect().top ?? HEADER_HEIGHT;
28
+ const panelFullHeight = window.innerHeight - dashboardTopPosition - window.scrollY;
24
29
  return /*#__PURE__*/ _jsx(Box, {
25
30
  ...boxProps,
26
31
  sx: {
27
32
  height: '100%'
28
33
  },
34
+ ref: boxRef,
29
35
  children: /*#__PURE__*/ _jsxs(ErrorBoundary, {
30
36
  FallbackComponent: ErrorAlert,
31
37
  children: [
@@ -41,7 +47,8 @@ import { EmptyDashboard } from '../EmptyDashboard';
41
47
  }),
42
48
  !isEmpty && panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ _jsx(GridLayout, {
43
49
  panelGroupId: panelGroupId,
44
- panelOptions: panelOptions
50
+ panelOptions: panelOptions,
51
+ panelFullHeight: panelFullHeight
45
52
  }, panelGroupId))
46
53
  ]
47
54
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Dashboard/Dashboard.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 { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\nimport { PanelOptions } from '../Panel';\nexport type DashboardProps = BoxProps & {\n /**\n * Props for `EmptyDashboard` component that will be rendered when the dashboard\n * is empty (i.e. has no panel groups). If not specified, the defaults will\n * be used.\n */\n emptyDashboardProps?: EmptyDashboardProps;\n panelOptions?: PanelOptions;\n};\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps) {\n const panelGroupIds = usePanelGroupIds();\n const isEmpty = !panelGroupIds.length;\n\n return (\n <Box {...boxProps} sx={{ height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {isEmpty && (\n <Box sx={{ height: '100%', display: 'flex', alignItems: 'center' }}>\n <EmptyDashboard {...emptyDashboardProps} />\n </Box>\n )}\n {!isEmpty &&\n panelGroupIds.map((panelGroupId) => (\n <GridLayout key={panelGroupId} panelGroupId={panelGroupId} panelOptions={panelOptions} />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","usePanelGroupIds","GridLayout","EmptyDashboard","Dashboard","emptyDashboardProps","panelOptions","boxProps","panelGroupIds","isEmpty","length","sx","height","FallbackComponent","display","alignItems","map","panelGroupId"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,QAAkB,gBAAgB;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,yBAAyB;AACnE,SAASC,gBAAgB,QAAQ,gBAAgB;AACjD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,cAAc,QAA6B,oBAAoB;AAYxE;;CAEC,GACD,OAAO,SAASC,UAAU,EAAEC,mBAAmB,EAAEC,YAAY,EAAE,GAAGC,UAA0B;IAC1F,MAAMC,gBAAgBP;IACtB,MAAMQ,UAAU,CAACD,cAAcE,MAAM;IAErC,qBACE,KAACZ;QAAK,GAAGS,QAAQ;QAAEI,IAAI;YAAEC,QAAQ;QAAO;kBACtC,cAAA,MAACb;YAAcc,mBAAmBb;;gBAC/BS,yBACC,KAACX;oBAAIa,IAAI;wBAAEC,QAAQ;wBAAQE,SAAS;wBAAQC,YAAY;oBAAS;8BAC/D,cAAA,KAACZ;wBAAgB,GAAGE,mBAAmB;;;gBAG1C,CAACI,WACAD,cAAcQ,GAAG,CAAC,CAACC,6BACjB,KAACf;wBAA8Be,cAAcA;wBAAcX,cAAcA;uBAAxDW;;;;AAK7B"}
1
+ {"version":3,"sources":["../../../src/components/Dashboard/Dashboard.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 { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { ReactElement, useRef } from 'react';\nimport { usePanelGroupIds } from '../../context';\nimport { GridLayout } from '../GridLayout';\nimport { EmptyDashboard, EmptyDashboardProps } from '../EmptyDashboard';\nimport { PanelOptions } from '../Panel';\nexport type DashboardProps = BoxProps & {\n /**\n * Props for `EmptyDashboard` component that will be rendered when the dashboard\n * is empty (i.e. has no panel groups). If not specified, the defaults will\n * be used.\n */\n emptyDashboardProps?: EmptyDashboardProps;\n panelOptions?: PanelOptions;\n};\nconst HEADER_HEIGHT = 165; // Approximate height of the header in dashboard view (including the navbar and variables toolbar)\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard({ emptyDashboardProps, panelOptions, ...boxProps }: DashboardProps): ReactElement {\n const panelGroupIds = usePanelGroupIds();\n const boxRef = useRef<HTMLDivElement>(null);\n const isEmpty = !panelGroupIds.length;\n const dashboardTopPosition = boxRef.current?.getBoundingClientRect().top ?? HEADER_HEIGHT;\n const panelFullHeight = window.innerHeight - dashboardTopPosition - window.scrollY;\n\n return (\n <Box {...boxProps} sx={{ height: '100%' }} ref={boxRef}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {isEmpty && (\n <Box sx={{ height: '100%', display: 'flex', alignItems: 'center' }}>\n <EmptyDashboard {...emptyDashboardProps} />\n </Box>\n )}\n {!isEmpty &&\n panelGroupIds.map((panelGroupId) => (\n <GridLayout\n key={panelGroupId}\n panelGroupId={panelGroupId}\n panelOptions={panelOptions}\n panelFullHeight={panelFullHeight}\n />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","useRef","usePanelGroupIds","GridLayout","EmptyDashboard","HEADER_HEIGHT","Dashboard","emptyDashboardProps","panelOptions","boxProps","panelGroupIds","boxRef","isEmpty","length","dashboardTopPosition","current","getBoundingClientRect","top","panelFullHeight","window","innerHeight","scrollY","sx","height","ref","FallbackComponent","display","alignItems","map","panelGroupId"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,QAAkB,gBAAgB;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,yBAAyB;AACnE,SAAuBC,MAAM,QAAQ,QAAQ;AAC7C,SAASC,gBAAgB,QAAQ,gBAAgB;AACjD,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,cAAc,QAA6B,oBAAoB;AAWxE,MAAMC,gBAAgB,KAAK,kGAAkG;AAE7H;;CAEC,GACD,OAAO,SAASC,UAAU,EAAEC,mBAAmB,EAAEC,YAAY,EAAE,GAAGC,UAA0B;IAC1F,MAAMC,gBAAgBR;IACtB,MAAMS,SAASV,OAAuB;IACtC,MAAMW,UAAU,CAACF,cAAcG,MAAM;IACrC,MAAMC,uBAAuBH,OAAOI,OAAO,EAAEC,wBAAwBC,OAAOZ;IAC5E,MAAMa,kBAAkBC,OAAOC,WAAW,GAAGN,uBAAuBK,OAAOE,OAAO;IAElF,qBACE,KAACvB;QAAK,GAAGW,QAAQ;QAAEa,IAAI;YAAEC,QAAQ;QAAO;QAAGC,KAAKb;kBAC9C,cAAA,MAACZ;YAAc0B,mBAAmBzB;;gBAC/BY,yBACC,KAACd;oBAAIwB,IAAI;wBAAEC,QAAQ;wBAAQG,SAAS;wBAAQC,YAAY;oBAAS;8BAC/D,cAAA,KAACvB;wBAAgB,GAAGG,mBAAmB;;;gBAG1C,CAACK,WACAF,cAAckB,GAAG,CAAC,CAACC,6BACjB,KAAC1B;wBAEC0B,cAAcA;wBACdrB,cAAcA;wBACdU,iBAAiBA;uBAHZW;;;;AASnB"}
@@ -1,8 +1,9 @@
1
+ import { ReactElement } from 'react';
1
2
  import { SxProps, Theme } from '@mui/material';
2
3
  interface DashboardStickyToolbarProps {
3
4
  initialVariableIsSticky?: boolean;
4
5
  sx?: SxProps<Theme>;
5
6
  }
6
- export declare function DashboardStickyToolbar(props: DashboardStickyToolbarProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function DashboardStickyToolbar(props: DashboardStickyToolbarProps): ReactElement;
7
8
  export {};
8
9
  //# sourceMappingURL=DashboardStickyToolbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardStickyToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardStickyToolbar/DashboardStickyToolbar.tsx"],"names":[],"mappings":"AAcA,OAAO,EAKL,OAAO,EACP,KAAK,EAIN,MAAM,eAAe,CAAC;AAMvB,UAAU,2BAA2B;IACnC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACrB;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,2CAuExE"}
1
+ {"version":3,"file":"DashboardStickyToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardStickyToolbar/DashboardStickyToolbar.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAC/C,OAAO,EAKL,OAAO,EACP,KAAK,EAIN,MAAM,eAAe,CAAC;AAMvB,UAAU,2BAA2B;IACnC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;CACrB;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,GAAG,YAAY,CAuEvF"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -16,7 +16,7 @@ import { AppBar, Box, IconButton, Stack, useMediaQuery, useScrollTrigger, useThe
16
16
  import PinOutline from 'mdi-material-ui/PinOutline';
17
17
  import PinOffOutline from 'mdi-material-ui/PinOffOutline';
18
18
  import { TimeRangeControls } from '@perses-dev/plugin-system';
19
- import { TemplateVariableList } from '../Variables';
19
+ import { VariableList } from '../Variables';
20
20
  export function DashboardStickyToolbar(props) {
21
21
  const [isPin, setIsPin] = useState(props.initialVariableIsSticky);
22
22
  const scrollTrigger = useScrollTrigger({
@@ -69,7 +69,7 @@ export function DashboardStickyToolbar(props) {
69
69
  },
70
70
  gap: 1,
71
71
  children: [
72
- /*#__PURE__*/ _jsx(TemplateVariableList, {}),
72
+ /*#__PURE__*/ _jsx(VariableList, {}),
73
73
  props.initialVariableIsSticky && /*#__PURE__*/ _jsx(IconButton, {
74
74
  style: {
75
75
  width: 'fit-content',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DashboardStickyToolbar/DashboardStickyToolbar.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 { useState } from 'react';\nimport {\n AppBar,\n Box,\n IconButton,\n Stack,\n SxProps,\n Theme,\n useMediaQuery,\n useScrollTrigger,\n useTheme,\n} from '@mui/material';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport PinOffOutline from 'mdi-material-ui/PinOffOutline';\nimport { TimeRangeControls } from '@perses-dev/plugin-system';\nimport { TemplateVariableList } from '../Variables';\n\ninterface DashboardStickyToolbarProps {\n initialVariableIsSticky?: boolean;\n sx?: SxProps<Theme>;\n}\n\nexport function DashboardStickyToolbar(props: DashboardStickyToolbarProps) {\n const [isPin, setIsPin] = useState(props.initialVariableIsSticky);\n\n const scrollTrigger = useScrollTrigger({ disableHysteresis: true });\n const isSticky = scrollTrigger && props.initialVariableIsSticky && isPin;\n\n const isBiggerThanMd = useMediaQuery(useTheme().breakpoints.up('md'));\n\n return (\n // marginBottom={-1} counteracts the marginBottom={1} on every variable input.\n // The margin on the inputs is for spacing between inputs, but is not meant to add space to bottom of the container.\n <Box marginBottom={-1} data-testid=\"variable-list\">\n <AppBar\n color=\"inherit\"\n position={isSticky ? 'fixed' : 'static'}\n elevation={isSticky ? 4 : 0}\n sx={{ backgroundColor: 'inherit', ...props.sx }}\n >\n <Box\n display=\"flex\"\n justifyContent=\"space-between\"\n sx={{\n flexDirection: isBiggerThanMd ? 'row' : 'column',\n }}\n >\n <Box\n display=\"flex\"\n flexWrap={!isSticky && isBiggerThanMd ? 'wrap' : 'nowrap'}\n maxWidth={isSticky || !isBiggerThanMd ? '100vw' : '100%'}\n maxHeight=\"150px\" // Limit the vertical space used to ~3 rows of variables\n pt={1}\n pl={isSticky ? 1 : 0}\n mt={isSticky && isBiggerThanMd ? 0.5 : 0}\n ml={isSticky && isBiggerThanMd ? 0.5 : 0}\n sx={{\n overflowX: !isSticky && isBiggerThanMd ? 'hidden' : 'auto',\n // Firefox:\n scrollbarWidth: 'thin',\n // Safari and Chrome:\n '&::-webkit-scrollbar': {\n height: '8px',\n backgroundColor: (theme) => theme.palette.grey['300'],\n },\n '&::-webkit-scrollbar-thumb': {\n background: (theme) => theme.palette.grey['600'],\n },\n }}\n gap={1}\n >\n <TemplateVariableList />\n {props.initialVariableIsSticky && (\n <IconButton style={{ width: 'fit-content', height: 'fit-content' }} onClick={() => setIsPin(!isPin)}>\n {isPin ? <PinOutline /> : <PinOffOutline />}\n </IconButton>\n )}\n </Box>\n {isSticky && (\n <Stack\n m={isBiggerThanMd ? 1.5 : 1}\n mt={isBiggerThanMd ? 1.5 : 0}\n ml={isBiggerThanMd ? 1.5 : 'auto'}\n direction=\"row\"\n justifyContent=\"end\"\n >\n <TimeRangeControls></TimeRangeControls>\n </Stack>\n )}\n </Box>\n </AppBar>\n </Box>\n );\n}\n"],"names":["useState","AppBar","Box","IconButton","Stack","useMediaQuery","useScrollTrigger","useTheme","PinOutline","PinOffOutline","TimeRangeControls","TemplateVariableList","DashboardStickyToolbar","props","isPin","setIsPin","initialVariableIsSticky","scrollTrigger","disableHysteresis","isSticky","isBiggerThanMd","breakpoints","up","marginBottom","data-testid","color","position","elevation","sx","backgroundColor","display","justifyContent","flexDirection","flexWrap","maxWidth","maxHeight","pt","pl","mt","ml","overflowX","scrollbarWidth","height","theme","palette","grey","background","gap","style","width","onClick","m","direction"],"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,QAAQ,QAAQ,QAAQ;AACjC,SACEC,MAAM,EACNC,GAAG,EACHC,UAAU,EACVC,KAAK,EAGLC,aAAa,EACbC,gBAAgB,EAChBC,QAAQ,QACH,gBAAgB;AACvB,OAAOC,gBAAgB,6BAA6B;AACpD,OAAOC,mBAAmB,gCAAgC;AAC1D,SAASC,iB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BACF;wBACAE,KAAK;;0CAEL,KAACpC;4BACAE,MAAMG,uBAAuB,kBAC5B,KAACb;gCAAW6C,OAAO;oCAAEC,OAAO;oCAAeP,QAAQ;gCAAc;gCAAGQ,SAAS,IAAMnC,SAAS,CAACD;0CAC1FA,sBAAQ,KAACN,gCAAgB,KAACC;;;;oBAIhCU,0BACC,KAACf;wBACC+C,GAAG/B,iBAAiB,MAAM;wBAC1BkB,IAAIlB,iBAAiB,MAAM;wBAC3BmB,IAAInB,iBAAiB,MAAM;wBAC3BgC,WAAU;wBACVrB,gBAAe;kCAEf,cAAA,KAACrB;;;;;;AAOf"}
1
+ {"version":3,"sources":["../../../src/components/DashboardStickyToolbar/DashboardStickyToolbar.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 { ReactElement, useState } from 'react';\nimport {\n AppBar,\n Box,\n IconButton,\n Stack,\n SxProps,\n Theme,\n useMediaQuery,\n useScrollTrigger,\n useTheme,\n} from '@mui/material';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport PinOffOutline from 'mdi-material-ui/PinOffOutline';\nimport { TimeRangeControls } from '@perses-dev/plugin-system';\nimport { VariableList } from '../Variables';\n\ninterface DashboardStickyToolbarProps {\n initialVariableIsSticky?: boolean;\n sx?: SxProps<Theme>;\n}\n\nexport function DashboardStickyToolbar(props: DashboardStickyToolbarProps): ReactElement {\n const [isPin, setIsPin] = useState(props.initialVariableIsSticky);\n\n const scrollTrigger = useScrollTrigger({ disableHysteresis: true });\n const isSticky = scrollTrigger && props.initialVariableIsSticky && isPin;\n\n const isBiggerThanMd = useMediaQuery(useTheme().breakpoints.up('md'));\n\n return (\n // marginBottom={-1} counteracts the marginBottom={1} on every variable input.\n // The margin on the inputs is for spacing between inputs, but is not meant to add space to bottom of the container.\n <Box marginBottom={-1} data-testid=\"variable-list\">\n <AppBar\n color=\"inherit\"\n position={isSticky ? 'fixed' : 'static'}\n elevation={isSticky ? 4 : 0}\n sx={{ backgroundColor: 'inherit', ...props.sx }}\n >\n <Box\n display=\"flex\"\n justifyContent=\"space-between\"\n sx={{\n flexDirection: isBiggerThanMd ? 'row' : 'column',\n }}\n >\n <Box\n display=\"flex\"\n flexWrap={!isSticky && isBiggerThanMd ? 'wrap' : 'nowrap'}\n maxWidth={isSticky || !isBiggerThanMd ? '100vw' : '100%'}\n maxHeight=\"150px\" // Limit the vertical space used to ~3 rows of variables\n pt={1}\n pl={isSticky ? 1 : 0}\n mt={isSticky && isBiggerThanMd ? 0.5 : 0}\n ml={isSticky && isBiggerThanMd ? 0.5 : 0}\n sx={{\n overflowX: !isSticky && isBiggerThanMd ? 'hidden' : 'auto',\n // Firefox:\n scrollbarWidth: 'thin',\n // Safari and Chrome:\n '&::-webkit-scrollbar': {\n height: '8px',\n backgroundColor: (theme) => theme.palette.grey['300'],\n },\n '&::-webkit-scrollbar-thumb': {\n background: (theme) => theme.palette.grey['600'],\n },\n }}\n gap={1}\n >\n <VariableList />\n {props.initialVariableIsSticky && (\n <IconButton style={{ width: 'fit-content', height: 'fit-content' }} onClick={() => setIsPin(!isPin)}>\n {isPin ? <PinOutline /> : <PinOffOutline />}\n </IconButton>\n )}\n </Box>\n {isSticky && (\n <Stack\n m={isBiggerThanMd ? 1.5 : 1}\n mt={isBiggerThanMd ? 1.5 : 0}\n ml={isBiggerThanMd ? 1.5 : 'auto'}\n direction=\"row\"\n justifyContent=\"end\"\n >\n <TimeRangeControls />\n </Stack>\n )}\n </Box>\n </AppBar>\n </Box>\n );\n}\n"],"names":["useState","AppBar","Box","IconButton","Stack","useMediaQuery","useScrollTrigger","useTheme","PinOutline","PinOffOutline","TimeRangeControls","VariableList","DashboardStickyToolbar","props","isPin","setIsPin","initialVariableIsSticky","scrollTrigger","disableHysteresis","isSticky","isBiggerThanMd","breakpoints","up","marginBottom","data-testid","color","position","elevation","sx","backgroundColor","display","justifyContent","flexDirection","flexWrap","maxWidth","maxHeight","pt","pl","mt","ml","overflowX","scrollbarWidth","height","theme","palette","grey","background","gap","style","width","onClick","m","direction"],"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,SACEC,MAAM,EACNC,GAAG,EACHC,UAAU,EACVC,KAAK,EAGLC,aAAa,EACbC,gBAAgB,EAChBC,QAAQ,QACH,gBAAgB;AACvB,OAAOC,gBAAgB,6BAA6B;AACpD,OAAOC,mBAAmB,gCAAgC;AAC1D,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,YAAY,QAAQ,eAAe;AAO5C,OAAO,SAASC,uBAAuBC,KAAkC;IACvE,MAAM,CAACC,OAAOC,SAAS,GAAGf,SAASa,MAAMG,uBAAuB;IAEhE,MAAMC,gBAAgBX,iBAAiB;QAAEY,mBAAmB;IAAK;IACjE,MAAMC,WAAWF,iBAAiBJ,MAAMG,uBAAuB,IAAIF;IAEnE,MAAMM,iBAAiBf,cAAcE,WAAWc,WAAW,CAACC,EAAE,CAAC;IAE/D,OACE,8EAA8E;IAC9E,oHAAoH;kBACpH,KAACpB;QAAIqB,cAAc,CAAC;QAAGC,eAAY;kBACjC,cAAA,KAACvB;YACCwB,OAAM;YACNC,UAAUP,WAAW,UAAU;YAC/BQ,WAAWR,WAAW,IAAI;YAC1BS,IAAI;gBAAEC,iBAAiB;gBAAW,GAAGhB,MAAMe,EAAE;YAAC;sBAE9C,cAAA,MAAC1B;gBACC4B,SAAQ;gBACRC,gBAAe;gBACfH,IAAI;oBACFI,eAAeZ,iBAAiB,QAAQ;gBAC1C;;kCAEA,MAAClB;wBACC4B,SAAQ;wBACRG,UAAU,CAACd,YAAYC,iBAAiB,SAAS;wBACjDc,UAAUf,YAAY,CAACC,iBAAiB,UAAU;wBAClDe,WAAU,QAAQ,wDAAwD;;wBAC1EC,IAAI;wBACJC,IAAIlB,WAAW,IAAI;wBACnBmB,IAAInB,YAAYC,iBAAiB,MAAM;wBACvCmB,IAAIpB,YAAYC,iBAAiB,MAAM;wBACvCQ,IAAI;4BACFY,WAAW,CAACrB,YAAYC,iBAAiB,WAAW;4BACpD,WAAW;4BACXqB,gBAAgB;4BAChB,qBAAqB;4BACrB,wBAAwB;gCACtBC,QAAQ;gCACRb,iBAAiB,CAACc,QAAUA,MAAMC,OAAO,CAACC,IAAI,CAAC,MAAM;4BACvD;4BACA,8BAA8B;gCAC5BC,YAAY,CAACH,QAAUA,MAAMC,OAAO,CAACC,IAAI,CAAC,MAAM;4BAClD;wBACF;wBACAE,KAAK;;0CAEL,KAACpC;4BACAE,MAAMG,uBAAuB,kBAC5B,KAACb;gCAAW6C,OAAO;oCAAEC,OAAO;oCAAeP,QAAQ;gCAAc;gCAAGQ,SAAS,IAAMnC,SAAS,CAACD;0CAC1FA,sBAAQ,KAACN,gCAAgB,KAACC;;;;oBAIhCU,0BACC,KAACf;wBACC+C,GAAG/B,iBAAiB,MAAM;wBAC1BkB,IAAIlB,iBAAiB,MAAM;wBAC3BmB,IAAInB,iBAAiB,MAAM;wBAC3BgC,WAAU;wBACVrB,gBAAe;kCAEf,cAAA,KAACrB;;;;;;AAOf"}
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { ReactElement } from 'react';
2
2
  import { OnSaveDashboard } from '../../context';
3
3
  export interface DashboardToolbarProps {
4
4
  dashboardName: string;
@@ -9,5 +9,5 @@ export interface DashboardToolbarProps {
9
9
  onCancelButtonClick: () => void;
10
10
  onSave?: OnSaveDashboard;
11
11
  }
12
- export declare const DashboardToolbar: (props: DashboardToolbarProps) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const DashboardToolbar: (props: DashboardToolbarProps) => ReactElement;
13
13
  //# sourceMappingURL=DashboardToolbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,eAAe,EAAe,MAAM,eAAe,CAAC;AAW7D,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,4CA8F5D,CAAC"}
1
+ {"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardToolbar/DashboardToolbar.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,eAAe,EAAe,MAAM,eAAe,CAAC;AAW7D,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,KAAG,YA8F/D,CAAC"}
@@ -53,7 +53,7 @@ export const DashboardToolbar = (props)=>{
53
53
  ml: "auto",
54
54
  children: [
55
55
  isReadonly && /*#__PURE__*/ _jsx(Alert, {
56
- severity: 'warning',
56
+ severity: "warning",
57
57
  sx: {
58
58
  backgroundColor: 'transparent',
59
59
  padding: 0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DashboardToolbar/DashboardToolbar.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 { Typography, Stack, Button, Box, useTheme, useMediaQuery, Alert } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { TimeRangeControls } from '@perses-dev/plugin-system';\nimport { OnSaveDashboard, useEditMode } from '../../context';\nimport { AddPanelButton } from '../AddPanelButton';\nimport { AddGroupButton } from '../AddGroupButton';\nimport { DownloadButton } from '../DownloadButton';\nimport { EditVariablesButton } from '../Variables';\nimport { EditDatasourcesButton } from '../Datasources';\nimport { EditButton } from '../EditButton';\nimport { EditJsonButton } from '../EditJsonButton';\nimport { SaveDashboardButton } from '../SaveDashboardButton';\nimport { DashboardStickyToolbar } from '../DashboardStickyToolbar';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n onEditButtonClick: () => void;\n onCancelButtonClick: () => void;\n onSave?: OnSaveDashboard;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps) => {\n const {\n dashboardName,\n dashboardTitleComponent,\n initialVariableIsSticky,\n isReadonly,\n onEditButtonClick,\n onCancelButtonClick,\n onSave,\n } = props;\n\n const { isEditMode } = useEditMode();\n\n const isBiggerThanSm = useMediaQuery(useTheme().breakpoints.up('sm'));\n const isBiggerThanMd = useMediaQuery(useTheme().breakpoints.up('md'));\n\n const dashboardTitle = dashboardTitleComponent ? (\n dashboardTitleComponent\n ) : (\n <Typography variant=\"h2\">{dashboardName}</Typography>\n );\n\n const testId = 'dashboard-toolbar';\n\n return (\n <>\n <Stack data-testid={testId}>\n <Box\n px={2}\n py={1.5}\n display=\"flex\"\n sx={{ backgroundColor: (theme) => theme.palette.primary.main + (isEditMode ? '30' : '0') }}\n >\n {dashboardTitle}\n {isEditMode ? (\n <Stack direction=\"row\" gap={1} ml=\"auto\">\n {isReadonly && (\n <Alert severity={'warning'} sx={{ backgroundColor: 'transparent', padding: 0 }}>\n Dashboard managed via code only. Download JSON and commit changes to save.\n </Alert>\n )}\n <Stack direction=\"row\" spacing={0.5} ml={1} whiteSpace=\"nowrap\">\n <EditVariablesButton />\n <EditDatasourcesButton />\n <AddPanelButton />\n <AddGroupButton />\n </Stack>\n <SaveDashboardButton onSave={onSave} isDisabled={isReadonly} />\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n ) : (\n <>\n {isBiggerThanSm && (\n <Stack direction=\"row\" gap={1} ml=\"auto\">\n <EditButton onClick={onEditButtonClick} />\n </Stack>\n )}\n </>\n )}\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'start',\n padding: (theme) => theme.spacing(1, 2, 0, 2),\n flexDirection: isBiggerThanMd ? 'row' : 'column',\n flexWrap: 'nowrap',\n gap: 1,\n }}\n >\n <Box width=\"100%\">\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardStickyToolbar\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) => palette.background.default,\n }}\n />\n </ErrorBoundary>\n </Box>\n <Stack direction=\"row\" ml=\"auto\" flexWrap=\"wrap\" justifyContent=\"end\">\n <Stack direction=\"row\" spacing={1} mt={1} ml={1}>\n <TimeRangeControls />\n <DownloadButton />\n <EditJsonButton isReadonly={!isEditMode} />\n </Stack>\n </Stack>\n </Box>\n </Stack>\n </>\n );\n};\n"],"names":["Typography","Stack","Button","Box","useTheme","useMediaQuery","Alert","ErrorBoundary","ErrorAlert","TimeRangeControls","useEditMode","AddPanelButton","AddGroupButton","DownloadButton","EditVariablesButton","EditDatasourcesButton","EditButton","EditJsonButton","SaveDashboardButton","DashboardStickyToolbar","DashboardToolbar","props","dashboardName","dashboardTitleComponent","initialVariableIsSticky","isReadonly","onEditButtonClick","onCancelButtonClick","onSave","isEditMode","isBiggerThanSm","breakpoints","up","isBiggerThanMd","dashboardTitle","variant","testId","data-testid","px","py","display","sx","backgroundColor","theme","palette","primary","main","direction","gap","ml","severity","padding","spacing","whiteSpace","isDisabled","onClick","width","alignItems","flexDirection","flexWrap","FallbackComponent","background","default","justifyContent","mt"],"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,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,QAAQ,gBAAgB;AAC/F,SAASC,aAAa,EAAEC,UAAU,QAAQ,yBAAyB;AACnE,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SAA0BC,WAAW,QAAQ,gBAAgB;AAC7D,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,mBAAmB,QAAQ,eAAe;AACnD,SAASC,qBAAqB,QAAQ,iBAAiB;AACvD,SAASC,UAAU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,WAAU;gCAAMC,KAAK;gCAAGC,IAAG;0CAChC,cAAA,KAACjC;oCAAWuC,SAAS7B;;;;;;8BAM/B,MAACvB;oBACCsC,IAAI;wBACFD,SAAS;wBACTgB,OAAO;wBACPC,YAAY;wBACZN,SAAS,CAACR,QAAUA,MAAMS,OAAO,CAAC,GAAG,GAAG,GAAG;wBAC3CM,eAAezB,iBAAiB,QAAQ;wBACxC0B,UAAU;wBACVX,KAAK;oBACP;;sCAEA,KAAC7C;4BAAIqD,OAAM;sCACT,cAAA,KAACjD;gCAAcqD,mBAAmBpD;0CAChC,cAAA,KAACW;oCACCK,yBAAyBA;oCACzBiB,IAAI;wCACFC,iBAAiB,CAAC,EAAEE,OAAO,EAAE,GAAKA,QAAQiB,UAAU,CAACC,OAAO;oCAC9D;;;;sCAIN,KAAC7D;4BAAM8C,WAAU;4BAAME,IAAG;4BAAOU,UAAS;4BAAOI,gBAAe;sCAC9D,cAAA,MAAC9D;gCAAM8C,WAAU;gCAAMK,SAAS;gCAAGY,IAAI;gCAAGf,IAAI;;kDAC5C,KAACxC;kDACD,KAACI;kDACD,KAACI;wCAAeQ,YAAY,CAACI;;;;;;;;;;AAO3C,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/DashboardToolbar/DashboardToolbar.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 { Typography, Stack, Button, Box, useTheme, useMediaQuery, Alert } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { TimeRangeControls } from '@perses-dev/plugin-system';\nimport { ReactElement } from 'react';\nimport { OnSaveDashboard, useEditMode } from '../../context';\nimport { AddPanelButton } from '../AddPanelButton';\nimport { AddGroupButton } from '../AddGroupButton';\nimport { DownloadButton } from '../DownloadButton';\nimport { EditVariablesButton } from '../Variables';\nimport { EditDatasourcesButton } from '../Datasources';\nimport { EditButton } from '../EditButton';\nimport { EditJsonButton } from '../EditJsonButton';\nimport { SaveDashboardButton } from '../SaveDashboardButton';\nimport { DashboardStickyToolbar } from '../DashboardStickyToolbar';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n dashboardTitleComponent?: JSX.Element;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n onEditButtonClick: () => void;\n onCancelButtonClick: () => void;\n onSave?: OnSaveDashboard;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps): ReactElement => {\n const {\n dashboardName,\n dashboardTitleComponent,\n initialVariableIsSticky,\n isReadonly,\n onEditButtonClick,\n onCancelButtonClick,\n onSave,\n } = props;\n\n const { isEditMode } = useEditMode();\n\n const isBiggerThanSm = useMediaQuery(useTheme().breakpoints.up('sm'));\n const isBiggerThanMd = useMediaQuery(useTheme().breakpoints.up('md'));\n\n const dashboardTitle = dashboardTitleComponent ? (\n dashboardTitleComponent\n ) : (\n <Typography variant=\"h2\">{dashboardName}</Typography>\n );\n\n const testId = 'dashboard-toolbar';\n\n return (\n <>\n <Stack data-testid={testId}>\n <Box\n px={2}\n py={1.5}\n display=\"flex\"\n sx={{ backgroundColor: (theme) => theme.palette.primary.main + (isEditMode ? '30' : '0') }}\n >\n {dashboardTitle}\n {isEditMode ? (\n <Stack direction=\"row\" gap={1} ml=\"auto\">\n {isReadonly && (\n <Alert severity=\"warning\" sx={{ backgroundColor: 'transparent', padding: 0 }}>\n Dashboard managed via code only. Download JSON and commit changes to save.\n </Alert>\n )}\n <Stack direction=\"row\" spacing={0.5} ml={1} whiteSpace=\"nowrap\">\n <EditVariablesButton />\n <EditDatasourcesButton />\n <AddPanelButton />\n <AddGroupButton />\n </Stack>\n <SaveDashboardButton onSave={onSave} isDisabled={isReadonly} />\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n ) : (\n <>\n {isBiggerThanSm && (\n <Stack direction=\"row\" gap={1} ml=\"auto\">\n <EditButton onClick={onEditButtonClick} />\n </Stack>\n )}\n </>\n )}\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'start',\n padding: (theme) => theme.spacing(1, 2, 0, 2),\n flexDirection: isBiggerThanMd ? 'row' : 'column',\n flexWrap: 'nowrap',\n gap: 1,\n }}\n >\n <Box width=\"100%\">\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardStickyToolbar\n initialVariableIsSticky={initialVariableIsSticky}\n sx={{\n backgroundColor: ({ palette }) => palette.background.default,\n }}\n />\n </ErrorBoundary>\n </Box>\n <Stack direction=\"row\" ml=\"auto\" flexWrap=\"wrap\" justifyContent=\"end\">\n <Stack direction=\"row\" spacing={1} mt={1} ml={1}>\n <TimeRangeControls />\n <DownloadButton />\n <EditJsonButton isReadonly={!isEditMode} />\n </Stack>\n </Stack>\n </Box>\n </Stack>\n </>\n );\n};\n"],"names":["Typography","Stack","Button","Box","useTheme","useMediaQuery","Alert","ErrorBoundary","ErrorAlert","TimeRangeControls","useEditMode","AddPanelButton","AddGroupButton","DownloadButton","EditVariablesButton","EditDatasourcesButton","EditButton","EditJsonButton","SaveDashboardButton","DashboardStickyToolbar","DashboardToolbar","props","dashboardName","dashboardTitleComponent","initialVariableIsSticky","isReadonly","onEditButtonClick","onCancelButtonClick","onSave","isEditMode","isBiggerThanSm","breakpoints","up","isBiggerThanMd","dashboardTitle","variant","testId","data-testid","px","py","display","sx","backgroundColor","theme","palette","primary","main","direction","gap","ml","severity","padding","spacing","whiteSpace","isDisabled","onClick","width","alignItems","flexDirection","flexWrap","FallbackComponent","background","default","justifyContent","mt"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1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,YAAY,CAACI;;;;;;;;;;AAO3C,EAAE"}
@@ -1,7 +1,8 @@
1
1
  import { DatasourceSpec } from '@perses-dev/core';
2
+ import { ReactElement } from 'react';
2
3
  export declare function DatasourceEditor(props: {
3
4
  datasources: Record<string, DatasourceSpec>;
4
5
  onChange: (datasources: Record<string, DatasourceSpec>) => void;
5
6
  onCancel: () => void;
6
- }): import("react/jsx-runtime").JSX.Element;
7
+ }): ReactElement;
7
8
  //# sourceMappingURL=DatasourceEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatasourceEditor.d.ts","sourceRoot":"","sources":["../../../src/components/Datasources/DatasourceEditor.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAAgC,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMhF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,IAAI,CAAC;IAChE,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,2CAyJA"}
1
+ {"version":3,"file":"DatasourceEditor.d.ts","sourceRoot":"","sources":["../../../src/components/Datasources/DatasourceEditor.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAAgC,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAI/C,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,IAAI,CAAC;IAChE,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,GAAG,YAAY,CA4Jf"}
@@ -15,7 +15,7 @@ import { Box, Button, IconButton, Stack, Table, TableBody, TableCell, TableConta
15
15
  import AddIcon from 'mdi-material-ui/Plus';
16
16
  import PencilIcon from 'mdi-material-ui/Pencil';
17
17
  import TrashIcon from 'mdi-material-ui/TrashCan';
18
- import { DatasourceEditorForm } from '@perses-dev/plugin-system';
18
+ import { DatasourceEditorForm, ValidationProvider } from '@perses-dev/plugin-system';
19
19
  import { useState } from 'react';
20
20
  import { useImmer } from 'use-immer';
21
21
  import { useDiscardChangesConfirmationDialog } from '../../context';
@@ -62,27 +62,29 @@ export function DatasourceEditor(props) {
62
62
  };
63
63
  const editDatasource = (name)=>{
64
64
  setDatasourceFormAction('update');
65
- var _datasources_name;
66
65
  setDatasourceEdit({
67
66
  name: name,
68
- spec: (_datasources_name = datasources[name]) !== null && _datasources_name !== void 0 ? _datasources_name : defaultSpec
67
+ spec: datasources[name] ?? defaultSpec
69
68
  });
70
69
  };
71
70
  return /*#__PURE__*/ _jsx(_Fragment, {
72
- children: datasourceEdit ? /*#__PURE__*/ _jsx(DatasourceEditorForm, {
73
- initialDatasourceDefinition: datasourceEdit,
74
- initialAction: datasourceFormAction,
75
- isDraft: true,
76
- onSave: (name, spec)=>{
77
- setDatasources((draft)=>{
78
- delete draft[datasourceEdit.name]; // to tackle the case where datasource name has been changed
79
- draft[name] = spec;
71
+ children: datasourceEdit ? /*#__PURE__*/ _jsx(ValidationProvider, {
72
+ children: /*#__PURE__*/ _jsx(DatasourceEditorForm, {
73
+ initialDatasourceDefinition: datasourceEdit,
74
+ action: datasourceFormAction,
75
+ isDraft: true,
76
+ onActionChange: setDatasourceFormAction,
77
+ onSave: (def)=>{
78
+ setDatasources((draft)=>{
79
+ delete draft[datasourceEdit.name]; // to tackle the case where datasource name has been changed
80
+ draft[def.name] = def.spec;
81
+ setDatasourceEdit(null);
82
+ });
83
+ },
84
+ onClose: ()=>{
80
85
  setDatasourceEdit(null);
81
- });
82
- },
83
- onClose: ()=>{
84
- setDatasourceEdit(null);
85
- }
86
+ }
87
+ })
86
88
  }) : /*#__PURE__*/ _jsxs(_Fragment, {
87
89
  children: [
88
90
  /*#__PURE__*/ _jsxs(Box, {
@@ -158,8 +160,6 @@ export function DatasourceEditor(props) {
158
160
  }),
159
161
  /*#__PURE__*/ _jsx(TableBody, {
160
162
  children: Object.entries(datasources).map(([name, spec])=>{
161
- var _spec_display;
162
- var _spec_display_description;
163
163
  return /*#__PURE__*/ _jsxs(TableRow, {
164
164
  children: [
165
165
  /*#__PURE__*/ _jsx(TableCell, {
@@ -174,7 +174,7 @@ export function DatasourceEditor(props) {
174
174
  children: spec.plugin.kind
175
175
  }),
176
176
  /*#__PURE__*/ _jsx(TableCell, {
177
- children: (_spec_display_description = (_spec_display = spec.display) === null || _spec_display === void 0 ? void 0 : _spec_display.description) !== null && _spec_display_description !== void 0 ? _spec_display_description : ''
177
+ children: spec.display?.description ?? ''
178
178
  }),
179
179
  /*#__PURE__*/ _jsxs(TableCell, {
180
180
  align: "right",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Datasources/DatasourceEditor.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 {\n Box,\n Button,\n IconButton,\n Stack,\n Table,\n TableBody,\n TableCell,\n TableContainer,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport PencilIcon from 'mdi-material-ui/Pencil';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\nimport { Action, DatasourceDefinition, DatasourceSpec } from '@perses-dev/core';\nimport { DatasourceEditorForm } from '@perses-dev/plugin-system';\nimport { useState } from 'react';\nimport { useImmer } from 'use-immer';\nimport { useDiscardChangesConfirmationDialog } from '../../context';\n\nexport function DatasourceEditor(props: {\n datasources: Record<string, DatasourceSpec>;\n onChange: (datasources: Record<string, DatasourceSpec>) => void;\n onCancel: () => void;\n}) {\n const [datasources, setDatasources] = useImmer(props.datasources);\n const [datasourceFormAction, setDatasourceFormAction] = useState<Action>('update');\n const [datasourceEdit, setDatasourceEdit] = useState<DatasourceDefinition | null>(null);\n const defaultSpec: DatasourceSpec = {\n default: false,\n plugin: {\n // TODO: find a way to avoid assuming that the PrometheusDatasource plugin is installed\n kind: 'PrometheusDatasource',\n spec: {},\n },\n };\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleCancel = () => {\n if (JSON.stringify(props.datasources) !== JSON.stringify(datasources)) {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n closeDiscardChangesConfirmationDialog();\n props.onCancel();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n description:\n 'You have unapplied changes. Are you sure you want to discard these changes? Changes cannot be recovered.',\n });\n } else {\n props.onCancel();\n }\n };\n\n const removeDatasource = (name: string) => {\n setDatasources((draft) => {\n delete draft[name];\n });\n };\n\n const addDatasource = () => {\n setDatasourceFormAction('create');\n setDatasourceEdit({\n name: 'NewDatasource',\n spec: defaultSpec,\n });\n };\n\n const editDatasource = (name: string) => {\n setDatasourceFormAction('update');\n setDatasourceEdit({\n name: name,\n spec: datasources[name] ?? defaultSpec,\n });\n };\n\n return (\n <>\n {datasourceEdit ? (\n <DatasourceEditorForm\n initialDatasourceDefinition={datasourceEdit}\n initialAction={datasourceFormAction}\n isDraft={true}\n onSave={(name: string, spec: DatasourceSpec) => {\n setDatasources((draft) => {\n delete draft[datasourceEdit.name]; // to tackle the case where datasource name has been changed\n draft[name] = spec;\n setDatasourceEdit(null);\n });\n }}\n onClose={() => {\n setDatasourceEdit(null);\n }}\n />\n ) : (\n <>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">Edit Dashboard Datasources</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button\n disabled={props.datasources === datasources}\n variant=\"contained\"\n onClick={() => {\n props.onChange(datasources);\n }}\n >\n Apply\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Stack spacing={2}>\n <Stack spacing={2}>\n <TableContainer>\n <Table sx={{ minWidth: 650 }} aria-label=\"table of datasources\">\n <TableHead>\n <TableRow>\n <TableCell>Name</TableCell>\n <TableCell>Type</TableCell>\n <TableCell>Description</TableCell>\n <TableCell align=\"right\">Actions</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {Object.entries(datasources).map(([name, spec]) => {\n return (\n <TableRow key={name}>\n <TableCell component=\"th\" scope=\"row\" sx={{ fontWeight: 'bold' }}>\n {name}\n </TableCell>\n <TableCell>{spec.plugin.kind}</TableCell>\n <TableCell>{spec.display?.description ?? ''}</TableCell>\n <TableCell align=\"right\" sx={{ whiteSpace: 'nowrap' }}>\n <IconButton onClick={() => editDatasource(name)}>\n <PencilIcon />\n </IconButton>\n <IconButton onClick={() => removeDatasource(name)}>\n <TrashIcon />\n </IconButton>\n </TableCell>\n </TableRow>\n );\n })}\n </TableBody>\n </Table>\n </TableContainer>\n <Box display=\"flex\">\n <Button\n variant=\"contained\"\n startIcon={<AddIcon />}\n sx={{ marginLeft: 'auto' }}\n onClick={addDatasource}\n >\n Add Datasource\n </Button>\n </Box>\n </Stack>\n </Stack>\n </Box>\n </>\n )}\n </>\n );\n}\n"],"names":["Box","Button","IconButton","Stack","Table","TableBody","TableCell","TableContainer","TableHead","TableRow","Typography","AddIcon","PencilIcon","TrashIcon","DatasourceEditorForm","useState","useImmer","useDiscardChangesConfirmationDialog","DatasourceEditor","props","datasources","setDatasources","datasourceFormAction","setDatasourceFormAction","datasourceEdit","setDatasourceEdit","defaultSpec","default","plugin","kind","spec","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleCancel","JSON","stringify","onDiscardChanges","onCancel","description","removeDatasource","name","draft","addDatasource","editDatasource","initialDatasourceDefinition","initialAction","isDraft","onSave","onClose","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","onChange","color","overflowY","minWidth","aria-label","align","Object","entries","map","component","scope","fontWeight","whiteSpace","startIcon"],"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,SACEA,GAAG,EACHC,MAAM,EACNC,UAAU,EACVC,KAAK,EACLC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,cAAc,EACdC,SAAS,EACTC,QAAQ,EACRC,UAAU,QACL,gBAAgB;AACvB,OAAOC,aAAa,uBAAuB;AAC3C,OAAOC,gBAAgB,yBAAyB;AAChD,OAAOC,eAAe,2BAA2B;AAEjD,SAASC,oBAAoB,QAAQ,4BAA4B;AACjE,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,mCAAmC,QAAQ,gBAAgB;AAEpE,OAAO,SAASC,iBAAiBC,KAIhC;IACC,MAAM,CAACC,aAAaC,eAAe,GAAGL,SAASG,MAAMC,WAAW;IAChE,MAAM,CAACE,sBAAsBC,wBAAwB,GAAGR,SAAiB;IACzE,MAAM,CAACS,gBAAgBC,kBAAkB,GAAGV,SAAsC;IAClF,MAAMW,cAA8B;QAClCC,SAAS;QACTC,QAAQ;YACN,uFAAuF;YACvFC,MAAM;YACNC,MAAM,CAAC;Q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gDAgBnB;;;;;8CAIN,KAACxC;oCAAIkD,SAAQ;8CACX,cAAA,KAACjD;wCACCyD,SAAQ;wCACRkB,yBAAW,KAACjE;wCACZsC,IAAI;4CAAEW,YAAY;wCAAO;wCACzBE,SAASpB;kDACV;;;;;;;;;;AAWnB"}
1
+ {"version":3,"sources":["../../../src/components/Datasources/DatasourceEditor.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 {\n Box,\n Button,\n IconButton,\n Stack,\n Table,\n TableBody,\n TableCell,\n TableContainer,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport PencilIcon from 'mdi-material-ui/Pencil';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\nimport { Action, DatasourceDefinition, DatasourceSpec } from '@perses-dev/core';\nimport { DatasourceEditorForm, ValidationProvider } from '@perses-dev/plugin-system';\nimport { ReactElement, useState } from 'react';\nimport { useImmer } from 'use-immer';\nimport { useDiscardChangesConfirmationDialog } from '../../context';\n\nexport function DatasourceEditor(props: {\n datasources: Record<string, DatasourceSpec>;\n onChange: (datasources: Record<string, DatasourceSpec>) => void;\n onCancel: () => void;\n}): ReactElement {\n const [datasources, setDatasources] = useImmer(props.datasources);\n const [datasourceFormAction, setDatasourceFormAction] = useState<Action>('update');\n const [datasourceEdit, setDatasourceEdit] = useState<DatasourceDefinition | null>(null);\n const defaultSpec: DatasourceSpec = {\n default: false,\n plugin: {\n // TODO: find a way to avoid assuming that the PrometheusDatasource plugin is installed\n kind: 'PrometheusDatasource',\n spec: {},\n },\n };\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleCancel = (): void => {\n if (JSON.stringify(props.datasources) !== JSON.stringify(datasources)) {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n closeDiscardChangesConfirmationDialog();\n props.onCancel();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n description:\n 'You have unapplied changes. Are you sure you want to discard these changes? Changes cannot be recovered.',\n });\n } else {\n props.onCancel();\n }\n };\n\n const removeDatasource = (name: string): void => {\n setDatasources((draft) => {\n delete draft[name];\n });\n };\n\n const addDatasource = (): void => {\n setDatasourceFormAction('create');\n setDatasourceEdit({\n name: 'NewDatasource',\n spec: defaultSpec,\n });\n };\n\n const editDatasource = (name: string): void => {\n setDatasourceFormAction('update');\n setDatasourceEdit({\n name: name,\n spec: datasources[name] ?? defaultSpec,\n });\n };\n\n return (\n <>\n {datasourceEdit ? (\n <ValidationProvider>\n <DatasourceEditorForm\n initialDatasourceDefinition={datasourceEdit}\n action={datasourceFormAction}\n isDraft={true}\n onActionChange={setDatasourceFormAction}\n onSave={(def: DatasourceDefinition) => {\n setDatasources((draft) => {\n delete draft[datasourceEdit.name]; // to tackle the case where datasource name has been changed\n draft[def.name] = def.spec;\n setDatasourceEdit(null);\n });\n }}\n onClose={() => {\n setDatasourceEdit(null);\n }}\n />\n </ValidationProvider>\n ) : (\n <>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">Edit Dashboard Datasources</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button\n disabled={props.datasources === datasources}\n variant=\"contained\"\n onClick={() => {\n props.onChange(datasources);\n }}\n >\n Apply\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Stack spacing={2}>\n <Stack spacing={2}>\n <TableContainer>\n <Table sx={{ minWidth: 650 }} aria-label=\"table of datasources\">\n <TableHead>\n <TableRow>\n <TableCell>Name</TableCell>\n <TableCell>Type</TableCell>\n <TableCell>Description</TableCell>\n <TableCell align=\"right\">Actions</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {Object.entries(datasources).map(([name, spec]) => {\n return (\n <TableRow key={name}>\n <TableCell component=\"th\" scope=\"row\" sx={{ fontWeight: 'bold' }}>\n {name}\n </TableCell>\n <TableCell>{spec.plugin.kind}</TableCell>\n <TableCell>{spec.display?.description ?? ''}</TableCell>\n <TableCell align=\"right\" sx={{ whiteSpace: 'nowrap' }}>\n <IconButton onClick={() => editDatasource(name)}>\n <PencilIcon />\n </IconButton>\n <IconButton onClick={() => removeDatasource(name)}>\n <TrashIcon />\n </IconButton>\n </TableCell>\n </TableRow>\n );\n })}\n </TableBody>\n </Table>\n </TableContainer>\n <Box display=\"flex\">\n <Button\n variant=\"contained\"\n startIcon={<AddIcon />}\n sx={{ marginLeft: 'auto' }}\n onClick={addDatasource}\n >\n Add Datasource\n </Button>\n </Box>\n </Stack>\n </Stack>\n </Box>\n </>\n )}\n </>\n );\n}\n"],"names":["Box","Button","IconButton","Stack","Table","TableBody","TableCell","TableContainer","TableHead","TableRow","Typography","AddIcon","PencilIcon","TrashIcon","DatasourceEditorForm","ValidationProvider","useState","useImmer","useDiscardChangesConfirmationDialog","DatasourceEditor","props","datasources","setDatasources","datasourceFormAction","setDatasourceFormAction","datasourceEdit","setDatasourceEdit","defaultSpec","default","plugin","kind","spec","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleCancel","JSON","stringify","onDiscardChanges","onCancel","description","removeDatasource","name","draft","addDatasource","editDatasource","initialDatasourceDefinition","action","isDraft","onActionChange","onSave","def","onClose","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","onChange","color","overflowY","minWidth","aria-label","align","Object","entries","map","component","scope","fontWeight","whiteSpace","startIcon"],"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,SACEA,GAAG,EACHC,MAAM,EACNC,UAAU,EACVC,KAAK,EACLC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,cAAc,EACdC,SAAS,EACTC,QAAQ,EACRC,UAAU,QACL,gBAAgB;AACvB,OAAOC,aAAa,uBAAuB;AAC3C,OAAOC,gBAAgB,yBAAyB;AAChD,OAAOC,eAAe,2BAA2B;AAEjD,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,4BAA4B;AACrF,SAAuBC,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,mCAAmC,QAAQ,gBAAgB;AAEpE,OAAO,SAASC,iBAAiBC,KAIhC;IACC,MAAM,CAACC,aAAaC,eAAe,GAAGL,SAASG,MAAMC,WAAW;IAChE,MAAM,CAACE,sBAAsBC,wBAAwB,GAAGR,SAAiB;IACzE,MAAM,CAACS,gBAAgBC,kBAAkB,GAAGV,SAAsC;IAClF,MAAMW,cAA8B;QAClCC,SAAS;QACTC,QAAQ;YACN,uFAAuF;YACvFC,MAAM;YACNC,MAAM,CAAC;QACT;IACF;IAEA,MAAM,EAAEC,oCAAoC,EAAEC,qCAAqC,EAAE,GACnFf;IAEF,MAAMgB,eAAe;QACnB,IAAIC,KAAKC,SAAS,CAAChB,MAAMC,WAAW,MAAMc,KAAKC,SAAS,CAACf,cAAc;YACrEW,qCAAqC;gBACnCK,kBAAkB;oBAChBJ;oBACAb,MAAMkB,QAAQ;gBAChB;gBACAA,UAAU;oBACRL;gBACF;gBACAM,aACE;YACJ;QACF,OA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oBAAIuD,SAAS;oBAAGH,IAAI;wBAAEgB,WAAW;oBAAS;8BACzC,cAAA,KAACjE;wBAAMsD,SAAS;kCACd,cAAA,MAACtD;4BAAMsD,SAAS;;8CACd,KAAClD;8CACC,cAAA,MAACH;wCAAMgD,IAAI;4CAAEiB,UAAU;wCAAI;wCAAGC,cAAW;;0DACvC,KAAC9D;0DACC,cAAA,MAACC;;sEACC,KAACH;sEAAU;;sEACX,KAACA;sEAAU;;sEACX,KAACA;sEAAU;;sEACX,KAACA;4DAAUiE,OAAM;sEAAQ;;;;;0DAG7B,KAAClE;0DACEmE,OAAOC,OAAO,CAACpD,aAAaqD,GAAG,CAAC,CAAC,CAACjC,MAAMV,KAAK;oDAC5C,qBACE,MAACtB;;0EACC,KAACH;gEAAUqE,WAAU;gEAAKC,OAAM;gEAAMxB,IAAI;oEAAEyB,YAAY;gEAAO;0EAC5DpC;;0EAEH,KAACnC;0EAAWyB,KAAKF,MAAM,CAACC,IAAI;;0EAC5B,KAACxB;0EAAWyB,KAAKsB,OAAO,EAAEd,eAAe;;0EACzC,MAACjC;gEAAUiE,OAAM;gEAAQnB,IAAI;oEAAE0B,YAAY;gEAAS;;kFAClD,KAAC5E;wEAAW+D,SAAS,IAAMrB,eAAeH;kFACxC,cAAA,KAAC7B;;kFAEH,KAACV;wEAAW+D,SAAS,IAAMzB,iBAAiBC;kFAC1C,cAAA,KAAC5B;;;;;uDAXQ4B;gDAgBnB;;;;;8CAIN,KAACzC;oCAAIqD,SAAQ;8CACX,cAAA,KAACpD;wCACC4D,SAAQ;wCACRkB,yBAAW,KAACpE;wCACZyC,IAAI;4CAAEW,YAAY;wCAAO;wCACzBE,SAAStB;kDACV;;;;;;;;;;AAWnB"}
@@ -1,2 +1,3 @@
1
- export declare function EditDatasourcesButton(): import("react/jsx-runtime").JSX.Element;
1
+ import { ReactElement } from 'react';
2
+ export declare function EditDatasourcesButton(): ReactElement;
2
3
  //# sourceMappingURL=EditDatasourcesButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EditDatasourcesButton.d.ts","sourceRoot":"","sources":["../../../src/components/Datasources/EditDatasourcesButton.tsx"],"names":[],"mappings":"AAuBA,wBAAgB,qBAAqB,4CAwFpC"}
1
+ {"version":3,"file":"EditDatasourcesButton.d.ts","sourceRoot":"","sources":["../../../src/components/Datasources/EditDatasourcesButton.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAU/C,wBAAgB,qBAAqB,IAAI,YAAY,CAwFpD"}
@@ -34,13 +34,10 @@ export function EditDatasourcesButton() {
34
34
  const handleChangeDatasources = (datasources)=>{
35
35
  // Calculates the new list of datasources that are allowed to be used.
36
36
  const newSavedDatasources = Object.keys(datasources).filter((key)=>{
37
- var _datasources_key_plugin, _datasources_key, _savedDatasources_key_plugin, _savedDatasources_key, _datasources_key_plugin_spec, _datasources_key_plugin1, _datasources_key1, _savedDatasources_key_plugin_spec, _savedDatasources_key_plugin1, _savedDatasources_key1;
38
- var _datasources_key_plugin_spec1;
39
37
  // Datasources are allowed to be used if a) they are direct, or b) they are proxied, and their
40
38
  // proxy is the same as what we have saved.
41
- const isDirect = 'directUrl' in ((_datasources_key_plugin_spec1 = (_datasources_key = datasources[key]) === null || _datasources_key === void 0 ? void 0 : (_datasources_key_plugin = _datasources_key.plugin) === null || _datasources_key_plugin === void 0 ? void 0 : _datasources_key_plugin.spec) !== null && _datasources_key_plugin_spec1 !== void 0 ? _datasources_key_plugin_spec1 : {});
42
- var _savedDatasources_key_plugin_spec1;
43
- const isSavedProxy = !isDirect && !('directUrl' in ((_savedDatasources_key_plugin_spec1 = (_savedDatasources_key = savedDatasources[key]) === null || _savedDatasources_key === void 0 ? void 0 : (_savedDatasources_key_plugin = _savedDatasources_key.plugin) === null || _savedDatasources_key_plugin === void 0 ? void 0 : _savedDatasources_key_plugin.spec) !== null && _savedDatasources_key_plugin_spec1 !== void 0 ? _savedDatasources_key_plugin_spec1 : {})) && ((_datasources_key1 = datasources[key]) === null || _datasources_key1 === void 0 ? void 0 : (_datasources_key_plugin1 = _datasources_key1.plugin) === null || _datasources_key_plugin1 === void 0 ? void 0 : (_datasources_key_plugin_spec = _datasources_key_plugin1.spec) === null || _datasources_key_plugin_spec === void 0 ? void 0 : _datasources_key_plugin_spec.proxy) === ((_savedDatasources_key1 = savedDatasources[key]) === null || _savedDatasources_key1 === void 0 ? void 0 : (_savedDatasources_key_plugin1 = _savedDatasources_key1.plugin) === null || _savedDatasources_key_plugin1 === void 0 ? void 0 : (_savedDatasources_key_plugin_spec = _savedDatasources_key_plugin1.spec) === null || _savedDatasources_key_plugin_spec === void 0 ? void 0 : _savedDatasources_key_plugin_spec.proxy);
39
+ const isDirect = 'directUrl' in (datasources[key]?.plugin?.spec ?? {});
40
+ const isSavedProxy = !isDirect && !('directUrl' in (savedDatasources[key]?.plugin?.spec ?? {})) && datasources[key]?.plugin?.spec?.proxy === savedDatasources[key]?.plugin?.spec?.proxy;
44
41
  return isDirect || isSavedProxy;
45
42
  }).reduce((obj, key)=>{
46
43
  obj[key] = datasources[key];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Datasources/EditDatasourcesButton.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 { useState } from 'react';\nimport { Button } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { Drawer, InfoTooltip } from '@perses-dev/components';\nimport { DashboardResource, DatasourceSpec, EphemeralDashboardResource } from '@perses-dev/core';\nimport { useDatasourceStore } from '@perses-dev/plugin-system';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboard } from '../../context';\nimport { DatasourceEditor } from './DatasourceEditor';\n\nexport function EditDatasourcesButton() {\n const [isDatasourceEditorOpen, setIsDatasourceEditorOpen] = useState(false);\n const { getLocalDatasources, setLocalDatasources, getSavedDatasources, setSavedDatasources } = useDatasourceStore();\n const localDatasources: Record<string, DatasourceSpec> = getLocalDatasources();\n const savedDatasources: Record<string, DatasourceSpec> = getSavedDatasources();\n const { dashboard, setDashboard } = useDashboard();\n\n const openDatasourceEditor = () => {\n setIsDatasourceEditorOpen(true);\n };\n\n const closeDatasourceEditor = () => {\n setIsDatasourceEditorOpen(false);\n };\n\n const handleChangeDatasources = (datasources: Record<string, DatasourceSpec>) => {\n // Calculates the new list of datasources that are allowed to be used.\n const newSavedDatasources: Record<string, DatasourceSpec> = Object.keys(datasources)\n .filter((key) => {\n // Datasources are allowed to be used if a) they are direct, or b) they are proxied, and their\n // proxy is the same as what we have saved.\n const isDirect = 'directUrl' in (datasources[key]?.plugin?.spec ?? {});\n const isSavedProxy =\n !isDirect &&\n !('directUrl' in (savedDatasources[key]?.plugin?.spec ?? {})) &&\n datasources[key]?.plugin?.spec?.proxy === savedDatasources[key]?.plugin?.spec?.proxy;\n\n return isDirect || isSavedProxy;\n })\n .reduce(\n (obj, key) => {\n obj[key] = datasources[key] as DatasourceSpec;\n\n return obj;\n },\n {} as Record<string, DatasourceSpec>\n );\n\n setDashboard(\n dashboard.kind === 'Dashboard'\n ? ({\n ...dashboard,\n spec: {\n ...dashboard.spec,\n datasources: datasources,\n },\n } as DashboardResource)\n : ({\n ...dashboard,\n spec: {\n ...dashboard.spec,\n datasources: datasources,\n },\n } as EphemeralDashboardResource)\n );\n setSavedDatasources(newSavedDatasources);\n setLocalDatasources(datasources);\n setIsDatasourceEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editDatasources}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openDatasourceEditor}\n aria-label={TOOLTIP_TEXT.editDatasources}\n variant=\"text\"\n color=\"primary\"\n sx={editButtonStyle}\n >\n Datasources\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isDatasourceEditorOpen}\n onClose={closeDatasourceEditor}\n PaperProps={{ sx: { width: '50%' } }}\n data-testid=\"datasource-editor\"\n >\n <DatasourceEditor\n datasources={localDatasources}\n onCancel={closeDatasourceEditor}\n onChange={handleChangeDatasources}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","useDatasourceStore","TOOLTIP_TEXT","editButtonStyle","useDashboard","DatasourceEditor","EditDatasourcesButton","isDatasourceEditorOpen","setIsDatasourceEditorOpen","getLocalDatasources","setLocalDatasources","getSavedDatasources","setSavedDatasources","localDatasources","savedDatasources","dashboard","setDashboard","openDatasourceEditor","closeDatasourceEditor","handleChangeDatasources","datasources","newSavedDatasources","Object","keys","filter","key","isDirect","plugin","spec","isSavedProxy","proxy","reduce","obj","kind","description","editDatasources","startIcon","onClick","aria-label","variant","color","sx","isOpen","onClose","PaperProps","width","data-testid","onCancel","onChange"],"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,QAAQ,QAAQ,QAAQ;AACjC,SAASC,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,OAAO,SAASC;IACd,MAAM,CAACC,wBAAwBC,0BAA0B,GAAGZ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d,wDAAAA,kCAAqCgB,KAAK;YAEtF,OAAOJ,YAAYG;QACrB,GACCE,MAAM,CACL,CAACC,KAAKP;YACJO,GAAG,CAACP,IAAI,GAAGL,WAAW,CAACK,IAAI;YAE3B,OAAOO;QACT,GACA,CAAC;QAGLhB,aACED,UAAUkB,IAAI,KAAK,cACd;YACC,GAAGlB,SAAS;YACZa,MAAM;gBACJ,GAAGb,UAAUa,IAAI;gBACjBR,aAAaA;YACf;QACF,IACC;YACC,GAAGL,SAAS;YACZa,MAAM;gBACJ,GAAGb,UAAUa,IAAI;gBACjBR,aAAaA;YACf;QACF;QAENR,oBAAoBS;QACpBX,oBAAoBU;QACpBZ,0BAA0B;IAC5B;IAEA,qBACE;;0BACE,KAACR;gBAAYkC,aAAahC,aAAaiC,eAAe;0BACpD,cAAA,KAACtC;oBACCuC,yBAAW,KAACtC;oBACZuC,SAASpB;oBACTqB,cAAYpC,aAAaiC,eAAe;oBACxCI,SAAQ;oBACRC,OAAM;oBACNC,IAAItC;8BACL;;;0BAIH,KAACJ;gBACC2C,QAAQnC;gBACRoC,SAASzB;gBACT0B,YAAY;oBAAEH,IAAI;wBAAEI,OAAO;oBAAM;gBAAE;gBACnCC,eAAY;0BAEZ,cAAA,KAACzC;oBACCe,aAAaP;oBACbkC,UAAU7B;oBACV8B,UAAU7B;;;;;AAKpB"}
1
+ {"version":3,"sources":["../../../src/components/Datasources/EditDatasourcesButton.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 { Button } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { Drawer, InfoTooltip } from '@perses-dev/components';\nimport { DashboardResource, DatasourceSpec, EphemeralDashboardResource } from '@perses-dev/core';\nimport { useDatasourceStore } from '@perses-dev/plugin-system';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboard } from '../../context';\nimport { DatasourceEditor } from './DatasourceEditor';\n\nexport function EditDatasourcesButton(): ReactElement {\n const [isDatasourceEditorOpen, setIsDatasourceEditorOpen] = useState(false);\n const { getLocalDatasources, setLocalDatasources, getSavedDatasources, setSavedDatasources } = useDatasourceStore();\n const localDatasources: Record<string, DatasourceSpec> = getLocalDatasources();\n const savedDatasources: Record<string, DatasourceSpec> = getSavedDatasources();\n const { dashboard, setDashboard } = useDashboard();\n\n const openDatasourceEditor = (): void => {\n setIsDatasourceEditorOpen(true);\n };\n\n const closeDatasourceEditor = (): void => {\n setIsDatasourceEditorOpen(false);\n };\n\n const handleChangeDatasources = (datasources: Record<string, DatasourceSpec>): void => {\n // Calculates the new list of datasources that are allowed to be used.\n const newSavedDatasources: Record<string, DatasourceSpec> = Object.keys(datasources)\n .filter((key) => {\n // Datasources are allowed to be used if a) they are direct, or b) they are proxied, and their\n // proxy is the same as what we have saved.\n const isDirect = 'directUrl' in (datasources[key]?.plugin?.spec ?? {});\n const isSavedProxy =\n !isDirect &&\n !('directUrl' in (savedDatasources[key]?.plugin?.spec ?? {})) &&\n datasources[key]?.plugin?.spec?.proxy === savedDatasources[key]?.plugin?.spec?.proxy;\n\n return isDirect || isSavedProxy;\n })\n .reduce(\n (obj, key) => {\n obj[key] = datasources[key] as DatasourceSpec;\n\n return obj;\n },\n {} as Record<string, DatasourceSpec>\n );\n\n setDashboard(\n dashboard.kind === 'Dashboard'\n ? ({\n ...dashboard,\n spec: {\n ...dashboard.spec,\n datasources: datasources,\n },\n } as DashboardResource)\n : ({\n ...dashboard,\n spec: {\n ...dashboard.spec,\n datasources: datasources,\n },\n } as EphemeralDashboardResource)\n );\n setSavedDatasources(newSavedDatasources);\n setLocalDatasources(datasources);\n setIsDatasourceEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editDatasources}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openDatasourceEditor}\n aria-label={TOOLTIP_TEXT.editDatasources}\n variant=\"text\"\n color=\"primary\"\n sx={editButtonStyle}\n >\n Datasources\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isDatasourceEditorOpen}\n onClose={closeDatasourceEditor}\n PaperProps={{ sx: { width: '50%' } }}\n data-testid=\"datasource-editor\"\n >\n <DatasourceEditor\n datasources={localDatasources}\n onCancel={closeDatasourceEditor}\n onChange={handleChangeDatasources}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","useDatasourceStore","TOOLTIP_TEXT","editButtonStyle","useDashboard","DatasourceEditor","EditDatasourcesButton","isDatasourceEditorOpen","setIsDatasourceEditorOpen","getLocalDatasources","setLocalDatasources","getSavedDatasources","setSavedDatasources","localDatasources","savedDatasources","dashboard","setDashboard","openDatasourceEditor","closeDatasourceEditor","handleChangeDatasources","datasources","newSavedDatasources","Object","keys","filter","key","isDirect","plugin","spec","isSavedProxy","proxy","reduce","obj","kind","description","editDatasources","startIcon","onClick","aria-label","variant","color","sx","isOpen","onClose","PaperProps","width","data-testid","onCancel","onChange"],"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,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,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AAaA;YACf;QACF;QAENR,oBAAoBS;QACpBX,oBAAoBU;QACpBZ,0BAA0B;IAC5B;IAEA,qBACE;;0BACE,KAACR;gBAAYkC,aAAahC,aAAaiC,eAAe;0BACpD,cAAA,KAACtC;oBACCuC,yBAAW,KAACtC;oBACZuC,SAASpB;oBACTqB,cAAYpC,aAAaiC,eAAe;oBACxCI,SAAQ;oBACRC,OAAM;oBACNC,IAAItC;8BACL;;;0BAIH,KAACJ;gBACC2C,QAAQnC;gBACRoC,SAASzB;gBACT0B,YAAY;oBAAEH,IAAI;wBAAEI,OAAO;oBAAM;gBAAE;gBACnCC,eAAY;0BAEZ,cAAA,KAACzC;oBACCe,aAAaP;oBACbkC,UAAU7B;oBACV8B,UAAU7B;;;;;AAKpB"}
@@ -1,2 +1,3 @@
1
- export declare const DeletePanelDialog: () => import("react/jsx-runtime").JSX.Element;
1
+ import { ReactElement } from 'react';
2
+ export declare const DeletePanelDialog: () => ReactElement;
2
3
  //# sourceMappingURL=DeletePanelDialog.d.ts.map