@perses-dev/dashboards 0.0.0-snapshot-ts-panel-actions-90e9ef0 → 0.0.0-snapshot-reverse-proxy-75afbd7

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 (194) 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 +79 -17
  4. package/dist/cjs/components/GridLayout/GridLayout.js +78 -126
  5. package/dist/cjs/components/GridLayout/Row.js +150 -0
  6. package/dist/cjs/components/GridLayout/index.js +1 -0
  7. package/dist/cjs/components/LeaveDialog/LeaveDialog.js +81 -0
  8. package/dist/cjs/components/LeaveDialog/index.js +30 -0
  9. package/dist/cjs/components/Panel/Panel.js +90 -2
  10. package/dist/cjs/components/Panel/PanelActions.js +37 -11
  11. package/dist/cjs/components/Panel/PanelHeader.js +37 -16
  12. package/dist/cjs/components/Panel/index.js +1 -0
  13. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +58 -21
  14. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +202 -180
  15. package/dist/cjs/components/PanelDrawer/PanelPreview.js +3 -0
  16. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +9 -21
  17. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +35 -15
  18. package/dist/cjs/components/QueryViewerDialog/QueryViewerDialog.js +121 -0
  19. package/dist/cjs/components/QueryViewerDialog/index.js +30 -0
  20. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -1
  21. package/dist/cjs/components/Variables/ListVariableListBox.js +201 -0
  22. package/dist/cjs/components/Variables/Variable.js +130 -72
  23. package/dist/cjs/components/Variables/VariableEditor.js +22 -15
  24. package/dist/cjs/components/Variables/index.js +1 -0
  25. package/dist/cjs/components/index.js +3 -1
  26. package/dist/cjs/constants/user-interface-text.js +4 -2
  27. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +7 -8
  28. package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +4 -4
  29. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  30. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +2 -2
  31. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +6 -2
  32. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -0
  33. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +10 -3
  34. package/dist/cjs/context/PanelEditorProvider/PanelEditorProvider.js +49 -0
  35. package/dist/cjs/context/PanelEditorProvider/index.js +23 -0
  36. package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
  37. package/dist/cjs/context/index.js +1 -0
  38. package/dist/cjs/context/useDashboard.js +5 -4
  39. package/dist/cjs/views/ViewDashboard/DashboardApp.js +7 -3
  40. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +9 -8
  41. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  42. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
  43. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  44. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
  45. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  46. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  47. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  48. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -15
  49. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  50. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  51. package/dist/components/GridLayout/GridItemContent.js +39 -18
  52. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  53. package/dist/components/GridLayout/GridLayout.d.ts +8 -0
  54. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  55. package/dist/components/GridLayout/GridLayout.js +72 -126
  56. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  57. package/dist/components/GridLayout/Row.d.ts +17 -0
  58. package/dist/components/GridLayout/Row.d.ts.map +1 -0
  59. package/dist/components/GridLayout/Row.js +142 -0
  60. package/dist/components/GridLayout/Row.js.map +1 -0
  61. package/dist/components/GridLayout/index.d.ts +1 -0
  62. package/dist/components/GridLayout/index.d.ts.map +1 -1
  63. package/dist/components/GridLayout/index.js +1 -0
  64. package/dist/components/GridLayout/index.js.map +1 -1
  65. package/dist/components/LeaveDialog/LeaveDialog.d.ts +13 -0
  66. package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -0
  67. package/dist/components/LeaveDialog/LeaveDialog.js +70 -0
  68. package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -0
  69. package/dist/components/LeaveDialog/index.d.ts +2 -0
  70. package/dist/components/LeaveDialog/index.d.ts.map +1 -0
  71. package/dist/components/LeaveDialog/index.js +15 -0
  72. package/dist/components/LeaveDialog/index.js.map +1 -0
  73. package/dist/components/Panel/HeaderIconButton.d.ts +1 -1
  74. package/dist/components/Panel/Panel.d.ts +6 -0
  75. package/dist/components/Panel/Panel.d.ts.map +1 -1
  76. package/dist/components/Panel/Panel.js +92 -4
  77. package/dist/components/Panel/Panel.js.map +1 -1
  78. package/dist/components/Panel/PanelActions.d.ts +7 -1
  79. package/dist/components/Panel/PanelActions.d.ts.map +1 -1
  80. package/dist/components/Panel/PanelActions.js +37 -11
  81. package/dist/components/Panel/PanelActions.js.map +1 -1
  82. package/dist/components/Panel/PanelHeader.d.ts +8 -1
  83. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  84. package/dist/components/Panel/PanelHeader.js +38 -17
  85. package/dist/components/Panel/PanelHeader.js.map +1 -1
  86. package/dist/components/Panel/index.d.ts +1 -0
  87. package/dist/components/Panel/index.d.ts.map +1 -1
  88. package/dist/components/Panel/index.js +1 -0
  89. package/dist/components/Panel/index.js.map +1 -1
  90. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  91. package/dist/components/PanelDrawer/PanelDrawer.js +59 -22
  92. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  93. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  94. package/dist/components/PanelDrawer/PanelEditorForm.js +205 -183
  95. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  96. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  97. package/dist/components/PanelDrawer/PanelPreview.js +4 -1
  98. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  99. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  100. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +8 -15
  101. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  102. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +1 -0
  103. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
  104. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +36 -16
  105. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  106. package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts +9 -0
  107. package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts.map +1 -0
  108. package/dist/components/QueryViewerDialog/QueryViewerDialog.js +72 -0
  109. package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -0
  110. package/dist/components/QueryViewerDialog/index.d.ts +2 -0
  111. package/dist/components/QueryViewerDialog/index.d.ts.map +1 -0
  112. package/dist/components/QueryViewerDialog/index.js +15 -0
  113. package/dist/components/QueryViewerDialog/index.js.map +1 -0
  114. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  115. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -1
  116. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  117. package/dist/components/Variables/ListVariableListBox.d.ts +16 -0
  118. package/dist/components/Variables/ListVariableListBox.d.ts.map +1 -0
  119. package/dist/components/Variables/ListVariableListBox.js +141 -0
  120. package/dist/components/Variables/ListVariableListBox.js.map +1 -0
  121. package/dist/components/Variables/Variable.d.ts.map +1 -1
  122. package/dist/components/Variables/Variable.js +134 -76
  123. package/dist/components/Variables/Variable.js.map +1 -1
  124. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  125. package/dist/components/Variables/VariableEditor.js +24 -17
  126. package/dist/components/Variables/VariableEditor.js.map +1 -1
  127. package/dist/components/Variables/index.d.ts +1 -0
  128. package/dist/components/Variables/index.d.ts.map +1 -1
  129. package/dist/components/Variables/index.js +1 -0
  130. package/dist/components/Variables/index.js.map +1 -1
  131. package/dist/components/index.d.ts +3 -1
  132. package/dist/components/index.d.ts.map +1 -1
  133. package/dist/components/index.js +3 -1
  134. package/dist/components/index.js.map +1 -1
  135. package/dist/constants/user-interface-text.d.ts +2 -0
  136. package/dist/constants/user-interface-text.d.ts.map +1 -1
  137. package/dist/constants/user-interface-text.js +4 -2
  138. package/dist/constants/user-interface-text.js.map +1 -1
  139. package/dist/context/DashboardProvider/DashboardProvider.d.ts +5 -5
  140. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  141. package/dist/context/DashboardProvider/DashboardProvider.js +7 -8
  142. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  143. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts.map +1 -1
  144. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +5 -5
  145. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -1
  146. package/dist/context/DashboardProvider/common.d.ts +1 -1
  147. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  148. package/dist/context/DashboardProvider/common.js.map +1 -1
  149. package/dist/context/DashboardProvider/duplicate-panel-slice.js +2 -2
  150. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  151. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +1 -0
  152. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  153. package/dist/context/DashboardProvider/panel-editor-slice.js +3 -3
  154. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  155. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -0
  156. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
  157. package/dist/context/DashboardProvider/panel-group-editor-slice.js +6 -2
  158. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  159. package/dist/context/DashboardProvider/panel-group-slice.d.ts +3 -0
  160. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  161. package/dist/context/DashboardProvider/panel-group-slice.js +1 -0
  162. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  163. package/dist/context/DashboardProvider/view-panel-slice.d.ts +6 -2
  164. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
  165. package/dist/context/DashboardProvider/view-panel-slice.js +10 -3
  166. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
  167. package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts +13 -0
  168. package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts.map +1 -0
  169. package/dist/context/PanelEditorProvider/PanelEditorProvider.js +33 -0
  170. package/dist/context/PanelEditorProvider/PanelEditorProvider.js.map +1 -0
  171. package/dist/context/PanelEditorProvider/index.d.ts +3 -0
  172. package/dist/context/PanelEditorProvider/index.d.ts.map +1 -0
  173. package/dist/context/PanelEditorProvider/index.js +16 -0
  174. package/dist/context/PanelEditorProvider/index.js.map +1 -0
  175. package/dist/context/VariableProvider/VariableProvider.js +1 -1
  176. package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
  177. package/dist/context/index.d.ts +1 -0
  178. package/dist/context/index.d.ts.map +1 -1
  179. package/dist/context/index.js +1 -0
  180. package/dist/context/index.js.map +1 -1
  181. package/dist/context/useDashboard.js +5 -4
  182. package/dist/context/useDashboard.js.map +1 -1
  183. package/dist/utils/panelUtils.d.ts +3 -0
  184. package/dist/utils/panelUtils.d.ts.map +1 -1
  185. package/dist/utils/panelUtils.js +3 -0
  186. package/dist/utils/panelUtils.js.map +1 -1
  187. package/dist/views/ViewDashboard/DashboardApp.d.ts +7 -6
  188. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  189. package/dist/views/ViewDashboard/DashboardApp.js +8 -4
  190. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  191. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  192. package/dist/views/ViewDashboard/ViewDashboard.js +9 -8
  193. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  194. package/package.json +8 -8
