@perses-dev/dashboards 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatter-chart-embed-8efdfab

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 (336) hide show
  1. package/dist/cjs/components/AddGroupButton/AddGroupButton.js +10 -7
  2. package/dist/cjs/components/AddGroupButton/index.js +10 -8
  3. package/dist/cjs/components/AddPanelButton/AddPanelButton.js +10 -11
  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 +53 -22
  8. package/dist/cjs/components/DashboardStickyToolbar/index.js +10 -8
  9. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +81 -102
  10. package/dist/cjs/components/DashboardToolbar/index.js +10 -8
  11. package/dist/cjs/components/Datasources/DatasourceEditor.js +237 -0
  12. package/dist/cjs/components/Datasources/EditDatasourcesButton.js +106 -0
  13. package/dist/cjs/components/Datasources/index.js +31 -0
  14. package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +12 -10
  15. package/dist/cjs/components/DeletePanelDialog/index.js +10 -8
  16. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +17 -15
  17. package/dist/cjs/components/DeletePanelGroupDialog/index.js +10 -8
  18. package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +5 -3
  19. package/dist/cjs/components/DiscardChangesConfirmationDialog/index.js +10 -8
  20. package/dist/cjs/components/DownloadButton/DownloadButton.js +12 -10
  21. package/dist/cjs/components/DownloadButton/index.js +10 -8
  22. package/dist/cjs/components/EditButton/EditButton.js +8 -6
  23. package/dist/cjs/components/EditButton/index.js +10 -8
  24. package/dist/cjs/components/EditJsonButton/EditJsonButton.js +15 -11
  25. package/dist/cjs/components/EditJsonButton/index.js +10 -8
  26. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +46 -24
  27. package/dist/cjs/components/EditJsonDialog/index.js +10 -8
  28. package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +18 -16
  29. package/dist/cjs/components/EmptyDashboard/index.js +10 -8
  30. package/dist/cjs/components/GridLayout/GridContainer.js +5 -3
  31. package/dist/cjs/components/GridLayout/GridItemContent.js +33 -14
  32. package/dist/cjs/components/GridLayout/GridLayout.js +18 -16
  33. package/dist/cjs/components/GridLayout/GridTitle.js +35 -33
  34. package/dist/cjs/components/GridLayout/index.js +13 -11
  35. package/dist/cjs/components/Panel/Panel.js +18 -22
  36. package/dist/cjs/components/Panel/PanelContent.js +11 -8
  37. package/dist/cjs/components/Panel/PanelHeader.js +33 -31
  38. package/dist/cjs/components/Panel/index.js +10 -8
  39. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +25 -77
  40. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +231 -141
  41. package/dist/cjs/components/PanelDrawer/PanelPreview.js +11 -9
  42. package/dist/cjs/components/PanelDrawer/index.js +11 -8
  43. package/dist/cjs/components/PanelDrawer/usePanelEditor.js +3 -1
  44. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +18 -16
  45. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +15 -11
  46. package/dist/cjs/components/PanelGroupDialog/index.js +10 -8
  47. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +47 -45
  48. package/dist/cjs/components/QuerySummaryTable/index.js +10 -8
  49. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +23 -21
  50. package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +10 -8
  51. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +8 -8
  52. package/dist/cjs/components/SaveDashboardButton/index.js +10 -8
  53. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +46 -19
  54. package/dist/cjs/components/TimeRangeControls/index.js +10 -8
  55. package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +5 -3
  56. package/dist/cjs/components/ToolbarIconButton/index.js +10 -8
  57. package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +140 -0
  58. package/dist/cjs/components/Variables/EditVariablesButton.js +17 -15
  59. package/dist/cjs/components/Variables/TemplateVariable.js +250 -105
  60. package/dist/cjs/components/Variables/VariableEditor.js +280 -204
  61. package/dist/cjs/components/Variables/VariableList.js +23 -21
  62. package/dist/cjs/components/Variables/index.js +14 -11
  63. package/dist/cjs/components/index.js +32 -29
  64. package/dist/cjs/constants/grid-layout-config.js +6 -2
  65. package/dist/cjs/constants/index.js +12 -9
  66. package/dist/cjs/constants/styles.js +42 -0
  67. package/dist/cjs/constants/user-interface-text.js +9 -2
  68. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +43 -35
  69. package/dist/cjs/context/DashboardProvider/common.js +6 -2
  70. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +70 -38
  71. package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +3 -1
  72. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +5 -3
  73. package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +3 -1
  74. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +3 -1
  75. package/dist/cjs/context/DashboardProvider/edit-json-dialog-slice.js +3 -1
  76. package/dist/cjs/context/DashboardProvider/index.js +12 -10
  77. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +13 -11
  78. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +8 -6
  79. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +15 -7
  80. package/dist/cjs/context/DashboardProvider/panel-slice.js +3 -1
  81. package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +3 -1
  82. package/dist/cjs/context/DatasourceStoreProvider.js +167 -46
  83. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +141 -34
  84. package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +12 -10
  85. package/dist/cjs/context/TemplateVariableProvider/index.js +10 -8
  86. package/dist/cjs/context/TemplateVariableProvider/query-params.js +17 -7
  87. package/dist/cjs/context/TemplateVariableProvider/utils.js +15 -7
  88. package/dist/cjs/context/index.js +13 -11
  89. package/dist/cjs/context/useDashboard.js +12 -8
  90. package/dist/cjs/index.js +12 -10
  91. package/dist/cjs/stories/decorators/WithDashboard.js +6 -4
  92. package/dist/cjs/stories/decorators/WithDatasourceStore.js +6 -4
  93. package/dist/cjs/stories/decorators/WithTemplateVariables.js +6 -4
  94. package/dist/cjs/stories/decorators/constants.js +5 -3
  95. package/dist/cjs/stories/decorators/index.js +13 -11
  96. package/dist/cjs/test/dashboard-provider.js +8 -4
  97. package/dist/cjs/test/datasource-provider.js +16 -12
  98. package/dist/cjs/test/index.js +13 -11
  99. package/dist/cjs/test/plugin-registry.js +6 -4
  100. package/dist/cjs/test/render.js +27 -20
  101. package/dist/cjs/test/setup-tests.js +2 -2
  102. package/dist/cjs/test/testDashboard.js +13 -11
  103. package/dist/cjs/utils/index.js +11 -9
  104. package/dist/cjs/utils/panelUtils.js +9 -3
  105. package/dist/cjs/utils/time.js +5 -3
  106. package/dist/cjs/validation/index.js +30 -0
  107. package/dist/cjs/validation/panel.js +29 -0
  108. package/dist/cjs/views/ViewDashboard/DashboardApp.js +30 -16
  109. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +63 -20
  110. package/dist/cjs/views/ViewDashboard/index.js +10 -8
  111. package/dist/cjs/views/index.js +10 -8
  112. package/dist/components/AddGroupButton/AddGroupButton.d.ts.map +1 -1
  113. package/dist/components/AddGroupButton/AddGroupButton.js +2 -1
  114. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
  115. package/dist/components/AddGroupButton/index.js.map +1 -1
  116. package/dist/components/AddPanelButton/AddPanelButton.js +2 -5
  117. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  118. package/dist/components/AddPanelButton/index.js.map +1 -1
  119. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  120. package/dist/components/Dashboard/index.js.map +1 -1
  121. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  122. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +37 -8
  123. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  124. package/dist/components/DashboardStickyToolbar/index.js.map +1 -1
  125. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  126. package/dist/components/DashboardToolbar/DashboardToolbar.js +61 -84
  127. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  128. package/dist/components/DashboardToolbar/index.js.map +1 -1
  129. package/dist/components/Datasources/DatasourceEditor.d.ts +8 -0
  130. package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -0
  131. package/dist/components/Datasources/DatasourceEditor.js +224 -0
  132. package/dist/components/Datasources/DatasourceEditor.js.map +1 -0
  133. package/dist/components/Datasources/EditDatasourcesButton.d.ts +3 -0
  134. package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -0
  135. package/dist/components/Datasources/EditDatasourcesButton.js +93 -0
  136. package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -0
  137. package/dist/components/Datasources/index.d.ts +3 -0
  138. package/dist/components/Datasources/index.d.ts.map +1 -0
  139. package/dist/components/Datasources/index.js +16 -0
  140. package/dist/components/Datasources/index.js.map +1 -0
  141. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  142. package/dist/components/DeletePanelDialog/index.js.map +1 -1
  143. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -2
  144. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  145. package/dist/components/DeletePanelGroupDialog/index.js.map +1 -1
  146. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  147. package/dist/components/DiscardChangesConfirmationDialog/index.js.map +1 -1
  148. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  149. package/dist/components/DownloadButton/index.js.map +1 -1
  150. package/dist/components/EditButton/EditButton.js.map +1 -1
  151. package/dist/components/EditButton/index.js.map +1 -1
  152. package/dist/components/EditJsonButton/EditJsonButton.d.ts +4 -1
  153. package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -1
  154. package/dist/components/EditJsonButton/EditJsonButton.js +5 -3
  155. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  156. package/dist/components/EditJsonButton/index.js.map +1 -1
  157. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +5 -1
  158. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  159. package/dist/components/EditJsonDialog/EditJsonDialog.js +32 -12
  160. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  161. package/dist/components/EditJsonDialog/index.js.map +1 -1
  162. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
  163. package/dist/components/EmptyDashboard/index.js.map +1 -1
  164. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  165. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  166. package/dist/components/GridLayout/GridItemContent.js +27 -10
  167. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  168. package/dist/components/GridLayout/GridLayout.js +2 -2
  169. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  170. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  171. package/dist/components/GridLayout/index.js.map +1 -1
  172. package/dist/components/Panel/Panel.d.ts.map +1 -1
  173. package/dist/components/Panel/Panel.js +5 -11
  174. package/dist/components/Panel/Panel.js.map +1 -1
  175. package/dist/components/Panel/PanelContent.d.ts +2 -1
  176. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  177. package/dist/components/Panel/PanelContent.js +3 -2
  178. package/dist/components/Panel/PanelContent.js.map +1 -1
  179. package/dist/components/Panel/PanelHeader.js.map +1 -1
  180. package/dist/components/Panel/index.js.map +1 -1
  181. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  182. package/dist/components/PanelDrawer/PanelDrawer.js +22 -76
  183. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  184. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +4 -1
  185. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  186. package/dist/components/PanelDrawer/PanelEditorForm.js +225 -139
  187. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  188. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  189. package/dist/components/PanelDrawer/PanelPreview.js +2 -2
  190. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  191. package/dist/components/PanelDrawer/index.d.ts +1 -0
  192. package/dist/components/PanelDrawer/index.d.ts.map +1 -1
  193. package/dist/components/PanelDrawer/index.js +1 -0
  194. package/dist/components/PanelDrawer/index.js.map +1 -1
  195. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
  196. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  197. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  198. package/dist/components/PanelGroupDialog/index.js.map +1 -1
  199. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +6 -6
  200. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  201. package/dist/components/QuerySummaryTable/index.js.map +1 -1
  202. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -4
  203. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  204. package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -1
  205. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  206. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +1 -3
  207. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  208. package/dist/components/SaveDashboardButton/index.js.map +1 -1
  209. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  210. package/dist/components/TimeRangeControls/TimeRangeControls.js +26 -5
  211. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  212. package/dist/components/TimeRangeControls/index.js.map +1 -1
  213. package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  214. package/dist/components/ToolbarIconButton/index.js.map +1 -1
  215. package/dist/components/Variables/BuiltinVariableAccordions.d.ts +8 -0
  216. package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -0
  217. package/dist/components/Variables/BuiltinVariableAccordions.js +127 -0
  218. package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -0
  219. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  220. package/dist/components/Variables/EditVariablesButton.js +5 -5
  221. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  222. package/dist/components/Variables/TemplateVariable.d.ts +10 -1
  223. package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
  224. package/dist/components/Variables/TemplateVariable.js +233 -98
  225. package/dist/components/Variables/TemplateVariable.js.map +1 -1
  226. package/dist/components/Variables/VariableEditor.d.ts +2 -1
  227. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  228. package/dist/components/Variables/VariableEditor.js +229 -157
  229. package/dist/components/Variables/VariableEditor.js.map +1 -1
  230. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  231. package/dist/components/Variables/VariableList.js +10 -12
  232. package/dist/components/Variables/VariableList.js.map +1 -1
  233. package/dist/components/Variables/index.d.ts +1 -0
  234. package/dist/components/Variables/index.d.ts.map +1 -1
  235. package/dist/components/Variables/index.js +1 -0
  236. package/dist/components/Variables/index.js.map +1 -1
  237. package/dist/components/index.d.ts +1 -0
  238. package/dist/components/index.d.ts.map +1 -1
  239. package/dist/components/index.js +1 -0
  240. package/dist/components/index.js.map +1 -1
  241. package/dist/constants/grid-layout-config.js.map +1 -1
  242. package/dist/constants/index.d.ts +1 -0
  243. package/dist/constants/index.d.ts.map +1 -1
  244. package/dist/constants/index.js +1 -0
  245. package/dist/constants/index.js.map +1 -1
  246. package/dist/constants/styles.d.ts +5 -0
  247. package/dist/constants/styles.d.ts.map +1 -0
  248. package/dist/constants/styles.js +23 -0
  249. package/dist/constants/styles.js.map +1 -0
  250. package/dist/constants/user-interface-text.d.ts +3 -0
  251. package/dist/constants/user-interface-text.d.ts.map +1 -1
  252. package/dist/constants/user-interface-text.js +3 -0
  253. package/dist/constants/user-interface-text.js.map +1 -1
  254. package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
  255. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  256. package/dist/context/DashboardProvider/DashboardProvider.js +8 -6
  257. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  258. package/dist/context/DashboardProvider/common.js.map +1 -1
  259. package/dist/context/DashboardProvider/dashboard-provider-api.js +2 -2
  260. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  261. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  262. package/dist/context/DashboardProvider/delete-panel-slice.js +2 -2
  263. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  264. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
  265. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  266. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
  267. package/dist/context/DashboardProvider/index.js.map +1 -1
  268. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -2
  269. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  270. package/dist/context/DashboardProvider/panel-editor-slice.js +7 -7
  271. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  272. package/dist/context/DashboardProvider/panel-group-editor-slice.js +2 -2
  273. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  274. package/dist/context/DashboardProvider/panel-group-slice.js +3 -3
  275. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  276. package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
  277. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  278. package/dist/context/DatasourceStoreProvider.d.ts +15 -10
  279. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  280. package/dist/context/DatasourceStoreProvider.js +161 -42
  281. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  282. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +11 -4
  283. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  284. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +106 -18
  285. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  286. package/dist/context/TemplateVariableProvider/hydrationUtils.js +7 -7
  287. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
  288. package/dist/context/TemplateVariableProvider/index.js.map +1 -1
  289. package/dist/context/TemplateVariableProvider/query-params.js.map +1 -1
  290. package/dist/context/TemplateVariableProvider/utils.js +3 -3
  291. package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
  292. package/dist/context/index.js.map +1 -1
  293. package/dist/context/useDashboard.d.ts.map +1 -1
  294. package/dist/context/useDashboard.js +5 -3
  295. package/dist/context/useDashboard.js.map +1 -1
  296. package/dist/index.js.map +1 -1
  297. package/dist/stories/decorators/WithDashboard.js.map +1 -1
  298. package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
  299. package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
  300. package/dist/stories/decorators/constants.js +2 -2
  301. package/dist/stories/decorators/constants.js.map +1 -1
  302. package/dist/stories/decorators/index.js.map +1 -1
  303. package/dist/test/dashboard-provider.js.map +1 -1
  304. package/dist/test/datasource-provider.d.ts.map +1 -1
  305. package/dist/test/datasource-provider.js +5 -7
  306. package/dist/test/datasource-provider.js.map +1 -1
  307. package/dist/test/index.js.map +1 -1
  308. package/dist/test/plugin-registry.js.map +1 -1
  309. package/dist/test/render.d.ts.map +1 -1
  310. package/dist/test/render.js +8 -3
  311. package/dist/test/render.js.map +1 -1
  312. package/dist/test/setup-tests.js.map +1 -1
  313. package/dist/test/testDashboard.js +10 -10
  314. package/dist/test/testDashboard.js.map +1 -1
  315. package/dist/utils/index.js.map +1 -1
  316. package/dist/utils/panelUtils.js.map +1 -1
  317. package/dist/utils/time.js.map +1 -1
  318. package/dist/validation/index.d.ts +2 -0
  319. package/dist/validation/index.d.ts.map +1 -0
  320. package/dist/validation/index.js +15 -0
  321. package/dist/validation/index.js.map +1 -0
  322. package/dist/validation/panel.d.ts +19 -0
  323. package/dist/validation/panel.d.ts.map +1 -0
  324. package/dist/validation/panel.js +21 -0
  325. package/dist/validation/panel.js.map +1 -0
  326. package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
  327. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  328. package/dist/views/ViewDashboard/DashboardApp.js +17 -5
  329. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  330. package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
  331. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  332. package/dist/views/ViewDashboard/ViewDashboard.js +52 -11
  333. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  334. package/dist/views/ViewDashboard/index.js.map +1 -1
  335. package/dist/views/index.js.map +1 -1
  336. package/package.json +8 -7
