@perses-dev/dashboards 0.52.0 → 0.53.0-beta.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 (178) hide show
  1. package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
  2. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -20
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +9 -67
  4. package/dist/cjs/components/GridLayout/GridLayout.js +1 -1
  5. package/dist/cjs/components/LeaveDialog/LeaveDialog.js +10 -1
  6. package/dist/cjs/components/Panel/Panel.js +4 -3
  7. package/dist/cjs/components/Panel/PanelHeader.js +1 -9
  8. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +186 -183
  9. package/dist/cjs/components/PanelDrawer/PanelPreview.js +3 -0
  10. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +6 -21
  11. package/dist/cjs/components/QueryViewerDialog/QueryViewerDialog.js +121 -0
  12. package/dist/cjs/components/QueryViewerDialog/index.js +30 -0
  13. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +18 -6
  14. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +11 -6
  15. package/dist/cjs/components/Variables/ListVariableListBox.js +201 -0
  16. package/dist/cjs/components/Variables/Variable.js +164 -72
  17. package/dist/cjs/components/Variables/VariableList.js +2 -2
  18. package/dist/cjs/components/Variables/index.js +1 -0
  19. package/dist/cjs/components/index.js +2 -1
  20. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +1 -1
  21. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -1
  22. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  23. package/dist/cjs/context/DashboardProvider/index.js +1 -1
  24. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +1 -1
  25. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -7
  26. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +1 -1
  27. package/dist/cjs/context/DatasourceStoreProvider.js +3 -4
  28. package/dist/cjs/context/PanelEditorProvider/PanelEditorProvider.js +49 -0
  29. package/dist/cjs/context/PanelEditorProvider/index.js +23 -0
  30. package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
  31. package/dist/cjs/context/VariableProvider/hydrationUtils.js +1 -1
  32. package/dist/cjs/context/VariableProvider/index.js +1 -1
  33. package/dist/cjs/context/VariableProvider/utils.js +1 -1
  34. package/dist/cjs/context/index.js +1 -0
  35. package/dist/cjs/context/useDashboard.js +1 -1
  36. package/dist/cjs/utils/panelUtils.js +1 -1
  37. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  38. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
  39. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  40. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  41. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -15
  42. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  43. package/dist/components/GridLayout/GridItemContent.d.ts +1 -1
  44. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  45. package/dist/components/GridLayout/GridItemContent.js +10 -68
  46. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  47. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  48. package/dist/components/GridLayout/GridLayout.js +1 -1
  49. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  50. package/dist/components/GridLayout/Row.d.ts +2 -2
  51. package/dist/components/GridLayout/Row.d.ts.map +1 -1
  52. package/dist/components/GridLayout/Row.js.map +1 -1
  53. package/dist/components/LeaveDialog/LeaveDialog.d.ts +2 -1
  54. package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -1
  55. package/dist/components/LeaveDialog/LeaveDialog.js +10 -1
  56. package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -1
  57. package/dist/components/Panel/Panel.d.ts +1 -2
  58. package/dist/components/Panel/Panel.d.ts.map +1 -1
  59. package/dist/components/Panel/Panel.js +5 -4
  60. package/dist/components/Panel/Panel.js.map +1 -1
  61. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  62. package/dist/components/Panel/PanelHeader.js +2 -10
  63. package/dist/components/Panel/PanelHeader.js.map +1 -1
  64. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  65. package/dist/components/PanelDrawer/PanelEditorForm.js +186 -183
  66. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  67. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  68. package/dist/components/PanelDrawer/PanelPreview.js +4 -1
  69. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  70. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  71. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +5 -15
  72. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  73. package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts +9 -0
  74. package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts.map +1 -0
  75. package/dist/components/QueryViewerDialog/QueryViewerDialog.js +72 -0
  76. package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -0
  77. package/dist/components/QueryViewerDialog/index.d.ts +2 -0
  78. package/dist/components/QueryViewerDialog/index.d.ts.map +1 -0
  79. package/dist/components/QueryViewerDialog/index.js +15 -0
  80. package/dist/components/QueryViewerDialog/index.js.map +1 -0
  81. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  82. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +19 -7
  83. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  84. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  85. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +11 -6
  86. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  87. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  88. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  89. package/dist/components/Variables/ListVariableListBox.d.ts +16 -0
  90. package/dist/components/Variables/ListVariableListBox.d.ts.map +1 -0
  91. package/dist/components/Variables/ListVariableListBox.js +141 -0
  92. package/dist/components/Variables/ListVariableListBox.js.map +1 -0
  93. package/dist/components/Variables/Variable.d.ts.map +1 -1
  94. package/dist/components/Variables/Variable.js +168 -75
  95. package/dist/components/Variables/Variable.js.map +1 -1
  96. package/dist/components/Variables/VariableEditor.d.ts +1 -2
  97. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  98. package/dist/components/Variables/VariableEditor.js.map +1 -1
  99. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  100. package/dist/components/Variables/VariableList.js +2 -2
  101. package/dist/components/Variables/VariableList.js.map +1 -1
  102. package/dist/components/Variables/index.d.ts +1 -0
  103. package/dist/components/Variables/index.d.ts.map +1 -1
  104. package/dist/components/Variables/index.js +1 -0
  105. package/dist/components/Variables/index.js.map +1 -1
  106. package/dist/components/index.d.ts +2 -1
  107. package/dist/components/index.d.ts.map +1 -1
  108. package/dist/components/index.js +2 -1
  109. package/dist/components/index.js.map +1 -1
  110. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -2
  111. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  112. package/dist/context/DashboardProvider/dashboard-provider-api.js +1 -1
  113. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  114. package/dist/context/DashboardProvider/delete-panel-slice.d.ts +2 -1
  115. package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -1
  116. package/dist/context/DashboardProvider/delete-panel-slice.js +1 -1
  117. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  118. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts +2 -1
  119. package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts.map +1 -1
  120. package/dist/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  121. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  122. package/dist/context/DashboardProvider/index.d.ts +0 -1
  123. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  124. package/dist/context/DashboardProvider/index.js +1 -1
  125. package/dist/context/DashboardProvider/index.js.map +1 -1
  126. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -2
  127. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  128. package/dist/context/DashboardProvider/panel-editor-slice.js +1 -1
  129. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  130. package/dist/context/DashboardProvider/panel-group-slice.d.ts +1 -24
  131. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  132. package/dist/context/DashboardProvider/panel-group-slice.js +1 -6
  133. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  134. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +2 -1
  135. package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -1
  136. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  137. package/dist/context/DashboardProvider/view-panel-slice.d.ts +1 -1
  138. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
  139. package/dist/context/DashboardProvider/view-panel-slice.js +1 -1
  140. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
  141. package/dist/context/DatasourceStoreProvider.d.ts +1 -17
  142. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  143. package/dist/context/DatasourceStoreProvider.js +2 -3
  144. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  145. package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts +13 -0
  146. package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts.map +1 -0
  147. package/dist/context/PanelEditorProvider/PanelEditorProvider.js +33 -0
  148. package/dist/context/PanelEditorProvider/PanelEditorProvider.js.map +1 -0
  149. package/dist/context/PanelEditorProvider/index.d.ts +3 -0
  150. package/dist/context/PanelEditorProvider/index.d.ts.map +1 -0
  151. package/dist/context/PanelEditorProvider/index.js +16 -0
  152. package/dist/context/PanelEditorProvider/index.js.map +1 -0
  153. package/dist/context/VariableProvider/VariableProvider.d.ts +1 -10
  154. package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -1
  155. package/dist/context/VariableProvider/VariableProvider.js +1 -1
  156. package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
  157. package/dist/context/VariableProvider/hydrationUtils.d.ts +1 -2
  158. package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -1
  159. package/dist/context/VariableProvider/hydrationUtils.js +1 -1
  160. package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
  161. package/dist/context/VariableProvider/index.js +1 -1
  162. package/dist/context/VariableProvider/index.js.map +1 -1
  163. package/dist/context/VariableProvider/utils.d.ts +1 -2
  164. package/dist/context/VariableProvider/utils.d.ts.map +1 -1
  165. package/dist/context/VariableProvider/utils.js +1 -1
  166. package/dist/context/VariableProvider/utils.js.map +1 -1
  167. package/dist/context/index.d.ts +1 -0
  168. package/dist/context/index.d.ts.map +1 -1
  169. package/dist/context/index.js +1 -0
  170. package/dist/context/index.js.map +1 -1
  171. package/dist/context/useDashboard.d.ts.map +1 -1
  172. package/dist/context/useDashboard.js +1 -1
  173. package/dist/context/useDashboard.js.map +1 -1
  174. package/dist/utils/panelUtils.d.ts +1 -2
  175. package/dist/utils/panelUtils.d.ts.map +1 -1
  176. package/dist/utils/panelUtils.js +1 -1
  177. package/dist/utils/panelUtils.js.map +1 -1
  178. package/package.json +5 -5
