@perses-dev/dashboards 0.53.0 → 0.54.0-beta.0

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 (293) hide show
  1. package/dist/cjs/components/DashboardLinks/DashboardLinksEditor.js +366 -0
  2. package/dist/cjs/components/DashboardLinks/EditDashboardLinksButton.js +81 -0
  3. package/dist/cjs/components/DashboardLinks/index.js +31 -0
  4. package/dist/cjs/components/DashboardShortcuts/index.js +23 -0
  5. package/dist/cjs/components/DashboardShortcuts/useDashboardShortcuts.js +373 -0
  6. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +16 -1
  7. package/dist/cjs/components/Datasources/EditDatasourcesButton.js +1 -7
  8. package/dist/cjs/components/GridLayout/GridItemContent.js +19 -6
  9. package/dist/cjs/components/{Panel/PanelLinks.js → LinksDisplay/LinksDisplay.js} +59 -10
  10. package/dist/cjs/components/LinksDisplay/index.js +30 -0
  11. package/dist/cjs/components/Panel/PanelActions.js +58 -35
  12. package/dist/cjs/components/PanelDrawer/PanelQueriesSharedControls.js +16 -1
  13. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -4
  14. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +3 -61
  15. package/dist/cjs/components/Variables/ListVariableListBox.js +6 -6
  16. package/dist/cjs/components/Variables/Variable.js +3 -3
  17. package/dist/cjs/components/index.js +2 -0
  18. package/dist/cjs/constants/user-interface-text.js +1 -0
  19. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +5 -1
  20. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +16 -0
  21. package/dist/cjs/context/DashboardProvider/index.js +7 -0
  22. package/dist/cjs/context/DashboardProvider/links-slice.js +32 -0
  23. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +2 -2
  24. package/dist/cjs/context/DashboardProvider/use-save-dashboard.js +104 -0
  25. package/dist/cjs/context/DatasourceStoreProvider.js +3 -9
  26. package/dist/cjs/context/VariableProvider/VariableProvider.js +7 -6
  27. package/dist/cjs/context/VariableProvider/hydrationUtils.js +3 -3
  28. package/dist/cjs/context/useDashboard.js +7 -4
  29. package/dist/cjs/index.js +2 -0
  30. package/dist/cjs/keyboard-shortcuts/PanelFocusProvider.js +157 -0
  31. package/dist/cjs/keyboard-shortcuts/default-shortcuts/dashboard.js +75 -0
  32. package/dist/cjs/keyboard-shortcuts/default-shortcuts/global.js +121 -0
  33. package/dist/cjs/keyboard-shortcuts/default-shortcuts/index.js +33 -0
  34. package/dist/cjs/keyboard-shortcuts/default-shortcuts/panel.js +90 -0
  35. package/dist/cjs/keyboard-shortcuts/default-shortcuts/time-range.js +142 -0
  36. package/dist/cjs/keyboard-shortcuts/events.js +93 -0
  37. package/dist/cjs/keyboard-shortcuts/index.js +89 -0
  38. package/dist/cjs/keyboard-shortcuts/types.js +42 -0
  39. package/dist/cjs/keyboard-shortcuts/utils.js +76 -0
  40. package/dist/cjs/model/DashboardResource.js +16 -0
  41. package/dist/cjs/model/index.js +30 -0
  42. package/dist/cjs/test/render.js +18 -3
  43. package/dist/cjs/views/ViewDashboard/DashboardApp.js +17 -2
  44. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -1
  45. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  46. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  47. package/dist/components/DashboardLinks/DashboardLinksEditor.d.ts +9 -0
  48. package/dist/components/DashboardLinks/DashboardLinksEditor.d.ts.map +1 -0
  49. package/dist/components/DashboardLinks/DashboardLinksEditor.js +353 -0
  50. package/dist/components/DashboardLinks/DashboardLinksEditor.js.map +1 -0
  51. package/dist/components/DashboardLinks/EditDashboardLinksButton.d.ts +18 -0
  52. package/dist/components/DashboardLinks/EditDashboardLinksButton.d.ts.map +1 -0
  53. package/dist/components/DashboardLinks/EditDashboardLinksButton.js +68 -0
  54. package/dist/components/DashboardLinks/EditDashboardLinksButton.js.map +1 -0
  55. package/dist/components/DashboardLinks/index.d.ts +3 -0
  56. package/dist/components/DashboardLinks/index.d.ts.map +1 -0
  57. package/dist/components/DashboardLinks/index.js +16 -0
  58. package/dist/components/DashboardLinks/index.js.map +1 -0
  59. package/dist/components/DashboardShortcuts/index.d.ts +3 -0
  60. package/dist/components/DashboardShortcuts/index.d.ts.map +1 -0
  61. package/dist/components/DashboardShortcuts/index.js +15 -0
  62. package/dist/components/DashboardShortcuts/index.js.map +1 -0
  63. package/dist/components/DashboardShortcuts/useDashboardShortcuts.d.ts +12 -0
  64. package/dist/components/DashboardShortcuts/useDashboardShortcuts.d.ts.map +1 -0
  65. package/dist/components/DashboardShortcuts/useDashboardShortcuts.js +365 -0
  66. package/dist/components/DashboardShortcuts/useDashboardShortcuts.js.map +1 -0
  67. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -0
  68. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  69. package/dist/components/DashboardToolbar/DashboardToolbar.js +17 -2
  70. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  71. package/dist/components/Datasources/DatasourceEditor.d.ts +1 -1
  72. package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
  73. package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
  74. package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -1
  75. package/dist/components/Datasources/EditDatasourcesButton.js +1 -7
  76. package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
  77. package/dist/components/DownloadButton/serializeDashboard.d.ts +2 -2
  78. package/dist/components/DownloadButton/serializeDashboard.d.ts.map +1 -1
  79. package/dist/components/DownloadButton/serializeDashboard.js.map +1 -1
  80. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  81. package/dist/components/GridLayout/GridItemContent.js +21 -8
  82. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  83. package/dist/components/GridLayout/GridLayout.d.ts +1 -1
  84. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  85. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  86. package/dist/components/GridLayout/GridTitle.d.ts +1 -1
  87. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  88. package/dist/components/GridLayout/Row.d.ts +2 -1
  89. package/dist/components/GridLayout/Row.d.ts.map +1 -1
  90. package/dist/components/GridLayout/Row.js.map +1 -1
  91. package/dist/components/LeaveDialog/LeaveDialog.d.ts +3 -3
  92. package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -1
  93. package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -1
  94. package/dist/components/LinksDisplay/LinksDisplay.d.ts +10 -0
  95. package/dist/components/LinksDisplay/LinksDisplay.d.ts.map +1 -0
  96. package/dist/components/{Panel/PanelLinks.js → LinksDisplay/LinksDisplay.js} +59 -10
  97. package/dist/components/LinksDisplay/LinksDisplay.js.map +1 -0
  98. package/dist/components/LinksDisplay/index.d.ts +2 -0
  99. package/dist/components/LinksDisplay/index.d.ts.map +1 -0
  100. package/dist/components/LinksDisplay/index.js +15 -0
  101. package/dist/components/LinksDisplay/index.js.map +1 -0
  102. package/dist/components/Panel/Panel.d.ts +2 -1
  103. package/dist/components/Panel/Panel.d.ts.map +1 -1
  104. package/dist/components/Panel/Panel.js.map +1 -1
  105. package/dist/components/Panel/PanelActions.d.ts +1 -1
  106. package/dist/components/Panel/PanelActions.d.ts.map +1 -1
  107. package/dist/components/Panel/PanelActions.js +59 -36
  108. package/dist/components/Panel/PanelActions.js.map +1 -1
  109. package/dist/components/Panel/PanelContent.d.ts +1 -1
  110. package/dist/components/Panel/PanelContent.js.map +1 -1
  111. package/dist/components/Panel/PanelHeader.d.ts +1 -1
  112. package/dist/components/Panel/PanelHeader.js.map +1 -1
  113. package/dist/components/Panel/PanelPluginLoader.d.ts +1 -1
  114. package/dist/components/Panel/PanelPluginLoader.js.map +1 -1
  115. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  116. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +2 -1
  117. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  118. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  119. package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -1
  120. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  121. package/dist/components/PanelDrawer/PanelQueriesSharedControls.d.ts +1 -1
  122. package/dist/components/PanelDrawer/PanelQueriesSharedControls.d.ts.map +1 -1
  123. package/dist/components/PanelDrawer/PanelQueriesSharedControls.js +16 -1
  124. package/dist/components/PanelDrawer/PanelQueriesSharedControls.js.map +1 -1
  125. package/dist/components/PanelDrawer/usePanelEditor.d.ts +1 -1
  126. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
  127. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  128. package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts +1 -1
  129. package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -1
  130. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +1 -1
  131. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  132. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  133. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +4 -62
  134. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  135. package/dist/components/Variables/BuiltinVariableAccordions.d.ts +1 -1
  136. package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -1
  137. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  138. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  139. package/dist/components/Variables/ListVariableListBox.js +1 -1
  140. package/dist/components/Variables/ListVariableListBox.js.map +1 -1
  141. package/dist/components/Variables/Variable.d.ts +1 -1
  142. package/dist/components/Variables/Variable.js +1 -1
  143. package/dist/components/Variables/Variable.js.map +1 -1
  144. package/dist/components/Variables/VariableEditor.d.ts +2 -1
  145. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  146. package/dist/components/Variables/VariableEditor.js.map +1 -1
  147. package/dist/components/Variables/VariableList.d.ts +1 -1
  148. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  149. package/dist/components/Variables/VariableList.js.map +1 -1
  150. package/dist/components/index.d.ts +2 -0
  151. package/dist/components/index.d.ts.map +1 -1
  152. package/dist/components/index.js +2 -0
  153. package/dist/components/index.js.map +1 -1
  154. package/dist/constants/user-interface-text.d.ts +1 -0
  155. package/dist/constants/user-interface-text.d.ts.map +1 -1
  156. package/dist/constants/user-interface-text.js +1 -0
  157. package/dist/constants/user-interface-text.js.map +1 -1
  158. package/dist/context/DashboardProvider/DashboardProvider.d.ts +8 -6
  159. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  160. package/dist/context/DashboardProvider/DashboardProvider.js +5 -1
  161. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  162. package/dist/context/DashboardProvider/common.d.ts +3 -2
  163. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  164. package/dist/context/DashboardProvider/common.js.map +1 -1
  165. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +15 -2
  166. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  167. package/dist/context/DashboardProvider/dashboard-provider-api.js +14 -0
  168. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  169. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +1 -1
  170. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  171. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  172. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  173. package/dist/context/DashboardProvider/index.d.ts +2 -0
  174. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  175. package/dist/context/DashboardProvider/index.js +1 -0
  176. package/dist/context/DashboardProvider/index.js.map +1 -1
  177. package/dist/context/DashboardProvider/links-slice.d.ts +19 -0
  178. package/dist/context/DashboardProvider/links-slice.d.ts.map +1 -0
  179. package/dist/context/DashboardProvider/links-slice.js +27 -0
  180. package/dist/context/DashboardProvider/links-slice.js.map +1 -0
  181. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -1
  182. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  183. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  184. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -1
  185. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  186. package/dist/context/DashboardProvider/panel-group-slice.d.ts +2 -1
  187. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  188. package/dist/context/DashboardProvider/panel-group-slice.js +1 -1
  189. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  190. package/dist/context/DashboardProvider/panel-slice.d.ts +1 -1
  191. package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
  192. package/dist/context/DashboardProvider/use-save-dashboard.d.ts +25 -0
  193. package/dist/context/DashboardProvider/use-save-dashboard.d.ts.map +1 -0
  194. package/dist/context/DashboardProvider/use-save-dashboard.js +105 -0
  195. package/dist/context/DashboardProvider/use-save-dashboard.js.map +1 -0
  196. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
  197. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
  198. package/dist/context/DatasourceStoreProvider.d.ts +4 -2
  199. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  200. package/dist/context/DatasourceStoreProvider.js +3 -9
  201. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  202. package/dist/context/VariableProvider/VariableProvider.d.ts +2 -1
  203. package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -1
  204. package/dist/context/VariableProvider/VariableProvider.js +2 -1
  205. package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
  206. package/dist/context/VariableProvider/hydrationUtils.d.ts +2 -1
  207. package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -1
  208. package/dist/context/VariableProvider/hydrationUtils.js +1 -1
  209. package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
  210. package/dist/context/VariableProvider/query-params.d.ts +1 -1
  211. package/dist/context/VariableProvider/query-params.js.map +1 -1
  212. package/dist/context/VariableProvider/utils.d.ts +2 -1
  213. package/dist/context/VariableProvider/utils.d.ts.map +1 -1
  214. package/dist/context/VariableProvider/utils.js.map +1 -1
  215. package/dist/context/useDashboard.d.ts +11 -3
  216. package/dist/context/useDashboard.d.ts.map +1 -1
  217. package/dist/context/useDashboard.js +6 -3
  218. package/dist/context/useDashboard.js.map +1 -1
  219. package/dist/index.d.ts +2 -0
  220. package/dist/index.d.ts.map +1 -1
  221. package/dist/index.js +2 -0
  222. package/dist/index.js.map +1 -1
  223. package/dist/keyboard-shortcuts/PanelFocusProvider.d.ts +12 -0
  224. package/dist/keyboard-shortcuts/PanelFocusProvider.d.ts.map +1 -0
  225. package/dist/keyboard-shortcuts/PanelFocusProvider.js +97 -0
  226. package/dist/keyboard-shortcuts/PanelFocusProvider.js.map +1 -0
  227. package/dist/keyboard-shortcuts/default-shortcuts/dashboard.d.ts +6 -0
  228. package/dist/keyboard-shortcuts/default-shortcuts/dashboard.d.ts.map +1 -0
  229. package/dist/keyboard-shortcuts/default-shortcuts/dashboard.js +53 -0
  230. package/dist/keyboard-shortcuts/default-shortcuts/dashboard.js.map +1 -0
  231. package/dist/keyboard-shortcuts/default-shortcuts/global.d.ts +9 -0
  232. package/dist/keyboard-shortcuts/default-shortcuts/global.d.ts.map +1 -0
  233. package/dist/keyboard-shortcuts/default-shortcuts/global.js +90 -0
  234. package/dist/keyboard-shortcuts/default-shortcuts/global.js.map +1 -0
  235. package/dist/keyboard-shortcuts/default-shortcuts/index.d.ts +5 -0
  236. package/dist/keyboard-shortcuts/default-shortcuts/index.d.ts.map +1 -0
  237. package/dist/keyboard-shortcuts/default-shortcuts/index.js +18 -0
  238. package/dist/keyboard-shortcuts/default-shortcuts/index.js.map +1 -0
  239. package/dist/keyboard-shortcuts/default-shortcuts/panel.d.ts +7 -0
  240. package/dist/keyboard-shortcuts/default-shortcuts/panel.d.ts.map +1 -0
  241. package/dist/keyboard-shortcuts/default-shortcuts/panel.js +65 -0
  242. package/dist/keyboard-shortcuts/default-shortcuts/panel.js.map +1 -0
  243. package/dist/keyboard-shortcuts/default-shortcuts/time-range.d.ts +10 -0
  244. package/dist/keyboard-shortcuts/default-shortcuts/time-range.d.ts.map +1 -0
  245. package/dist/keyboard-shortcuts/default-shortcuts/time-range.js +108 -0
  246. package/dist/keyboard-shortcuts/default-shortcuts/time-range.js.map +1 -0
  247. package/dist/keyboard-shortcuts/events.d.ts +18 -0
  248. package/dist/keyboard-shortcuts/events.d.ts.map +1 -0
  249. package/dist/keyboard-shortcuts/events.js +35 -0
  250. package/dist/keyboard-shortcuts/events.js.map +1 -0
  251. package/dist/keyboard-shortcuts/index.d.ts +9 -0
  252. package/dist/keyboard-shortcuts/index.d.ts.map +1 -0
  253. package/dist/keyboard-shortcuts/index.js +21 -0
  254. package/dist/keyboard-shortcuts/index.js.map +1 -0
  255. package/dist/keyboard-shortcuts/types.d.ts +37 -0
  256. package/dist/keyboard-shortcuts/types.d.ts.map +1 -0
  257. package/dist/keyboard-shortcuts/types.js +26 -0
  258. package/dist/keyboard-shortcuts/types.js.map +1 -0
  259. package/dist/keyboard-shortcuts/utils.d.ts +12 -0
  260. package/dist/keyboard-shortcuts/utils.d.ts.map +1 -0
  261. package/dist/keyboard-shortcuts/utils.js +51 -0
  262. package/dist/keyboard-shortcuts/utils.js.map +1 -0
  263. package/dist/model/DashboardResource.d.ts +15 -0
  264. package/dist/model/DashboardResource.d.ts.map +1 -0
  265. package/dist/model/DashboardResource.js +18 -0
  266. package/dist/model/DashboardResource.js.map +1 -0
  267. package/dist/model/index.d.ts +2 -0
  268. package/dist/model/index.d.ts.map +1 -0
  269. package/dist/model/index.js +15 -0
  270. package/dist/model/index.js.map +1 -0
  271. package/dist/test/dashboard-provider.d.ts +1 -1
  272. package/dist/test/dashboard-provider.d.ts.map +1 -1
  273. package/dist/test/dashboard-provider.js.map +1 -1
  274. package/dist/test/datasource-provider.js.map +1 -1
  275. package/dist/test/plugin-registry.js.map +1 -1
  276. package/dist/test/render.d.ts.map +1 -1
  277. package/dist/test/render.js +18 -3
  278. package/dist/test/render.js.map +1 -1
  279. package/dist/test/testDashboard.d.ts +11 -2
  280. package/dist/test/testDashboard.d.ts.map +1 -1
  281. package/dist/test/testDashboard.js.map +1 -1
  282. package/dist/utils/panelUtils.js.map +1 -1
  283. package/dist/views/ViewDashboard/DashboardApp.d.ts +5 -3
  284. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  285. package/dist/views/ViewDashboard/DashboardApp.js +18 -3
  286. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  287. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  288. package/dist/views/ViewDashboard/ViewDashboard.js +3 -2
  289. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  290. package/package.json +6 -4
  291. package/dist/components/Panel/PanelLinks.d.ts +0 -6
  292. package/dist/components/Panel/PanelLinks.d.ts.map +0 -1
  293. package/dist/components/Panel/PanelLinks.js.map +0 -1