@@ -63,8 +63,6 @@ function DashboardStickyToolbar(props) {
63
63
  display: "flex",
64
64
  flexWrap: !isSticky && isBiggerThanMd ? 'wrap' : 'nowrap',
65
65
  maxWidth: isSticky || !isBiggerThanMd ? '100vw' : '100%',
66
- maxHeight: "150px" // Limit the vertical space used to ~3 rows of variables
67
- ,
68
66
  pt: 1,
69
67
  pl: isSticky ? 1 : 0,
70
68
  mt: isSticky && isBiggerThanMd ? 0.5 : 0,
@@ -21,14 +21,9 @@ Object.defineProperty(exports, "DeletePanelGroupDialog", {
21
21
  }
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
+ const _components = require("@perses-dev/components");
24
25
  const _material = require("@mui/material");
25
- const _Close = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Close"));
26
26
  const _context = require("../../context");
27
- function _interop_require_default(obj) {
28
- return obj && obj.__esModule ? obj : {
29
- default: obj
30
- };
31
- }
32
27
  const DeletePanelGroupDialog = ()=>{
33
28
  const { deletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } = (0, _context.useDeletePanelGroupDialog)();
34
29
  const { setViewPanel } = (0, _context.useViewPanel)();
@@ -42,26 +37,16 @@ const DeletePanelGroupDialog = ()=>{
42
37
  closeDeletePanelGroupDialog();
43
38
  setViewPanel(undefined);
44
39
  };
45
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Dialog, {
40
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.Dialog, {
46
41
  open: deletePanelGroupDialog !== undefined,
47
42
  children: [
48
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.DialogTitle, {
43
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.Header, {
49
44
  children: "Delete Panel Group"
50
45
  }),
51
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
52
- "aria-label": "Close",
53
- onClick: ()=>closeDeletePanelGroupDialog(),
54
- sx: (theme)=>({
55
- position: 'absolute',
56
- top: theme.spacing(0.5),
57
- right: theme.spacing(0.5)
58
- }),
59
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Close.default, {})
60
- }),
61
46
  /*#__PURE__*/ (0, _jsxruntime.jsxs)("form", {
62
47
  onSubmit: handleDelete,
63
48
  children: [
64
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.DialogContent, {
49
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.Dialog.Content, {
65
50
  dividers: true,
66
51
  sx: {
67
52
  width: '500px'
@@ -72,7 +57,7 @@ const DeletePanelGroupDialog = ()=>{
72
57
  "? This will delete all the panels within the group."
73
58
  ]
74
59
  }),
75
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.DialogActions, {
60
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.Dialog.Actions, {
76
61
  children: [
77
62
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
78
63
  variant: "contained",
@@ -24,9 +24,52 @@ const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
25
  const _reactintersectionobserver = require("react-intersection-observer");
26
26
  const _pluginsystem = require("@perses-dev/plugin-system");
27
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
27
28
  const _context = require("../../context");
28
29
  const _Panel = require("../Panel");
29
30
  const _panelgroupslice = require("../../context/DashboardProvider/panel-group-slice");
31
+ const _QueryViewerDialog = require("../QueryViewerDialog");
32
+ function _getRequireWildcardCache(nodeInterop) {
33
+ if (typeof WeakMap !== "function") return null;
34
+ var cacheBabelInterop = new WeakMap();
35
+ var cacheNodeInterop = new WeakMap();
36
+ return (_getRequireWildcardCache = function(nodeInterop) {
37
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
38
+ })(nodeInterop);
39
+ }
40
+ function _interop_require_wildcard(obj, nodeInterop) {
41
+ if (!nodeInterop && obj && obj.__esModule) {
42
+ return obj;
43
+ }
44
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
45
+ return {
46
+ default: obj
47
+ };
48
+ }
49
+ var cache = _getRequireWildcardCache(nodeInterop);
50
+ if (cache && cache.has(obj)) {
51
+ return cache.get(obj);
52
+ }
53
+ var newObj = {
54
+ __proto__: null
55
+ };
56
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
57
+ for(var key in obj){
58
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
59
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
60
+ if (desc && (desc.get || desc.set)) {
61
+ Object.defineProperty(newObj, key, desc);
62
+ } else {
63
+ newObj[key] = obj[key];
64
+ }
65
+ }
66
+ }
67
+ newObj.default = obj;
68
+ if (cache) {
69
+ cache.set(obj, newObj);
70
+ }
71
+ return newObj;
72
+ }
30
73
  function GridItemContent(props) {
31
74
  const { panelGroupItemId, width } = props;
32
75
  const panelDefinition = (0, _context.usePanel)(panelGroupItemId);
@@ -39,6 +82,17 @@ function GridItemContent(props) {
39
82
  initialInView: false,
40
83
  triggerOnce: true
41
84
  });
85
+ const [openQueryViewer, setOpenQueryViewer] = (0, _react.useState)(false);
86
+ const viewQueriesHandler = (0, _react.useMemo)(()=>{
87
+ return isEditMode || !queries?.length ? undefined : {
88
+ onClick: ()=>{
89
+ setOpenQueryViewer(true);
90
+ }
91
+ };
92
+ }, [
93
+ isEditMode,
94
+ queries
95
+ ]);
42
96
  const readHandlers = {
43
97
  isPanelViewed: (0, _panelgroupslice.isPanelGroupItemIdEqual)(viewPanelGroupItemId, panelGroupItemId),
44
98
  onViewPanelClick: function() {
@@ -69,28 +123,36 @@ function GridItemContent(props) {
69
123
  };
70
124
  });
71
125
  const pluginQueryOptions = typeof plugin?.queryOptions === 'function' ? plugin?.queryOptions(panelDefinition.spec.plugin.spec) : plugin?.queryOptions;
72
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
126
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
73
127
  ref: ref,
74
128
  sx: {
75
129
  width: '100%',
76
130
  height: '100%'
77
131
  },
78
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DataQueriesProvider, {
79
- definitions: definitions,
80
- options: {
81
- suggestedStepMs,
82
- ...pluginQueryOptions
83
- },
84
- queryOptions: {
85
- enabled: inView
86
- },
87
- children: inView && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Panel.Panel, {
88
- definition: panelDefinition,
89
- readHandlers: readHandlers,
90
- editHandlers: editHandlers,
91
- panelOptions: props.panelOptions,
92
- panelGroupItemId: panelGroupItemId
132
+ children: [
133
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DataQueriesProvider, {
134
+ definitions: definitions,
135
+ options: {
136
+ suggestedStepMs,
137
+ ...pluginQueryOptions
138
+ },
139
+ queryOptions: {
140
+ enabled: inView
141
+ },
142
+ children: inView && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Panel.Panel, {
143
+ definition: panelDefinition,
144
+ readHandlers: readHandlers,
145
+ editHandlers: editHandlers,
146
+ viewQueriesHandler: viewQueriesHandler,
147
+ panelOptions: props.panelOptions,
148
+ panelGroupItemId: panelGroupItemId
149
+ })
150
+ }),
151
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_QueryViewerDialog.QueryViewerDialog, {
152
+ open: openQueryViewer,
153
+ queryDefinitions: queryDefinitions,
154
+ onClose: ()=>setOpenQueryViewer(false)
93
155
  })
94
- })
156
+ ]
95
157
  });
96
158
  }
@@ -14,67 +14,34 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "GridLayout", {
18
- enumerable: true,
19
- get: function() {
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
+ GridLayout: function() {
20
25
  return GridLayout;
26
+ },
27
+ RepeatGridLayout: function() {
28
+ return RepeatGridLayout;
21
29
  }
22
30
  });
23
31
  const _jsxruntime = require("react/jsx-runtime");
24
32
  const _react = require("react");
25
- const _reactgridlayout = require("react-grid-layout");
26
- const _material = require("@mui/material");
27
- const _components = require("@perses-dev/components");
33
+ const _pluginsystem = require("@perses-dev/plugin-system");
28
34
  const _context = require("../../context");
29
35
  const _constants = require("../../constants");
30
- const _GridTitle = require("./GridTitle");
31
- const _GridItemContent = require("./GridItemContent");
32
- const _GridContainer = require("./GridContainer");
33
- const DEFAULT_MARGIN = 10;
34
- const ROW_HEIGHT = 30;
36
+ const _Row = require("./Row");
35
37
  function GridLayout(props) {
36
38
  const { panelGroupId, panelOptions, panelFullHeight } = props;
37
- const theme = (0, _material.useTheme)();
38
39
  const groupDefinition = (0, _context.usePanelGroup)(panelGroupId);
39
40
  const { updatePanelGroupLayouts } = (0, _context.usePanelGroupActions)(panelGroupId);
40
- const [isOpen, setIsOpen] = (0, _react.useState)(!groupDefinition.isCollapsed);
41
+ const viewPanelItemId = (0, _context.useViewPanelGroup)();
41
42
  const { isEditMode } = (0, _context.useEditMode)();
42
43
  const [gridColWidth, setGridColWidth] = (0, _react.useState)(0);
43
- const viewPanelItemId = (0, _context.useViewPanelGroup)();
44
44
  const hasViewPanel = viewPanelItemId?.panelGroupId === panelGroupId; // current panelGroup contains the panel extended?
45
- const itemLayoutViewed = viewPanelItemId?.panelGroupItemLayoutId;
46
- (0, _react.useEffect)(()=>{
47
- if (hasViewPanel) {
48
- setIsOpen(true);
49
- }
50
- }, [
51
- hasViewPanel
52
- ]);
53
- // If there is a panel in view mode, we should hide the grid if the panel is not in the current group.
54
- const isGridDisplayed = viewPanelItemId === undefined || hasViewPanel;
55
- // Item layout is override if there is a panel in view mode
56
- const itemLayouts = (0, _react.useMemo)(()=>{
57
- if (itemLayoutViewed) {
58
- return groupDefinition.itemLayouts.map((itemLayout)=>{
59
- if (itemLayout.i === itemLayoutViewed) {
60
- const rowTitleHeight = 40 + 8; // 40 is the height of the row title and 8 is the margin height
61
- return {
62
- h: Math.round(((panelFullHeight ?? window.innerHeight) - rowTitleHeight) / (ROW_HEIGHT + DEFAULT_MARGIN)),
63
- i: itemLayoutViewed,
64
- w: 48,
65
- x: 0,
66
- y: 0
67
- };
68
- }
69
- return itemLayout;
70
- });
71
- }
72
- return groupDefinition.itemLayouts;
73
- }, [
74
- groupDefinition.itemLayouts,
75
- itemLayoutViewed,
76
- panelFullHeight
77
- ]);
78
45
  const handleLayoutChange = (currentLayout, allLayouts)=>{
79
46
  // Using the value from `allLayouts` instead of `currentLayout` because of
80
47
  // a bug in react-layout-grid where `currentLayout` does not adjust properly
@@ -95,85 +62,70 @@ function GridLayout(props) {
95
62
  // exclude margin and padding from total width
96
63
  setGridColWidth((containerWidth - marginWidth - containerPaddingWidth) / cols);
97
64
  };
98
- // https://github.com/react-grid-layout/react-grid-layout?tab=readme-ov-file#react-hooks-performance
99
- const ResponsiveGridLayout = (0, _react.useMemo)(()=>(0, _reactgridlayout.WidthProvider)(_reactgridlayout.Responsive), []);
100
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_GridContainer.GridContainer, {
101
- sx: {
102
- display: isGridDisplayed ? 'block' : 'none',
103
- height: itemLayoutViewed ? `${panelFullHeight}px` : 'unset',
104
- overflow: itemLayoutViewed ? 'hidden' : 'unset'
105
- },
106
- children: [
107
- groupDefinition.title !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsx)(_GridTitle.GridTitle, {
108
- panelGroupId: panelGroupId,
109
- title: groupDefinition.title,
110
- collapse: groupDefinition.isCollapsed === undefined ? undefined : {
111
- isOpen,
112
- onToggleOpen: ()=>setIsOpen((current)=>!current)
113
- }
114
- }),
115
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Collapse, {
116
- in: isOpen,
117
- unmountOnExit: true,
118
- appear: false,
119
- "data-testid": "panel-group-content",
120
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(ResponsiveGridLayout, {
121
- className: "layout",
122
- breakpoints: {
123
- sm: theme.breakpoints.values.sm,
124
- xxs: 0
125
- },
126
- cols: _constants.GRID_LAYOUT_COLS,
127
- rowHeight: ROW_HEIGHT,
128
- draggableHandle: ".drag-handle",
129
- resizeHandles: [
130
- 'se'
131
- ],
132
- isDraggable: isEditMode && !hasViewPanel,
133
- isResizable: isEditMode && !hasViewPanel,
134
- margin: [
135
- DEFAULT_MARGIN,
136
- DEFAULT_MARGIN
137
- ],
138
- containerPadding: [
139
- 0,
140
- 10
141
- ],
142
- layouts: {
143
- [_constants.GRID_LAYOUT_SMALL_BREAKPOINT]: itemLayouts
144
- },
145
- onLayoutChange: handleLayoutChange,
146
- onWidthChange: handleWidthChange,
147
- allowOverlap: hasViewPanel,
148
- children: itemLayouts.map(({ i, w })=>/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
149
- style: {
150
- display: itemLayoutViewed !== undefined ? itemLayoutViewed === i ? 'unset' : 'none' : 'unset'
151
- },
152
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
153
- FallbackComponent: _components.ErrorAlert,
154
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_GridItemContent.GridItemContent, {
155
- panelOptions: panelOptions,
156
- panelGroupItemId: {
157
- panelGroupId,
158
- panelGroupItemLayoutId: i
159
- },
160
- width: calculateGridItemWidth(w, gridColWidth)
161
- })
162
- })
163
- }, i))
65
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
66
+ children: !groupDefinition.repeatVariable ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_Row.Row, {
67
+ panelGroupId: panelGroupId,
68
+ groupDefinition: groupDefinition,
69
+ gridColWidth: gridColWidth,
70
+ panelFullHeight: panelFullHeight,
71
+ panelOptions: panelOptions,
72
+ isEditMode: isEditMode,
73
+ onLayoutChange: handleLayoutChange,
74
+ onWidthChange: handleWidthChange
75
+ }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(RepeatGridLayout, {
76
+ repeatVariableName: groupDefinition.repeatVariable,
77
+ panelGroupId: panelGroupId,
78
+ groupDefinition: groupDefinition,
79
+ gridColWidth: gridColWidth,
80
+ panelFullHeight: panelFullHeight,
81
+ panelOptions: panelOptions,
82
+ isEditMode: isEditMode,
83
+ onLayoutChange: handleLayoutChange,
84
+ onWidthChange: handleWidthChange
85
+ })
86
+ });
87
+ }
88
+ function RepeatGridLayout({ repeatVariableName, panelGroupId, groupDefinition, gridColWidth, panelFullHeight, panelOptions, isEditMode = false, onLayoutChange, onWidthChange }) {
89
+ const variables = (0, _pluginsystem.useVariableValues)();
90
+ const variable = variables[repeatVariableName];
91
+ // If the variable is not defined, or if it is defined but has no values, render a standard row without repeating
92
+ if (variable === undefined || !Array.isArray(variable.value) || variable.value.length === 0) {
93
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_Row.Row, {
94
+ panelGroupId: panelGroupId,
95
+ groupDefinition: groupDefinition,
96
+ gridColWidth: gridColWidth,
97
+ panelFullHeight: panelFullHeight,
98
+ panelOptions: panelOptions,
99
+ isEditMode: isEditMode,
100
+ onLayoutChange: onLayoutChange,
101
+ onWidthChange: onWidthChange
102
+ });
103
+ }
104
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
105
+ children: variable.value.map((value)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.VariableContext.Provider, {
106
+ value: {
107
+ state: {
108
+ ...variables,
109
+ [repeatVariableName]: {
110
+ value,
111
+ loading: false
112
+ }
113
+ }
114
+ },
115
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Row.Row, {
116
+ panelGroupId: panelGroupId,
117
+ groupDefinition: groupDefinition,
118
+ gridColWidth: gridColWidth,
119
+ panelFullHeight: panelFullHeight,
120
+ panelOptions: panelOptions,
121
+ isEditMode: isEditMode,
122
+ onLayoutChange: onLayoutChange,
123
+ onWidthChange: onWidthChange,
124
+ repeatVariable: [
125
+ repeatVariableName,
126
+ value
127
+ ]
164
128
  })
165
- })
166
- ]
129
+ }, `${repeatVariableName}-${value}`))
167
130
  });
