@perses-dev/dashboards 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/dist/cjs/components/Dashboard.js +6 -11
  2. package/dist/cjs/components/DashboardToolbar.js +12 -6
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +7 -15
  4. package/dist/cjs/components/GridLayout/GridLayout.js +27 -22
  5. package/dist/cjs/components/GridLayout/GridTitle.js +27 -7
  6. package/dist/cjs/components/Panel/DeletePanelDialog.js +95 -0
  7. package/dist/cjs/components/Panel/Panel.js +12 -10
  8. package/dist/cjs/components/Panel/Panel.test.js +15 -6
  9. package/dist/cjs/components/Panel/PanelContent.js +3 -2
  10. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +13 -12
  11. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +9 -13
  12. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +87 -39
  13. package/dist/cjs/components/PanelDrawer/PanelPreview.js +54 -0
  14. package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +88 -0
  15. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +70 -118
  16. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +21 -36
  17. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
  18. package/dist/cjs/components/PanelGroupDialog/index.js +29 -0
  19. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +8 -11
  20. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +20 -13
  21. package/dist/cjs/components/Variables/Variable.js +20 -11
  22. package/dist/cjs/components/Variables/VariableEditor.js +240 -0
  23. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +236 -0
  24. package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
  25. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +88 -0
  26. package/dist/cjs/components/Variables/VariableList.js +49 -69
  27. package/dist/cjs/components/Variables/index.js +1 -0
  28. package/dist/cjs/components/index.js +1 -0
  29. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +82 -0
  30. package/dist/cjs/context/DashboardProvider/common.js +18 -0
  31. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +164 -0
  32. package/dist/cjs/context/DashboardProvider/index.js +29 -0
  33. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +175 -0
  34. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +102 -0
  35. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +208 -0
  36. package/dist/cjs/context/DatasourceStoreProvider.js +109 -7
  37. package/dist/cjs/context/TemplateVariableProvider.js +8 -1
  38. package/dist/cjs/context/TimeRangeProvider.js +20 -44
  39. package/dist/cjs/context/index.js +1 -3
  40. package/dist/cjs/context/useDashboardSpec.js +61 -0
  41. package/dist/cjs/index.js +1 -0
  42. package/dist/cjs/test/render.js +25 -5
  43. package/dist/cjs/test/setup-tests.js +4 -1
  44. package/dist/cjs/test/testDashboard.js +24 -11
  45. package/dist/cjs/utils/index.js +28 -0
  46. package/dist/cjs/utils/time-range-params.js +145 -0
  47. package/dist/cjs/views/ViewDashboard/DashboardApp.js +5 -8
  48. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -22
  49. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +114 -0
  50. package/dist/components/Dashboard.d.ts +1 -4
  51. package/dist/components/Dashboard.d.ts.map +1 -1
  52. package/dist/components/Dashboard.js +7 -12
  53. package/dist/components/Dashboard.js.map +1 -1
  54. package/dist/components/DashboardToolbar.d.ts.map +1 -1
  55. package/dist/components/DashboardToolbar.js +14 -8
  56. package/dist/components/DashboardToolbar.js.map +1 -1
  57. package/dist/components/GridLayout/GridItemContent.d.ts +2 -4
  58. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  59. package/dist/components/GridLayout/GridItemContent.js +7 -15
  60. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  61. package/dist/components/GridLayout/GridLayout.d.ts +2 -4
  62. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  63. package/dist/components/GridLayout/GridLayout.js +28 -23
  64. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  65. package/dist/components/GridLayout/GridTitle.d.ts +2 -1
  66. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  67. package/dist/components/GridLayout/GridTitle.js +28 -8
  68. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  69. package/dist/components/Panel/DeletePanelDialog.d.ts +5 -0
  70. package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -0
  71. package/dist/components/Panel/DeletePanelDialog.js +84 -0
  72. package/dist/components/Panel/DeletePanelDialog.js.map +1 -0
  73. package/dist/components/Panel/Panel.d.ts +2 -2
  74. package/dist/components/Panel/Panel.d.ts.map +1 -1
  75. package/dist/components/Panel/Panel.js +13 -11
  76. package/dist/components/Panel/Panel.js.map +1 -1
  77. package/dist/components/Panel/Panel.test.d.ts +1 -1
  78. package/dist/components/Panel/Panel.test.d.ts.map +1 -1
  79. package/dist/components/Panel/Panel.test.js +10 -6
  80. package/dist/components/Panel/Panel.test.js.map +1 -1
  81. package/dist/components/Panel/PanelContent.d.ts +4 -1
  82. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  83. package/dist/components/Panel/PanelContent.js +3 -2
  84. package/dist/components/Panel/PanelContent.js.map +1 -1
  85. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  86. package/dist/components/PanelDrawer/PanelDrawer.js +14 -13
  87. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  88. package/dist/components/PanelDrawer/PanelDrawer.test.js +9 -13
  89. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
  90. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +3 -3
  91. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  92. package/dist/components/PanelDrawer/PanelEditorForm.js +89 -41
  93. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  94. package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
  95. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
  96. package/dist/components/PanelDrawer/PanelPreview.js +48 -0
  97. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
  98. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +3 -0
  99. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
  100. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +77 -0
  101. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
  102. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +4 -2
  103. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  104. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +73 -119
  105. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  106. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +20 -35
  107. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
  108. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
  109. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
  110. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
  111. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
  112. package/dist/components/PanelGroupDialog/index.d.ts +3 -0
  113. package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
  114. package/dist/components/PanelGroupDialog/index.js +16 -0
  115. package/dist/components/PanelGroupDialog/index.js.map +1 -0
  116. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  117. package/dist/components/TimeRangeControls/TimeRangeControls.js +11 -14
  118. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  119. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +21 -14
  120. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  121. package/dist/components/Variables/Variable.js +22 -13
  122. package/dist/components/Variables/Variable.js.map +1 -1
  123. package/dist/components/Variables/VariableEditor.d.ts +8 -0
  124. package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
  125. package/dist/components/Variables/VariableEditor.js +229 -0
  126. package/dist/components/Variables/VariableEditor.js.map +1 -0
  127. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
  128. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
  129. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +225 -0
  130. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
  131. package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
  132. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
  133. package/dist/components/Variables/VariableEditorForm/index.js +15 -0
  134. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
  135. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +21 -0
  136. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
  137. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +76 -0
  138. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
  139. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  140. package/dist/components/Variables/VariableList.js +47 -72
  141. package/dist/components/Variables/VariableList.js.map +1 -1
  142. package/dist/components/Variables/index.d.ts +1 -0
  143. package/dist/components/Variables/index.d.ts.map +1 -1
  144. package/dist/components/Variables/index.js +1 -0
  145. package/dist/components/Variables/index.js.map +1 -1
  146. package/dist/components/index.d.ts +1 -0
  147. package/dist/components/index.d.ts.map +1 -1
  148. package/dist/components/index.js +1 -0
  149. package/dist/components/index.js.map +1 -1
  150. package/dist/context/DashboardProvider/DashboardProvider.d.ts +25 -0
  151. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
  152. package/dist/context/DashboardProvider/DashboardProvider.js +64 -0
  153. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
  154. package/dist/context/DashboardProvider/common.d.ts +5 -0
  155. package/dist/context/DashboardProvider/common.d.ts.map +1 -0
  156. package/dist/context/DashboardProvider/common.js +17 -0
  157. package/dist/context/DashboardProvider/common.js.map +1 -0
  158. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +74 -0
  159. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
  160. package/dist/context/DashboardProvider/dashboard-provider-api.js +163 -0
  161. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
  162. package/dist/context/DashboardProvider/index.d.ts +5 -0
  163. package/dist/context/DashboardProvider/index.d.ts.map +1 -0
  164. package/dist/context/DashboardProvider/index.js +16 -0
  165. package/dist/context/DashboardProvider/index.js.map +1 -0
  166. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +85 -0
  167. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
  168. package/dist/context/DashboardProvider/panel-editor-slice.js +171 -0
  169. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
  170. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +40 -0
  171. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
  172. package/dist/context/DashboardProvider/panel-group-editor-slice.js +96 -0
  173. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
  174. package/dist/context/DashboardProvider/panel-group-slice.d.ts +80 -0
  175. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
  176. package/dist/context/DashboardProvider/panel-group-slice.js +204 -0
  177. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
  178. package/dist/context/DatasourceStoreProvider.d.ts +10 -2
  179. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  180. package/dist/context/DatasourceStoreProvider.js +111 -9
  181. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  182. package/dist/context/TemplateVariableProvider.d.ts +2 -0
  183. package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
  184. package/dist/context/TemplateVariableProvider.js +8 -1
  185. package/dist/context/TemplateVariableProvider.js.map +1 -1
  186. package/dist/context/TimeRangeProvider.d.ts +9 -2
  187. package/dist/context/TimeRangeProvider.d.ts.map +1 -1
  188. package/dist/context/TimeRangeProvider.js +15 -43
  189. package/dist/context/TimeRangeProvider.js.map +1 -1
  190. package/dist/context/index.d.ts +1 -3
  191. package/dist/context/index.d.ts.map +1 -1
  192. package/dist/context/index.js +1 -3
  193. package/dist/context/index.js.map +1 -1
  194. package/dist/context/useDashboardSpec.d.ts +3 -0
  195. package/dist/context/useDashboardSpec.d.ts.map +1 -0
  196. package/dist/context/useDashboardSpec.js +55 -0
  197. package/dist/context/useDashboardSpec.js.map +1 -0
  198. package/dist/index.d.ts +1 -0
  199. package/dist/index.d.ts.map +1 -1
  200. package/dist/index.js +1 -0
  201. package/dist/index.js.map +1 -1
  202. package/dist/test/plugin-registry.d.ts +2 -2
  203. package/dist/test/plugin-registry.d.ts.map +1 -1
  204. package/dist/test/plugin-registry.js.map +1 -1
  205. package/dist/test/render.d.ts +2 -1
  206. package/dist/test/render.d.ts.map +1 -1
  207. package/dist/test/render.js +25 -5
  208. package/dist/test/render.js.map +1 -1
  209. package/dist/test/setup-tests.d.ts.map +1 -1
  210. package/dist/test/setup-tests.js +4 -0
  211. package/dist/test/setup-tests.js.map +1 -1
  212. package/dist/test/testDashboard.d.ts.map +1 -1
  213. package/dist/test/testDashboard.js +24 -11
  214. package/dist/test/testDashboard.js.map +1 -1
  215. package/dist/utils/index.d.ts +2 -0
  216. package/dist/utils/index.d.ts.map +1 -0
  217. package/dist/utils/index.js +15 -0
  218. package/dist/utils/index.js.map +1 -0
  219. package/dist/utils/time-range-params.d.ts +25 -0
  220. package/dist/utils/time-range-params.d.ts.map +1 -0
  221. package/dist/utils/time-range-params.js +137 -0
  222. package/dist/utils/time-range-params.js.map +1 -0
  223. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  224. package/dist/views/ViewDashboard/DashboardApp.js +6 -9
  225. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  226. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  227. package/dist/views/ViewDashboard/ViewDashboard.js +5 -22
  228. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  229. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
  230. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
  231. package/dist/views/ViewDashboard/tests/panelGroups.test.js +107 -0
  232. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
  233. package/package.json +5 -4
  234. package/dist/cjs/components/PanelDrawer/PanelSpecEditor.js +0 -40
  235. package/dist/cjs/components/PanelDrawer/PanelTypeSelect.js +0 -38
  236. package/dist/cjs/components/PanelDrawer/panel-editor-model.js +0 -140
  237. package/dist/cjs/context/DashboardAppSlice.js +0 -57
  238. package/dist/cjs/context/DashboardProvider.js +0 -128
  239. package/dist/cjs/context/LayoutsSlice.js +0 -55
  240. package/dist/cjs/context/QueryStringProvider.js +0 -89
  241. package/dist/components/PanelDrawer/PanelSpecEditor.d.ts +0 -7
  242. package/dist/components/PanelDrawer/PanelSpecEditor.d.ts.map +0 -1
  243. package/dist/components/PanelDrawer/PanelSpecEditor.js +0 -34
  244. package/dist/components/PanelDrawer/PanelSpecEditor.js.map +0 -1
  245. package/dist/components/PanelDrawer/PanelTypeSelect.d.ts +0 -8
  246. package/dist/components/PanelDrawer/PanelTypeSelect.d.ts.map +0 -1
  247. package/dist/components/PanelDrawer/PanelTypeSelect.js +0 -34
  248. package/dist/components/PanelDrawer/PanelTypeSelect.js.map +0 -1
  249. package/dist/components/PanelDrawer/panel-editor-model.d.ts +0 -27
  250. package/dist/components/PanelDrawer/panel-editor-model.d.ts.map +0 -1
  251. package/dist/components/PanelDrawer/panel-editor-model.js +0 -133
  252. package/dist/components/PanelDrawer/panel-editor-model.js.map +0 -1
  253. package/dist/context/DashboardAppSlice.d.ts +0 -26
  254. package/dist/context/DashboardAppSlice.d.ts.map +0 -1
  255. package/dist/context/DashboardAppSlice.js +0 -45
  256. package/dist/context/DashboardAppSlice.js.map +0 -1
  257. package/dist/context/DashboardProvider.d.ts +0 -36
  258. package/dist/context/DashboardProvider.d.ts.map +0 -1
  259. package/dist/context/DashboardProvider.js +0 -107
  260. package/dist/context/DashboardProvider.js.map +0 -1
  261. package/dist/context/LayoutsSlice.d.ts +0 -12
  262. package/dist/context/LayoutsSlice.d.ts.map +0 -1
  263. package/dist/context/LayoutsSlice.js +0 -43
  264. package/dist/context/LayoutsSlice.js.map +0 -1
  265. package/dist/context/QueryStringProvider.d.ts +0 -13
  266. package/dist/context/QueryStringProvider.d.ts.map +0 -1
  267. package/dist/context/QueryStringProvider.js +0 -40
  268. package/dist/context/QueryStringProvider.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/time-range-params.ts"],"sourcesContent":["// Copyright 2022 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 { useMemo, useCallback, useState } from 'react';\nimport { useQueryParams, QueryParamConfig } from 'use-query-params';\nimport { getUnixTime, isDate } from 'date-fns';\nimport {\n TimeRangeValue,\n isRelativeTimeRange,\n isDurationString,\n DurationString,\n AbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { TimeRange } from '@perses-dev/plugin-system';\n\nexport type TimeOptionValue = Date | DurationString | null | undefined;\n\n/* Interprets an encoded string and returns either the string or null/undefined if not available */\nfunction getEncodedValue(\n input: string | Array<string | null> | null | undefined,\n allowEmptyString?: boolean\n): string | null | undefined {\n if (input == null) {\n return input;\n }\n // '' or []\n if (input.length === 0 && (!allowEmptyString || (allowEmptyString && input !== ''))) {\n return null;\n }\n\n const str = input instanceof Array ? input[0] : input;\n if (str == null) {\n return str;\n }\n if (!allowEmptyString && str === '') {\n return null;\n }\n\n return str;\n}\n\n/* Encodes individual TimeRangeValue as a string, depends on whether start is relative or absolute */\nexport function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined {\n if (!timeOptionValue) {\n return timeOptionValue;\n }\n\n if (typeof timeOptionValue === 'string') {\n if (isDurationString(timeOptionValue)) {\n return timeOptionValue;\n }\n }\n return (getUnixTime(timeOptionValue) * 1000).toString();\n}\n\n/* Converts param input to supported relative or absolute time range format */\nexport function decodeTimeRangeValue(\n input: string | Array<string | null> | null | undefined\n): Date | DurationString | null | undefined {\n const paramString = getEncodedValue(input);\n if (paramString == null) return paramString;\n return isDurationString(paramString) ? paramString : new Date(Number(paramString));\n}\n\n/**\n * Custom TimeRangeValue param type\n * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types\n */\nexport const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue> = {\n encode: encodeTimeRangeValue,\n decode: decodeTimeRangeValue,\n equals: (valueA: TimeOptionValue, valueB: TimeOptionValue) => {\n if (valueA === valueB) return true;\n if (valueA == null || valueB == null) return valueA === valueB;\n return valueA.valueOf() === valueB.valueOf();\n },\n};\n\nexport const timeRangeQueryConfig = {\n start: TimeRangeParam,\n end: TimeRangeParam,\n};\n\n/**\n * Gets the initial time range taking into account URL params and dashboard JSON duration\n * Sets start query param if it is empty on page load\n */\nexport function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue {\n const [query] = useQueryParams(timeRangeQueryConfig);\n const { start, end } = query;\n return useMemo(() => {\n let initialTimeRange: TimeRangeValue = { pastDuration: dashboardDuration };\n if (!start) {\n return initialTimeRange;\n }\n const startStr = start.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = { pastDuration: startStr };\n } else if (isDate(start) && isDate(end)) {\n initialTimeRange = { start: start, end: end } as AbsoluteTimeRange;\n }\n return initialTimeRange;\n }, [start, end, dashboardDuration]);\n}\n\n/**\n * Returns time range getter and setter, set paramsEnabled to false to disable query string serialization\n */\nexport function useSetTimeRangeParams(initialTimeRange: TimeRangeValue, paramsEnabled = true): TimeRange {\n const [query, setQuery] = useQueryParams(timeRangeQueryConfig);\n\n // fallback when app does not want query string as source of truth\n const [timeRangeState, setTimeRangeState] = useState<TimeRangeValue>(initialTimeRange);\n\n const { start } = query;\n\n // set start param on page load if empty\n if (paramsEnabled && !start) {\n if (isRelativeTimeRange(initialTimeRange)) {\n setQuery({ start: initialTimeRange.pastDuration, end: undefined });\n }\n }\n\n const setTimeRange: TimeRange['setTimeRange'] = useCallback(\n (value: TimeRangeValue) => {\n if (isRelativeTimeRange(value)) {\n setQuery({ start: value.pastDuration, end: undefined });\n } else {\n setQuery(value);\n }\n },\n [setQuery]\n );\n\n if (!paramsEnabled) {\n return { timeRange: timeRangeState, setTimeRange: setTimeRangeState };\n }\n return { timeRange: initialTimeRange, setTimeRange: setTimeRange };\n}\n"],"names":["useMemo","useCallback","useState","useQueryParams","getUnixTime","isDate","isRelativeTimeRange","isDurationString","getEncodedValue","input","allowEmptyString","length","str","Array","encodeTimeRangeValue","timeOptionValue","toString","decodeTimeRangeValue","paramString","Date","Number","TimeRangeParam","encode","decode","equals","valueA","valueB","valueOf","timeRangeQueryConfig","start","end","useInitialTimeRange","dashboardDuration","query","initialTimeRange","pastDuration","startStr","useSetTimeRangeParams","paramsEnabled","setQuery","timeRangeState","setTimeRangeState","undefined","setTimeRange","value","timeRange"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;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EY,SAAS;aAAE,CAAC,CAAC;QAC1D,OAAO;YACLH,QAAQ,CAACK,KAAK,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,EACD;QAACL,QAAQ;KAAC,CACX,AAAC;IAEF,IAAI,CAACD,aAAa,EAAE;QAClB,OAAO;YAAEO,SAAS,EAAEL,cAAc;YAAEG,YAAY,EAAEF,iBAAiB;SAAE,CAAC;IACxE,CAAC;IACD,OAAO;QAAEI,SAAS,EAAEX,gBAAgB;QAAES,YAAY,EAAEA,YAAY;KAAE,CAAC;AACrE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,iBAAiB,CAAC;CACtC;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAyBpD,CAAC"}