@@ -25,13 +25,16 @@ const _react = require("react");
25
25
  const _material = require("@mui/material");
26
26
  const _pluginsystem = require("@perses-dev/plugin-system");
27
27
  const _Panel = require("../Panel");
28
+ const _context = require("../../context");
28
29
  const PANEL_PREVIEW_HEIGHT = 300;
29
30
  const PANEL_PREVIEW_DEFAULT_WIDTH = 840;
30
31
  function PanelPreview({ panelDefinition }) {
31
32
  const boxRef = (0, _react.useRef)(null);
32
33
  let width = PANEL_PREVIEW_DEFAULT_WIDTH;
34
+ const panelEditorContext = (0, _react.useContext)(_context.PanelEditorContext);
33
35
  if (boxRef.current !== null) {
34
36
  width = boxRef.current.getBoundingClientRect().width;
37
+ panelEditorContext?.preview?.setPreviewPanelWidth?.(width);
35
38
  }
36
39
  const suggestedStepMs = (0, _pluginsystem.useSuggestedStepMs)(width);
37
40
  const { data: plugin, isLoading } = (0, _pluginsystem.usePlugin)('Panel', panelDefinition.spec.plugin.kind);
@@ -21,17 +21,12 @@ Object.defineProperty(exports, "PanelGroupDialog", {
21
21
  }
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
- const _material = require("@mui/material");
25
- const _Close = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Close"));
26
24
  const _react = require("react");
27
25
  const _pluginsystem = require("@perses-dev/plugin-system");
26
+ const _components = require("@perses-dev/components");
27
+ const _material = require("@mui/material");
28
28
  const _context = require("../../context");
29
29
  const _PanelGroupEditorForm = require("./PanelGroupEditorForm");
30
- function _interop_require_default(obj) {
31
- return obj && obj.__esModule ? obj : {
32
- default: obj
33
- };
34
- }
35
30
  function PanelGroupDialog() {
36
31
  const panelGroupEditor = (0, _context.usePanelGroupEditor)();
37
32
  const variables = (0, _pluginsystem.useVariableValues)();
@@ -53,30 +48,20 @@ function PanelGroupDialog() {
53
48
  panelGroupEditor.applyChanges(values);
54
49
  handleClose();
55
50
  };
56
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Dialog, {
51
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog, {
57
52
  open: isOpen,
58
53
  TransitionProps: {
59
54
  onExited: handleExited
60
55
  },
61
56
  children: panelGroupEditor !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
62
57
  children: [
63
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.DialogTitle, {
58
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.Dialog.Header, {
64
59
  children: [
65
60
  panelGroupEditor.mode,
66
61
  " Panel Group"
67
62
  ]
68
63
  }),
69
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
70
- "aria-label": "Close",
71
- onClick: panelGroupEditor.close,
72
- sx: (theme)=>({
73
- position: 'absolute',
74
- top: theme.spacing(0.5),
75
- right: theme.spacing(0.5)
76
- }),
77
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Close.default, {})
78
- }),
79
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.DialogContent, {
64
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.Content, {
80
65
  dividers: true,
81
66
  sx: {
82
67
  width: '500px'
@@ -87,7 +72,7 @@ function PanelGroupDialog() {
87
72
  onSubmit: handleSubmit
88
73
  })
89
74
  }),
90
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.DialogActions, {
75
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.Dialog.Actions, {
91
76
  children: [
92
77
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
93
78
  variant: "contained",
@@ -0,0 +1,121 @@
1
+ // Copyright 2025 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, "QueryViewerDialog", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return QueryViewerDialog;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
25
+ const _components = require("@perses-dev/components");
26
+ const _material = require("@mui/material");
27
+ const _pluginsystem = require("@perses-dev/plugin-system");
28
+ function _getRequireWildcardCache(nodeInterop) {
29
+ if (typeof WeakMap !== "function") return null;
30
+ var cacheBabelInterop = new WeakMap();
31
+ var cacheNodeInterop = new WeakMap();
32
+ return (_getRequireWildcardCache = function(nodeInterop) {
33
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
34
+ })(nodeInterop);
35
+ }
36
+ function _interop_require_wildcard(obj, nodeInterop) {
37
+ if (!nodeInterop && obj && obj.__esModule) {
38
+ return obj;
39
+ }
40
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
41
+ return {
42
+ default: obj
43
+ };
44
+ }
45
+ var cache = _getRequireWildcardCache(nodeInterop);
46
+ if (cache && cache.has(obj)) {
47
+ return cache.get(obj);
48
+ }
49
+ var newObj = {
50
+ __proto__: null
51
+ };
52
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
53
+ for(var key in obj){
54
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
55
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
56
+ if (desc && (desc.get || desc.set)) {
57
+ Object.defineProperty(newObj, key, desc);
58
+ } else {
59
+ newObj[key] = obj[key];
60
+ }
61
+ }
62
+ }
63
+ newObj.default = obj;
64
+ if (cache) {
65
+ cache.set(obj, newObj);
66
+ }
67
+ return newObj;
68
+ }
69
+ function QueryViewerDialog({ open, queryDefinitions, onClose }) {
70
+ const queryRows = (0, _react.useMemo)(()=>{
71
+ if (!queryDefinitions?.length) return null;
72
+ const queryItems = [];
73
+ queryDefinitions.forEach((query, index)=>{
74
+ if (query?.spec?.plugin?.kind && query?.kind) {
75
+ queryItems.push(/*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.default.Fragment, {
76
+ children: [
77
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PluginSpecEditor, {
78
+ value: query.spec.plugin.spec,
79
+ pluginSelection: {
80
+ kind: query.spec.plugin.kind,
81
+ type: query.kind
82
+ },
83
+ onChange: ()=>{},
84
+ isReadonly: true
85
+ }),
86
+ index < queryDefinitions.length - 1 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {
87
+ sx: {
88
+ my: 2
89
+ }
90
+ })
91
+ ]
92
+ }, `query-${index}`));
93
+ }
94
+ });
95
+ return queryItems;
96
+ }, [
97
+ queryDefinitions
98
+ ]);
99
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.Dialog, {
100
+ open: open,
101
+ onClose: onClose,
102
+ maxWidth: "lg",
103
+ fullWidth: true,
104
+ children: [
105
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.Header, {
106
+ children: "Query Viewer"
107
+ }),
108
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.Content, {
109
+ children: queryRows
110
+ }),
111
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.Actions, {
112
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
113
+ variant: "outlined",
114
+ color: "secondary",
115
+ onClick: onClose,
116
+ children: "Close"
117
+ })
118
+ })
119
+ ]
120
+ });
121
+ }
@@ -0,0 +1,30 @@
1
+ // Copyright 2025 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
+ _export_star(require("./QueryViewerDialog"), exports);
18
+ function _export_star(from, to) {
19
+ Object.keys(from).forEach(function(k) {
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
+ }
28
+ });
29
+ return from;
30
+ }
@@ -32,15 +32,19 @@ const SaveChangesConfirmationDialog = ()=>{
32
32
  const { saveChangesConfirmationDialog: dialog } = (0, _context.useSaveChangesConfirmationDialog)();
33
33
  const isSavedDurationModified = dialog?.isSavedDurationModified ?? true;
34
34
  const isSavedVariableModified = dialog?.isSavedVariableModified ?? true;
35
+ const isSavedRefreshIntervalModified = dialog?.isSavedRefreshIntervalModified ?? true;
35
36
  const [saveDefaultTimeRange, setSaveDefaultTimeRange] = (0, _react.useState)(isSavedDurationModified);
36
37
  const [saveDefaultVariables, setSaveDefaultVariables] = (0, _react.useState)(isSavedVariableModified);
38
+ const [saveDefaultRefreshInterval, setDefaultRefreshInterval] = (0, _react.useState)(isSavedRefreshIntervalModified);
37
39
  const { getSavedVariablesStatus } = (0, _context.useVariableDefinitionActions)();
38
40
  const { modifiedVariableNames } = getSavedVariablesStatus();
39
41
  const isOpen = dialog !== undefined;
40
- const { timeRange } = (0, _pluginsystem.useTimeRange)();
42
+ const { timeRange, refreshInterval } = (0, _pluginsystem.useTimeRange)();
41
43
  const currentTimeRangeText = (0, _core.isRelativeTimeRange)(timeRange) ? `(Last ${timeRange.pastDuration})` : '(Absolute time ranges can not be saved)';
42
- const saveTimeRangeText = `Save current time range as new default ${currentTimeRangeText}`;
43
- const saveVariablesText = `Save current variable values as new default (${modifiedVariableNames.length > 0 ? modifiedVariableNames.join(', ') : 'No modified variables'})`;
44
+ const saveTimeRangeMessage = `Save current time range as new default ${currentTimeRangeText}`;
45
+ const saveVariableMessage = `Save current variable values as new default (${modifiedVariableNames.length > 0 ? modifiedVariableNames.join(', ') : 'No modified variables'})`;
46
+ const refreshIntervalDisplay = _pluginsystem.DEFAULT_REFRESH_INTERVAL_OPTIONS.some((i)=>i.display === refreshInterval) ? refreshInterval : _pluginsystem.DEFAULT_REFRESH_INTERVAL_OPTIONS.find((i)=>i.value.pastDuration === refreshInterval)?.display;
47
+ const saveRefreshIntervalMessage = `Save current refresh interval as new default ${refreshIntervalDisplay ? `(${refreshIntervalDisplay})` : 'refresh interval not modified'}`;
44
48
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog, {
45
49
  open: isOpen,
46
50
  children: dialog !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
@@ -63,7 +67,15 @@ const SaveChangesConfirmationDialog = ()=>{
63
67
  checked: saveDefaultTimeRange && isSavedDurationModified && (0, _core.isRelativeTimeRange)(timeRange),
64
68
  onChange: (e)=>setSaveDefaultTimeRange(e.target.checked)
65
69
  }),
66
- label: saveTimeRangeText
70
+ label: saveTimeRangeMessage
71
+ }),
72
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
73
+ control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
74
+ disabled: !isSavedRefreshIntervalModified,
75
+ checked: saveDefaultRefreshInterval && isSavedRefreshIntervalModified,
76
+ onChange: (e)=>setDefaultRefreshInterval(e.target.checked)
77
+ }),
78
+ label: saveRefreshIntervalMessage
67
79
  }),
68
80
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
69
81
  control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
@@ -71,7 +83,7 @@ const SaveChangesConfirmationDialog = ()=>{
71
83
  checked: saveDefaultVariables && isSavedVariableModified,
72
84
  onChange: (e)=>setSaveDefaultVariables(e.target.checked)
73
85
  }),
74
- label: saveVariablesText
86
+ label: saveVariableMessage
75
87
  })
76
88
  ]
77
89
  })
@@ -81,7 +93,7 @@ const SaveChangesConfirmationDialog = ()=>{
81
93
  children: [
82
94
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.PrimaryButton, {
83
95
  onClick: ()=>{
84
- return dialog.onSaveChanges(saveDefaultTimeRange, saveDefaultVariables);
96
+ return dialog.onSaveChanges(saveDefaultTimeRange, saveDefaultRefreshInterval, saveDefaultVariables);
85
97
  },
86
98
  children: "Save Changes"
87
99
  }),
@@ -31,24 +31,28 @@ const SaveDashboardButton = ({ onSave, isDisabled, variant = 'contained' })=>{
31
31
  const { dashboard, setDashboard } = (0, _context.useDashboard)();
32
32
  const { getSavedVariablesStatus, setVariableDefaultValues } = (0, _context.useVariableDefinitionActions)();
33
33
  const { isSavedVariableModified } = getSavedVariablesStatus();
34
- const { timeRange } = (0, _pluginsystem.useTimeRange)();
34
+ const { timeRange, refreshInterval } = (0, _pluginsystem.useTimeRange)();
35
35
  const { setEditMode } = (0, _context.useEditMode)();
36
36
  const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = (0, _context.useSaveChangesConfirmationDialog)();
37
37
  const onSaveButtonClick = ()=>{
38
38
  const isSavedDurationModified = (0, _core.isRelativeTimeRange)(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;
39
+ const isSavedRefreshIntervalModified = dashboard.spec.refreshInterval !== refreshInterval;
39
40
  // Save dashboard
40
41
  // - if active timeRange from plugin-system is relative and different from currently saved
41
42
  // - or if the saved variables are different from currently saved
42
- if (isSavedDurationModified || isSavedVariableModified) {
43
+ if (isSavedDurationModified || isSavedVariableModified || isSavedRefreshIntervalModified) {
43
44
  openSaveChangesConfirmationDialog({
44
- onSaveChanges: (saveDefaultTimeRange, saveDefaultVariables)=>{
45
- if ((0, _core.isRelativeTimeRange)(timeRange) && saveDefaultTimeRange === true) {
45
+ onSaveChanges: (saveDefaultTimeRange, saveDefaultRefreshInterval, saveDefaultVariables)=>{
46
+ if ((0, _core.isRelativeTimeRange)(timeRange) && saveDefaultTimeRange) {
46
47
  dashboard.spec.duration = timeRange.pastDuration;
47
48
  }
48
- if (saveDefaultVariables === true) {
49
+ if (saveDefaultVariables) {
49
50
  const variables = setVariableDefaultValues();
50
51
  dashboard.spec.variables = variables;
51
52
  }
53
+ if (saveDefaultRefreshInterval && isSavedRefreshIntervalModified) {
54
+ dashboard.spec.refreshInterval = refreshInterval;
55
+ }
52
56
  setDashboard(dashboard);
53
57
  saveDashboard();
54
58
  },
@@ -56,7 +60,8 @@ const SaveDashboardButton = ({ onSave, isDisabled, variant = 'contained' })=>{
56
60
  closeSaveChangesConfirmationDialog();
57
61
  },
58
62
  isSavedDurationModified,
59
- isSavedVariableModified
63
+ isSavedVariableModified,
64
+ isSavedRefreshIntervalModified
60
65
  });
61
66
  } else {
62
67
  saveDashboard();
@@ -0,0 +1,201 @@
1
+ // Copyright 2025 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
+ ListVariableListBox: function() {
25
+ return ListVariableListBox;
26
+ },
27
+ ListVariableListBoxProvider: function() {
28
+ return ListVariableListBoxProvider;
29
+ },
30
+ useListVariableListBoxContext: function() {
31
+ return useListVariableListBoxContext;
32
+ }
33
+ });
34
+ const _jsxruntime = require("react/jsx-runtime");
35
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
36
+ const _material = require("@mui/material");
37
+ const _core = require("@perses-dev/core");
38
+ function _getRequireWildcardCache(nodeInterop) {
39
+ if (typeof WeakMap !== "function") return null;
40
+ var cacheBabelInterop = new WeakMap();
41
+ var cacheNodeInterop = new WeakMap();
42
+ return (_getRequireWildcardCache = function(nodeInterop) {
43
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
44
+ })(nodeInterop);
45
+ }
46
+ function _interop_require_wildcard(obj, nodeInterop) {
47
+ if (!nodeInterop && obj && obj.__esModule) {
48
+ return obj;
49
+ }
50
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
51
+ return {
52
+ default: obj
53
+ };
54
+ }
55
+ var cache = _getRequireWildcardCache(nodeInterop);
56
+ if (cache && cache.has(obj)) {
57
+ return cache.get(obj);
58
+ }
59
+ var newObj = {
60
+ __proto__: null
61
+ };
62
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
63
+ for(var key in obj){
64
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
65
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
66
+ if (desc && (desc.get || desc.set)) {
67
+ Object.defineProperty(newObj, key, desc);
68
+ } else {
69
+ newObj[key] = obj[key];
70
+ }
71
+ }
72
+ }
73
+ newObj.default = obj;
74
+ if (cache) {
75
+ cache.set(obj, newObj);
76
+ }
77
+ return newObj;
78
+ }
79
+ const ListVariableListBoxContext = /*#__PURE__*/ _react.default.createContext(undefined);
80
+ function useListVariableListBoxContext() {
81
+ const ctx = (0, _react.useContext)(ListVariableListBoxContext);
82
+ if (!ctx) throw new Error('ListVariableListBoxContext not found');
83
+ return ctx;
84
+ }
85
+ /*
86
+ * Handles the logic for toggling the global select checkbox in the ListBox header.
87
+ *
88
+ * If all options are selected, it will deselect all options.
89
+ * Except if filteredOptions is a subset of options, then it will only deselect the filtered options.
90
+ *
91
+ * If some options are selected, it will select all filtered options.
92
+ *
93
+ * If no options are selected, it will select all filtered options.
94
+ * Should be not possible since a ListVariable has always at least one value.
95
+ *
96
+ * If allowAllValue is true, it will handle the special "All" option logic.
97
+ * Main difference is if some options are selected and there is no filter, it will select the "All" option
98
+ */ function handleGlobalSelectToggle(options, selectedOptions, filteredOptions, isIndeterminate, isAllSelected, allowAllValue, onChange) {
99
+ if (isAllSelected) {
100
+ if (filteredOptions.length !== options.length) {
101
+ onChange(selectedOptions.filter((o)=>!filteredOptions.includes(o)));
102
+ } else {
103
+ onChange([]);
104
+ }
105
+ return;
106
+ }
107
+ if (isIndeterminate) {
108
+ if (allowAllValue) {
109
+ if (filteredOptions.length === options.length) {
110
+ if (selectedOptions[0]?.value === _core.DEFAULT_ALL_VALUE) {
111
+ onChange(options.filter((o)=>o.value !== _core.DEFAULT_ALL_VALUE));
112
+ } else {
113
+ onChange([
114
+ {
115
+ label: _core.DEFAULT_ALL_VALUE,
116
+ value: _core.DEFAULT_ALL_VALUE
117
+ }
118
+ ]);
119
+ }
120
+ } else {
121
+ if (filteredOptions.every((o)=>selectedOptions.includes(o))) {
122
+ onChange(selectedOptions.filter((o)=>!filteredOptions.includes(o)));
123
+ } else {
124
+ onChange([
125
+ ...selectedOptions,
126
+ ...filteredOptions.filter((o)=>o.value !== _core.DEFAULT_ALL_VALUE)
127
+ ]);
128
+ }
129
+ }
130
+ } else {
131
+ if (filteredOptions.length === options.length) {
132
+ onChange(options);
133
+ } else {
134
+ if (filteredOptions.every((o)=>selectedOptions.includes(o))) {
135
+ onChange(selectedOptions.filter((o)=>!filteredOptions.includes(o)));
136
+ } else {
137
+ onChange([
138
+ ...selectedOptions,
139
+ ...filteredOptions
140
+ ]);
141
+ }
142
+ }
143
+ }
144
+ return;
145
+ }
146
+ // Nothing selected, so select filtered options
147
+ onChange(filteredOptions);
148
+ }
149
+ function ListVariableListBoxProvider({ value, children }) {
150
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(ListVariableListBoxContext.Provider, {
151
+ value: value,
152
+ children: children
153
+ });
154
+ }
155
+ const ListVariableListBox = /*#__PURE__*/ (0, _react.forwardRef)(function ListVariableListBox(props, ref) {
156
+ const { children, ...rest } = props;
157
+ const { options, selectedOptions, filteredOptions, allowAllValue, onChange } = useListVariableListBoxContext();
158
+ // Derived selection metadata for context listbox header
159
+ const selectedCount = (0, _react.useMemo)(()=>selectedOptions.length, [
160
+ selectedOptions
161
+ ]);
162
+ const isIndeterminate = (0, _react.useMemo)(()=>options.length > 0 && selectedCount > 0 && selectedCount !== options.length, [
163
+ selectedCount,
164
+ options
165
+ ]);
166
+ const isAllSelected = (0, _react.useMemo)(()=>options.length > 0 && selectedCount === options.length, [
167
+ selectedCount,
168
+ options
169
+ ]);
170
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)("ul", {
171
+ ...rest,
172
+ ref: ref,
173
+ role: "listbox",
174
+ children: [
175
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)("li", {
176
+ style: {
177
+ display: 'flex',
178
+ alignItems: 'center'
179
+ },
180
+ children: [
181
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
182
+ indeterminate: isIndeterminate,
183
+ checked: isAllSelected,
184
+ // intentionally not passing event to underlying handler to mimic previous behavior
185
+ onChange: ()=>handleGlobalSelectToggle(options, selectedOptions, filteredOptions, isIndeterminate, isAllSelected, allowAllValue, onChange)
186
+ }),
187
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)("span", {
188
+ children: [
189
+ /*#__PURE__*/ (0, _jsxruntime.jsx)("strong", {
190
+ children: selectedCount
191
+ }),
192
+ " Selected"
193
+ ]
194
+ })
195
+ ]
196
+ }),
197
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {}),
198
+ children
199
+ ]
200
+ });
201
+ });