@perses-dev/dashboards 0.52.0-beta.4 → 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/GridItemContent.js +137 -17
- 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 +7 -2
- package/dist/cjs/components/Panel/PanelActions.js +25 -5
- package/dist/cjs/components/Panel/PanelHeader.js +33 -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/constants/user-interface-text.js +4 -2
- 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/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +99 -20
- package/dist/components/GridLayout/GridItemContent.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 +6 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +7 -2
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.d.ts +5 -0
- package/dist/components/Panel/PanelActions.d.ts.map +1 -1
- package/dist/components/Panel/PanelActions.js +25 -5
- package/dist/components/Panel/PanelActions.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +7 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +34 -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/constants/user-interface-text.d.ts +2 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +4 -2
- package/dist/constants/user-interface-text.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
|
@@ -24,9 +24,51 @@ 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
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
32
|
+
if (typeof WeakMap !== "function") return null;
|
|
33
|
+
var cacheBabelInterop = new WeakMap();
|
|
34
|
+
var cacheNodeInterop = new WeakMap();
|
|
35
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
36
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
37
|
+
})(nodeInterop);
|
|
38
|
+
}
|
|
39
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
40
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
44
|
+
return {
|
|
45
|
+
default: obj
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
49
|
+
if (cache && cache.has(obj)) {
|
|
50
|
+
return cache.get(obj);
|
|
51
|
+
}
|
|
52
|
+
var newObj = {
|
|
53
|
+
__proto__: null
|
|
54
|
+
};
|
|
55
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
56
|
+
for(var key in obj){
|
|
57
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
58
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
59
|
+
if (desc && (desc.get || desc.set)) {
|
|
60
|
+
Object.defineProperty(newObj, key, desc);
|
|
61
|
+
} else {
|
|
62
|
+
newObj[key] = obj[key];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
newObj.default = obj;
|
|
67
|
+
if (cache) {
|
|
68
|
+
cache.set(obj, newObj);
|
|
69
|
+
}
|
|
70
|
+
return newObj;
|
|
71
|
+
}
|
|
30
72
|
function GridItemContent(props) {
|
|
31
73
|
const { panelGroupItemId, width } = props;
|
|
32
74
|
const panelDefinition = (0, _context.usePanel)(panelGroupItemId);
|
|
@@ -39,6 +81,17 @@ function GridItemContent(props) {
|
|
|
39
81
|
initialInView: false,
|
|
40
82
|
triggerOnce: true
|
|
41
83
|
});
|
|
84
|
+
const [openQueryViewer, setOpenQueryViewer] = (0, _react.useState)(false);
|
|
85
|
+
const viewQueriesHandler = (0, _react.useMemo)(()=>{
|
|
86
|
+
return isEditMode || !queries?.length ? undefined : {
|
|
87
|
+
onClick: ()=>{
|
|
88
|
+
setOpenQueryViewer(true);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}, [
|
|
92
|
+
isEditMode,
|
|
93
|
+
queries
|
|
94
|
+
]);
|
|
42
95
|
const readHandlers = {
|
|
43
96
|
isPanelViewed: (0, _panelgroupslice.isPanelGroupItemIdEqual)(viewPanelGroupItemId, panelGroupItemId),
|
|
44
97
|
onViewPanelClick: function() {
|
|
@@ -69,28 +122,95 @@ function GridItemContent(props) {
|
|
|
69
122
|
};
|
|
70
123
|
});
|
|
71
124
|
const pluginQueryOptions = typeof plugin?.queryOptions === 'function' ? plugin?.queryOptions(panelDefinition.spec.plugin.spec) : plugin?.queryOptions;
|
|
72
|
-
|
|
125
|
+
const queryRows = (0, _react.useMemo)(()=>{
|
|
126
|
+
if (!queries?.length) return null;
|
|
127
|
+
const queryItems = [];
|
|
128
|
+
queries.forEach((query, index)=>{
|
|
129
|
+
if (query?.spec?.plugin?.kind && query?.kind) {
|
|
130
|
+
queryItems.push(/*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.default.Fragment, {
|
|
131
|
+
children: [
|
|
132
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PluginSpecEditor, {
|
|
133
|
+
value: query.spec.plugin.spec,
|
|
134
|
+
pluginSelection: {
|
|
135
|
+
kind: query.spec.plugin.kind,
|
|
136
|
+
type: query.kind
|
|
137
|
+
},
|
|
138
|
+
onChange: ()=>{},
|
|
139
|
+
isReadonly: true
|
|
140
|
+
}),
|
|
141
|
+
index < queries.length - 1 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {
|
|
142
|
+
sx: {
|
|
143
|
+
my: 2
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
}, `query-${index}`));
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return queryItems;
|
|
151
|
+
}, [
|
|
152
|
+
queries
|
|
153
|
+
]);
|
|
154
|
+
const onCloseHandler = ()=>{
|
|
155
|
+
setOpenQueryViewer(false);
|
|
156
|
+
};
|
|
157
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
73
158
|
ref: ref,
|
|
74
159
|
sx: {
|
|
75
160
|
width: '100%',
|
|
76
161
|
height: '100%'
|
|
77
162
|
},
|
|
78
|
-
children:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
163
|
+
children: [
|
|
164
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Dialog, {
|
|
165
|
+
fullWidth: true,
|
|
166
|
+
PaperProps: {
|
|
167
|
+
sx: {
|
|
168
|
+
margin: '10px',
|
|
169
|
+
width: 'calc(100% - 20px)'
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
maxWidth: "lg",
|
|
173
|
+
open: openQueryViewer,
|
|
174
|
+
children: [
|
|
175
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.DialogTitle, {
|
|
176
|
+
children: "Query Viewer"
|
|
177
|
+
}),
|
|
178
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.DialogContent, {
|
|
179
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
180
|
+
sx: {
|
|
181
|
+
padding: '5px'
|
|
182
|
+
},
|
|
183
|
+
children: queryRows
|
|
184
|
+
})
|
|
185
|
+
}),
|
|
186
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.DialogActions, {
|
|
187
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
188
|
+
variant: "outlined",
|
|
189
|
+
onClick: onCloseHandler,
|
|
190
|
+
color: "primary",
|
|
191
|
+
children: "Close"
|
|
192
|
+
})
|
|
193
|
+
})
|
|
194
|
+
]
|
|
195
|
+
}),
|
|
196
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DataQueriesProvider, {
|
|
197
|
+
definitions: definitions,
|
|
198
|
+
options: {
|
|
199
|
+
suggestedStepMs,
|
|
200
|
+
...pluginQueryOptions
|
|
201
|
+
},
|
|
202
|
+
queryOptions: {
|
|
203
|
+
enabled: inView
|
|
204
|
+
},
|
|
205
|
+
children: inView && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Panel.Panel, {
|
|
206
|
+
definition: panelDefinition,
|
|
207
|
+
readHandlers: readHandlers,
|
|
208
|
+
editHandlers: editHandlers,
|
|
209
|
+
viewQueriesHandler: viewQueriesHandler,
|
|
210
|
+
panelOptions: props.panelOptions,
|
|
211
|
+
panelGroupItemId: panelGroupItemId
|
|
212
|
+
})
|
|
93
213
|
})
|
|
94
|
-
|
|
214
|
+
]
|
|
95
215
|
});
|
|
96
216
|
}
|
|
@@ -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
|
+
}
|