168
131
  }
169
- /**
170
- * Calculates grid item width
171
- * @param w number of columns the grid item spans
172
- * @param colWidth the width of each column in px
173
- * @returns grid item's width in px
174
- * https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35
175
- */ const calculateGridItemWidth = (w, colWidth)=>{
176
- // 0 * Infinity === NaN, which causes problems with resize contraints
177
- if (!Number.isFinite(w)) return w;
178
- return Math.round(colWidth * w + Math.max(0, w - 1) * DEFAULT_MARGIN);
179
- };
@@ -0,0 +1,150 @@
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, "Row", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return Row;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _dashboards = require("@perses-dev/dashboards");
26
+ const _react = require("react");
27
+ const _reactgridlayout = require("react-grid-layout");
28
+ const _components = require("@perses-dev/components");
29
+ const _constants = require("../../constants");
30
+ const _GridContainer = require("./GridContainer");
31
+ const _GridItemContent = require("./GridItemContent");
32
+ const _GridTitle = require("./GridTitle");
33
+ const DEFAULT_MARGIN = 10;
34
+ const ROW_HEIGHT = 30;
35
+ function Row({ panelGroupId, groupDefinition, gridColWidth, panelFullHeight, panelOptions, isEditMode = false, onLayoutChange, onWidthChange, repeatVariable }) {
36
+ const ResponsiveGridLayout = (0, _react.useMemo)(()=>(0, _reactgridlayout.WidthProvider)(_reactgridlayout.Responsive), []);
37
+ const theme = (0, _material.useTheme)();
38
+ const viewPanelItemId = (0, _dashboards.useViewPanelGroup)();
39
+ const [isOpen, setIsOpen] = (0, _react.useState)(!groupDefinition.isCollapsed);
40
+ const hasViewPanel = viewPanelItemId?.panelGroupId === panelGroupId && // Check for repeatVariable panels
41
+ viewPanelItemId.repeatVariable?.[0] === repeatVariable?.[0] && viewPanelItemId.repeatVariable?.[1] === repeatVariable?.[1];
42
+ const itemLayoutViewed = viewPanelItemId?.panelGroupItemLayoutId;
43
+ // If there is a panel in view mode, we should hide the grid if the panel is not in the current group.
44
+ const isGridDisplayed = !viewPanelItemId || hasViewPanel;
45
+ // TODO: handle it without useEffect
46
+ (0, _react.useEffect)(()=>{
47
+ if (hasViewPanel) {
48
+ setIsOpen(true);
49
+ }
50
+ }, [
51
+ hasViewPanel
52
+ ]);
53
+ // Item layout is override if there is a panel in view mode
54
+ const itemLayouts = (0, _react.useMemo)(()=>{
55
+ if (itemLayoutViewed) {
56
+ return groupDefinition.itemLayouts.map((itemLayout)=>{
57
+ if (itemLayout.i === itemLayoutViewed) {
58
+ const rowTitleHeight = 40 + 8; // 40 is the height of the row title and 8 is the margin height
59
+ return {
60
+ h: Math.round(((panelFullHeight ?? window.innerHeight) - rowTitleHeight) / (ROW_HEIGHT + DEFAULT_MARGIN)),
61
+ i: itemLayoutViewed,
62
+ w: 48,
63
+ x: 0,
64
+ y: 0
65
+ };
66
+ }
67
+ return itemLayout;
68
+ });
69
+ }
70
+ return groupDefinition.itemLayouts;
71
+ }, [
72
+ groupDefinition.itemLayouts,
73
+ itemLayoutViewed,
74
+ panelFullHeight
75
+ ]);
76
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_GridContainer.GridContainer, {
77
+ sx: {
78
+ display: isGridDisplayed ? 'block' : 'none',
79
+ height: itemLayoutViewed ? `${panelFullHeight}px` : 'unset',
80
+ overflow: itemLayoutViewed ? 'hidden' : 'unset'
81
+ },
82
+ children: [
83
+ groupDefinition.title && /*#__PURE__*/ (0, _jsxruntime.jsx)(_GridTitle.GridTitle, {
84
+ panelGroupId: panelGroupId,
85
+ title: groupDefinition.title,
86
+ collapse: groupDefinition.isCollapsed === undefined ? undefined : {
87
+ isOpen: isOpen,
88
+ onToggleOpen: ()=>setIsOpen((current)=>!current)
89
+ }
90
+ }),
91
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Collapse, {
92
+ in: isOpen,
93
+ unmountOnExit: true,
94
+ appear: false,
95
+ "data-testid": "panel-group-content",
96
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(ResponsiveGridLayout, {
97
+ className: "layout",
98
+ breakpoints: {
99
+ [_constants.GRID_LAYOUT_SMALL_BREAKPOINT]: theme.breakpoints.values.sm,
100
+ xxs: 0
101
+ },
102
+ cols: _constants.GRID_LAYOUT_COLS,
103
+ rowHeight: ROW_HEIGHT,
104
+ draggableHandle: ".drag-handle",
105
+ resizeHandles: [
106
+ 'se'
107
+ ],
108
+ isDraggable: isEditMode && !hasViewPanel,
109
+ isResizable: isEditMode && !hasViewPanel,
110
+ margin: [
111
+ DEFAULT_MARGIN,
112
+ DEFAULT_MARGIN
113
+ ],
114
+ containerPadding: [
115
+ 0,
116
+ 10
117
+ ],
118
+ layouts: {
119
+ sm: itemLayouts
120
+ },
121
+ onLayoutChange: onLayoutChange,
122
+ onWidthChange: onWidthChange,
123
+ allowOverlap: hasViewPanel,
124
+ children: itemLayouts.map(({ i, w })=>/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
125
+ style: {
126
+ display: itemLayoutViewed ? itemLayoutViewed === i ? 'unset' : 'none' : 'unset'
127
+ },
128
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
129
+ FallbackComponent: _components.ErrorAlert,
130
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_GridItemContent.GridItemContent, {
131
+ panelOptions: panelOptions,
132
+ panelGroupItemId: {
133
+ panelGroupId,
134
+ panelGroupItemLayoutId: i,
135
+ repeatVariable
136
+ },
137
+ width: calculateGridItemWidth(w, gridColWidth)
138
+ })
139
+ })
140
+ }, i))
141
+ })
142
+ })
143
+ ]
144
+ });
145
+ }
146
+ const calculateGridItemWidth = (w, colWidth)=>{
147
+ // 0 * Infinity === NaN, which causes problems with resize contraints
148
+ if (!Number.isFinite(w)) return w;
149
+ return Math.round(colWidth * w + Math.max(0, w - 1) * DEFAULT_MARGIN);
150
+ };
@@ -18,6 +18,7 @@ _export_star(require("./GridContainer"), exports);
18
18
  _export_star(require("./GridItemContent"), exports);
