@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,236 @@
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, "VariableEditForm", {
18
+ enumerable: true,
19
+ get: ()=>VariableEditForm
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
23
+ const _material = require("@mui/material");
24
+ const _useImmer = require("use-immer");
25
+ const _pluginSystem = require("@perses-dev/plugin-system");
26
+ const _variableEditorFormModel = require("./variable-editor-form-model");
27
+ function _interopRequireDefault(obj) {
28
+ return obj && obj.__esModule ? obj : {
29
+ default: obj
30
+ };
31
+ }
32
+ const VARIABLE_TYPES = [
33
+ 'ListVariable',
34
+ 'TextVariable'
35
+ ];
36
+ const SectionHeader = ({ children })=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
37
+ pb: 2,
38
+ variant: "subtitle1",
39
+ children: children
40
+ });
41
+ function VariableEditForm({ initialVariableDefinition , onChange , onCancel }) {
42
+ const [state, setState] = (0, _useImmer.useImmer)((0, _variableEditorFormModel.getInitialState)(initialVariableDefinition));
43
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
44
+ children: [
45
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(SectionHeader, {
46
+ children: "General"
47
+ }),
48
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
49
+ container: true,
50
+ spacing: 2,
51
+ mb: 2,
52
+ children: [
53
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
54
+ item: true,
55
+ xs: 6,
56
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
57
+ label: "Name",
58
+ value: state.name,
59
+ onChange: (v)=>{
60
+ setState((draft)=>{
61
+ draft.name = v.target.value;
62
+ });
63
+ }
64
+ })
65
+ }),
66
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
67
+ item: true,
68
+ xs: 6,
69
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
70
+ fullWidth: true,
71
+ children: [
72
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
73
+ id: "variable-type-select-label",
74
+ children: "Type"
75
+ }),
76
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Select, {
77
+ labelId: "variable-type-select-label",
78
+ id: "variable-type-select",
79
+ label: "Type",
80
+ value: state.kind,
81
+ onChange: (v)=>{
82
+ setState((draft)=>{
83
+ draft.kind = v.target.value;
84
+ });
85
+ },
86
+ children: VARIABLE_TYPES.map((v)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
87
+ value: v,
88
+ children: v
89
+ }, v))
90
+ })
91
+ ]
92
+ })
93
+ }),
94
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
95
+ item: true,
96
+ xs: 6,
97
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
98
+ label: "Label",
99
+ value: state.label,
100
+ onChange: (v)=>{
101
+ setState((draft)=>{
102
+ draft.label = v.target.value;
103
+ });
104
+ }
105
+ })
106
+ }),
107
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
108
+ item: true,
109
+ xs: 12,
110
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
111
+ label: "Description",
112
+ value: state.description,
113
+ onChange: (v)=>{
114
+ setState((draft)=>{
115
+ draft.description = v.target.value;
116
+ });
117
+ }
118
+ })
119
+ })
120
+ ]
121
+ }),
122
+ state.kind === 'TextVariable' && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
123
+ children: [
124
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(SectionHeader, {
125
+ children: "Text Options"
126
+ }),
127
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
128
+ container: true,
129
+ spacing: 2,
130
+ mb: 2,
131
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
132
+ item: true,
133
+ xs: 12,
134
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
135
+ label: "Value",
136
+ value: state.textVariableFields.value,
137
+ onChange: (v)=>{
138
+ setState((draft)=>{
139
+ draft.textVariableFields.value = v.target.value;
140
+ });
141
+ }
142
+ })
143
+ })
144
+ })
145
+ ]
146
+ }),
147
+ state.kind === 'ListVariable' && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
148
+ children: [
149
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(SectionHeader, {
150
+ children: "List Options"
151
+ }),
152
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
153
+ container: true,
154
+ spacing: 2,
155
+ mb: 2,
156
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
157
+ item: true,
158
+ xs: 6,
159
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginEditor, {
160
+ width: 500,
161
+ pluginType: "Variable",
162
+ pluginKindLabel: "Source",
163
+ value: state.listVariableFields.plugin,
164
+ onChange: (val)=>{
165
+ setState((draft)=>{
166
+ draft.listVariableFields.plugin = val;
167
+ });
168
+ }
169
+ })
170
+ })
171
+ }),
172
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(SectionHeader, {
173
+ children: "Dropdown Options"
174
+ }),
175
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
176
+ container: true,
177
+ spacing: 1,
178
+ mb: 1,
179
+ children: [
180
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
181
+ item: true,
182
+ xs: 12,
183
+ children: [
184
+ "Allow Multiple",
185
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
186
+ checked: state.listVariableFields.allowMultiple,
187
+ onChange: (e)=>{
188
+ setState((draft)=>{
189
+ draft.listVariableFields.allowMultiple = e.target.checked;
190
+ });
191
+ }
192
+ })
193
+ ]
194
+ }),
195
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
196
+ item: true,
197
+ xs: 12,
198
+ children: [
199
+ "Allow All",
200
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
201
+ checked: state.listVariableFields.allowAll,
202
+ onChange: (e)=>{
203
+ setState((draft)=>{
204
+ draft.listVariableFields.allowAll = e.target.checked;
205
+ });
206
+ }
207
+ })
208
+ ]
209
+ })
210
+ ]
211
+ })
212
+ ]
213
+ }),
214
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
215
+ direction: 'row',
216
+ spacing: 2,
217
+ justifyContent: "end",
218
+ children: [
219
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
220
+ onClick: ()=>{
221
+ onCancel();
222
+ },
223
+ children: "Cancel"
224
+ }),
225
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
226
+ variant: "contained",
227
+ onClick: ()=>{
228
+ onChange((0, _variableEditorFormModel.getVariableDefinitionFromState)(state));
229
+ },
230
+ children: "Update Variable"
231
+ })
232
+ ]
233
+ })
234
+ ]
235
+ });
236
+ }
@@ -0,0 +1,28 @@
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
+ _exportStar(require("./VariableEditorForm"), exports);
18
+ function _exportStar(from, to) {
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
+ });
26
+ });
27
+ return from;
28
+ }
@@ -0,0 +1,88 @@
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
+ getInitialState: ()=>getInitialState,
25
+ getVariableDefinitionFromState: ()=>getVariableDefinitionFromState
26
+ });
27
+ function getInitialState(initialVariableDefinition) {
28
+ var ref;
29
+ var _value;
30
+ const textVariableFields = {
31
+ value: (_value = initialVariableDefinition.spec.value) !== null && _value !== void 0 ? _value : ''
32
+ };
33
+ const listVariableFields = {
34
+ allowMultiple: false,
35
+ allowAll: false,
36
+ plugin: {
37
+ kind: '',
38
+ spec: {}
39
+ }
40
+ };
41
+ if (initialVariableDefinition.kind === 'ListVariable') {
42
+ var _allow_all_value;
43
+ listVariableFields.allowMultiple = (_allow_all_value = initialVariableDefinition.spec.allow_all_value) !== null && _allow_all_value !== void 0 ? _allow_all_value : false;
44
+ var _allow_all_value1;
45
+ listVariableFields.allowAll = (_allow_all_value1 = initialVariableDefinition.spec.allow_all_value) !== null && _allow_all_value1 !== void 0 ? _allow_all_value1 : false;
46
+ listVariableFields.plugin = initialVariableDefinition.spec.plugin;
47
+ }
48
+ return {
49
+ name: initialVariableDefinition.spec.name,
50
+ label: (ref = initialVariableDefinition.spec.display) === null || ref === void 0 ? void 0 : ref.label,
51
+ kind: initialVariableDefinition.kind,
52
+ description: '',
53
+ listVariableFields,
54
+ textVariableFields
55
+ };
56
+ }
57
+ function getVariableDefinitionFromState(state) {
58
+ const { name , label , kind } = state;
59
+ const commonSpec = {
60
+ name,
61
+ display: {
62
+ label
63
+ }
64
+ };
65
+ if (kind === 'TextVariable') {
66
+ const textVariableDefinition = {
67
+ kind,
68
+ spec: {
69
+ ...commonSpec,
70
+ ...state.textVariableFields
71
+ }
72
+ };
73
+ return textVariableDefinition;
74
+ }
75
+ if (kind === 'ListVariable') {
76
+ const listVariableDefinition = {
77
+ kind,
78
+ spec: {
79
+ ...commonSpec,
80
+ allow_multiple: state.listVariableFields.allowMultiple,
81
+ allow_all_value: state.listVariableFields.allowAll,
82
+ plugin: state.listVariableFields.plugin
83
+ }
84
+ };
85
+ return listVariableDefinition;
86
+ }
87
+ throw new Error(`Unknown variable kind: ${kind}`);
88
+ }
@@ -21,92 +21,72 @@ Object.defineProperty(exports, "TemplateVariableList", {
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _react = require("react");
23
23
  const _material = require("@mui/material");
24
+ const _eye = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Eye"));
25
+ const _pencil = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Pencil"));
24
26
  const _context = require("../../context");
25
27
  const _variable = require("./Variable");
28
+ const _variableEditor = require("./VariableEditor");
29
+ function _interopRequireDefault(obj) {
30
+ return obj && obj.__esModule ? obj : {
31
+ default: obj
32
+ };
33
+ }
26
34
  function TemplateVariableList() {
27
35
  const [isEditing, setIsEditing] = (0, _react.useState)(false);
28
36
  const variableDefinitions = (0, _context.useTemplateVariableDefinitions)();
29
37
  const { isEditMode } = (0, _context.useEditMode)();
30
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
38
+ const [showVariablesInEditMode, setShowVariablesInEditMode] = (0, _react.useState)(true);
39
+ const showVariables = isEditMode ? showVariablesInEditMode : true;
40
+ const { setVariableDefinitions } = (0, _context.useTemplateVariableActions)();
41
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
31
42
  children: [
32
43
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Drawer, {
33
44
  anchor: 'right',
34
45
  open: isEditing,
35
- onClose: ()=>setIsEditing(false),
36
- children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
37
- width: 900,
38
- p: 4,
39
- children: [
40
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableContainer, {
41
- component: _material.Paper,
42
- children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Table, {
43
- sx: {
44
- minWidth: 650
45
- },
46
- "aria-label": "simple table",
47
- children: [
48
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableHead, {
49
- children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.TableRow, {
50
- children: [
51
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
52
- children: "Variable Name"
53
- }),
54
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
55
- align: "right",
56
- children: "Type"
57
- })
58
- ]
59
- })
60
- }),
61
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableBody, {
62
- children: variableDefinitions.map((v)=>/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.TableRow, {
63
- sx: {
64
- '&:last-child td, &:last-child th': {
65
- border: 0
66
- }
67
- },
68
- children: [
69
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
70
- component: "th",
71
- scope: "row",
72
- sx: {
73
- fontWeight: 'bold'
74
- },
75
- children: v.spec.name
76
- }),
77
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
78
- align: "right",
79
- children: v.kind
80
- })
81
- ]
82
- }, v.spec.name))
83
- })
84
- ]
85
- })
86
- }),
87
- /*#__PURE__*/ (0, _jsxRuntime.jsx)("pre", {
88
- children: JSON.stringify(variableDefinitions, null, 2)
89
- })
90
- ]
46
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variableEditor.VariableEditor, {
47
+ onCancel: ()=>{
48
+ setIsEditing(false);
49
+ },
50
+ variableDefinitions: variableDefinitions,
51
+ onChange: (v)=>{
52
+ setVariableDefinitions(v);
53
+ setIsEditing(false);
54
+ }
91
55
  })
