@perses-dev/dashboards 0.39.0 → 0.40.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/dist/cjs/components/AddGroupButton/AddGroupButton.js +9 -7
  2. package/dist/cjs/components/AddGroupButton/index.js +10 -8
  3. package/dist/cjs/components/AddPanelButton/AddPanelButton.js +9 -7
  4. package/dist/cjs/components/AddPanelButton/index.js +10 -8
  5. package/dist/cjs/components/Dashboard/Dashboard.js +11 -9
  6. package/dist/cjs/components/Dashboard/index.js +10 -8
  7. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +18 -16
  8. package/dist/cjs/components/DashboardStickyToolbar/index.js +10 -8
  9. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +43 -41
  10. package/dist/cjs/components/DashboardToolbar/index.js +10 -8
  11. package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +12 -10
  12. package/dist/cjs/components/DeletePanelDialog/index.js +10 -8
  13. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +17 -15
  14. package/dist/cjs/components/DeletePanelGroupDialog/index.js +10 -8
  15. package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +5 -3
  16. package/dist/cjs/components/DiscardChangesConfirmationDialog/index.js +10 -8
  17. package/dist/cjs/components/DownloadButton/DownloadButton.js +12 -10
  18. package/dist/cjs/components/DownloadButton/index.js +10 -8
  19. package/dist/cjs/components/EditButton/EditButton.js +8 -6
  20. package/dist/cjs/components/EditButton/index.js +10 -8
  21. package/dist/cjs/components/EditJsonButton/EditJsonButton.js +10 -8
  22. package/dist/cjs/components/EditJsonButton/index.js +10 -8
  23. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +29 -23
  24. package/dist/cjs/components/EditJsonDialog/index.js +10 -8
  25. package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +18 -16
  26. package/dist/cjs/components/EmptyDashboard/index.js +10 -8
  27. package/dist/cjs/components/GridLayout/GridContainer.js +5 -3
  28. package/dist/cjs/components/GridLayout/GridItemContent.js +33 -14
  29. package/dist/cjs/components/GridLayout/GridLayout.js +18 -16
  30. package/dist/cjs/components/GridLayout/GridTitle.js +35 -33
  31. package/dist/cjs/components/GridLayout/index.js +13 -11
  32. package/dist/cjs/components/Panel/Panel.js +17 -22
  33. package/dist/cjs/components/Panel/PanelContent.js +8 -6
  34. package/dist/cjs/components/Panel/PanelHeader.js +33 -31
  35. package/dist/cjs/components/Panel/index.js +10 -8
  36. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +25 -77
  37. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +269 -141
  38. package/dist/cjs/components/PanelDrawer/PanelPreview.js +11 -9
  39. package/dist/cjs/components/PanelDrawer/index.js +10 -8
  40. package/dist/cjs/components/PanelDrawer/usePanelEditor.js +3 -1
  41. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +18 -16
  42. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +15 -11
  43. package/dist/cjs/components/PanelGroupDialog/index.js +10 -8
  44. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +46 -44
  45. package/dist/cjs/components/QuerySummaryTable/index.js +10 -8
  46. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +23 -21
  47. package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +10 -8
  48. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +8 -8
  49. package/dist/cjs/components/SaveDashboardButton/index.js +10 -8
  50. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +40 -16
  51. package/dist/cjs/components/TimeRangeControls/index.js +10 -8
  52. package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +5 -3
  53. package/dist/cjs/components/ToolbarIconButton/index.js +10 -8
  54. package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +140 -0
  55. package/dist/cjs/components/Variables/EditVariablesButton.js +16 -11
  56. package/dist/cjs/components/Variables/TemplateVariable.js +116 -69
  57. package/dist/cjs/components/Variables/VariableEditor.js +280 -204
  58. package/dist/cjs/components/Variables/VariableList.js +19 -15
  59. package/dist/cjs/components/Variables/index.js +14 -11
  60. package/dist/cjs/components/index.js +31 -29
  61. package/dist/cjs/constants/grid-layout-config.js +6 -2
  62. package/dist/cjs/constants/index.js +11 -9
  63. package/dist/cjs/constants/user-interface-text.js +6 -2
  64. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +40 -34
  65. package/dist/cjs/context/DashboardProvider/common.js +6 -2
  66. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +70 -38
  67. package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +3 -1
  68. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +5 -3
  69. package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +3 -1
  70. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +3 -1
  71. package/dist/cjs/context/DashboardProvider/edit-json-dialog-slice.js +3 -1
  72. package/dist/cjs/context/DashboardProvider/index.js +12 -10
  73. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +13 -11
  74. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +8 -6
  75. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +15 -7
  76. package/dist/cjs/context/DashboardProvider/panel-slice.js +3 -1
  77. package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +3 -1
  78. package/dist/cjs/context/DatasourceStoreProvider.js +114 -45
  79. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +125 -34
  80. package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +12 -10
  81. package/dist/cjs/context/TemplateVariableProvider/index.js +10 -8
  82. package/dist/cjs/context/TemplateVariableProvider/query-params.js +17 -7
  83. package/dist/cjs/context/TemplateVariableProvider/utils.js +15 -7
  84. package/dist/cjs/context/index.js +13 -11
  85. package/dist/cjs/context/useDashboard.js +8 -6
  86. package/dist/cjs/index.js +12 -10
  87. package/dist/cjs/stories/decorators/WithDashboard.js +6 -4
  88. package/dist/cjs/stories/decorators/WithDatasourceStore.js +6 -4
  89. package/dist/cjs/stories/decorators/WithTemplateVariables.js +6 -4
  90. package/dist/cjs/stories/decorators/constants.js +5 -3
  91. package/dist/cjs/stories/decorators/index.js +13 -11
  92. package/dist/cjs/test/dashboard-provider.js +8 -4
  93. package/dist/cjs/test/datasource-provider.js +16 -12
  94. package/dist/cjs/test/index.js +13 -11
  95. package/dist/cjs/test/plugin-registry.js +6 -4
  96. package/dist/cjs/test/render.js +27 -20
  97. package/dist/cjs/test/setup-tests.js +2 -2
  98. package/dist/cjs/test/testDashboard.js +13 -11
  99. package/dist/cjs/utils/index.js +11 -9
  100. package/dist/cjs/utils/panelUtils.js +9 -3
  101. package/dist/cjs/utils/time.js +5 -3
  102. package/dist/cjs/validation/index.js +30 -0
  103. package/dist/cjs/validation/panel.js +29 -0
  104. package/dist/cjs/views/ViewDashboard/DashboardApp.js +20 -16
  105. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +63 -19
  106. package/dist/cjs/views/ViewDashboard/index.js +10 -8
  107. package/dist/cjs/views/index.js +10 -8
  108. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
  109. package/dist/components/AddGroupButton/index.js.map +1 -1
  110. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  111. package/dist/components/AddPanelButton/index.js.map +1 -1
  112. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  113. package/dist/components/Dashboard/index.js.map +1 -1
  114. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  115. package/dist/components/DashboardStickyToolbar/index.js.map +1 -1
  116. package/dist/components/DashboardToolbar/DashboardToolbar.js +1 -1
  117. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  118. package/dist/components/DashboardToolbar/index.js.map +1 -1
  119. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  120. package/dist/components/DeletePanelDialog/index.js.map +1 -1
  121. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -2
  122. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  123. package/dist/components/DeletePanelGroupDialog/index.js.map +1 -1
  124. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  125. package/dist/components/DiscardChangesConfirmationDialog/index.js.map +1 -1
  126. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  127. package/dist/components/DownloadButton/index.js.map +1 -1
  128. package/dist/components/EditButton/EditButton.js.map +1 -1
  129. package/dist/components/EditButton/index.js.map +1 -1
  130. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  131. package/dist/components/EditJsonButton/index.js.map +1 -1
  132. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +4 -1
  133. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  134. package/dist/components/EditJsonDialog/EditJsonDialog.js +12 -8
  135. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  136. package/dist/components/EditJsonDialog/index.js.map +1 -1
  137. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
  138. package/dist/components/EmptyDashboard/index.js.map +1 -1
  139. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  140. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  141. package/dist/components/GridLayout/GridItemContent.js +27 -10
  142. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  143. package/dist/components/GridLayout/GridLayout.js +2 -2
  144. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  145. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  146. package/dist/components/GridLayout/index.js.map +1 -1
  147. package/dist/components/Panel/Panel.d.ts.map +1 -1
  148. package/dist/components/Panel/Panel.js +4 -11
  149. package/dist/components/Panel/Panel.js.map +1 -1
  150. package/dist/components/Panel/PanelContent.js.map +1 -1
  151. package/dist/components/Panel/PanelHeader.js.map +1 -1
  152. package/dist/components/Panel/index.js.map +1 -1
  153. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  154. package/dist/components/PanelDrawer/PanelDrawer.js +22 -76
  155. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  156. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +4 -1
  157. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  158. package/dist/components/PanelDrawer/PanelEditorForm.js +223 -138
  159. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  160. package/dist/components/PanelDrawer/PanelPreview.js +2 -2
  161. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  162. package/dist/components/PanelDrawer/index.js.map +1 -1
  163. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
  164. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  165. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  166. package/dist/components/PanelGroupDialog/index.js.map +1 -1
  167. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +4 -4
  168. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  169. package/dist/components/QuerySummaryTable/index.js.map +1 -1
  170. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -4
  171. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  172. package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -1
  173. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  174. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +1 -3
  175. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  176. package/dist/components/SaveDashboardButton/index.js.map +1 -1
  177. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  178. package/dist/components/TimeRangeControls/TimeRangeControls.js +19 -1
  179. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  180. package/dist/components/TimeRangeControls/index.js.map +1 -1
  181. package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  182. package/dist/components/ToolbarIconButton/index.js.map +1 -1
  183. package/dist/components/Variables/BuiltinVariableAccordions.d.ts +8 -0
  184. package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -0
  185. package/dist/components/Variables/BuiltinVariableAccordions.js +127 -0
  186. package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -0
  187. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  188. package/dist/components/Variables/EditVariablesButton.js +3 -0
  189. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  190. package/dist/components/Variables/TemplateVariable.d.ts +10 -1
  191. package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
  192. package/dist/components/Variables/TemplateVariable.js +91 -54
  193. package/dist/components/Variables/TemplateVariable.js.map +1 -1
  194. package/dist/components/Variables/VariableEditor.d.ts +2 -1
  195. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  196. package/dist/components/Variables/VariableEditor.js +229 -157
  197. package/dist/components/Variables/VariableEditor.js.map +1 -1
  198. package/dist/components/Variables/VariableList.js +6 -6
  199. package/dist/components/Variables/VariableList.js.map +1 -1
  200. package/dist/components/Variables/index.d.ts +1 -0
  201. package/dist/components/Variables/index.d.ts.map +1 -1
  202. package/dist/components/Variables/index.js +1 -0
  203. package/dist/components/Variables/index.js.map +1 -1
  204. package/dist/components/index.js.map +1 -1
  205. package/dist/constants/grid-layout-config.js.map +1 -1
  206. package/dist/constants/index.js.map +1 -1
  207. package/dist/constants/user-interface-text.js.map +1 -1
  208. package/dist/context/DashboardProvider/DashboardProvider.js +5 -5
  209. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  210. package/dist/context/DashboardProvider/common.js.map +1 -1
  211. package/dist/context/DashboardProvider/dashboard-provider-api.js +2 -2
  212. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  213. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  214. package/dist/context/DashboardProvider/delete-panel-slice.js +2 -2
  215. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  216. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
  217. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  218. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
  219. package/dist/context/DashboardProvider/index.js.map +1 -1
  220. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -1
  221. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  222. package/dist/context/DashboardProvider/panel-editor-slice.js +7 -7
  223. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  224. package/dist/context/DashboardProvider/panel-group-editor-slice.js +2 -2
  225. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  226. package/dist/context/DashboardProvider/panel-group-slice.js +3 -3
  227. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  228. package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
  229. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  230. package/dist/context/DatasourceStoreProvider.d.ts +14 -10
  231. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  232. package/dist/context/DatasourceStoreProvider.js +107 -40
  233. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  234. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +10 -4
  235. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  236. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +93 -18
  237. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  238. package/dist/context/TemplateVariableProvider/hydrationUtils.js +7 -7
  239. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
  240. package/dist/context/TemplateVariableProvider/index.js.map +1 -1
  241. package/dist/context/TemplateVariableProvider/query-params.js.map +1 -1
  242. package/dist/context/TemplateVariableProvider/utils.js +3 -3
  243. package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
  244. package/dist/context/index.js.map +1 -1
  245. package/dist/context/useDashboard.js +1 -1
  246. package/dist/context/useDashboard.js.map +1 -1
  247. package/dist/index.js.map +1 -1
  248. package/dist/stories/decorators/WithDashboard.js.map +1 -1
  249. package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
  250. package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
  251. package/dist/stories/decorators/constants.js +2 -2
  252. package/dist/stories/decorators/constants.js.map +1 -1
  253. package/dist/stories/decorators/index.js.map +1 -1
  254. package/dist/test/dashboard-provider.js.map +1 -1
  255. package/dist/test/datasource-provider.d.ts.map +1 -1
  256. package/dist/test/datasource-provider.js +5 -7
  257. package/dist/test/datasource-provider.js.map +1 -1
  258. package/dist/test/index.js.map +1 -1
  259. package/dist/test/plugin-registry.js.map +1 -1
  260. package/dist/test/render.d.ts.map +1 -1
  261. package/dist/test/render.js +6 -1
  262. package/dist/test/render.js.map +1 -1
  263. package/dist/test/setup-tests.js.map +1 -1
  264. package/dist/test/testDashboard.js +10 -10
  265. package/dist/test/testDashboard.js.map +1 -1
  266. package/dist/utils/index.js.map +1 -1
  267. package/dist/utils/panelUtils.js.map +1 -1
  268. package/dist/utils/time.js.map +1 -1
  269. package/dist/validation/index.d.ts +2 -0
  270. package/dist/validation/index.d.ts.map +1 -0
  271. package/dist/validation/index.js +15 -0
  272. package/dist/validation/index.js.map +1 -0
  273. package/dist/validation/panel.d.ts +19 -0
  274. package/dist/validation/panel.d.ts.map +1 -0
  275. package/dist/validation/panel.js +21 -0
  276. package/dist/validation/panel.js.map +1 -0
  277. package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
  278. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  279. package/dist/views/ViewDashboard/DashboardApp.js +4 -2
  280. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  281. package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
  282. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  283. package/dist/views/ViewDashboard/ViewDashboard.js +49 -7
  284. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  285. package/dist/views/ViewDashboard/index.js.map +1 -1
  286. package/dist/views/index.js.map +1 -1
  287. package/package.json +8 -7