@@ -37,8 +37,8 @@ const _AlertCircle = /*#__PURE__*/ _interop_require_default(require("mdi-materia
37
37
  const _InformationOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/InformationOutline"));
38
38
  const _LightningBolt = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/LightningBolt"));
39
39
  const _constants = require("../../constants");
40
+ const _LinksDisplay = require("../LinksDisplay");
40
41
  const _HeaderIconButton = require("./HeaderIconButton");
41
- const _PanelLinks = require("./PanelLinks");
42
42
  function _interop_require_default(obj) {
43
43
  return obj && obj.__esModule ? obj : {
44
44
  default: obj
@@ -89,8 +89,9 @@ const PanelActions = ({ editHandlers, readHandlers, viewQueriesHandler, extra, t
89
89
  descriptionTooltipId,
90
90
  description
91
91
  ]);
92
- const linksAction = links && links.length > 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_PanelLinks.PanelLinks, {
93
- links: links
92
+ const linksAction = links && links.length > 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_LinksDisplay.LinksDisplay, {
93
+ links: links,
94
+ variant: "panel"
94
95
  });
95
96
  const extraActions = editHandlers === undefined && extra;
96
97
  const queryStateIndicator = (0, _react.useMemo)(()=>{
@@ -230,17 +231,22 @@ const PanelActions = ({ editHandlers, readHandlers, viewQueriesHandler, extra, t
230
231
  ]);
231
232
  const moveAction = (0, _react.useMemo)(()=>{
232
233
  if (editActions && !readHandlers?.isPanelViewed) {
233
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
234
- description: _constants.TOOLTIP_TEXT.movePanel,
235
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_HeaderIconButton.HeaderIconButton, {
236
- "aria-label": _constants.ARIA_LABEL_TEXT.movePanel(title),
237
- size: "small",
238
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DragVertical.default, {
239
- className: "drag-handle",
240
- sx: {
241
- cursor: 'grab'
242
- },
243
- fontSize: "inherit"
234
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
235
+ sx: {
236
+ background: (theme)=>theme.palette.background.default
237
+ },
238
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
239
+ description: _constants.TOOLTIP_TEXT.movePanel,
240
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_HeaderIconButton.HeaderIconButton, {
241
+ "aria-label": _constants.ARIA_LABEL_TEXT.movePanel(title),
242
+ size: "small",
243
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DragVertical.default, {
244
+ className: "drag-handle",
245
+ sx: {
246
+ cursor: 'grab'
247
+ },
248
+ fontSize: "inherit"
249
+ })
244
250
  })
245
251
  })
246
252
  });
@@ -393,22 +399,25 @@ const PanelActions = ({ editHandlers, readHandlers, viewQueriesHandler, extra, t
393
399
  ]
394
400
  });
395
401
  };
396
- const OverflowMenu = ({ children, title, icon, direction = 'row' })=>{
397
- const [anchorPosition, setAnchorPosition] = (0, _react.useState)();
402
+ const OverflowMenu = ({ children, title, icon, direction = 'row', placement = 'bottom', offsetX = -2, offsetY = -25 })=>{
403
+ const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
398
404
  // do not show overflow menu if there is no content (for example, edit actions are hidden)
399
405
  const hasContent = /*#__PURE__*/ (0, _react.isValidElement)(children) || Array.isArray(children) && children.some(_react.isValidElement);
400
406
  if (!hasContent) {
401
407
  return null;
402
408
  }
403
409
  const handleClick = (event)=>{
404
- setAnchorPosition(event.currentTarget.getBoundingClientRect());
410
+ setAnchorEl(anchorEl ? null : event.currentTarget);
405
411
  };
406
412
  const handleClose = ()=>{
407
- setAnchorPosition(undefined);
413
+ setAnchorEl(null);
408
414
  };
409
- const open = Boolean(anchorPosition);
415
+ const open = Boolean(anchorEl);
410
416
  const id = open ? 'actions-menu' : undefined;
411
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
417
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
418
+ sx: {
419
+ background: (theme)=>theme.palette.background.default
420
+ },
412
421
  children: [
413
422
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_HeaderIconButton.HeaderIconButton, {
414
423
  className: "show-actions",
@@ -420,24 +429,38 @@ const OverflowMenu = ({ children, title, icon, direction = 'row' })=>{
420
429
  fontSize: "inherit"
421
430
  })
422
431
  }),
423
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Popover, {
432
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Popper, {
424
433
  id: id,
425
434
  open: open,
426
- anchorReference: "anchorPosition",
427
- anchorPosition: anchorPosition,
428
- onClose: handleClose,
429
- anchorOrigin: {
430
- vertical: 'bottom',
431
- horizontal: 'left'
435
+ anchorEl: anchorEl,
436
+ placement: placement,
437
+ modifiers: [
438
+ {
439
+ name: 'offset',
440
+ options: {
441
+ offset: [
442
+ offsetX,
443
+ offsetY
444
+ ]
445
+ }
446
+ }
447
+ ],
448
+ sx: {
449
+ backgroundColor: (theme)=>theme.palette.background.paper,
450
+ borderRadius: 1,
451
+ boxShadow: (theme)=>theme.shadows[4]
432
452
  },
433
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
434
- direction: direction,
435
- alignItems: "center",
436
- sx: {
437
- padding: 1
438
- },
439
- onClick: handleClose,
440
- children: children
453
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ClickAwayListener, {
454
+ onClickAway: handleClose,
455
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
456
+ direction: direction,
457
+ alignItems: "center",
458
+ sx: {
459
+ padding: 1
460
+ },
461
+ onClick: handleClose,
462
+ children: children
463
+ })
441
464
  })
442
465
  })
443
466
  ]
@@ -40,6 +40,21 @@ function PanelQueriesSharedControls({ plugin, control, panelDefinition, onQuerie
40
40
  spec: query.spec.plugin.spec
41
41
  };
42
42
  }) ?? []);