92
56
  }),
57
+ isEditMode && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
58
+ pb: 2,
59
+ children: [
60
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Button, {
61
+ onClick: ()=>setShowVariablesInEditMode(!showVariablesInEditMode),
62
+ startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_eye.default, {}),
63
+ children: [
64
+ showVariablesInEditMode ? 'Hide' : 'Show',
65
+ " Variables"
66
+ ]
67
+ }),
68
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
69
+ onClick: ()=>setIsEditing(true),
70
+ startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencil.default, {}),
71
+ children: "Edit Variables"
72
+ })
73
+ ]
74
+ }),
93
75
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
94
76
  display: 'flex',
95
77
  justifyContent: "space-between",
96
- children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
78
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
97
79
  direction: 'row',
98
80
  spacing: 2,
99
- children: [
100
- variableDefinitions.map((v)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
101
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variable.TemplateVariable, {
102
- name: v.spec.name
103
- }, v.spec.name)
104
- }, v.spec.name)),
105
- isEditMode && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
106
- onClick: ()=>setIsEditing(true),
107
- children: "Modify Variables"
108
- })
109
- ]
81
+ children: showVariables && variableDefinitions.map((v)=>{
82
+ var ref;
83
+ /*#__PURE__*/ return (0, _jsxRuntime.jsx)(_material.Box, {
84
+ display: ((ref = v.spec.display) === null || ref === void 0 ? void 0 : ref.hidden) ? 'none' : undefined,
85
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variable.TemplateVariable, {
86
+ name: v.spec.name
87
+ }, v.spec.name)
88
+ }, v.spec.name);
89
+ })
110
90
  })