@@ -12,7 +12,7 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { useState, useMemo } from 'react';
15
- import { Button, Stack, Box, TableContainer, TableBody, TableRow, TableCell as MuiTableCell, Table, TableHead, Switch, Typography, IconButton, Alert, styled, capitalize, Tooltip } from '@mui/material';
15
+ import { Button, Stack, Box, TableContainer, TableBody, TableRow, TableCell as MuiTableCell, Table, TableHead, Switch, Typography, IconButton, Alert, styled, capitalize, Tooltip, Accordion, AccordionSummary, AccordionDetails } from '@mui/material';
16
16
  import AddIcon from 'mdi-material-ui/Plus';
17
17
  import { useImmer } from 'use-immer';
18
18
  import PencilIcon from 'mdi-material-ui/Pencil';
@@ -20,12 +20,16 @@ import TrashIcon from 'mdi-material-ui/TrashCan';
20
20
  import ArrowUp from 'mdi-material-ui/ArrowUp';
21
21
  import ArrowDown from 'mdi-material-ui/ArrowDown';
22
22
  import ContentDuplicate from 'mdi-material-ui/ContentDuplicate';
23
- import { VariableEditForm, VARIABLE_TYPES } from '@perses-dev/plugin-system';
23
+ import OpenInNewIcon from 'mdi-material-ui/OpenInNew';
24
+ import ExpandMoreIcon from 'mdi-material-ui/ChevronUp';
25
+ import { VariableEditorForm, VARIABLE_TYPES } from '@perses-dev/plugin-system';
26
+ import { InfoTooltip } from '@perses-dev/components';
24
27
  import { useDiscardChangesConfirmationDialog } from '../../context';
