@perses-dev/dashboards 0.53.1 → 0.54.0-beta.1

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 (319) 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 +21 -8
  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 +38 -23
  12. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +2 -2
  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/defaults.js +32 -0
  19. package/dist/cjs/constants/index.js +1 -0
  20. package/dist/cjs/constants/user-interface-text.js +1 -0
  21. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +8 -4
  22. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +16 -0
  23. package/dist/cjs/context/DashboardProvider/index.js +7 -0
  24. package/dist/cjs/context/DashboardProvider/links-slice.js +32 -0
  25. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +2 -2
  26. package/dist/cjs/context/DashboardProvider/use-save-dashboard.js +104 -0
  27. package/dist/cjs/context/DatasourceStoreProvider.js +3 -9
  28. package/dist/cjs/context/VariableProvider/VariableProvider.js +7 -6
  29. package/dist/cjs/context/VariableProvider/hydrationUtils.js +3 -3
  30. package/dist/cjs/context/useDashboard.js +7 -4
  31. package/dist/cjs/index.js +3 -0
  32. package/dist/cjs/keyboard-shortcuts/PanelFocusProvider.js +157 -0
  33. package/dist/cjs/keyboard-shortcuts/default-shortcuts/dashboard.js +75 -0
  34. package/dist/cjs/keyboard-shortcuts/default-shortcuts/global.js +121 -0
  35. package/dist/cjs/keyboard-shortcuts/default-shortcuts/index.js +33 -0
  36. package/dist/cjs/keyboard-shortcuts/default-shortcuts/panel.js +90 -0
  37. package/dist/cjs/keyboard-shortcuts/default-shortcuts/time-range.js +142 -0
  38. package/dist/cjs/keyboard-shortcuts/events.js +93 -0
  39. package/dist/cjs/keyboard-shortcuts/index.js +92 -0
  40. package/dist/cjs/keyboard-shortcuts/types.js +42 -0
  41. package/dist/cjs/keyboard-shortcuts/utils.js +87 -0
  42. package/dist/cjs/model/DashboardResource.js +16 -0
  43. package/dist/cjs/model/PanelGroupDefinition.js +25 -0
  44. package/dist/cjs/model/VariableDefinition.js +16 -0
  45. package/dist/cjs/model/index.js +31 -0
  46. package/dist/cjs/test/render.js +18 -3
  47. package/dist/cjs/views/ViewDashboard/DashboardApp.js +17 -2
  48. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -4
  49. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  50. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  51. package/dist/components/DashboardLinks/DashboardLinksEditor.d.ts +9 -0
  52. package/dist/components/DashboardLinks/DashboardLinksEditor.d.ts.map +1 -0
  53. package/dist/components/DashboardLinks/DashboardLinksEditor.js +353 -0
  54. package/dist/components/DashboardLinks/DashboardLinksEditor.js.map +1 -0
  55. package/dist/components/DashboardLinks/EditDashboardLinksButton.d.ts +18 -0
  56. package/dist/components/DashboardLinks/EditDashboardLinksButton.d.ts.map +1 -0
  57. package/dist/components/DashboardLinks/EditDashboardLinksButton.js +68 -0
  58. package/dist/components/DashboardLinks/EditDashboardLinksButton.js.map +1 -0
  59. package/dist/components/DashboardLinks/index.d.ts +3 -0
  60. package/dist/components/DashboardLinks/index.d.ts.map +1 -0
  61. package/dist/components/DashboardLinks/index.js +16 -0
  62. package/dist/components/DashboardLinks/index.js.map +1 -0
  63. package/dist/components/DashboardShortcuts/index.d.ts +3 -0
  64. package/dist/components/DashboardShortcuts/index.d.ts.map +1 -0
  65. package/dist/components/DashboardShortcuts/index.js +15 -0
  66. package/dist/components/DashboardShortcuts/index.js.map +1 -0
  67. package/dist/components/DashboardShortcuts/useDashboardShortcuts.d.ts +12 -0
  68. package/dist/components/DashboardShortcuts/useDashboardShortcuts.d.ts.map +1 -0
  69. package/dist/components/DashboardShortcuts/useDashboardShortcuts.js +365 -0
  70. package/dist/components/DashboardShortcuts/useDashboardShortcuts.js.map +1 -0
  71. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -0
  72. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  73. package/dist/components/DashboardToolbar/DashboardToolbar.js +17 -2
  74. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  75. package/dist/components/Datasources/DatasourceEditor.d.ts +1 -1
  76. package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
  77. package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
  78. package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -1
  79. package/dist/components/Datasources/EditDatasourcesButton.js +1 -7
  80. package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
  81. package/dist/components/DownloadButton/serializeDashboard.d.ts +2 -2
  82. package/dist/components/DownloadButton/serializeDashboard.d.ts.map +1 -1
  83. package/dist/components/DownloadButton/serializeDashboard.js.map +1 -1
  84. package/dist/components/GridLayout/GridItemContent.d.ts +1 -1
  85. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  86. package/dist/components/GridLayout/GridItemContent.js +21 -8
  87. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  88. package/dist/components/GridLayout/GridLayout.d.ts +1 -1
  89. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  90. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  91. package/dist/components/GridLayout/GridTitle.d.ts +1 -1
  92. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  93. package/dist/components/GridLayout/Row.d.ts +2 -1
  94. package/dist/components/GridLayout/Row.d.ts.map +1 -1
  95. package/dist/components/GridLayout/Row.js.map +1 -1
  96. package/dist/components/LeaveDialog/LeaveDialog.d.ts +3 -3
  97. package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -1
  98. package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -1
  99. package/dist/components/LinksDisplay/LinksDisplay.d.ts +10 -0
  100. package/dist/components/LinksDisplay/LinksDisplay.d.ts.map +1 -0
  101. package/dist/components/{Panel/PanelLinks.js → LinksDisplay/LinksDisplay.js} +59 -10
  102. package/dist/components/LinksDisplay/LinksDisplay.js.map +1 -0
  103. package/dist/components/LinksDisplay/index.d.ts +2 -0
  104. package/dist/components/LinksDisplay/index.d.ts.map +1 -0
  105. package/dist/components/LinksDisplay/index.js +15 -0
  106. package/dist/components/LinksDisplay/index.js.map +1 -0
  107. package/dist/components/Panel/Panel.d.ts +2 -1
  108. package/dist/components/Panel/Panel.d.ts.map +1 -1
  109. package/dist/components/Panel/Panel.js.map +1 -1
  110. package/dist/components/Panel/PanelActions.d.ts +1 -1
  111. package/dist/components/Panel/PanelActions.d.ts.map +1 -1
  112. package/dist/components/Panel/PanelActions.js +39 -24
  113. package/dist/components/Panel/PanelActions.js.map +1 -1
  114. package/dist/components/Panel/PanelContent.d.ts +1 -1
  115. package/dist/components/Panel/PanelContent.js.map +1 -1
  116. package/dist/components/Panel/PanelHeader.d.ts +1 -1
  117. package/dist/components/Panel/PanelHeader.js.map +1 -1
  118. package/dist/components/Panel/PanelPluginLoader.d.ts +1 -1
  119. package/dist/components/Panel/PanelPluginLoader.js.map +1 -1
  120. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  121. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +2 -1
  122. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  123. package/dist/components/PanelDrawer/PanelEditorForm.js +2 -2
  124. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  125. package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -1
  126. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  127. package/dist/components/PanelDrawer/PanelQueriesSharedControls.d.ts +1 -1
  128. package/dist/components/PanelDrawer/PanelQueriesSharedControls.js.map +1 -1
  129. package/dist/components/PanelDrawer/usePanelEditor.d.ts +1 -1
  130. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
  131. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  132. package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts +1 -1
  133. package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -1
  134. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +1 -1
  135. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  136. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  137. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +4 -62
  138. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  139. package/dist/components/Variables/BuiltinVariableAccordions.d.ts +1 -1
  140. package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -1
  141. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  142. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  143. package/dist/components/Variables/ListVariableListBox.js +1 -1
  144. package/dist/components/Variables/ListVariableListBox.js.map +1 -1
  145. package/dist/components/Variables/Variable.d.ts +1 -1
  146. package/dist/components/Variables/Variable.js +1 -1
  147. package/dist/components/Variables/Variable.js.map +1 -1
  148. package/dist/components/Variables/VariableEditor.d.ts +2 -1
  149. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  150. package/dist/components/Variables/VariableEditor.js.map +1 -1
  151. package/dist/components/Variables/VariableList.d.ts +1 -1
  152. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  153. package/dist/components/Variables/VariableList.js.map +1 -1
  154. package/dist/components/index.d.ts +2 -0
  155. package/dist/components/index.d.ts.map +1 -1
  156. package/dist/components/index.js +2 -0
  157. package/dist/components/index.js.map +1 -1
  158. package/dist/constants/defaults.d.ts +4 -0
  159. package/dist/constants/defaults.d.ts.map +1 -0
  160. package/dist/constants/defaults.js +16 -0
  161. package/dist/constants/defaults.js.map +1 -0
  162. package/dist/constants/index.d.ts +1 -0
  163. package/dist/constants/index.d.ts.map +1 -1
  164. package/dist/constants/index.js +1 -0
  165. package/dist/constants/index.js.map +1 -1
  166. package/dist/constants/user-interface-text.d.ts +1 -0
  167. package/dist/constants/user-interface-text.d.ts.map +1 -1
  168. package/dist/constants/user-interface-text.js +1 -0
  169. package/dist/constants/user-interface-text.js.map +1 -1
  170. package/dist/context/DashboardProvider/DashboardProvider.d.ts +8 -6
  171. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  172. package/dist/context/DashboardProvider/DashboardProvider.js +6 -2
  173. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  174. package/dist/context/DashboardProvider/common.d.ts +3 -2
  175. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  176. package/dist/context/DashboardProvider/common.js.map +1 -1
  177. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +14 -2
  178. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  179. package/dist/context/DashboardProvider/dashboard-provider-api.js +14 -0
  180. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  181. package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +1 -1
  182. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  183. package/dist/context/DashboardProvider/delete-panel-slice.d.ts +1 -1
  184. package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -1
  185. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  186. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts +1 -1
  187. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts.map +1 -1
  188. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  189. package/dist/context/DashboardProvider/index.d.ts +2 -0
  190. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  191. package/dist/context/DashboardProvider/index.js +1 -0
  192. package/dist/context/DashboardProvider/index.js.map +1 -1
  193. package/dist/context/DashboardProvider/links-slice.d.ts +19 -0
  194. package/dist/context/DashboardProvider/links-slice.d.ts.map +1 -0
  195. package/dist/context/DashboardProvider/links-slice.js +27 -0
  196. package/dist/context/DashboardProvider/links-slice.js.map +1 -0
  197. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +3 -1
  198. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  199. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  200. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -1
  201. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  202. package/dist/context/DashboardProvider/panel-group-slice.d.ts +2 -1
  203. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  204. package/dist/context/DashboardProvider/panel-group-slice.js +1 -1
  205. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  206. package/dist/context/DashboardProvider/panel-slice.d.ts +1 -1
  207. package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
  208. package/dist/context/DashboardProvider/use-save-dashboard.d.ts +25 -0
  209. package/dist/context/DashboardProvider/use-save-dashboard.d.ts.map +1 -0
  210. package/dist/context/DashboardProvider/use-save-dashboard.js +105 -0
  211. package/dist/context/DashboardProvider/use-save-dashboard.js.map +1 -0
  212. package/dist/context/DashboardProvider/view-panel-slice.d.ts +1 -1
  213. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
  214. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
  215. package/dist/context/DatasourceStoreProvider.d.ts +4 -2
  216. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  217. package/dist/context/DatasourceStoreProvider.js +3 -9
  218. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  219. package/dist/context/VariableProvider/VariableProvider.d.ts +2 -1
  220. package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -1
  221. package/dist/context/VariableProvider/VariableProvider.js +2 -1
  222. package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
  223. package/dist/context/VariableProvider/hydrationUtils.d.ts +2 -1
  224. package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -1
  225. package/dist/context/VariableProvider/hydrationUtils.js +1 -1
  226. package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
  227. package/dist/context/VariableProvider/query-params.d.ts +1 -1
  228. package/dist/context/VariableProvider/query-params.js.map +1 -1
  229. package/dist/context/VariableProvider/utils.d.ts +2 -1
  230. package/dist/context/VariableProvider/utils.d.ts.map +1 -1
  231. package/dist/context/VariableProvider/utils.js.map +1 -1
  232. package/dist/context/useDashboard.d.ts +10 -3
  233. package/dist/context/useDashboard.d.ts.map +1 -1
  234. package/dist/context/useDashboard.js +6 -3
  235. package/dist/context/useDashboard.js.map +1 -1
  236. package/dist/index.d.ts +3 -0
  237. package/dist/index.d.ts.map +1 -1
  238. package/dist/index.js +3 -0
  239. package/dist/index.js.map +1 -1
  240. package/dist/keyboard-shortcuts/PanelFocusProvider.d.ts +12 -0
  241. package/dist/keyboard-shortcuts/PanelFocusProvider.d.ts.map +1 -0
  242. package/dist/keyboard-shortcuts/PanelFocusProvider.js +97 -0
  243. package/dist/keyboard-shortcuts/PanelFocusProvider.js.map +1 -0
  244. package/dist/keyboard-shortcuts/default-shortcuts/dashboard.d.ts +6 -0
  245. package/dist/keyboard-shortcuts/default-shortcuts/dashboard.d.ts.map +1 -0
  246. package/dist/keyboard-shortcuts/default-shortcuts/dashboard.js +53 -0
  247. package/dist/keyboard-shortcuts/default-shortcuts/dashboard.js.map +1 -0
  248. package/dist/keyboard-shortcuts/default-shortcuts/global.d.ts +9 -0
  249. package/dist/keyboard-shortcuts/default-shortcuts/global.d.ts.map +1 -0
  250. package/dist/keyboard-shortcuts/default-shortcuts/global.js +90 -0
  251. package/dist/keyboard-shortcuts/default-shortcuts/global.js.map +1 -0
  252. package/dist/keyboard-shortcuts/default-shortcuts/index.d.ts +5 -0
  253. package/dist/keyboard-shortcuts/default-shortcuts/index.d.ts.map +1 -0
  254. package/dist/keyboard-shortcuts/default-shortcuts/index.js +18 -0
  255. package/dist/keyboard-shortcuts/default-shortcuts/index.js.map +1 -0
  256. package/dist/keyboard-shortcuts/default-shortcuts/panel.d.ts +7 -0
  257. package/dist/keyboard-shortcuts/default-shortcuts/panel.d.ts.map +1 -0
  258. package/dist/keyboard-shortcuts/default-shortcuts/panel.js +65 -0
  259. package/dist/keyboard-shortcuts/default-shortcuts/panel.js.map +1 -0
  260. package/dist/keyboard-shortcuts/default-shortcuts/time-range.d.ts +10 -0
  261. package/dist/keyboard-shortcuts/default-shortcuts/time-range.d.ts.map +1 -0
  262. package/dist/keyboard-shortcuts/default-shortcuts/time-range.js +108 -0
  263. package/dist/keyboard-shortcuts/default-shortcuts/time-range.js.map +1 -0
  264. package/dist/keyboard-shortcuts/events.d.ts +18 -0
  265. package/dist/keyboard-shortcuts/events.d.ts.map +1 -0
  266. package/dist/keyboard-shortcuts/events.js +35 -0
  267. package/dist/keyboard-shortcuts/events.js.map +1 -0
  268. package/dist/keyboard-shortcuts/index.d.ts +9 -0
  269. package/dist/keyboard-shortcuts/index.d.ts.map +1 -0
  270. package/dist/keyboard-shortcuts/index.js +21 -0
  271. package/dist/keyboard-shortcuts/index.js.map +1 -0
  272. package/dist/keyboard-shortcuts/types.d.ts +37 -0
  273. package/dist/keyboard-shortcuts/types.d.ts.map +1 -0
  274. package/dist/keyboard-shortcuts/types.js +26 -0
  275. package/dist/keyboard-shortcuts/types.js.map +1 -0
  276. package/dist/keyboard-shortcuts/utils.d.ts +20 -0
  277. package/dist/keyboard-shortcuts/utils.d.ts.map +1 -0
  278. package/dist/keyboard-shortcuts/utils.js +64 -0
  279. package/dist/keyboard-shortcuts/utils.js.map +1 -0
  280. package/dist/model/DashboardResource.d.ts +15 -0
  281. package/dist/model/DashboardResource.d.ts.map +1 -0
  282. package/dist/model/DashboardResource.js +18 -0
  283. package/dist/model/DashboardResource.js.map +1 -0
  284. package/dist/model/PanelGroupDefinition.d.ts +59 -0
  285. package/dist/model/PanelGroupDefinition.d.ts.map +1 -0
  286. package/dist/model/PanelGroupDefinition.js +19 -0
  287. package/dist/model/PanelGroupDefinition.js.map +1 -0
  288. package/dist/model/VariableDefinition.d.ts +50 -0
  289. package/dist/model/VariableDefinition.d.ts.map +1 -0
  290. package/dist/model/VariableDefinition.js +20 -0
  291. package/dist/model/VariableDefinition.js.map +1 -0
  292. package/dist/model/index.d.ts +3 -0
  293. package/dist/model/index.d.ts.map +1 -0
  294. package/dist/model/index.js +16 -0
  295. package/dist/model/index.js.map +1 -0
  296. package/dist/test/dashboard-provider.d.ts +1 -1
  297. package/dist/test/dashboard-provider.d.ts.map +1 -1
  298. package/dist/test/dashboard-provider.js.map +1 -1
  299. package/dist/test/plugin-registry.js.map +1 -1
  300. package/dist/test/render.d.ts.map +1 -1
  301. package/dist/test/render.js +18 -3
  302. package/dist/test/render.js.map +1 -1
  303. package/dist/test/testDashboard.d.ts +11 -2
  304. package/dist/test/testDashboard.d.ts.map +1 -1
  305. package/dist/test/testDashboard.js.map +1 -1
  306. package/dist/utils/panelUtils.d.ts +1 -1
  307. package/dist/utils/panelUtils.d.ts.map +1 -1
  308. package/dist/utils/panelUtils.js.map +1 -1
  309. package/dist/views/ViewDashboard/DashboardApp.d.ts +5 -3
  310. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  311. package/dist/views/ViewDashboard/DashboardApp.js +18 -3
  312. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  313. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  314. package/dist/views/ViewDashboard/ViewDashboard.js +3 -2
  315. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  316. package/package.json +5 -3
  317. package/dist/components/Panel/PanelLinks.d.ts +0 -6
  318. package/dist/components/Panel/PanelLinks.d.ts.map +0 -1
  319. package/dist/components/Panel/PanelLinks.js.map +0 -1
