@perses-dev/dashboards 0.52.0-beta.5 → 0.52.0-rc.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 (127) hide show
  1. package/dist/cjs/components/GridLayout/GridLayout.js +78 -126
  2. package/dist/cjs/components/GridLayout/Row.js +150 -0
  3. package/dist/cjs/components/GridLayout/index.js +1 -0
  4. package/dist/cjs/components/LeaveDialog/LeaveDialog.js +72 -0
  5. package/dist/cjs/components/LeaveDialog/index.js +30 -0
  6. package/dist/cjs/components/Panel/Panel.js +5 -1
  7. package/dist/cjs/components/Panel/PanelActions.js +4 -4
  8. package/dist/cjs/components/Panel/PanelHeader.js +32 -15
  9. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +58 -21
  10. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +204 -185
  11. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +3 -0
  12. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +35 -15
  13. package/dist/cjs/components/Variables/VariableEditor.js +22 -15
  14. package/dist/cjs/components/index.js +1 -0
  15. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +7 -8
  16. package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +27 -5
  17. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +1 -0
  18. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +6 -2
  19. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -0
  20. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +10 -3
  21. package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
  22. package/dist/cjs/context/VariableProvider/query-params.js +12 -14
  23. package/dist/cjs/context/useDashboard.js +5 -4
  24. package/dist/cjs/test/render.js +6 -8
  25. package/dist/cjs/views/ViewDashboard/DashboardApp.js +7 -3
  26. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +9 -8
  27. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
  28. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  29. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  30. package/dist/components/GridLayout/GridLayout.d.ts +8 -0
  31. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  32. package/dist/components/GridLayout/GridLayout.js +72 -126
  33. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  34. package/dist/components/GridLayout/Row.d.ts +17 -0
  35. package/dist/components/GridLayout/Row.d.ts.map +1 -0
  36. package/dist/components/GridLayout/Row.js +142 -0
  37. package/dist/components/GridLayout/Row.js.map +1 -0
  38. package/dist/components/GridLayout/index.d.ts +1 -0
  39. package/dist/components/GridLayout/index.d.ts.map +1 -1
  40. package/dist/components/GridLayout/index.js +1 -0
  41. package/dist/components/GridLayout/index.js.map +1 -1
  42. package/dist/components/LeaveDialog/LeaveDialog.d.ts +12 -0
  43. package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -0
  44. package/dist/components/LeaveDialog/LeaveDialog.js +61 -0
  45. package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -0
  46. package/dist/components/LeaveDialog/index.d.ts +2 -0
  47. package/dist/components/LeaveDialog/index.d.ts.map +1 -0
  48. package/dist/components/LeaveDialog/index.js +15 -0
  49. package/dist/components/LeaveDialog/index.js.map +1 -0
  50. package/dist/components/Panel/HeaderIconButton.d.ts +1 -1
  51. package/dist/components/Panel/Panel.d.ts +5 -0
  52. package/dist/components/Panel/Panel.d.ts.map +1 -1
  53. package/dist/components/Panel/Panel.js +5 -1
  54. package/dist/components/Panel/Panel.js.map +1 -1
  55. package/dist/components/Panel/PanelActions.d.ts +2 -0
  56. package/dist/components/Panel/PanelActions.d.ts.map +1 -1
  57. package/dist/components/Panel/PanelActions.js +4 -4
  58. package/dist/components/Panel/PanelActions.js.map +1 -1
  59. package/dist/components/Panel/PanelHeader.d.ts +6 -1
  60. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  61. package/dist/components/Panel/PanelHeader.js +33 -16
  62. package/dist/components/Panel/PanelHeader.js.map +1 -1
  63. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  64. package/dist/components/PanelDrawer/PanelDrawer.js +59 -22
  65. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  66. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  67. package/dist/components/PanelDrawer/PanelEditorForm.js +207 -188
  68. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  69. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  70. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +3 -0
  71. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  72. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +1 -0
  73. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
  74. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +36 -16
  75. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  76. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  77. package/dist/components/Variables/VariableEditor.js +24 -17
  78. package/dist/components/Variables/VariableEditor.js.map +1 -1
  79. package/dist/components/index.d.ts +1 -0
  80. package/dist/components/index.d.ts.map +1 -1
  81. package/dist/components/index.js +1 -0
  82. package/dist/components/index.js.map +1 -1
  83. package/dist/context/DashboardProvider/DashboardProvider.d.ts +5 -5
  84. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  85. package/dist/context/DashboardProvider/DashboardProvider.js +7 -8
  86. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  87. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.d.ts.map +1 -1
  88. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +27 -5
  89. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -1
  90. package/dist/context/DashboardProvider/common.d.ts +1 -1
  91. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  92. package/dist/context/DashboardProvider/common.js.map +1 -1
  93. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +1 -0
  94. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  95. package/dist/context/DashboardProvider/panel-editor-slice.js +1 -0
  96. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  97. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -0
  98. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
  99. package/dist/context/DashboardProvider/panel-group-editor-slice.js +6 -2
  100. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  101. package/dist/context/DashboardProvider/panel-group-slice.d.ts +3 -0
  102. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  103. package/dist/context/DashboardProvider/panel-group-slice.js +1 -0
  104. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  105. package/dist/context/DashboardProvider/view-panel-slice.d.ts +6 -2
  106. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
  107. package/dist/context/DashboardProvider/view-panel-slice.js +10 -3
  108. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
  109. package/dist/context/VariableProvider/VariableProvider.js +1 -1
  110. package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
  111. package/dist/context/VariableProvider/query-params.d.ts +4 -3
  112. package/dist/context/VariableProvider/query-params.d.ts.map +1 -1
  113. package/dist/context/VariableProvider/query-params.js +9 -14
  114. package/dist/context/VariableProvider/query-params.js.map +1 -1
  115. package/dist/context/useDashboard.js +5 -4
  116. package/dist/context/useDashboard.js.map +1 -1
  117. package/dist/test/render.d.ts.map +1 -1
  118. package/dist/test/render.js +6 -8
  119. package/dist/test/render.js.map +1 -1
  120. package/dist/views/ViewDashboard/DashboardApp.d.ts +7 -6
  121. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  122. package/dist/views/ViewDashboard/DashboardApp.js +8 -4
  123. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  124. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  125. package/dist/views/ViewDashboard/ViewDashboard.js +9 -8
  126. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  127. package/package.json +6 -6