43
+ const handleOnQueriesChange = (0, _react.useCallback)((queries)=>{
44
+ onQueriesChange(queries);
45
+ // If the number of queries has changed, force preview definition update to remove results of deleted queries.
46
+ if (queries.length !== previewDefinition.length) {
47
+ setPreviewDefinition(queries.map((query)=>{
48
+ return {
49
+ kind: query.spec.plugin.kind,
50
+ spec: query.spec.plugin.spec
51
+ };
52
+ }));
53
+ }
54
+ }, [
55
+ onQueriesChange,
56
+ previewDefinition.length
57
+ ]);
43
58
  const handleRunQuery = (0, _react.useCallback)((index, newDef)=>{
44
59
  setPreviewDefinition((prev)=>{
45
60
  const newDefinitions = [
@@ -85,7 +100,7 @@ function PanelQueriesSharedControls({ plugin, control, panelDefinition, onQuerie
85
100
  control: control,
86
101
  panelDefinition: panelDefinition,
87
102
  onJSONChange: onJSONChange,
88
- onQueriesChange: onQueriesChange,
103
+ onQueriesChange: handleOnQueriesChange,
89
104
  onQueryRun: handleRunQuery,
90
105
  onPluginSpecChange: onPluginSpecChange
91
106
  })
@@ -24,7 +24,7 @@ const _jsxruntime = require("react/jsx-runtime");
24
24
  const _react = require("react");
25
25
  const _material = require("@mui/material");
26
26
  const _pluginsystem = require("@perses-dev/plugin-system");
27
- const _core = require("@perses-dev/core");
27
+ const _spec = require("@perses-dev/spec");
28
28
  const _components = require("@perses-dev/components");
29
29
  const _context = require("../../context");
30
30
  const SAVE_DEFAULTS_DIALOG_TEXT = 'You have made changes to the time range or the variables values. Would you like to save these as defaults?';
@@ -40,7 +40,7 @@ const SaveChangesConfirmationDialog = ()=>{
40
40
  const { modifiedVariableNames } = getSavedVariablesStatus();
41
41
  const isOpen = dialog !== undefined;
42
42
  const { timeRange, refreshInterval } = (0, _pluginsystem.useTimeRange)();
43
- const currentTimeRangeText = (0, _core.isRelativeTimeRange)(timeRange) ? `(Last ${timeRange.pastDuration})` : '(Absolute time ranges can not be saved)';
43
+ const currentTimeRangeText = (0, _spec.isRelativeTimeRange)(timeRange) ? `(Last ${timeRange.pastDuration})` : '(Absolute time ranges can not be saved)';
44
44
  const saveTimeRangeMessage = `Save current time range as new default ${currentTimeRangeText}`;
45
45
  const saveVariableMessage = `Save current variable values as new default (${modifiedVariableNames.length > 0 ? modifiedVariableNames.join(', ') : 'No modified variables'})`;
46
46
  const refreshIntervalDisplay = _pluginsystem.DEFAULT_REFRESH_INTERVAL_OPTIONS.some((i)=>i.display === refreshInterval) ? refreshInterval : _pluginsystem.DEFAULT_REFRESH_INTERVAL_OPTIONS.find((i)=>i.value.pastDuration === refreshInterval)?.display;
@@ -63,8 +63,8 @@ const SaveChangesConfirmationDialog = ()=>{
63
63
  children: [
64
64
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
65
65
  control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
66
- disabled: !isSavedDurationModified || !(0, _core.isRelativeTimeRange)(timeRange),
67
- checked: saveDefaultTimeRange && isSavedDurationModified && (0, _core.isRelativeTimeRange)(timeRange),
66
+ disabled: !isSavedDurationModified || !(0, _spec.isRelativeTimeRange)(timeRange),
67
+ checked: saveDefaultTimeRange && isSavedDurationModified && (0, _spec.isRelativeTimeRange)(timeRange),
68
68
  onChange: (e)=>setSaveDefaultTimeRange(e.target.checked)
69
69
  }),
70
70
  label: saveTimeRangeMessage
@@ -21,72 +21,14 @@ Object.defineProperty(exports, "SaveDashboardButton", {
21
21
  }
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
- const _react = require("react");
25
24
  const _material = require("@mui/material");
26
- const _core = require("@perses-dev/core");
27
- const _pluginsystem = require("@perses-dev/plugin-system");
28
25
  const _context = require("../../context");
29
26
  const SaveDashboardButton = ({ onSave, isDisabled, variant = 'contained' })=>{
30
- const [isSavingDashboard, setSavingDashboard] = (0, _react.useState)(false);
31
- const { dashboard, setDashboard } = (0, _context.useDashboard)();
32
- const { getSavedVariablesStatus, setVariableDefaultValues } = (0, _context.useVariableDefinitionActions)();
33
- const { isSavedVariableModified } = getSavedVariablesStatus();
34
- const { timeRange, refreshInterval } = (0, _pluginsystem.useTimeRange)();
35
- const { setEditMode } = (0, _context.useEditMode)();
36
- const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = (0, _context.useSaveChangesConfirmationDialog)();
37
- const onSaveButtonClick = ()=>{
38
- const isSavedDurationModified = (0, _core.isRelativeTimeRange)(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;
39
- const isSavedRefreshIntervalModified = dashboard.spec.refreshInterval !== refreshInterval;
40
- // Save dashboard
41
- // - if active timeRange from plugin-system is relative and different from currently saved
42
- // - or if the saved variables are different from currently saved
43
- if (isSavedDurationModified || isSavedVariableModified || isSavedRefreshIntervalModified) {
44
- openSaveChangesConfirmationDialog({
45
- onSaveChanges: (saveDefaultTimeRange, saveDefaultRefreshInterval, saveDefaultVariables)=>{
46
- if ((0, _core.isRelativeTimeRange)(timeRange) && saveDefaultTimeRange) {
47
- dashboard.spec.duration = timeRange.pastDuration;
48
- }
49
- if (saveDefaultVariables) {
50
- const variables = setVariableDefaultValues();
51
- dashboard.spec.variables = variables;
52
- }
53
- if (saveDefaultRefreshInterval && isSavedRefreshIntervalModified) {
54
- dashboard.spec.refreshInterval = refreshInterval;
55
- }
56
- setDashboard(dashboard);
57
- saveDashboard();
58
- },
59
- onCancel: ()=>{
60
- closeSaveChangesConfirmationDialog();
61
- },
62
- isSavedDurationModified,
63
- isSavedVariableModified,
64
- isSavedRefreshIntervalModified
65
- });
66
- } else {
67
- saveDashboard();
68
- }
69
- };
70
- const saveDashboard = async ()=>{
71
- if (onSave) {
72
- try {
73
- setSavingDashboard(true);
74
- await onSave(dashboard);
75
- closeSaveChangesConfirmationDialog();
76
- setEditMode(false);
77
- } catch (error) {
78
- throw new Error(`An error occurred while saving the dashboard. ${error}`);
79
- } finally{
80
- setSavingDashboard(false);
81
- }
82
- } else {
83
- setEditMode(false);
84
- }
85
- };
27
+ const { saveDashboard, isSaving } = (0, _context.useSaveDashboard)(onSave);
86
28
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
87
29
  variant: variant,
88
- onClick: onSaveButtonClick,
89
- disabled: isDisabled || isSavingDashboard,
30
+ onClick: saveDashboard,
31
+ disabled: isDisabled || isSaving,
90
32
  children: "Save"
91
33
  });
92
34
  };
@@ -34,7 +34,7 @@ _export(exports, {
34
34
  const _jsxruntime = require("react/jsx-runtime");
35
35
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
36
36
  const _material = require("@mui/material");
37
- const _core = require("@perses-dev/core");
37
+ const _spec = require("@perses-dev/spec");
38
38
  function _getRequireWildcardCache(nodeInterop) {
39
39
  if (typeof WeakMap !== "function") return null;
40
40
  var cacheBabelInterop = new WeakMap();
@@ -107,13 +107,13 @@ function useListVariableListBoxContext() {
107
107
  if (isIndeterminate) {
108
108
  if (allowAllValue) {
109
109
  if (filteredOptions.length === options.length) {
110
- if (selectedOptions[0]?.value === _core.DEFAULT_ALL_VALUE) {
111
- onChange(options.filter((o)=>o.value !== _core.DEFAULT_ALL_VALUE));
110
+ if (selectedOptions[0]?.value === _spec.DEFAULT_ALL_VALUE) {
111
+ onChange(options.filter((o)=>o.value !== _spec.DEFAULT_ALL_VALUE));
112
112
  } else {
113
113
  onChange([
114
114
  {
115
- label: _core.DEFAULT_ALL_VALUE,
116
- value: _core.DEFAULT_ALL_VALUE
115
+ label: _spec.DEFAULT_ALL_VALUE,
116
+ value: _spec.DEFAULT_ALL_VALUE
117
117
  }
118
118
  ]);
119
119
  }
@@ -123,7 +123,7 @@ function useListVariableListBoxContext() {
123
123
  } else {
124
124
  onChange([
125
125
  ...selectedOptions,
126
- ...filteredOptions.filter((o)=>o.value !== _core.DEFAULT_ALL_VALUE)
126
+ ...filteredOptions.filter((o)=>o.value !== _spec.DEFAULT_ALL_VALUE)
127
127
  ]);
128
128
  }
129
129
  }
@@ -31,7 +31,7 @@ _export(exports, {
31
31
  const _jsxruntime = require("react/jsx-runtime");
32
32
  const _react = require("react");
33
33
  const _material = require("@mui/material");
34
- const _core = require("@perses-dev/core");
34
+ const _spec = require("@perses-dev/spec");
35
35
  const _pluginsystem = require("@perses-dev/plugin-system");
36
36
  const _context = require("../../context");
37
37
  const _constants = require("../../constants");
@@ -104,7 +104,7 @@ function useListVariableState(spec, state, variablesOptionsQuery) {
104
104
  if (allowAllValue) {
105
105
  computedOptions = [
106
106
  {
107
- value: _core.DEFAULT_ALL_VALUE,
107
+ value: _spec.DEFAULT_ALL_VALUE,
108
108
  label: 'All'
109
109
  },
110
110
  ...computedOptions
@@ -292,7 +292,7 @@ function ListVariable({ name, source }) {
292
292
  value: selectedOptions,
293
293
  onChange: (_, value)=>{
294
294
  if ((value === null || Array.isArray(value) && value.length === 0) && allowAllValue) {
295
- setVariableValue(name, _core.DEFAULT_ALL_VALUE, source);
295
+ setVariableValue(name, _spec.DEFAULT_ALL_VALUE, source);
296
296
  } else {
297
297
  setVariableValue(name, variableOptionToVariableValue(value), source);
298
298
  }
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", {
17
17
  _export_star(require("./AddGroupButton"), exports);
18
18
  _export_star(require("./AddPanelButton"), exports);
19
19
  _export_star(require("./Dashboard"), exports);
20
+ _export_star(require("./DashboardLinks"), exports);
21
+ _export_star(require("./DashboardShortcuts"), exports);
20
22
  _export_star(require("./DashboardToolbar"), exports);
21
23
  _export_star(require("./DashboardStickyToolbar"), exports);
22
24
  _export_star(require("./Datasources"), exports);
@@ -34,6 +34,7 @@ const TOOLTIP_TEXT = {
34
34
  addGroup: 'Add panel group',
35
35
  editDatasources: 'Edit datasources',
36
36
  editJson: 'Edit JSON',
37
+ editLinks: 'Edit links',
37
38
  editVariables: 'Edit variables',
38
39
  viewJson: 'View JSON',
39
40
  // Group buttons
@@ -52,6 +52,7 @@ const _duplicatepanelslice = require("./duplicate-panel-slice");
52
52
  const _editjsondialogslice = require("./edit-json-dialog-slice");
53
53
  const _common = require("./common");
54
54
  const _viewpanelslice = require("./view-panel-slice");
55
+ const _linksslice = require("./links-slice");
55
56
  const DashboardContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
56
57
  function useDashboardStore(selector) {
57
58
  const store = (0, _react.useContext)(DashboardContext);
@@ -92,6 +93,7 @@ function DashboardProvider(props) {
92
93
  function initStore(props) {
93
94
  const { initialState: { dashboardResource, isEditMode, viewPanelRef, setViewPanelRef } } = props;
94
95
  const { kind, metadata, spec: { display, duration, refreshInterval = _core.DEFAULT_REFRESH_INTERVAL, datasources, layouts = [], panels = {} } } = dashboardResource;
96
+ const links = dashboardResource.spec.links ?? [];
95
97
  const ttl = 'ttl' in dashboardResource.spec ? dashboardResource.spec.ttl : undefined;
96
98
  const store = (0, _zustand.createStore)()((0, _immer.immer)((0, _middleware.devtools)((...args)=>{
97
99
  const [set] = args;
@@ -104,6 +106,7 @@ function initStore(props) {
104
106
  ...(0, _deletepanelslice.createDeletePanelSlice)()(...args),
105
107
  ...(0, _duplicatepanelslice.createDuplicatePanelSlice)()(...args),
106
108
  ...(0, _viewpanelslice.createViewPanelSlice)(viewPanelRef, setViewPanelRef)(...args),
109
+ /* Links */ ...(0, _linksslice.createLinksSlice)(links)(...args),
107
110
  /* General */ ...(0, _discardchangesdialogslice.createDiscardChangesDialogSlice)(...args),
108
111
  ...(0, _editjsondialogslice.createEditJsonDialogSlice)(...args),
109
112
  ...(0, _savechangesdialogslice.createSaveChangesDialogSlice)(...args),
@@ -120,7 +123,7 @@ function initStore(props) {
120
123
  isEditMode
121
124
  });
122
125
  },
123
- setDashboard: ({ kind, metadata, spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {} } })=>{
126
+ setDashboard: ({ kind, metadata, spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {}, links = [] } })=>{
124
127
  set((state)=>{
125
128
  state.kind = kind;
126
129
  state.metadata = metadata;
@@ -132,6 +135,7 @@ function initStore(props) {
132
135
  state.duration = duration;
133
136
  state.refreshInterval = refreshInterval ?? _core.DEFAULT_REFRESH_INTERVAL;
134
137
  state.datasources = datasources;
138
+ state.links = links;
135
139
  // TODO: add ttl here to e.g allow edition from JSON view, but probably requires quite some refactoring
136
140
  });
137
141
  }
@@ -27,6 +27,12 @@ _export(exports, {
27
27
  get useDashboardDuration () {
28
28
  return useDashboardDuration;
29
29
  },
30
+ get useDashboardLinks () {
31
+ return useDashboardLinks;
32
+ },
33
+ get useDashboardLinksActions () {
34
+ return useDashboardLinksActions;
35
+ },
30
36
  get useDeletePanelDialog () {
31
37
  return useDeletePanelDialog;
32
38
  },
@@ -101,6 +107,16 @@ function useDashboardActions() {
101
107
  openAddPanel: ()=>openAddPanel()
102
108
  };
103
109
  }
110
+ const selectDashboardLinks = (state)=>state.links;
111
+ function useDashboardLinks() {
112
+ return (0, _DashboardProvider.useDashboardStore)(selectDashboardLinks) ?? [];
113
+ }
114
+ const selectDashboardLinksActions = (state)=>({
115
+ setLinks: state.setLinks
116
+ });
117
+ function useDashboardLinksActions() {
118
+ return (0, _DashboardProvider.useDashboardStore)(selectDashboardLinksActions);
119
+ }
104
120
  const selectPanelGroupOrder = (state)=>state.panelGroupOrder;
105
121
  function usePanelGroupIds() {
106
122
  return (0, _DashboardProvider.useDashboardStore)(selectPanelGroupOrder);
@@ -14,9 +14,16 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ Object.defineProperty(exports, "useSaveDashboard", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return _usesavedashboard.useSaveDashboard;
21
+ }
22
+ });
17
23
  _export_star(require("./common"), exports);
18
24
  _export_star(require("./dashboard-provider-api"), exports);
19
25
  _export_star(require("./DashboardProvider"), exports);
26
+ const _usesavedashboard = require("./use-save-dashboard");
20
27
  function _export_star(from, to) {
21
28
  Object.keys(from).forEach(function(k) {
22
29
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -0,0 +1,32 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "createLinksSlice", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return createLinksSlice;
21
+ }
22
+ });
23
+ function createLinksSlice(initLinks) {
24
+ return (set)=>({
25
+ links: initLinks,
26
+ setLinks: (links)=>{
27
+ set((state)=>{
28
+ state.links = links;
29
+ });
30
+ }
31
+ });
32
+ }
@@ -34,7 +34,7 @@ _export(exports, {
34
34
  return createPanelGroupSlice;
35
35
  }
36
36
  });
37
- const _core = require("@perses-dev/core");
37
+ const _spec = require("@perses-dev/spec");
38
38
  const _common = require("./common");
39
39
  function createPanelGroupSlice(layouts) {
40
40
  const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
@@ -87,7 +87,7 @@ function convertLayoutsToPanelGroups(layouts) {
87
87
  x: item.x,
88
88
  y: item.y
89
89
  });
90
- itemPanelKeys[panelGroupLayoutId] = (0, _core.getPanelKeyFromRef)(item.content);
90
+ itemPanelKeys[panelGroupLayoutId] = (0, _spec.getPanelKeyFromRef)(item.content);
91
91
  }
92
92
  // Create the panel group and keep track of the ID order
93
93
  const panelGroupId = (0, _common.generateId)();
@@ -0,0 +1,104 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "useSaveDashboard", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return useSaveDashboard;
21
+ }
22
+ });
23
+ const _react = require("react");
24
+ const _spec = require("@perses-dev/spec");
25
+ const _pluginsystem = require("@perses-dev/plugin-system");
26
+ const _VariableProvider = require("../VariableProvider/VariableProvider");
27
+ const _useDashboard = require("../useDashboard");
28
+ const _dashboardproviderapi = require("./dashboard-provider-api");
29
+ function useSaveDashboard(onSave) {
30
+ const [isSaving, setSaving] = (0, _react.useState)(false);
31
+ const { dashboard, setDashboard } = (0, _useDashboard.useDashboard)();
32
+ const { setEditMode } = (0, _dashboardproviderapi.useEditMode)();
33
+ const { timeRange, refreshInterval } = (0, _pluginsystem.useTimeRange)();
34
+ const { getSavedVariablesStatus, setVariableDefaultValues } = (0, _VariableProvider.useVariableDefinitionActions)();
35
+ const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = (0, _dashboardproviderapi.useSaveChangesConfirmationDialog)();
36
+ const performSave = (0, _react.useCallback)(async ()=>{
37
+ if (!onSave) {
38
+ setEditMode(false);
39
+ return;
40
+ }
41
+ try {
42
+ setSaving(true);
43
+ await onSave(dashboard);
44
+ closeSaveChangesConfirmationDialog();
45
+ setEditMode(false);
46
+ } finally{
47
+ setSaving(false);
48
+ }
49
+ }, [
50
+ closeSaveChangesConfirmationDialog,
51
+ dashboard,
52
+ onSave,
53
+ setEditMode
54
+ ]);
55
+ const saveDashboard = (0, _react.useCallback)(()=>{
56
+ if (isSaving) {
57
+ return;
58
+ }
59
+ const { isSavedVariableModified } = getSavedVariablesStatus();
60
+ const isSavedDurationModified = (0, _spec.isRelativeTimeRange)(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;
61
+ const isSavedRefreshIntervalModified = dashboard.spec.refreshInterval !== refreshInterval;
62
+ if (isSavedDurationModified || isSavedVariableModified || isSavedRefreshIntervalModified) {
63
+ openSaveChangesConfirmationDialog({
64
+ onSaveChanges: (saveDefaultTimeRange, saveDefaultRefreshInterval, saveDefaultVariables)=>{
65
+ if ((0, _spec.isRelativeTimeRange)(timeRange) && saveDefaultTimeRange) {
66
+ dashboard.spec.duration = timeRange.pastDuration;
67
+ }
68
+ if (saveDefaultVariables) {
69
+ const variables = setVariableDefaultValues();
70
+ dashboard.spec.variables = variables;
71
+ }
72
+ if (saveDefaultRefreshInterval && isSavedRefreshIntervalModified) {
73
+ dashboard.spec.refreshInterval = refreshInterval;
74
+ }
75
+ setDashboard(dashboard);
76
+ performSave();
77
+ },
78
+ onCancel: ()=>{
79
+ closeSaveChangesConfirmationDialog();
80
+ },
81
+ isSavedDurationModified,
82
+ isSavedVariableModified,
83
+ isSavedRefreshIntervalModified
84
+ });
85
+ } else {
86
+ performSave();
87
+ }
88
+ }, [
89
+ isSaving,
90
+ getSavedVariablesStatus,
91
+ timeRange,
92
+ dashboard,
93
+ refreshInterval,
94
+ openSaveChangesConfirmationDialog,
95
+ setVariableDefaultValues,
96
+ setDashboard,
97
+ performSave,
98
+ closeSaveChangesConfirmationDialog
99
+ ]);
100
+ return {
101
+ saveDashboard,
102
+ isSaving
103
+ };
104
+ }
@@ -47,7 +47,7 @@ function DatasourceStoreProvider(props) {
47
47
  }
48
48
  if (project) {
49
49
  // Try to find it at the project level as a Datasource resource
50
- const datasource = await datasourceApi.getDatasource(project, selector);
50
+ const datasource = await datasourceApi.getDatasource(String(project), selector);
51
51
  if (datasource !== undefined) {
52
52
  return {
53
53
  spec: datasource.spec,
@@ -102,7 +102,7 @@ function DatasourceStoreProvider(props) {
102
102
  listPluginMetadata([
103
103
  'Datasource'
104
104
  ]),
105
- project ? datasourceApi.listDatasources(project, datasourcePluginName) : [],
105
+ project ? datasourceApi.listDatasources(String(project), datasourcePluginName) : [],
106
106
  datasourceApi.listGlobalDatasources(datasourcePluginName)
107
107
  ]);
108
108
  // Find the metadata for the plugin type they asked for, so we can use it for the name of the default datasource
@@ -160,13 +160,7 @@ function DatasourceStoreProvider(props) {
160
160
  ]);
161
161
  const setLocalDatasources = (0, _react.useCallback)((datasources)=>{
162
162
  if (dashboardResource) {
163
- setDashboardResource(dashboardResource.kind === 'Dashboard' ? {
164
- ...dashboardResource,
165
- spec: {
166
- ...dashboardResource.spec,
167
- datasources: datasources
168
- }
169
- } : {
163
+ setDashboardResource({
170
164
  ...dashboardResource,
171
165
  spec: {
172
166
  ...dashboardResource.spec,