@@ -0,0 +1,20 @@
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
+ /**
14
+ * External variable definition that can be provided from an external source.
15
+ * Multiple external variable definitions can be provided to a dashboard, and
16
+ * the order of the sources is important as first one will take precedence on
17
+ * the following ones, in case they have same names.
18
+ */ export { };
19
+
20
+ //# sourceMappingURL=VariableDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/VariableDefinition.ts"],"sourcesContent":["// Copyright 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 { Definition, UnknownSpec, VariableSpec } from '@perses-dev/spec';\n\nexport type VariableValue = string | string[] | null;\n\nexport interface TextVariableSpec extends VariableSpec {\n value: string;\n constant?: boolean;\n}\n\nexport interface ListVariableSpec<PluginSpec = UnknownSpec> extends VariableSpec {\n defaultValue?: VariableValue;\n allowMultiple: boolean;\n allowAllValue: boolean;\n customAllValue?: string;\n capturingRegexp?: string;\n sort?: string;\n plugin: Definition<PluginSpec>;\n}\n\nexport interface ListVariableDefinition extends Definition<ListVariableSpec> {\n kind: 'ListVariable';\n}\n\nexport interface TextVariableDefinition extends Definition<TextVariableSpec> {\n kind: 'TextVariable';\n}\n\nexport type VariableDefinition = TextVariableDefinition | ListVariableDefinition;\n\n/**\n * External variable definition that can be provided from an external source.\n * Multiple external variable definitions can be provided to a dashboard, and\n * the order of the sources is important as first one will take precedence on\n * the following ones, in case they have same names.\n */\nexport interface ExternalVariableDefinition {\n /**\n * Source identifier for this set of external variables\n */\n source: string;\n /**\n * Optional tooltip information for the external variables\n */\n tooltip?: {\n title?: string;\n description?: string;\n };\n /**\n * Optional link to edit these external variables\n */\n editLink?: string;\n /**\n * The variable definitions from this external source\n */\n definitions: VariableDefinition[];\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA+BjC;;;;;CAKC,GACD,WAoBC"}
@@ -0,0 +1,3 @@
1
+ export * from './DashboardResource';
2
+ export * from './PanelGroupDefinition';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,16 @@
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
+ export * from './DashboardResource';
14
+ export * from './PanelGroupDefinition';
15
+
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './DashboardResource';\nexport * from './PanelGroupDefinition';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB;AACpC,cAAc,yBAAyB"}
@@ -1,6 +1,6 @@
1
- import { DashboardResource } from '@perses-dev/core';
2
1
  import { StoreApi } from 'zustand';
3
2
  import { DashboardStoreState } from '../context';