@@ -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,72 @@
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
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(Prompt, {
69
+ isBlocked: JSON.stringify(original) !== JSON.stringify(current),
70
+ message: "You have unsaved changes, are you sure you want to leave?"
71
+ });
72
+ }
@@ -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("./LeaveDialog"), 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
+ }
@@ -142,6 +142,8 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
142
142
  const handleMouseLeave = (e)=>{
143
143
  onMouseLeave?.(e);
144
144
  };
145
+ // default value for showIcons: if the dashboard is in editing mode or the panel is in fullscreen mode: 'always', otherwise 'hover'
146
+ const showIcons = panelOptions?.showIcons ?? (editHandlers || readHandlers?.isPanelViewed ? 'always' : 'hover');
145
147
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Card, {
146
148
  component: "section",
147
149
  sx: (0, _components.combineSx)({
@@ -175,9 +177,11 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
175
177
  viewQueriesHandler: viewQueriesHandler,
176
178
  links: definition.spec.links,
177
179
  pluginActions: pluginActions,
180
+ showIcons: showIcons,
178
181
  sx: {
179
182
  paddingX: `${chartsTheme.container.padding.default}px`
180
- }
183
+ },
184
+ dimension: contentDimensions
181
185
  }),
182
186
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CardContent, {
183
187
  component: "figure",
@@ -48,7 +48,7 @@ const ConditionalBox = (0, _material.styled)(_material.Box)({
48
48
  flexGrow: 1,
49
49
  justifyContent: 'flex-end'
50
50
  });
51
- const PanelActions = ({ editHandlers, readHandlers, viewQueriesHandler, extra, title, description, descriptionTooltipId, links, queryResults, pluginActions = [] })=>{
51
+ const PanelActions = ({ editHandlers, readHandlers, viewQueriesHandler, extra, title, description, descriptionTooltipId, links, queryResults, pluginActions = [], showIcons })=>{
52
52
  const descriptionAction = (0, _react.useMemo)(()=>{
53
53
  if (description && description.trim().length > 0) {
54
54
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
@@ -221,8 +221,8 @@ const PanelActions = ({ editHandlers, readHandlers, viewQueriesHandler, extra, t
221
221
  flexGrow: 1
222
222
  }
223
223
  });
224
- // if the panel is in non-editing, non-fullscreen mode, show certain icons only on hover
225
- const OnHover = ({ children })=>editHandlers === undefined && !readHandlers?.isPanelViewed ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
224
+ // By default, the panel header shows certain icons only on hover if the panel is in non-editing, non-fullscreen mode
225
+ const OnHover = ({ children })=>showIcons === 'hover' ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
226
226
  sx: {
227
227
  display: 'var(--panel-hover, none)'
228
228
  },
@@ -344,7 +344,7 @@ const OverflowMenu = ({ children, title })=>{
344
344
  // do not show overflow menu if there is no content (for example, edit actions are hidden)
345
345
  const hasContent = /*#__PURE__*/ (0, _react.isValidElement)(children) || Array.isArray(children) && children.some(_react.isValidElement);
346
346
  if (!hasContent) {
347
- return undefined;
347
+ return null;
348
348
  }
349
349
  const handleClick = (event)=>{
350
350
  setAnchorPosition(event.currentTarget.getBoundingClientRect());
@@ -24,13 +24,24 @@ const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
25
  const _components = require("@perses-dev/components");
26
26
  const _pluginsystem = require("@perses-dev/plugin-system");
27
+ const _react = require("react");
27
28
  const _constants = require("../../constants");
28
29
  const _PanelActions = require("./PanelActions");
29
- function PanelHeader({ id, title: rawTitle, description: rawDescription, links, queryResults, readHandlers, editHandlers, sx, extra, pluginActions, viewQueriesHandler, ...rest }) {
30
+ function PanelHeader({ id, title: rawTitle, description: rawDescription, links, queryResults, readHandlers, editHandlers, sx, extra, pluginActions, showIcons, viewQueriesHandler, dimension, ...rest }) {
30
31
  const titleElementId = `${id}-title`;
31
32
  const descriptionTooltipId = `${id}-description`;
32
33
  const title = (0, _pluginsystem.useReplaceVariablesInString)(rawTitle);
33
34
  const description = (0, _pluginsystem.useReplaceVariablesInString)(rawDescription);
35
+ const textRef = (0, _react.useRef)(null);
36
+ const [isEllipsisActive, setIsEllipsisActive] = (0, _react.useState)(false);
37
+ (0, _react.useEffect)(()=>{
38
+ if (textRef.current && dimension?.width) {
39
+ setIsEllipsisActive(textRef.current.scrollWidth > textRef.current.clientWidth);
40
+ }
41
+ }, [
42
+ title,
43
+ dimension?.width
44
+ ]);
34
45
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CardHeader, {
35
46
  id: id,
36
47
  component: "header",
@@ -42,19 +53,24 @@ function PanelHeader({ id, title: rawTitle, description: rawDescription, links,
42
53
  alignItems: "center",
43
54
  height: "var(--panel-header-height, 30px)",
44
55
  children: [
45
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
46
- id: titleElementId,
47
- variant: "subtitle1",
48
- sx: {
49
- // `minHeight` guarantees that the header has the correct height
50
- // when there is no title (i.e. in the preview)
51
- lineHeight: '24px',
52
- minHeight: '26px',
53
- whiteSpace: 'nowrap',
54
- overflow: 'hidden',
55
- textOverflow: 'ellipsis'
56
- },
57
- children: title
56
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tooltip, {
57
+ title: title,
58
+ disableHoverListener: !isEllipsisActive,
59
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
60
+ id: titleElementId,
61
+ variant: "subtitle1",
62
+ ref: textRef,
63
+ sx: {
64
+ // `minHeight` guarantees that the header has the correct height
65
+ // when there is no title (i.e. in the preview)
66
+ lineHeight: '24px',
67
+ minHeight: '26px',
68
+ whiteSpace: 'nowrap',
69
+ overflow: 'hidden',
70
+ textOverflow: 'ellipsis'
71
+ },
72
+ children: title
73
+ })
58
74
  }),
59
75
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_PanelActions.PanelActions, {
60
76
  title: title,
@@ -66,7 +82,8 @@ function PanelHeader({ id, title: rawTitle, description: rawDescription, links,
66
82
  viewQueriesHandler: viewQueriesHandler,
67
83
  extra: extra,
68
84
  queryResults: queryResults,
69
- pluginActions: pluginActions
85
+ pluginActions: pluginActions,
86
+ showIcons: showIcons
70
87
  })
71
88
  ]
72
89
  }),