25
28
  import { hydrateTemplateVariableStates } from '../../context/TemplateVariableProvider/hydrationUtils';
29
+ import { BuiltinVariableAccordions } from './BuiltinVariableAccordions';
26
30
  function getVariableLabelByKind(kind) {
27
- var ref;
28
- return (ref = VARIABLE_TYPES.find((variableType)=>variableType.kind === kind)) === null || ref === void 0 ? void 0 : ref.label;
31
+ var _VARIABLE_TYPES_find;
32
+ return (_VARIABLE_TYPES_find = VARIABLE_TYPES.find((variableType)=>variableType.kind === kind)) === null || _VARIABLE_TYPES_find === void 0 ? void 0 : _VARIABLE_TYPES_find.label;
29
33
  }
30
34
  function getValidation(variableDefinitions) {
31
35
  const errors = [];
@@ -44,6 +48,7 @@ export function VariableEditor(props) {
44
48
  const [variableEditIdx, setVariableEditIdx] = useState(null);
45
49
  const [variableFormAction, setVariableFormAction] = useState('update');
46
50
  const externalVariableDefinitions = props.externalVariableDefinitions;
51
+ const builtinVariableDefinitions = props.builtinVariableDefinitions;
47
52
  const validation = useMemo(()=>getValidation(variableDefinitions), [
48
53
  variableDefinitions
49
54
  ]);
@@ -122,11 +127,11 @@ export function VariableEditor(props) {
122
127
  draft[index] = prevElement;
123
128
  } else {
124
129
  const nextElement = draft[index + 1];
125
- const currentElement1 = draft[index];
126
- if (index === draft.length - 1 || !nextElement || !currentElement1) {
130
+ const currentElement = draft[index];
131
+ if (index === draft.length - 1 || !nextElement || !currentElement) {
127
132
  return;
128
133
  }
129
- draft[index + 1] = currentElement1;
134
+ draft[index + 1] = currentElement;
130
135
  draft[index] = nextElement;
131
136
  }
132
137
  });
@@ -136,24 +141,25 @@ export function VariableEditor(props) {
136
141
  draft.push(v);
137
142
  });