@@ -16,16 +16,21 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  Object.defineProperty(exports, "DatasourceStoreProvider", {
18
18
  enumerable: true,
19
- get: ()=>DatasourceStoreProvider
19
+ get: function() {
20
+ return DatasourceStoreProvider;
21
+ }
20
22
  });
21
- const _jsxRuntime = require("react/jsx-runtime");
23
+ const _jsxruntime = require("react/jsx-runtime");
22
24
  const _react = require("react");
23
25
  const _core = require("@perses-dev/core");
24
- const _pluginSystem = require("@perses-dev/plugin-system");
26
+ const _pluginsystem = require("@perses-dev/plugin-system");
25
27
  function DatasourceStoreProvider(props) {
26
- const { dashboardResource , projectName , datasourceApi , onCreate , children } = props;
28
+ const { projectName , datasourceApi , onCreate , children } = props;
29
+ const [dashboardResource, setDashboardResource] = (0, _react.useState)(props.dashboardResource);
30
+ var _props_savedDatasources;
31
+ const [savedDatasources, setSavedDatasources] = (0, _react.useState)((_props_savedDatasources = props.savedDatasources) !== null && _props_savedDatasources !== void 0 ? _props_savedDatasources : {});
27
32
  const project = projectName !== null && projectName !== void 0 ? projectName : dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.metadata.project;
28
- const { getPlugin , listPluginMetadata } = (0, _pluginSystem.usePluginRegistry)();
33
+ const { getPlugin , listPluginMetadata } = (0, _pluginsystem.usePluginRegistry)();
29
34
  const findDatasource = (0, _core.useEvent)(async (selector)=>{
30
35
  // Try to find it in dashboard spec
31
36
  if (dashboardResource) {
@@ -33,8 +38,12 @@ function DatasourceStoreProvider(props) {
33
38
  const dashboardDatasource = findDashboardDatasource(datasources, selector);
34
39
  if (dashboardDatasource !== undefined) {
35
40
  return {
36
- spec: dashboardDatasource,
37
- proxyUrl: undefined
41
+ spec: dashboardDatasource.spec,
42
+ proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
43
+ project: dashboardResource.metadata.project,
44
+ dashboard: dashboardResource.metadata.name,
45
+ name: dashboardDatasource.name
46
+ })
38
47
  };
39
48
  }
40
49
  }
@@ -43,8 +52,11 @@ function DatasourceStoreProvider(props) {
43
52
  const datasource = await datasourceApi.getDatasource(project, selector);
44
53
  if (datasource !== undefined) {
45
54
  return {
46
- spec: datasource.resource.spec,
47
- proxyUrl: datasource.proxyUrl
55
+ spec: datasource.spec,
56
+ proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
57
+ project: datasource.metadata.project,
58
+ name: datasource.metadata.name
59
+ })
48
60
  };
49
61
  }
50
62
  }