3
+ import { DashboardResource } from '../model';
4
4
  /**
5
5
  * Helper to get a test dashboard resource.
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard-provider.d.ts","sourceRoot":"","sources":["../../src/test/dashboard-provider.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAoB,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGnE;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,iBAAiB,CAGpD;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI;IAC5C,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,KAAK,EAAE;QAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAA;KAAE,CAAC;CAClD,CAcA"}
1
+ {"version":3,"file":"dashboard-provider.d.ts","sourceRoot":"","sources":["../../src/test/dashboard-provider.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAoB,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,iBAAiB,CAGpD;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI;IAC5C,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,KAAK,EAAE;QAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAA;KAAE,CAAC;CAClD,CAcA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/dashboard-provider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DashboardResource } from '@perses-dev/core';\nimport { useContext } from 'react';\nimport { StoreApi } from 'zustand';\nimport { DashboardContext, DashboardStoreState } from '../context';\nimport testDashboard from './testDashboard';\n\n/**\n * Helper to get a test dashboard resource.\n */\nexport function getTestDashboard(): DashboardResource {\n // TODO: Should we be cloning this to create a new object each time?\n return testDashboard;\n}\n\n/**\n * Test helper to create a \"spy\" component that will capture the DashboardProvider's store, allowing you to inspect\n * its state in tests. Be sure to render the DashboardProviderSpy component that's returned in the component test\n * underneath the DashboardProvider.\n */\nexport function createDashboardProviderSpy(): {\n DashboardProviderSpy: () => null;\n store: { value?: StoreApi<DashboardStoreState> };\n} {\n const store: { value?: StoreApi<DashboardStoreState> } = {};\n\n // Spy component just captures the store value so it can be inspected in tests\n function DashboardProviderSpy(): null {\n const ctx = useContext(DashboardContext);\n store.value = ctx;\n return null;\n }\n\n return {\n DashboardProviderSpy,\n store,\n };\n}\n"],"names":["useContext","DashboardContext","testDashboard","getTestDashboard","createDashboardProviderSpy","store","DashboardProviderSpy","ctx","value"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,UAAU,QAAQ,QAAQ;AAEnC,SAASC,gBAAgB,QAA6B,aAAa;AACnE,OAAOC,mBAAmB,kBAAkB;AAE5C;;CAEC,GACD,OAAO,SAASC;IACd,oEAAoE;IACpE,OAAOD;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASE;IAId,MAAMC,QAAmD,CAAC;IAE1D,8EAA8E;IAC9E,SAASC;QACP,MAAMC,MAAMP,WAAWC;QACvBI,MAAMG,KAAK,GAAGD;QACd,OAAO;IACT;IAEA,OAAO;QACLD;QACAD;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/test/dashboard-provider.tsx"],"sourcesContent":["// Copyright 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 { useContext } from 'react';\nimport { StoreApi } from 'zustand';\nimport { DashboardContext, DashboardStoreState } from '../context';\nimport { DashboardResource } from '../model';\nimport testDashboard from './testDashboard';\n\n/**\n * Helper to get a test dashboard resource.\n */\nexport function getTestDashboard(): DashboardResource {\n // TODO: Should we be cloning this to create a new object each time?\n return testDashboard;\n}\n\n/**\n * Test helper to create a \"spy\" component that will capture the DashboardProvider's store, allowing you to inspect\n * its state in tests. Be sure to render the DashboardProviderSpy component that's returned in the component test\n * underneath the DashboardProvider.\n */\nexport function createDashboardProviderSpy(): {\n DashboardProviderSpy: () => null;\n store: { value?: StoreApi<DashboardStoreState> };\n} {\n const store: { value?: StoreApi<DashboardStoreState> } = {};\n\n // Spy component just captures the store value so it can be inspected in tests\n function DashboardProviderSpy(): null {\n const ctx = useContext(DashboardContext);\n store.value = ctx;\n return null;\n }\n\n return {\n DashboardProviderSpy,\n store,\n };\n}\n"],"names":["useContext","DashboardContext","testDashboard","getTestDashboard","createDashboardProviderSpy","store","DashboardProviderSpy","ctx","value"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,UAAU,QAAQ,QAAQ;AAEnC,SAASC,gBAAgB,QAA6B,aAAa;AAEnE,OAAOC,mBAAmB,kBAAkB;AAE5C;;CAEC,GACD,OAAO,SAASC;IACd,oEAAoE;IACpE,OAAOD;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASE;IAId,MAAMC,QAAmD,CAAC;IAE1D,8EAA8E;IAC9E,SAASC;QACP,MAAMC,MAAMP,WAAWC;QACvBI,MAAMG,KAAK,GAAGD;QACd,OAAO;IACT;IAEA,OAAO;QACLD;QACAD;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/plugin-registry.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec } from '@perses-dev/core';\nimport { PanelPlugin, MockPlugin } from '@perses-dev/plugin-system';\nimport { ReactElement } from 'react';\n\nconst FakeTimeSeriesChartOptionEditor = (): ReactElement => {\n return <div>TimeSeriesChart options</div>;\n};\n\nconst FakeTimeSeriesPlugin: PanelPlugin<UnknownSpec> = {\n PanelComponent: () => {\n return <div>TimeSeriesChart panel</div>;\n },\n panelOptionsEditorComponents: [\n {\n label: 'Settings',\n content: FakeTimeSeriesChartOptionEditor,\n },\n ],\n createInitialOptions: () => ({}),\n supportedQueryTypes: ['TimeSeriesQuery'],\n};\n\nconst MOCK_TIME_SERIES_PANEL: MockPlugin = {\n kind: 'Panel',\n spec: { name: 'TimeSeriesChart' },\n plugin: FakeTimeSeriesPlugin,\n};\n\n// Array of default mock plugins added to the PluginRegistry during test renders\nexport const MOCK_PLUGINS: MockPlugin[] = [MOCK_TIME_SERIES_PANEL];\n"],"names":["FakeTimeSeriesChartOptionEditor","div","FakeTimeSeriesPlugin","PanelComponent","panelOptionsEditorComponents","label","content","createInitialOptions","supportedQueryTypes","MOCK_TIME_SERIES_PANEL","kind","spec","name","plugin","MOCK_PLUGINS"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAMjC,MAAMA,kCAAkC;IACtC,qBAAO,KAACC;kBAAI;;AACd;AAEA,MAAMC,uBAAiD;IACrDC,gBAAgB;QACd,qBAAO,KAACF;sBAAI;;IACd;IACAG,8BAA8B;QAC5B;YACEC,OAAO;YACPC,SAASN;QACX;KACD;IACDO,sBAAsB,IAAO,CAAA,CAAC,CAAA;IAC9BC,qBAAqB;QAAC;KAAkB;AAC1C;AAEA,MAAMC,yBAAqC;IACzCC,MAAM;IACNC,MAAM;QAAEC,MAAM;IAAkB;IAChCC,QAAQX;AACV;AAEA,gFAAgF;AAChF,OAAO,MAAMY,eAA6B;IAACL;CAAuB,CAAC"}
1
+ {"version":3,"sources":["../../src/test/plugin-registry.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec } from '@perses-dev/spec';\nimport { PanelPlugin, MockPlugin } from '@perses-dev/plugin-system';\nimport { ReactElement } from 'react';\n\nconst FakeTimeSeriesChartOptionEditor = (): ReactElement => {\n return <div>TimeSeriesChart options</div>;\n};\n\nconst FakeTimeSeriesPlugin: PanelPlugin<UnknownSpec> = {\n PanelComponent: () => {\n return <div>TimeSeriesChart panel</div>;\n },\n panelOptionsEditorComponents: [\n {\n label: 'Settings',\n content: FakeTimeSeriesChartOptionEditor,\n },\n ],\n createInitialOptions: () => ({}),\n supportedQueryTypes: ['TimeSeriesQuery'],\n};\n\nconst MOCK_TIME_SERIES_PANEL: MockPlugin = {\n kind: 'Panel',\n spec: { name: 'TimeSeriesChart' },\n plugin: FakeTimeSeriesPlugin,\n};\n\n// Array of default mock plugins added to the PluginRegistry during test renders\nexport const MOCK_PLUGINS: MockPlugin[] = [MOCK_TIME_SERIES_PANEL];\n"],"names":["FakeTimeSeriesChartOptionEditor","div","FakeTimeSeriesPlugin","PanelComponent","panelOptionsEditorComponents","label","content","createInitialOptions","supportedQueryTypes","MOCK_TIME_SERIES_PANEL","kind","spec","name","plugin","MOCK_PLUGINS"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAMjC,MAAMA,kCAAkC;IACtC,qBAAO,KAACC;kBAAI;;AACd;AAEA,MAAMC,uBAAiD;IACrDC,gBAAgB;QACd,qBAAO,KAACF;sBAAI;;IACd;IACAG,8BAA8B;QAC5B;YACEC,OAAO;YACPC,SAASN;QACX;KACD;IACDO,sBAAsB,IAAO,CAAA,CAAC,CAAA;IAC9BC,qBAAqB;QAAC;KAAkB;AAC1C;AAEA,MAAMC,yBAAqC;IACzCC,MAAM;IACNC,MAAM;QAAEC,MAAM;IAAkB;IAChCC,QAAQX;AACV;AAEA,gFAAgF;AAChF,OAAO,MAAMY,eAA6B;IAACL;CAAuB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAU,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAuB,aAAa,EAAE,MAAM,SAAS,CAAC;AAiC7D;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,KAAK,CAAC,YAAY,EACtB,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EACxC,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CA4Bd"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAU,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAuB,aAAa,EAAE,MAAM,SAAS,CAAC;AAkC7D;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,KAAK,CAAC,YAAY,EACtB,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EACxC,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CAqCd"}
@@ -13,6 +13,7 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { ChartsProvider, SnackbarProvider, testChartsTheme } from '@perses-dev/components';
15
15
  import { mockPluginRegistry, PluginRegistry } from '@perses-dev/plugin-system';
16
+ import { HotkeysProvider } from '@tanstack/react-hotkeys';
16
17
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
17
18
  import { render } from '@testing-library/react';
18
19
  import { createMemoryHistory } from 'history';
@@ -21,6 +22,7 @@ import { Router } from 'react-router-dom';
21
22
  import { QueryParamProvider } from 'use-query-params';
22
23
  import { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';
23
24
  import { DatasourceStoreProvider } from '../context';
25
+ import { PanelFocusProvider } from '../keyboard-shortcuts';
24
26
  import { defaultDatasourceProps } from '../test';
25
27
  import { MOCK_PLUGINS } from './plugin-registry';
26
28
  /*
@@ -71,9 +73,22 @@ import { MOCK_PLUGINS } from './plugin-registry';
71
73
  children: /*#__PURE__*/ _jsx(PluginRegistry, {
72
74
  pluginLoader: mockRegistry.pluginLoader,
73
75
  defaultPluginKinds: mockRegistry.defaultPluginKinds,
74
- children: /*#__PURE__*/ _jsx(DatasourceStoreProvider, {
75
- ...defaultDatasourceProps,
76
- children: ui
76
+ children: /*#__PURE__*/ _jsx(HotkeysProvider, {
77
+ defaultOptions: {
78
+ hotkey: {
79
+ preventDefault: true,
80
+ stopPropagation: true
81
+ },
82
+ hotkeySequence: {
83
+ timeout: 1000
84
+ }
85
+ },
86
+ children: /*#__PURE__*/ _jsx(PanelFocusProvider, {
87
+ children: /*#__PURE__*/ _jsx(DatasourceStoreProvider, {
88
+ ...defaultDatasourceProps,
89
+ children: ui
90
+ })
91
+ })
77
92
  })
78
93
  })
79
94
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ChartsProvider, SnackbarProvider, testChartsTheme } from '@perses-dev/components';\nimport { mockPluginRegistry, PluginRegistry } from '@perses-dev/plugin-system';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { render, RenderOptions, RenderResult } from '@testing-library/react';\nimport { createMemoryHistory, MemoryHistory } from 'history';\nimport { ReactElement, useLayoutEffect, useState } from 'react';\nimport { Router } from 'react-router-dom';\nimport { QueryParamProvider } from 'use-query-params';\nimport { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';\nimport { DatasourceStoreProvider } from '../context';\nimport { defaultDatasourceProps } from '../test';\nimport { MOCK_PLUGINS } from './plugin-registry';\n\ninterface CustomRouterProps {\n history: MemoryHistory;\n children: React.ReactNode;\n}\n\n/*\n * Workaround for React router upgrade type errors.\n * More details: https://stackoverflow.com/a/69948457/17575201\n */\nconst CustomRouter: React.FC<CustomRouterProps> = ({ history, children }) => {\n const [state, setState] = useState({\n action: history.action,\n location: history.location,\n });\n\n useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router location={state.location} navigationType={state.action} navigator={history}>\n {children}\n </Router>\n );\n};\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(\n ui: React.ReactElement,\n options?: Omit<RenderOptions, 'queries'>,\n history?: MemoryHistory\n): RenderResult {\n // Create a new QueryClient for each test to avoid caching issues\n const queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false, retry: false } } });\n\n const customHistory = history ?? createMemoryHistory();\n\n const mockRegistry = mockPluginRegistry(...MOCK_PLUGINS);\n\n const BaseRender = (): ReactElement => (\n <CustomRouter history={customHistory}>\n <QueryClientProvider client={queryClient}>\n <QueryParamProvider adapter={ReactRouter6Adapter}>\n <SnackbarProvider anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}>\n <ChartsProvider chartsTheme={testChartsTheme}>\n <PluginRegistry\n pluginLoader={mockRegistry.pluginLoader}\n defaultPluginKinds={mockRegistry.defaultPluginKinds}\n >\n <DatasourceStoreProvider {...defaultDatasourceProps}>{ui}</DatasourceStoreProvider>\n </PluginRegistry>\n </ChartsProvider>\n </SnackbarProvider>\n </QueryParamProvider>\n </QueryClientProvider>\n </CustomRouter>\n );\n\n return render(<BaseRender />, options);\n}\n"],"names":["ChartsProvider","SnackbarProvider","testChartsTheme","mockPluginRegistry","PluginRegistry","QueryClient","QueryClientProvider","render","createMemoryHistory","useLayoutEffect","useState","Router","QueryParamProvider","ReactRouter6Adapter","DatasourceStoreProvider","defaultDatasourceProps","MOCK_PLUGINS","CustomRouter","history","children","state","setState","action","location","listen","navigationType","navigator","renderWithContext","ui","options","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","customHistory","mockRegistry","BaseRender","client","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S;gBAAEC,sBAAsB;gBAAOC,OAAO;YAAM;QAAE;IAAE;IAEjH,MAAMC,gBAAgBjB,WAAWV;IAEjC,MAAM4B,eAAejC,sBAAsBa;IAE3C,MAAMqB,aAAa,kBACjB,KAACpB;YAAaC,SAASiB;sBACrB,cAAA,KAAC7B;gBAAoBgC,QAAQR;0BAC3B,cAAA,KAAClB;oBAAmB2B,SAAS1B;8BAC3B,cAAA,KAACZ;wBAAiBuC,cAAc;4BAAEC,UAAU;4BAAUC,YAAY;wBAAQ;kCACxE,cAAA,KAAC1C;4BAAe2C,aAAazC;sCAC3B,cAAA,KAACE;gCACCwC,cAAcR,aAAaQ,YAAY;gCACvCC,oBAAoBT,aAAaS,kBAAkB;0CAEnD,cAAA,KAAC/B;oCAAyB,GAAGC,sBAAsB;8CAAGa;;;;;;;;IASpE,OAAOrB,qBAAO,KAAC8B,iBAAeR;AAChC"}
1
+ {"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ChartsProvider, SnackbarProvider, testChartsTheme } from '@perses-dev/components';\nimport { mockPluginRegistry, PluginRegistry } from '@perses-dev/plugin-system';\nimport { HotkeysProvider } from '@tanstack/react-hotkeys';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { render, RenderOptions, RenderResult } from '@testing-library/react';\nimport { createMemoryHistory, MemoryHistory } from 'history';\nimport { ReactElement, useLayoutEffect, useState } from 'react';\nimport { Router } from 'react-router-dom';\nimport { QueryParamProvider } from 'use-query-params';\nimport { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';\nimport { DatasourceStoreProvider } from '../context';\nimport { PanelFocusProvider } from '../keyboard-shortcuts';\nimport { defaultDatasourceProps } from '../test';\nimport { MOCK_PLUGINS } from './plugin-registry';\n\ninterface CustomRouterProps {\n history: MemoryHistory;\n children: React.ReactNode;\n}\n\n/*\n * Workaround for React router upgrade type errors.\n * More details: https://stackoverflow.com/a/69948457/17575201\n */\nconst CustomRouter: React.FC<CustomRouterProps> = ({ history, children }) => {\n const [state, setState] = useState({\n action: history.action,\n location: history.location,\n });\n\n useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router location={state.location} navigationType={state.action} navigator={history}>\n {children}\n </Router>\n );\n};\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(\n ui: React.ReactElement,\n options?: Omit<RenderOptions, 'queries'>,\n history?: MemoryHistory\n): RenderResult {\n // Create a new QueryClient for each test to avoid caching issues\n const queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false, retry: false } } });\n\n const customHistory = history ?? createMemoryHistory();\n\n const mockRegistry = mockPluginRegistry(...MOCK_PLUGINS);\n\n const BaseRender = (): ReactElement => (\n <CustomRouter history={customHistory}>\n <QueryClientProvider client={queryClient}>\n <QueryParamProvider adapter={ReactRouter6Adapter}>\n <SnackbarProvider anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}>\n <ChartsProvider chartsTheme={testChartsTheme}>\n <PluginRegistry\n pluginLoader={mockRegistry.pluginLoader}\n defaultPluginKinds={mockRegistry.defaultPluginKinds}\n >\n <HotkeysProvider\n defaultOptions={{\n hotkey: { preventDefault: true, stopPropagation: true },\n hotkeySequence: { timeout: 1000 },\n }}\n >\n <PanelFocusProvider>\n <DatasourceStoreProvider {...defaultDatasourceProps}>{ui}</DatasourceStoreProvider>\n </PanelFocusProvider>\n </HotkeysProvider>\n </PluginRegistry>\n </ChartsProvider>\n </SnackbarProvider>\n </QueryParamProvider>\n </QueryClientProvider>\n </CustomRouter>\n );\n\n return render(<BaseRender />, options);\n}\n"],"names":["ChartsProvider","SnackbarProvider","testChartsTheme","mockPluginRegistry","PluginRegistry","HotkeysProvider","QueryClient","QueryClientProvider","render","createMemoryHistory","useLayoutEffect","useState","Router","QueryParamProvider","ReactRouter6Adapter","DatasourceStoreProvider","PanelFocusProvider","defaultDatasourceProps","MOCK_PLUGINS","CustomRouter","history","children","state","setState","action","location","listen","navigationType","navigator","renderWithContext","ui","options","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","customHistory","mockRegistry","BaseRender","client","adapter","anchorOrigin","vertical","horizontal","chartsTheme","pluginLoader","defaultPluginKinds","hotkey","preventDefault","stopPropagation","hotkeySequence","timeout"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,cAAc,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,yBAAyB;AAC3F,SAASC,kBAAkB,EAAEC,cAAc,QAAQ,4BAA4B;AAC/E,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,wBAAwB;AACzE,SAASC,MAAM,QAAqC,yBAAyB;AAC7E,SAASC,mBAAmB,QAAuB,UAAU;AAC7D,SAAuBC,eAAe,EAAEC,QAAQ,QAAQ,QAAQ;AAChE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,kBAAkB,QAAQ,mBAAmB;AACtD,SAASC,mBAAmB,QAAQ,2CAA2C;AAC/E,SAASC,uBAAuB,QAAQ,aAAa;AACrD,SAASC,kBAAkB,QAAQ,wBAAwB;AAC3D,SAASC,sBAAsB,QAAQ,UAAU;AACjD,SAASC,YAAY,QAAQ,oBAAoB;AAOjD;;;CAGC,GACD,MAAMC,eAA4C,CAAC,EAAEC,OAAO,EAAEC,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
+ import { DashboardResource } from '../model';
2
+ type DashboardResourceTest = Omit<DashboardResource, 'metadata'> & {
3
+ metadata: {
4
+ name: string;
5
+ project: string;
6
+ createdAt: string;
7
+ updatedAt: string;
8
+ version: number;
9
+ };
10
+ };
11
+ declare const testDashboard: DashboardResourceTest;
3
12
  export default testDashboard;
4
13
  //# sourceMappingURL=testDashboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testDashboard.d.ts","sourceRoot":"","sources":["../../src/test/testDashboard.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,QAAA,MAAM,aAAa,EAAE,iBA0PpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"testDashboard.d.ts","sourceRoot":"","sources":["../../src/test/testDashboard.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,KAAK,qBAAqB,GAAG,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG;IACjE,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,QAAA,MAAM,aAAa,EAAE,qBA0PpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/testDashboard.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DashboardResource } from '@perses-dev/core';\n\nconst testDashboard: DashboardResource = {\n kind: 'Dashboard',\n metadata: {\n name: 'Node Stats',\n project: 'perses',\n createdAt: '2021-11-09',\n updatedAt: '2021-11-09',\n version: 0,\n },\n spec: {\n duration: '30m',\n refreshInterval: '0s',\n variables: [\n {\n kind: 'TextVariable',\n spec: {\n name: 'job',\n value: 'node',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'instance',\n value: 'demo.do.prometheus.io:9100',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'interval',\n value: '1m',\n },\n },\n ],\n panels: {\n cpu: {\n kind: 'Panel',\n spec: {\n display: { name: 'CPU' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: '%' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'avg without (cpu)(rate(node_cpu_seconds_total{job=\"node\",instance=\"$instance\",mode!=\"idle\"}[$interval]))',\n },\n },\n },\n },\n ],\n },\n },\n memory: {\n kind: 'Panel',\n spec: {\n display: { name: 'Memory' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'bytes' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'node_memory_MemTotal_bytes{job=\"node\",instance=\"$instance\"} - node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n },\n },\n // This panel is referenced in more than one layout below\n diskIO: {\n kind: 'Panel',\n spec: {\n display: { name: 'Disk I/O Utilization' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'percent' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'rate(node_disk_io_time_seconds_total{job=\"node\",instance=\"$instance\",device!~\"^(md\\\\\\\\d+$|dm-)\"}[$interval])',\n },\n },\n },\n },\n ],\n },\n },\n filesystemFullness: {\n kind: 'Panel',\n spec: {\n display: { name: 'Filesystem Fullness' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'percent' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n '1 - node_filesystem_free_bytes{job=\"node\",instance=\"$instance\",fstype!=\"rootfs\",mountpoint!~\"/(run|var).*\",mountpoint!=\"\"} / node_filesystem_size_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n },\n },\n },\n layouts: [\n // Regular Title, no collapse enabled\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'CPU Stats',\n collapse: {\n open: true,\n },\n },\n items: [\n // First Row\n {\n x: 0,\n y: 0,\n width: 12,\n height: 4,\n content: { $ref: '#/spec/panels/cpu' },\n },\n {\n x: 0,\n y: 5,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n ],\n },\n },\n // No title,\n {\n kind: 'Grid',\n spec: {\n items: [\n {\n x: 0,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n {\n x: 8,\n y: 0,\n width: 8,\n height: 3,\n content: { $ref: '#/spec/panels/memory' },\n },\n ],\n },\n },\n // Collapsed\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'Disk Stats',\n collapse: {\n open: false,\n },\n },\n items: [\n {\n x: 18,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/filesystemFullness' },\n },\n ],\n },\n },\n ],\n },\n};\n\nexport default testDashboard;\n"],"names":["testDashboard","kind","metadata","name","project","createdAt","updatedAt","version","spec","duration","refreshInterval","variables","value","panels","cpu","display","plugin","format","unit","queries","query","memory","diskIO","filesystemFullness","layouts","title","collapse","open","items","x","y","width","height","content","$ref"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,MAAMA,gBAAmC;IACvCC,MAAM;IACNC,UAAU;QACRC,MAAM;QACNC,SAAS;QACTC,WAAW;QACXC,WAAW;QACXC,SAAS;IACX;IACAC,MAAM;QACJC,UAAU;QACVC,iBAAiB;QACjBC,WAAW;YACT;gBACEV,MAAM;gBACNO,MAAM;oBACJL,MAAM;oBACNS,OAAO;gBACT;YACF;YACA;gBACEX,MAAM;gBACNO,MAAM;oBACJL,MAAM;oBACNS,OAAO;gBACT;YACF;YACA;gBACEX,MAAM;gBACNO,MAAM;oBACJL,MAAM;oBACNS,OAAO;gBACT;YACF;SACD;QACDC,QAAQ;YACNC,KAAK;gBACHb,MAAM;gBACNO,MAAM;oBACJO,SAAS;wBAAEZ,MAAM;oBAAM;oBACvBa,QAAQ;wBACNf,MAAM;wBACNO,MAAM;4BACJS,QAAQ;gCAAEC,MAAM;4BA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AQ;wBACNf,MAAM;wBACNO,MAAM;4BACJS,QAAQ;gCAAEC,MAAM;4BAAU;wBAC5B;oBACF;oBACAC,SAAS;wBACP;4BACElB,MAAM;4BACNO,MAAM;gCACJQ,QAAQ;oCACNf,MAAM;oCACNO,MAAM;wCACJY,OACE;oCACJ;gCACF;4BACF;wBACF;qBACD;gBACH;YACF;QACF;QACAI,SAAS;YACP,qCAAqC;YACrC;gBACEvB,MAAM;gBACNO,MAAM;oBACJO,SAAS;wBACPU,OAAO;wBACPC,UAAU;4BACRC,MAAM;wBACR;oBACF;oBACAC,OAAO;wBACL,YAAY;wBACZ;4BACEC,GAAG;4BACHC,GAAG;4BACHC,OAAO;4BACPC,QAAQ;4BACRC,SAAS;gCAAEC,MAAM;4BAAoB;wBACvC;wBACA;4BACEL,GAAG;4BACHC,GAAG;4BACHC,OAAO;4BACPC,QAAQ;4BACRC,SAAS;gCAAEC,MAAM;4BAAuB;wBAC1C;qBACD;gBACH;YACF;YACA,YAAY;YACZ;gBACEjC,MAAM;gBACNO,MAAM;oBACJoB,OAAO;wBACL;4BACEC,GAAG;4BACHC,GAAG;4BACHC,OAAO;4BACPC,QAAQ;4BACRC,SAAS;gCAAEC,MAAM;4BAAuB;wBAC1C;wBACA;4BACEL,GAAG;4BACHC,GAAG;4BACHC,OAAO;4BACPC,QAAQ;4BACRC,SAAS;gCAAEC,MAAM;4BAAuB;wBAC1C;qBACD;gBACH;YACF;YACA,YAAY;YACZ;gBACEjC,MAAM;gBACNO,MAAM;oBACJO,SAAS;wBACPU,OAAO;wBACPC,UAAU;4BACRC,MAAM;wBACR;oBACF;oBACAC,OAAO;wBACL;4BACEC,GAAG;4BACHC,GAAG;4BACHC,OAAO;4BACPC,QAAQ;4BACRC,SAAS;gCAAEC,MAAM;4BAAmC;wBACtD;qBACD;gBACH;YACF;SACD;IACH;AACF;AAEA,eAAelC,cAAc"}
1
+ {"version":3,"sources":["../../src/test/testDashboard.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DashboardResource } from '../model';\n\ntype DashboardResourceTest = Omit<DashboardResource, 'metadata'> & {\n metadata: {\n name: string;\n project: string;\n createdAt: string;\n updatedAt: string;\n version: number;\n };\n};\n\nconst testDashboard: DashboardResourceTest = {\n kind: 'Dashboard',\n metadata: {\n name: 'Node Stats',\n project: 'perses',\n createdAt: '2021-11-09',\n updatedAt: '2021-11-09',\n version: 0,\n },\n spec: {\n duration: '30m',\n refreshInterval: '0s',\n variables: [\n {\n kind: 'TextVariable',\n spec: {\n name: 'job',\n value: 'node',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'instance',\n value: 'demo.do.prometheus.io:9100',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'interval',\n value: '1m',\n },\n },\n ],\n panels: {\n cpu: {\n kind: 'Panel',\n spec: {\n display: { name: 'CPU' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: '%' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'avg without (cpu)(rate(node_cpu_seconds_total{job=\"node\",instance=\"$instance\",mode!=\"idle\"}[$interval]))',\n },\n },\n },\n },\n ],\n },\n },\n memory: {\n kind: 'Panel',\n spec: {\n display: { name: 'Memory' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'bytes' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'node_memory_MemTotal_bytes{job=\"node\",instance=\"$instance\"} - node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n },\n },\n // This panel is referenced in more than one layout below\n diskIO: {\n kind: 'Panel',\n spec: {\n display: { name: 'Disk I/O Utilization' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'percent' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'rate(node_disk_io_time_seconds_total{job=\"node\",instance=\"$instance\",device!~\"^(md\\\\\\\\d+$|dm-)\"}[$interval])',\n },\n },\n },\n },\n ],\n },\n },\n filesystemFullness: {\n kind: 'Panel',\n spec: {\n display: { name: 'Filesystem Fullness' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'percent' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n '1 - node_filesystem_free_bytes{job=\"node\",instance=\"$instance\",fstype!=\"rootfs\",mountpoint!~\"/(run|var).*\",mountpoint!=\"\"} / node_filesystem_size_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n },\n },\n },\n layouts: [\n // Regular Title, no collapse enabled\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'CPU Stats',\n collapse: {\n open: true,\n },\n },\n items: [\n // First Row\n {\n x: 0,\n y: 0,\n width: 12,\n height: 4,\n content: { $ref: '#/spec/panels/cpu' },\n },\n {\n x: 0,\n y: 5,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n ],\n },\n },\n // No title,\n {\n kind: 'Grid',\n spec: {\n items: [\n {\n x: 0,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n {\n x: 8,\n y: 0,\n width: 8,\n height: 3,\n content: { $ref: '#/spec/panels/memory' },\n },\n ],\n },\n },\n // Collapsed\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'Disk Stats',\n collapse: {\n open: false,\n },\n },\n items: [\n {\n x: 18,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/filesystemFullness' },\n },\n ],\n },\n },\n ],\n },\n};\n\nexport default testDashboard;\n"],"names":["testDashboard","kind","metadata","name","project","createdAt","updatedAt","version","spec","duration","refreshInterval","variables","value","panels","cpu","display","plugin","format","unit","queries","query","memory","diskIO","filesystemFullness","layouts","title","collapse","open","items","x","y","width","height","content","$ref"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAcjC,MAAMA,gBAAuC;IAC3CC,MAAM;IACNC,UAAU;QACRC,MAAM;QACNC,SAAS;QACTC,WAAW;QACXC,WAAW;QACXC,SAAS;IACX;IACAC,MAAM;QACJC,UAAU;QACVC,iBAAiB;QACjBC,WAAW;YACT;gBACEV,MAAM;gBACNO,MAAM;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ACA,YAAY;YACZ;gBACEjC,MAAM;gBACNO,MAAM;oBACJO,SAAS;wBACPU,OAAO;wBACPC,UAAU;4BACRC,MAAM;wBACR;oBACF;oBACAC,OAAO;wBACL;4BACEC,GAAG;4BACHC,GAAG;4BACHC,OAAO;4BACPC,QAAQ;4BACRC,SAAS;gCAAEC,MAAM;4BAAmC;wBACtD;qBACD;gBACH;YACF;SACD;IACH;AACF;AAEA,eAAelC,cAAc"}
@@ -1,4 +1,4 @@
1
- import { PanelGroupDefinition, PanelGroupItemLayout } from '@perses-dev/core';
1
+ import { PanelGroupDefinition, PanelGroupItemLayout } from '../model';
2
2
  export declare function getYForNewRow(group: PanelGroupDefinition): number;
3
3
  export type UnpositionedPanelGroupItemLayout = Omit<PanelGroupItemLayout, 'x' | 'y'>;
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"panelUtils.d.ts","sourceRoot":"","sources":["../../src/utils/panelUtils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI9E,wBAAgB,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CASjE;AA8BD,MAAM,MAAM,gCAAgC,GAAG,IAAI,CAAC,oBAAoB,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;AAErF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,gCAAgC,EAC3C,eAAe,EAAE,oBAAoB,EACrC,WAAW,EAAE,oBAAoB,EAAE,GAClC,oBAAoB,EAAE,CAyExB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,MAQnC,CAAC"}
1
+ {"version":3,"file":"panelUtils.d.ts","sourceRoot":"","sources":["../../src/utils/panelUtils.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGtE,wBAAgB,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM,CASjE;AA8BD,MAAM,MAAM,gCAAgC,GAAG,IAAI,CAAC,oBAAoB,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;AAErF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,gCAAgC,EAC3C,eAAe,EAAE,oBAAoB,EACrC,WAAW,EAAE,oBAAoB,EAAE,GAClC,oBAAoB,EAAE,CAyExB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,MAQnC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/panelUtils.ts"],"sourcesContent":["// Copyright 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 { PanelGroupDefinition, PanelGroupItemLayout } from '@perses-dev/core';\nimport { GRID_LAYOUT_SMALL_BREAKPOINT, GRID_LAYOUT_COLS } from '../constants';\n\n// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present\nexport function getYForNewRow(group: PanelGroupDefinition): number {\n let newRowY = 0;\n for (const layout of group.itemLayouts) {\n const itemMaxY = layout.y + layout.h;\n if (itemMaxY > newRowY) {\n newRowY = itemMaxY;\n }\n }\n return newRowY;\n}\n\ntype PanelGroupItemBounds = {\n /**\n * Left horizontal position.\n */\n x1: number;\n /**\n * Right horizontal position.\n */\n x2: number;\n /**\n * Top vertical position.\n */\n y1: number;\n /**\n * Bottom vertical position\n */\n y2: number;\n};\n\nfunction getPanelBounds({ x, y, w, h }: PanelGroupItemLayout): PanelGroupItemBounds {\n return {\n x1: x,\n x2: x + w,\n y1: y,\n y2: y + h,\n };\n}\n\nexport type UnpositionedPanelGroupItemLayout = Omit<PanelGroupItemLayout, 'x' | 'y'>;\n\n/**\n * Inserts a new panel into the layout with placement determined by a specified\n * reference panel. The new panel is placed:\n * - To the right of the reference panel if there is space available without\n * moving other panels.\n * - Otherwise, directly below the reference panel. If other panels are below\n * this location, they will also shift downward because the grid uses\n * vertical-based compacting.\n *\n * @param newLayout - Layout for new panel to insert into the grid.\n * @param referenceLayout - Layout for reference panel used to determine the\n * placement of the new panel.\n * @param itemLayouts - Full grid layout.\n * @returns - Item layouts modified to insert the new panel.\n */\nexport function insertPanelInLayout(\n newLayout: UnpositionedPanelGroupItemLayout,\n referenceLayout: PanelGroupItemLayout,\n itemLayouts: PanelGroupItemLayout[]\n): PanelGroupItemLayout[] {\n const MAX_LAYOUT_WIDTH = GRID_LAYOUT_COLS[GRID_LAYOUT_SMALL_BREAKPOINT];\n\n const referenceBounds = getPanelBounds(referenceLayout);\n\n // Organize layouts based on vertical relation to the item being inserted\n // after.\n const aboveInsertRow: PanelGroupItemLayout[] = [];\n const insertRow: PanelGroupItemLayout[] = [];\n const belowInsertRow: PanelGroupItemLayout[] = [];\n itemLayouts.forEach((itemLayout) => {\n const itemBounds = getPanelBounds(itemLayout);\n\n if (itemBounds.y2 <= referenceBounds.y1) {\n aboveInsertRow.push(itemLayout);\n } else if (itemBounds.y1 >= referenceBounds.y2) {\n belowInsertRow.push(itemLayout);\n } else {\n insertRow.push(itemLayout);\n }\n });\n\n // Cannot safely assume that the order of item layouts array is strictly\n // left to right. Sorting the row by horizontal position to more easily find\n // gaps.\n insertRow.sort((a, b) => a.x - b.x);\n const insertAfterIndex = insertRow.findIndex((item) => item.i === referenceLayout.i);\n\n if (insertAfterIndex === insertRow.length - 1) {\n // Insert to the right when space is available and the reference is the last\n // item in the row.\n if (referenceBounds.x2 + newLayout.w <= MAX_LAYOUT_WIDTH) {\n return [\n ...aboveInsertRow,\n ...insertRow,\n {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n },\n ...belowInsertRow,\n ];\n }\n } else if (insertAfterIndex >= 0) {\n const nextItem = insertRow[insertAfterIndex + 1];\n\n if (nextItem && getPanelBounds(nextItem).x1 - referenceBounds.x2 >= newLayout.w) {\n // Insert to the right when space is available between the reference and\n // the next item in the row.\n insertRow.splice(insertAfterIndex + 1, 0, {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n });\n\n return [...aboveInsertRow, ...insertRow, ...belowInsertRow];\n }\n }\n\n // Insert the new item below the original and shift the items below the\n // row where the reference is located.\n return [\n ...aboveInsertRow,\n ...insertRow,\n { x: referenceBounds.x1, y: referenceBounds.y2, ...newLayout },\n ...belowInsertRow.map((itemLayout) => {\n // Note: the grid will not necessarily display all of these items shifted\n // all the way down because of vertical compacting, but shifing their\n // y position ensures the new item gets vertical precedence over items\n // below it in that compacting.\n return { ...itemLayout, y: itemLayout.y + newLayout.h };\n }),\n ];\n}\n\n/**\n * This function generates a unique panel key based on UUID or timestamp and random suffix.\n */\nexport const generatePanelKey = (): string => {\n /* crypto.randomUUID() is only available in secure contexts (HTTPS), */\n if (window.isSecureContext) {\n return crypto.randomUUID().replaceAll('-', '');\n }\n const timestamp = String(Date.now());\n const randomSuffix = Math.random().toString(36).substring(2);\n return `${timestamp}${randomSuffix}`;\n};\n"],"names":["GRID_LAYOUT_SMALL_BREAKPOINT","GRID_LAYOUT_COLS","getYForNewRow","group","newRowY","layout","itemLayouts","itemMaxY","y","h","getPanelBounds","x","w","x1","x2","y1","y2","insertPanelInLayout","newLayout","referenceLayout","MAX_LAYOUT_WIDTH","referenceBounds","aboveInsertRow","insertRow","belowInsertRow","forEach","itemLayout","itemBounds","push","sort","a","b","insertAfterIndex","findIndex","item","i","length","nextItem","splice","map","generatePanelKey","window","isSecureContext","crypto","randomUUID","replaceAll","timestamp","String","Date","now","randomSuffix","Math","random","toString","substring"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,E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,OAAOC,OAAOC,UAAU,GAAGC,UAAU,CAAC,KAAK;IAC7C;IACA,MAAMC,YAAYC,OAAOC,KAAKC,GAAG;IACjC,MAAMC,eAAeC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC;IAC1D,OAAO,GAAGR,YAAYI,cAAc;AACtC,EAAE"}
1
+ {"version":3,"sources":["../../src/utils/panelUtils.ts"],"sourcesContent":["// Copyright 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 { GRID_LAYOUT_SMALL_BREAKPOINT, GRID_LAYOUT_COLS } from '../constants';\nimport { PanelGroupDefinition, PanelGroupItemLayout } from '../model';\n\n// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present\nexport function getYForNewRow(group: PanelGroupDefinition): number {\n let newRowY = 0;\n for (const layout of group.itemLayouts) {\n const itemMaxY = layout.y + layout.h;\n if (itemMaxY > newRowY) {\n newRowY = itemMaxY;\n }\n }\n return newRowY;\n}\n\ntype PanelGroupItemBounds = {\n /**\n * Left horizontal position.\n */\n x1: number;\n /**\n * Right horizontal position.\n */\n x2: number;\n /**\n * Top vertical position.\n */\n y1: number;\n /**\n * Bottom vertical position\n */\n y2: number;\n};\n\nfunction getPanelBounds({ x, y, w, h }: PanelGroupItemLayout): PanelGroupItemBounds {\n return {\n x1: x,\n x2: x + w,\n y1: y,\n y2: y + h,\n };\n}\n\nexport type UnpositionedPanelGroupItemLayout = Omit<PanelGroupItemLayout, 'x' | 'y'>;\n\n/**\n * Inserts a new panel into the layout with placement determined by a specified\n * reference panel. The new panel is placed:\n * - To the right of the reference panel if there is space available without\n * moving other panels.\n * - Otherwise, directly below the reference panel. If other panels are below\n * this location, they will also shift downward because the grid uses\n * vertical-based compacting.\n *\n * @param newLayout - Layout for new panel to insert into the grid.\n * @param referenceLayout - Layout for reference panel used to determine the\n * placement of the new panel.\n * @param itemLayouts - Full grid layout.\n * @returns - Item layouts modified to insert the new panel.\n */\nexport function insertPanelInLayout(\n newLayout: UnpositionedPanelGroupItemLayout,\n referenceLayout: PanelGroupItemLayout,\n itemLayouts: PanelGroupItemLayout[]\n): PanelGroupItemLayout[] {\n const MAX_LAYOUT_WIDTH = GRID_LAYOUT_COLS[GRID_LAYOUT_SMALL_BREAKPOINT];\n\n const referenceBounds = getPanelBounds(referenceLayout);\n\n // Organize layouts based on vertical relation to the item being inserted\n // after.\n const aboveInsertRow: PanelGroupItemLayout[] = [];\n const insertRow: PanelGroupItemLayout[] = [];\n const belowInsertRow: PanelGroupItemLayout[] = [];\n itemLayouts.forEach((itemLayout) => {\n const itemBounds = getPanelBounds(itemLayout);\n\n if (itemBounds.y2 <= referenceBounds.y1) {\n aboveInsertRow.push(itemLayout);\n } else if (itemBounds.y1 >= referenceBounds.y2) {\n belowInsertRow.push(itemLayout);\n } else {\n insertRow.push(itemLayout);\n }\n });\n\n // Cannot safely assume that the order of item layouts array is strictly\n // left to right. Sorting the row by horizontal position to more easily find\n // gaps.\n insertRow.sort((a, b) => a.x - b.x);\n const insertAfterIndex = insertRow.findIndex((item) => item.i === referenceLayout.i);\n\n if (insertAfterIndex === insertRow.length - 1) {\n // Insert to the right when space is available and the reference is the last\n // item in the row.\n if (referenceBounds.x2 + newLayout.w <= MAX_LAYOUT_WIDTH) {\n return [\n ...aboveInsertRow,\n ...insertRow,\n {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n },\n ...belowInsertRow,\n ];\n }\n } else if (insertAfterIndex >= 0) {\n const nextItem = insertRow[insertAfterIndex + 1];\n\n if (nextItem && getPanelBounds(nextItem).x1 - referenceBounds.x2 >= newLayout.w) {\n // Insert to the right when space is available between the reference and\n // the next item in the row.\n insertRow.splice(insertAfterIndex + 1, 0, {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n });\n\n return [...aboveInsertRow, ...insertRow, ...belowInsertRow];\n }\n }\n\n // Insert the new item below the original and shift the items below the\n // row where the reference is located.\n return [\n ...aboveInsertRow,\n ...insertRow,\n { x: referenceBounds.x1, y: referenceBounds.y2, ...newLayout },\n ...belowInsertRow.map((itemLayout) => {\n // Note: the grid will not necessarily display all of these items shifted\n // all the way down because of vertical compacting, but shifing their\n // y position ensures the new item gets vertical precedence over items\n // below it in that compacting.\n return { ...itemLayout, y: itemLayout.y + newLayout.h };\n }),\n ];\n}\n\n/**\n * This function generates a unique panel key based on UUID or timestamp and random suffix.\n */\nexport const generatePanelKey = (): string => {\n /* crypto.randomUUID() is only available in secure contexts (HTTPS), */\n if (window.isSecureContext) {\n return crypto.randomUUID().replaceAll('-', '');\n }\n const timestamp = String(Date.now());\n const randomSuffix = Math.random().toString(36).substring(2);\n return `${timestamp}${randomSuffix}`;\n};\n"],"names":["GRID_LAYOUT_SMALL_BREAKPOINT","GRID_LAYOUT_COLS","getYForNewRow","group","newRowY","layout","itemLayouts","itemMaxY","y","h","getPanelBounds","x","w","x1","x2","y1","y2","insertPanelInLayout","newLayout","referenceLayout","MAX_LAYOUT_WIDTH","referenceBounds","aboveInsertRow","insertRow","belowInsertRow","forEach","itemLayout","itemBounds","push","sort","a","b","insertAfterIndex","findIndex","item","i","length","nextItem","splice","map","generatePanelKey","window","isSecureContext","crypto","randomUUID","replaceAll","timestamp","String","Date","now","randomSuffix","Math","random","toString","substring"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,4BAA4B,EAAEC,gBA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AAQ,CAAC,IAAIC,SAAS,CAAC;IAC1D,OAAO,GAAGR,YAAYI,cAAc;AACtC,EAAE"}
@@ -1,19 +1,21 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
- import { DashboardResource, EphemeralDashboardResource } from '@perses-dev/core';
2
+ import { DashboardSpec } from '@perses-dev/spec';
3
3
  import { EmptyDashboardProps } from '../../components';
4
4
  import { OnSaveDashboard } from '../../context';
5
+ import { DashboardResource } from '../../model';
5
6
  export interface DashboardAppProps {
6
- dashboardResource: DashboardResource | EphemeralDashboardResource;
7
+ dashboardResource: DashboardResource;
7
8
  emptyDashboardProps?: Partial<EmptyDashboardProps>;
8
9
  isReadonly: boolean;
9
10
  isVariableEnabled: boolean;
10
11
  isDatasourceEnabled: boolean;
12
+ disableShortcuts?: boolean;
11
13
  isCreating?: boolean;
12
14
  isInitialVariableSticky?: boolean;
13
15
  isLeavingConfirmDialogEnabled?: boolean;
14
16
  dashboardTitleComponent?: ReactNode;
15
17
  onSave?: OnSaveDashboard;
16
- onDiscard?: (entity: DashboardResource) => void;
18
+ onDiscard?: (name: string, spec: DashboardSpec) => void;
17
19
  }
18
20
  export declare const DashboardApp: (props: DashboardAppProps) => ReactElement;
19
21
  //# sourceMappingURL=DashboardApp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAEjF,OAAO,EAQL,mBAAmB,EAIpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAkE,MAAM,eAAe,CAAC;AAEhH,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,iBAAiB,GAAG,0BAA0B,CAAC;IAClE,mBAAmB,CAAC,EAAE,OA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CAAC,EAAE,eAAe,CAAC;IACzB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;CACzD;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,KAAG,YAMvD,CAAC"}
@@ -15,10 +15,18 @@ import { useState } from 'react';
15
15
  import { Box } from '@mui/material';
16
16
  import { ChartsProvider, ErrorAlert, ErrorBoundary, useChartsTheme } from '@perses-dev/components';
17
17
  import { useDatasourceStore } from '@perses-dev/plugin-system';
18
- import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog, DashboardDiscardChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog, EditJsonDialog, SaveChangesConfirmationDialog, LeaveDialog } from '../../components';
18
+ import { PanelDrawer, Dashboard, useDashboardShortcuts, PanelGroupDialog, DeletePanelGroupDialog, DashboardDiscardChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog, EditJsonDialog, SaveChangesConfirmationDialog, LeaveDialog } from '../../components';
19
19
  import { useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';
20
+ import { PanelFocusProvider } from '../../keyboard-shortcuts';
20
21
  export const DashboardApp = (props)=>{
21
- const { dashboardResource, emptyDashboardProps, isReadonly, isVariableEnabled, isDatasourceEnabled, isCreating, isInitialVariableSticky, isLeavingConfirmDialogEnabled, dashboardTitleComponent, onSave, onDiscard } = props;
22
+ return /*#__PURE__*/ _jsx(PanelFocusProvider, {
23
+ children: /*#__PURE__*/ _jsx(DashboardAppContent, {
24
+ ...props
25
+ })
26
+ });
27
+ };
28
+ const DashboardAppContent = (props)=>{
29
+ const { dashboardResource, emptyDashboardProps, isReadonly, isVariableEnabled, isDatasourceEnabled, disableShortcuts, isCreating, isInitialVariableSticky, isLeavingConfirmDialogEnabled, dashboardTitleComponent, onSave, onDiscard } = props;
22
30
  const chartsTheme = useChartsTheme();
23
31
  const { isEditMode, setEditMode } = useEditMode();
24
32
  const { dashboard, setDashboard } = useDashboard();
@@ -33,7 +41,7 @@ export const DashboardApp = (props)=>{
33
41
  setEditMode(false);
34
42
  closeDiscardChangesConfirmationDialog();
35
43
  if (onDiscard) {
36
- onDiscard(dashboard);
44
+ onDiscard(dashboard.metadata.name, dashboard.spec);
37
45
  }
38
46
  };
39
47
  const onEditButtonClick = ()=>{
@@ -56,6 +64,13 @@ export const DashboardApp = (props)=>{
56
64
  });
57
65
  }
58
66
  };
67
+ useDashboardShortcuts({
68
+ onSave,
69
+ isReadonly,
70
+ onEditButtonClick,
71
+ onCancelButtonClick,
72
+ disabled: disableShortcuts
73
+ });
59
74
  return /*#__PURE__*/ _jsxs(Box, {
60
75
  sx: {
61
76
  flexGrow: 1,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, ReactNode, useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ChartsProvider, ErrorAlert, ErrorBoundary, useChartsTheme } from '@perses-dev/components';\nimport { DashboardResource, EphemeralDashboardResource } from '@perses-dev/core';\nimport { useDatasourceStore } from '@perses-dev/plugin-system';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n DashboardDiscardChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n EmptyDashboardProps,\n EditJsonDialog,\n SaveChangesConfirmationDialog,\n LeaveDialog,\n} from '../../components';\nimport { OnSaveDashboard, useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource | EphemeralDashboardResource;\n emptyDashboardProps?: Partial<EmptyDashboardProps>;\n isReadonly: boolean;\n isVariableEnabled: boolean;\n isDatasourceEnabled: boolean;\n isCreating?: boolean;\n isInitialVariableSticky?: boolean;\n // If true, browser confirmation dialog will be shown when navigating away with unsaved changes (closing tab, ...).\n isLeavingConfirmDialogEnabled?: boolean;\n dashboardTitleComponent?: ReactNode;\n onSave?: OnSaveDashboard;\n onDiscard?: (entity: DashboardResource) => void;\n}\n\nexport const DashboardApp = (props: DashboardAppProps): ReactElement => {\n const {\n dashboardResource,\n emptyDashboardProps,\n isReadonly,\n isVariableEnabled,\n isDatasourceEnabled,\n isCreating,\n isInitialVariableSticky,\n isLeavingConfirmDialogEnabled,\n dashboardTitleComponent,\n onSave,\n onDiscard,\n } = props;\n\n const chartsTheme = useChartsTheme();\n\n const { isEditMode, setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<\n DashboardResource | EphemeralDashboardResource | undefined\n >(undefined);\n const { setSavedDatasources } = useDatasourceStore();\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleDiscardChanges = (): void => {\n // Reset to the original spec and exit edit mode\n if (originalDashboard) {\n setDashboard(originalDashboard);\n }\n setEditMode(false);\n closeDiscardChangesConfirmationDialog();\n if (onDiscard) {\n onDiscard(dashboard as unknown as DashboardResource);\n }\n };\n\n const onEditButtonClick = (): void => {\n setEditMode(true);\n setOriginalDashboard(dashboard);\n setSavedDatasources(dashboard.spec.datasources ?? {});\n };\n\n const onCancelButtonClick = (): void => {\n // check if dashboard has been modified\n if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {\n setEditMode(false);\n } else {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n handleDiscardChanges();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n });\n }\n };\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar\n dashboardName={dashboardResource.metadata.name}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={isInitialVariableSticky}\n onSave={onSave}\n isReadonly={isReadonly}\n isVariableEnabled={isVariableEnabled}\n isDatasourceEnabled={isDatasourceEnabled}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ paddingTop: 2, paddingX: 2, height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard\n emptyDashboardProps={{\n onEditButtonClick,\n ...emptyDashboardProps,\n }}\n />\n </ErrorBoundary>\n <ChartsProvider chartsTheme={chartsTheme} enablePinning={false} enableSyncGrouping={false}>\n <PanelDrawer />\n </ChartsProvider>\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <DashboardDiscardChangesConfirmationDialog />\n <EditJsonDialog isReadonly={!isEditMode} disableMetadataEdition={!isCreating} />\n <SaveChangesConfirmationDialog />\n {isLeavingConfirmDialogEnabled && isEditMode && (\n <LeaveDialog original={originalDashboard} current={dashboard} />\n )}\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ChartsProvider","ErrorAlert","ErrorBoundary","useChartsTheme","useDatasourceStore","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","DashboardDiscardChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","EditJsonDialog","SaveChangesConfirmationDialog","LeaveDialog","useDashboard","useDiscardChangesConfirmationDialog","useEditMode","DashboardApp","props","dashboardResource","emptyDashboardProps","isReadonly","isVariableEnabled","isDatasourceEnabled","isCreating","isInitialVariableSticky","isLeavingConfirmDialogEnabled","dashboardTitleComponent","onSave","onDiscard","chartsTheme","isEditMode","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","setSavedDatasources","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleDiscardChanges","onEditButtonClick","spec","datasources","onCancelButtonClick","JSON","stringify","onDiscardChanges","onCancel","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","initialVariableIsSticky","paddingTop","paddingX","height","FallbackComponent","enablePinning","enableSyncGrouping","disableMetadataEdition","original","current"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAkCA,QAAQ,QAAQ,QAAQ;AAC1D,SAASC,GAAG,QAAQ,gBAAgB;AACpC,SAASC,cAAc,EAAEC,UAAU,EAAEC,aAAa,EAAEC,cAAc,QAAQ,yBAAyB;AAEnG,SAASC,kBAAkB,QAAQ,4BAA4B;AAC/D,SACEC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,sBAAsB,EACtBC,yCAAyC,EACzCC,gBAAgB,EAChBC,iBAAiB,EAEjBC,cAAc,EACdC,6BAA6B,EAC7BC,WAAW,QACN,mBAAmB;AAC1B,SAA0BC,YAAY,EAAEC,mCAAmC,EAAEC,WAAW,QAAQ,gBAAgB;AAiBhH,OAAO,MAAMC,eAAe,CAACC;IAC3B,MAAM,EACJC,iBAAiB,EACjBC,mBAAmB,EACnBC,UAAU,EACVC,iBAAiB,EACjBC,mBAAmB,EACnBC,UAAU,EACVC,uBAAuB,EACvBC,6BAA6B,EAC7BC,uBAAuB,EACvBC,MAAM,EACNC,SAAS,EACV,GAAGX;IAEJ,MAAMY,cAAc5B;IAEpB,MAAM,EAAE6B,UAAU,EAAEC,WAAW,EAAE,GAAGhB;IACpC,MAAM,EAAEiB,SAAS,EAAEC,YAAY,EAAE,GAAGpB;IACpC,MAAM,CAACqB,mBAAmBC,qBAAqB,GAAGvC,SAE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AeU,YAAY,CAACU;wBAAYmC,wBAAwB,CAAC1C;;kCAClE,KAACZ;oBACAc,iCAAiCK,4BAChC,KAAClB;wBAAYsD,UAAUhC;wBAAmBiC,SAASnC;;;;;;AAK7D,EAAE"}
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, ReactNode, useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ChartsProvider, ErrorAlert, ErrorBoundary, useChartsTheme } from '@perses-dev/components';\nimport { useDatasourceStore } from '@perses-dev/plugin-system';\nimport { DashboardSpec } from '@perses-dev/spec';\nimport {\n PanelDrawer,\n Dashboard,\n useDashboardShortcuts,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n DashboardDiscardChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n EmptyDashboardProps,\n EditJsonDialog,\n SaveChangesConfirmationDialog,\n LeaveDialog,\n} from '../../components';\nimport { OnSaveDashboard, useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';\nimport { PanelFocusProvider } from '../../keyboard-shortcuts';\nimport { DashboardResource } from '../../model';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource;\n emptyDashboardProps?: Partial<EmptyDashboardProps>;\n isReadonly: boolean;\n isVariableEnabled: boolean;\n isDatasourceEnabled: boolean;\n disableShortcuts?: boolean;\n isCreating?: boolean;\n isInitialVariableSticky?: boolean;\n // If true, browser confirmation dialog will be shown when navigating away with unsaved changes (closing tab, ...).\n isLeavingConfirmDialogEnabled?: boolean;\n dashboardTitleComponent?: ReactNode;\n onSave?: OnSaveDashboard;\n onDiscard?: (name: string, spec: DashboardSpec) => void;\n}\n\nexport const DashboardApp = (props: DashboardAppProps): ReactElement => {\n return (\n <PanelFocusProvider>\n <DashboardAppContent {...props} />\n </PanelFocusProvider>\n );\n};\n\nconst DashboardAppContent = (props: DashboardAppProps): ReactElement => {\n const {\n dashboardResource,\n emptyDashboardProps,\n isReadonly,\n isVariableEnabled,\n isDatasourceEnabled,\n disableShortcuts,\n isCreating,\n isInitialVariableSticky,\n isLeavingConfirmDialogEnabled,\n dashboardTitleComponent,\n onSave,\n onDiscard,\n } = props;\n\n const chartsTheme = useChartsTheme();\n\n const { isEditMode, setEditMode } = useEditMode();\n\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<DashboardResource | undefined>(undefined);\n\n const { setSavedDatasources } = useDatasourceStore();\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleDiscardChanges = (): void => {\n // Reset to the original spec and exit edit mode\n if (originalDashboard) {\n setDashboard(originalDashboard);\n }\n setEditMode(false);\n closeDiscardChangesConfirmationDialog();\n if (onDiscard) {\n onDiscard(dashboard.metadata.name, dashboard.spec);\n }\n };\n\n const onEditButtonClick = (): void => {\n setEditMode(true);\n setOriginalDashboard(dashboard);\n setSavedDatasources(dashboard.spec.datasources ?? {});\n };\n\n const onCancelButtonClick = (): void => {\n // check if dashboard has been modified\n if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {\n setEditMode(false);\n } else {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n handleDiscardChanges();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n });\n }\n };\n\n useDashboardShortcuts({\n onSave,\n isReadonly,\n onEditButtonClick,\n onCancelButtonClick,\n disabled: disableShortcuts,\n });\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar\n dashboardName={dashboardResource.metadata.name}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={isInitialVariableSticky}\n onSave={onSave}\n isReadonly={isReadonly}\n isVariableEnabled={isVariableEnabled}\n isDatasourceEnabled={isDatasourceEnabled}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ paddingTop: 2, paddingX: 2, height: '100%' }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard\n emptyDashboardProps={{\n onEditButtonClick,\n ...emptyDashboardProps,\n }}\n />\n </ErrorBoundary>\n <ChartsProvider chartsTheme={chartsTheme} enablePinning={false} enableSyncGrouping={false}>\n <PanelDrawer />\n </ChartsProvider>\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <DashboardDiscardChangesConfirmationDialog />\n <EditJsonDialog isReadonly={!isEditMode} disableMetadataEdition={!isCreating} />\n <SaveChangesConfirmationDialog />\n {isLeavingConfirmDialogEnabled && isEditMode && (\n <LeaveDialog original={originalDashboard} current={dashboard} />\n )}\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ChartsProvider","ErrorAlert","ErrorBoundary","useChartsTheme","useDatasourceStore","PanelDrawer","Dashboard","useDashboardShortcuts","PanelGroupDialog","DeletePanelGroupDialog","DashboardDiscardChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","EditJsonDialog","SaveChangesConfirmationDialog","LeaveDialog","useDashboard","useDiscardChangesConfirmationDialog","useEditMode","PanelFocusProvider","DashboardApp","props","DashboardAppContent","dashboardResource","emptyDashboardProps","isReadonly","isVariableEnabled","isDatasourceEnabled","disableShortcuts","isCreating","isInitialVariableSticky","isLeavingConfirmDialogEnabled","dashboardTitleComponent","onSave","onDiscard","chartsTheme","isEditMode","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","setSavedDatasources","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleDiscardChanges","metadata","name","spec","onEditButtonClick","datasources","onCancelButtonClick","JSON","stringify","onDiscardChanges","onCancel","disabled","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","initialVariableIsSticky","paddingTop","paddingX","height","FallbackComponent","enablePinning","enableSyncGrouping","disableMetadataEdition","original","current"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAkCA,QAAQ,QAAQ,QAAQ;AAC1D,SAASC,GAAG,QAAQ,gBAAgB;AACpC,SAASC,cAAc,EAAEC,UAAU,EAAEC,aAAa,EAAEC,cAAc,QAAQ,yBAAyB;AACnG,SAASC,kBAAkB,QAAQ,4BAA4B;AAE/D,SACEC,WAAW,EACXC,SAAS,EACTC,qBAAqB,EACrBC,gBAAgB,EAChBC,sBAAsB,EACtBC,yCAAyC,EACzCC,gBAAgB,EAChBC,iBAAiB,EAEjBC,cAAc,EACdC,6BAA6B,EAC7BC,WAAW,QACN,mBAAmB;AAC1B,SAA0BC,YAAY,EAAEC,mCAAmC,EAAEC,WAAW,QAAQ,gBAAgB;AAChH,SAASC,kBAAkB,QAAQ,2BAA2B;AAmB9D,OAAO,MAAMC,eAAe,CAACC;IAC3B,qBACE,KAACF;kBACC,cAAA,KAACG;YAAqB,GAAGD,KAAK;;;AAGpC,EAAE;AAEF,MAAMC,sBAAsB,CAACD;IAC3B,MAAM,EACJE,iBAAiB,EACjBC,mBAAmB,EACnBC,UAAU,EACVC,iBAAiB,EACjBC,mBAAmB,EACnBC,gBAAgB,EAChBC,UAAU,EACVC,uBAAuB,EACvBC,6BAA6B,EAC7BC,uBAAuB,EACvBC,MAAM,EACNC,SAAS,EACV,GAAGb;IAEJ,MAAMc,c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AQ;gBAAO;;kCACpD,KAAClE;wBAAcmE,mBAAmBpE;kCAChC,cAAA,KAACK;4BACCkB,qBAAqB;gCACnB0B;gCACA,GAAG1B,mBAAmB;4BACxB;;;kCAGJ,KAACxB;wBAAemC,aAAaA;wBAAamC,eAAe;wBAAOC,oBAAoB;kCAClF,cAAA,KAAClE;;kCAEH,KAACG;kCACD,KAACC;kCACD,KAACG;kCACD,KAACF;kCACD,KAACG;wBAAeY,YAAY,CAACW;wBAAYoC,wBAAwB,CAAC3C;;kCAClE,KAACf;oBACAiB,iCAAiCK,4BAChC,KAACrB;wBAAY0D,UAAUjC;wBAAmBkC,SAASpC;;;;;;AAK7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAS9C,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAC9C,OAAO,EACL,4BAA4B,EAE5B,qBAAqB,EAEtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAgB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,iBAAiB;IACvF,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,CAAC;IAC7D,2BAA2B,CAAC,EAAE,qBAAqB,CAAC,6BAA6B,CAAC,CAAC;IACnF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CAgHrE"}
1
+ {"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAS9C,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAE9C,OAAO,EACL,4BAA4B,EAE5B,qBAAqB,EAEtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAgB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,iBAAiB;IACvF,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,CAAC;IAC7D,2BAA2B,CAAC,EAAE,qBAAqB,CAAC,6BAA6B,CAAC,CAAC;IACnF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CAkHrE"}
@@ -12,17 +12,17 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
- import { DEFAULT_DASHBOARD_DURATION, DEFAULT_REFRESH_INTERVAL } from '@perses-dev/core';
16
15
  import { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';
17
16
  import { TimeRangeProviderWithQueryParams, useInitialRefreshInterval, useInitialTimeRange, usePluginBuiltinVariableDefinitions } from '@perses-dev/plugin-system';
18
17
  import { useMemo } from 'react';
18
+ import { DEFAULT_DASHBOARD_DURATION, DEFAULT_REFRESH_INTERVAL } from '../../constants';
19
19
  import { DatasourceStoreProvider, VariableProviderWithQueryParams } from '../../context';
20
20
  import { DashboardProviderWithQueryParams } from '../../context/DashboardProvider/DashboardProviderWithQueryParams';
21
21
  import { DashboardApp } from './DashboardApp';
22
22
  /**
23
23
  * The View for displaying a Dashboard, along with the UI for selecting variable values.
24
24
  */ export function ViewDashboard(props) {
25
- const { dashboardResource, datasourceApi, externalVariableDefinitions, emptyDashboardProps, isReadonly, isVariableEnabled, isDatasourceEnabled, isEditing, isCreating, isInitialVariableSticky, isLeavingConfirmDialogEnabled, dashboardTitleComponent, onSave, onDiscard, sx, ...others } = props;
25
+ const { dashboardResource, datasourceApi, externalVariableDefinitions, emptyDashboardProps, isReadonly, isVariableEnabled, isDatasourceEnabled, disableShortcuts, isEditing, isCreating, isInitialVariableSticky, isLeavingConfirmDialogEnabled, dashboardTitleComponent, onSave, onDiscard, sx, ...others } = props;
26
26
  const { spec } = dashboardResource;
27
27
  const dashboardDuration = spec.duration ?? DEFAULT_DASHBOARD_DURATION;
28
28
  const dashboardRefreshInterval = spec.refreshInterval ?? DEFAULT_REFRESH_INTERVAL;
@@ -99,6 +99,7 @@ import { DashboardApp } from './DashboardApp';
99
99
  isReadonly: isReadonly,
100
100
  isVariableEnabled: isVariableEnabled,
101
101
  isDatasourceEnabled: isDatasourceEnabled,
102
+ disableShortcuts: disableShortcuts,
102
103
  isCreating: isCreating,
103
104
  isInitialVariableSticky: isInitialVariableSticky,
104
105
  isLeavingConfirmDialogEnabled: isLeavingConfirmDialogEnabled,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { BuiltinVariableDefinition, DEFAULT_DASHBOARD_DURATION, DEFAULT_REFRESH_INTERVAL } from '@perses-dev/core';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport {\n TimeRangeProviderWithQueryParams,\n useInitialRefreshInterval,\n useInitialTimeRange,\n usePluginBuiltinVariableDefinitions,\n} from '@perses-dev/plugin-system';\nimport { ReactElement, useMemo } from 'react';\nimport {\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n VariableProviderProps,\n VariableProviderWithQueryParams,\n} from '../../context';\nimport { DashboardProviderWithQueryParams } from '../../context/DashboardProvider/DashboardProviderWithQueryParams';\nimport { DashboardApp, DashboardAppProps } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'>, DashboardAppProps {\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n externalVariableDefinitions?: VariableProviderProps['externalVariableDefinitions'];\n isEditing?: boolean;\n isCreating?: boolean;\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps): ReactElement {\n const {\n dashboardResource,\n datasourceApi,\n externalVariableDefinitions,\n emptyDashboardProps,\n isReadonly,\n isVariableEnabled,\n isDatasourceEnabled,\n isEditing,\n isCreating,\n isInitialVariableSticky,\n isLeavingConfirmDialogEnabled,\n dashboardTitleComponent,\n onSave,\n onDiscard,\n sx,\n ...others\n } = props;\n const { spec } = dashboardResource;\n const dashboardDuration = spec.duration ?? DEFAULT_DASHBOARD_DURATION;\n const dashboardRefreshInterval = spec.refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n const initialTimeRange = useInitialTimeRange(dashboardDuration);\n const initialRefreshInterval = useInitialRefreshInterval(dashboardRefreshInterval);\n const { data } = usePluginBuiltinVariableDefinitions();\n\n const builtinVariables = useMemo(() => {\n const result = [\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__dashboard',\n value: () => dashboardResource.metadata.name,\n source: 'Dashboard',\n display: {\n name: '__dashboard',\n description: 'The name of the current dashboard',\n hidden: true,\n },\n },\n } as BuiltinVariableDefinition,\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__project',\n value: () => dashboardResource.metadata.project,\n source: 'Dashboard',\n display: {\n name: '__project',\n description: 'The name of the current dashboard project',\n hidden: true,\n },\n },\n } as BuiltinVariableDefinition,\n ];\n if (data) {\n data.forEach((def: BuiltinVariableDefinition) => result.push(def));\n }\n return result;\n }, [dashboardResource.metadata.name, dashboardResource.metadata.project, data]);\n\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProviderWithQueryParams\n initialState={{\n isEditMode: !!isEditing,\n dashboardResource,\n }}\n >\n <TimeRangeProviderWithQueryParams\n initialTimeRange={initialTimeRange}\n initialRefreshInterval={initialRefreshInterval}\n >\n <VariableProviderWithQueryParams\n initialVariableDefinitions={spec.variables}\n externalVariableDefinitions={externalVariableDefinitions}\n builtinVariableDefinitions={builtinVariables}\n >\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp\n dashboardResource={dashboardResource}\n emptyDashboardProps={emptyDashboardProps}\n isReadonly={isReadonly}\n isVariableEnabled={isVariableEnabled}\n isDatasourceEnabled={isDatasourceEnabled}\n isCreating={isCreating}\n isInitialVariableSticky={isInitialVariableSticky}\n isLeavingConfirmDialogEnabled={isLeavingConfirmDialogEnabled}\n dashboardTitleComponent={dashboardTitleComponent}\n onSave={onSave}\n onDiscard={onDiscard}\n />\n </ErrorBoundary>\n </Box>\n </VariableProviderWithQueryParams>\n </TimeRangeProviderWithQueryParams>\n </DashboardProviderWithQueryParams>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["Box","DEFAULT_DASHBOARD_DURATION","DEFAULT_REFRESH_INTERVAL","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProviderWithQueryParams","useInitialRefreshInterval","useInitialTimeRange","usePluginBuiltinVariableDefinitions","useMemo","DatasourceStoreProvider","VariableProviderWithQueryParams","DashboardProviderWithQueryParams","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","externalVariableDefinitions","emptyDashboardProps","isReadonly","isVariableEnabled","isDatasourceEnabled","isEditing","isCreating","isInitialVariableSticky","isLeavingConfirmDialogEnabled","dashboardTitleComponent","onSave","onDiscard","sx","others","spec","dashboardDuration","duration","dashboardRefreshInterval","refreshInterval","initialTimeRange","initialRefreshInterval","data","builtinVariables","result","kind","name","value","metadata","source","display","description","hidden","project","forEach","def","push","initialState","isEditMode","initialVariableDefinitions","variables","builtinVariableDefinitions","width","height","position","overflow","FallbackComponent"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,QAAkB,gBAAgB;AAC9C,SAAoCC,0BAA0B,EAAEC,wBAAwB,QAAQ,mBAAmB;AACnH,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,yBAAyB;AAC9E,SACEC,gCAAgC,EAChCC,yBAAyB,EACzBC,mBAAmB,EACnBC,mCAAmC,QAC9B,4BAA4B;AACnC,SAAuBC,OAAO,QAAQ,QAAQ;AAC9C,SAEEC,uBAAuB,EAEvBC,+BAA+B,QAC1B,gBAAgB;AACvB,SAASC,gCAAgC,QAAQ,mEAAmE;AACpH,SAASC,YAAY,QAA2B,iBAAiB;AASjE;;CAEC,GACD,OAAO,SAASC,cAAcC,KAAyB;IACrD,MAAM,EACJC,iBAAiB,EACjBC,aAAa,EACbC,2BAA2B,EAC3BC,mBAAmB,EACnBC,UAAU,EACVC,iBAAiB,EACjBC,mBAAmB,EACnBC,SAAS,EACTC,UAAU,EACVC,uBAAuB,EACvBC,6BAA6B,EAC7BC,uBAAuB,EACvBC,MAAM,EACNC,SAAS,EACTC,EAAE,EACF,GAAGC,QACJ,GAAGhB;IACJ,MAAM,EAAEiB,IAAI,EAAE,GAAGhB;IACjB,MAAMiB,oBAAoBD,KAAKE,QAAQ,IAAIlC;IAC3C,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6D,mBAAmB5D;sCAChC,cAAA,KAACU;gCACCG,mBAAmBA;gCACnBG,qBAAqBA;gCACrBC,YAAYA;gCACZC,mBAAmBA;gCACnBC,qBAAqBA;gCACrBE,YAAYA;gCACZC,yBAAyBA;gCACzBC,+BAA+BA;gCAC/BC,yBAAyBA;gCACzBC,QAAQA;gCACRC,WAAWA;;;;;;;;AAS7B"}
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { BuiltinVariableDefinition } from '@perses-dev/spec';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport {\n TimeRangeProviderWithQueryParams,\n useInitialRefreshInterval,\n useInitialTimeRange,\n usePluginBuiltinVariableDefinitions,\n} from '@perses-dev/plugin-system';\nimport { ReactElement, useMemo } from 'react';\nimport { DEFAULT_DASHBOARD_DURATION, DEFAULT_REFRESH_INTERVAL } from '../../constants';\nimport {\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n VariableProviderProps,\n VariableProviderWithQueryParams,\n} from '../../context';\nimport { DashboardProviderWithQueryParams } from '../../context/DashboardProvider/DashboardProviderWithQueryParams';\nimport { DashboardApp, DashboardAppProps } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'>, DashboardAppProps {\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n externalVariableDefinitions?: VariableProviderProps['externalVariableDefinitions'];\n isEditing?: boolean;\n isCreating?: boolean;\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps): ReactElement {\n const {\n dashboardResource,\n datasourceApi,\n externalVariableDefinitions,\n emptyDashboardProps,\n isReadonly,\n isVariableEnabled,\n isDatasourceEnabled,\n disableShortcuts,\n isEditing,\n isCreating,\n isInitialVariableSticky,\n isLeavingConfirmDialogEnabled,\n dashboardTitleComponent,\n onSave,\n onDiscard,\n sx,\n ...others\n } = props;\n const { spec } = dashboardResource;\n const dashboardDuration = spec.duration ?? DEFAULT_DASHBOARD_DURATION;\n const dashboardRefreshInterval = spec.refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n const initialTimeRange = useInitialTimeRange(dashboardDuration);\n const initialRefreshInterval = useInitialRefreshInterval(dashboardRefreshInterval);\n const { data } = usePluginBuiltinVariableDefinitions();\n\n const builtinVariables = useMemo(() => {\n const result = [\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__dashboard',\n value: () => dashboardResource.metadata.name,\n source: 'Dashboard',\n display: {\n name: '__dashboard',\n description: 'The name of the current dashboard',\n hidden: true,\n },\n },\n } as BuiltinVariableDefinition,\n {\n kind: 'BuiltinVariable',\n spec: {\n name: '__project',\n value: () => dashboardResource.metadata.project,\n source: 'Dashboard',\n display: {\n name: '__project',\n description: 'The name of the current dashboard project',\n hidden: true,\n },\n },\n } as BuiltinVariableDefinition,\n ];\n if (data) {\n data.forEach((def: BuiltinVariableDefinition) => result.push(def));\n }\n return result;\n }, [dashboardResource.metadata.name, dashboardResource.metadata.project, data]);\n\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProviderWithQueryParams\n initialState={{\n isEditMode: !!isEditing,\n dashboardResource,\n }}\n >\n <TimeRangeProviderWithQueryParams\n initialTimeRange={initialTimeRange}\n initialRefreshInterval={initialRefreshInterval}\n >\n <VariableProviderWithQueryParams\n initialVariableDefinitions={spec.variables}\n externalVariableDefinitions={externalVariableDefinitions}\n builtinVariableDefinitions={builtinVariables}\n >\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp\n dashboardResource={dashboardResource}\n emptyDashboardProps={emptyDashboardProps}\n isReadonly={isReadonly}\n isVariableEnabled={isVariableEnabled}\n isDatasourceEnabled={isDatasourceEnabled}\n disableShortcuts={disableShortcuts}\n isCreating={isCreating}\n isInitialVariableSticky={isInitialVariableSticky}\n isLeavingConfirmDialogEnabled={isLeavingConfirmDialogEnabled}\n dashboardTitleComponent={dashboardTitleComponent}\n onSave={onSave}\n onDiscard={onDiscard}\n />\n </ErrorBoundary>\n </Box>\n </VariableProviderWithQueryParams>\n </TimeRangeProviderWithQueryParams>\n </DashboardProviderWithQueryParams>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProviderWithQueryParams","useInitialRefreshInterval","useInitialTimeRange","usePluginBuiltinVariableDefinitions","useMemo","DEFAULT_DASHBOARD_DURATION","DEFAULT_REFRESH_INTERVAL","DatasourceStoreProvider","VariableProviderWithQueryParams","DashboardProviderWithQueryParams","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","externalVariableDefinitions","emptyDashboardProps","isReadonly","isVariableEnabled","isDatasourceEnabled","disableShortcuts","isEditing","isCreating","isInitialVariableSticky","isLeavingConfirmDialogEnabled","dashboardTitleComponent","onSave","onDiscard","sx","others","spec","dashboardDuration","duration","dashboardRefreshInterval","refreshInterval","initialTimeRange","initialRefreshInterval","data","builtinVariables","result","kind","name","value","metadata","source","display","description","hidden","project","forEach","def","push","initialState","isEditMode","initialVariableDefinitions","variables","builtinVariableDefinitions","width","height","position","overflow","FallbackComponent"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,E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AAa;wBACbC,QAAQ;oBACV;gBACF;YACF;YACA;gBACEP,MAAM;gBACNV,MAAM;oBACJW,MAAM;oBACNC,OAAO,IAAM7B,kBAAkB8B,QAAQ,CAACK,OAAO;oBAC/CJ,QAAQ;oBACRC,SAAS;wBACPJ,MAAM;wBACNK,aAAa;wBACbC,QAAQ;oBACV;gBACF;YACF;SACD;QACD,IAAIV,MAAM;YACRA,KAAKY,OAAO,CAAC,CAACC,MAAmCX,OAAOY,IAAI,CAACD;QAC/D;QACA,OAAOX;IACT,GAAG;QAAC1B,kBAAkB8B,QAAQ,CAACF,IAAI;QAAE5B,kBAAkB8B,QAAQ,CAACK,OAAO;QAAEX;KAAK;IAE9E,qBACE,KAAC9B;QAAwBM,mBAAmBA;QAAmBC,eAAeA;kBAC5E,cAAA,KAACL;YACC2C,cAAc;gBACZC,YAAY,CAAC,CAAChC;gBACdR;YACF;sBAEA,cAAA,KAACb;gBACCmC,kBAAkBA;gBAClBC,wBAAwBA;0BAExB,cAAA,KAAC5B;oBACC8C,4BAA4BxB,KAAKyB,SAAS;oBAC1CxC,6BAA6BA;oBAC7ByC,4BAA4BlB;8BAE5B,cAAA,KAAC1C;wBACCgC,IAAI7B,UACF;4BACE8C,SAAS;4BACTY,OAAO;4BACPC,QAAQ;4BACRC,UAAU;4BACVC,UAAU;wBACZ,GACAhC;wBAED,GAAGC,MAAM;kCAEV,cAAA,KAAChC;4BAAcgE,mBAAmB/D;sCAChC,cAAA,KAACY;gCACCG,mBAAmBA;gCACnBG,qBAAqBA;gCACrBC,YAAYA;gCACZC,mBAAmBA;gCACnBC,qBAAqBA;gCACrBC,kBAAkBA;gCAClBE,YAAYA;gCACZC,yBAAyBA;gCACzBC,+BAA+BA;gCAC/BC,yBAAyBA;gCACzBC,QAAQA;gCACRC,WAAWA;;;;;;;;AAS7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.53.1",
3
+ "version": "0.54.0-beta.1",
4
4
  "description": "The dashboards feature in Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -29,9 +29,10 @@
29
29
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
30
30
  },
31
31
  "dependencies": {
32
- "@perses-dev/components": "0.53.1",
32
+ "@perses-dev/components": "0.54.0-beta.1",
33
33
  "@perses-dev/core": "0.53.0",
34
- "@perses-dev/plugin-system": "0.53.1",
34
+ "@perses-dev/plugin-system": "0.54.0-beta.1",
35
+ "@perses-dev/spec": "0.2.0-beta.0",
35
36
  "@types/react-grid-layout": "^1.3.2",
36
37
  "date-fns": "^4.1.0",
37
38
  "immer": "^10.1.1",
@@ -39,6 +40,7 @@
39
40
  "react-grid-layout": "^1.3.4",
40
41
  "react-hook-form": "^7.46.1",
41
42
  "react-intersection-observer": "^9.4.0",
43
+ "@tanstack/react-hotkeys": "^0.9.1",
42
44
  "use-immer": "^0.11.0",
43
45
  "use-query-params": "^2.2.1",
44
46
  "use-resize-observer": "^9.0.0",