@perses-dev/dashboards 0.0.0-snapshot-scatterplot-fix-imports-95e1b59 → 0.0.0-snapshot-histogram-types-78c5104

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 (366) 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 +4 -4
  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/DeletePanelDialog/DeletePanelDialog.js +2 -0
  7. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -4
  8. package/dist/cjs/components/DownloadButton/DownloadButton.js +135 -29
  9. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +10 -13
  10. package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +2 -2
  11. package/dist/cjs/components/GridLayout/GridContainer.js +15 -10
  12. package/dist/cjs/components/GridLayout/GridItemContent.js +20 -4
  13. package/dist/cjs/components/GridLayout/GridLayout.js +57 -12
  14. package/dist/cjs/components/GridLayout/GridTitle.js +3 -3
  15. package/dist/cjs/{validation/panel.js → components/Panel/HeaderIconButton.js} +8 -10
  16. package/dist/cjs/components/Panel/Panel.js +19 -11
  17. package/dist/cjs/components/Panel/PanelActions.js +365 -0
  18. package/dist/cjs/components/Panel/PanelContent.js +59 -13
  19. package/dist/cjs/components/Panel/PanelHeader.js +14 -117
  20. package/dist/cjs/components/Panel/PanelLinks.js +136 -0
  21. package/dist/cjs/components/Panel/PanelPluginLoader.js +56 -0
  22. package/dist/cjs/components/Panel/index.js +1 -0
  23. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +9 -6
  24. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +81 -67
  25. package/dist/cjs/components/PanelDrawer/PanelPreview.js +7 -3
  26. package/dist/cjs/components/PanelDrawer/usePanelEditor.js +9 -6
  27. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
  28. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
  29. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -6
  30. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +2 -2
  31. package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +7 -14
  32. package/dist/cjs/components/Variables/EditVariablesButton.js +4 -4
  33. package/dist/cjs/components/Variables/{TemplateVariable.js → Variable.js} +52 -60
  34. package/dist/cjs/components/Variables/VariableEditor.js +34 -40
  35. package/dist/cjs/components/Variables/VariableList.js +23 -22
  36. package/dist/cjs/components/Variables/index.js +2 -2
  37. package/dist/cjs/constants/styles.js +19 -7
  38. package/dist/cjs/constants/user-interface-text.js +3 -1
  39. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +10 -8
  40. package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +36 -0
  41. package/dist/cjs/context/DashboardProvider/common.js +2 -2
  42. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +25 -6
  43. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -2
  44. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +7 -10
  45. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +1 -2
  46. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +8 -3
  47. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +79 -0
  48. package/dist/cjs/context/DatasourceStoreProvider.js +18 -23
  49. package/dist/cjs/context/{TemplateVariableProvider/TemplateVariableProvider.js → VariableProvider/VariableProvider.js} +76 -87
  50. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.js +11 -14
  51. package/dist/cjs/{validation → context/VariableProvider}/index.js +2 -2
  52. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/query-params.js +1 -1
  53. package/dist/cjs/context/{TemplateVariableProvider → VariableProvider}/utils.js +3 -3
  54. package/dist/cjs/context/index.js +2 -2
  55. package/dist/cjs/context/useDashboard.js +4 -4
  56. package/dist/cjs/test/datasource-provider.js +1 -1
  57. package/dist/cjs/test/plugin-registry.js +8 -3
  58. package/dist/cjs/test/render.js +13 -11
  59. package/dist/cjs/views/ViewDashboard/DashboardApp.js +6 -4
  60. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +10 -9
  61. package/dist/components/AddGroupButton/AddGroupButton.d.ts +2 -1
  62. package/dist/components/AddGroupButton/AddGroupButton.d.ts.map +1 -1
  63. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
  64. package/dist/components/AddPanelButton/AddPanelButton.d.ts +2 -1
  65. package/dist/components/AddPanelButton/AddPanelButton.d.ts.map +1 -1
  66. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  67. package/dist/components/Dashboard/Dashboard.d.ts +2 -1
  68. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  69. package/dist/components/Dashboard/Dashboard.js +8 -1
  70. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  71. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +2 -1
  72. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  73. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +3 -3
  74. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  75. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +4 -2
  76. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  77. package/dist/components/DashboardToolbar/DashboardToolbar.js +4 -4
  78. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  79. package/dist/components/Datasources/DatasourceEditor.d.ts +2 -1
  80. package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
  81. package/dist/components/Datasources/DatasourceEditor.js +19 -19
  82. package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
  83. package/dist/components/Datasources/EditDatasourcesButton.d.ts +2 -1
  84. package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -1
  85. package/dist/components/Datasources/EditDatasourcesButton.js +2 -5
  86. package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
  87. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +2 -1
  88. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -1
  89. package/dist/components/DeletePanelDialog/DeletePanelDialog.js +3 -1
  90. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  91. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts +2 -1
  92. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  93. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +6 -5
  94. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  95. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +2 -1
  96. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
  97. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  98. package/dist/components/DownloadButton/DownloadButton.d.ts +2 -5
  99. package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -1
  100. package/dist/components/DownloadButton/DownloadButton.js +94 -29
  101. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  102. package/dist/components/EditButton/EditButton.d.ts +2 -1
  103. package/dist/components/EditButton/EditButton.d.ts.map +1 -1
  104. package/dist/components/EditButton/EditButton.js.map +1 -1
  105. package/dist/components/EditJsonButton/EditJsonButton.d.ts +2 -1
  106. package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -1
  107. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  108. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +2 -1
  109. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  110. package/dist/components/EditJsonDialog/EditJsonDialog.js +7 -10
  111. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  112. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts +3 -3
  113. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts.map +1 -1
  114. package/dist/components/EmptyDashboard/EmptyDashboard.js +2 -2
  115. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
  116. package/dist/components/GridLayout/GridContainer.d.ts +5 -3
  117. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -1
  118. package/dist/components/GridLayout/GridContainer.js +15 -10
  119. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  120. package/dist/components/GridLayout/GridItemContent.d.ts +2 -1
  121. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  122. package/dist/components/GridLayout/GridItemContent.js +22 -6
  123. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  124. package/dist/components/GridLayout/GridLayout.d.ts +4 -2
  125. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  126. package/dist/components/GridLayout/GridLayout.js +59 -14
  127. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  128. package/dist/components/GridLayout/GridTitle.d.ts +3 -2
  129. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  130. package/dist/components/GridLayout/GridTitle.js +3 -3
  131. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  132. package/dist/components/Panel/HeaderIconButton.d.ts +5 -0
  133. package/dist/components/Panel/HeaderIconButton.d.ts.map +1 -0
  134. package/dist/{stories/decorators/index.js → components/Panel/HeaderIconButton.js} +7 -6
  135. package/dist/components/Panel/HeaderIconButton.js.map +1 -0
  136. package/dist/components/Panel/Panel.d.ts +16 -5
  137. package/dist/components/Panel/Panel.d.ts.map +1 -1
  138. package/dist/components/Panel/Panel.js +25 -12
  139. package/dist/components/Panel/Panel.js.map +1 -1
  140. package/dist/components/Panel/PanelActions.d.ts +22 -0
  141. package/dist/components/Panel/PanelActions.d.ts.map +1 -0
  142. package/dist/components/Panel/PanelActions.js +352 -0
  143. package/dist/components/Panel/PanelActions.js.map +1 -0
  144. package/dist/components/Panel/PanelContent.d.ts +7 -5
  145. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  146. package/dist/components/Panel/PanelContent.js +61 -15
  147. package/dist/components/Panel/PanelContent.js.map +1 -1
  148. package/dist/components/Panel/PanelHeader.d.ts +10 -8
  149. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  150. package/dist/components/Panel/PanelHeader.js +18 -116
  151. package/dist/components/Panel/PanelHeader.js.map +1 -1
  152. package/dist/components/Panel/PanelLinks.d.ts +6 -0
  153. package/dist/components/Panel/PanelLinks.d.ts.map +1 -0
  154. package/dist/components/Panel/PanelLinks.js +123 -0
  155. package/dist/components/Panel/PanelLinks.js.map +1 -0
  156. package/dist/components/Panel/PanelPluginLoader.d.ts +13 -0
  157. package/dist/components/Panel/PanelPluginLoader.d.ts.map +1 -0
  158. package/dist/components/Panel/PanelPluginLoader.js +51 -0
  159. package/dist/components/Panel/PanelPluginLoader.js.map +1 -0
  160. package/dist/components/Panel/index.d.ts +1 -0
  161. package/dist/components/Panel/index.d.ts.map +1 -1
  162. package/dist/components/Panel/index.js +1 -0
  163. package/dist/components/Panel/index.js.map +1 -1
  164. package/dist/components/PanelDrawer/PanelDrawer.d.ts +2 -1
  165. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  166. package/dist/components/PanelDrawer/PanelDrawer.js +10 -7
  167. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  168. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +3 -3
  169. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  170. package/dist/components/PanelDrawer/PanelEditorForm.js +84 -70
  171. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  172. package/dist/components/PanelDrawer/PanelPreview.d.ts +3 -2
  173. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  174. package/dist/components/PanelDrawer/PanelPreview.js +8 -4
  175. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  176. package/dist/components/PanelDrawer/usePanelEditor.d.ts +12 -10
  177. package/dist/components/PanelDrawer/usePanelEditor.d.ts.map +1 -1
  178. package/dist/components/PanelDrawer/usePanelEditor.js +9 -6
  179. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
  180. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +2 -1
  181. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  182. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
  183. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  184. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +2 -1
  185. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
  186. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  187. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts +2 -1
  188. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts.map +1 -1
  189. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
  190. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  191. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +2 -1
  192. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  193. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +5 -7
  194. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  195. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +2 -1
  196. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  197. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +3 -3
  198. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  199. package/dist/components/Variables/BuiltinVariableAccordions.d.ts +2 -1
  200. package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -1
  201. package/dist/components/Variables/BuiltinVariableAccordions.js +7 -14
  202. package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -1
  203. package/dist/components/Variables/EditVariablesButton.d.ts +2 -1
  204. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  205. package/dist/components/Variables/EditVariablesButton.js +5 -5
  206. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  207. package/dist/components/Variables/{TemplateVariable.d.ts → Variable.d.ts} +6 -5
  208. package/dist/components/Variables/Variable.d.ts.map +1 -0
  209. package/dist/components/Variables/{TemplateVariable.js → Variable.js} +53 -61
  210. package/dist/components/Variables/Variable.js.map +1 -0
  211. package/dist/components/Variables/VariableEditor.d.ts +3 -2
  212. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  213. package/dist/components/Variables/VariableEditor.js +35 -41
  214. package/dist/components/Variables/VariableEditor.js.map +1 -1
  215. package/dist/components/Variables/VariableList.d.ts +4 -3
  216. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  217. package/dist/components/Variables/VariableList.js +21 -20
  218. package/dist/components/Variables/VariableList.js.map +1 -1
  219. package/dist/components/Variables/index.d.ts +1 -1
  220. package/dist/components/Variables/index.d.ts.map +1 -1
  221. package/dist/components/Variables/index.js +2 -2
  222. package/dist/components/Variables/index.js.map +1 -1
  223. package/dist/constants/styles.d.ts +5 -2
  224. package/dist/constants/styles.d.ts.map +1 -1
  225. package/dist/constants/styles.js +6 -3
  226. package/dist/constants/styles.js.map +1 -1
  227. package/dist/constants/user-interface-text.d.ts +3 -1
  228. package/dist/constants/user-interface-text.d.ts.map +1 -1
  229. package/dist/constants/user-interface-text.js +3 -1
  230. package/dist/constants/user-interface-text.js.map +1 -1
  231. package/dist/context/DashboardProvider/DashboardProvider.d.ts +6 -3
  232. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  233. package/dist/context/DashboardProvider/DashboardProvider.js +11 -9
  234. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  235. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts +4 -0
  236. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts.map +1 -0
  237. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +28 -0
  238. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -0
  239. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  240. package/dist/context/DashboardProvider/common.js +2 -2
  241. package/dist/context/DashboardProvider/common.js.map +1 -1
  242. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +45 -23
  243. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  244. package/dist/context/DashboardProvider/dashboard-provider-api.js +23 -6
  245. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  246. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +2 -1
  247. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts.map +1 -1
  248. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  249. package/dist/context/DashboardProvider/delete-panel-slice.js +1 -2
  250. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  251. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
  252. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  253. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
  254. package/dist/context/DashboardProvider/index.d.ts +1 -2
  255. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  256. package/dist/context/DashboardProvider/index.js.map +1 -1
  257. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -9
  258. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  259. package/dist/context/DashboardProvider/panel-editor-slice.js +4 -7
  260. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  261. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +2 -1
  262. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
  263. package/dist/context/DashboardProvider/panel-group-editor-slice.js +1 -2
  264. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  265. package/dist/context/DashboardProvider/panel-group-slice.d.ts +3 -3
  266. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  267. package/dist/context/DashboardProvider/panel-group-slice.js +7 -3
  268. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  269. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  270. package/dist/context/DashboardProvider/view-panel-slice.d.ts +21 -0
  271. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -0
  272. package/dist/context/DashboardProvider/view-panel-slice.js +73 -0
  273. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -0
  274. package/dist/context/DatasourceStoreProvider.d.ts +7 -7
  275. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  276. package/dist/context/DatasourceStoreProvider.js +18 -23
  277. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  278. package/dist/context/VariableProvider/VariableProvider.d.ts +119 -0
  279. package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -0
  280. package/dist/context/{TemplateVariableProvider/TemplateVariableProvider.js → VariableProvider/VariableProvider.js} +62 -64
  281. package/dist/context/VariableProvider/VariableProvider.js.map +1 -0
  282. package/dist/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.d.ts +1 -1
  283. package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -0
  284. package/dist/context/{TemplateVariableProvider → VariableProvider}/hydrationUtils.js +9 -12
  285. package/dist/context/VariableProvider/hydrationUtils.js.map +1 -0
  286. package/dist/context/VariableProvider/index.d.ts +2 -0
  287. package/dist/context/VariableProvider/index.d.ts.map +1 -0
  288. package/dist/{validation → context/VariableProvider}/index.js +2 -2
  289. package/dist/context/VariableProvider/index.js.map +1 -0
  290. package/dist/context/{TemplateVariableProvider → VariableProvider}/query-params.d.ts +2 -6
  291. package/dist/context/VariableProvider/query-params.d.ts.map +1 -0
  292. package/dist/context/{TemplateVariableProvider → VariableProvider}/query-params.js +1 -1
  293. package/dist/context/VariableProvider/query-params.js.map +1 -0
  294. package/dist/context/{TemplateVariableProvider → VariableProvider}/utils.d.ts +1 -1
  295. package/dist/context/VariableProvider/utils.d.ts.map +1 -0
  296. package/dist/context/{TemplateVariableProvider → VariableProvider}/utils.js +3 -3
  297. package/dist/context/VariableProvider/utils.js.map +1 -0
  298. package/dist/context/index.d.ts +1 -1
  299. package/dist/context/index.d.ts.map +1 -1
  300. package/dist/context/index.js +2 -2
  301. package/dist/context/index.js.map +1 -1
  302. package/dist/context/useDashboard.d.ts.map +1 -1
  303. package/dist/context/useDashboard.js +4 -4
  304. package/dist/context/useDashboard.js.map +1 -1
  305. package/dist/test/dashboard-provider.d.ts +1 -1
  306. package/dist/test/dashboard-provider.d.ts.map +1 -1
  307. package/dist/test/dashboard-provider.js.map +1 -1
  308. package/dist/test/datasource-provider.d.ts +3 -3
  309. package/dist/test/datasource-provider.d.ts.map +1 -1
  310. package/dist/test/datasource-provider.js +1 -1
  311. package/dist/test/datasource-provider.js.map +1 -1
  312. package/dist/test/plugin-registry.d.ts.map +1 -1
  313. package/dist/test/plugin-registry.js +8 -3
  314. package/dist/test/plugin-registry.js.map +1 -1
  315. package/dist/test/render.d.ts +2 -2
  316. package/dist/test/render.d.ts.map +1 -1
  317. package/dist/test/render.js +9 -7
  318. package/dist/test/render.js.map +1 -1
  319. package/dist/utils/panelUtils.d.ts.map +1 -1
  320. package/dist/utils/panelUtils.js.map +1 -1
  321. package/dist/views/ViewDashboard/DashboardApp.d.ts +4 -2
  322. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  323. package/dist/views/ViewDashboard/DashboardApp.js +6 -4
  324. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  325. package/dist/views/ViewDashboard/ViewDashboard.d.ts +4 -3
  326. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  327. package/dist/views/ViewDashboard/ViewDashboard.js +11 -10
  328. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  329. package/package.json +12 -12
  330. package/dist/cjs/context/TemplateVariableProvider/index.js +0 -30
  331. package/dist/cjs/stories/decorators/WithDashboard.js +0 -41
  332. package/dist/cjs/stories/decorators/WithDatasourceStore.js +0 -39
  333. package/dist/cjs/stories/decorators/WithTemplateVariables.js +0 -37
  334. package/dist/cjs/stories/decorators/constants.js +0 -39
  335. package/dist/cjs/stories/decorators/index.js +0 -33
  336. package/dist/components/Variables/TemplateVariable.d.ts.map +0 -1
  337. package/dist/components/Variables/TemplateVariable.js.map +0 -1
  338. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +0 -77
  339. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +0 -1
  340. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +0 -1
  341. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +0 -1
  342. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +0 -1
  343. package/dist/context/TemplateVariableProvider/index.d.ts +0 -2
  344. package/dist/context/TemplateVariableProvider/index.d.ts.map +0 -1
  345. package/dist/context/TemplateVariableProvider/index.js +0 -15
  346. package/dist/context/TemplateVariableProvider/index.js.map +0 -1
  347. package/dist/context/TemplateVariableProvider/query-params.d.ts.map +0 -1
  348. package/dist/context/TemplateVariableProvider/query-params.js.map +0 -1
  349. package/dist/context/TemplateVariableProvider/utils.d.ts.map +0 -1
  350. package/dist/context/TemplateVariableProvider/utils.js.map +0 -1
  351. package/dist/stories/decorators/WithDashboard.js +0 -33
  352. package/dist/stories/decorators/WithDashboard.js.map +0 -1
  353. package/dist/stories/decorators/WithDatasourceStore.js +0 -31
  354. package/dist/stories/decorators/WithDatasourceStore.js.map +0 -1
  355. package/dist/stories/decorators/WithTemplateVariables.js +0 -29
  356. package/dist/stories/decorators/WithTemplateVariables.js.map +0 -1
  357. package/dist/stories/decorators/constants.js +0 -31
  358. package/dist/stories/decorators/constants.js.map +0 -1
  359. package/dist/stories/decorators/index.js.map +0 -1
  360. package/dist/validation/index.d.ts +0 -2
  361. package/dist/validation/index.d.ts.map +0 -1
  362. package/dist/validation/index.js.map +0 -1
  363. package/dist/validation/panel.d.ts +0 -19
  364. package/dist/validation/panel.d.ts.map +0 -1
  365. package/dist/validation/panel.js +0 -21
  366. package/dist/validation/panel.js.map +0 -1