@@ -52,8 +64,10 @@ function DatasourceStoreProvider(props) {
52
64
  const globalDatasource = await datasourceApi.getGlobalDatasource(selector);
53
65
  if (globalDatasource !== undefined) {
54
66
  return {
55
- spec: globalDatasource.resource.spec,
56
- proxyUrl: globalDatasource.proxyUrl
67
+ spec: globalDatasource.spec,
68
+ proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
69
+ name: globalDatasource.metadata.name
70
+ })
57
71
  };
58
72
  }
59
73
  throw new Error(`No datasource found for kind '${selector.kind}' and name '${selector.name}'`);
@@ -85,53 +99,104 @@ function DatasourceStoreProvider(props) {
85
99
  getPlugin,
86
100
  onCreate
87
101
  ]);
88
- const listDatasourceMetadata = (0, _core.useEvent)(async (datasourcePluginKind)=>{
102
+ const listDatasourceSelectItems = (0, _core.useEvent)(async (datasourcePluginKind)=>{
89
103
  const [pluginMetadata, datasources, globalDatasources] = await Promise.all([
90
104
  listPluginMetadata('Datasource'),
91
105
  project ? datasourceApi.listDatasources(project, datasourcePluginKind) : [],
92
106
  datasourceApi.listGlobalDatasources(datasourcePluginKind)
93
107
  ]);
94
- // Find the metadata for the plugin type they asked for so we can use it for the name of the default datasource
108
+ // Find the metadata for the plugin type they asked for, so we can use it for the name of the default datasource
95
109
  const datasourcePluginMetadata = pluginMetadata.find((metadata)=>metadata.kind === datasourcePluginKind);
96
110
  if (datasourcePluginMetadata === undefined) {
97
111
  throw new Error(`Could not find a Datasource plugin with kind '${datasourcePluginKind}'`);
98
112
  }
99
- // Get helper for de-duping results properly
100
- const { results , addResult } = buildListDatasourceMetadataResults(datasourcePluginMetadata.display.name);
101
- // Start with dashboard datasources that have highest precedence
113
+ // Get helper for computing results properly
114
+ const { results , addItem } = buildDatasourceSelectItemGroups(datasourcePluginMetadata.display.name);
115
+ // Start with dashboard datasources with the highest precedence
102
116
  if (dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.spec.datasources) {
103
117
  for(const selectorName in dashboardResource.spec.datasources){
104
118
  const spec = dashboardResource.spec.datasources[selectorName];
105
119
  if (spec === undefined || spec.plugin.kind !== datasourcePluginKind) continue;
106
- addResult(spec, selectorName);
120
+ const saved = selectorName in savedDatasources;
121
+ addItem({
122
+ spec,
123
+ selectorName,
124
+ selectorGroup: 'dashboard',
125
+ saved
126
+ });
107
127
  }
108
128
  }
109
129
  // Now look at project-level datasources
110
130
  for (const datasource of datasources){
111
- const selectorName1 = datasource.metadata.name;
112
- addResult(datasource.spec, selectorName1);
131
+ const selectorName = datasource.metadata.name;
132
+ addItem({
133
+ spec: datasource.spec,
134
+ selectorName,
135
+ selectorGroup: 'project',
136
+ editLink: `/projects/${project}/datasources`
137
+ });
113
138
  }
114
139
  // And finally global datasources
115
140
  for (const globalDatasource of globalDatasources){
116
- const selectorName2 = globalDatasource.metadata.name;
117
- addResult(globalDatasource.spec, selectorName2);
141
+ const selectorName = globalDatasource.metadata.name;
142
+ addItem({
143
+ spec: globalDatasource.spec,
144
+ selectorName,
145
+ selectorGroup: 'global',
146
+ editLink: '/admin/datasources'
147
+ });
118
148
  }
119
149
  return results;
120
150
  });
151
+ const getLocalDatasources = (0, _react.useCallback)(()=>{
152
+ var _dashboardResource_spec_datasources;
153
+ return (_dashboardResource_spec_datasources = dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.spec.datasources) !== null && _dashboardResource_spec_datasources !== void 0 ? _dashboardResource_spec_datasources : {};
154
+ }, [
155
+ dashboardResource
156
+ ]);
157
+ const getSavedDatasources = (0, _react.useCallback)(()=>{
158
+ return savedDatasources;
159
+ }, [
160
+ savedDatasources
161
+ ]);
162
+ const setLocalDatasources = (0, _react.useCallback)((datasources)=>{
163
+ if (dashboardResource) {
164
+ setDashboardResource({
165
+ ...dashboardResource,
166
+ spec: {
167
+ ...dashboardResource.spec,
168
+ datasources: datasources
169
+ }
170
+ });
171
+ }
172
+ }, [
173
+ dashboardResource
174
+ ]);
121
175
  const ctxValue = (0, _react.useMemo)(()=>({
122
176
  getDatasource,
123
177
  getDatasourceClient,
124
- listDatasourceMetadata
178
+ getLocalDatasources,
179
+ setLocalDatasources,
180
+ setSavedDatasources,
181
+ getSavedDatasources,
182
+ listDatasourceSelectItems
125
183
  }), [
126
184
  getDatasource,
127
185
  getDatasourceClient,
128
- listDatasourceMetadata
186
+ getLocalDatasources,
187
+ setLocalDatasources,
188
+ listDatasourceSelectItems,
189
+ setSavedDatasources,
190
+ getSavedDatasources
129
191
  ]);
130
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceStoreContext.Provider, {
192
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceStoreContext.Provider, {
131
193
  value: ctxValue,
132
194
  children: children
133
195
  });
134
196
  }
197
+ function buildDatasourceProxyUrl(api, params) {
198
+ return api.buildProxyUrl ? api.buildProxyUrl(params) : '';
199
+ }
135
200
  // Helper to find a datasource in the list embedded in a dashboard spec
136
201
  function findDashboardDatasource(dashboardDatasources, selector) {
137
202
  if (dashboardDatasources === undefined) return undefined;
@@ -139,42 +204,98 @@ function findDashboardDatasource(dashboardDatasources, selector) {
139
204
  if (selector.name !== undefined) {
140
205
  const named = dashboardDatasources[selector.name];
141
206
  if (named === undefined) return undefined;
142
- return named.plugin.kind === selector.kind ? named : undefined;
207
+ return named.plugin.kind === selector.kind ? {
208
+ name: selector.name,
209
+ spec: named
210
+ } : undefined;
143
211
  }
144
212
  // If only using a kind, try to find one with that kind that is the default
145
- return Object.values(dashboardDatasources).find((ds)=>ds.plugin.kind === selector.kind && ds.default === true);
213
+ const result = Object.entries(dashboardDatasources).find((entry)=>entry[1].plugin.kind === selector.kind && entry[1].default);
214
+ if (!result) {
215
+ return undefined;
216
+ }
217
+ return {
218
+ name: result[0],
219
+ spec: result[1]
220
+ };
146
221
  }
147
- // Helper for building a list of DatasourceMetadata results that will take care of de-duping already used selectors
148
- function buildListDatasourceMetadataResults(pluginDisplayName) {
222
+ /**
223
+ * Helper for building a list of DatasourceSelectItemGroup results.
224
+ * @param pluginDisplayName
225
+ */ function buildDatasourceSelectItemGroups(pluginDisplayName) {
149
226
  const results = [];
150
227
  const usedNames = new Set();
151
- let defaultAdded = false;
152
- const addResult = (spec, selectorName)=>{
153
- var ref;
154
- // If we haven't added a default yet and this is a default, add default option to the beginning of the results
155
- if (spec.default && defaultAdded === false) {
156
- results.unshift({
157
- name: `Default ${pluginDisplayName}`,
158
- selector: {
159
- kind: spec.plugin.kind
160
- }
228
+ let isFirst = true;
229
+ let explicitDefaultAdded = false;
230
+ const groupIndices = {};
231
+ let currentGroupIndex = 1; // 0 is the default group, always there as it contains at least the first item.
232
+ const addItem = ({ spec , selectorName , selectorGroup: group , editLink , saved })=>{
233
+ var _spec_display;
234
+ group = group !== null && group !== void 0 ? group : '';
235
+ // Ensure the default group is always present as soon as an item is added.
236
+ if (isFirst) {
237
+ results.push({
238
+ group: `Default ${pluginDisplayName}`,
239
+ items: []
161
240
  });
162
- defaultAdded = true;
163
241
  }
164
- // If we already have a datasource with this selector name, ignore it, otherwise add to end of list
165
- if (usedNames.has(selectorName)) return;
166
- var ref1;
167
- results.push({
168
- name: (ref1 = (ref = spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref1 !== void 0 ? ref1 : selectorName,
242
+ var _groupIndices_group;
243
+ // Create the group if necessary
244
+ let selectItemGroup = results[(_groupIndices_group = groupIndices[group]) !== null && _groupIndices_group !== void 0 ? _groupIndices_group : -1];
245
+ if (!selectItemGroup) {
246
+ groupIndices[group] = currentGroupIndex;
247
+ selectItemGroup = {
248
+ items: [],
249
+ group,
250
+ editLink
251
+ };
252
+ results[currentGroupIndex] = selectItemGroup;
253
+ currentGroupIndex++;
254
+ }
255
+ // Add item to the group
256
+ const isOverridden = usedNames.has(selectorName);
257
+ var _spec_display_name;
258
+ selectItemGroup.items.push({
259
+ name: (_spec_display_name = (_spec_display = spec.display) === null || _spec_display === void 0 ? void 0 : _spec_display.name) !== null && _spec_display_name !== void 0 ? _spec_display_name : selectorName,
260
+ overridden: isOverridden,
261
+ saved,
169
262
  selector: {
170
263
  kind: spec.plugin.kind,
171
- name: selectorName
264
+ name: selectorName,
265
+ group
172
266
  }
173
267
  });
174
268
  usedNames.add(selectorName);
269
+ const isExplicitDefault = !isOverridden && spec.default && !explicitDefaultAdded;
270
+ if (results[0] && (isFirst || isExplicitDefault)) {
271
+ // If we haven't added a default yet and this is a default, add default option to the beginning of the results
272
+ results[0].items = [
273
+ {
274
+ name: `Default (${selectorName} from ${group})`,
275
+ selector: {
276
+ kind: spec.plugin.kind
277
+ }
278
+ }
279
+ ];
280
+ // We consider that we added the default datasource only if it has been explicitly set as default.
281
+ // If we add this datasource as default just because it's the first, it still needs to be overridable by
282
+ // another datasource explicitly set as default.
283
+ explicitDefaultAdded = isExplicitDefault;
284
+ }
285
+ // At the end, we make sure the overriding item(s) is well flagged so
286
+ if (isOverridden) {
287
+ for(let i = explicitDefaultAdded ? 1 : 0; i < currentGroupIndex; i++){
288
+ var _results_i;
289
+ var _results_i_items;
290
+ ((_results_i_items = (_results_i = results[i]) === null || _results_i === void 0 ? void 0 : _results_i.items) !== null && _results_i_items !== void 0 ? _results_i_items : []).filter((item)=>item.selector.name === selectorName).forEach((item)=>{
291
+ item.overriding = true;
292
+ });
293
+ }
294
+ }
295
+ isFirst = false;
175
296
  };
176
297
  return {
177
298
  results,
178
- addResult
299
+ addItem
179
300
  };
180
301
  }
@@ -21,27 +21,46 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- useTemplateVariableStoreCtx: ()=>useTemplateVariableStoreCtx,
25
- useTemplateVariableValues: ()=>useTemplateVariableValues,
26
- useTemplateVariable: ()=>useTemplateVariable,
27
- useTemplateVariableActions: ()=>useTemplateVariableActions,
28
- useTemplateVariableDefinitions: ()=>useTemplateVariableDefinitions,
29
- useTemplateExternalVariableDefinitions: ()=>useTemplateExternalVariableDefinitions,
30
- useTemplateVariableStore: ()=>useTemplateVariableStore,
31
- TemplateVariableProvider: ()=>TemplateVariableProvider
24
+ useTemplateVariableStoreCtx: function() {
25
+ return useTemplateVariableStoreCtx;
26
+ },
27
+ useTemplateVariableValues: function() {
28
+ return useTemplateVariableValues;
29
+ },
30
+ useTemplateVariable: function() {
31
+ return useTemplateVariable;
32
+ },
33
+ useTemplateVariableActions: function() {
34
+ return useTemplateVariableActions;
35
+ },
36
+ useTemplateVariableDefinitions: function() {
37
+ return useTemplateVariableDefinitions;
38
+ },
39
+ useTemplateExternalVariableDefinitions: function() {
40
+ return useTemplateExternalVariableDefinitions;
41
+ },
42
+ useTemplateVariableStore: function() {
43
+ return useTemplateVariableStore;
44
+ },
45
+ TemplateVariableProvider: function() {
46
+ return TemplateVariableProvider;
47
+ },
48
+ TemplateVariableProviderWithQueryParams: function() {
49
+ return TemplateVariableProviderWithQueryParams;
50
+ }
32
51
  });
33
- const _jsxRuntime = require("react/jsx-runtime");
52
+ const _jsxruntime = require("react/jsx-runtime");
34
53
  const _react = require("react");
35
54
  const _zustand = require("zustand");
36
55
  const _immer = require("zustand/middleware/immer");
37
56
  const _middleware = require("zustand/middleware");
38
- const _immer1 = /*#__PURE__*/ _interopRequireDefault(require("immer"));
39
- const _pluginSystem = require("@perses-dev/plugin-system");
57
+ const _immer1 = /*#__PURE__*/ _interop_require_default(require("immer"));
58
+ const _pluginsystem = require("@perses-dev/plugin-system");
40
59
  const _core = require("@perses-dev/core");
41
60
  const _utils = require("./utils");
42
61
  const _hydrationUtils = require("./hydrationUtils");
43
- const _queryParams = require("./query-params");
44
- function _interopRequireDefault(obj) {
62
+ const _queryparams = require("./query-params");
63
+ function _interop_require_default(obj) {
45
64
  return obj && obj.__esModule ? obj : {
46
65
  default: obj
47
66
  };
@@ -92,12 +111,12 @@ function useTemplateVariableValues(variableNames) {
92
111
  function useTemplateVariable(name, source) {
93
112
  const store = useTemplateVariableStoreCtx();
94
113
  return (0, _zustand.useStore)(store, (s)=>{
95
- var ref;
114
+ var _s_externalVariableDefinitions_find;
96
115
  const state = s.variableState.get({
97
116
  name,
98
117
  source
99
118
  });
100
- const definitions = source ? (ref = s.externalVariableDefinitions.find((v)=>v.source === source)) === null || ref === void 0 ? void 0 : ref.definitions : s.variableDefinitions;
119
+ const definitions = source ? (_s_externalVariableDefinitions_find = s.externalVariableDefinitions.find((v)=>v.source === source)) === null || _s_externalVariableDefinitions_find === void 0 ? void 0 : _s_externalVariableDefinitions_find.definitions : s.variableDefinitions;
101
120
  const definition = (definitions || []).find((v)=>v.spec.name === name);
102
121
  return {
103
122
  state,
@@ -130,10 +149,11 @@ function useTemplateVariableStore() {
130
149
  const store = useTemplateVariableStoreCtx();
131
150
  return (0, _zustand.useStore)(store);
132
151
  }
133
- function PluginProvider({ children }) {
152
+ function PluginProvider({ children , builtinVariables }) {
134
153
  const originalValues = useTemplateVariableValues();
135
154
  const definitions = useTemplateVariableDefinitions();
136
155
  const externalDefinitions = useTemplateExternalVariableDefinitions();
156
+ const { absoluteTimeRange } = (0, _pluginsystem.useTimeRange)();
137
157
  const values = (0, _react.useMemo)(()=>{
138
158
  const contextValues = {};
139
159
  // This will loop through all the current variables values
@@ -146,12 +166,12 @@ function PluginProvider({ children }) {
146
166
  if (v.value === _core.DEFAULT_ALL_VALUE) {
147
167
  const definition = (0, _utils.findVariableDefinitionByName)(name, definitions, externalDefinitions);
148
168
  // If the variable is a list variable and has a custom all value, then use that value instead
149
- if ((definition === null || definition === void 0 ? void 0 : definition.kind) === 'ListVariable' && definition.spec.custom_all_value) {
150
- v.value = definition.spec.custom_all_value;
169
+ if ((definition === null || definition === void 0 ? void 0 : definition.kind) === 'ListVariable' && definition.spec.customAllValue) {
170
+ v.value = definition.spec.customAllValue;
151
171
  } else {
152
- var ref;
153
- var ref1;
154
- v.value = (ref1 = (ref = v.options) === null || ref === void 0 ? void 0 : ref.map((o)=>o.value)) !== null && ref1 !== void 0 ? ref1 : null;
172
+ var _v_options;
173
+ var _v_options_map;
174
+ v.value = (_v_options_map = (_v_options = v.options) === null || _v_options === void 0 ? void 0 : _v_options.map((o)=>o.value)) !== null && _v_options_map !== void 0 ? _v_options_map : null;
155
175
  }
156
176
  }
157
177
  contextValues[name] = v;
@@ -162,15 +182,88 @@ function PluginProvider({ children }) {
162
182
  definitions,
163
183
  externalDefinitions
164
184
  ]);
165
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TemplateVariableContext.Provider, {
185
+ const allBuiltinVariables = [
186
+ {
187
+ kind: 'BuiltinVariable',
188
+ spec: {
189
+ name: '__from',
190
+ value: ()=>absoluteTimeRange.start.valueOf().toString(),
191
+ source: 'Dashboard',
192
+ display: {
193
+ name: '__from',
194
+ description: 'Start time of the current time range in unix millisecond epoch',
195
+ hidden: true
196
+ }
197
+ }
198
+ },
199
+ {
200
+ kind: 'BuiltinVariable',
201
+ spec: {
202
+ name: '__to',
203
+ value: ()=>absoluteTimeRange.end.valueOf().toString(),
204
+ source: 'Dashboard',
205
+ display: {
206
+ name: '__to',
207
+ description: 'End time of the current time range in unix millisecond epoch',
208
+ hidden: true
209
+ }
210
+ }
211
+ },
212
+ {
213
+ kind: 'BuiltinVariable',
214
+ spec: {
215
+ name: '__range',
216
+ value: ()=>(0, _core.formatDuration)((0, _core.intervalToPrometheusDuration)(absoluteTimeRange)),
217
+ source: 'Dashboard',
218
+ display: {
219
+ name: '__range',
220
+ description: 'The range for the current dashboard in human readable format',
221
+ hidden: true
222
+ }
223
+ }
224
+ },
225
+ {
226
+ kind: 'BuiltinVariable',
227
+ spec: {
228
+ name: '__range_s',
229
+ value: ()=>((absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()) / 1000).toString(),
230
+ source: 'Dashboard',
231
+ display: {
232
+ name: '__range_s',
233
+ description: 'The range for the current dashboard in second',
234
+ hidden: true
235
+ }
236
+ }
237
+ },
238
+ {
239
+ kind: 'BuiltinVariable',
240
+ spec: {
241
+ name: '__range_ms',
242
+ value: ()=>(absoluteTimeRange.end.valueOf() - absoluteTimeRange.start.valueOf()).toString(),
243
+ source: 'Dashboard',
244
+ display: {
245
+ name: '__range_ms',
246
+ description: 'The range for the current dashboard in millisecond',
247
+ hidden: true
248
+ }
249
+ }
250
+ }
251
+ ];
252
+ builtinVariables === null || builtinVariables === void 0 ? void 0 : builtinVariables.forEach((def)=>allBuiltinVariables.push(def));
253
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.BuiltinVariableContext.Provider, {
166
254
  value: {
167
- state: values
255
+ variables: allBuiltinVariables
168
256
  },
169
- children: children
257
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TemplateVariableContext.Provider, {
258
+ value: {
259
+ state: values
260
+ },
261
+ children: children
262
+ })
170
263
  });
171
264
  }
172
265
  function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , externalVariableDefinitions =[] , queryParams }) {
173
- const initialParams = (0, _queryParams.getInitalValuesFromQueryParameters)(queryParams ? queryParams[0] : {});
266
+ const initialParams = (0, _queryparams.getInitalValuesFromQueryParameters)(queryParams ? queryParams[0] : {});
174
267
  const store = (0, _zustand.createStore)()((0, _middleware.devtools)((0, _immer.immer)((set, get)=>{
175
268
  return {
176
269
  variableState: (0, _hydrationUtils.hydrateTemplateVariableStates)(initialVariableDefinitions, initialParams, externalVariableDefinitions),
@@ -227,7 +320,7 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , exter
227
320
  if (queryParams) {
228
321
  const setQueryParams = queryParams[1];
229
322
  setQueryParams({
230
- [(0, _queryParams.getURLQueryParamName)(name)]: val
323
+ [(0, _queryparams.getURLQueryParamName)(name)]: val
231
324
  });
232
325
  }
233
326
  varState.value = val;
@@ -246,16 +339,16 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , exter
246
339
  draft[index] = {
247
340
  kind: 'ListVariable',
248
341
  spec: (0, _immer1.default)(variable.spec, (specDraft)=>{
249
- specDraft.default_value = currentVariable.value;
342
+ specDraft.defaultValue = currentVariable.value;
250
343
  })
251
344
  };
252
345
  }
253
346
  } else if (variable.kind === 'TextVariable') {
254
- const currentVariable1 = variableState.get({
347
+ const currentVariable = variableState.get({
255
348
  name
256
349
  });
257
- const currentVariableValue = typeof (currentVariable1 === null || currentVariable1 === void 0 ? void 0 : currentVariable1.value) === 'string' ? currentVariable1.value : '';
258
- if ((currentVariable1 === null || currentVariable1 === void 0 ? void 0 : currentVariable1.value) !== undefined) {
350
+ const currentVariableValue = typeof (currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) === 'string' ? currentVariable.value : '';
351
+ if ((currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== undefined) {
259
352
  draft[index] = {
260
353
  kind: 'TextVariable',
261
354
  spec: (0, _immer1.default)(variable.spec, (specDraft)=>{
@@ -278,17 +371,31 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , exter
278
371
  })));
279
372
  return store;
280
373
  }
281
- function TemplateVariableProvider({ children , initialVariableDefinitions =[] , externalVariableDefinitions =[] }) {
374
+ function TemplateVariableProvider({ children , initialVariableDefinitions =[] , externalVariableDefinitions =[] , builtinVariables =[] }) {
375
+ const [store] = (0, _react.useState)(createTemplateVariableSrvStore({
376
+ initialVariableDefinitions,
377
+ externalVariableDefinitions
378
+ }));
379
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(TemplateVariableStoreContext.Provider, {
380
+ value: store,
381
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(PluginProvider, {
382
+ builtinVariables: builtinVariables,
383
+ children: children
384
+ })
385
+ });
386
+ }
387
+ function TemplateVariableProviderWithQueryParams({ children , initialVariableDefinitions =[] , externalVariableDefinitions =[] , builtinVariables =[] }) {
282
388
  const allVariableDefs = (0, _utils.mergeVariableDefinitions)(initialVariableDefinitions, externalVariableDefinitions);
283
- const queryParams = (0, _queryParams.useVariableQueryParams)(allVariableDefs);
389
+ const queryParams = (0, _queryparams.useVariableQueryParams)(allVariableDefs);
284
390
  const [store] = (0, _react.useState)(createTemplateVariableSrvStore({
285
391
  initialVariableDefinitions,
286
392
  externalVariableDefinitions,
287
393
  queryParams
288
394
  }));
289
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(TemplateVariableStoreContext.Provider, {
395
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(TemplateVariableStoreContext.Provider, {
290
396
  value: store,
291
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(PluginProvider, {
397
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(PluginProvider, {
398
+ builtinVariables: builtinVariables,
292
399
  children: children
293
400
  })
294
401
  });
@@ -16,10 +16,12 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  Object.defineProperty(exports, "hydrateTemplateVariableStates", {
18
18
  enumerable: true,
19
- get: ()=>hydrateTemplateVariableStates
19
+ get: function() {
20
+ return hydrateTemplateVariableStates;
21
+ }
20
22
  });
21
23
  const _core = require("@perses-dev/core");
22
- const _pluginSystem = require("@perses-dev/plugin-system");
24
+ const _pluginsystem = require("@perses-dev/plugin-system");
23
25
  // TODO: move to TemplateVariableProvider/utils.ts
24
26
  function hydrateTemplateVariableState(variable, initialValue) {
25
27
  const varState = {
@@ -34,15 +36,15 @@ function hydrateTemplateVariableState(variable, initialValue) {
34
36
  break;
35
37
  case 'ListVariable':
36
38
  varState.options = [];
37
- var ref;
38
- varState.value = (ref = initialValue !== null && initialValue !== void 0 ? initialValue : variable.spec.default_value) !== null && ref !== void 0 ? ref : null;
39
- // TODO: smarter fallbacks for default_value when allow_all_value is true
39
+ var _ref;
40
+ varState.value = (_ref = initialValue !== null && initialValue !== void 0 ? initialValue : variable.spec.defaultValue) !== null && _ref !== void 0 ? _ref : null;
41
+ // TODO: smarter fallbacks for defaultValue when allowAllValue is true
40
42
  if (varState.options.length > 0 && !varState.value) {
41
- var ref1;
42
- var ref2;
43
- const firstOptionValue = (ref2 = (ref1 = varState.options[0]) === null || ref1 === void 0 ? void 0 : ref1.value) !== null && ref2 !== void 0 ? ref2 : null;
43
+ var _varState_options_;
44
+ var _varState_options__value;
45
+ const firstOptionValue = (_varState_options__value = (_varState_options_ = varState.options[0]) === null || _varState_options_ === void 0 ? void 0 : _varState_options_.value) !== null && _varState_options__value !== void 0 ? _varState_options__value : null;
44
46
  if (firstOptionValue !== null) {
45
- varState.value = variable.spec.allow_multiple ? [
47
+ varState.value = variable.spec.allowMultiple ? [
46
48
  firstOptionValue
47
49
  ] : firstOptionValue;
48
50
  }
@@ -62,7 +64,7 @@ function hydrateTemplateVariableState(variable, initialValue) {
62
64
  return varState;
63
65
  }
64
66
  function hydrateTemplateVariableStates(localDefinitions, initialValues, externalDefinitions = []) {
65
- const state = new _pluginSystem.VariableStoreStateMap();
67
+ const state = new _pluginsystem.VariableStoreStateMap();
66
68
  // Collect the names used by local definitions
67
69
  let overridingNames = {};
68
70
  localDefinitions.forEach((v)=>{
@@ -14,15 +14,17 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _exportStar(require("./TemplateVariableProvider"), exports);
18
- function _exportStar(from, to) {
17
+ _export_star(require("./TemplateVariableProvider"), exports);
18
+ function _export_star(from, to) {
19
19
  Object.keys(from).forEach(function(k) {
20
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
- enumerable: true,
22
- get: function() {
23
- return from[k];
24
- }
25
- });
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
+ Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ }
26
28
  });
27
29
  return from;
28
30
  }