@perses-dev/dashboards 0.52.0-beta.5 → 0.52.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/GridLayout/GridLayout.js +78 -126
- package/dist/cjs/components/GridLayout/Row.js +150 -0
- package/dist/cjs/components/GridLayout/index.js +1 -0
- package/dist/cjs/components/LeaveDialog/LeaveDialog.js +44 -0
- package/dist/cjs/components/LeaveDialog/index.js +30 -0
- package/dist/cjs/components/Panel/Panel.js +5 -1
- package/dist/cjs/components/Panel/PanelActions.js +3 -3
- package/dist/cjs/components/Panel/PanelHeader.js +32 -15
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +58 -21
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +3 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +35 -15
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +7 -8
- package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +3 -3
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +1 -0
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +6 -2
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -0
- package/dist/cjs/context/DashboardProvider/view-panel-slice.js +10 -3
- package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/cjs/context/useDashboard.js +5 -4
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +7 -3
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +9 -8
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +8 -0
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +72 -126
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/Row.d.ts +17 -0
- package/dist/components/GridLayout/Row.d.ts.map +1 -0
- package/dist/components/GridLayout/Row.js +142 -0
- package/dist/components/GridLayout/Row.js.map +1 -0
- package/dist/components/GridLayout/index.d.ts +1 -0
- package/dist/components/GridLayout/index.d.ts.map +1 -1
- package/dist/components/GridLayout/index.js +1 -0
- package/dist/components/GridLayout/index.js.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.d.ts +7 -0
- package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -0
- package/dist/components/LeaveDialog/LeaveDialog.js +36 -0
- package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -0
- package/dist/components/LeaveDialog/index.d.ts +2 -0
- package/dist/components/LeaveDialog/index.d.ts.map +1 -0
- package/dist/components/LeaveDialog/index.js +15 -0
- package/dist/components/LeaveDialog/index.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +5 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +5 -1
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.d.ts +2 -0
- package/dist/components/Panel/PanelActions.d.ts.map +1 -1
- package/dist/components/Panel/PanelActions.js +3 -3
- package/dist/components/Panel/PanelActions.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +6 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +33 -16
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +59 -22
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +3 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +36 -16
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +5 -5
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +7 -8
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +4 -4
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +1 -1
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +6 -2
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +3 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.d.ts +6 -2
- package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.js +10 -3
- package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
- package/dist/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/useDashboard.js +5 -4
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +7 -6
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +8 -4
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +9 -8
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +5 -5
|
@@ -14,67 +14,34 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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,44 @@
|
|
|
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, "LeaveDialog", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return LeaveDialog;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _react = require("react");
|
|
25
|
+
function LeaveDialog({ original, current }) {
|
|
26
|
+
(0, _react.useEffect)(()=>{
|
|
27
|
+
const handleBeforeUnload = (event)=>{
|
|
28
|
+
if (JSON.stringify(original) === JSON.stringify(current)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
event.returnValue = ''; // Required for Chrome
|
|
33
|
+
return ''; // Required for other browsers
|
|
34
|
+
};
|
|
35
|
+
window.addEventListener('beforeunload', handleBeforeUnload);
|
|
36
|
+
return ()=>{
|
|
37
|
+
window.removeEventListener('beforeunload', handleBeforeUnload);
|
|
38
|
+
};
|
|
39
|
+
}, [
|
|
40
|
+
original,
|
|
41
|
+
current
|
|
42
|
+
]);
|
|
43
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {});
|
|
44
|
+
}
|
|
@@ -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
|
|
225
|
-
const OnHover = ({ children })=>
|
|
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
|
},
|
|
@@ -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.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
}),
|