19
19
  _export_star(require("./GridLayout"), exports);
20
20
  _export_star(require("./GridTitle"), exports);
21
+ _export_star(require("./Row"), exports);
21
22
  function _export_star(from, to) {
22
23
  Object.keys(from).forEach(function(k) {
23
24
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -0,0 +1,81 @@
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
+ LeaveDialog: function() {
25
+ return LeaveDialog;
26
+ },
27
+ Prompt: function() {
28
+ return Prompt;
29
+ }
30
+ });
31
+ const _jsxruntime = require("react/jsx-runtime");
32
+ const _react = require("react");
33
+ const _reactrouterdom = require("react-router-dom");
34
+ const _components = require("@perses-dev/components");
35
+ const handleRouteChange = (event)=>{
36
+ event.preventDefault();
37
+ event.returnValue = ''; // Required for Chrome
38
+ return ''; // Required for other browsers
39
+ };
40
+ function Prompt({ isBlocked, message }) {
41
+ const blocker = (0, _reactrouterdom.useBlocker)(isBlocked);
42
+ const isBlockedState = blocker.state === 'blocked';
43
+ const isProceedingState = blocker.state === 'proceeding';
44
+ (0, _react.useEffect)(()=>{
45
+ if (isBlocked) {
46
+ window.addEventListener('beforeunload', handleRouteChange);
47
+ } else {
48
+ window.removeEventListener('beforeunload', handleRouteChange);
49
+ }
50
+ return ()=>{
51
+ window.removeEventListener('beforeunload', handleRouteChange);
52
+ };
53
+ }, [
54
+ blocker,
55
+ isBlocked,
56
+ isBlockedState
57
+ ]);
58
+ const handleDiscardChanges = ()=>blocker.proceed?.();
59
+ const handleCancel = ()=>blocker.reset?.();
60
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.DiscardChangesConfirmationDialog, {
61
+ description: message,
62
+ isOpen: isBlockedState || isProceedingState,
63
+ onDiscardChanges: handleDiscardChanges,
64
+ onCancel: handleCancel
65
+ });
66
+ }
67
+ function LeaveDialog({ original, current }) {
68
+ const handleIsBlocked = (ctx)=>{
69
+ if (JSON.stringify(original) !== JSON.stringify(current)) {
70
+ // Only block navigation if the pathname is changing (=> ignore search params changes)
71
+ if (ctx.currentLocation.pathname !== ctx.nextLocation.pathname) {
72
+ return true;
73
+ }
74
+ }
75
+ return false;
76
+ };
77
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(Prompt, {
78
+ isBlocked: handleIsBlocked,
79
+ message: "You have unsaved changes, are you sure you want to leave?"
80
+ });
81
+ }