@perses-dev/dashboards 0.53.0-beta.0 → 0.53.0-beta.2
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 +3 -3
- package/dist/cjs/components/GridLayout/GridLayout.js +1 -1
- package/dist/cjs/components/Panel/Panel.js +4 -3
- package/dist/cjs/components/Panel/PanelActions.js +5 -3
- package/dist/cjs/components/Panel/PanelHeader.js +1 -9
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +165 -196
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +2 -23
- package/dist/cjs/components/PanelDrawer/PanelQueriesSharedControls.js +80 -0
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +18 -6
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +11 -6
- package/dist/cjs/components/Variables/Variable.js +34 -0
- package/dist/cjs/components/Variables/VariableEditor.js +15 -22
- package/dist/cjs/components/Variables/VariableList.js +2 -2
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +1 -1
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -1
- package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +1 -1
- package/dist/cjs/context/DashboardProvider/index.js +1 -1
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +1 -1
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -7
- package/dist/cjs/context/DashboardProvider/view-panel-slice.js +1 -1
- package/dist/cjs/context/DatasourceStoreProvider.js +3 -4
- package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/cjs/context/VariableProvider/hydrationUtils.js +1 -1
- package/dist/cjs/context/VariableProvider/index.js +1 -1
- package/dist/cjs/context/VariableProvider/utils.js +1 -1
- package/dist/cjs/context/useDashboard.js +1 -1
- package/dist/cjs/utils/panelUtils.js +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +2 -2
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +1 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/Row.d.ts +2 -2
- package/dist/components/GridLayout/Row.d.ts.map +1 -1
- package/dist/components/GridLayout/Row.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +1 -2
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +5 -4
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.d.ts.map +1 -1
- package/dist/components/Panel/PanelActions.js +5 -3
- package/dist/components/Panel/PanelActions.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +2 -10
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +167 -198
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +2 -23
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.d.ts +13 -0
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.js +74 -0
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.js.map +1 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +19 -7
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +11 -6
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
- package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js.map +1 -1
- package/dist/components/Variables/Variable.js +37 -2
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +1 -2
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +17 -24
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +2 -2
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -2
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.js +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.js +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/index.d.ts +0 -1
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js +1 -1
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -2
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +1 -24
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +1 -6
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.d.ts +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.js +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +1 -17
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +2 -3
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts +2 -2
- package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts.map +1 -1
- package/dist/context/PanelEditorProvider/PanelEditorProvider.js.map +1 -1
- package/dist/context/VariableProvider/VariableProvider.d.ts +1 -10
- package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -1
- package/dist/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/VariableProvider/hydrationUtils.d.ts +1 -2
- package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/VariableProvider/hydrationUtils.js +1 -1
- package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/VariableProvider/index.js +1 -1
- package/dist/context/VariableProvider/index.js.map +1 -1
- package/dist/context/VariableProvider/utils.d.ts +1 -2
- package/dist/context/VariableProvider/utils.d.ts.map +1 -1
- package/dist/context/VariableProvider/utils.js +1 -1
- package/dist/context/VariableProvider/utils.js.map +1 -1
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +1 -1
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/utils/panelUtils.d.ts +1 -2
- package/dist/utils/panelUtils.d.ts.map +1 -1
- package/dist/utils/panelUtils.js +1 -1
- package/dist/utils/panelUtils.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -25,9 +25,9 @@ const _material = require("@mui/material");
|
|
|
25
25
|
const _reactintersectionobserver = require("react-intersection-observer");
|
|
26
26
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
27
27
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
28
|
+
const _core = require("@perses-dev/core");
|
|
28
29
|
const _context = require("../../context");
|
|
29
30
|
const _Panel = require("../Panel");
|
|
30
|
-
const _panelgroupslice = require("../../context/DashboardProvider/panel-group-slice");
|
|
31
31
|
const _QueryViewerDialog = require("../QueryViewerDialog");
|
|
32
32
|
function _getRequireWildcardCache(nodeInterop) {
|
|
33
33
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -94,7 +94,7 @@ function GridItemContent(props) {
|
|
|
94
94
|
queries
|
|
95
95
|
]);
|
|
96
96
|
const readHandlers = {
|
|
97
|
-
isPanelViewed: (0,
|
|
97
|
+
isPanelViewed: (0, _core.isPanelGroupItemIdEqual)(viewPanelGroupItemId, panelGroupItemId),
|
|
98
98
|
onViewPanelClick: function() {
|
|
99
99
|
if (viewPanelGroupItemId === undefined) {
|
|
100
100
|
viewPanel(panelGroupItemId);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -52,7 +52,6 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
|
|
|
52
52
|
width,
|
|
53
53
|
height
|
|
54
54
|
]);
|
|
55
|
-
const chartsTheme = (0, _components.useChartsTheme)();
|
|
56
55
|
const { queryResults } = (0, _pluginsystem.useDataQueriesContext)();
|
|
57
56
|
const { getPlugin } = (0, _pluginsystem.usePluginRegistry)();
|
|
58
57
|
const panelPropsForActions = (0, _react.useMemo)(()=>{
|
|
@@ -179,7 +178,9 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
|
|
|
179
178
|
pluginActions: pluginActions,
|
|
180
179
|
showIcons: showIcons,
|
|
181
180
|
sx: {
|
|
182
|
-
|
|
181
|
+
py: '2px',
|
|
182
|
+
pl: '8px',
|
|
183
|
+
pr: '2px'
|
|
183
184
|
},
|
|
184
185
|
dimension: contentDimensions
|
|
185
186
|
}),
|
|
@@ -88,15 +88,17 @@ const PanelActions = ({ editHandlers, readHandlers, viewQueriesHandler, extra, t
|
|
|
88
88
|
size: "1.125rem"
|
|
89
89
|
});
|
|
90
90
|
} else if (queryErrors.length > 0) {
|
|
91
|
-
const errorTexts = queryErrors.map((q)=>q.error).map((e)=>e
|
|
92
|
-
.join('\n');
|
|
91
|
+
const errorTexts = queryErrors.map((q)=>q.error).map((e)=>e.message).join('\n');
|
|
93
92
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
|
|
94
93
|
description: errorTexts,
|
|
95
94
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_HeaderIconButton.HeaderIconButton, {
|
|
96
95
|
"aria-label": "panel errors",
|
|
97
96
|
size: "small",
|
|
98
97
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Alert.default, {
|
|
99
|
-
fontSize: "inherit"
|
|
98
|
+
fontSize: "inherit",
|
|
99
|
+
sx: {
|
|
100
|
+
color: (theme)=>theme.palette.error.main
|
|
101
|
+
}
|
|
100
102
|
})
|
|
101
103
|
})
|
|
102
104
|
});
|
|
@@ -33,15 +33,7 @@ function PanelHeader({ id, title: rawTitle, description: rawDescription, links,
|
|
|
33
33
|
const title = (0, _pluginsystem.useReplaceVariablesInString)(rawTitle);
|
|
34
34
|
const description = (0, _pluginsystem.useReplaceVariablesInString)(rawDescription);
|
|
35
35
|
const textRef = (0, _react.useRef)(null);
|
|
36
|
-
const
|
|
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
|
-
]);
|
|
36
|
+
const isEllipsisActive = textRef.current && dimension?.width ? textRef.current.scrollWidth > textRef.current.clientWidth : false;
|
|
45
37
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CardHeader, {
|
|
46
38
|
id: id,
|
|
47
39
|
component: "header",
|
|
@@ -31,15 +31,14 @@ _export(exports, {
|
|
|
31
31
|
const _jsxruntime = require("react/jsx-runtime");
|
|
32
32
|
const _react = require("react");
|
|
33
33
|
const _material = require("@mui/material");
|
|
34
|
-
const _core = require("@perses-dev/core");
|
|
35
34
|
const _components = require("@perses-dev/components");
|
|
36
35
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
37
36
|
const _reacthookform = require("react-hook-form");
|
|
38
37
|
const _zod = require("@hookform/resolvers/zod");
|
|
39
38
|
const _context = require("../../context");
|
|
40
39
|
const _PanelEditorProvider = require("../../context/PanelEditorProvider/PanelEditorProvider");
|
|
41
|
-
const _PanelPreview = require("./PanelPreview");
|
|
42
40
|
const _usePanelEditor = require("./usePanelEditor");
|
|
41
|
+
const _PanelQueriesSharedControls = require("./PanelQueriesSharedControls");
|
|
43
42
|
function PanelEditorForm(props) {
|
|
44
43
|
const { initialValues, initialAction, onSave, onClose } = props;
|
|
45
44
|
const pluginEditorRef = (0, _react.useRef)(null);
|
|
@@ -53,9 +52,6 @@ function PanelEditorForm(props) {
|
|
|
53
52
|
mode: 'onBlur',
|
|
54
53
|
defaultValues: initialValues
|
|
55
54
|
});
|
|
56
|
-
const { dashboard } = (0, _context.useDashboard)();
|
|
57
|
-
const dashboardDuration = dashboard?.kind === 'Dashboard' ? dashboard.spec.duration : _core.DEFAULT_DASHBOARD_DURATION;
|
|
58
|
-
const initialTimeRange = (0, _pluginsystem.useInitialTimeRange)(dashboardDuration);
|
|
59
55
|
// Use common plugin editor logic even though we've split the inputs up in this form
|
|
60
56
|
const pluginEditor = (0, _pluginsystem.usePluginEditor)({
|
|
61
57
|
pluginTypes: [
|
|
@@ -131,7 +127,6 @@ function PanelEditorForm(props) {
|
|
|
131
127
|
control: form.control,
|
|
132
128
|
name: 'panelDefinition.spec.plugin.kind'
|
|
133
129
|
});
|
|
134
|
-
const { timeRange } = (0, _pluginsystem.useTimeRangeParams)(initialTimeRange);
|
|
135
130
|
const handleSubmit = (0, _react.useCallback)(()=>{
|
|
136
131
|
pluginEditorRef.current?.flushChanges?.();
|
|
137
132
|
form.handleSubmit(processForm)();
|
|
@@ -139,204 +134,178 @@ function PanelEditorForm(props) {
|
|
|
139
134
|
form,
|
|
140
135
|
processForm
|
|
141
136
|
]);
|
|
142
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
143
|
-
|
|
144
|
-
children: /*#__PURE__*/ (0, _jsxruntime.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
|
|
157
|
-
variant: "h2",
|
|
158
|
-
children: [
|
|
159
|
-
titleAction,
|
|
160
|
-
" Panel"
|
|
161
|
-
]
|
|
162
|
-
}),
|
|
163
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
164
|
-
direction: "row",
|
|
165
|
-
spacing: 1,
|
|
166
|
-
marginLeft: "auto",
|
|
167
|
-
children: [
|
|
168
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
169
|
-
variant: "contained",
|
|
170
|
-
disabled: !form.formState.isValid,
|
|
171
|
-
onClick: handleSubmit,
|
|
172
|
-
children: submitText
|
|
173
|
-
}),
|
|
174
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
175
|
-
color: "secondary",
|
|
176
|
-
variant: "outlined",
|
|
177
|
-
onClick: handleCancel,
|
|
178
|
-
children: "Cancel"
|
|
179
|
-
})
|
|
180
|
-
]
|
|
181
|
-
})
|
|
182
|
-
]
|
|
183
|
-
}),
|
|
184
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
185
|
-
id: panelEditorFormId,
|
|
186
|
-
sx: {
|
|
187
|
-
flex: 1,
|
|
188
|
-
overflowY: 'scroll',
|
|
189
|
-
padding: (theme)=>theme.spacing(2)
|
|
190
|
-
},
|
|
191
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
192
|
-
container: true,
|
|
193
|
-
spacing: 2,
|
|
137
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.FormProvider, {
|
|
138
|
+
...form,
|
|
139
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_PanelEditorProvider.PanelEditorProvider, {
|
|
140
|
+
children: [
|
|
141
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
142
|
+
sx: {
|
|
143
|
+
display: 'flex',
|
|
144
|
+
alignItems: 'center',
|
|
145
|
+
padding: (theme)=>theme.spacing(1, 2),
|
|
146
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
147
|
+
},
|
|
148
|
+
children: [
|
|
149
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
|
|
150
|
+
variant: "h2",
|
|
194
151
|
children: [
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
onChange: (event)=>{
|
|
210
|
-
field.onChange(event);
|
|
211
|
-
setName(event.target.value);
|
|
212
|
-
}
|
|
213
|
-
})
|
|
214
|
-
})
|
|
215
|
-
}),
|
|
216
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
217
|
-
item: true,
|
|
218
|
-
xs: 4,
|
|
219
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
220
|
-
control: form.control,
|
|
221
|
-
name: "groupId",
|
|
222
|
-
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
223
|
-
select: true,
|
|
224
|
-
...field,
|
|
225
|
-
required: true,
|
|
226
|
-
fullWidth: true,
|
|
227
|
-
label: "Group",
|
|
228
|
-
error: !!fieldState.error,
|
|
229
|
-
helperText: fieldState.error?.message,
|
|
230
|
-
onChange: (event)=>{
|
|
231
|
-
field.onChange(event);
|
|
232
|
-
},
|
|
233
|
-
children: panelGroups.map((panelGroup, index)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
234
|
-
value: panelGroup.id,
|
|
235
|
-
children: panelGroup.title ?? `Group ${index + 1}`
|
|
236
|
-
}, panelGroup.id))
|
|
237
|
-
})
|
|
238
|
-
})
|
|
239
|
-
}),
|
|
240
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
241
|
-
item: true,
|
|
242
|
-
xs: 8,
|
|
243
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
244
|
-
control: form.control,
|
|
245
|
-
name: "panelDefinition.spec.display.description",
|
|
246
|
-
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
247
|
-
...field,
|
|
248
|
-
fullWidth: true,
|
|
249
|
-
label: "Description",
|
|
250
|
-
error: !!fieldState.error,
|
|
251
|
-
helperText: fieldState.error?.message,
|
|
252
|
-
value: watchedDescription ?? '',
|
|
253
|
-
onChange: (event)=>{
|
|
254
|
-
field.onChange(event);
|
|
255
|
-
setDescription(event.target.value);
|
|
256
|
-
}
|
|
257
|
-
})
|
|
258
|
-
})
|
|
259
|
-
}),
|
|
260
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
261
|
-
item: true,
|
|
262
|
-
xs: 4,
|
|
263
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
264
|
-
control: form.control,
|
|
265
|
-
name: "panelDefinition.spec.plugin.kind",
|
|
266
|
-
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PluginKindSelect, {
|
|
267
|
-
...field,
|
|
268
|
-
pluginTypes: [
|
|
269
|
-
'Panel'
|
|
270
|
-
],
|
|
271
|
-
required: true,
|
|
272
|
-
fullWidth: true,
|
|
273
|
-
label: "Type",
|
|
274
|
-
disabled: pluginEditor.isLoading,
|
|
275
|
-
error: !!pluginEditor.error || !!fieldState.error,
|
|
276
|
-
helperText: pluginEditor.error?.message ?? fieldState.error?.message,
|
|
277
|
-
value: {
|
|
278
|
-
type: 'Panel',
|
|
279
|
-
kind: watchedPluginKind
|
|
280
|
-
},
|
|
281
|
-
onChange: (event)=>{
|
|
282
|
-
field.onChange(event.kind);
|
|
283
|
-
pluginEditor.onSelectionChange(event);
|
|
284
|
-
}
|
|
285
|
-
})
|
|
286
|
-
})
|
|
152
|
+
titleAction,
|
|
153
|
+
" Panel"
|
|
154
|
+
]
|
|
155
|
+
}),
|
|
156
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
157
|
+
direction: "row",
|
|
158
|
+
spacing: 1,
|
|
159
|
+
marginLeft: "auto",
|
|
160
|
+
children: [
|
|
161
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
162
|
+
variant: "contained",
|
|
163
|
+
disabled: !form.formState.isValid,
|
|
164
|
+
onClick: handleSubmit,
|
|
165
|
+
children: submitText
|
|
287
166
|
}),
|
|
288
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
167
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
168
|
+
color: "secondary",
|
|
169
|
+
variant: "outlined",
|
|
170
|
+
onClick: handleCancel,
|
|
171
|
+
children: "Cancel"
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
})
|
|
175
|
+
]
|
|
176
|
+
}),
|
|
177
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
178
|
+
id: panelEditorFormId,
|
|
179
|
+
sx: {
|
|
180
|
+
flex: 1,
|
|
181
|
+
overflowY: 'scroll',
|
|
182
|
+
padding: (theme)=>theme.spacing(2)
|
|
183
|
+
},
|
|
184
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
185
|
+
container: true,
|
|
186
|
+
spacing: 2,
|
|
187
|
+
children: [
|
|
188
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
189
|
+
item: true,
|
|
190
|
+
xs: 8,
|
|
191
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
192
|
+
control: form.control,
|
|
193
|
+
name: "panelDefinition.spec.display.name",
|
|
194
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
195
|
+
...field,
|
|
196
|
+
required: true,
|
|
197
|
+
fullWidth: true,
|
|
198
|
+
label: "Name",
|
|
199
|
+
error: !!fieldState.error,
|
|
200
|
+
helperText: fieldState.error?.message,
|
|
201
|
+
value: watchedName ?? '',
|
|
202
|
+
onChange: (event)=>{
|
|
203
|
+
field.onChange(event);
|
|
204
|
+
setName(event.target.value);
|
|
205
|
+
}
|
|
302
206
|
})
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
207
|
+
})
|
|
208
|
+
}),
|
|
209
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
210
|
+
item: true,
|
|
211
|
+
xs: 4,
|
|
212
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
213
|
+
control: form.control,
|
|
214
|
+
name: "groupId",
|
|
215
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
216
|
+
select: true,
|
|
217
|
+
...field,
|
|
218
|
+
required: true,
|
|
219
|
+
fullWidth: true,
|
|
220
|
+
label: "Group",
|
|
221
|
+
error: !!fieldState.error,
|
|
222
|
+
helperText: fieldState.error?.message,
|
|
223
|
+
onChange: (event)=>{
|
|
224
|
+
field.onChange(event);
|
|
317
225
|
},
|
|
318
|
-
|
|
319
|
-
|
|
226
|
+
children: panelGroups.map((panelGroup, index)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
227
|
+
value: panelGroup.id,
|
|
228
|
+
children: panelGroup.title ?? `Group ${index + 1}`
|
|
229
|
+
}, panelGroup.id))
|
|
230
|
+
})
|
|
231
|
+
})
|
|
232
|
+
}),
|
|
233
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
234
|
+
item: true,
|
|
235
|
+
xs: 8,
|
|
236
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
237
|
+
control: form.control,
|
|
238
|
+
name: "panelDefinition.spec.display.description",
|
|
239
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
240
|
+
...field,
|
|
241
|
+
fullWidth: true,
|
|
242
|
+
label: "Description",
|
|
243
|
+
error: !!fieldState.error,
|
|
244
|
+
helperText: fieldState.error?.message,
|
|
245
|
+
value: watchedDescription ?? '',
|
|
246
|
+
onChange: (event)=>{
|
|
247
|
+
field.onChange(event);
|
|
248
|
+
setDescription(event.target.value);
|
|
320
249
|
}
|
|
321
250
|
})
|
|
322
|
-
})
|
|
323
251
|
})
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
252
|
+
}),
|
|
253
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
254
|
+
item: true,
|
|
255
|
+
xs: 4,
|
|
256
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
257
|
+
control: form.control,
|
|
258
|
+
name: "panelDefinition.spec.plugin.kind",
|
|
259
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PluginKindSelect, {
|
|
260
|
+
...field,
|
|
261
|
+
pluginTypes: [
|
|
262
|
+
'Panel'
|
|
263
|
+
],
|
|
264
|
+
required: true,
|
|
265
|
+
fullWidth: true,
|
|
266
|
+
label: "Type",
|
|
267
|
+
disabled: pluginEditor.isLoading,
|
|
268
|
+
error: !!pluginEditor.error || !!fieldState.error,
|
|
269
|
+
helperText: pluginEditor.error?.message ?? fieldState.error?.message,
|
|
270
|
+
value: {
|
|
271
|
+
type: 'Panel',
|
|
272
|
+
kind: watchedPluginKind
|
|
273
|
+
},
|
|
274
|
+
onChange: (event)=>{
|
|
275
|
+
field.onChange(event.kind);
|
|
276
|
+
pluginEditor.onSelectionChange(event);
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
})
|
|
280
|
+
}),
|
|
281
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
282
|
+
FallbackComponent: _components.ErrorAlert,
|
|
283
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PanelQueriesSharedControls.PanelQueriesSharedControls, {
|
|
284
|
+
control: form.control,
|
|
285
|
+
plugin: plugin,
|
|
286
|
+
panelDefinition: panelDefinition,
|
|
287
|
+
onQueriesChange: (q)=>setQueries(q),
|
|
288
|
+
onPluginSpecChange: (spec)=>{
|
|
289
|
+
pluginEditor.onSpecChange(spec);
|
|
290
|
+
},
|
|
291
|
+
onJSONChange: handlePanelDefinitionChange
|
|
292
|
+
})
|
|
293
|
+
})
|
|
294
|
+
]
|
|
337
295
|
})
|
|
338
|
-
|
|
339
|
-
|
|
296
|
+
}),
|
|
297
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.DiscardChangesConfirmationDialog, {
|
|
298
|
+
description: "You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.",
|
|
299
|
+
isOpen: isDiscardDialogOpened,
|
|
300
|
+
onCancel: ()=>{
|
|
301
|
+
setDiscardDialogOpened(false);
|
|
302
|
+
},
|
|
303
|
+
onDiscardChanges: ()=>{
|
|
304
|
+
setDiscardDialogOpened(false);
|
|
305
|
+
onClose();
|
|
306
|
+
}
|
|
307
|
+
})
|
|
308
|
+
]
|
|
340
309
|
})
|
|
341
310
|
});
|
|
342
311
|
}
|
|
@@ -23,7 +23,6 @@ Object.defineProperty(exports, "PanelPreview", {
|
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _react = require("react");
|
|
25
25
|
const _material = require("@mui/material");
|
|
26
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
27
26
|
const _Panel = require("../Panel");
|
|
28
27
|
const _context = require("../../context");
|
|
29
28
|
const PANEL_PREVIEW_HEIGHT = 300;
|
|
@@ -36,34 +35,14 @@ function PanelPreview({ panelDefinition }) {
|
|
|
36
35
|
width = boxRef.current.getBoundingClientRect().width;
|
|
37
36
|
panelEditorContext?.preview?.setPreviewPanelWidth?.(width);
|
|
38
37
|
}
|
|
39
|
-
const suggestedStepMs = (0, _pluginsystem.useSuggestedStepMs)(width);
|
|
40
|
-
const { data: plugin, isLoading } = (0, _pluginsystem.usePlugin)('Panel', panelDefinition.spec.plugin.kind);
|
|
41
|
-
if (isLoading) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
38
|
if (panelDefinition.spec.plugin.kind === '') {
|
|
45
39
|
return null;
|
|
46
40
|
}
|
|
47
|
-
const queries = panelDefinition.spec.queries ?? [];
|
|
48
|
-
// map TimeSeriesQueryDefinition to Definition<UnknownSpec>
|
|
49
|
-
const definitions = queries.length ? queries.map((query)=>{
|
|
50
|
-
return {
|
|
51
|
-
kind: query.spec.plugin.kind,
|
|
52
|
-
spec: query.spec.plugin.spec
|
|
53
|
-
};
|
|
54
|
-
}) : [];
|
|
55
41
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
56
42
|
ref: boxRef,
|
|
57
43
|
height: PANEL_PREVIEW_HEIGHT,
|
|
58
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
59
|
-
|
|
60
|
-
options: {
|
|
61
|
-
suggestedStepMs,
|
|
62
|
-
...plugin?.queryOptions
|
|
63
|
-
},
|
|
64
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Panel.Panel, {
|
|
65
|
-
definition: panelDefinition
|
|
66
|
-
})
|
|
44
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Panel.Panel, {
|
|
45
|
+
definition: panelDefinition
|
|
67
46
|
})
|
|
68
47
|
});
|
|
69
48
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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, "PanelQueriesSharedControls", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return PanelQueriesSharedControls;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _material = require("@mui/material");
|
|
25
|
+
const _components = require("@perses-dev/components");
|
|
26
|
+
const _dashboards = require("@perses-dev/dashboards");
|
|
27
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
28
|
+
const _react = require("react");
|
|
29
|
+
function PanelQueriesSharedControls({ plugin, control, panelDefinition, onQueriesChange, onPluginSpecChange, onJSONChange }) {
|
|
30
|
+
const { data: pluginPreview } = (0, _pluginsystem.usePlugin)('Panel', plugin.kind);
|
|
31
|
+
const panelEditorContext = (0, _react.useContext)(_dashboards.PanelEditorContext);
|
|
32
|
+
const pluginQueryOptions = typeof pluginPreview?.queryOptions === 'function' ? pluginPreview?.queryOptions(panelDefinition.spec.plugin.spec) : pluginPreview?.queryOptions;
|
|
33
|
+
const suggestedStepMs = (0, _pluginsystem.useSuggestedStepMs)(panelEditorContext?.preview.previewPanelWidth);
|
|
34
|
+
const definitions = panelDefinition.spec.queries?.map((query)=>{
|
|
35
|
+
return {
|
|
36
|
+
kind: query.spec.plugin.kind,
|
|
37
|
+
spec: query.spec.plugin.spec
|
|
38
|
+
};
|
|
39
|
+
}) ?? [];
|
|
40
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_pluginsystem.DataQueriesProvider, {
|
|
41
|
+
definitions: definitions,
|
|
42
|
+
options: {
|
|
43
|
+
suggestedStepMs,
|
|
44
|
+
...pluginQueryOptions
|
|
45
|
+
},
|
|
46
|
+
children: [
|
|
47
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
48
|
+
item: true,
|
|
49
|
+
xs: 12,
|
|
50
|
+
children: [
|
|
51
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
52
|
+
variant: "h4",
|
|
53
|
+
marginBottom: 1,
|
|
54
|
+
children: "Preview"
|
|
55
|
+
}),
|
|
56
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
57
|
+
FallbackComponent: _components.ErrorAlert,
|
|
58
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.PanelPreview, {
|
|
59
|
+
panelDefinition: panelDefinition
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
]
|
|
63
|
+
}),
|
|
64
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
65
|
+
item: true,
|
|
66
|
+
xs: 12,
|
|
67
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
68
|
+
FallbackComponent: _components.ErrorAlert,
|
|
69
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PanelSpecEditor, {
|
|
70
|
+
control: control,
|
|
71
|
+
panelDefinition: panelDefinition,
|
|
72
|
+
onJSONChange: onJSONChange,
|
|
73
|
+
onQueriesChange: onQueriesChange,
|
|
74
|
+
onPluginSpecChange: onPluginSpecChange
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
}
|