@perses-dev/dashboards 0.39.0 → 0.40.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 (287) hide show
  1. package/dist/cjs/components/AddGroupButton/AddGroupButton.js +9 -7
  2. package/dist/cjs/components/AddGroupButton/index.js +10 -8
  3. package/dist/cjs/components/AddPanelButton/AddPanelButton.js +9 -7
  4. package/dist/cjs/components/AddPanelButton/index.js +10 -8
  5. package/dist/cjs/components/Dashboard/Dashboard.js +11 -9
  6. package/dist/cjs/components/Dashboard/index.js +10 -8
  7. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +18 -16
  8. package/dist/cjs/components/DashboardStickyToolbar/index.js +10 -8
  9. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +43 -41
  10. package/dist/cjs/components/DashboardToolbar/index.js +10 -8
  11. package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +12 -10
  12. package/dist/cjs/components/DeletePanelDialog/index.js +10 -8
  13. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +17 -15
  14. package/dist/cjs/components/DeletePanelGroupDialog/index.js +10 -8
  15. package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +5 -3
  16. package/dist/cjs/components/DiscardChangesConfirmationDialog/index.js +10 -8
  17. package/dist/cjs/components/DownloadButton/DownloadButton.js +12 -10
  18. package/dist/cjs/components/DownloadButton/index.js +10 -8
  19. package/dist/cjs/components/EditButton/EditButton.js +8 -6
  20. package/dist/cjs/components/EditButton/index.js +10 -8
  21. package/dist/cjs/components/EditJsonButton/EditJsonButton.js +10 -8
  22. package/dist/cjs/components/EditJsonButton/index.js +10 -8
  23. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +29 -23
  24. package/dist/cjs/components/EditJsonDialog/index.js +10 -8
  25. package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +18 -16
  26. package/dist/cjs/components/EmptyDashboard/index.js +10 -8
  27. package/dist/cjs/components/GridLayout/GridContainer.js +5 -3
  28. package/dist/cjs/components/GridLayout/GridItemContent.js +33 -14
  29. package/dist/cjs/components/GridLayout/GridLayout.js +18 -16
  30. package/dist/cjs/components/GridLayout/GridTitle.js +35 -33
  31. package/dist/cjs/components/GridLayout/index.js +13 -11
  32. package/dist/cjs/components/Panel/Panel.js +17 -22
  33. package/dist/cjs/components/Panel/PanelContent.js +8 -6
  34. package/dist/cjs/components/Panel/PanelHeader.js +33 -31
  35. package/dist/cjs/components/Panel/index.js +10 -8
  36. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +25 -77
  37. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +269 -141
  38. package/dist/cjs/components/PanelDrawer/PanelPreview.js +11 -9
  39. package/dist/cjs/components/PanelDrawer/index.js +10 -8
  40. package/dist/cjs/components/PanelDrawer/usePanelEditor.js +3 -1
  41. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +18 -16
  42. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +15 -11
  43. package/dist/cjs/components/PanelGroupDialog/index.js +10 -8
  44. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +46 -44
  45. package/dist/cjs/components/QuerySummaryTable/index.js +10 -8
  46. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +23 -21
  47. package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +10 -8
  48. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +8 -8
  49. package/dist/cjs/components/SaveDashboardButton/index.js +10 -8
  50. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +40 -16
  51. package/dist/cjs/components/TimeRangeControls/index.js +10 -8
  52. package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +5 -3
  53. package/dist/cjs/components/ToolbarIconButton/index.js +10 -8
  54. package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +140 -0
  55. package/dist/cjs/components/Variables/EditVariablesButton.js +16 -11
  56. package/dist/cjs/components/Variables/TemplateVariable.js +116 -69
  57. package/dist/cjs/components/Variables/VariableEditor.js +280 -204
  58. package/dist/cjs/components/Variables/VariableList.js +19 -15
  59. package/dist/cjs/components/Variables/index.js +14 -11
  60. package/dist/cjs/components/index.js +31 -29
  61. package/dist/cjs/constants/grid-layout-config.js +6 -2
  62. package/dist/cjs/constants/index.js +11 -9
  63. package/dist/cjs/constants/user-interface-text.js +6 -2
  64. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +40 -34
  65. package/dist/cjs/context/DashboardProvider/common.js +6 -2
  66. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +70 -38
  67. package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +3 -1
  68. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +5 -3
  69. package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +3 -1
  70. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +3 -1
  71. package/dist/cjs/context/DashboardProvider/edit-json-dialog-slice.js +3 -1
  72. package/dist/cjs/context/DashboardProvider/index.js +12 -10
  73. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +13 -11
  74. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +8 -6
  75. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +15 -7
  76. package/dist/cjs/context/DashboardProvider/panel-slice.js +3 -1
  77. package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +3 -1
  78. package/dist/cjs/context/DatasourceStoreProvider.js +114 -45
  79. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +125 -34
  80. package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +12 -10
  81. package/dist/cjs/context/TemplateVariableProvider/index.js +10 -8
  82. package/dist/cjs/context/TemplateVariableProvider/query-params.js +17 -7
  83. package/dist/cjs/context/TemplateVariableProvider/utils.js +15 -7
  84. package/dist/cjs/context/index.js +13 -11
  85. package/dist/cjs/context/useDashboard.js +8 -6
  86. package/dist/cjs/index.js +12 -10
  87. package/dist/cjs/stories/decorators/WithDashboard.js +6 -4
  88. package/dist/cjs/stories/decorators/WithDatasourceStore.js +6 -4
  89. package/dist/cjs/stories/decorators/WithTemplateVariables.js +6 -4
  90. package/dist/cjs/stories/decorators/constants.js +5 -3
  91. package/dist/cjs/stories/decorators/index.js +13 -11
  92. package/dist/cjs/test/dashboard-provider.js +8 -4
  93. package/dist/cjs/test/datasource-provider.js +16 -12
  94. package/dist/cjs/test/index.js +13 -11
  95. package/dist/cjs/test/plugin-registry.js +6 -4
  96. package/dist/cjs/test/render.js +27 -20
  97. package/dist/cjs/test/setup-tests.js +2 -2
  98. package/dist/cjs/test/testDashboard.js +13 -11
  99. package/dist/cjs/utils/index.js +11 -9
  100. package/dist/cjs/utils/panelUtils.js +9 -3
  101. package/dist/cjs/utils/time.js +5 -3
  102. package/dist/cjs/validation/index.js +30 -0
  103. package/dist/cjs/validation/panel.js +29 -0
  104. package/dist/cjs/views/ViewDashboard/DashboardApp.js +20 -16
  105. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +63 -19
  106. package/dist/cjs/views/ViewDashboard/index.js +10 -8
  107. package/dist/cjs/views/index.js +10 -8
  108. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
  109. package/dist/components/AddGroupButton/index.js.map +1 -1
  110. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  111. package/dist/components/AddPanelButton/index.js.map +1 -1
  112. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  113. package/dist/components/Dashboard/index.js.map +1 -1
  114. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  115. package/dist/components/DashboardStickyToolbar/index.js.map +1 -1
  116. package/dist/components/DashboardToolbar/DashboardToolbar.js +1 -1
  117. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  118. package/dist/components/DashboardToolbar/index.js.map +1 -1
  119. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  120. package/dist/components/DeletePanelDialog/index.js.map +1 -1
  121. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -2
  122. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  123. package/dist/components/DeletePanelGroupDialog/index.js.map +1 -1
  124. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  125. package/dist/components/DiscardChangesConfirmationDialog/index.js.map +1 -1
  126. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  127. package/dist/components/DownloadButton/index.js.map +1 -1
  128. package/dist/components/EditButton/EditButton.js.map +1 -1
  129. package/dist/components/EditButton/index.js.map +1 -1
  130. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  131. package/dist/components/EditJsonButton/index.js.map +1 -1
  132. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +4 -1
  133. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  134. package/dist/components/EditJsonDialog/EditJsonDialog.js +12 -8
  135. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  136. package/dist/components/EditJsonDialog/index.js.map +1 -1
  137. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
  138. package/dist/components/EmptyDashboard/index.js.map +1 -1
  139. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  140. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  141. package/dist/components/GridLayout/GridItemContent.js +27 -10
  142. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  143. package/dist/components/GridLayout/GridLayout.js +2 -2
  144. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  145. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  146. package/dist/components/GridLayout/index.js.map +1 -1
  147. package/dist/components/Panel/Panel.d.ts.map +1 -1
  148. package/dist/components/Panel/Panel.js +4 -11
  149. package/dist/components/Panel/Panel.js.map +1 -1
  150. package/dist/components/Panel/PanelContent.js.map +1 -1
  151. package/dist/components/Panel/PanelHeader.js.map +1 -1
  152. package/dist/components/Panel/index.js.map +1 -1
  153. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  154. package/dist/components/PanelDrawer/PanelDrawer.js +22 -76
  155. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  156. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +4 -1
  157. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  158. package/dist/components/PanelDrawer/PanelEditorForm.js +223 -138
  159. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  160. package/dist/components/PanelDrawer/PanelPreview.js +2 -2
  161. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  162. package/dist/components/PanelDrawer/index.js.map +1 -1
  163. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
  164. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  165. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  166. package/dist/components/PanelGroupDialog/index.js.map +1 -1
  167. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +4 -4
  168. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  169. package/dist/components/QuerySummaryTable/index.js.map +1 -1
  170. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -4
  171. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  172. package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -1
  173. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  174. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +1 -3
  175. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  176. package/dist/components/SaveDashboardButton/index.js.map +1 -1
  177. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  178. package/dist/components/TimeRangeControls/TimeRangeControls.js +19 -1
  179. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  180. package/dist/components/TimeRangeControls/index.js.map +1 -1
  181. package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  182. package/dist/components/ToolbarIconButton/index.js.map +1 -1
  183. package/dist/components/Variables/BuiltinVariableAccordions.d.ts +8 -0
  184. package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -0
  185. package/dist/components/Variables/BuiltinVariableAccordions.js +127 -0
  186. package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -0
  187. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  188. package/dist/components/Variables/EditVariablesButton.js +3 -0
  189. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  190. package/dist/components/Variables/TemplateVariable.d.ts +10 -1
  191. package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
  192. package/dist/components/Variables/TemplateVariable.js +91 -54
  193. package/dist/components/Variables/TemplateVariable.js.map +1 -1
  194. package/dist/components/Variables/VariableEditor.d.ts +2 -1
  195. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  196. package/dist/components/Variables/VariableEditor.js +229 -157
  197. package/dist/components/Variables/VariableEditor.js.map +1 -1
  198. package/dist/components/Variables/VariableList.js +6 -6
  199. package/dist/components/Variables/VariableList.js.map +1 -1
  200. package/dist/components/Variables/index.d.ts +1 -0
  201. package/dist/components/Variables/index.d.ts.map +1 -1
  202. package/dist/components/Variables/index.js +1 -0
  203. package/dist/components/Variables/index.js.map +1 -1
  204. package/dist/components/index.js.map +1 -1
  205. package/dist/constants/grid-layout-config.js.map +1 -1
  206. package/dist/constants/index.js.map +1 -1
  207. package/dist/constants/user-interface-text.js.map +1 -1
  208. package/dist/context/DashboardProvider/DashboardProvider.js +5 -5
  209. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  210. package/dist/context/DashboardProvider/common.js.map +1 -1
  211. package/dist/context/DashboardProvider/dashboard-provider-api.js +2 -2
  212. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  213. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  214. package/dist/context/DashboardProvider/delete-panel-slice.js +2 -2
  215. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  216. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
  217. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  218. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
  219. package/dist/context/DashboardProvider/index.js.map +1 -1
  220. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -1
  221. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  222. package/dist/context/DashboardProvider/panel-editor-slice.js +7 -7
  223. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  224. package/dist/context/DashboardProvider/panel-group-editor-slice.js +2 -2
  225. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  226. package/dist/context/DashboardProvider/panel-group-slice.js +3 -3
  227. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  228. package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
  229. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  230. package/dist/context/DatasourceStoreProvider.d.ts +14 -10
  231. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  232. package/dist/context/DatasourceStoreProvider.js +107 -40
  233. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  234. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +10 -4
  235. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  236. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +93 -18
  237. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  238. package/dist/context/TemplateVariableProvider/hydrationUtils.js +7 -7
  239. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
  240. package/dist/context/TemplateVariableProvider/index.js.map +1 -1
  241. package/dist/context/TemplateVariableProvider/query-params.js.map +1 -1
  242. package/dist/context/TemplateVariableProvider/utils.js +3 -3
  243. package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
  244. package/dist/context/index.js.map +1 -1
  245. package/dist/context/useDashboard.js +1 -1
  246. package/dist/context/useDashboard.js.map +1 -1
  247. package/dist/index.js.map +1 -1
  248. package/dist/stories/decorators/WithDashboard.js.map +1 -1
  249. package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
  250. package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
  251. package/dist/stories/decorators/constants.js +2 -2
  252. package/dist/stories/decorators/constants.js.map +1 -1
  253. package/dist/stories/decorators/index.js.map +1 -1
  254. package/dist/test/dashboard-provider.js.map +1 -1
  255. package/dist/test/datasource-provider.d.ts.map +1 -1
  256. package/dist/test/datasource-provider.js +5 -7
  257. package/dist/test/datasource-provider.js.map +1 -1
  258. package/dist/test/index.js.map +1 -1
  259. package/dist/test/plugin-registry.js.map +1 -1
  260. package/dist/test/render.d.ts.map +1 -1
  261. package/dist/test/render.js +6 -1
  262. package/dist/test/render.js.map +1 -1
  263. package/dist/test/setup-tests.js.map +1 -1
  264. package/dist/test/testDashboard.js +10 -10
  265. package/dist/test/testDashboard.js.map +1 -1
  266. package/dist/utils/index.js.map +1 -1
  267. package/dist/utils/panelUtils.js.map +1 -1
  268. package/dist/utils/time.js.map +1 -1
  269. package/dist/validation/index.d.ts +2 -0
  270. package/dist/validation/index.d.ts.map +1 -0
  271. package/dist/validation/index.js +15 -0
  272. package/dist/validation/index.js.map +1 -0
  273. package/dist/validation/panel.d.ts +19 -0
  274. package/dist/validation/panel.d.ts.map +1 -0
  275. package/dist/validation/panel.js +21 -0
  276. package/dist/validation/panel.js.map +1 -0
  277. package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
  278. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  279. package/dist/views/ViewDashboard/DashboardApp.js +4 -2
  280. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  281. package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
  282. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  283. package/dist/views/ViewDashboard/ViewDashboard.js +49 -7
  284. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  285. package/dist/views/ViewDashboard/index.js.map +1 -1
  286. package/dist/views/index.js.map +1 -1
  287. package/package.json +8 -7
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/plugin-registry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec } from '@perses-dev/core';\nimport { PanelPlugin, MockPlugin } from '@perses-dev/plugin-system';\n\nconst FakeTimeSeriesChartOptionEditor = () => {\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};\n\nconst MOCK_TIME_SERIES_PANEL: MockPlugin = {\n pluginType: 'Panel',\n kind: '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","MOCK_TIME_SERIES_PANEL","pluginType","kind","plugin","MOCK_PLUGINS"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAGA,MAAMA,+BAA+B,GAAG,IAAM;IAC5C,qBAAO,KAACC,KAAG;kBAAC,yBAAuB;MAAM,CAAC;AAC5C,CAAC,AAAC;AAEF,MAAMC,oBAAoB,GAA6B;IACrDC,cAAc,EAAE,IAAM;QACpB,qBAAO,KAACF,KAAG;sBAAC,uBAAqB;UAAM,CAAC;IAC1C,CAAC;IACDG,4BAA4B,EAAE;QAC5B;YACEC,KAAK,EAAE,UAAU;YACjBC,OAAO,EAAEN,+BAA+B;SACzC;KACF;IACDO,oBAAoB,EAAE,IAAO,CAAA,EAAE,CAAA,AAAC;CACjC,AAAC;AAEF,MAAMC,sBAAsB,GAAe;IACzCC,UAAU,EAAE,OAAO;IACnBC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAET,oBAAoB;CAC7B,AAAC;AAEF,gFAAgF;AAChF,OAAO,MAAMU,YAAY,GAAiB;IAACJ,sBAAsB;CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/test/plugin-registry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec } from '@perses-dev/core';\nimport { PanelPlugin, MockPlugin } from '@perses-dev/plugin-system';\n\nconst FakeTimeSeriesChartOptionEditor = () => {\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};\n\nconst MOCK_TIME_SERIES_PANEL: MockPlugin = {\n pluginType: 'Panel',\n kind: '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","MOCK_TIME_SERIES_PANEL","pluginType","kind","plugin","MOCK_PLUGINS"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAKjC,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;AAChC;AAEA,MAAMC,yBAAqC;IACzCC,YAAY;IACZC,MAAM;IACNC,QAAQT;AACV;AAEA,gFAAgF;AAChF,OAAO,MAAMU,eAA6B;IAACJ;CAAuB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAU,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAuB,aAAa,EAAE,MAAM,SAAS,CAAC;AAgC7D;;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,gIAsBxB"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAU,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE/D,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,gIAwBxB"}
@@ -20,6 +20,8 @@ import { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';
20
20
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
21
21
  import { ChartsProvider, SnackbarProvider, testChartsTheme } from '@perses-dev/components';
22
22
  import { mockPluginRegistry, PluginRegistry } from '@perses-dev/plugin-system';
23
+ import { DatasourceStoreProvider } from '../context';
24
+ import { defaultDatasourceProps } from '../test';
23
25
  import { MOCK_PLUGINS } from './plugin-registry';
24
26
  /*
25
27
  * Workaround for React router upgrade type errors.
@@ -67,7 +69,10 @@ import { MOCK_PLUGINS } from './plugin-registry';
67
69
  chartsTheme: testChartsTheme,
68
70
  children: /*#__PURE__*/ _jsx(PluginRegistry, {
69
71
  ...mockPluginRegistry(...MOCK_PLUGINS),
70
- children: ui
72
+ children: /*#__PURE__*/ _jsx(DatasourceStoreProvider, {
73
+ ...defaultDatasourceProps,
74
+ children: ui
75
+ })
71
76
  })
72
77
  })
