@perses-dev/dashboards 0.8.1 → 0.10.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/Dashboard.js +25 -14
- package/dist/cjs/components/DashboardToolbar.js +148 -20
- package/dist/cjs/components/GridLayout/GridItemContent.js +25 -19
- package/dist/cjs/components/GridLayout/GridLayout.js +92 -27
- package/dist/cjs/components/GridLayout/GridTitle.js +91 -31
- package/dist/cjs/components/GridLayout/index.js +18 -19
- package/dist/cjs/components/Panel/DeletePanelDialog.js +91 -0
- package/dist/cjs/components/Panel/Panel.js +156 -55
- package/dist/cjs/components/Panel/Panel.test.js +58 -41
- package/dist/cjs/components/Panel/PanelContent.js +41 -12
- package/dist/cjs/components/Panel/index.js +16 -17
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +84 -108
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +87 -92
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +194 -0
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +48 -0
- package/dist/cjs/components/PanelDrawer/index.js +28 -0
- package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +86 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +121 -39
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +74 -88
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +120 -38
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +42 -27
- package/dist/cjs/components/TimeRangeControls/index.js +16 -17
- package/dist/cjs/components/Variables/Variable.js +195 -36
- package/dist/cjs/components/Variables/VariableEditor.js +207 -0
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +236 -0
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +88 -0
- package/dist/cjs/components/Variables/VariableList.js +81 -13
- package/dist/cjs/components/Variables/index.js +18 -18
- package/dist/cjs/components/index.js +21 -21
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +70 -0
- package/dist/cjs/context/DashboardProvider/common.js +18 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +71 -0
- package/dist/cjs/context/DashboardProvider/index.js +29 -0
- package/dist/cjs/context/DashboardProvider/layout-slice.js +200 -0
- package/dist/cjs/context/DashboardProvider/panel-editing-slice.js +156 -0
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +38 -0
- package/dist/cjs/context/DatasourceStoreProvider.js +170 -0
- package/dist/cjs/context/QueryStringProvider.js +69 -15
- package/dist/cjs/context/TemplateVariableProvider.js +135 -136
- package/dist/cjs/context/TimeRangeProvider.js +79 -30
- package/dist/cjs/context/index.js +20 -22
- package/dist/cjs/css/styles.js +43 -39
- package/dist/cjs/index.js +19 -20
- package/dist/cjs/test/dashboard-provider.js +51 -0
- package/dist/cjs/test/index.js +18 -18
- package/dist/cjs/test/plugin-registry.js +52 -25
- package/dist/cjs/test/render.js +25 -22
- package/dist/cjs/test/setup-tests.js +4 -2
- package/dist/cjs/test/testDashboard.js +203 -107
- package/dist/cjs/utils/functions.js +9 -5
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +49 -23
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +62 -31
- package/dist/cjs/views/ViewDashboard/index.js +16 -17
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +165 -0
- package/dist/cjs/views/index.js +16 -17
- package/dist/components/Dashboard.d.ts +1 -4
- package/dist/components/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard.js +34 -1
- package/dist/components/Dashboard.js.map +1 -0
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +154 -1
- package/dist/components/DashboardToolbar.js.map +1 -0
- package/dist/components/GridLayout/GridItemContent.d.ts +3 -3
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +35 -1
- package/dist/components/GridLayout/GridItemContent.js.map +1 -0
- package/dist/components/GridLayout/GridLayout.d.ts +2 -3
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +102 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -0
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +99 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -0
- package/dist/components/GridLayout/index.js +16 -1
- package/dist/components/GridLayout/index.js.map +1 -0
- package/dist/components/Panel/DeletePanelDialog.d.ts +5 -0
- package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -0
- package/dist/components/Panel/DeletePanelDialog.js +80 -0
- package/dist/components/Panel/DeletePanelDialog.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +1 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +181 -1
- package/dist/components/Panel/Panel.js.map +1 -0
- package/dist/components/Panel/Panel.test.js +74 -1
- package/dist/components/Panel/Panel.test.js.map +1 -0
- package/dist/components/Panel/PanelContent.d.ts +5 -4
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +41 -1
- package/dist/components/Panel/PanelContent.js.map +1 -0
- package/dist/components/Panel/index.js +15 -1
- package/dist/components/Panel/index.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.d.ts +4 -2
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +96 -1
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.js +99 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +12 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js +184 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -0
- package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelPreview.js +42 -0
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
- package/dist/components/PanelDrawer/index.d.ts +2 -0
- package/dist/components/PanelDrawer/index.d.ts.map +1 -0
- package/dist/components/PanelDrawer/index.js +15 -0
- package/dist/components/PanelDrawer/index.js.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +4 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +75 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +131 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +74 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +137 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +59 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -0
- package/dist/components/TimeRangeControls/index.js +15 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +210 -1
- package/dist/components/Variables/Variable.js.map +1 -0
- package/dist/components/Variables/VariableEditor.d.ts +8 -0
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditor.js +196 -0
- package/dist/components/Variables/VariableEditor.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +225 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.js +15 -0
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +21 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +76 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +84 -1
- package/dist/components/Variables/VariableList.js.map +1 -0
- 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 +17 -1
- package/dist/components/Variables/index.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +20 -1
- package/dist/components/index.js.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +23 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.js +52 -0
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
- package/dist/context/DashboardProvider/common.d.ts +5 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -0
- package/dist/context/DashboardProvider/common.js +17 -0
- package/dist/context/DashboardProvider/common.js.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +32 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js +56 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +3 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -0
- package/dist/context/DashboardProvider/index.js +16 -0
- package/dist/context/DashboardProvider/index.js.map +1 -0
- package/dist/context/DashboardProvider/layout-slice.d.ts +57 -0
- package/dist/context/DashboardProvider/layout-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/layout-slice.js +196 -0
- package/dist/context/DashboardProvider/layout-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts +70 -0
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-editing-slice.js +152 -0
- package/dist/context/DashboardProvider/panel-editing-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +15 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.js +32 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
- package/dist/context/DatasourceStoreProvider.d.ts +24 -0
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -0
- package/dist/context/DatasourceStoreProvider.js +166 -0
- package/dist/context/DatasourceStoreProvider.js.map +1 -0
- package/dist/context/QueryStringProvider.js +40 -1
- package/dist/context/QueryStringProvider.js.map +1 -0
- package/dist/context/TemplateVariableProvider.d.ts +8 -3
- package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider.js +199 -1
- package/dist/context/TemplateVariableProvider.js.map +1 -0
- package/dist/context/TimeRangeProvider.js +72 -1
- package/dist/context/TimeRangeProvider.js.map +1 -0
- package/dist/context/index.d.ts +3 -4
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +19 -1
- package/dist/context/index.js.map +1 -0
- package/dist/css/styles.js +186 -1
- package/dist/css/styles.js.map +1 -0
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -0
- package/dist/test/dashboard-provider.d.ts +19 -0
- package/dist/test/dashboard-provider.d.ts.map +1 -0
- package/dist/test/dashboard-provider.js +40 -0
- package/dist/test/dashboard-provider.js.map +1 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +17 -1
- package/dist/test/index.js.map +1 -0
- package/dist/test/plugin-registry.d.ts +3 -4
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +74 -1
- package/dist/test/plugin-registry.js.map +1 -0
- package/dist/test/render.d.ts +1 -2
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +34 -1
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.js +18 -1
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +286 -1
- package/dist/test/testDashboard.js.map +1 -0
- package/dist/utils/functions.js +17 -1
- package/dist/utils/functions.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +55 -1
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +79 -1
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -0
- package/dist/views/ViewDashboard/index.js +15 -1
- package/dist/views/ViewDashboard/index.js.map +1 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +158 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
- package/dist/views/index.js +15 -1
- package/dist/views/index.js.map +1 -0
- package/package.json +13 -7
- package/dist/cjs/components/PanelDrawer/PanelOptionsEditor.js +0 -19
- package/dist/cjs/context/DashboardAppSlice.js +0 -45
- package/dist/cjs/context/DashboardProvider.js +0 -98
- package/dist/cjs/context/LayoutsSlice.js +0 -42
- package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts +0 -9
- package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelOptionsEditor.js +0 -1
- package/dist/context/DashboardAppSlice.d.ts +0 -26
- package/dist/context/DashboardAppSlice.d.ts.map +0 -1
- package/dist/context/DashboardAppSlice.js +0 -1
- package/dist/context/DashboardProvider.d.ts +0 -34
- package/dist/context/DashboardProvider.d.ts.map +0 -1
- package/dist/context/DashboardProvider.js +0 -1
- package/dist/context/LayoutsSlice.d.ts +0 -12
- package/dist/context/LayoutsSlice.d.ts.map +0 -1
- package/dist/context/LayoutsSlice.js +0 -1
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
1
|
// Copyright 2022 The Perses Authors
|
|
5
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -13,112 +10,91 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
13
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
11
|
// See the License for the specific language governing permissions and
|
|
15
12
|
// limitations under the License.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const [options, setOptions] = (0, react_1.useState)({});
|
|
40
|
-
// TO DO: we might want to make the form a sub component we don't need this useEffect
|
|
41
|
-
// currently, we need to reset the states whenever panelDrawer is reopened
|
|
42
|
-
// since this component does not get remounted when it open/closes (otherwise we lose the animation of sliding in/out)
|
|
43
|
-
(0, react_1.useEffect)(() => {
|
|
44
|
-
var _a, _b, _c, _d;
|
|
45
|
-
setGroup(panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.groupIndex);
|
|
46
|
-
if (panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.panelKey) {
|
|
47
|
-
// display panel name and description in text fields when editing an existing panel
|
|
48
|
-
setPanelName((_b = (_a = panels[panelDrawer.panelKey]) === null || _a === void 0 ? void 0 : _a.display.name) !== null && _b !== void 0 ? _b : '');
|
|
49
|
-
setPanelDescription((_d = (_c = panels[panelDrawer.panelKey]) === null || _c === void 0 ? void 0 : _c.display.description) !== null && _d !== void 0 ? _d : '');
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
setPanelName('');
|
|
53
|
-
setPanelDescription('');
|
|
54
|
-
}
|
|
55
|
-
}, [panelDrawer, panels]);
|
|
56
|
-
const handleGroupChange = (e) => {
|
|
57
|
-
const { value } = e.target;
|
|
58
|
-
// Handle string (which would be empty string but shouldn't happen since we don't allow a "None" option) by
|
|
59
|
-
// just ignoring it
|
|
60
|
-
if (typeof value === 'string')
|
|
61
|
-
return;
|
|
62
|
-
setGroup(value);
|
|
63
|
-
};
|
|
64
|
-
const handlePanelNameChange = (e) => {
|
|
65
|
-
setPanelName(e.target.value);
|
|
66
|
-
};
|
|
67
|
-
const handlePanelDescriptionChange = (e) => {
|
|
68
|
-
setPanelDescription(e.target.value);
|
|
69
|
-
};
|
|
70
|
-
const handleKindChange = (e) => {
|
|
71
|
-
setKind(e.target.value);
|
|
72
|
-
};
|
|
73
|
-
const handleOptionsChange = (next) => {
|
|
74
|
-
setOptions(next);
|
|
75
|
-
};
|
|
76
|
-
const handleSubmit = (e) => {
|
|
77
|
-
e.preventDefault();
|
|
78
|
-
if ((panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.groupIndex) !== undefined && !(panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.panelKey)) {
|
|
79
|
-
addNewPanel();
|
|
80
|
-
}
|
|
81
|
-
else if (panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.panelKey) {
|
|
82
|
-
editPanel();
|
|
83
|
-
}
|
|
84
|
-
closePanelDrawer();
|
|
85
|
-
};
|
|
86
|
-
const addNewPanel = () => {
|
|
87
|
-
if ((panelDrawer === null || panelDrawer === void 0 ? void 0 : panelDrawer.groupIndex) === undefined) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const panelKey = (0, functions_1.removeWhiteSpacesAndSpecialCharacters)(panelName);
|
|
91
|
-
updatePanel(panelKey, {
|
|
92
|
-
kind,
|
|
93
|
-
options,
|
|
94
|
-
display: { name: panelName, description: panelDescription },
|
|
95
|
-
}, panelDrawer.groupIndex);
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "PanelDrawer", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>PanelDrawer
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _components = require("@perses-dev/components");
|
|
25
|
+
const _context = require("../../context");
|
|
26
|
+
const _panelEditorForm = require("./PanelEditorForm");
|
|
27
|
+
const PanelDrawer = ()=>{
|
|
28
|
+
const { panelEditor } = (0, _context.usePanels)();
|
|
29
|
+
// When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
|
|
30
|
+
const [isClosing, setIsClosing] = (0, _react.useState)(false);
|
|
31
|
+
const handleClose = ()=>setIsClosing(true);
|
|
32
|
+
// Don't call closeDrawer on the store until the Drawer has completely transitioned out
|
|
33
|
+
const handleExited = ()=>{
|
|
34
|
+
panelEditor === null || panelEditor === void 0 ? void 0 : panelEditor.close();
|
|
35
|
+
setIsClosing(false);
|
|
96
36
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
37
|
+
// Drawer is open if we have a model and we're not transitioning out
|
|
38
|
+
const isOpen = panelEditor !== undefined && isClosing === false;
|
|
39
|
+
const handleSubmit = (values)=>{
|
|
40
|
+
// This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy
|
|
41
|
+
if (panelEditor === undefined) {
|
|
42
|
+
throw new Error('Cannot apply changes');
|
|
100
43
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
kind,
|
|
104
|
-
options,
|
|
105
|
-
display: { name: panelName !== null && panelName !== void 0 ? panelName : '', description: panelDescription },
|
|
106
|
-
});
|
|
107
|
-
// TO DO: need to move panel if panel group changes
|
|
44
|
+
panelEditor.applyChanges(values);
|
|
45
|
+
handleClose();
|
|
108
46
|
};
|
|
109
|
-
return (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
47
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Drawer, {
|
|
48
|
+
isOpen: isOpen,
|
|
49
|
+
onClose: handleClose,
|
|
50
|
+
SlideProps: {
|
|
51
|
+
onExited: handleExited
|
|
52
|
+
},
|
|
53
|
+
children: panelEditor !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
54
|
+
children: [
|
|
55
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
56
|
+
sx: {
|
|
57
|
+
display: 'flex',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
marginBottom: (theme)=>theme.spacing(2),
|
|
60
|
+
paddingBottom: (theme)=>theme.spacing(2),
|
|
61
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.grey[100]}`
|
|
62
|
+
},
|
|
63
|
+
children: [
|
|
64
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
65
|
+
variant: "h2",
|
|
66
|
+
children: [
|
|
67
|
+
panelEditor.mode,
|
|
68
|
+
" Panel"
|
|
69
|
+
]
|
|
70
|
+
}),
|
|
71
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
72
|
+
direction: "row",
|
|
73
|
+
spacing: 1,
|
|
74
|
+
sx: {
|
|
75
|
+
marginLeft: 'auto'
|
|
76
|
+
},
|
|
77
|
+
children: [
|
|
78
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
79
|
+
type: "submit",
|
|
80
|
+
variant: "contained",
|
|
81
|
+
form: _panelEditorForm.panelEditorFormId,
|
|
82
|
+
children: panelEditor.mode === 'Add' ? 'Add' : 'Apply'
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
85
|
+
variant: "outlined",
|
|
86
|
+
onClick: handleClose,
|
|
87
|
+
children: "Cancel"
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelEditorForm.PanelEditorForm, {
|
|
94
|
+
onSubmit: handleSubmit,
|
|
95
|
+
initialValues: panelEditor.initialValues
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
})
|
|
99
|
+
});
|
|
123
100
|
};
|
|
124
|
-
exports.default = PanelDrawer;
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
30
1
|
// Copyright 2022 The Perses Authors
|
|
31
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
32
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -39,73 +10,97 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
39
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
40
11
|
// See the License for the specific language governing permissions and
|
|
41
12
|
// limitations under the License.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const dashboardAppSlice = __importStar(require("../../context/DashboardAppSlice"));
|
|
46
|
-
const layoutsSlice = __importStar(require("../../context/LayoutsSlice"));
|
|
47
|
-
const context = __importStar(require("../../context/DashboardProvider"));
|
|
48
|
-
const test_1 = require("../../test");
|
|
49
|
-
const testDashboard_1 = __importDefault(require("../../test/testDashboard"));
|
|
50
|
-
const PanelDrawer_1 = __importDefault(require("./PanelDrawer"));
|
|
51
|
-
const updatePanel = jest.fn();
|
|
52
|
-
jest.spyOn(context, 'usePanels').mockReturnValue({
|
|
53
|
-
updatePanel,
|
|
54
|
-
panels: {},
|
|
55
|
-
});
|
|
56
|
-
const addItemToLayout = jest.fn();
|
|
57
|
-
jest.spyOn(layoutsSlice, 'useLayouts').mockReturnValue({
|
|
58
|
-
addItemToLayout,
|
|
59
|
-
updateLayout: jest.fn(),
|
|
60
|
-
layouts: testDashboard_1.default.spec.layouts,
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
61
16
|
});
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const renderPanelDrawer = ()
|
|
77
|
-
const { addMockPlugin, pluginRegistryProps
|
|
78
|
-
addMockPlugin('Panel', '
|
|
79
|
-
|
|
17
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
19
|
+
const _react = require("@testing-library/react");
|
|
20
|
+
const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
|
|
21
|
+
const _testUtils = require("react-dom/test-utils");
|
|
22
|
+
const _test = require("../../test");
|
|
23
|
+
const _dashboardProvider = require("../../context/DashboardProvider");
|
|
24
|
+
const _panelDrawer = require("./PanelDrawer");
|
|
25
|
+
function _interopRequireDefault(obj) {
|
|
26
|
+
return obj && obj.__esModule ? obj : {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
describe('Panel Drawer', ()=>{
|
|
31
|
+
const renderPanelDrawer = ()=>{
|
|
32
|
+
const { addMockPlugin , pluginRegistryProps } = (0, _test.mockPluginRegistryProps)();
|
|
33
|
+
addMockPlugin('Panel', 'TimeSeriesChart', _test.FAKE_PANEL_PLUGIN);
|
|
34
|
+
const { store , DashboardProviderSpy } = (0, _test.createDashboardProviderSpy)();
|
|
35
|
+
(0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
|
|
36
|
+
...pluginRegistryProps,
|
|
37
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_dashboardProvider.DashboardProvider, {
|
|
38
|
+
initialState: {
|
|
39
|
+
dashboardSpec: (0, _test.getTestDashboard)().spec,
|
|
40
|
+
isEditMode: true
|
|
41
|
+
},
|
|
42
|
+
children: [
|
|
43
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardProviderSpy, {}),
|
|
44
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelDrawer.PanelDrawer, {})
|
|
45
|
+
]
|
|
46
|
+
})
|
|
47
|
+
}));
|
|
48
|
+
const { value: storeApi } = store;
|
|
49
|
+
if (storeApi === undefined) {
|
|
50
|
+
throw new Error('Expected dashboard store to be set after initial render');
|
|
51
|
+
}
|
|
52
|
+
return storeApi;
|
|
80
53
|
};
|
|
81
|
-
it('should add new panel', ()
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
54
|
+
it('should add new panel', async ()=>{
|
|
55
|
+
const storeApi = renderPanelDrawer();
|
|
56
|
+
// Open the drawer for a new panel (i.e. no panel key)
|
|
57
|
+
(0, _testUtils.act)(()=>storeApi.getState().addPanel(0));
|
|
58
|
+
const nameInput = await _react.screen.findByLabelText(/Name/);
|
|
59
|
+
_userEvent.default.type(nameInput, 'New Panel');
|
|
60
|
+
_userEvent.default.click(_react.screen.getByText('Add'));
|
|
61
|
+
// TODO: Assert drawer is closed?
|
|
62
|
+
const panels = storeApi.getState().panels;
|
|
63
|
+
expect(panels).toMatchObject({
|
|
64
|
+
// Should have the new panel in the store
|
|
65
|
+
NewPanel: {
|
|
66
|
+
kind: 'Panel',
|
|
67
|
+
spec: {
|
|
68
|
+
display: {
|
|
69
|
+
name: 'New Panel'
|
|
70
|
+
},
|
|
71
|
+
plugin: {
|
|
72
|
+
kind: '',
|
|
73
|
+
spec: {}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
92
78
|
});
|
|
93
|
-
it('should edit an existing panel', ()
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
79
|
+
it('should edit an existing panel', async ()=>{
|
|
80
|
+
const storeApi = renderPanelDrawer();
|
|
81
|
+
// Open the drawer for an existing panel
|
|
82
|
+
(0, _testUtils.act)(()=>storeApi.getState().editPanel({
|
|
97
83
|
groupIndex: 0,
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
expect(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
84
|
+
itemIndex: 0
|
|
85
|
+
}));
|
|
86
|
+
const nameInput = await _react.screen.findByLabelText(/Name/);
|
|
87
|
+
_userEvent.default.clear(nameInput);
|
|
88
|
+
_userEvent.default.type(nameInput, 'cpu usage');
|
|
89
|
+
_userEvent.default.click(_react.screen.getByText('Apply'));
|
|
90
|
+
const panels = storeApi.getState().panels;
|
|
91
|
+
expect(panels).toMatchObject({
|
|
92
|
+
cpu: {
|
|
93
|
+
kind: 'Panel',
|
|
94
|
+
spec: {
|
|
95
|
+
display: {
|
|
96
|
+
name: 'cpu usage'
|
|
97
|
+
},
|
|
98
|
+
plugin: {
|
|
99
|
+
kind: 'TimeSeriesChart',
|
|
100
|
+
spec: {}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
109
104
|
});
|
|
110
105
|
});
|
|
111
106
|
});
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
PanelEditorForm: ()=>PanelEditorForm,
|
|
25
|
+
panelEditorFormId: ()=>panelEditorFormId
|
|
26
|
+
});
|
|
27
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
+
const _react = require("react");
|
|
29
|
+
const _material = require("@mui/material");
|
|
30
|
+
const _components = require("@perses-dev/components");
|
|
31
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
32
|
+
const _context = require("../../context");
|
|
33
|
+
const _panelPreview = require("./PanelPreview");
|
|
34
|
+
function PanelEditorForm(props) {
|
|
35
|
+
var ref;
|
|
36
|
+
const { initialValues , onSubmit } = props;
|
|
37
|
+
const { layouts } = (0, _context.useLayouts)();
|
|
38
|
+
const [name, setName] = (0, _react.useState)(initialValues.name);
|
|
39
|
+
const [description, setDescription] = (0, _react.useState)(initialValues.description);
|
|
40
|
+
const [groupIndex, setGroupIndex] = (0, _react.useState)(initialValues.groupIndex);
|
|
41
|
+
const [kind, setKind] = (0, _react.useState)(initialValues.kind);
|
|
42
|
+
const [spec, setSpec] = (0, _react.useState)(initialValues.spec);
|
|
43
|
+
// Use common plugin editor logic even though we've split the inputs up in this form
|
|
44
|
+
const pluginEditor = (0, _pluginSystem.usePluginEditor)({
|
|
45
|
+
pluginType: 'Panel',
|
|
46
|
+
value: {
|
|
47
|
+
kind,
|
|
48
|
+
spec
|
|
49
|
+
},
|
|
50
|
+
onChange: (plugin)=>{
|
|
51
|
+
setKind(plugin.kind);
|
|
52
|
+
setSpec(plugin.spec);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// Ignore string values (which would be an "empty" value from the Select) since we don't allow them to unset it
|
|
56
|
+
const handleGroupChange = (e)=>{
|
|
57
|
+
const { value } = e.target;
|
|
58
|
+
if (typeof value === 'string') {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setGroupIndex(value);
|
|
62
|
+
};
|
|
63
|
+
const handleSubmit = (e)=>{
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
if (spec === undefined) {
|
|
66
|
+
throw new Error('Cannot submit without a plugin spec');
|
|
67
|
+
}
|
|
68
|
+
const values = {
|
|
69
|
+
name,
|
|
70
|
+
description,
|
|
71
|
+
groupIndex,
|
|
72
|
+
kind,
|
|
73
|
+
spec
|
|
74
|
+
};
|
|
75
|
+
onSubmit(values);
|
|
76
|
+
};
|
|
77
|
+
var _title, ref1;
|
|
78
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("form", {
|
|
79
|
+
id: panelEditorFormId,
|
|
80
|
+
onSubmit: handleSubmit,
|
|
81
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
82
|
+
container: true,
|
|
83
|
+
spacing: 2,
|
|
84
|
+
children: [
|
|
85
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
86
|
+
item: true,
|
|
87
|
+
xs: 8,
|
|
88
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
89
|
+
required: true,
|
|
90
|
+
label: "Name",
|
|
91
|
+
value: name,
|
|
92
|
+
variant: "outlined",
|
|
93
|
+
onChange: (e)=>setName(e.target.value)
|
|
94
|
+
})
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
97
|
+
item: true,
|
|
98
|
+
xs: 4,
|
|
99
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
100
|
+
children: [
|
|
101
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
102
|
+
id: "select-group",
|
|
103
|
+
children: "Group"
|
|
104
|
+
}),
|
|
105
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Select, {
|
|
106
|
+
required: true,
|
|
107
|
+
labelId: "select-group",
|
|
108
|
+
label: "Group",
|
|
109
|
+
value: groupIndex !== null && groupIndex !== void 0 ? groupIndex : 0,
|
|
110
|
+
onChange: handleGroupChange,
|
|
111
|
+
children: layouts.map((layout, index)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
112
|
+
value: index,
|
|
113
|
+
children: (_title = layout.title) !== null && _title !== void 0 ? _title : `Group ${index + 1}`
|
|
114
|
+
}, index))
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
})
|
|
118
|
+
}),
|
|
119
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
120
|
+
item: true,
|
|
121
|
+
xs: 8,
|
|
122
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
123
|
+
label: "Description",
|
|
124
|
+
value: description,
|
|
125
|
+
variant: "outlined",
|
|
126
|
+
onChange: (e)=>setDescription(e.target.value)
|
|
127
|
+
})
|
|
128
|
+
}),
|
|
129
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
130
|
+
item: true,
|
|
131
|
+
xs: 4,
|
|
132
|
+
children: [
|
|
133
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
134
|
+
disabled: pluginEditor.isLoading,
|
|
135
|
+
error: pluginEditor.error !== null,
|
|
136
|
+
children: [
|
|
137
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
138
|
+
id: "panel-type-label",
|
|
139
|
+
children: "Type"
|
|
140
|
+
}),
|
|
141
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginKindSelect, {
|
|
142
|
+
pluginType: "Panel",
|
|
143
|
+
required: true,
|
|
144
|
+
labelId: "panel-type-label",
|
|
145
|
+
label: "Type",
|
|
146
|
+
value: pluginEditor.pendingKind ? pluginEditor.pendingKind : kind,
|
|
147
|
+
onChange: pluginEditor.onKindChange
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
}),
|
|
151
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormHelperText, {
|
|
152
|
+
children: (ref1 = (ref = pluginEditor.error) === null || ref === void 0 ? void 0 : ref.message) !== null && ref1 !== void 0 ? ref1 : ''
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
}),
|
|
156
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
157
|
+
item: true,
|
|
158
|
+
xs: 12,
|
|
159
|
+
children: [
|
|
160
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
161
|
+
variant: "h4",
|
|
162
|
+
marginBottom: 1,
|
|
163
|
+
children: "Preview"
|
|
164
|
+
}),
|
|
165
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
166
|
+
FallbackComponent: _components.ErrorAlert,
|
|
167
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelPreview.PanelPreview, {
|
|
168
|
+
kind: kind,
|
|
169
|
+
name: name,
|
|
170
|
+
description: description,
|
|
171
|
+
spec: spec,
|
|
172
|
+
groupIndex: groupIndex
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
]
|
|
176
|
+
}),
|
|
177
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
178
|
+
item: true,
|
|
179
|
+
xs: 12,
|
|
180
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
181
|
+
FallbackComponent: _components.ErrorAlert,
|
|
182
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginSpecEditor, {
|
|
183
|
+
pluginType: "Panel",
|
|
184
|
+
pluginKind: kind,
|
|
185
|
+
value: spec,
|
|
186
|
+
onChange: pluginEditor.onSpecChange
|
|
187
|
+
})
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const panelEditorFormId = 'panel-editor-form';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright 2022 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, "PanelPreview", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>PanelPreview
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _panel = require("../Panel");
|
|
24
|
+
function PanelPreview({ name , description , kind , spec , groupIndex }) {
|
|
25
|
+
const previewValues = {
|
|
26
|
+
definition: {
|
|
27
|
+
kind: 'Panel',
|
|
28
|
+
spec: {
|
|
29
|
+
display: {
|
|
30
|
+
name,
|
|
31
|
+
description
|
|
32
|
+
},
|
|
33
|
+
plugin: {
|
|
34
|
+
kind,
|
|
35
|
+
spec
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
groupIndex,
|
|
40
|
+
itemIndex: 0
|
|
41
|
+
};
|
|
42
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
43
|
+
height: 300,
|
|
44
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
|
|
45
|
+
...previewValues
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
}
|