111
91
  })
112
92
  ]
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  _exportStar(require("./Variable"), exports);
18
18
  _exportStar(require("./VariableList"), exports);
19
+ _exportStar(require("./VariableEditorForm"), exports);
19
20
  function _exportStar(from, to) {
20
21
  Object.keys(from).forEach(function(k) {
21
22
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
@@ -18,6 +18,7 @@ _exportStar(require("./Dashboard"), exports);
18
18
  _exportStar(require("./GridLayout"), exports);
19
19
  _exportStar(require("./Panel"), exports);
20
20
  _exportStar(require("./PanelDrawer"), exports);
21
+ _exportStar(require("./PanelGroupDialog"), exports);
21
22
  _exportStar(require("./TimeRangeControls"), exports);
22
23
  _exportStar(require("./Variables"), exports);
23
24
  function _exportStar(from, to) {
@@ -0,0 +1,82 @@
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
+ DashboardContext: ()=>DashboardContext,
25
+ useDashboardStore: ()=>useDashboardStore,
26
+ DashboardProvider: ()=>DashboardProvider
27
+ });
28
+ const _jsxRuntime = require("react/jsx-runtime");
29
+ const _zustand = require("zustand");
30
+ const _middleware = require("zustand/middleware");
31
+ const _immer = require("zustand/middleware/immer");
32
+ const _shallow = /*#__PURE__*/ _interopRequireDefault(require("zustand/shallow"));
33
+ const _react = require("react");
34
+ const _panelGroupEditorSlice = require("./panel-group-editor-slice");
35
+ const _panelGroupSlice = require("./panel-group-slice");
36
+ const _panelEditorSlice = require("./panel-editor-slice");
37
+ function _interopRequireDefault(obj) {
38
+ return obj && obj.__esModule ? obj : {
39
+ default: obj
40
+ };
41
+ }
42
+ const DashboardContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
43
+ function useDashboardStore(selector) {
44
+ const store = (0, _react.useContext)(DashboardContext);
45
+ if (store === undefined) {
46
+ throw new Error('No DashboardContext found. Did you forget a Provider?');
47
+ }
48
+ return (0, _zustand.useStore)(store, selector, _shallow.default);
49
+ }
50
+ function DashboardProvider(props) {
51
+ const { children , initialState: { dashboardSpec , isEditMode } , } = props;
52
+ const { layouts , panels } = dashboardSpec;
53
+ const dashboardStore = (0, _zustand.createStore)()((0, _immer.immer)((0, _middleware.devtools)((...args)=>{
54
+ const [set, get] = args;
55
+ return {
56
+ ...(0, _panelGroupEditorSlice.createPanelGroupEditorSlice)(...args),
57
+ ...(0, _panelGroupSlice.createPanelGroupSlice)(layouts)(...args),
58
+ ...(0, _panelEditorSlice.createPanelEditorSlice)(panels)(...args),
59
+ defaultTimeRange: {
60
+ pastDuration: dashboardSpec.duration
61
+ },
62
+ isEditMode: !!isEditMode,
63
+ setEditMode: (isEditMode)=>set({
64
+ isEditMode
65
+ }),
66
+ reset: ()=>{
67
+ const { resetPanels , resetPanelGroups } = get();
68
+ resetPanels();
69
+ resetPanelGroups();
70
+ },
71
+ save: ()=>{
72
+ const { savePanels , savePanelGroups } = get();
73
+ savePanels();
74
+ savePanelGroups();
75
+ }
76
+ };
77
+ })));
78
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardContext.Provider, {
79
+ value: dashboardStore,
80
+ children: children
81
+ });
82
+ }
@@ -0,0 +1,18 @@
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
+ /**
14
+ * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).
15
+ */ "use strict";
16
+ Object.defineProperty(exports, "__esModule", {
17
+ value: true
18
+ });