138
143
  };
139
- var ref, ref1;
144
+ var _getVariableLabelByKind, _v_spec_display_description, _getVariableLabelByKind1, _v_spec_display_description1;
140
145
  return /*#__PURE__*/ _jsxs(_Fragment, {
141
146
  children: [
142
- currentEditingVariableDefinition && /*#__PURE__*/ _jsx(VariableEditForm, {
147
+ currentEditingVariableDefinition && /*#__PURE__*/ _jsx(VariableEditorForm, {
143
148
  initialVariableDefinition: currentEditingVariableDefinition,
144
- onChange: (definition)=>{
149
+ initialAction: variableFormAction,
150
+ isDraft: true,
151
+ onSave: (definition)=>{
145
152
  setVariableDefinitions((draft)=>{
146
153
  draft[variableEditIdx] = definition;
147
154
  setVariableEditIdx(null);
148
155
  });
149
156
  },
150
- onCancel: ()=>{
157
+ onClose: ()=>{
151
158
  if (variableFormAction === 'create') {
152
159
  removeVariable(variableEditIdx);
153
160
  }
154
161
  setVariableEditIdx(null);
155
- },
156
- action: variableFormAction
162
+ }
157
163
  }),
158
164
  !currentEditingVariableDefinition && /*#__PURE__*/ _jsxs(_Fragment, {
159
165
  children: [
@@ -167,7 +173,7 @@ export function VariableEditor(props) {
167
173
  children: [
168
174
  /*#__PURE__*/ _jsx(Typography, {
169
175
  variant: "h2",
170
- children: "Dashboard Variables"
176
+ children: "Edit Dashboard Variables"
171
177
  }),
172
178
  /*#__PURE__*/ _jsxs(Stack, {
173
179
  direction: "row",
@@ -192,129 +198,21 @@ export function VariableEditor(props) {
192
198
  })
193
199
  ]
194
200
  }),
195
- /*#__PURE__*/ _jsxs(Box, {
201
+ /*#__PURE__*/ _jsx(Box, {
196
202
  padding: 2,
197
203
  sx: {
198
204
  overflowY: 'scroll'
199
205
  },
200
- children: [
201
- /*#__PURE__*/ _jsxs(Stack, {
202
- spacing: 2,
203
- children: [
204
- !validation.isValid && validation.errors.map((error)=>/*#__PURE__*/ _jsx(Alert, {
205
- severity: "error",
206
- children: error
207
- }, error)),
208
- /*#__PURE__*/ _jsx(TableContainer, {
209
- children: /*#__PURE__*/ _jsxs(Table, {
210
- sx: {
211
- minWidth: 650
212
- },
213
- "aria-label": "table of variables",
214
- children: [
215
- /*#__PURE__*/ _jsx(TableHead, {
216
- children: /*#__PURE__*/ _jsxs(TableRow, {
217
- children: [
218
- /*#__PURE__*/ _jsx(TableCell, {
219
- children: "Visibility"
220
- }),
221
- /*#__PURE__*/ _jsx(TableCell, {
222
- children: "Name"
223
- }),
224
- /*#__PURE__*/ _jsx(TableCell, {
225
- children: "Type"
226
- }),
227
- /*#__PURE__*/ _jsx(TableCell, {
228
- align: "right"
229
- })
230
- ]
231
- })
232
- }),
233
- /*#__PURE__*/ _jsx(TableBody, {
234
- children: variableDefinitions.map((v, idx)=>{
235
- var ref1;
236
- /*#__PURE__*/ return _jsxs(TableRow, {
237
- children: [
238
- /*#__PURE__*/ _jsx(TableCell, {
239
- component: "th",
240
- scope: "row",
241
- children: /*#__PURE__*/ _jsx(Switch, {
242
- checked: ((ref1 = v.spec.display) === null || ref1 === void 0 ? void 0 : ref1.hidden) !== true,
243
- onChange: (e)=>{
244
- toggleVariableVisibility(idx, e.target.checked);
245
- }
246
- })
247
- }),
248
- /*#__PURE__*/ _jsx(TableCell, {
249
- component: "th",
250
- scope: "row",
251
- sx: {
252
- fontWeight: 'bold'
253
- },
254
- children: /*#__PURE__*/ _jsx(VariableName, {
255
- name: v.spec.name,
256
- state: variableState.get({
257
- name: v.spec.name
258
- })
259
- })
260
- }),
261
- /*#__PURE__*/ _jsx(TableCell, {
262
- children: (ref = getVariableLabelByKind(v.kind)) !== null && ref !== void 0 ? ref : v.kind
263
- }),
264
- /*#__PURE__*/ _jsxs(TableCell, {
265
- align: "right",
266
- children: [
267
- /*#__PURE__*/ _jsx(IconButton, {
268
- onClick: ()=>changeVariableOrder(idx, 'up'),
269
- disabled: idx === 0,
270
- children: /*#__PURE__*/ _jsx(ArrowUp, {})
271
- }),
272
- /*#__PURE__*/ _jsx(IconButton, {
273
- onClick: ()=>changeVariableOrder(idx, 'down'),
274
- disabled: idx === variableDefinitions.length - 1,
275
- children: /*#__PURE__*/ _jsx(ArrowDown, {})
276
- }),
277
- /*#__PURE__*/ _jsx(IconButton, {
278
- onClick: ()=>editVariable(idx),
279
- children: /*#__PURE__*/ _jsx(PencilIcon, {})
280
- }),
281
- /*#__PURE__*/ _jsx(IconButton, {
282
- onClick: ()=>removeVariable(idx),
283
- children: /*#__PURE__*/ _jsx(TrashIcon, {})
284
- })
285
- ]
286
- })
287
- ]
288
- }, v.spec.name);
289
- })
290
- })
291
- ]
292
- })
293
- }),
294
- /*#__PURE__*/ _jsx(Box, {
295
- display: "flex",
296
- children: /*#__PURE__*/ _jsx(Button, {
297
- variant: "contained",
298
- startIcon: /*#__PURE__*/ _jsx(AddIcon, {}),
299
- sx: {
300
- marginLeft: 'auto'
301
- },
302
- onClick: addVariable,
303
- children: "Add Variable"
304
- })
305
- })
306
- ]
307
- }),
308
- externalVariableDefinitions.map((extVar)=>{
309
- /*#__PURE__*/ return _jsxs(Stack, {
206
+ children: /*#__PURE__*/ _jsxs(Stack, {
207
+ spacing: 2,
208
+ children: [
209
+ /*#__PURE__*/ _jsxs(Stack, {
210
+ spacing: 2,
310
211
  children: [
311
- /*#__PURE__*/ _jsxs(Typography, {
312
- variant: "h2",
313
- children: [
314
- capitalize(extVar.source),
315
- " Variables"
316
- ]
317
- }),
212
+ !validation.isValid && validation.errors.map((error)=>/*#__PURE__*/ _jsx(Alert, {
213
+ severity: "error",
214
+ children: error
215
+ }, error)),
318
216
  /*#__PURE__*/ _jsx(TableContainer, {
319
217
  children: /*#__PURE__*/ _jsxs(Table, {
320
218
  sx: {
@@ -335,22 +233,28 @@ export function VariableEditor(props) {
335
233
  children: "Type"
336
234
  }),
337
235
  /*#__PURE__*/ _jsx(TableCell, {
338
- align: "right"
236
+ children: "Description"
237
+ }),
238
+ /*#__PURE__*/ _jsx(TableCell, {
239
+ align: "right",
240
+ children: "Actions"
339
241
  })
340
242
  ]
341
243
  })
342
244
  }),
343
245
  /*#__PURE__*/ _jsx(TableBody, {
344
- children: extVar.definitions.map((v)=>{
345
- var ref;
246
+ children: variableDefinitions.map((v, idx)=>{
247
+ var _v_spec_display, _v_spec_display1;
346
248
  /*#__PURE__*/ return _jsxs(TableRow, {
347
249
  children: [
348
250
  /*#__PURE__*/ _jsx(TableCell, {
349
251
  component: "th",
350
252
  scope: "row",
351
253
  children: /*#__PURE__*/ _jsx(Switch, {
352
- checked: ((ref = v.spec.display) === null || ref === void 0 ? void 0 : ref.hidden) !== true,
353
- disabled: true
254
+ checked: ((_v_spec_display = v.spec.display) === null || _v_spec_display === void 0 ? void 0 : _v_spec_display.hidden) !== true,
255
+ onChange: (e)=>{
256
+ toggleVariableVisibility(idx, e.target.checked);
257
+ }
354
258
  })
355
259
  }),
356
260
  /*#__PURE__*/ _jsx(TableCell, {
@@ -362,41 +266,38 @@ export function VariableEditor(props) {
362
266
  children: /*#__PURE__*/ _jsx(VariableName, {
363
267
  name: v.spec.name,
364
268
  state: variableState.get({
365
- name: v.spec.name,
366
- source: extVar.source
269
+ name: v.spec.name
367
270
  })
368
271
  })
369
272
  }),
370
273
  /*#__PURE__*/ _jsx(TableCell, {
371
- children: (ref1 = getVariableLabelByKind(v.kind)) !== null && ref1 !== void 0 ? ref1 : v.kind
274
+ children: (_getVariableLabelByKind = getVariableLabelByKind(v.kind)) !== null && _getVariableLabelByKind !== void 0 ? _getVariableLabelByKind : v.kind
275
+ }),
276
+ /*#__PURE__*/ _jsx(TableCell, {
277
+ children: (_v_spec_display_description = (_v_spec_display1 = v.spec.display) === null || _v_spec_display1 === void 0 ? void 0 : _v_spec_display1.description) !== null && _v_spec_display_description !== void 0 ? _v_spec_display_description : ''
372
278
  }),
373
279
  /*#__PURE__*/ _jsxs(TableCell, {
374
280
  align: "right",
281
+ sx: {
282
+ whiteSpace: 'nowrap'
283
+ },
375
284
  children: [
376
- /*#__PURE__*/ _jsx(Tooltip, {
377
- title: "Override",
378
- children: /*#__PURE__*/ _jsx(IconButton, {
379
- onClick: ()=>overrideVariable(v),
380
- disabled: !!variableState.get({
381
- name: v.spec.name
382
- }),
383
- children: /*#__PURE__*/ _jsx(ContentDuplicate, {})
384
- })
385
- }),
386
285
  /*#__PURE__*/ _jsx(IconButton, {
387
- disabled: true,
286
+ onClick: ()=>changeVariableOrder(idx, 'up'),
287
+ disabled: idx === 0,
388
288
  children: /*#__PURE__*/ _jsx(ArrowUp, {})
389
289
  }),
390
290
  /*#__PURE__*/ _jsx(IconButton, {
391
- disabled: true,
291
+ onClick: ()=>changeVariableOrder(idx, 'down'),
292
+ disabled: idx === variableDefinitions.length - 1,
392
293
  children: /*#__PURE__*/ _jsx(ArrowDown, {})
393
294
  }),
394
295
  /*#__PURE__*/ _jsx(IconButton, {
395
- disabled: true,
296
+ onClick: ()=>editVariable(idx),
396
297
  children: /*#__PURE__*/ _jsx(PencilIcon, {})
397
298
  }),
398
299
  /*#__PURE__*/ _jsx(IconButton, {
399
- disabled: true,
300
+ onClick: ()=>removeVariable(idx),
400
301
  children: /*#__PURE__*/ _jsx(TrashIcon, {})
401
302
  })
402
303
  ]
@@ -407,11 +308,182 @@ export function VariableEditor(props) {
407
308
  })
408
309
  ]
409
310
  })
311
+ }),
312
+ /*#__PURE__*/ _jsx(Box, {
313
+ display: "flex",
314
+ children: /*#__PURE__*/ _jsx(Button, {
315
+ variant: "contained",
316
+ startIcon: /*#__PURE__*/ _jsx(AddIcon, {}),
317
+ sx: {
318
+ marginLeft: 'auto'
319
+ },
320
+ onClick: addVariable,
321
+ children: "Add Variable"
322
+ })
410
323
  })
411
324
  ]
412
- }, extVar.source);
413
- })
414
- ]
325
+ }),
326
+ externalVariableDefinitions && !externalVariableDefinitions.every((v)=>v.definitions.length === 0) && externalVariableDefinitions.map((extVar)=>{
327
+ return extVar.definitions.length > 0 && /*#__PURE__*/ _jsxs(Accordion, {
328
+ sx: (theme)=>({
329
+ '.MuiAccordionSummary-root': {
330
+ backgroundColor: theme.palette.background.lighter
331
+ },
332
+ '.MuiAccordionDetails-root': {
333
+ backgroundColor: theme.palette.background.lighter
334
+ }
335
+ }),
336
+ children: [
337
+ /*#__PURE__*/ _jsx(AccordionSummary, {
338
+ expandIcon: /*#__PURE__*/ _jsx(ExpandMoreIcon, {}),
339
+ "aria-controls": extVar.source,
340
+ id: extVar.source,
341
+ children: /*#__PURE__*/ _jsx(Stack, {
342
+ flexDirection: "row",
343
+ alignItems: "center",
344
+ justifyContent: "start",
345
+ children: /*#__PURE__*/ _jsxs(_Fragment, {
346
+ children: [
347
+ extVar.tooltip ? /*#__PURE__*/ _jsx(Typography, {
348
+ variant: "h2",
349
+ children: /*#__PURE__*/ _jsx(InfoTooltip, {
350
+ title: extVar.tooltip.title || '',
351
+ description: extVar.tooltip.description || '',
352
+ children: /*#__PURE__*/ _jsxs("span", {
353
+ children: [
354
+ capitalize(extVar.source),
355
+ " Variables"
356
+ ]
357
+ })
358
+ })
359
+ }) : /*#__PURE__*/ _jsxs(Typography, {
360
+ variant: "h2",
361
+ children: [
362
+ capitalize(extVar.source),
363
+ " Variables"
364
+ ]
365
+ }),
366
+ extVar.editLink && /*#__PURE__*/ _jsx(IconButton, {
367
+ href: extVar.editLink,
368
+ target: "_blank",
369
+ children: /*#__PURE__*/ _jsx(OpenInNewIcon, {
370
+ fontSize: "small"
371
+ })
372
+ })
373
+ ]
374
+ })
375
+ })
376
+ }),
377
+ /*#__PURE__*/ _jsx(AccordionDetails, {
378
+ children: /*#__PURE__*/ _jsx(TableContainer, {
379
+ children: /*#__PURE__*/ _jsxs(Table, {
380
+ sx: {
381
+ minWidth: 650
382
+ },
383
+ "aria-label": "table of external variables",
384
+ children: [
385
+ /*#__PURE__*/ _jsx(TableHead, {
386
+ children: /*#__PURE__*/ _jsxs(TableRow, {
387
+ children: [
388
+ /*#__PURE__*/ _jsx(TableCell, {
389
+ children: "Visibility"
390
+ }),
391
+ /*#__PURE__*/ _jsx(TableCell, {
392
+ children: "Name"
393
+ }),
394
+ /*#__PURE__*/ _jsx(TableCell, {
395
+ children: "Type"
396
+ }),
397
+ /*#__PURE__*/ _jsx(TableCell, {
398
+ children: "Description"
399
+ }),
400
+ /*#__PURE__*/ _jsx(TableCell, {
401
+ align: "right",
402
+ children: "Actions"
403
+ })
404
+ ]
405
+ })
406
+ }),
407
+ /*#__PURE__*/ _jsx(TableBody, {
408
+ children: extVar.definitions.map((v)=>{
409
+ var _v_spec_display, _v_spec_display1;
410
+ /*#__PURE__*/ return _jsxs(TableRow, {
411
+ children: [
412
+ /*#__PURE__*/ _jsx(TableCell, {
413
+ component: "th",
414
+ scope: "row",
415
+ children: /*#__PURE__*/ _jsx(Switch, {
416
+ checked: ((_v_spec_display = v.spec.display) === null || _v_spec_display === void 0 ? void 0 : _v_spec_display.hidden) !== true,
417
+ disabled: true
418
+ })
419
+ }),
420
+ /*#__PURE__*/ _jsx(TableCell, {
421
+ component: "th",
422
+ scope: "row",
423
+ sx: {
424
+ fontWeight: 'bold'
425
+ },
426
+ children: /*#__PURE__*/ _jsx(VariableName, {
427
+ name: v.spec.name,
428
+ state: variableState.get({
429
+ name: v.spec.name,
430
+ source: extVar.source
431
+ })
432
+ })
433
+ }),
434
+ /*#__PURE__*/ _jsx(TableCell, {
435
+ children: (_getVariableLabelByKind1 = getVariableLabelByKind(v.kind)) !== null && _getVariableLabelByKind1 !== void 0 ? _getVariableLabelByKind1 : v.kind
436
+ }),
437
+ /*#__PURE__*/ _jsx(TableCell, {
438
+ children: (_v_spec_display_description1 = (_v_spec_display1 = v.spec.display) === null || _v_spec_display1 === void 0 ? void 0 : _v_spec_display1.description) !== null && _v_spec_display_description1 !== void 0 ? _v_spec_display_description1 : ''
439
+ }),
440
+ /*#__PURE__*/ _jsxs(TableCell, {
441
+ align: "right",
442
+ children: [
443
+ /*#__PURE__*/ _jsx(Tooltip, {
444
+ title: "Override",
445
+ children: /*#__PURE__*/ _jsx(IconButton, {
446
+ onClick: ()=>overrideVariable(v),
447
+ disabled: !!variableState.get({
448
+ name: v.spec.name
449
+ }),
450
+ children: /*#__PURE__*/ _jsx(ContentDuplicate, {})
451
+ })
452
+ }),
453
+ /*#__PURE__*/ _jsx(IconButton, {
454
+ disabled: true,
455
+ children: /*#__PURE__*/ _jsx(ArrowUp, {})
456
+ }),
457
+ /*#__PURE__*/ _jsx(IconButton, {
458
+ disabled: true,
459
+ children: /*#__PURE__*/ _jsx(ArrowDown, {})
460
+ }),
461
+ /*#__PURE__*/ _jsx(IconButton, {
462
+ disabled: true,
463
+ children: /*#__PURE__*/ _jsx(PencilIcon, {})
464
+ }),
465
+ /*#__PURE__*/ _jsx(IconButton, {
466
+ disabled: true,
467
+ children: /*#__PURE__*/ _jsx(TrashIcon, {})
468
+ })
469
+ ]
470
+ })
471
+ ]
472
+ }, v.spec.name);
473
+ })
474
+ })
475
+ ]
476
+ })
477
+ })
478
+ })
479
+ ]
480
+ });
481
+ }),
482
+ builtinVariableDefinitions && /*#__PURE__*/ _jsx(BuiltinVariableAccordions, {
483
+ builtinVariableDefinitions: builtinVariableDefinitions
484
+ })
485
+ ]
486
+ })
415
487
  })
416
488
  ]
417
489
  })