1
+ {"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAKrD,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,iBAAiB,CAAC;CACtC;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAyBpD,CAAC"}
@@ -13,14 +13,11 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
16
- import { PanelDrawer, Dashboard } from '../../components';
17
- import PanelGroupDialog from '../../components/PanelGroupDialog/PanelGroupDialog';
16
+ import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog } from '../../components';
18
17
  import { DashboardToolbar } from '../../components/DashboardToolbar';
19
- import { useDashboard, useDashboardApp } from '../../context';
18
+ import DeletePanelDialog from '../../components/Panel/DeletePanelDialog';
20
19
  export const DashboardApp = (props)=>{
21
20
  const { dashboardResource } = props;
22
- const { dashboard } = useDashboard();
23
- const { panelGroupDialog } = useDashboardApp();
24
21
  return /*#__PURE__*/ _jsxs(Box, {
25
22
  sx: {
26
23
  padding: (theme)=>theme.spacing(1, 0),
@@ -41,12 +38,12 @@ export const DashboardApp = (props)=>{
41
38
  children: [
42
39
  /*#__PURE__*/ _jsx(ErrorBoundary, {
43
40
  FallbackComponent: ErrorAlert,
44
- children: /*#__PURE__*/ _jsx(Dashboard, {
45
- spec: dashboard
46
- })
41
+ children: /*#__PURE__*/ _jsx(Dashboard, {})
47
42
  }),
48
43
  /*#__PURE__*/ _jsx(PanelDrawer, {}),
49
- panelGroupDialog && /*#__PURE__*/ _jsx(PanelGroupDialog, {})
44
+ /*#__PURE__*/ _jsx(PanelGroupDialog, {}),
45
+ /*#__PURE__*/ _jsx(DeletePanelGroupDialog, {}),
46
+ /*#__PURE__*/ _jsx(DeletePanelDialog, {})
50
47
  ]
51
48
  })
52
49
  ]
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport { PanelDrawer, Dashboard } from '../../components';\nimport PanelGroupDialog from '../../components/PanelGroupDialog/PanelGroupDialog';\nimport { DashboardToolbar } from '../../components/DashboardToolbar';\nimport { useDashboard, useDashboardApp } from '../../context';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const { dashboardResource } = props;\n const { dashboard } = useDashboard();\n const { panelGroupDialog } = useDashboardApp();\n return (\n <Box\n sx={{\n padding: (theme) => theme.spacing(1, 0),\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar dashboardName={dashboardResource.metadata.name} />\n <Box sx={{ padding: (theme) => theme.spacing(2) }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard spec={dashboard} />\n </ErrorBoundary>\n <PanelDrawer />\n {panelGroupDialog && <PanelGroupDialog />}\n </Box>\n </Box>\n );\n};\n"],"names":["Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DashboardToolbar","useDashboard","useDashboardApp","DashboardApp","props","dashboardResource","dashboard","panelGroupDialog","sx","padding","theme","spacing","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","FallbackComponent","spec"],"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,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AAEnE,SAASC,WAAW,EAAEC,SAAS,QAAQ,kBAAkB,CAAC;AAC1D,OAAOC,gBAAgB,MAAM,oDAAoD,CAAC;AAClF,SAASC,gBAAgB,QAAQ,mCAAmC,CAAC;AACrE,SAASC,YAAY,EAAEC,eAAe,QAAQ,eAAe,CAAC;AAM9D,OAAO,MAAMC,YAAY,GAAG,CAACC,KAAwB,GAAK;IACxD,MAAM,EAAEC,iBAAiB,CAAA,EAAE,GAAGD,KAAK,AAAC;IACpC,MAAM,EAAEE,SAAS,CAAA,EAAE,GAAGL,YAAY,EAAE,AAAC;IACrC,MAAM,EAAEM,gBAAgB,CAAA,EAAE,GAAGL,eAAe,EAAE,AAAC;IAC/C,qBACE,MAACR,GAAG;QACFc,EAAE,EAAE;YACFC,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;YACvCC,QAAQ,EAAE,CAAC;YACXC,SAAS,EAAE,QAAQ;YACnBC,SAAS,EAAE,MAAM;YACjBC,OAAO,EAAE,MAAM;YACfC,aAAa,EAAE,QAAQ;SACxB;;0BAED,KAAChB,gBAAgB;gBAACiB,aAAa,EAAEZ,iBAAiB,CAACa,QAAQ,CAACC,IAAI;cAAI;0BACpE,MAACzB,GAAG;gBAACc,EAAE,EAAE;oBAAEC,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;iBAAE;;kCAC/C,KAACf,aAAa;wBAACwB,iBAAiB,EAAEzB,UAAU;kCAC1C,cAAA,KAACG,SAAS;4BAACuB,IAAI,EAAEf,SAAS;0BAAI;sBAChB;kCAChB,KAACT,WAAW,KAAG;oBACdU,gBAAgB,kBAAI,KAACR,gBAAgB,KAAG;;cACrC;;MACF,CACN;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog } from '../../components';\nimport { DashboardToolbar } from '../../components/DashboardToolbar';\nimport DeletePanelDialog from '../../components/Panel/DeletePanelDialog';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const { dashboardResource } = props;\n return (\n <Box\n sx={{\n padding: (theme) => theme.spacing(1, 0),\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar dashboardName={dashboardResource.metadata.name} />\n <Box sx={{ padding: (theme) => theme.spacing(2) }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard />\n </ErrorBoundary>\n <PanelDrawer />\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n </Box>\n </Box>\n );\n};\n"],"names":["Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","DashboardToolbar","DeletePanelDialog","DashboardApp","props","dashboardResource","sx","padding","theme","spacing","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","FallbackComponent"],"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,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AAEnE,SAASC,WAAW,EAAEC,SAAS,EAAEC,gBAAgB,EAAEC,sBAAsB,QAAQ,kBAAkB,CAAC;AACpG,SAASC,gBAAgB,QAAQ,mCAAmC,CAAC;AACrE,OAAOC,iBAAiB,MAAM,0CAA0C,CAAC;AAMzE,OAAO,MAAMC,YAAY,GAAG,CAACC,KAAwB,GAAK;IACxD,MAAM,EAAEC,iBAAiB,CAAA,EAAE,GAAGD,KAAK,AAAC;IACpC,qBACE,MAACV,GAAG;QACFY,EAAE,EAAE;YACFC,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;YACvCC,QAAQ,EAAE,CAAC;YACXC,SAAS,EAAE,QAAQ;YACnBC,SAAS,EAAE,MAAM;YACjBC,OAAO,EAAE,MAAM;YACfC,aAAa,EAAE,QAAQ;SACxB;;0BAED,KAACb,gBAAgB;gBAACc,aAAa,EAAEV,iBAAiB,CAACW,QAAQ,CAACC,IAAI;cAAI;0BACpE,MAACvB,GAAG;gBAACY,EAAE,EAAE;oBAAEC,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;iBAAE;;kCAC/C,KAACb,aAAa;wBAACsB,iBAAiB,EAAEvB,UAAU;kCAC1C,cAAA,KAACG,SAAS,KAAG;sBACC;kCAChB,KAACD,WAAW,KAAG;kCACf,KAACE,gBAAgB,KAAG;kCACpB,KAACC,sBAAsB,KAAG;kCAC1B,KAACE,iBAAiB,KAAG;;cACjB;;MACF,CACN;AACJ,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAuB,MAAM,kBAAkB,CAAC;AAG1E,OAAO,EAIL,4BAA4B,EAE7B,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;IACpE,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,CAAC;CAC9D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eA8CtD"}
1
+ {"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAIL,4BAA4B,EAE7B,MAAM,eAAe,CAAC;AAIvB,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;IACpE,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,CAAC;CAC9D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eAkCtD"}
@@ -11,38 +11,20 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import { useEffect } from 'react';
15
14
  import { Box } from '@mui/material';
16
- import { getDefaultTimeRange } from '@perses-dev/core';
17
- import { useQueryString } from '@perses-dev/plugin-system';
18
15
  import { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';
19
16
  import { TimeRangeProvider, TemplateVariableProvider, DashboardProvider, DatasourceStoreProvider } from '../../context';
17
+ import { useInitialTimeRange, useSetTimeRangeParams } from '../../utils';
20
18
  import { DashboardApp } from './DashboardApp';
21
19
  /**
22
20
  * The View for displaying a Dashboard, along with the UI for selecting variable values.
23
21
  */ export function ViewDashboard(props) {
24
22
  const { dashboardResource , datasourceApi , sx , ...others } = props;
25
23
  const { spec } = dashboardResource;
26
- const { queryString , setQueryString } = useQueryString();
27
24
  var _duration;
28
25
  const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : '1h';
29
- const defaultTimeRange = getDefaultTimeRange(dashboardDuration, queryString);
30
- // TODO: add reusable sync query string or no-op util
31
- useEffect(()=>{
32
- const currentParams = Object.fromEntries([
33
- ...queryString
34
- ]);
35
- // if app does not provide query string implementation, setTimeRange is used instead
36
- if (!currentParams.start && setQueryString) {
37
- // default to duration in dashboard definition if start param is not already set
38
- queryString.set('start', dashboardDuration);
39
- setQueryString(queryString);
40
- }
41
- }, [
42
- dashboardDuration,
43
- queryString,
44
- setQueryString
45
- ]);
26
+ const initialTimeRange = useInitialTimeRange(dashboardDuration);
27
+ const { timeRange , setTimeRange } = useSetTimeRangeParams(initialTimeRange, true);
46
28
  return /*#__PURE__*/ _jsx(DatasourceStoreProvider, {
47
29
  dashboardResource: dashboardResource,
48
30
  datasourceApi: datasourceApi,
@@ -51,7 +33,8 @@ import { DashboardApp } from './DashboardApp';
51
33
  dashboardSpec: spec
52
34
  },
53
35
  children: /*#__PURE__*/ _jsx(TimeRangeProvider, {
54
- initialTimeRange: defaultTimeRange,
36
+ timeRange: timeRange,
37
+ setTimeRange: setTimeRange,
55
38
  children: /*#__PURE__*/ _jsx(TemplateVariableProvider, {
56
39
  initialVariableDefinitions: spec.variables,
57
40
  children: /*#__PURE__*/ _jsx(Box, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"sourcesContent":["// Copyright 2022 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 { useEffect } from 'react';\nimport { Box, BoxProps } from '@mui/material';\nimport { DashboardResource, getDefaultTimeRange } from '@perses-dev/core';\nimport { useQueryString } from '@perses-dev/plugin-system';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport {\n TimeRangeProvider,\n TemplateVariableProvider,\n DashboardProvider,\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n} from '../../context';\nimport { DashboardApp } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'> {\n dashboardResource: DashboardResource;\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps) {\n const { dashboardResource, datasourceApi, sx, ...others } = props;\n const { spec } = dashboardResource;\n\n const { queryString, setQueryString } = useQueryString();\n const dashboardDuration = spec.duration ?? '1h';\n const defaultTimeRange = getDefaultTimeRange(dashboardDuration, queryString);\n\n // TODO: add reusable sync query string or no-op util\n useEffect(() => {\n const currentParams = Object.fromEntries([...queryString]);\n // if app does not provide query string implementation, setTimeRange is used instead\n if (!currentParams.start && setQueryString) {\n // default to duration in dashboard definition if start param is not already set\n queryString.set('start', dashboardDuration);\n setQueryString(queryString);\n }\n }, [dashboardDuration, queryString, setQueryString]);\n\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProvider initialState={{ dashboardSpec: spec }}>\n <TimeRangeProvider initialTimeRange={defaultTimeRange}>\n <TemplateVariableProvider initialVariableDefinitions={spec.variables}>\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp dashboardResource={dashboardResource} />\n </ErrorBoundary>\n </Box>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n </DashboardProvider>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["useEffect","Box","getDefaultTimeRange","useQueryString","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProvider","TemplateVariableProvider","DashboardProvider","DatasourceStoreProvider","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","sx","others","spec","queryString","setQueryString","dashboardDuration","duration","defaultTimeRange","currentParams","Object","fromEntries","start","set","initialState","dashboardSpec","initialTimeRange","initialVariableDefinitions","variables","display","width","height","position","overflow","FallbackComponent"],"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,SAAS,QAAQ,OAAO,CAAC;AAClC,SAASC,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAA4BC,mBAAmB,QAAQ,kBAAkB,CAAC;AAC1E,SAASC,cAAc,QAAQ,2BAA2B,CAAC;AAC3D,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAC9E,SACEC,iBAAiB,EACjBC,wBAAwB,EACxBC,iBAAiB,EAEjBC,uBAAuB,QAClB,eAAe,CAAC;AACvB,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAO9C;;CAEC,GACD,OAAO,SAASC,aAAa,CAACC,KAAyB,EAAE;IACvD,MAAM,EAAEC,iBAAiB,CAAA,EAAEC,aAAa,CAAA,EAAEC,EAAE,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGJ,KAAK,AAAC;IAClE,MAAM,EAAEK,IAAI,CAAA,EAAE,GAAGJ,iBAAiB,AAAC;IAEnC,MAAM,EAAEK,WAAW,CAAA,EAAEC,cAAc,CAAA,EAAE,GAAGjB,cAAc,EAAE,AAAC;QAC/Be,SAAa;IAAvC,MAAMG,iBAAiB,GAAGH,CAAAA,SAAa,GAAbA,IAAI,CAACI,QAAQ,cAAbJ,SAAa,cAAbA,SAAa,GAAI,IAAI,AAAC;IAChD,MAAMK,gBAAgB,GAAGrB,mBAAmB,CAACmB,iBAAiB,EAAEF,WAAW,CAAC,AAAC;IAE7E,qDAAqD;IACrDnB,SAAS,CAAC,IAAM;QACd,MAAMwB,aAAa,GAAGC,MAAM,CAACC,WAAW,CAAC;eAAIP,WAAW;SAAC,CAAC,AAAC;QAC3D,oFAAoF;QACpF,IAAI,CAACK,aAAa,CAACG,KAAK,IAAIP,cAAc,EAAE;YAC1C,gFAAgF;YAChFD,WAAW,CAACS,GAAG,CAAC,OAAO,EAAEP,iBAAiB,CAAC,CAAC;YAC5CD,cAAc,CAACD,WAAW,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,EAAE;QAACE,iBAAiB;QAAEF,WAAW;QAAEC,cAAc;KAAC,CAAC,CAAC;IAErD,qBACE,KAACV,uBAAuB;QAACI,iBAAiB,EAAEA,iBAAiB;QAAEC,aAAa,EAAEA,aAAa;kBACzF,cAAA,KAACN,iBAAiB;YAACoB,YAAY,EAAE;gBAAEC,aAAa,EAAEZ,IAAI;aAAE;sBACtD,cAAA,KAACX,iBAAiB;gBAACwB,gBAAgB,EAAER,gBAAgB;0BACnD,cAAA,KAACf,wBAAwB;oBAACwB,0BAA0B,EAAEd,IAAI,CAACe,SAAS;8BAClE,cAAA,KAAChC,GAAG;wBACFe,EAAE,EAAEV,SAAS,CACX;4BACE4B,OAAO,EAAE,MAAM;4BACfC,KAAK,EAAE,MAAM;4BACbC,MAAM,EAAE,MAAM;4BACdC,QAAQ,EAAE,UAAU;4BACpBC,QAAQ,EAAE,QAAQ;yBACnB,EACDtB,EAAE,CACH;wBACA,GAAGC,MAAM;kCAEV,cAAA,KAACb,aAAa;4BAACmC,iBAAiB,EAAElC,UAAU;sCAC1C,cAAA,KAACM,YAAY;gCAACG,iBAAiB,EAAEA,iBAAiB;8BAAI;0BACxC;sBACZ;kBACmB;cACT;UACF;MACI,CAC1B;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { DashboardResource } from '@perses-dev/core';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport {\n TimeRangeProvider,\n TemplateVariableProvider,\n DashboardProvider,\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n} from '../../context';\nimport { useInitialTimeRange, useSetTimeRangeParams } from '../../utils';\nimport { DashboardApp } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'> {\n dashboardResource: DashboardResource;\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps) {\n const { dashboardResource, datasourceApi, sx, ...others } = props;\n const { spec } = dashboardResource;\n const dashboardDuration = spec.duration ?? '1h';\n const initialTimeRange = useInitialTimeRange(dashboardDuration);\n const { timeRange, setTimeRange } = useSetTimeRangeParams(initialTimeRange, true);\n\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProvider initialState={{ dashboardSpec: spec }}>\n <TimeRangeProvider timeRange={timeRange} setTimeRange={setTimeRange}>\n <TemplateVariableProvider initialVariableDefinitions={spec.variables}>\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp dashboardResource={dashboardResource} />\n </ErrorBoundary>\n </Box>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n </DashboardProvider>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProvider","TemplateVariableProvider","DashboardProvider","DatasourceStoreProvider","useInitialTimeRange","useSetTimeRangeParams","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","sx","others","spec","dashboardDuration","duration","initialTimeRange","timeRange","setTimeRange","initialState","dashboardSpec","initialVariableDefinitions","variables","display","width","height","position","overflow","FallbackComponent"],"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,GAAG,QAAkB,eAAe,CAAC;AAE9C,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAC9E,SACEC,iBAAiB,EACjBC,wBAAwB,EACxBC,iBAAiB,EAEjBC,uBAAuB,QAClB,eAAe,CAAC;AACvB,SAASC,mBAAmB,EAAEC,qBAAqB,QAAQ,aAAa,CAAC;AACzE,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAO9C;;CAEC,GACD,OAAO,SAASC,aAAa,CAACC,KAAyB,EAAE;IACvD,MAAM,EAAEC,iBAAiB,CAAA,EAAEC,aAAa,CAAA,EAAEC,EAAE,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGJ,KAAK,AAAC;IAClE,MAAM,EAAEK,IAAI,CAAA,EAAE,GAAGJ,iBAAiB,AAAC;QACTI,SAAa;IAAvC,MAAMC,iBAAiB,GAAGD,CAAAA,SAAa,GAAbA,IAAI,CAACE,QAAQ,cAAbF,SAAa,cAAbA,SAAa,GAAI,IAAI,AAAC;IAChD,MAAMG,gBAAgB,GAAGZ,mBAAmB,CAACU,iBAAiB,CAAC,AAAC;IAChE,MAAM,EAAEG,SAAS,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGb,qBAAqB,CAACW,gBAAgB,EAAE,IAAI,CAAC,AAAC;IAElF,qBACE,KAACb,uBAAuB;QAACM,iBAAiB,EAAEA,iBAAiB;QAAEC,aAAa,EAAEA,aAAa;kBACzF,cAAA,KAACR,iBAAiB;YAACiB,YAAY,EAAE;gBAAEC,aAAa,EAAEP,IAAI;aAAE;sBACtD,cAAA,KAACb,iBAAiB;gBAACiB,SAAS,EAAEA,SAAS;gBAAEC,YAAY,EAAEA,YAAY;0BACjE,cAAA,KAACjB,wBAAwB;oBAACoB,0BAA0B,EAAER,IAAI,CAACS,SAAS;8BAClE,cAAA,KAAC1B,GAAG;wBACFe,EAAE,EAAEZ,SAAS,CACX;4BACEwB,OAAO,EAAE,MAAM;4BACfC,KAAK,EAAE,MAAM;4BACbC,MAAM,EAAE,MAAM;4BACdC,QAAQ,EAAE,UAAU;4BACpBC,QAAQ,EAAE,QAAQ;yBACnB,EACDhB,EAAE,CACH;wBACA,GAAGC,MAAM;kCAEV,cAAA,KAACf,aAAa;4BAAC+B,iBAAiB,EAAE9B,UAAU;sCAC1C,cAAA,KAACQ,YAAY;gCAACG,iBAAiB,EAAEA,iBAAiB;8BAAI;0BACxC;sBACZ;kBACmB;cACT;UACF;MACI,CAC1B;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=panelGroups.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panelGroups.test.d.ts","sourceRoot":"","sources":["../../../../src/views/ViewDashboard/tests/panelGroups.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,107 @@
1
+ // Copyright 2022 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 { jsx as _jsx } from "react/jsx-runtime";
14
+ import { screen } from '@testing-library/react';
15
+ import userEvent from '@testing-library/user-event';
16
+ import { DashboardProvider, TemplateVariableProvider, TimeRangeProvider } from '../../../context';
17
+ import { getTestDashboard, renderWithContext } from '../../../test';
18
+ import { DashboardApp } from '../DashboardApp';
19
+ describe('Panel Groups', ()=>{
20
+ const renderDashboard = ()=>{
21
+ renderWithContext(/*#__PURE__*/ _jsx(TimeRangeProvider, {
22
+ timeRange: {
23
+ pastDuration: '30m'
24
+ },
25
+ children: /*#__PURE__*/ _jsx(TemplateVariableProvider, {
26
+ children: /*#__PURE__*/ _jsx(DashboardProvider, {
27
+ initialState: {
28
+ dashboardSpec: getTestDashboard().spec,
29
+ isEditMode: true
30
+ },
31
+ children: /*#__PURE__*/ _jsx(DashboardApp, {
32
+ dashboardResource: getTestDashboard()
33
+ })
34
+ })
35
+ })
36
+ }));
37
+ };
38
+ it('should delete panel', ()=>{
39
+ renderDashboard();
40
+ const panel = screen.getByText('CPU');
41
+ userEvent.hover(panel);
42
+ const deletePanelButton = screen.getByLabelText('delete panel');
43
+ userEvent.click(deletePanelButton);
44
+ screen.getByText('Delete Panel');
45
+ const deleteButton = screen.getByText('Delete');
46
+ userEvent.click(deleteButton);
47
+ // The panel should disappear
48
+ const deletedPanel = screen.queryByText('CPU');
49
+ expect(deletedPanel).not.toBeInTheDocument();
50
+ });
51
+ it('should only delete panel from panel group if panel is not referenced more than once', ()=>{
52
+ renderDashboard();
53
+ const panels = screen.getAllByText('Disk I/O Utilization');
54
+ expect(panels).toHaveLength(2);
55
+ const panel = panels[0];
56
+ if (panel === undefined) throw new Error('Missing panel');
57
+ userEvent.hover(panel);
58
+ const deletePanelButton = screen.getByLabelText('delete panel');
59
+ userEvent.click(deletePanelButton);
60
+ screen.getByText('Delete Panel');
61
+ const deleteButton = screen.getByText('Delete');
62
+ userEvent.click(deleteButton);
63
+ // The deleted panel should still be on screen in the other group
64
+ const deletedPanel = screen.queryByText('Disk I/O Utilization');
65
+ expect(deletedPanel).toBeInTheDocument();
66
+ });
67
+ it('should swap panels', ()=>{
68
+ renderDashboard();
69
+ // should move panel down
70
+ const group1 = screen.getByText('CPU Stats');
71
+ userEvent.hover(group1);
72
+ const moveGroupDownBtn = screen.getByLabelText('move group down');
73
+ userEvent.click(moveGroupDownBtn);
74
+ userEvent.unhover(moveGroupDownBtn);
75
+ // should move panel up
76
+ const group2 = screen.getByText('Disk Stats');
77
+ userEvent.hover(group2);
78
+ const moveGroupUpBtn = screen.getByLabelText('move group up');
79
+ userEvent.click(moveGroupUpBtn);
80
+ /* TODO: Figure out how to test this visually without coupling to the store
81
+ const layouts = storeApi.getState().layouts;
82
+ expect(layouts[0]?.title).toBe(undefined);
83
+ expect(layouts[1]?.title).toBe('Disk Stats');
84
+ expect(layouts[2]?.title).toBe('CPU Stats');
85
+ */ });
86
+ it('should delete a panel group', ()=>{
87
+ renderDashboard();
88
+ const group = screen.getByText('CPU Stats');
89
+ userEvent.hover(group);
90
+ const deleteGroupIcon = screen.getByLabelText('delete group');
91
+ userEvent.click(deleteGroupIcon);
92
+ screen.getByText('Delete Panel Group');
93
+ const deleteButton = screen.getByText('Delete');
94
+ userEvent.click(deleteButton);
95
+ // should remove group
96
+ const deletedGroup = screen.queryByText('CPU Stats');
97
+ expect(deletedGroup).not.toBeInTheDocument();
98
+ // CPU panel should be completely gone since it wasn't in any other group
99
+ let panel = screen.queryByText('CPU');
100
+ expect(panel).not.toBeInTheDocument();
101
+ // A DiskIO panel should still be present in the other group that wasn't deleted
102
+ panel = screen.queryByText('Disk I/O Utilization');
103
+ expect(panel).toBeInTheDocument();
104
+ });
105
+ });
106
+
107
+ //# sourceMappingURL=panelGroups.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/views/ViewDashboard/tests/panelGroups.test.tsx"],"sourcesContent":["// Copyright 2022 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 { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { DashboardProvider, TemplateVariableProvider, TimeRangeProvider } from '../../../context';\nimport { getTestDashboard, renderWithContext } from '../../../test';\nimport { DashboardApp } from '../DashboardApp';\n\ndescribe('Panel Groups', () => {\n const renderDashboard = () => {\n renderWithContext(\n <TimeRangeProvider timeRange={{ pastDuration: '30m' }}>\n <TemplateVariableProvider>\n <DashboardProvider initialState={{ dashboardSpec: getTestDashboard().spec, isEditMode: true }}>\n <DashboardApp dashboardResource={getTestDashboard()} />\n </DashboardProvider>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n );\n };\n it('should delete panel', () => {\n renderDashboard();\n const panel = screen.getByText('CPU');\n userEvent.hover(panel);\n const deletePanelButton = screen.getByLabelText('delete panel');\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The panel should disappear\n const deletedPanel = screen.queryByText('CPU');\n expect(deletedPanel).not.toBeInTheDocument();\n });\n\n it('should only delete panel from panel group if panel is not referenced more than once', () => {\n renderDashboard();\n\n const panels = screen.getAllByText('Disk I/O Utilization');\n expect(panels).toHaveLength(2);\n\n const panel = panels[0];\n if (panel === undefined) throw new Error('Missing panel');\n\n userEvent.hover(panel);\n const deletePanelButton = screen.getByLabelText('delete panel');\n userEvent.click(deletePanelButton);\n screen.getByText('Delete Panel');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // The deleted panel should still be on screen in the other group\n const deletedPanel = screen.queryByText('Disk I/O Utilization');\n expect(deletedPanel).toBeInTheDocument();\n });\n\n it('should swap panels', () => {\n renderDashboard();\n\n // should move panel down\n const group1 = screen.getByText('CPU Stats');\n userEvent.hover(group1);\n const moveGroupDownBtn = screen.getByLabelText('move group down');\n userEvent.click(moveGroupDownBtn);\n userEvent.unhover(moveGroupDownBtn);\n\n // should move panel up\n const group2 = screen.getByText('Disk Stats');\n userEvent.hover(group2);\n const moveGroupUpBtn = screen.getByLabelText('move group up');\n userEvent.click(moveGroupUpBtn);\n\n /* TODO: Figure out how to test this visually without coupling to the store\n const layouts = storeApi.getState().layouts;\n expect(layouts[0]?.title).toBe(undefined);\n expect(layouts[1]?.title).toBe('Disk Stats');\n expect(layouts[2]?.title).toBe('CPU Stats');\n */\n });\n\n it('should delete a panel group', () => {\n renderDashboard();\n const group = screen.getByText('CPU Stats');\n userEvent.hover(group);\n const deleteGroupIcon = screen.getByLabelText('delete group');\n userEvent.click(deleteGroupIcon);\n screen.getByText('Delete Panel Group');\n const deleteButton = screen.getByText('Delete');\n userEvent.click(deleteButton);\n\n // should remove group\n const deletedGroup = screen.queryByText('CPU Stats');\n expect(deletedGroup).not.toBeInTheDocument();\n\n // CPU panel should be completely gone since it wasn't in any other group\n let panel = screen.queryByText('CPU');\n expect(panel).not.toBeInTheDocument();\n\n // A DiskIO panel should still be present in the other group that wasn't deleted\n panel = screen.queryByText('Disk I/O Utilization');\n expect(panel).toBeInTheDocument();\n });\n});\n"],"names":["screen","userEvent","DashboardProvider","TemplateVariableProvider","TimeRangeProvider","getTestDashboard","renderWithContext","DashboardApp","describe","renderDashboard","timeRange","pastDuration","initialState","dashboardSpec","spec","isEditMode","dashboardResource","it","panel","getByText","hover","deletePanelButton","getByLabelText","click","deleteButton","deletedPanel","queryByText","expect","not","toBeInTheDocument","panels","getAllByText","toHaveLength","undefined","Error","group1","moveGroupDownBtn","unhover","group2","moveGroupUpBtn","group","deleteGroupIcon","deletedGroup"],"mappings":"AAAA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AAM,CAACe,YAAY,CAAC,CAACd,GAAG,CAACC,iBAAiB,EAAE,CAAC;QAE7C,yEAAyE;QACzE,IAAIX,KAAK,GAAGlB,MAAM,CAAC0B,WAAW,CAAC,KAAK,CAAC,AAAC;QACtCC,MAAM,CAACT,KAAK,CAAC,CAACU,GAAG,CAACC,iBAAiB,EAAE,CAAC;QAEtC,gFAAgF;QAChFX,KAAK,GAAGlB,MAAM,CAAC0B,WAAW,CAAC,sBAAsB,CAAC,CAAC;QACnDC,MAAM,CAACT,KAAK,CAAC,CAACW,iBAAiB,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "The dashboards feature in Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -27,9 +27,9 @@
27
27
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
28
28
  },
29
29
  "dependencies": {
30
- "@perses-dev/components": "^0.9.0",
31
- "@perses-dev/core": "^0.9.0",
32
- "@perses-dev/plugin-system": "^0.9.0",
30
+ "@perses-dev/components": "^0.11.0",
31
+ "@perses-dev/core": "^0.11.0",
32
+ "@perses-dev/plugin-system": "^0.11.0",
33
33
  "@types/react-grid-layout": "^1.3.2",
34
34
  "date-fns": "^2.28.0",
35
35
  "immer": "^9.0.15",
@@ -37,6 +37,7 @@
37
37
  "react-grid-layout": "^1.3.4",
38
38
  "react-intersection-observer": "^9.4.0",
39
39
  "use-immer": "^0.7.0",
40
+ "use-query-params": "^2.1.1",
40
41
  "use-resize-observer": "^9.0.0",
41
42
  "zustand": "^4.1.1"
42
43
  },
@@ -1,40 +0,0 @@
1
- // Copyright 2022 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "PanelSpecEditor", {
18
- enumerable: true,
19
- get: ()=>PanelSpecEditor
20
- });
21
- const _jsxRuntime = require("react/jsx-runtime");
22
- const _pluginSystem = require("@perses-dev/plugin-system");
23
- function PanelSpecEditor(props) {
24
- const { panelPluginKind , ...others } = props;
25
- const { data: plugin , isLoading } = (0, _pluginSystem.usePlugin)('Panel', panelPluginKind, {
26
- useErrorBoundary: true,
27
- enabled: panelPluginKind !== ''
28
- });
29
- // TODO: Proper loading indicator
30
- if (isLoading) {
31
- return null;
32
- }
33
- if (plugin === undefined) {
34
- throw new Error(`Missing OptionsEditorComponent for Panel plugin with kind '${panelPluginKind}'`);
35
- }
36
- const { OptionsEditorComponent } = plugin;
37
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(OptionsEditorComponent, {
38
- ...others
39
- });
40
- }
@@ -1,38 +0,0 @@
1
- // Copyright 2022 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "PanelTypeSelect", {
18
- enumerable: true,
19
- get: ()=>PanelTypeSelect
20
- });
21
- const _jsxRuntime = require("react/jsx-runtime");
22
- const _material = require("@mui/material");
23
- const _pluginSystem = require("@perses-dev/plugin-system");
24
- function PanelTypeSelect(props) {
25
- const { value: propValue , ...others } = props;
26
- const { data , isLoading } = (0, _pluginSystem.useListPluginMetadata)('Panel');
27
- // Pass an empty value while options are still loading so MUI doesn't complain about us using an "out of range" value
28
- const value = propValue !== '' && isLoading ? '' : propValue;
29
- // TODO: Does this need a loading indicator of some kind?
30
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Select, {
31
- ...others,
32
- value: value,
33
- children: data === null || data === void 0 ? void 0 : data.map((metadata)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
34
- value: metadata.kind,
35
- children: metadata.display.name
36
- }, metadata.kind))
37
- });
38
- }
@@ -1,140 +0,0 @@
1
- // Copyright 2022 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- usePanelDrawerModel: ()=>usePanelDrawerModel,
25
- usePanelSpecState: ()=>usePanelSpecState
26
- });
27
- const _react = require("react");
28
- const _pluginSystem = require("@perses-dev/plugin-system");
29
- const _useImmer = require("use-immer");
30
- const _context = require("../../context");
31
- const _functions = require("../../utils/functions");
32
- function usePanelDrawerModel() {
33
- const { panelDrawer } = (0, _context.useDashboardApp)();
34
- const { panels , updatePanel } = (0, _context.usePanels)();
35
- // If we're closed, no model to return
36
- if (panelDrawer === undefined) {
37
- return undefined;
38
- }
39
- // If we don't have a panel key, we're adding a new panel
40
- const { panelKey , groupIndex } = panelDrawer;
41
- if (panelKey === undefined) {
42
- return {
43
- drawerTitle: 'Add Panel',
44
- submitButtonText: 'Add',
45
- initialValues: {
46
- name: '',
47
- description: '',
48
- group: groupIndex !== null && groupIndex !== void 0 ? groupIndex : 0,
49
- kind: '',
50
- spec: {}
51
- },
52
- applyChanges: (values)=>{
53
- const { name , description , group , kind , spec } = values;
54
- const panelKey = (0, _functions.removeWhiteSpacesAndSpecialCharacters)(name);
55
- updatePanel(panelKey, {
56
- kind: 'Panel',
57
- spec: {
58
- display: {
59
- name,
60
- description
61
- },
62
- plugin: {
63
- kind,
64
- spec
65
- }
66
- }
67
- }, group);
68
- }
69
- };
70
- }
71
- // Otherwise we have a panel key, so we're trying to edit an existing panel
72
- const existingPanel = panels[panelKey];
73
- // TODO: Can we better express this via the type system on the dashboard store to avoid these states?
74
- if (existingPanel === undefined) {
75
- throw new Error(`Cannot find existing panel '${panelKey}' to edit`);
76
- }
77
- if (groupIndex === undefined) {
78
- throw new Error(`Cannot edit existing panel '${panelKey}' without its group index`);
79
- }
80
- var _description;
81
- return {
82
- drawerTitle: 'Edit Panel',
83
- submitButtonText: 'Apply',
84
- initialValues: {
85
- name: existingPanel.spec.display.name,
86
- description: (_description = existingPanel.spec.display.description) !== null && _description !== void 0 ? _description : '',
87
- group: groupIndex,
88
- kind: existingPanel.spec.plugin.kind,
89
- spec: existingPanel.spec.plugin.spec
90
- },
91
- applyChanges: (values)=>{
92
- const { name , description , group , kind , spec } = values;
93
- updatePanel(panelKey, {
94
- kind: 'Panel',
95
- spec: {
96
- display: {
97
- name,
98
- description
99
- },
100
- plugin: {
101
- kind,
102
- spec
103
- }
104
- }
105
- });
106
- if (group !== groupIndex) {
107
- // TO DO: need to move panel if panel group changes
108
- }
109
- }
110
- };
111
- }
112
- function usePanelSpecState(panelPluginKind, initialState) {
113
- // Keeping track of spec values by kind allows users to switch between panel types and come back with their old
114
- // values intact from before the switch
115
- const [specByKind, setSpecByKind] = (0, _useImmer.useImmer)({
116
- [panelPluginKind]: initialState
117
- });
118
- const { data: plugin } = (0, _pluginSystem.usePlugin)('Panel', panelPluginKind, {
119
- enabled: panelPluginKind !== ''
120
- });
121
- const pluginInitialSpec = (0, _react.useMemo)(()=>{
122
- return plugin === null || plugin === void 0 ? void 0 : plugin.createInitialOptions();
123
- }, [
124
- plugin
125
- ]);
126
- var _panelPluginKind;
127
- // Use the value in specByKind or if unset, use the initial values from the plugin (which could still be undefined)
128
- const spec = (_panelPluginKind = specByKind[panelPluginKind]) !== null && _panelPluginKind !== void 0 ? _panelPluginKind : pluginInitialSpec;
129
- // TODO: Do we want to expose more of a immer style API to plugin authors for managing their state, rather than the
130
- // current "onChange" API?
131
- const onSpecChange = (next)=>{
132
- setSpecByKind((draft)=>{
133
- draft[panelPluginKind] = next;
134
- });
135
- };
136
- return {
137
- spec,
138
- onSpecChange
139
- };
140
- }
@@ -1,57 +0,0 @@
1
- // Copyright 2022 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- createDashboardAppSlice: ()=>createDashboardAppSlice,
25
- useDashboardApp: ()=>useDashboardApp
26
- });
27
- const _immer = require("zustand/middleware/immer");
28
- const _dashboardProvider = require("./DashboardProvider");
29
- const createDashboardAppSlice = (0, _immer.immer)((set)=>({
30
- openPanelDrawer: ({ groupIndex , panelKey })=>set((state)=>{
31
- state.panelDrawer = {
32
- groupIndex,
33
- panelKey
34
- };
35
- }),
36
- closePanelDrawer: ()=>set((state)=>{
37
- state.panelDrawer = undefined;
38
- }),
39
- openPanelGroupDialog: (groupIndex)=>set((state)=>{
40
- state.panelGroupDialog = {
41
- groupIndex
42
- };
43
- }),
44
- closePanelGroupDialog: ()=>set((state)=>{
45
- state.panelGroupDialog = undefined;
46
- })
47
- }));
48
- function useDashboardApp() {
49
- return (0, _dashboardProvider.useDashboardStore)(({ panelDrawer , openPanelDrawer , closePanelDrawer , panelGroupDialog , openPanelGroupDialog , closePanelGroupDialog , })=>({
50
- panelDrawer,
51
- openPanelDrawer,
52
- closePanelDrawer,
53
- panelGroupDialog,
54
- openPanelGroupDialog,
55
- closePanelGroupDialog
56
- }));
57
- }