@perses-dev/dashboards 0.0.0-snapshot-ts-panel-actions-90e9ef0 → 0.0.0-snapshot-reverse-proxy-75afbd7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -20
- package/dist/cjs/components/GridLayout/GridItemContent.js +79 -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 +81 -0
- package/dist/cjs/components/LeaveDialog/index.js +30 -0
- package/dist/cjs/components/Panel/Panel.js +90 -2
- package/dist/cjs/components/Panel/PanelActions.js +37 -11
- package/dist/cjs/components/Panel/PanelHeader.js +37 -16
- package/dist/cjs/components/Panel/index.js +1 -0
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +58 -21
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +202 -180
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +3 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +9 -21
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +35 -15
- package/dist/cjs/components/QueryViewerDialog/QueryViewerDialog.js +121 -0
- package/dist/cjs/components/QueryViewerDialog/index.js +30 -0
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -1
- package/dist/cjs/components/Variables/ListVariableListBox.js +201 -0
- package/dist/cjs/components/Variables/Variable.js +130 -72
- package/dist/cjs/components/Variables/VariableEditor.js +22 -15
- package/dist/cjs/components/Variables/index.js +1 -0
- package/dist/cjs/components/index.js +3 -1
- 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 +4 -4
- package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +1 -1
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +2 -2
- 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/PanelEditorProvider/PanelEditorProvider.js +49 -0
- package/dist/cjs/context/PanelEditorProvider/index.js +23 -0
- package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/cjs/context/index.js +1 -0
- 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/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- 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/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -15
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +39 -18
- 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 +13 -0
- package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -0
- package/dist/components/LeaveDialog/LeaveDialog.js +70 -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/HeaderIconButton.d.ts +1 -1
- 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 +92 -4
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.d.ts +7 -1
- package/dist/components/Panel/PanelActions.d.ts.map +1 -1
- package/dist/components/Panel/PanelActions.js +37 -11
- package/dist/components/Panel/PanelActions.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +8 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +38 -17
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +1 -0
- package/dist/components/Panel/index.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/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +205 -183
- 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 +4 -1
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +8 -15
- 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/QueryViewerDialog/QueryViewerDialog.d.ts +9 -0
- package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts.map +1 -0
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js +72 -0
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -0
- package/dist/components/QueryViewerDialog/index.d.ts +2 -0
- package/dist/components/QueryViewerDialog/index.d.ts.map +1 -0
- package/dist/components/QueryViewerDialog/index.js +15 -0
- package/dist/components/QueryViewerDialog/index.js.map +1 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/Variables/ListVariableListBox.d.ts +16 -0
- package/dist/components/Variables/ListVariableListBox.d.ts.map +1 -0
- package/dist/components/Variables/ListVariableListBox.js +141 -0
- package/dist/components/Variables/ListVariableListBox.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +134 -76
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +24 -17
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/index.d.ts +1 -0
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +1 -0
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -1
- 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.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +5 -5
- 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/duplicate-panel-slice.js +2 -2
- package/dist/context/DashboardProvider/duplicate-panel-slice.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 +3 -3
- 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/PanelEditorProvider/PanelEditorProvider.d.ts +13 -0
- package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts.map +1 -0
- package/dist/context/PanelEditorProvider/PanelEditorProvider.js +33 -0
- package/dist/context/PanelEditorProvider/PanelEditorProvider.js.map +1 -0
- package/dist/context/PanelEditorProvider/index.d.ts +3 -0
- package/dist/context/PanelEditorProvider/index.d.ts.map +1 -0
- package/dist/context/PanelEditorProvider/index.js +16 -0
- package/dist/context/PanelEditorProvider/index.js.map +1 -0
- package/dist/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -0
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboard.js +5 -4
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/utils/panelUtils.d.ts +3 -0
- package/dist/utils/panelUtils.d.ts.map +1 -1
- package/dist/utils/panelUtils.js +3 -0
- package/dist/utils/panelUtils.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 +8 -8
|
@@ -31,15 +31,18 @@ _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");
|
|
34
35
|
const _components = require("@perses-dev/components");
|
|
35
36
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
36
37
|
const _reacthookform = require("react-hook-form");
|
|
37
38
|
const _zod = require("@hookform/resolvers/zod");
|
|
38
39
|
const _context = require("../../context");
|
|
40
|
+
const _PanelEditorProvider = require("../../context/PanelEditorProvider/PanelEditorProvider");
|
|
39
41
|
const _PanelPreview = require("./PanelPreview");
|
|
40
42
|
const _usePanelEditor = require("./usePanelEditor");
|
|
41
43
|
function PanelEditorForm(props) {
|
|
42
44
|
const { initialValues, initialAction, onSave, onClose } = props;
|
|
45
|
+
const pluginEditorRef = (0, _react.useRef)(null);
|
|
43
46
|
const panelGroups = (0, _context.useListPanelGroups)();
|
|
44
47
|
const { panelDefinition, setName, setDescription, setLinks, setQueries, setPlugin, setPanelDefinition } = (0, _usePanelEditor.usePanelEditor)(initialValues.panelDefinition);
|
|
45
48
|
const { plugin } = panelDefinition.spec;
|
|
@@ -50,6 +53,9 @@ function PanelEditorForm(props) {
|
|
|
50
53
|
mode: 'onBlur',
|
|
51
54
|
defaultValues: initialValues
|
|
52
55
|
});
|
|
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);
|
|
53
59
|
// Use common plugin editor logic even though we've split the inputs up in this form
|
|
54
60
|
const pluginEditor = (0, _pluginsystem.usePluginEditor)({
|
|
55
61
|
pluginTypes: [
|
|
@@ -88,9 +94,11 @@ function PanelEditorForm(props) {
|
|
|
88
94
|
setLinks,
|
|
89
95
|
links
|
|
90
96
|
]);
|
|
91
|
-
const processForm = (data)=>{
|
|
97
|
+
const processForm = (0, _react.useCallback)((data)=>{
|
|
92
98
|
onSave(data);
|
|
93
|
-
}
|
|
99
|
+
}, [
|
|
100
|
+
onSave
|
|
101
|
+
]);
|
|
94
102
|
// When user click on cancel, several possibilities:
|
|
95
103
|
// - create action: ask for discard approval
|
|
96
104
|
// - update action: ask for discard approval if changed
|
|
@@ -123,199 +131,213 @@ function PanelEditorForm(props) {
|
|
|
123
131
|
control: form.control,
|
|
124
132
|
name: 'panelDefinition.spec.plugin.kind'
|
|
125
133
|
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
const { timeRange } = (0, _pluginsystem.useTimeRangeParams)(initialTimeRange);
|
|
135
|
+
const handleSubmit = (0, _react.useCallback)(()=>{
|
|
136
|
+
pluginEditorRef.current?.flushChanges?.();
|
|
137
|
+
form.handleSubmit(processForm)();
|
|
138
|
+
}, [
|
|
139
|
+
form,
|
|
140
|
+
processForm
|
|
141
|
+
]);
|
|
142
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TimeRangeProvider, {
|
|
143
|
+
timeRange: timeRange,
|
|
144
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.FormProvider, {
|
|
145
|
+
...form,
|
|
146
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_PanelEditorProvider.PanelEditorProvider, {
|
|
136
147
|
children: [
|
|
137
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
145
|
-
direction: "row",
|
|
146
|
-
spacing: 1,
|
|
147
|
-
marginLeft: "auto",
|
|
148
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
149
|
+
sx: {
|
|
150
|
+
display: 'flex',
|
|
151
|
+
alignItems: 'center',
|
|
152
|
+
padding: (theme)=>theme.spacing(1, 2),
|
|
153
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
154
|
+
},
|
|
148
155
|
children: [
|
|
149
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
150
|
-
variant: "
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
156
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
|
|
157
|
+
variant: "h2",
|
|
158
|
+
children: [
|
|
159
|
+
titleAction,
|
|
160
|
+
" Panel"
|
|
161
|
+
]
|
|
154
162
|
}),
|
|
155
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
children:
|
|
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
|
+
]
|
|
160
181
|
})
|
|
161
182
|
]
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
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,
|
|
194
|
+
children: [
|
|
195
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
196
|
+
item: true,
|
|
197
|
+
xs: 8,
|
|
198
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
199
|
+
control: form.control,
|
|
200
|
+
name: "panelDefinition.spec.display.name",
|
|
201
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
202
|
+
...field,
|
|
203
|
+
required: true,
|
|
204
|
+
fullWidth: true,
|
|
205
|
+
label: "Name",
|
|
206
|
+
error: !!fieldState.error,
|
|
207
|
+
helperText: fieldState.error?.message,
|
|
208
|
+
value: watchedName ?? '',
|
|
209
|
+
onChange: (event)=>{
|
|
210
|
+
field.onChange(event);
|
|
211
|
+
setName(event.target.value);
|
|
212
|
+
}
|
|
213
|
+
})
|
|
194
214
|
})
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
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
|
+
})
|
|
218
238
|
})
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
+
})
|
|
238
258
|
})
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
+
})
|
|
266
286
|
})
|
|
267
|
-
})
|
|
268
|
-
}),
|
|
269
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
270
|
-
item: true,
|
|
271
|
-
xs: 12,
|
|
272
|
-
children: [
|
|
273
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
274
|
-
variant: "h4",
|
|
275
|
-
marginBottom: 1,
|
|
276
|
-
children: "Preview"
|
|
277
287
|
}),
|
|
278
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
288
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
289
|
+
item: true,
|
|
290
|
+
xs: 12,
|
|
291
|
+
children: [
|
|
292
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
293
|
+
variant: "h4",
|
|
294
|
+
marginBottom: 1,
|
|
295
|
+
children: "Preview"
|
|
296
|
+
}),
|
|
297
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
298
|
+
FallbackComponent: _components.ErrorAlert,
|
|
299
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PanelPreview.PanelPreview, {
|
|
300
|
+
panelDefinition: panelDefinition
|
|
301
|
+
})
|
|
302
|
+
})
|
|
303
|
+
]
|
|
304
|
+
}),
|
|
305
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
306
|
+
item: true,
|
|
307
|
+
xs: 12,
|
|
308
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
309
|
+
FallbackComponent: _components.ErrorAlert,
|
|
310
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PanelSpecEditor, {
|
|
311
|
+
ref: pluginEditorRef,
|
|
312
|
+
control: form.control,
|
|
313
|
+
panelDefinition: panelDefinition,
|
|
314
|
+
onJSONChange: handlePanelDefinitionChange,
|
|
315
|
+
onQueriesChange: (queries)=>{
|
|
316
|
+
setQueries(queries);
|
|
317
|
+
},
|
|
318
|
+
onPluginSpecChange: (spec)=>{
|
|
319
|
+
pluginEditor.onSpecChange(spec);
|
|
320
|
+
}
|
|
321
|
+
})
|
|
282
322
|
})
|
|
283
323
|
})
|
|
284
324
|
]
|
|
285
|
-
}),
|
|
286
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
287
|
-
item: true,
|
|
288
|
-
xs: 12,
|
|
289
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
290
|
-
FallbackComponent: _components.ErrorAlert,
|
|
291
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PanelSpecEditor, {
|
|
292
|
-
control: form.control,
|
|
293
|
-
panelDefinition: panelDefinition,
|
|
294
|
-
onJSONChange: handlePanelDefinitionChange,
|
|
295
|
-
onQueriesChange: (queries)=>{
|
|
296
|
-
setQueries(queries);
|
|
297
|
-
},
|
|
298
|
-
onPluginSpecChange: (spec)=>{
|
|
299
|
-
pluginEditor.onSpecChange(spec);
|
|
300
|
-
}
|
|
301
|
-
})
|
|
302
|
-
})
|
|
303
325
|
})
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
326
|
+
}),
|
|
327
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.DiscardChangesConfirmationDialog, {
|
|
328
|
+
description: "You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.",
|
|
329
|
+
isOpen: isDiscardDialogOpened,
|
|
330
|
+
onCancel: ()=>{
|
|
331
|
+
setDiscardDialogOpened(false);
|
|
332
|
+
},
|
|
333
|
+
onDiscardChanges: ()=>{
|
|
334
|
+
setDiscardDialogOpened(false);
|
|
335
|
+
onClose();
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
]
|
|
317
339
|
})
|
|
318
|
-
|
|
340
|
+
})
|
|
319
341
|
});
|
|
320
342
|
}
|
|
321
343
|
const panelEditorFormId = 'panel-editor-form';
|
|
@@ -25,13 +25,16 @@ const _react = require("react");
|
|
|
25
25
|
const _material = require("@mui/material");
|
|
26
26
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
27
27
|
const _Panel = require("../Panel");
|
|
28
|
+
const _context = require("../../context");
|
|
28
29
|
const PANEL_PREVIEW_HEIGHT = 300;
|
|
29
30
|
const PANEL_PREVIEW_DEFAULT_WIDTH = 840;
|
|
30
31
|
function PanelPreview({ panelDefinition }) {
|
|
31
32
|
const boxRef = (0, _react.useRef)(null);
|
|
32
33
|
let width = PANEL_PREVIEW_DEFAULT_WIDTH;
|
|
34
|
+
const panelEditorContext = (0, _react.useContext)(_context.PanelEditorContext);
|
|
33
35
|
if (boxRef.current !== null) {
|
|
34
36
|
width = boxRef.current.getBoundingClientRect().width;
|
|
37
|
+
panelEditorContext?.preview?.setPreviewPanelWidth?.(width);
|
|
35
38
|
}
|
|
36
39
|
const suggestedStepMs = (0, _pluginsystem.useSuggestedStepMs)(width);
|
|
37
40
|
const { data: plugin, isLoading } = (0, _pluginsystem.usePlugin)('Panel', panelDefinition.spec.plugin.kind);
|
|
@@ -21,18 +21,15 @@ Object.defineProperty(exports, "PanelGroupDialog", {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _material = require("@mui/material");
|
|
25
|
-
const _Close = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Close"));
|
|
26
24
|
const _react = require("react");
|
|
25
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
26
|
+
const _components = require("@perses-dev/components");
|
|
27
|
+
const _material = require("@mui/material");
|
|
27
28
|
const _context = require("../../context");
|
|
28
29
|
const _PanelGroupEditorForm = require("./PanelGroupEditorForm");
|
|
29
|
-
function _interop_require_default(obj) {
|
|
30
|
-
return obj && obj.__esModule ? obj : {
|
|
31
|
-
default: obj
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
30
|
function PanelGroupDialog() {
|
|
35
31
|
const panelGroupEditor = (0, _context.usePanelGroupEditor)();
|
|
32
|
+
const variables = (0, _pluginsystem.useVariableValues)();
|
|
36
33
|
// When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
|
|
37
34
|
const [isClosing, setIsClosing] = (0, _react.useState)(false);
|
|
38
35
|
const handleClose = ()=>setIsClosing(true);
|
|
@@ -51,40 +48,31 @@ function PanelGroupDialog() {
|
|
|
51
48
|
panelGroupEditor.applyChanges(values);
|
|
52
49
|
handleClose();
|
|
53
50
|
};
|
|
54
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
51
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog, {
|
|
55
52
|
open: isOpen,
|
|
56
53
|
TransitionProps: {
|
|
57
54
|
onExited: handleExited
|
|
58
55
|
},
|
|
59
56
|
children: panelGroupEditor !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
60
57
|
children: [
|
|
61
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(
|
|
58
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.Dialog.Header, {
|
|
62
59
|
children: [
|
|
63
60
|
panelGroupEditor.mode,
|
|
64
61
|
" Panel Group"
|
|
65
62
|
]
|
|
66
63
|
}),
|
|
67
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
68
|
-
"aria-label": "Close",
|
|
69
|
-
onClick: panelGroupEditor.close,
|
|
70
|
-
sx: (theme)=>({
|
|
71
|
-
position: 'absolute',
|
|
72
|
-
top: theme.spacing(0.5),
|
|
73
|
-
right: theme.spacing(0.5)
|
|
74
|
-
}),
|
|
75
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Close.default, {})
|
|
76
|
-
}),
|
|
77
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.DialogContent, {
|
|
64
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.Content, {
|
|
78
65
|
dividers: true,
|
|
79
66
|
sx: {
|
|
80
67
|
width: '500px'
|
|
81
68
|
},
|
|
82
69
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PanelGroupEditorForm.PanelGroupEditorForm, {
|
|
83
70
|
initialValues: panelGroupEditor.initialValues,
|
|
71
|
+
variables: Object.keys(variables),
|
|
84
72
|
onSubmit: handleSubmit
|
|
85
73
|
})
|
|
86
74
|
}),
|
|
87
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(
|
|
75
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.Dialog.Actions, {
|
|
88
76
|
children: [
|
|
89
77
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
90
78
|
variant: "contained",
|
|
@@ -32,18 +32,16 @@ const _jsxruntime = require("react/jsx-runtime");
|
|
|
32
32
|
const _react = require("react");
|
|
33
33
|
const _material = require("@mui/material");
|
|
34
34
|
function PanelGroupEditorForm(props) {
|
|
35
|
-
const { initialValues, onSubmit } = props;
|
|
35
|
+
const { initialValues, variables, onSubmit } = props;
|
|
36
36
|
const [title, setTitle] = (0, _react.useState)(initialValues.title);
|
|
37
37
|
const [isCollapsed, setIsCollapsed] = (0, _react.useState)(initialValues.isCollapsed);
|
|
38
|
-
const
|
|
39
|
-
const next = e.target.value;
|
|
40
|
-
setIsCollapsed(next === 'Closed');
|
|
41
|
-
};
|
|
38
|
+
const [repeatVariable, setRepeatVariable] = (0, _react.useState)(initialValues.repeatVariable);
|
|
42
39
|
const handleSubmit = (e)=>{
|
|
43
40
|
e.preventDefault();
|
|
44
41
|
onSubmit({
|
|
45
42
|
title,
|
|
46
|
-
isCollapsed
|
|
43
|
+
isCollapsed,
|
|
44
|
+
repeatVariable
|
|
47
45
|
});
|
|
48
46
|
};
|
|
49
47
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("form", {
|
|
@@ -58,25 +56,21 @@ function PanelGroupEditorForm(props) {
|
|
|
58
56
|
label: "Name",
|
|
59
57
|
variant: "outlined",
|
|
60
58
|
value: title,
|
|
61
|
-
onChange: (e)=>setTitle(e.target.value)
|
|
59
|
+
onChange: (e)=>setTitle(e.target.value),
|
|
60
|
+
"data-testid": "panel-group-editor-name"
|
|
62
61
|
})
|
|
63
62
|
}),
|
|
64
63
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.FormControl, {
|
|
65
64
|
fullWidth: true,
|
|
66
65
|
margin: "normal",
|
|
67
66
|
children: [
|
|
68
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
69
|
-
|
|
70
|
-
children: "Collapse State"
|
|
71
|
-
}),
|
|
72
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Select, {
|
|
67
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
68
|
+
select: true,
|
|
73
69
|
required: true,
|
|
74
|
-
displayEmpty: true,
|
|
75
|
-
labelId: "select-collapse-state",
|
|
76
70
|
label: "Collapse State",
|
|
77
71
|
size: "small",
|
|
78
72
|
value: isCollapsed ? 'Closed' : 'Open',
|
|
79
|
-
onChange:
|
|
73
|
+
onChange: (e)=>setIsCollapsed(e.target.value === 'Closed'),
|
|
80
74
|
children: [
|
|
81
75
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
82
76
|
value: "Open",
|
|
@@ -87,6 +81,32 @@ function PanelGroupEditorForm(props) {
|
|
|
87
81
|
children: "Closed"
|
|
88
82
|
})
|
|
89
83
|
]
|
|
84
|
+
}),
|
|
85
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControl, {
|
|
86
|
+
fullWidth: true,
|
|
87
|
+
margin: "normal",
|
|
88
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
89
|
+
select: true,
|
|
90
|
+
label: "Repeat Variable",
|
|
91
|
+
variant: "outlined",
|
|
92
|
+
value: repeatVariable ?? '',
|
|
93
|
+
onChange: (e)=>setRepeatVariable(e.target.value === '' ? undefined : e.target.value),
|
|
94
|
+
children: [
|
|
95
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
96
|
+
value: "",
|
|
97
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
98
|
+
sx: {
|
|
99
|
+
fontStyle: 'italic'
|
|
100
|
+
},
|
|
101
|
+
children: "None"
|
|
102
|
+
})
|
|
103
|
+
}),
|
|
104
|
+
variables?.sort((a, b)=>a.localeCompare(b)).map((variable)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
105
|
+
value: variable,
|
|
106
|
+
children: variable
|
|
107
|
+
}, variable))
|
|
108
|
+
]
|
|
109
|
+
})
|
|
90
110
|
})
|
|
91
111
|
]
|
|
92
112
|
})
|