@@ -11,32 +11,48 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { useState } from 'react';
14
+ import { useEffect, useState } from 'react';
15
15
  import { Box, Button, Grid, MenuItem, Stack, TextField, Typography } from '@mui/material';
16
16
  import { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';
17
- import { PluginKindSelect, usePluginEditor, PanelSpecEditor, getTitleAction, getSubmitText } from '@perses-dev/plugin-system';
18
- import { Controller, FormProvider, useForm } from 'react-hook-form';
17
+ import { PluginKindSelect, usePluginEditor, PanelSpecEditor, getTitleAction, getSubmitText, useValidationSchemas } from '@perses-dev/plugin-system';
18
+ import { Controller, FormProvider, useForm, useWatch } from 'react-hook-form';
19
19
  import { zodResolver } from '@hookform/resolvers/zod';
20
20
  import { useListPanelGroups } from '../../context';
21
- import { panelEditorValidationSchema } from '../../validation';
22
21
  import { PanelPreview } from './PanelPreview';
23
22
  import { usePanelEditor } from './usePanelEditor';
24
23
  export function PanelEditorForm(props) {
25
- const { initialValues: { panelDefinition: initialPanelDef, groupId: initialGroupId }, initialAction, onSave, onClose } = props;
24
+ const { initialValues, initialAction, onSave, onClose } = props;
26
25
  const panelGroups = useListPanelGroups();
27
- const [groupId, setGroupId] = useState(initialGroupId);
28
- const { panelDefinition, setName, setDescription, setQueries, setPlugin, setPanelDefinition } = usePanelEditor(initialPanelDef);
26
+ const { panelDefinition, setName, setDescription, setLinks, setQueries, setPlugin, setPanelDefinition } = usePanelEditor(initialValues.panelDefinition);
29
27
  const { plugin } = panelDefinition.spec;
30
28
  const [isDiscardDialogOpened, setDiscardDialogOpened] = useState(false);
29
+ const { panelEditorSchema } = useValidationSchemas();
30
+ const form = useForm({
31
+ resolver: zodResolver(panelEditorSchema),
32
+ mode: 'onBlur',
33
+ defaultValues: initialValues
34
+ });
31
35
  // Use common plugin editor logic even though we've split the inputs up in this form
32
36
  const pluginEditor = usePluginEditor({
33
- pluginType: 'Panel',
37
+ pluginTypes: [
38
+ 'Panel'
39
+ ],
34
40
  value: {
35
- kind: plugin.kind,
41
+ selection: {
42
+ kind: plugin.kind,
43
+ type: 'Panel'
44
+ },
36
45
  spec: plugin.spec
37
46
  },
38
47
  onChange: (plugin)=>{
39
- setPlugin(plugin);
48
+ form.setValue('panelDefinition.spec.plugin', {
49
+ kind: plugin.selection.kind,
50
+ spec: plugin.spec
51
+ });
52
+ setPlugin({
53
+ kind: plugin.selection.kind,
54
+ spec: plugin.spec
55
+ });
40
56
  },
41
57
  onHideQueryEditorChange: (isHidden)=>{
42
58
  setQueries(undefined, isHidden);
@@ -44,35 +60,25 @@ export function PanelEditorForm(props) {
44
60
  });
45
61
  const titleAction = getTitleAction(initialAction, true);
46
62
  const submitText = getSubmitText(initialAction, true);
47
- const form = useForm({
48
- resolver: zodResolver(panelEditorValidationSchema),
49
- mode: 'onBlur',
50
- defaultValues: {
51
- name: initialPanelDef.spec.display.name,
52
- groupId: initialGroupId,
53
- description: initialPanelDef.spec.display.description,
54
- type: pluginEditor.pendingKind ? pluginEditor.pendingKind : plugin.kind
55
- }
63
+ const links = useWatch({
64
+ control: form.control,
65
+ name: 'panelDefinition.spec.links'
56
66
  });
57
- const processForm = ()=>{
58
- const values = {
59
- groupId,
60
- panelDefinition
61
- };
62
- onSave(values);
67
+ useEffect(()=>{
68
+ setLinks(links);
69
+ }, [
70
+ setLinks,
71
+ links
72
+ ]);
73
+ const processForm = (data)=>{
74
+ onSave(data);
63
75
  };
64
76
  // When user click on cancel, several possibilities:
65
77
  // - create action: ask for discard approval
66
78
  // - update action: ask for discard approval if changed
67
79
  // - read action: don´t ask for discard approval
68
80
  function handleCancel() {
69
- if (JSON.stringify({
70
- groupId: initialGroupId,
71
- panelDefinition: initialPanelDef
72
- }) !== JSON.stringify({
73
- groupId,
74
- panelDefinition
75
- })) {
81
+ if (JSON.stringify(initialValues) !== JSON.stringify(form.getValues())) {
76
82
  setDiscardDialogOpened(true);
77
83
  } else {
78
84
  onClose();
@@ -87,6 +93,18 @@ export function PanelEditorForm(props) {
87
93
  }
88
94
  setPanelDefinition(nextPanelDef);
89
95
  };
96
+ const watchedName = useWatch({
97
+ control: form.control,
98
+ name: 'panelDefinition.spec.display.name'
99
+ });
100
+ const watchedDescription = useWatch({
101
+ control: form.control,
102
+ name: 'panelDefinition.spec.display.description'
103
+ });
104
+ const watchedPluginKind = useWatch({
105
+ control: form.control,
106
+ name: 'panelDefinition.spec.plugin.kind'
107
+ });
90
108
  return /*#__PURE__*/ _jsxs(FormProvider, {
91
109
  ...form,
92
110
  children: [
@@ -141,98 +159,93 @@ export function PanelEditorForm(props) {
141
159
  item: true,
142
160
  xs: 8,
143
161
  children: /*#__PURE__*/ _jsx(Controller, {
144
- name: "name",
145
- render: ({ field, fieldState })=>{
146
- var _fieldState_error;
147
- return /*#__PURE__*/ _jsx(TextField, {
162
+ control: form.control,
163
+ name: "panelDefinition.spec.display.name",
164
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
148
165
  ...field,
149
166
  required: true,
150
167
  fullWidth: true,
151
168
  label: "Name",
152
169
  error: !!fieldState.error,
153
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
170
+ helperText: fieldState.error?.message,
171
+ value: watchedName ?? '',
154
172
  onChange: (event)=>{
155
173
  field.onChange(event);
156
174
  setName(event.target.value);
157
175
  }
158
- });
159
- }
176
+ })
160
177
  })
161
178
  }),
162
179
  /*#__PURE__*/ _jsx(Grid, {
163
180
  item: true,
164
181
  xs: 4,
165
182
  children: /*#__PURE__*/ _jsx(Controller, {
183
+ control: form.control,
166
184
  name: "groupId",
167
- render: ({ field, fieldState })=>{
168
- var _fieldState_error;
169
- return /*#__PURE__*/ _jsx(TextField, {
185
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
170
186
  select: true,
171
187
  ...field,
172
188
  required: true,
173
189
  fullWidth: true,
174
190
  label: "Group",
175
191
  error: !!fieldState.error,
176
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
192
+ helperText: fieldState.error?.message,
177
193
  onChange: (event)=>{
178
194
  field.onChange(event);
179
- setGroupId(+event.target.value);
180
195
  },
181
- children: panelGroups.map((panelGroup, index)=>/*#__PURE__*/ {
182
- var _panelGroup_title;
183
- return _jsx(MenuItem, {
196
+ children: panelGroups.map((panelGroup, index)=>/*#__PURE__*/ _jsx(MenuItem, {
184
197
  value: panelGroup.id,
185
- children: (_panelGroup_title = panelGroup.title) !== null && _panelGroup_title !== void 0 ? _panelGroup_title : `Group ${index + 1}`
186
- }, panelGroup.id);
187
- })
188
- });
189
- }
198
+ children: panelGroup.title ?? `Group ${index + 1}`
199
+ }, panelGroup.id))
200
+ })
190
201
  })
191
202
  }),
192
203
  /*#__PURE__*/ _jsx(Grid, {
193
204
  item: true,
194
205
  xs: 8,
195
206
  children: /*#__PURE__*/ _jsx(Controller, {
196
- name: "description",
197
- render: ({ field, fieldState })=>{
198
- var _fieldState_error;
199
- return /*#__PURE__*/ _jsx(TextField, {
207
+ control: form.control,
208
+ name: "panelDefinition.spec.display.description",
209
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
200
210
  ...field,
201
211
  fullWidth: true,
202
212
  label: "Description",
203
213
  error: !!fieldState.error,
204
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
214
+ helperText: fieldState.error?.message,
215
+ value: watchedDescription ?? '',
205
216
  onChange: (event)=>{
206
217
  field.onChange(event);
207
218
  setDescription(event.target.value);
208
219
  }
209
- });
210
- }
220
+ })
211
221
  })
212
222
  }),
213
223
  /*#__PURE__*/ _jsx(Grid, {
214
224
  item: true,
215
225
  xs: 4,
216
226
  children: /*#__PURE__*/ _jsx(Controller, {
217
- name: "type",
218
- render: ({ field, fieldState })=>/*#__PURE__*/ {
219
- var _pluginEditor_error, _fieldState_error;
220
- var _pluginEditor_error_message;
221
- return _jsx(PluginKindSelect, {
227
+ control: form.control,
228
+ name: "panelDefinition.spec.plugin.kind",
229
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(PluginKindSelect, {
222
230
  ...field,
223
- pluginType: "Panel",
231
+ pluginTypes: [
232
+ 'Panel'
233
+ ],
224
234
  required: true,
225
235
  fullWidth: true,
226
236
  label: "Type",
227
237
  disabled: pluginEditor.isLoading,
228
238
  error: !!pluginEditor.error || !!fieldState.error,
229
- helperText: (_pluginEditor_error_message = (_pluginEditor_error = pluginEditor.error) === null || _pluginEditor_error === void 0 ? void 0 : _pluginEditor_error.message) !== null && _pluginEditor_error_message !== void 0 ? _pluginEditor_error_message : (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
239
+ helperText: pluginEditor.error?.message ?? fieldState.error?.message,
240
+ value: {
241
+ type: 'Panel',
242
+ kind: watchedPluginKind
243
+ },
230
244
  onChange: (event)=>{
231
- field.onChange(event);
232
- pluginEditor.onKindChange(event);
245
+ field.onChange(event.kind);
246
+ pluginEditor.onSelectionChange(event);
233
247
  }
234
- });
235
- }
248
+ })
236
249
  })
237
250
  }),
238
251
  /*#__PURE__*/ _jsxs(Grid, {
@@ -258,6 +271,7 @@ export function PanelEditorForm(props) {
258
271
  children: /*#__PURE__*/ _jsx(ErrorBoundary, {
259
272
  FallbackComponent: ErrorAlert,
260
273
  children: /*#__PURE__*/ _jsx(PanelSpecEditor, {
274
+ control: form.control,
261
275
  panelDefinition: panelDefinition,
262
276
  onJSONChange: handlePanelDefinitionChange,
263
277
  onQueriesChange: (queries)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.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 { Box, Button, Grid, MenuItem, Stack, TextField, Typography } from '@mui/material';\nimport { Action, PanelDefinition } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport {\n PluginKindSelect,\n usePluginEditor,\n PanelSpecEditor,\n getTitleAction,\n getSubmitText,\n} from '@perses-dev/plugin-system';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useListPanelGroups } from '../../context';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';\nimport { panelEditorValidationSchema, PanelEditorValidationType } from '../../validation';\nimport { PanelPreview } from './PanelPreview';\nimport { usePanelEditor } from './usePanelEditor';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorValues;\n initialAction: Action;\n onSave: (values: PanelEditorValues) => void;\n onClose: () => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps) {\n const {\n initialValues: { panelDefinition: initialPanelDef, groupId: initialGroupId },\n initialAction,\n onSave,\n onClose,\n } = props;\n const panelGroups = useListPanelGroups();\n const [groupId, setGroupId] = useState(initialGroupId);\n const { panelDefinition, setName, setDescription, setQueries, setPlugin, setPanelDefinition } =\n usePanelEditor(initialPanelDef);\n const { plugin } = panelDefinition.spec;\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginType: 'Panel',\n value: { kind: plugin.kind, spec: plugin.spec },\n onChange: (plugin) => {\n setPlugin(plugin);\n },\n onHideQueryEditorChange: (isHidden) => {\n setQueries(undefined, isHidden);\n },\n });\n\n const titleAction = getTitleAction(initialAction, true);\n const submitText = getSubmitText(initialAction, true);\n\n const form = useForm<PanelEditorValidationType>({\n resolver: zodResolver(panelEditorValidationSchema),\n mode: 'onBlur',\n defaultValues: {\n name: initialPanelDef.spec.display.name,\n groupId: initialGroupId,\n description: initialPanelDef.spec.display.description,\n type: pluginEditor.pendingKind ? pluginEditor.pendingKind : plugin.kind,\n },\n });\n\n const processForm: SubmitHandler<PanelEditorValidationType> = () => {\n const values: PanelEditorValues = { groupId, panelDefinition };\n onSave(values);\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel() {\n if (\n JSON.stringify({ groupId: initialGroupId, panelDefinition: initialPanelDef }) !==\n JSON.stringify({ groupId, panelDefinition })\n ) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n const handlePanelDefinitionChange = (nextPanelDefStr: string) => {\n const nextPanelDef: PanelDefinition = JSON.parse(nextPanelDefStr);\n const { kind: pluginKind, spec: pluginSpec } = nextPanelDef.spec.plugin;\n // if panel plugin kind and spec are modified, then need to save current spec\n if (\n panelDefinition.spec.plugin.kind !== pluginKind &&\n JSON.stringify(panelDefinition.spec.plugin.spec) !== JSON.stringify(pluginSpec)\n ) {\n pluginEditor.rememberCurrentSpecState();\n }\n setPanelDefinition(nextPanelDef);\n };\n\n return (\n <FormProvider {...form}>\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\">{titleAction} Panel</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button variant=\"contained\" disabled={!form.formState.isValid} onClick={form.handleSubmit(processForm)}>\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box id={panelEditorFormId} sx={{ flex: 1, overflowY: 'scroll', padding: (theme) => theme.spacing(2) }}>\n <Grid container spacing={2}>\n <Grid item xs={8}>\n <Controller\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setName(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"groupId\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n required\n fullWidth\n label=\"Group\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setGroupId(+event.target.value);\n }}\n >\n {panelGroups.map((panelGroup, index) => (\n <MenuItem key={panelGroup.id} value={panelGroup.id}>\n {panelGroup.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setDescription(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"type\"\n render={({ field, fieldState }) => (\n <PluginKindSelect\n {...field}\n pluginType=\"Panel\"\n required\n fullWidth\n label=\"Type\"\n disabled={pluginEditor.isLoading}\n error={!!pluginEditor.error || !!fieldState.error}\n helperText={pluginEditor.error?.message ?? fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n pluginEditor.onKindChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h4\" marginBottom={1}>\n Preview\n </Typography>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelPreview panelDefinition={panelDefinition} />\n </ErrorBoundary>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelSpecEditor\n panelDefinition={panelDefinition}\n onJSONChange={handlePanelDefinitionChange}\n onQueriesChange={(queries) => {\n setQueries(queries);\n }}\n onPluginSpecChange={(spec) => {\n pluginEditor.onSpecChange(spec);\n }}\n />\n </ErrorBoundary>\n </Grid>\n </Grid>\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["useState","Box","Button","Grid","MenuItem","Stack","TextField","Typography","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","PluginKindSelect","usePluginEditor","PanelSpecEditor","getTitleAction","getSubmitText","Controller","FormProvider","useForm","zodResolver","useListPanelGroups","panelEditorValidationSchema","PanelPreview","usePanelEditor","PanelEditorForm","props","initialValues","panelDefinition","initialPanelDef","groupId","initialGroupId","initialAction","onSave","onClose","panelGroups","setGroupId","setName","setDescription","setQueries","setPlugin","setPanelDefinition","plugin","spec","isDiscardDialogOpened","setDiscardDialogOpened","pluginEditor","pluginType","value","kind","onChange","onHideQueryEditorChange","isHidden","undefined","titleAction","submitText","form","resolver","mode","defaultValues","name","display","description","type","pendingKind","processForm","values","handleCancel","JSON","stringify","handlePanelDefinitionChange","nextPanelDefStr","nextPanelDef","parse","pluginKind","pluginSpec","rememberCurrentSpecState","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","formState","isValid","onClick","handleSubmit","color","id","panelEditorFormId","flex","overflowY","container","item","xs","render","field","fieldState","required","fullWidth","label","error","helperText","message","event","target","select","map","panelGroup","index","title","isLoading","onKindChange","marginBottom","FallbackComponent","onJSONChange","onQueriesChange","queries","onPluginSpecChange","onSpecChange","isOpen","onCancel","onDiscardChanges"],"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,GAAG,EAAEC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAE1F,SAASC,gCAAgC,EAAEC,UAAU,EAAEC,aAAa,QAAQ,yBAAyB;AACrG,SACEC,gBAAgB,EAChBC,eAAe,EACfC,eAAe,EACfC,cAAc,EACdC,aAAa,QACR,4BAA4B;AACnC,SAASC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,QAAQ,kBAAkB;AACnF,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,kBAAkB,QAAQ,gBAAgB;AAEnD,SAASC,2BAA2B,QAAmC,mBAAmB;AAC1F,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc,QAAQ,mBAAmB;AASlD,OAAO,SAASC,gBAAg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KAACzF;gCAAc6G,mBAAmB9G;0CAChC,cAAA,KAACI;oCACCc,iBAAiBA;oCACjB6F,cAAcnD;oCACdoD,iBAAiB,CAACC;wCAChBpF,WAAWoF;oCACb;oCACAC,oBAAoB,CAACjF;wCACnBG,aAAa+E,YAAY,CAAClF;oCAC5B;;;;;;;0BAMV,KAAClC;gBACCqD,aAAY;gBACZgE,QAAQlF;gBACRmF,UAAU;oBACRlF,uBAAuB;gBACzB;gBACAmF,kBAAkB;oBAChBnF,uBAAuB;oBACvBX;gBACF;;;;AAIR;AAEA;;CAEC,GACD,OAAO,MAAM6D,oBAAoB,oBAAoB"}
1
+ {"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.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, useEffect, useState } from 'react';\nimport { Box, Button, Grid, MenuItem, Stack, TextField, Typography } from '@mui/material';\nimport { Action, PanelDefinition, PanelEditorValues } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport {\n PluginKindSelect,\n usePluginEditor,\n PanelSpecEditor,\n getTitleAction,\n getSubmitText,\n useValidationSchemas,\n} from '@perses-dev/plugin-system';\nimport { Controller, FormProvider, SubmitHandler, useForm, useWatch } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useListPanelGroups } from '../../context';\nimport { PanelPreview } from './PanelPreview';\nimport { usePanelEditor } from './usePanelEditor';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorValues;\n initialAction: Action;\n onSave: (values: PanelEditorValues) => void;\n onClose: () => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps): ReactElement {\n const { initialValues, initialAction, onSave, onClose } = props;\n const panelGroups = useListPanelGroups();\n const { panelDefinition, setName, setDescription, setLinks, setQueries, setPlugin, setPanelDefinition } =\n usePanelEditor(initialValues.panelDefinition);\n const { plugin } = panelDefinition.spec;\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n\n const { panelEditorSchema } = useValidationSchemas();\n const form = useForm<PanelEditorValues>({\n resolver: zodResolver(panelEditorSchema),\n mode: 'onBlur',\n defaultValues: initialValues,\n });\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginTypes: ['Panel'],\n value: { selection: { kind: plugin.kind, type: 'Panel' }, spec: plugin.spec },\n onChange: (plugin) => {\n form.setValue('panelDefinition.spec.plugin', { kind: plugin.selection.kind, spec: plugin.spec });\n setPlugin({\n kind: plugin.selection.kind,\n spec: plugin.spec,\n });\n },\n onHideQueryEditorChange: (isHidden) => {\n setQueries(undefined, isHidden);\n },\n });\n\n const titleAction = getTitleAction(initialAction, true);\n const submitText = getSubmitText(initialAction, true);\n\n const links = useWatch({ control: form.control, name: 'panelDefinition.spec.links' });\n useEffect(() => {\n setLinks(links);\n }, [setLinks, links]);\n\n const processForm: SubmitHandler<PanelEditorValues> = (data) => {\n onSave(data);\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel(): void {\n if (JSON.stringify(initialValues) !== JSON.stringify(form.getValues())) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n const handlePanelDefinitionChange = (nextPanelDefStr: string): void => {\n const nextPanelDef: PanelDefinition = JSON.parse(nextPanelDefStr);\n const { kind: pluginKind, spec: pluginSpec } = nextPanelDef.spec.plugin;\n // if panel plugin kind and spec are modified, then need to save current spec\n if (\n panelDefinition.spec.plugin.kind !== pluginKind &&\n JSON.stringify(panelDefinition.spec.plugin.spec) !== JSON.stringify(pluginSpec)\n ) {\n pluginEditor.rememberCurrentSpecState();\n }\n setPanelDefinition(nextPanelDef);\n };\n\n const watchedName = useWatch({ control: form.control, name: 'panelDefinition.spec.display.name' });\n const watchedDescription = useWatch({ control: form.control, name: 'panelDefinition.spec.display.description' });\n const watchedPluginKind = useWatch({ control: form.control, name: 'panelDefinition.spec.plugin.kind' });\n\n return (\n <FormProvider {...form}>\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\">{titleAction} Panel</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button variant=\"contained\" disabled={!form.formState.isValid} onClick={form.handleSubmit(processForm)}>\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box id={panelEditorFormId} sx={{ flex: 1, overflowY: 'scroll', padding: (theme) => theme.spacing(2) }}>\n <Grid container spacing={2}>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"panelDefinition.spec.display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={watchedName ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setName(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"groupId\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n required\n fullWidth\n label=\"Group\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n }}\n >\n {panelGroups.map((panelGroup, index) => (\n <MenuItem key={panelGroup.id} value={panelGroup.id}>\n {panelGroup.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"panelDefinition.spec.display.description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={watchedDescription ?? ''}\n onChange={(event) => {\n field.onChange(event);\n setDescription(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"panelDefinition.spec.plugin.kind\"\n render={({ field, fieldState }) => (\n <PluginKindSelect\n {...field}\n pluginTypes={['Panel']}\n required\n fullWidth\n label=\"Type\"\n disabled={pluginEditor.isLoading}\n error={!!pluginEditor.error || !!fieldState.error}\n helperText={pluginEditor.error?.message ?? fieldState.error?.message}\n value={{ type: 'Panel', kind: watchedPluginKind }}\n onChange={(event) => {\n field.onChange(event.kind);\n pluginEditor.onSelectionChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h4\" marginBottom={1}>\n Preview\n </Typography>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelPreview panelDefinition={panelDefinition} />\n </ErrorBoundary>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelSpecEditor\n control={form.control}\n panelDefinition={panelDefinition}\n onJSONChange={handlePanelDefinitionChange}\n onQueriesChange={(queries) => {\n setQueries(queries);\n }}\n onPluginSpecChange={(spec) => {\n pluginEditor.onSpecChange(spec);\n }}\n />\n </ErrorBoundary>\n </Grid>\n </Grid>\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["useEffect","useState","Box","Button","Grid","MenuItem","Stack","TextField","Typography","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","PluginKindSelect","usePluginEditor","PanelSpecEditor","getTitleAction","getSubmitText","useValidationSchemas","Controller","FormProvider","useForm","useWatch","zodResolver","useListPanelGroups","PanelPreview","usePanelEditor","PanelEditorForm","props","initialValues","initialAction","onSave","onClose","panelGroups","panelDefinition","setName","setDescription","setLinks","setQueries","setPlugin","setPanelDefinition","plugin","spec","isDiscardDialogOpened","setDiscardDialogOpened","panelEditorSchema","form","resolver","mode","defaultValues","pluginEditor","pluginTypes","value","selection","kind","type","onChange","setValue","onHideQueryEditorChange","isHidden","undefined","titleAction","submitText","links","control","name","processForm","data","handleCancel","JSON","stringify","getValues","handlePanelDefinitionChange","nextPanelDefStr","nextPanelDef","parse","pluginKind","pluginSpec","rememberCurrentSpecState","watchedName","watchedDescription","watchedPluginKind","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","formState","isValid","onClick","handleSubmit","color","id","panelEditorFormId","flex","overflowY","container","item","xs","render","field","fieldState","required","fullWidth","label","error","helperText","message","event","target","select","map","panelGroup","index","title","isLoading","onSelectionChange","marginBottom","FallbackComponent","onJSONChange","onQueriesChange","queries","onPluginSpecChange","onSpecChange","description","isOpen","onCancel","onDiscardChanges"],"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,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAC1D,SAASC,GAAG,EAAEC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,g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SAAS;wCACTC,OAAM;wCACNlB,UAAU5C,aAAayE,SAAS;wCAChCV,OAAO,CAAC,CAAC/D,aAAa+D,KAAK,IAAI,CAAC,CAACJ,WAAWI,KAAK;wCACjDC,YAAYhE,aAAa+D,KAAK,EAAEE,WAAWN,WAAWI,KAAK,EAAEE;wCAC7D/D,OAAO;4CAAEG,MAAM;4CAASD,MAAM2B;wCAAkB;wCAChDzB,UAAU,CAAC4D;4CACTR,MAAMpD,QAAQ,CAAC4D,MAAM9D,IAAI;4CACzBJ,aAAa0E,iBAAiB,CAACR;wCACjC;;;;sCAKR,MAAC/G;4BAAKoG,IAAI;4BAACC,IAAI;;8CACb,KAACjG;oCAAWkF,SAAQ;oCAAKkC,cAAc;8CAAG;;8CAG1C,KAACjH;oCAAckH,mBAAmBnH;8CAChC,cAAA,KAACc;wCAAaS,iBAAiBA;;;;;sCAGnC,KAAC7B;4BAAKoG,IAAI;4BAACC,IAAI;sCACb,cAAA,KAAC9F;gCAAckH,mBAAmBnH;0CAChC,cAAA,KAACI;oCACCiD,SAASlB,KAAKkB,OAAO;oCACrB9B,iBAAiBA;oCACjB6F,cAAcvD;oCACdwD,iBAAiB,CAACC;wCAChB3F,WAAW2F;oCACb;oCACAC,oBAAoB,CAACxF;wCACnBQ,aAAaiF,YAAY,CAACzF;oCAC5B;;;;;;;0BAMV,KAAChC;gBACC0H,aAAY;gBACZC,QAAQ1F;gBACR2F,UAAU;oBACR1F,uBAAuB;gBACzB;gBACA2F,kBAAkB;oBAChB3F,uBAAuB;oBACvBZ;gBACF;;;;AAIR;AAEA;;CAEC,GACD,OAAO,MAAMqE,oBAAoB,oBAAoB"}
@@ -1,3 +1,4 @@
1
- import { PanelEditorValues } from '../../context';
2
- export declare function PanelPreview({ panelDefinition }: Pick<PanelEditorValues, 'panelDefinition'>): import("react/jsx-runtime").JSX.Element | null;
1
+ import { ReactElement } from 'react';
2
+ import { PanelEditorValues } from '@perses-dev/core';
3
+ export declare function PanelPreview({ panelDefinition }: Pick<PanelEditorValues, 'panelDefinition'>): ReactElement | null;
3
4
  //# sourceMappingURL=PanelPreview.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PanelPreview.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAMlD,wBAAgB,YAAY,CAAC,EAAE,eAAe,EAAE,EAAE,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,kDA+B3F"}
1
+ {"version":3,"file":"PanelPreview.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAU,MAAM,OAAO,CAAC;AAG7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,wBAAgB,YAAY,CAAC,EAAE,eAAe,EAAE,EAAE,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,YAAY,GAAG,IAAI,CAoCjH"}
@@ -13,7 +13,7 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { useRef } from 'react';
15
15
  import { Box } from '@mui/material';
16
- import { DataQueriesProvider, useSuggestedStepMs } from '@perses-dev/plugin-system';
16
+ import { DataQueriesProvider, usePlugin, useSuggestedStepMs } from '@perses-dev/plugin-system';
17
17
  import { Panel } from '../Panel';
18
18
  const PANEL_PREVIEW_HEIGHT = 300;
19
19
  const PANEL_PREVIEW_DEFAULT_WIDTH = 840;
@@ -24,11 +24,14 @@ export function PanelPreview({ panelDefinition }) {
24
24
  width = boxRef.current.getBoundingClientRect().width;
25
25
  }
26
26
  const suggestedStepMs = useSuggestedStepMs(width);
27
+ const { data: plugin, isPending } = usePlugin('Panel', panelDefinition.spec.plugin.kind);
28
+ if (isPending) {
29
+ return null;
30
+ }
27
31
  if (panelDefinition.spec.plugin.kind === '') {
28
32
  return null;
29
33
  }
30
- var _panelDefinition_spec_queries;
31
- const queries = (_panelDefinition_spec_queries = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries !== void 0 ? _panelDefinition_spec_queries : [];
34
+ const queries = panelDefinition.spec.queries ?? [];
32
35
  // map TimeSeriesQueryDefinition to Definition<UnknownSpec>
33
36
  const definitions = queries.length ? queries.map((query)=>{
34
37
  return {
@@ -42,7 +45,8 @@ export function PanelPreview({ panelDefinition }) {
42
45
  children: /*#__PURE__*/ _jsx(DataQueriesProvider, {
43
46
  definitions: definitions,
44
47
  options: {
45
- suggestedStepMs
48
+ suggestedStepMs,
49
+ ...plugin?.queryOptions
46
50
  },
47
51
  children: /*#__PURE__*/ _jsx(Panel, {
48
52
  definition: panelDefinition
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelDrawer/PanelPreview.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 { useRef } from 'react';\nimport { Box } from '@mui/material';\nimport { DataQueriesProvider, useSuggestedStepMs } from '@perses-dev/plugin-system';\nimport { PanelEditorValues } from '../../context';\nimport { Panel } from '../Panel';\n\nconst PANEL_PREVIEW_HEIGHT = 300;\nconst PANEL_PREVIEW_DEFAULT_WIDTH = 840;\n\nexport function PanelPreview({ panelDefinition }: Pick<PanelEditorValues, 'panelDefinition'>) {\n const boxRef = useRef<HTMLDivElement>(null);\n let width = PANEL_PREVIEW_DEFAULT_WIDTH;\n if (boxRef.current !== null) {\n width = boxRef.current.getBoundingClientRect().width;\n }\n const suggestedStepMs = useSuggestedStepMs(width);\n\n if (panelDefinition.spec.plugin.kind === '') {\n return null;\n }\n\n const queries = panelDefinition.spec.queries ?? [];\n\n // map TimeSeriesQueryDefinition to Definition<UnknownSpec>\n const definitions = queries.length\n ? queries.map((query) => {\n return {\n kind: query.spec.plugin.kind,\n spec: query.spec.plugin.spec,\n };\n })\n : [];\n\n return (\n <Box ref={boxRef} height={PANEL_PREVIEW_HEIGHT}>\n <DataQueriesProvider definitions={definitions} options={{ suggestedStepMs }}>\n <Panel definition={panelDefinition} />\n </DataQueriesProvider>\n </Box>\n );\n}\n"],"names":["useRef","Box","DataQueriesProvider","useSuggestedStepMs","Panel","PANEL_PREVIEW_HEIGHT","PANEL_PREVIEW_DEFAULT_WIDTH","PanelPreview","panelDefinition","boxRef","width","current","getBoundingClientRect","suggestedStepMs","spec","plugin","kind","queries","definitions","length","map","query","ref","height","options","definition"],"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,QAAQ;AAC/B,SAASC,GAAG,QAAQ,gBAAgB;AACpC,SAASC,mBAAmB,EAAEC,kBAAkB,QAAQ,4BAA4B;AAEpF,SAASC,KAAK,QAAQ,WAAW;AAEjC,MAAMC,uBAAuB;AAC7B,MAAMC,8BAA8B;AAEpC,OAAO,SAASC,aAAa,EAAEC,eAAe,EAA8C;IAC1F,MAAMC,SAAST,OAAuB;IACtC,IAAIU,QAAQJ;IACZ,IAAIG,OAAOE,OAAO,KAAK,MAAM;QAC3BD,QAAQD,OAAOE,OAAO,CAACC,qBAAqB,GAAGF,KAAK;IACtD;IACA,MAAMG,kBAAkBV,mBAAmBO;IAE3C,IAAIF,gBAAgBM,IAAI,CAACC,MAAM,CAACC,IAAI,KAAK,IAAI;QAC3C,OAAO;IACT;QAEgBR;IAAhB,MAAMS,UAAUT,CAAAA,gCAAAA,gBAAgBM,IAAI,CAACG,OAAO,cAA5BT,2CAAAA,gCAAgC,EAAE;IAElD,2DAA2D;IAC3D,MAAMU,cAAcD,QAAQE,MAAM,GAC9BF,QAAQG,GAAG,CAAC,CAACC;QACX,OAAO;YACLL,MAAMK,MAAMP,IAAI,CAACC,MAAM,CAACC,IAAI;YAC5BF,MAAMO,MAAMP,IAAI,CAACC,MAAM,CAACD,IAAI;QAC9B;IACF,KACA,EAAE;IAEN,qBACE,KAACb;QAAIqB,KAAKb;QAAQc,QAAQlB;kBACxB,cAAA,KAACH;YAAoBgB,aAAaA;YAAaM,SAAS;gBAAEX;YAAgB;sBACxE,cAAA,KAACT;gBAAMqB,YAAYjB;;;;AAI3B"}
1
+ {"version":3,"sources":["../../../src/components/PanelDrawer/PanelPreview.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, useRef } from 'react';\nimport { Box } from '@mui/material';\nimport { DataQueriesProvider, usePlugin, useSuggestedStepMs } from '@perses-dev/plugin-system';\nimport { PanelEditorValues } from '@perses-dev/core';\nimport { Panel } from '../Panel';\n\nconst PANEL_PREVIEW_HEIGHT = 300;\nconst PANEL_PREVIEW_DEFAULT_WIDTH = 840;\n\nexport function PanelPreview({ panelDefinition }: Pick<PanelEditorValues, 'panelDefinition'>): ReactElement | null {\n const boxRef = useRef<HTMLDivElement>(null);\n let width = PANEL_PREVIEW_DEFAULT_WIDTH;\n if (boxRef.current !== null) {\n width = boxRef.current.getBoundingClientRect().width;\n }\n const suggestedStepMs = useSuggestedStepMs(width);\n\n const { data: plugin, isPending } = usePlugin('Panel', panelDefinition.spec.plugin.kind);\n if (isPending) {\n return null;\n }\n\n if (panelDefinition.spec.plugin.kind === '') {\n return null;\n }\n\n const queries = panelDefinition.spec.queries ?? [];\n\n // map TimeSeriesQueryDefinition to Definition<UnknownSpec>\n const definitions = queries.length\n ? queries.map((query) => {\n return {\n kind: query.spec.plugin.kind,\n spec: query.spec.plugin.spec,\n };\n })\n : [];\n\n return (\n <Box ref={boxRef} height={PANEL_PREVIEW_HEIGHT}>\n <DataQueriesProvider definitions={definitions} options={{ suggestedStepMs, ...plugin?.queryOptions }}>\n <Panel definition={panelDefinition} />\n </DataQueriesProvider>\n </Box>\n );\n}\n"],"names":["useRef","Box","DataQueriesProvider","usePlugin","useSuggestedStepMs","Panel","PANEL_PREVIEW_HEIGHT","PANEL_PREVIEW_DEFAULT_WIDTH","PanelPreview","panelDefinition","boxRef","width","current","getBoundingClientRect","suggestedStepMs","data","plugin","isPending","spec","kind","queries","definitions","length","map","query","ref","height","options","queryOptions","definition"],"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,MAAM,QAAQ,QAAQ;AAC7C,SAASC,GAAG,QAAQ,gBAAgB;AACpC,SAASC,mBAAmB,EAAEC,SAAS,EAAEC,kBAAkB,QAAQ,4BAA4B;AAE/F,SAASC,KAAK,QAAQ,WAAW;AAEjC,MAAMC,uBAAuB;AAC7B,MAAMC,8BAA8B;AAEpC,OAAO,SAASC,aAAa,EAAEC,eAAe,EAA8C;IAC1F,MAAMC,SAASV,OAAuB;IACtC,IAAIW,QAAQJ;IACZ,IAAIG,OAAOE,OAAO,KAAK,MAAM;QAC3BD,QAAQD,OAAOE,OAAO,CAACC,qBAAqB,GAAGF,KAAK;IACtD;IACA,MAAMG,kBAAkBV,mBAAmBO;IAE3C,MAAM,EAAEI,MAAMC,MAAM,EAAEC,SAAS,EAAE,GAAGd,UAAU,SAASM,gBAAgBS,IAAI,CAACF,MAAM,CAACG,IAAI;IACvF,IAAIF,WAAW;QACb,OAAO;IACT;IAEA,IAAIR,gBAAgBS,IAAI,CAACF,MAAM,CAACG,IAAI,KAAK,IAAI;QAC3C,OAAO;IACT;IAEA,MAAMC,UAAUX,gBAAgBS,IAAI,CAACE,OAAO,IAAI,EAAE;IAElD,2DAA2D;IAC3D,MAAMC,cAAcD,QAAQE,MAAM,GAC9BF,QAAQG,GAAG,CAAC,CAACC;QACX,OAAO;YACLL,MAAMK,MAAMN,IAAI,CAACF,MAAM,CAACG,IAAI;YAC5BD,MAAMM,MAAMN,IAAI,CAACF,MAAM,CAACE,IAAI;QAC9B;IACF,KACA,EAAE;IAEN,qBACE,KAACjB;QAAIwB,KAAKf;QAAQgB,QAAQpB;kBACxB,cAAA,KAACJ;YAAoBmB,aAAaA;YAAaM,SAAS;gBAAEb;gBAAiB,GAAGE,QAAQY,YAAY;YAAC;sBACjG,cAAA,KAACvB;gBAAMwB,YAAYpB;;;;AAI3B"}
@@ -1,15 +1,17 @@
1
- /// <reference types="react" />
2
- import { PanelDefinition, QueryDefinition } from '@perses-dev/core';
1
+ import { Definition, Link, PanelDefinition, QueryDefinition, UnknownSpec } from '@perses-dev/core';
2
+ interface UsePanelEditorResult {
3
+ setName: (value: string) => void;
4
+ panelDefinition: PanelDefinition;
5
+ setPlugin: (value: Definition<UnknownSpec>) => void;
6
+ setLinks: (value?: Link[]) => void;
7
+ setDescription: (value?: string) => void;
8
+ setPanelDefinition: (panelDefinition: PanelDefinition) => void;
9
+ setQueries: (queries?: QueryDefinition[], hideQueryEditor?: boolean) => void;
10
+ }
3
11
  /**
4
12
  * UsePanelEditor is used in PanelEditorForm
5
13
  * This hook stores the states of panel definition and returns the onChange handlers for each state
6
14
  */
7
- export declare const usePanelEditor: (panelDefinition: PanelDefinition) => {
8
- panelDefinition: PanelDefinition<import("@perses-dev/core").UnknownSpec>;
9
- setName: import("react").Dispatch<import("react").SetStateAction<string>>;
10
- setDescription: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
11
- setQueries: (queries?: QueryDefinition[], hideQueryEditor?: boolean) => void;
12
- setPlugin: import("react").Dispatch<import("react").SetStateAction<import("@perses-dev/core").Definition<import("@perses-dev/core").UnknownSpec>>>;
13
- setPanelDefinition: (panelDefinition: PanelDefinition) => void;
14
- };
15
+ export declare const usePanelEditor: (panelDefinition: PanelDefinition) => UsePanelEditorResult;
16
+ export {};
15
17
  //# sourceMappingURL=usePanelEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePanelEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/usePanelEditor.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,cAAc,oBAAqB,eAAe;;;;2BAehD,eAAe,EAAE,oBAAoB,OAAO;;0CAarC,eAAe;CA4BpC,CAAC"}
1
+ {"version":3,"file":"usePanelEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/usePanelEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEnG,UAAU,oBAAoB;IAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,eAAe,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACpD,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACnC,cAAc,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,kBAAkB,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,IAAI,CAAC;IAC/D,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,EAAE,EAAE,eAAe,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9E;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,oBA8DlE,CAAC"}
@@ -15,9 +15,10 @@ import { useCallback, useMemo, useState } from 'react';
15
15
  * UsePanelEditor is used in PanelEditorForm
16
16
  * This hook stores the states of panel definition and returns the onChange handlers for each state
17
17
  */ export const usePanelEditor = (panelDefinition)=>{
18
- const { display, plugin: pluginDefinition, queries: initialQueries } = panelDefinition.spec;
18
+ const { display, plugin: pluginDefinition, queries: initialQueries, links: initialLinks } = panelDefinition.spec;
19
19
  const [name, setName] = useState(display.name);
20
20
  const [description, setDescription] = useState(display.description);
21
+ const [links, setLinks] = useState(initialLinks);
21
22
  const [plugin, setPlugin] = useState(pluginDefinition);
22
23
  // need to keep track of prevQueries if switching from a panel with no queries (ex: markdown) to one with queries
23
24
  const [prevQueries, setPrevQueries] = useState(initialQueries);
@@ -40,14 +41,16 @@ import { useCallback, useMemo, useState } from 'react';
40
41
  ]);
41
42
  // reset panel definition
42
43
  const setPanelDefinition = useCallback((panelDefinition)=>{
43
- const { display, plugin, queries } = panelDefinition.spec;
44
+ const { display, plugin, queries, links } = panelDefinition.spec;
44
45
  setName(display.name);
45
46
  setDescription(display.description);
47
+ setLinks(links);
46
48
  setPlugin(plugin);
47
49
  setQueries(queries);
48
50
  }, [
49
51
  setName,
50
52
  setDescription,
53
+ setLinks,
51
54
  setPlugin,
52
55
  setQueries
53
56
  ]);
@@ -60,23 +63,23 @@ import { useCallback, useMemo, useState } from 'react';
60
63
  description
61
64
  },
62
65
  plugin,
63
- queries: currentQueries
66
+ queries: currentQueries,
67
+ links
64
68
  }
65
69
  },
66
70
  setName,
67
71
  setDescription,
72
+ setLinks,
68
73
  setQueries,
69
74
  setPlugin,
70
75
  setPanelDefinition
71
76
  }), [
72
77
  name,
73
78
  description,
79
+ links,
74
80
  plugin,
75
81
  currentQueries,
76
- setName,
77
- setDescription,
78
82
  setQueries,
79
- setPlugin,
80
83
  setPanelDefinition
81
84
  ]);
82
85
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelDrawer/usePanelEditor.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 { useCallback, useMemo, useState } from 'react';\nimport { PanelDefinition, QueryDefinition } from '@perses-dev/core';\n\n/**\n * UsePanelEditor is used in PanelEditorForm\n * This hook stores the states of panel definition and returns the onChange handlers for each state\n */\nexport const usePanelEditor = (panelDefinition: PanelDefinition) => {\n const { display, plugin: pluginDefinition, queries: initialQueries } = panelDefinition.spec;\n const [name, setName] = useState(display.name);\n const [description, setDescription] = useState(display.description);\n const [plugin, setPlugin] = useState(pluginDefinition);\n\n // need to keep track of prevQueries if switching from a panel with no queries (ex: markdown) to one with queries\n const [prevQueries, setPrevQueries] = useState(initialQueries);\n const [currentQueries, setCurrentQueries] = useState(initialQueries);\n\n /**\n * If hideQueryEditor is true, set panelDefinition.spec.queries to undefined.\n * If hideQueryEditor is false and query is undefined, set panelDefinition.spec.queries to previous queries.\n */\n const setQueries = useCallback(\n (queries?: QueryDefinition[], hideQueryEditor?: boolean) => {\n if (hideQueryEditor) {\n setPrevQueries(currentQueries);\n setCurrentQueries(undefined);\n } else {\n setCurrentQueries(queries === undefined ? prevQueries : queries);\n }\n },\n [setCurrentQueries, currentQueries, setPrevQueries, prevQueries]\n );\n\n // reset panel definition\n const setPanelDefinition = useCallback(\n (panelDefinition: PanelDefinition) => {\n const { display, plugin, queries } = panelDefinition.spec;\n setName(display.name);\n setDescription(display.description);\n setPlugin(plugin);\n setQueries(queries);\n },\n [setName, setDescription, setPlugin, setQueries]\n );\n\n return useMemo(\n () => ({\n panelDefinition: {\n kind: 'Panel',\n spec: {\n display: { name, description },\n plugin,\n queries: currentQueries,\n },\n } as PanelDefinition,\n setName,\n setDescription,\n setQueries,\n setPlugin,\n setPanelDefinition,\n }),\n [name, description, plugin, currentQueries, setName, setDescription, setQueries, setPlugin, setPanelDefinition]\n );\n};\n"],"names":["useCallback","useMemo","useState","usePanelEditor","panelDefinition","display","plugin","pluginDefinition","queries","initialQueries","spec","name","setName","description","setDescription","setPlugin","prevQueries","setPrevQueries","currentQueries","setCurrentQueries","setQueries","hideQueryEditor","undefined","setPanelDefinition","kind"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAGvD;;;CAGC,GACD,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,MAAM,EAAEC,OAAO,EAAEC,QAAQC,gBAAgB,EAAEC,SAASC,cAAc,EAAE,GAAGL,gBAAgBM,IAAI;IAC3F,MAAM,CAACC,MAAMC,QAAQ,GAAGV,SAASG,QAAQM,IAAI;IAC7C,MAAM,CAACE,aAAaC,eAAe,GAAGZ,SAASG,QAAQQ,WAAW;IAClE,MAAM,CAACP,QAAQS,UAAU,GAAGb,SAASK;IAErC,iHAAiH;IACjH,MAAM,CAACS,aAAaC,eAAe,GAAGf,SAASO;IAC/C,MAAM,CAACS,gBAAgBC,kBAAkB,GAAGjB,SAASO;IAErD;;;GAGC,GACD,MAAMW,aAAapB,YACjB,CAACQ,SAA6Ba;QAC5B,IAAIA,iBAAiB;YACnBJ,eAAeC;YACfC,kBAAkBG;QACpB,OAAO;YACLH,kBAAkBX,YAAYc,YAAYN,cAAcR;QAC1D;IACF,GACA;QAACW;QAAmBD;QAAgBD;QAAgBD;KAAY;IAGlE,yBAAyB;IACzB,MAAMO,qBAAqBvB,YACzB,CAACI;QACC,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEE,OAAO,EAAE,GAAGJ,gBAAgBM,IAAI;QACzDE,QAAQP,QAAQM,IAAI;QACpBG,eAAeT,QAAQQ,WAAW;QAClCE,UAAUT;QACVc,WAAWZ;IACb,GACA;QAACI;QAASE;QAAgBC;QAAWK;KAAW;IAGlD,OAAOnB,QACL,IAAO,CAAA;YACLG,iBAAiB;gBACfoB,MAAM;gBACNd,MAAM;oBACJL,SAAS;wBAAEM;wBAAME;oBAAY;oBAC7BP;oBACAE,SAASU;gBACX;YACF;YACAN;YACAE;YACAM;YACAL;YACAQ;QACF,CAAA,GACA;QAACZ;QAAME;QAAaP;QAAQY;QAAgBN;QAASE;QAAgBM;QAAYL;QAAWQ;KAAmB;AAEnH,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/PanelDrawer/usePanelEditor.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 { useCallback, useMemo, useState } from 'react';\nimport { Definition, Link, PanelDefinition, QueryDefinition, UnknownSpec } from '@perses-dev/core';\n\ninterface UsePanelEditorResult {\n setName: (value: string) => void;\n panelDefinition: PanelDefinition;\n setPlugin: (value: Definition<UnknownSpec>) => void;\n setLinks: (value?: Link[]) => void;\n setDescription: (value?: string) => void;\n setPanelDefinition: (panelDefinition: PanelDefinition) => void;\n setQueries: (queries?: QueryDefinition[], hideQueryEditor?: boolean) => void;\n}\n\n/**\n * UsePanelEditor is used in PanelEditorForm\n * This hook stores the states of panel definition and returns the onChange handlers for each state\n */\nexport const usePanelEditor: (panelDefinition: PanelDefinition) => UsePanelEditorResult = (\n panelDefinition: PanelDefinition\n) => {\n const { display, plugin: pluginDefinition, queries: initialQueries, links: initialLinks } = panelDefinition.spec;\n const [name, setName] = useState(display.name);\n const [description, setDescription] = useState(display.description);\n const [links, setLinks] = useState(initialLinks);\n const [plugin, setPlugin] = useState(pluginDefinition);\n\n // need to keep track of prevQueries if switching from a panel with no queries (ex: markdown) to one with queries\n const [prevQueries, setPrevQueries] = useState(initialQueries);\n const [currentQueries, setCurrentQueries] = useState(initialQueries);\n\n /**\n * If hideQueryEditor is true, set panelDefinition.spec.queries to undefined.\n * If hideQueryEditor is false and query is undefined, set panelDefinition.spec.queries to previous queries.\n */\n const setQueries = useCallback(\n (queries?: QueryDefinition[], hideQueryEditor?: boolean) => {\n if (hideQueryEditor) {\n setPrevQueries(currentQueries);\n setCurrentQueries(undefined);\n } else {\n setCurrentQueries(queries === undefined ? prevQueries : queries);\n }\n },\n [setCurrentQueries, currentQueries, setPrevQueries, prevQueries]\n );\n\n // reset panel definition\n const setPanelDefinition = useCallback(\n (panelDefinition: PanelDefinition) => {\n const { display, plugin, queries, links } = panelDefinition.spec;\n setName(display.name);\n setDescription(display.description);\n setLinks(links);\n setPlugin(plugin);\n setQueries(queries);\n },\n [setName, setDescription, setLinks, setPlugin, setQueries]\n );\n\n return useMemo(\n () => ({\n panelDefinition: {\n kind: 'Panel',\n spec: {\n display: { name, description },\n plugin,\n queries: currentQueries,\n links,\n },\n } as PanelDefinition,\n setName,\n setDescription,\n setLinks,\n setQueries,\n setPlugin,\n setPanelDefinition,\n }),\n [name, description, links, plugin, currentQueries, setQueries, setPanelDefinition]\n );\n};\n"],"names":["useCallback","useMemo","useState","usePanelEditor","panelDefinition","display","plugin","pluginDefinition","queries","initialQueries","links","initialLinks","spec","name","setName","description","setDescription","setLinks","setPlugin","prevQueries","setPrevQueries","currentQueries","setCurrentQueries","setQueries","hideQueryEditor","undefined","setPanelDefinition","kind"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAavD;;;CAGC,GACD,OAAO,MAAMC,iBAA6E,CACxFC;IAEA,MAAM,EAAEC,OAAO,EAAEC,QAAQC,gBAAgB,EAAEC,SAASC,cAAc,EAAEC,OAAOC,YAAY,EAAE,GAAGP,gBAAgBQ,IAAI;IAChH,MAAM,CAACC,MAAMC,QAAQ,GAAGZ,SAASG,QAAQQ,IAAI;IAC7C,MAAM,CAACE,aAAaC,eAAe,GAAGd,SAASG,QAAQU,WAAW;IAClE,MAAM,CAACL,OAAOO,SAAS,GAAGf,SAASS;IACnC,MAAM,CAACL,QAAQY,UAAU,GAAGhB,SAASK;IAErC,iHAAiH;IACjH,MAAM,CAACY,aAAaC,eAAe,GAAGlB,SAASO;IAC/C,MAAM,CAACY,gBAAgBC,kBAAkB,GAAGpB,SAASO;IAErD;;;GAGC,GACD,MAAMc,aAAavB,YACjB,CAACQ,SAA6BgB;QAC5B,IAAIA,iBAAiB;YACnBJ,eAAeC;YACfC,kBAAkBG;QACpB,OAAO;YACLH,kBAAkBd,YAAYiB,YAAYN,cAAcX;QAC1D;IACF,GACA;QAACc;QAAmBD;QAAgBD;QAAgBD;KAAY;IAGlE,yBAAyB;IACzB,MAAMO,qBAAqB1B,YACzB,CAACI;QACC,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEE,OAAO,EAAEE,KAAK,EAAE,GAAGN,gBAAgBQ,IAAI;QAChEE,QAAQT,QAAQQ,IAAI;QACpBG,eAAeX,QAAQU,WAAW;QAClCE,SAASP;QACTQ,UAAUZ;QACViB,WAAWf;IACb,GACA;QAACM;QAASE;QAAgBC;QAAUC;QAAWK;KAAW;IAG5D,OAAOtB,QACL,IAAO,CAAA;YACLG,iBAAiB;gBACfuB,MAAM;gBACNf,MAAM;oBACJP,SAAS;wBAAEQ;wBAAME;oBAAY;oBAC7BT;oBACAE,SAASa;oBACTX;gBACF;YACF;YACAI;YACAE;YACAC;YACAM;YACAL;YACAQ;QACF,CAAA,GACA;QAACb;QAAME;QAAaL;QAAOJ;QAAQe;QAAgBE;QAAYG;KAAmB;AAEtF,EAAE"}
@@ -1,5 +1,6 @@
1
+ import { ReactElement } from 'react';
1
2
  /**
2
3
  * A dialog for adding or editing a Panel Group. Open and initial state is controlled by the DashboardStore.
3
4
  */
4
- export declare function PanelGroupDialog(): import("react/jsx-runtime").JSX.Element;
5
+ export declare function PanelGroupDialog(): ReactElement;
5
6
  //# sourceMappingURL=PanelGroupDialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PanelGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.tsx"],"names":[],"mappings":"AAmBA;;GAEG;AACH,wBAAgB,gBAAgB,4CAwD/B"}
1
+ {"version":3,"file":"PanelGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAI/C;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,CAwD/C"}
@@ -25,7 +25,7 @@ import { PanelGroupEditorForm, panelGroupEditorFormId } from './PanelGroupEditor
25
25
  const handleClose = ()=>setIsClosing(true);
26
26
  // Don't call close on the store until the Dialog has completely transitioned out
27
27
  const handleExited = ()=>{
28
- panelGroupEditor === null || panelGroupEditor === void 0 ? void 0 : panelGroupEditor.close();
28
+ panelGroupEditor?.close();
29
29
  setIsClosing(false);
30
30
  };
31
31
  // Dialog is open if we have a model and we're not transitioning out
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.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 { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useState } from 'react';\nimport { usePanelGroupEditor } from '../../context';\nimport { PanelGroupEditorForm, panelGroupEditorFormId, PanelGroupEditorFormProps } from './PanelGroupEditorForm';\n\n/**\n * A dialog for adding or editing a Panel Group. Open and initial state is controlled by the DashboardStore.\n */\nexport function PanelGroupDialog() {\n const panelGroupEditor = usePanelGroupEditor();\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n const handleClose = () => setIsClosing(true);\n\n // Don't call close on the store until the Dialog has completely transitioned out\n const handleExited = () => {\n panelGroupEditor?.close();\n setIsClosing(false);\n };\n\n // Dialog is open if we have a model and we're not transitioning out\n const isOpen = panelGroupEditor !== undefined && isClosing === false;\n\n const handleSubmit: PanelGroupEditorFormProps['onSubmit'] = (values) => {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelGroupEditor === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelGroupEditor.applyChanges(values);\n handleClose();\n };\n\n return (\n <Dialog open={isOpen} TransitionProps={{ onExited: handleExited }}>\n {panelGroupEditor !== undefined && (\n <>\n <DialogTitle>{panelGroupEditor.mode} Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={panelGroupEditor.close}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <DialogContent dividers sx={{ width: '500px' }}>\n <PanelGroupEditorForm initialValues={panelGroupEditor.initialValues} onSubmit={handleSubmit} />\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\" form={panelGroupEditorFormId}>\n {panelGroupEditor.mode === 'Edit' ? 'Apply' : 'Add'}\n </Button>\n <Button variant=\"outlined\" color=\"secondary\" onClick={panelGroupEditor.close}>\n Cancel\n </Button>\n </DialogActions>\n </>\n )}\n </Dialog>\n );\n}\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useState","usePanelGroupEditor","PanelGroupEditorForm","panelGroupEditorFormId","PanelGroupDialog","panelGroupEditor","isClosing","setIsClosing","handleClose","handleExited","close","isOpen","undefined","handleSubmit","values","Error","applyChanges","open","TransitionProps","onExited","mode","aria-label","onClick","sx","theme","position","top","spacing","right","dividers","width","initialValues","onSubmit","variant","type","form","color"],"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,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,gBAAgB;AACtG,OAAOC,eAAe,wBAAwB;AAC9C,SAASC,QAAQ,QAAQ,QAAQ;AACjC,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,oBAAoB,EAAEC,sBAAsB,QAAmC,yBAA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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 { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { ReactElement, useState } from 'react';\nimport { usePanelGroupEditor } from '../../context';\nimport { PanelGroupEditorForm, panelGroupEditorFormId, PanelGroupEditorFormProps } from './PanelGroupEditorForm';\n\n/**\n * A dialog for adding or editing a Panel Group. Open and initial state is controlled by the DashboardStore.\n */\nexport function PanelGroupDialog(): ReactElement {\n const panelGroupEditor = usePanelGroupEditor();\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n const handleClose = (): void => setIsClosing(true);\n\n // Don't call close on the store until the Dialog has completely transitioned out\n const handleExited = (): void => {\n panelGroupEditor?.close();\n setIsClosing(false);\n };\n\n // Dialog is open if we have a model and we're not transitioning out\n const isOpen = panelGroupEditor !== undefined && isClosing === false;\n\n const handleSubmit: PanelGroupEditorFormProps['onSubmit'] = (values) => {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelGroupEditor === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelGroupEditor.applyChanges(values);\n handleClose();\n };\n\n return (\n <Dialog open={isOpen} TransitionProps={{ onExited: handleExited }}>\n {panelGroupEditor !== undefined && (\n <>\n <DialogTitle>{panelGroupEditor.mode} Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={panelGroupEditor.close}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <DialogContent dividers sx={{ width: '500px' }}>\n <PanelGroupEditorForm initialValues={panelGroupEditor.initialValues} onSubmit={handleSubmit} />\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\" form={panelGroupEditorFormId}>\n {panelGroupEditor.mode === 'Edit' ? 'Apply' : 'Add'}\n </Button>\n <Button variant=\"outlined\" color=\"secondary\" onClick={panelGroupEditor.close}>\n Cancel\n </Button>\n </DialogActions>\n </>\n )}\n </Dialog>\n );\n}\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useState","usePanelGroupEditor","PanelGroupEditorForm","panelGroupEditorFormId","PanelGroupDialog","panelGroupEditor","isClosing","setIsClosing","handleClose","handleExited","close","isOpen","undefined","handleSubmit","values","Error","applyChanges","open","TransitionProps","onExited","mode","aria-label","onClick","sx","theme","position","top","spacing","right","dividers","width","initialValues","onSubmit","variant","type","form","color"],"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,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,gBAAgB;AACtG,OAAOC,eAAe,wBAAwB;AAC9C,SAAuBC,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,oBAAoB,EAAEC,sBAAsB,QAAmC,yBAAyB;AAEjH;;CAEC,GACD,OAAO,SAASC;IACd,MAAMC,mBAAmBJ;IAEzB,iHAAiH;IACjH,MAAM,CAACK,WAAWC,aAAa,GAAGP,SAAS;IAC3C,MAAMQ,cAAc,IAAYD,aAAa;IAE7C,iFAAiF;IACjF,MAAME,eAAe;QACnBJ,kBAAkBK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