73
78
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useLayoutEffect, useState } from 'react';\nimport { render, RenderOptions } from '@testing-library/react';\nimport { Router } from 'react-router-dom';\nimport { createMemoryHistory, MemoryHistory } from 'history';\nimport { QueryParamProvider } from 'use-query-params';\nimport { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ChartsProvider, SnackbarProvider, testChartsTheme } from '@perses-dev/components';\nimport { mockPluginRegistry, PluginRegistry } from '@perses-dev/plugin-system';\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) {\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 BaseRender = () => (\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 {...mockPluginRegistry(...MOCK_PLUGINS)}>{ui}</PluginRegistry>\n </ChartsProvider>\n </SnackbarProvider>\n </QueryParamProvider>\n </QueryClientProvider>\n </CustomRouter>\n );\n\n return render(<BaseRender />, options);\n}\n"],"names":["useLayoutEffect","useState","render","Router","createMemoryHistory","QueryParamProvider","ReactRouter6Adapter","QueryClient","QueryClientProvider","ChartsProvider","SnackbarProvider","testChartsTheme","mockPluginRegistry","PluginRegistry","MOCK_PLUGINS","CustomRouter","history","children","state","setState","action","location","listen","navigationType","navigator","renderWithContext","ui","options","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","customHistory","BaseRender","client","adapter","anchorOrigin","vertical","horizontal","chartsTheme"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,eAAe,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAClD,SAASC,MAAM,QAAuB,wBAAwB,CAAC;AAC/D,SAASC,MAAM,QAAQ,kBAAkB,CAAC;AAC1C,SAASC,mBAAmB,QAAuB,SAAS,CAAC;AAC7D,SAASC,kBAAkB,QAAQ,kBAAkB,CAAC;AACtD,SAASC,mBAAmB,QAAQ,0CAA0C,CAAC;AAC/E,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,uBAAuB,CAAC;AACzE,SAASC,cAAc,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,wBAAwB,CAAC;AAC3F,SAASC,kBAAkB,EAAEC,cAAc,QAAQ,2BAA2B,CAAC;AAC/E,SAASC,YAAY,QAAQ,mBAAmB,CAAC;AAOjD;;;CAGC,GACD,MA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AW,EAAE7B,eAAe;sCAC1C,cAAA,KAACE,cAAc;gCAAE,GAAGD,kBAAkB,IAAIE,YAAY,CAAC;0CAAGY,EAAE;8BAAkB;0BAC/D;sBACA;kBACA;cACD;UACT,AAChB,AAAC;IAEF,OAAOxB,MAAM,eAAC,KAACgC,UAAU,KAAG,EAAEP,OAAO,CAAC,CAAC;AACzC,CAAC"}
1
+ {"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useLayoutEffect, useState } from 'react';\nimport { render, RenderOptions } from '@testing-library/react';\nimport { Router } from 'react-router-dom';\nimport { createMemoryHistory, MemoryHistory } from 'history';\nimport { QueryParamProvider } from 'use-query-params';\nimport { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ChartsProvider, SnackbarProvider, testChartsTheme } from '@perses-dev/components';\nimport { mockPluginRegistry, PluginRegistry } from '@perses-dev/plugin-system';\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) {\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 BaseRender = () => (\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 {...mockPluginRegistry(...MOCK_PLUGINS)}>\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":["useLayoutEffect","useState","render","Router","createMemoryHistory","QueryParamProvider","ReactRouter6Adapter","QueryClient","QueryClientProvider","ChartsProvider","SnackbarProvider","testChartsTheme","mockPluginRegistry","PluginRegistry","DatasourceStoreProvider","defaultDatasourceProps","MOCK_PLUGINS","CustomRouter","history","children","state","setState","action","location","listen","navigationType","navigator","renderWithContext","ui","options","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","customHistory","BaseRender","client","adapter","anchorOrigin","vertical","horizontal","chartsTheme"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,eAAe,EAAEC,QAAQ,QAAQ,QAAQ;AAClD,SAASC,MAAM,QAAuB,yBAAyB;AAC/D,SAASC,MAAM,QAAQ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B,GAAGD,sBAAsBI,aAAa;0CACrD,cAAA,KAACF;oCAAyB,GAAGC,sBAAsB;8CAAGa;;;;;;;;IASpE,OAAO1B,qBAAO,KAACkC,iBAAeP;AAChC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/setup-tests.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { defaultFallbackInView } from 'react-intersection-observer';\n\n// Add testing library assertions\nimport '@testing-library/jest-dom/extend-expect';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n\n// Tell react-intersection-observer that everything should be considered in-view for tests (see package documentation\n// for other options)\ndefaultFallbackInView(true);\n"],"names":["defaultFallbackInView","jest","mock"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,qBAAqB,QAAQ,6BAA6B,CAAC;AAEpE,iCAAiC;AACjC,OAAO,yCAAyC,CAAC;AAEjD,iFAAiF;AACjFC,IAAI,CAACC,IAAI,CAAC,cAAc,CAAC,CAAC;AAE1B,qHAAqH;AACrH,qBAAqB;AACrBF,qBAAqB,CAAC,IAAI,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/test/setup-tests.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { defaultFallbackInView } from 'react-intersection-observer';\n\n// Add testing library assertions\nimport '@testing-library/jest-dom/extend-expect';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n\n// Tell react-intersection-observer that everything should be considered in-view for tests (see package documentation\n// for other options)\ndefaultFallbackInView(true);\n"],"names":["defaultFallbackInView","jest","mock"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,qBAAqB,QAAQ,8BAA8B;AAEpE,iCAAiC;AACjC,OAAO,0CAA0C;AAEjD,iFAAiF;AACjFC,KAAKC,KAAK;AAEV,qHAAqH;AACrH,qBAAqB;AACrBF,sBAAsB"}
@@ -15,8 +15,8 @@ const testDashboard = {
15
15
  metadata: {
16
16
  name: 'Node Stats',
17
17
  project: 'perses',
18
- created_at: '2021-11-09',
19
- updated_at: '2021-11-09',
18
+ createdAt: '2021-11-09',
19
+ updatedAt: '2021-11-09',
20
20
  version: 0
21
21
  },
22
22
  spec: {
@@ -55,8 +55,8 @@ const testDashboard = {
55
55
  plugin: {
56
56
  kind: 'TimeSeriesChart',
57
57
  spec: {
58
- unit: {
59
- kind: '%'
58
+ format: {
59
+ unit: '%'
60
60
  }
61
61
  }
62
62
  },
@@ -84,8 +84,8 @@ const testDashboard = {
84
84
  plugin: {
85
85
  kind: 'TimeSeriesChart',
86
86
  spec: {
87
- unit: {
88
- kind: 'Bytes'
87
+ format: {
88
+ unit: 'bytes'
89
89
  }
90
90
  }
91
91
  },
@@ -147,8 +147,8 @@ const testDashboard = {
147
147
  plugin: {
148
148
  kind: 'TimeSeriesChart',
149
149
  spec: {
150
- unit: {
151
- kind: 'Percent'
150
+ format: {
151
+ unit: 'percent'
152
152
  }
153
153
  }
154
154
  },
@@ -176,8 +176,8 @@ const testDashboard = {
176
176
  plugin: {
177
177
  kind: 'TimeSeriesChart',
178
178
  spec: {
179
- unit: {
180
- kind: 'Percent'
179
+ format: {
180
+ unit: 'percent'
181
181
  }
182
182
  }
183
183
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/testDashboard.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DashboardResource } from '@perses-dev/core';\n\nconst testDashboard: DashboardResource = {\n kind: 'Dashboard',\n metadata: {\n name: 'Node Stats',\n project: 'perses',\n created_at: '2021-11-09',\n updated_at: '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 unit: { kind: '%' },\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 unit: { kind: '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 unit: { kind: '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 unit: { kind: '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","created_at","updated_at","version","spec","duration","refreshInterval","variables","value","panels","cpu","display","plugin","unit","queries","query","memory","diskIO","filesystemFullness","layouts","title","collapse","open","items","x","y","width","height","content","$ref"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0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4BACTC,OAAO,EAAE;gCAAEC,IAAI,EAAE,sBAAsB;6BAAE;yBAC1C;qBACF;iBACF;aACF;YACD,YAAY;YACZ;gBACEhC,IAAI,EAAE,MAAM;gBACZO,IAAI,EAAE;oBACJmB,KAAK,EAAE;wBACL;4BACEC,CAAC,EAAE,CAAC;4BACJC,CAAC,EAAE,CAAC;4BACJC,KAAK,EAAE,CAAC;4BACRC,MAAM,EAAE,CAAC;4BACTC,OAAO,EAAE;gCAAEC,IAAI,EAAE,sBAAsB;6BAAE;yBAC1C;wBACD;4BACEL,CAAC,EAAE,CAAC;4BACJC,CAAC,EAAE,CAAC;4BACJC,KAAK,EAAE,CAAC;4BACRC,MAAM,EAAE,CAAC;4BACTC,OAAO,EAAE;gCAAEC,IAAI,EAAE,sBAAsB;6BAAE;yBAC1C;qBACF;iBACF;aACF;YACD,YAAY;YACZ;gBACEhC,IAAI,EAAE,MAAM;gBACZO,IAAI,EAAE;oBACJO,OAAO,EAAE;wBACPS,KAAK,EAAE,YAAY;wBACnBC,QAAQ,EAAE;4BACRC,IAAI,EAAE,KAAK;yBACZ;qBACF;oBACDC,KAAK,EAAE;wBACL;4BACEC,CAAC,EAAE,EAAE;4BACLC,CAAC,EAAE,CAAC;4BACJC,KAAK,EAAE,CAAC;4BACRC,MAAM,EAAE,CAAC;4BACTC,OAAO,EAAE;gCAAEC,IAAI,EAAE,kCAAkC;6BAAE;yBACtD;qBACF;iBACF;aACF;SACF;KACF;CACF,AAAC;AAEF,eAAejC,aAAa,CAAC"}
1
+ {"version":3,"sources":["../../src/test/testDashboard.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DashboardResource } from '@perses-dev/core';\n\nconst testDashboard: DashboardResource = {\n kind: 'Dashboard',\n metadata: {\n name: 'Node Stats',\n project: 'perses',\n createdAt: '2021-11-09',\n updatedAt: '2021-11-09',\n version: 0,\n },\n spec: {\n duration: '30m',\n refreshInterval: '0s',\n variables: [\n {\n kind: 'TextVariable',\n spec: {\n name: 'job',\n value: 'node',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'instance',\n value: 'demo.do.prometheus.io:9100',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'interval',\n value: '1m',\n },\n },\n ],\n panels: {\n cpu: {\n kind: 'Panel',\n spec: {\n display: { name: 'CPU' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: '%' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'avg without (cpu)(rate(node_cpu_seconds_total{job=\"node\",instance=\"$instance\",mode!=\"idle\"}[$interval]))',\n },\n },\n },\n },\n ],\n },\n },\n memory: {\n kind: 'Panel',\n spec: {\n display: { name: 'Memory' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'bytes' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'node_memory_MemTotal_bytes{job=\"node\",instance=\"$instance\"} - node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n },\n },\n // This panel is referenced in more than one layout below\n diskIO: {\n kind: 'Panel',\n spec: {\n display: { name: 'Disk I/O Utilization' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'percent' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'rate(node_disk_io_time_seconds_total{job=\"node\",instance=\"$instance\",device!~\"^(md\\\\\\\\d+$|dm-)\"}[$interval])',\n },\n },\n },\n },\n ],\n },\n },\n filesystemFullness: {\n kind: 'Panel',\n spec: {\n display: { name: 'Filesystem Fullness' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n format: { unit: 'percent' },\n },\n },\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n '1 - node_filesystem_free_bytes{job=\"node\",instance=\"$instance\",fstype!=\"rootfs\",mountpoint!~\"/(run|var).*\",mountpoint!=\"\"} / node_filesystem_size_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n },\n },\n },\n layouts: [\n // Regular Title, no collapse enabled\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'CPU Stats',\n collapse: {\n open: true,\n },\n },\n items: [\n // First Row\n {\n x: 0,\n y: 0,\n width: 12,\n height: 4,\n content: { $ref: '#/spec/panels/cpu' },\n },\n {\n x: 0,\n y: 5,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n ],\n },\n },\n // No title,\n {\n kind: 'Grid',\n spec: {\n items: [\n {\n x: 0,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n {\n x: 8,\n y: 0,\n width: 8,\n height: 3,\n content: { $ref: '#/spec/panels/memory' },\n },\n ],\n },\n },\n // Collapsed\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'Disk Stats',\n collapse: {\n open: false,\n },\n },\n items: [\n {\n x: 18,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/filesystemFullness' },\n },\n ],\n },\n },\n ],\n },\n};\n\nexport default testDashboard;\n"],"names":["testDashboard","kind","metadata","name","project","createdAt","updatedAt","version","spec","duration","refreshInterval","variables","value","panels","cpu","display","plugin","format","unit","queries","query","memory","diskIO","filesystemFullness","layouts","title","collapse","open","items","x","y","width","height","content","$ref"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,MAAMA,gBAAmC;IACvCC,MAAM;IACNC,UAAU;QACRC,MAAM;QACNC,SAAS;QACTC,WAAW;QACXC,WAAW;QACXC,SAAS;IACX;IACAC,MAAM;QACJC,UAAU;QACVC,iBAAiB;QACjBC,WAAW;YACT;gBACEV,MAAM;gBACNO,MAAM;oBACJL,MAAM;oBACNS,OAAO;gBACT;YACF;YACA;gBACEX,MAAM;gBACNO,MAAM;oBACJL,MAAM;oBACNS,OAAO;gBACT;YACF;YACA;gBACEX,MAAM;gBACNO,MAAM;oBACJL,MAAM;oBACNS,OAAO;gBACT;YACF;SACD;QACDC,QAAQ;YACNC,KAAK;gBACHb,MAAM;gBACNO,MAAM;oBACJO,SAAS;wBAAEZ,MAAM;oBAAM;oBACvBa,QAAQ;wBACNf,MAAM;wBACNO,MAAM;4BACJS,QAAQ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oBAAsB;oBACvCa,QAAQ;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 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './panelUtils';\nexport * from './time';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './panelUtils';\nexport * from './time';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/panelUtils.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PanelDefinition } from '@perses-dev/core';\nimport { PanelGroupDefinition, PanelGroupItemLayout } from '../context';\nimport { GRID_LAYOUT_SMALL_BREAKPOINT, GRID_LAYOUT_COLS } from '../constants';\n\n// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present\nexport function getYForNewRow(group: PanelGroupDefinition) {\n let newRowY = 0;\n for (const layout of group.itemLayouts) {\n const itemMaxY = layout.y + layout.h;\n if (itemMaxY > newRowY) {\n newRowY = itemMaxY;\n }\n }\n return newRowY;\n}\n\ntype PanelGroupItemBounds = {\n /**\n * Left horizontal position.\n */\n x1: number;\n /**\n * Right horizontal position.\n */\n x2: number;\n /**\n * Top vertical position.\n */\n y1: number;\n /**\n * Bottom vertical position\n */\n y2: number;\n};\n\nfunction getPanelBounds({ x, y, w, h }: PanelGroupItemLayout): PanelGroupItemBounds {\n return {\n x1: x,\n x2: x + w,\n y1: y,\n y2: y + h,\n };\n}\n\nexport type UnpositionedPanelGroupItemLayout = Omit<PanelGroupItemLayout, 'x' | 'y'>;\n\n/**\n * Inserts a new panel into the layout with placement determined by a specified\n * reference panel. The new panel is placed:\n * - To the right of the reference panel if there is space available without\n * moving other panels.\n * - Otherwise, directly below the reference panel. If other panels are below\n * this location, they will also shift downward because the grid uses\n * vertical-based compacting.\n *\n * @param newLayout - Layout for new panel to insert into the grid.\n * @param referenceLayout - Layout for reference panel used to determine the\n * placement of the new panel.\n * @param itemLayouts - Full grid layout.\n * @returns - Item layouts modified to insert the new panel.\n */\nexport function insertPanelInLayout(\n newLayout: UnpositionedPanelGroupItemLayout,\n referenceLayout: PanelGroupItemLayout,\n itemLayouts: PanelGroupItemLayout[]\n): PanelGroupItemLayout[] {\n const MAX_LAYOUT_WIDTH = GRID_LAYOUT_COLS[GRID_LAYOUT_SMALL_BREAKPOINT];\n\n const referenceBounds = getPanelBounds(referenceLayout);\n\n // Organize layouts based on vertical relation to the item being inserted\n // after.\n const aboveInsertRow: PanelGroupItemLayout[] = [];\n const insertRow: PanelGroupItemLayout[] = [];\n const belowInsertRow: PanelGroupItemLayout[] = [];\n itemLayouts.forEach((itemLayout) => {\n const itemBounds = getPanelBounds(itemLayout);\n\n if (itemBounds.y2 <= referenceBounds.y1) {\n aboveInsertRow.push(itemLayout);\n } else if (itemBounds.y1 >= referenceBounds.y2) {\n belowInsertRow.push(itemLayout);\n } else {\n insertRow.push(itemLayout);\n }\n });\n\n // Cannot safely assume that the order of item layouts array is strictly\n // left to right. Sorting the row by horizontal position to more easily find\n // gaps.\n insertRow.sort((a, b) => a.x - b.x);\n const insertAfterIndex = insertRow.findIndex((item) => item.i === referenceLayout.i);\n\n if (insertAfterIndex === insertRow.length - 1) {\n // Insert to the right when space is available and the reference is the last\n // item in the row.\n if (referenceBounds.x2 + newLayout.w <= MAX_LAYOUT_WIDTH) {\n return [\n ...aboveInsertRow,\n ...insertRow,\n {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n },\n ...belowInsertRow,\n ];\n }\n } else if (insertAfterIndex >= 0) {\n const nextItem = insertRow[insertAfterIndex + 1];\n\n if (nextItem && getPanelBounds(nextItem).x1 - referenceBounds.x2 >= newLayout.w) {\n // Insert to the right when space is available between the reference and\n // the next item in the row.\n insertRow.splice(insertAfterIndex + 1, 0, {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n });\n\n return [...aboveInsertRow, ...insertRow, ...belowInsertRow];\n }\n }\n\n // Insert the new item below the original and shift the items below the\n // row where the reference is located.\n return [\n ...aboveInsertRow,\n ...insertRow,\n { x: referenceBounds.x1, y: referenceBounds.y2, ...newLayout },\n ...belowInsertRow.map((itemLayout) => {\n // Note: the grid will not necessarily display all of these items shifted\n // all the way down because of vertical compacting, but shifing their\n // y position ensures the new item gets vertical precedence over items\n // below it in that compacting.\n return { ...itemLayout, y: itemLayout.y + newLayout.h };\n }),\n ];\n}\n\n/**\n * Get a valid panel key, where a valid key:\n * - does not include invalid characters\n * - is unique\n */\nexport function getValidPanelKey(panelKey: string, panels: Record<string, PanelDefinition>): string {\n const uniquePanelKeys = getUniquePanelKeys(panels);\n let normalizedPanelKey = getPanelKeyParts(removeWhiteSpaces(panelKey)).name;\n\n const matchingKey = uniquePanelKeys[normalizedPanelKey];\n if (typeof matchingKey === 'number') {\n normalizedPanelKey += `-${matchingKey + 1}`;\n }\n return normalizedPanelKey;\n}\n\ntype PanelKeyParts = {\n name: string;\n number?: number;\n};\n\nconst removeWhiteSpaces = (str: string) => {\n return str.replace(/\\s+/g, '');\n};\n\n/**\n * Breaks the specified panel key into the name and the optional `-number` used\n * for deduping panels with the same name.\n */\nfunction getPanelKeyParts(panelKey: string): PanelKeyParts {\n const parts = panelKey.match(/(.+)-([0-9]+)/);\n if (parts && parts[1] && parts[2]) {\n return {\n name: parts[1],\n number: parseInt(parts[2], 10),\n };\n }\n\n return {\n name: panelKey,\n };\n}\n\n// Find all the unique panel keys and the largest number used for each.\n// ex: cpu, cpu-1, cpu-2 count as the same panel key since these panels have the same name\nfunction getUniquePanelKeys(panels: Record<string, PanelDefinition>): Record<string, number> {\n const uniquePanelKeys: Record<string, number> = {};\n Object.keys(panels).forEach((panelKey) => {\n const { name, number } = getPanelKeyParts(panelKey);\n if (uniquePanelKeys[name] === undefined) {\n uniquePanelKeys[name] = 0;\n }\n const currentValue = uniquePanelKeys[name];\n if (typeof currentValue === 'number' && number) {\n // Check for the maximum value because we cannot rely on a sequential\n // set of numbers when panels are modified.\n uniquePanelKeys[name] = Math.max(currentValue, number);\n }\n });\n return uniquePanelKeys;\n}\n"],"names":["GRID_LAYOUT_SMALL_BREAKPOINT","GRID_LAYOUT_COLS","getYForNewRow","group","newRowY","layout","itemLayouts","itemMaxY","y","h","getPanelBounds","x","w","x1","x2","y1","y2","insertPanelInLayout","newLayout","referenceLayout","MAX_LAYOUT_WIDTH","referenceBounds","aboveInsertRow","insertRow","belowInsertRow","forEach","itemLayout","itemBounds","push","sort","a","b","insertAfterIndex","findIndex","item","i","length","nextItem","splice","map","getValidPanelKey","panelKey","panels","uniquePanelKeys","getUniquePanelKeys","normalizedPanelKey","getPanelKeyParts","removeWhiteSpaces","name","matchingKey","str","replace","parts","match","number","parseInt","Object","keys","undefined","currentValue","Math","max"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,4BAA4B,EAAEC,gBAAgB,QAAQ,cAAc,CAAC;AAE9E,yHAAyH;AACzH,OAAO,SAASC,aAAa,CAACC,KAA2B,EAAE;IACzD,IAAIC,OAAO,GAAG,CAAC,AAAC;IAChB,KAAK,MAAMC,MAAM,IAAIF,KAAK,CAACG,WAAW,CAAE;QACtC,MAAMC,QAAQ,GAAGF,MAAM,CAACG,CAAC,GAAGH,MAAM,CAACI,CAAC,AAAC;QACrC,IAAIF,QAAQ,GAAGH,OAAO,EAAE;YACtBA,OAAO,GAAGG,QAAQ,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAOH,OAAO,CAAC;AACjB,CAAC;AAqBD,SAASM,cAAc,CAAC,EAAEC,CAAC,CAAA,EAAEH,CAAC,CAAA,EAAEI,CAAC,CAAA,EAAEH,CAAC,CAAA,EAAwB,EAAwB;IAClF,OAAO;QACLI,EAAE,EAAEF,CAAC;QACLG,EAAE,EAAEH,CAAC,GAAGC,CAAC;QACTG,EAAE,EAAEP,CAAC;QACLQ,EAAE,EAAER,CAAC,GAAGC,CAAC;KACV,CAA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AAA,EAAEM,MAAM,CAAA,EAAE,GAAGR,gBAAgB,CAACL,QAAQ,CAAC,AAAC;QACpD,IAAIE,eAAe,CAACK,IAAI,CAAC,KAAKU,SAAS,EAAE;YACvCf,eAAe,CAACK,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;QACD,MAAMW,YAAY,GAAGhB,eAAe,CAACK,IAAI,CAAC,AAAC;QAC3C,IAAI,OAAOW,YAAY,KAAK,QAAQ,IAAIL,MAAM,EAAE;YAC9C,qEAAqE;YACrE,2CAA2C;YAC3CX,eAAe,CAACK,IAAI,CAAC,GAAGY,IAAI,CAACC,GAAG,CAACF,YAAY,EAAEL,MAAM,CAAC,CAAC;QACzD,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAOX,eAAe,CAAC;AACzB,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/panelUtils.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PanelDefinition } from '@perses-dev/core';\nimport { PanelGroupDefinition, PanelGroupItemLayout } from '../context';\nimport { GRID_LAYOUT_SMALL_BREAKPOINT, GRID_LAYOUT_COLS } from '../constants';\n\n// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present\nexport function getYForNewRow(group: PanelGroupDefinition) {\n let newRowY = 0;\n for (const layout of group.itemLayouts) {\n const itemMaxY = layout.y + layout.h;\n if (itemMaxY > newRowY) {\n newRowY = itemMaxY;\n }\n }\n return newRowY;\n}\n\ntype PanelGroupItemBounds = {\n /**\n * Left horizontal position.\n */\n x1: number;\n /**\n * Right horizontal position.\n */\n x2: number;\n /**\n * Top vertical position.\n */\n y1: number;\n /**\n * Bottom vertical position\n */\n y2: number;\n};\n\nfunction getPanelBounds({ x, y, w, h }: PanelGroupItemLayout): PanelGroupItemBounds {\n return {\n x1: x,\n x2: x + w,\n y1: y,\n y2: y + h,\n };\n}\n\nexport type UnpositionedPanelGroupItemLayout = Omit<PanelGroupItemLayout, 'x' | 'y'>;\n\n/**\n * Inserts a new panel into the layout with placement determined by a specified\n * reference panel. The new panel is placed:\n * - To the right of the reference panel if there is space available without\n * moving other panels.\n * - Otherwise, directly below the reference panel. If other panels are below\n * this location, they will also shift downward because the grid uses\n * vertical-based compacting.\n *\n * @param newLayout - Layout for new panel to insert into the grid.\n * @param referenceLayout - Layout for reference panel used to determine the\n * placement of the new panel.\n * @param itemLayouts - Full grid layout.\n * @returns - Item layouts modified to insert the new panel.\n */\nexport function insertPanelInLayout(\n newLayout: UnpositionedPanelGroupItemLayout,\n referenceLayout: PanelGroupItemLayout,\n itemLayouts: PanelGroupItemLayout[]\n): PanelGroupItemLayout[] {\n const MAX_LAYOUT_WIDTH = GRID_LAYOUT_COLS[GRID_LAYOUT_SMALL_BREAKPOINT];\n\n const referenceBounds = getPanelBounds(referenceLayout);\n\n // Organize layouts based on vertical relation to the item being inserted\n // after.\n const aboveInsertRow: PanelGroupItemLayout[] = [];\n const insertRow: PanelGroupItemLayout[] = [];\n const belowInsertRow: PanelGroupItemLayout[] = [];\n itemLayouts.forEach((itemLayout) => {\n const itemBounds = getPanelBounds(itemLayout);\n\n if (itemBounds.y2 <= referenceBounds.y1) {\n aboveInsertRow.push(itemLayout);\n } else if (itemBounds.y1 >= referenceBounds.y2) {\n belowInsertRow.push(itemLayout);\n } else {\n insertRow.push(itemLayout);\n }\n });\n\n // Cannot safely assume that the order of item layouts array is strictly\n // left to right. Sorting the row by horizontal position to more easily find\n // gaps.\n insertRow.sort((a, b) => a.x - b.x);\n const insertAfterIndex = insertRow.findIndex((item) => item.i === referenceLayout.i);\n\n if (insertAfterIndex === insertRow.length - 1) {\n // Insert to the right when space is available and the reference is the last\n // item in the row.\n if (referenceBounds.x2 + newLayout.w <= MAX_LAYOUT_WIDTH) {\n return [\n ...aboveInsertRow,\n ...insertRow,\n {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n },\n ...belowInsertRow,\n ];\n }\n } else if (insertAfterIndex >= 0) {\n const nextItem = insertRow[insertAfterIndex + 1];\n\n if (nextItem && getPanelBounds(nextItem).x1 - referenceBounds.x2 >= newLayout.w) {\n // Insert to the right when space is available between the reference and\n // the next item in the row.\n insertRow.splice(insertAfterIndex + 1, 0, {\n ...newLayout,\n x: referenceBounds.x2,\n y: referenceBounds.y1,\n });\n\n return [...aboveInsertRow, ...insertRow, ...belowInsertRow];\n }\n }\n\n // Insert the new item below the original and shift the items below the\n // row where the reference is located.\n return [\n ...aboveInsertRow,\n ...insertRow,\n { x: referenceBounds.x1, y: referenceBounds.y2, ...newLayout },\n ...belowInsertRow.map((itemLayout) => {\n // Note: the grid will not necessarily display all of these items shifted\n // all the way down because of vertical compacting, but shifing their\n // y position ensures the new item gets vertical precedence over items\n // below it in that compacting.\n return { ...itemLayout, y: itemLayout.y + newLayout.h };\n }),\n ];\n}\n\n/**\n * Get a valid panel key, where a valid key:\n * - does not include invalid characters\n * - is unique\n */\nexport function getValidPanelKey(panelKey: string, panels: Record<string, PanelDefinition>): string {\n const uniquePanelKeys = getUniquePanelKeys(panels);\n let normalizedPanelKey = getPanelKeyParts(removeWhiteSpaces(panelKey)).name;\n\n const matchingKey = uniquePanelKeys[normalizedPanelKey];\n if (typeof matchingKey === 'number') {\n normalizedPanelKey += `-${matchingKey + 1}`;\n }\n return normalizedPanelKey;\n}\n\ntype PanelKeyParts = {\n name: string;\n number?: number;\n};\n\nconst removeWhiteSpaces = (str: string) => {\n return str.replace(/\\s+/g, '');\n};\n\n/**\n * Breaks the specified panel key into the name and the optional `-number` used\n * for deduping panels with the same name.\n */\nfunction getPanelKeyParts(panelKey: string): PanelKeyParts {\n const parts = panelKey.match(/(.+)-([0-9]+)/);\n if (parts && parts[1] && parts[2]) {\n return {\n name: parts[1],\n number: parseInt(parts[2], 10),\n };\n }\n\n return {\n name: panelKey,\n };\n}\n\n// Find all the unique panel keys and the largest number used for each.\n// ex: cpu, cpu-1, cpu-2 count as the same panel key since these panels have the same name\nfunction getUniquePanelKeys(panels: Record<string, PanelDefinition>): Record<string, number> {\n const uniquePanelKeys: Record<string, number> = {};\n Object.keys(panels).forEach((panelKey) => {\n const { name, number } = getPanelKeyParts(panelKey);\n if (uniquePanelKeys[name] === undefined) {\n uniquePanelKeys[name] = 0;\n }\n const currentValue = uniquePanelKeys[name];\n if (typeof currentValue === 'number' && number) {\n // Check for the maximum value because we cannot rely on a sequential\n // set of numbers when panels are modified.\n uniquePanelKeys[name] = Math.max(currentValue, number);\n }\n });\n return uniquePanelKeys;\n}\n"],"names":["GRID_LAYOUT_SMALL_BREAKPOINT","GRID_LAYOUT_COLS","getYForNewRow","group","newRowY","layout","itemLayouts","itemMaxY","y","h","getPanelBounds","x","w","x1","x2","y1","y2","insertPanelInLayout","newLayout","referenceLayout","MAX_LAYOUT_WIDTH","referenceBounds","aboveInsertRow","insertRow","belowInsertRow","forEach","itemLayout","itemBounds","push","sort","a","b","insertAfterIndex","findIndex","item","i","length","nextItem","splice","map","getValidPanelKey","panelKey","panels","uniquePanelKeys","getUniquePanelKeys","normalizedPanelKey","getPanelKeyParts","removeWhiteSpaces","name","matchingKey","str","replace","parts","match","number","parseInt","Object","keys","undefined","currentValue","Math","max"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,4BAA4B,EAAEC,gBAAgB,QAAQ,eAAe;AAE9E,yHAAyH;AACzH,OAAO,SAASC,cAA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AAE,IAAIA,KAAK,CAAC,EAAE,EAAE;QACjC,OAAO;YACLJ,MAAMI,KAAK,CAAC,EAAE;YACdE,QAAQC,SAASH,KAAK,CAAC,EAAE,EAAE;QAC7B;IACF;IAEA,OAAO;QACLJ,MAAMP;IACR;AACF;AAEA,uEAAuE;AACvE,0FAA0F;AAC1F,SAASG,mBAAmBF,MAAuC;IACjE,MAAMC,kBAA0C,CAAC;IACjDa,OAAOC,KAAKf,QAAQjB,QAAQ,CAACgB;QAC3B,MAAM,EAAEO,KAAI,EAAEM,OAAM,EAAE,GAAGR,iBAAiBL;QAC1C,IAAIE,eAAe,CAACK,KAAK,KAAKU,WAAW;YACvCf,eAAe,CAACK,KAAK,GAAG;QAC1B;QACA,MAAMW,eAAehB,eAAe,CAACK,KAAK;QAC1C,IAAI,OAAOW,iBAAiB,YAAYL,QAAQ;YAC9C,qEAAqE;YACrE,2CAA2C;YAC3CX,eAAe,CAACK,KAAK,GAAGY,KAAKC,IAAIF,cAAcL;QACjD;IACF;IACA,OAAOX;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/time.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { getSuggestedStepMs } from '@perses-dev/core';\nimport { useTimeRange } from '@perses-dev/plugin-system';\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number) {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n"],"names":["getSuggestedStepMs","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","undefined"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,kBAAkB,QAAQ,kBAAkB,CAAC;AACtD,SAASC,YAAY,QAAQ,2BAA2B,CAAC;AAEzD;;CAEC,GACD,OAAO,SAASC,kBAAkB,CAACC,KAAc,EAAE;IACjD,MAAM,EAAEC,iBAAiB,CAAA,EAAE,GAAGH,YAAY,EAAE,AAAC;IAC7C,IAAIE,KAAK,KAAKE,SAAS,EAAE,OAAO,CAAC,CAAC;IAClC,OAAOL,kBAAkB,CAACI,iBAAiB,EAAED,KAAK,CAAC,CAAC;AACtD,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/time.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { getSuggestedStepMs } from '@perses-dev/core';\nimport { useTimeRange } from '@perses-dev/plugin-system';\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number) {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n"],"names":["getSuggestedStepMs","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","undefined"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,kBAAkB,QAAQ,mBAAmB;AACtD,SAASC,YAAY,QAAQ,4BAA4B;AAEzD;;CAEC,GACD,OAAO,SAASC,mBAAmBC,KAAc;IAC/C,MAAM,EAAEC,kBAAiB,EAAE,GAAGH;IAC9B,IAAIE,UAAUE,WAAW,OAAO;IAChC,OAAOL,mBAAmBI,mBAAmBD;AAC/C"}
@@ -0,0 +1,2 @@
1
+ export * from './panel';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2023 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 './panel';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/validation/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './panel';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,UAAU"}
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ export declare const panelEditorValidationSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ groupId: z.ZodNumber;
5
+ description: z.ZodOptional<z.ZodString>;
6
+ type: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ name: string;
9
+ groupId: number;
10
+ type: string;
11
+ description?: string | undefined;
12
+ }, {
13
+ name: string;
14
+ groupId: number;
15
+ type: string;
16
+ description?: string | undefined;
17
+ }>;
18
+ export declare type PanelEditorValidationType = z.infer<typeof panelEditorValidationSchema>;
19
+ //# sourceMappingURL=panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/validation/panel.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;EAKtC,CAAC;AAEH,oBAAY,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ // Copyright 2023 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
+ import { z } from 'zod';
14
+ export const panelEditorValidationSchema = z.object({
15
+ name: z.string().nonempty('Required'),
16
+ groupId: z.number(),
17
+ description: z.string().optional(),
18
+ type: z.string().nonempty('Required')
19
+ });
20
+
21
+ //# sourceMappingURL=panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/validation/panel.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { z } from 'zod';\n\nexport const panelEditorValidationSchema = z.object({\n name: z.string().nonempty('Required'),\n groupId: z.number(),\n description: z.string().optional(),\n type: z.string().nonempty('Required'),\n});\n\nexport type PanelEditorValidationType = z.infer<typeof panelEditorValidationSchema>;\n"],"names":["z","panelEditorValidationSchema","object","name","string","nonempty","groupId","number","description","optional","type"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,8BAA8BD,EAAEE,OAAO;IAClDC,MAAMH,EAAEI,SAASC,SAAS;IAC1BC,SAASN,EAAEO;IACXC,aAAaR,EAAEI,SAASK;IACxBC,MAAMV,EAAEI,SAASC,SAAS;AAC5B,GAAG"}
@@ -10,6 +10,7 @@ export interface DashboardAppProps {
10
10
  onDiscard?: (entity: DashboardResource) => void;
11
11
  initialVariableIsSticky?: boolean;
12
12
  isReadonly: boolean;
13
+ isCreating?: boolean;
13
14
  }
14
15
  export declare const DashboardApp: (props: DashboardAppProps) => JSX.Element;
15
16
  //# sourceMappingURL=DashboardApp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAQL,mBAAmB,EAGpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAkE,MAAM,eAAe,CAAC;AAEhH,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAChD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBA6FpD,CAAC"}
1
+ {"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAQL,mBAAmB,EAGpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAkE,MAAM,eAAe,CAAC;AAEhH,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,uBAAuB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACtC,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAChD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBA8FpD,CAAC"}
@@ -17,7 +17,7 @@ import { ChartsProvider, ErrorAlert, ErrorBoundary, useChartsTheme } from '@pers
17
17
  import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog, DashboardDiscardChangesConfirmationDialog, DashboardToolbar, DeletePanelDialog, EditJsonDialog, SaveChangesConfirmationDialog } from '../../components';
18
18
  import { useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';
19
19
  export const DashboardApp = (props)=>{
20
- const { dashboardResource , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , } = props;
20
+ const { dashboardResource , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , isCreating } = props;
21
21
  const chartsTheme = useChartsTheme();
22
22
  const { setEditMode } = useEditMode();
23
23
  const { dashboard , setDashboard } = useDashboard();
@@ -95,7 +95,9 @@ export const DashboardApp = (props)=>{
95
95
  /*#__PURE__*/ _jsx(DeletePanelGroupDialog, {}),
96
96
  /*#__PURE__*/ _jsx(DeletePanelDialog, {}),
97
97
  /*#__PURE__*/ _jsx(DashboardDiscardChangesConfirmationDialog, {}),
98
- /*#__PURE__*/ _jsx(EditJsonDialog, {}),
98
+ /*#__PURE__*/ _jsx(EditJsonDialog, {
99
+ disableMetadataEdition: !isCreating
100
+ }),
99
101
  /*#__PURE__*/ _jsx(SaveChangesConfirmationDialog, {})
100
102
  ]
101
103
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ChartsProvider, ErrorAlert, ErrorBoundary, useChartsTheme } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n DashboardDiscardChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n EmptyDashboardProps,\n EditJsonDialog,\n SaveChangesConfirmationDialog,\n} from '../../components';\nimport { OnSaveDashboard, useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n emptyDashboardProps?: Partial<EmptyDashboardProps>;\n dashboardResource: DashboardResource;\n dashboardTitleComponent?: JSX.Element;\n onSave?: OnSaveDashboard;\n onDiscard?: (entity: DashboardResource) => void;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const {\n dashboardResource,\n dashboardTitleComponent,\n emptyDashboardProps,\n onSave,\n onDiscard,\n initialVariableIsSticky,\n isReadonly,\n } = props;\n\n const chartsTheme = useChartsTheme();\n\n const { setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<DashboardResource | undefined>(undefined);\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleDiscardChanges = () => {\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);\n }\n };\n\n const onEditButtonClick = () => {\n setEditMode(true);\n setOriginalDashboard(dashboard);\n };\n\n const onCancelButtonClick = () => {\n // check if dashboard has been modified\n if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {\n setEditMode(false);\n } else {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n handleDiscardChanges();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n });\n }\n };\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar\n dashboardName={dashboardResource.metadata.name}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n onSave={onSave}\n isReadonly={isReadonly}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ padding: (theme) => theme.spacing(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}>\n <PanelDrawer />\n </ChartsProvider>\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <DashboardDiscardChangesConfirmationDialog />\n <EditJsonDialog />\n <SaveChangesConfirmationDialog />\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ChartsProvider","ErrorAlert","ErrorBoundary","useChartsTheme","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","DashboardDiscardChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","EditJsonDialog","SaveChangesConfirmationDialog","useDashboard","useDiscardChangesConfirmationDialog","useEditMode","DashboardApp","props","dashboardResource","dashboardTitleComponent","emptyDashboardProps","onSave","onDiscard","initialVariableIsSticky","isReadonly","chartsTheme","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleDiscardChanges","onEditButtonClick","onCancelButtonClick","JSON","stringify","onDiscardChanges","onCancel","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","padding","theme","spacing","height","FallbackComponent","enablePinning"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,cAAc,EAAEC,UAAU,EAAEC,aAAa,EAAEC,cAAc,QAAQ,wBAAwB,CAAC;AAEnG,SACEC,WAAW,EACXC,SAAS,EACTC,gBAAgB,EAChBC,sBAAsB,EACtBC,yCAAyC,EACzCC,gBAAgB,EAChBC,iBAAiB,EAEjBC,cAAc,EACdC,6BAA6B,QACxB,kBAAkB,CAAC;AAC1B,SAA0BC,YAAY,EAAEC,mCAAmC,EAAEC,WAAW,QAAQ,eAAe,CAAC;AAYhH,OAAO,MAAMC,YAAY,GAAG,CAACC,KAAwB,GAAK;IACxD,MAAM,EACJC,iBAAiB,CAAA,EACjBC,uBAAuB,CAAA,EACvBC,mBAAmB,CAAA,EACnBC,MAAM,CAAA,EACNC,SAAS,CAAA,EACTC,uBAAuB,CAAA,EACvBC,UAAU,CAAA,IACX,GAAGP,KAAK,AAAC;IAEV,MAAMQ,WAAW,GAAGtB,cAAc,EAAE,AAAC;IAErC,MAAM,EAAEuB,WAAW,CAAA,EAAE,GAAGX,WAAW,EAAE,AAAC;IACtC,MAAM,EAAEY,SAAS,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGf,YAAY,EAAE,AAAC;IACnD,MAAM,CAACgB,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGhC,QAAQ,CAAgCiC,SAAS,CAAC,AAAC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B;gBAChDF,MAAM,EAAEA,MAAM;gBACdG,UAAU,EAAEA,UAAU;gBACtBW,iBAAiB,EAAEA,iBAAiB;gBACpCC,mBAAmB,EAAEA,mBAAmB;cACxC;0BACF,MAACrC,GAAG;gBAAC0C,EAAE,EAAE;oBAAES,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;oBAAEC,MAAM,EAAE,MAAM;iBAAE;;kCAC/D,KAACnD,aAAa;wBAACoD,iBAAiB,EAAErD,UAAU;kCAC1C,cAAA,KAACI,SAAS;4BACRe,mBAAmB,EAAE;gCACnBe,iBAAiB;gCACjB,GAAGf,mBAAmB;6BACvB;0BACD;sBACY;kCAChB,KAACpB,cAAc;wBAACyB,WAAW,EAAEA,WAAW;wBAAE8B,aAAa,EAAE,KAAK;kCAC5D,cAAA,KAACnD,WAAW,KAAG;sBACA;kCACjB,KAACE,gBAAgB,KAAG;kCACpB,KAACC,sBAAsB,KAAG;kCAC1B,KAACG,iBAAiB,KAAG;kCACrB,KAACF,yCAAyC,KAAG;kCAC7C,KAACG,cAAc,KAAG;kCAClB,KAACC,6BAA6B,KAAG;;cAC7B;;MACF,CACN;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { Box } from '@mui/material';\nimport { ChartsProvider, ErrorAlert, ErrorBoundary, useChartsTheme } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport {\n PanelDrawer,\n Dashboard,\n PanelGroupDialog,\n DeletePanelGroupDialog,\n DashboardDiscardChangesConfirmationDialog,\n DashboardToolbar,\n DeletePanelDialog,\n EmptyDashboardProps,\n EditJsonDialog,\n SaveChangesConfirmationDialog,\n} from '../../components';\nimport { OnSaveDashboard, useDashboard, useDiscardChangesConfirmationDialog, useEditMode } from '../../context';\n\nexport interface DashboardAppProps {\n emptyDashboardProps?: Partial<EmptyDashboardProps>;\n dashboardResource: DashboardResource;\n dashboardTitleComponent?: JSX.Element;\n onSave?: OnSaveDashboard;\n onDiscard?: (entity: DashboardResource) => void;\n initialVariableIsSticky?: boolean;\n isReadonly: boolean;\n isCreating?: boolean;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const {\n dashboardResource,\n dashboardTitleComponent,\n emptyDashboardProps,\n onSave,\n onDiscard,\n initialVariableIsSticky,\n isReadonly,\n isCreating,\n } = props;\n\n const chartsTheme = useChartsTheme();\n\n const { setEditMode } = useEditMode();\n const { dashboard, setDashboard } = useDashboard();\n const [originalDashboard, setOriginalDashboard] = useState<DashboardResource | undefined>(undefined);\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleDiscardChanges = () => {\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);\n }\n };\n\n const onEditButtonClick = () => {\n setEditMode(true);\n setOriginalDashboard(dashboard);\n };\n\n const onCancelButtonClick = () => {\n // check if dashboard has been modified\n if (JSON.stringify(dashboard) === JSON.stringify(originalDashboard)) {\n setEditMode(false);\n } else {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n handleDiscardChanges();\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n });\n }\n };\n\n return (\n <Box\n sx={{\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar\n dashboardName={dashboardResource.metadata.name}\n dashboardTitleComponent={dashboardTitleComponent}\n initialVariableIsSticky={initialVariableIsSticky}\n onSave={onSave}\n isReadonly={isReadonly}\n onEditButtonClick={onEditButtonClick}\n onCancelButtonClick={onCancelButtonClick}\n />\n <Box sx={{ padding: (theme) => theme.spacing(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}>\n <PanelDrawer />\n </ChartsProvider>\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n <DashboardDiscardChangesConfirmationDialog />\n <EditJsonDialog disableMetadataEdition={!isCreating} />\n <SaveChangesConfirmationDialog />\n </Box>\n </Box>\n );\n};\n"],"names":["useState","Box","ChartsProvider","ErrorAlert","ErrorBoundary","useChartsTheme","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","DashboardDiscardChangesConfirmationDialog","DashboardToolbar","DeletePanelDialog","EditJsonDialog","SaveChangesConfirmationDialog","useDashboard","useDiscardChangesConfirmationDialog","useEditMode","DashboardApp","props","dashboardResource","dashboardTitleComponent","emptyDashboardProps","onSave","onDiscard","initialVariableIsSticky","isReadonly","isCreating","chartsTheme","setEditMode","dashboard","setDashboard","originalDashboard","setOriginalDashboard","undefined","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleDiscardChanges","onEditButtonClick","onCancelButtonClick","JSON","stringify","onDiscardChanges","onCancel","sx","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","padding","theme","spacing","height","FallbackComponent","enablePinning","disableMetadataEdition"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EA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ACF;IACF;IAEA,qBACE,MAACnC;QACC2C,IAAI;YACFC,UAAU;YACVC,WAAW;YACXC,WAAW;YACXC,SAAS;YACTC,eAAe;QACjB;;0BAEA,KAACtC;gBACCuC,eAAe9B,kBAAkB+B,SAASC;gBAC1C/B,yBAAyBA;gBACzBI,yBAAyBA;gBACzBF,QAAQA;gBACRG,YAAYA;gBACZY,mBAAmBA;gBACnBC,qBAAqBA;;0BAEvB,MAACtC;gBAAI2C,IAAI;oBAAES,SAAS,CAACC,QAAUA,MAAMC,QAAQ;oBAAIC,QAAQ;gBAAO;;kCAC9D,KAACpD;wBAAcqD,mBAAmBtD;kCAChC,cAAA,KAACI;4BACCe,qBAAqB;gCACnBgB;gCACA,GAAGhB,mBAAmB;4BACxB;;;kCAGJ,KAACpB;wBAAe0B,aAAaA;wBAAa8B,eAAe;kCACvD,cAAA,KAACpD;;kCAEH,KAACE;kCACD,KAACC;kCACD,KAACG;kCACD,KAACF;kCACD,KAACG;wBAAe8C,wBAAwB,CAAChC;;kCACzC,KAACb;;;;;AAIT,EAAE"}
@@ -6,6 +6,7 @@ export interface ViewDashboardProps extends Omit<BoxProps, 'children'>, Dashboar
6
6
  datasourceApi: DatasourceStoreProviderProps['datasourceApi'];
7
7
  externalVariableDefinitions?: TemplateVariableProviderProps['externalVariableDefinitions'];
8
8
  isEditing?: boolean;
9
+ isCreating?: boolean;
9
10
  }
10
11
  /**
11
12
  * The View for displaying a Dashboard, along with the UI for selecting variable values.
@@ -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;AAI9C,OAAO,EAGL,4BAA4B,EAE5B,6BAA6B,EAC9B,MAAM,eAAe,CAAC;AACvB,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,6BAA6B,CAAC,6BAA6B,CAAC,CAAC;IAC3F,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eA+DtD"}
1
+ {"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAU9C,OAAO,EAGL,4BAA4B,EAE5B,6BAA6B,EAC9B,MAAM,eAAe,CAAC;AACvB,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,6BAA6B,CAAC,6BAA6B,CAAC,CAAC;IAC3F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eAsGtD"}
@@ -14,20 +14,60 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { DEFAULT_DASHBOARD_DURATION, DEFAULT_REFRESH_INTERVAL } from '@perses-dev/core';
16
16
  import { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';
17
- import { TimeRangeProvider, useInitialRefreshInterval, useInitialTimeRange } from '@perses-dev/plugin-system';
17
+ import { TimeRangeProvider, useInitialRefreshInterval, useInitialTimeRange, usePluginBuiltinVariableDefinitions } from '@perses-dev/plugin-system';
18
+ import { useMemo } from 'react';
18
19
  import { TemplateVariableProvider, DashboardProvider, DatasourceStoreProvider } from '../../context';
19
20
  import { DashboardApp } from './DashboardApp';
20
21
  /**
21
22
  * The View for displaying a Dashboard, along with the UI for selecting variable values.
22
23
  */ export function ViewDashboard(props) {
23
- const { dashboardResource , datasourceApi , externalVariableDefinitions , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , isEditing , sx , ...others } = props;
24
+ const { dashboardResource , datasourceApi , externalVariableDefinitions , dashboardTitleComponent , emptyDashboardProps , onSave , onDiscard , initialVariableIsSticky , isReadonly , isEditing , isCreating , sx , ...others } = props;
24
25
  const { spec } = dashboardResource;
25
- var _duration;
26
- const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : DEFAULT_DASHBOARD_DURATION;
27
- var _refreshInterval;
28
- const dashboardRefreshInterval = (_refreshInterval = spec.refreshInterval) !== null && _refreshInterval !== void 0 ? _refreshInterval : DEFAULT_REFRESH_INTERVAL;
26
+ var _spec_duration;
27
+ const dashboardDuration = (_spec_duration = spec.duration) !== null && _spec_duration !== void 0 ? _spec_duration : DEFAULT_DASHBOARD_DURATION;
28
+ var _spec_refreshInterval;
29
+ const dashboardRefreshInterval = (_spec_refreshInterval = spec.refreshInterval) !== null && _spec_refreshInterval !== void 0 ? _spec_refreshInterval : DEFAULT_REFRESH_INTERVAL;
29
30
  const initialTimeRange = useInitialTimeRange(dashboardDuration);
30
31
  const initialRefreshInterval = useInitialRefreshInterval(dashboardRefreshInterval);
32
+ const { data } = usePluginBuiltinVariableDefinitions();
33
+ const builtinVariables = useMemo(()=>{
34
+ const result = [
35
+ {
36
+ kind: 'BuiltinVariable',
37
+ spec: {
38
+ name: '__dashboard',
39
+ value: ()=>dashboardResource.metadata.name,
40
+ source: 'Dashboard',
41
+ display: {
42
+ name: '__dashboard',
43
+ description: 'The name of the current dashboard',
44
+ hidden: true
45
+ }
46
+ }
47
+ },
48
+ {
49
+ kind: 'BuiltinVariable',
50
+ spec: {
51
+ name: '__project',
52
+ value: ()=>dashboardResource.metadata.project,
53
+ source: 'Dashboard',
54
+ display: {
55
+ name: '__project',
56
+ description: 'The name of the current dashboard project',
57
+ hidden: true
58
+ }
59
+ }
60
+ }
61
+ ];
62
+ if (data) {
63
+ data.forEach((def)=>result.push(def));
64
+ }
65
+ return result;
66
+ }, [
67
+ dashboardResource.metadata.name,
68
+ dashboardResource.metadata.project,
69
+ data
70
+ ]);
31
71
  return /*#__PURE__*/ _jsx(DatasourceStoreProvider, {
32
72
  dashboardResource: dashboardResource,
33
73
  datasourceApi: datasourceApi,
@@ -43,6 +83,7 @@ import { DashboardApp } from './DashboardApp';
43
83
  children: /*#__PURE__*/ _jsx(TemplateVariableProvider, {
44
84
  initialVariableDefinitions: spec.variables,
45
85
  externalVariableDefinitions: externalVariableDefinitions,
86
+ builtinVariables: builtinVariables,
46
87
  children: /*#__PURE__*/ _jsx(Box, {
47
88
  sx: combineSx({
48
89
  display: 'flex',
@@ -61,7 +102,8 @@ import { DashboardApp } from './DashboardApp';
61
102
  onSave: onSave,
62
103
  onDiscard: onDiscard,
63
104
  initialVariableIsSticky: initialVariableIsSticky,
64
- isReadonly: isReadonly
105
+ isReadonly: isReadonly,
106
+ isCreating: isCreating
65
107
  })
66
108
  })
67
109
  })