@perses-dev/dashboards 0.9.0 → 0.11.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 +6 -11
- package/dist/cjs/components/DashboardToolbar.js +12 -6
- package/dist/cjs/components/GridLayout/GridItemContent.js +7 -15
- package/dist/cjs/components/GridLayout/GridLayout.js +27 -22
- package/dist/cjs/components/GridLayout/GridTitle.js +27 -7
- package/dist/cjs/components/Panel/DeletePanelDialog.js +95 -0
- package/dist/cjs/components/Panel/Panel.js +12 -10
- package/dist/cjs/components/Panel/Panel.test.js +15 -6
- package/dist/cjs/components/Panel/PanelContent.js +3 -2
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +13 -12
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +9 -13
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +87 -39
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +54 -0
- package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +88 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +70 -118
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +21 -36
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
- package/dist/cjs/components/PanelGroupDialog/index.js +29 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +8 -11
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +20 -13
- package/dist/cjs/components/Variables/Variable.js +20 -11
- package/dist/cjs/components/Variables/VariableEditor.js +240 -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 +49 -69
- package/dist/cjs/components/Variables/index.js +1 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +82 -0
- package/dist/cjs/context/DashboardProvider/common.js +18 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +164 -0
- package/dist/cjs/context/DashboardProvider/index.js +29 -0
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +175 -0
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +102 -0
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +208 -0
- package/dist/cjs/context/DatasourceStoreProvider.js +109 -7
- package/dist/cjs/context/TemplateVariableProvider.js +8 -1
- package/dist/cjs/context/TimeRangeProvider.js +20 -44
- package/dist/cjs/context/index.js +1 -3
- package/dist/cjs/context/useDashboardSpec.js +61 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/test/render.js +25 -5
- package/dist/cjs/test/setup-tests.js +4 -1
- package/dist/cjs/test/testDashboard.js +24 -11
- package/dist/cjs/utils/index.js +28 -0
- package/dist/cjs/utils/time-range-params.js +145 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +5 -8
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -22
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +114 -0
- package/dist/components/Dashboard.d.ts +1 -4
- package/dist/components/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard.js +7 -12
- package/dist/components/Dashboard.js.map +1 -1
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +14 -8
- package/dist/components/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +2 -4
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +7 -15
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +2 -4
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +28 -23
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts +2 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +28 -8
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- 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 +84 -0
- package/dist/components/Panel/DeletePanelDialog.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +2 -2
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +13 -11
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/Panel.test.d.ts +1 -1
- package/dist/components/Panel/Panel.test.d.ts.map +1 -1
- package/dist/components/Panel/Panel.test.js +10 -6
- package/dist/components/Panel/Panel.test.js.map +1 -1
- package/dist/components/Panel/PanelContent.d.ts +4 -1
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +3 -2
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +14 -13
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js +9 -13
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +3 -3
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +89 -41
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- 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 +48 -0
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +3 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +77 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +4 -2
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +73 -119
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +20 -35
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
- package/dist/components/PanelGroupDialog/index.d.ts +3 -0
- package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/index.js +16 -0
- package/dist/components/PanelGroupDialog/index.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +11 -14
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +21 -14
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
- package/dist/components/Variables/Variable.js +22 -13
- package/dist/components/Variables/Variable.js.map +1 -1
- 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 +229 -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 +47 -72
- package/dist/components/Variables/VariableList.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 +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +25 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.js +64 -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 +74 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js +163 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +5 -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/panel-editor-slice.d.ts +85 -0
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js +171 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +40 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +96 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +80 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.js +204 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
- package/dist/context/DatasourceStoreProvider.d.ts +10 -2
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +111 -9
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider.d.ts +2 -0
- package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider.js +8 -1
- package/dist/context/TemplateVariableProvider.js.map +1 -1
- package/dist/context/TimeRangeProvider.d.ts +9 -2
- package/dist/context/TimeRangeProvider.d.ts.map +1 -1
- package/dist/context/TimeRangeProvider.js +15 -43
- package/dist/context/TimeRangeProvider.js.map +1 -1
- package/dist/context/index.d.ts +1 -3
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -3
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboardSpec.d.ts +3 -0
- package/dist/context/useDashboardSpec.d.ts.map +1 -0
- package/dist/context/useDashboardSpec.js +55 -0
- package/dist/context/useDashboardSpec.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/test/plugin-registry.d.ts +2 -2
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts +2 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +25 -5
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.d.ts.map +1 -1
- package/dist/test/setup-tests.js +4 -0
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +24 -11
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +15 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/time-range-params.d.ts +25 -0
- package/dist/utils/time-range-params.d.ts.map +1 -0
- package/dist/utils/time-range-params.js +137 -0
- package/dist/utils/time-range-params.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +6 -9
- 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 +5 -22
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- 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 +107 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
- package/package.json +5 -4
- package/dist/cjs/components/PanelDrawer/PanelSpecEditor.js +0 -40
- package/dist/cjs/components/PanelDrawer/PanelTypeSelect.js +0 -38
- package/dist/cjs/components/PanelDrawer/panel-editor-model.js +0 -140
- package/dist/cjs/context/DashboardAppSlice.js +0 -57
- package/dist/cjs/context/DashboardProvider.js +0 -128
- package/dist/cjs/context/LayoutsSlice.js +0 -55
- package/dist/cjs/context/QueryStringProvider.js +0 -89
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts +0 -7
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelSpecEditor.js +0 -34
- package/dist/components/PanelDrawer/PanelSpecEditor.js.map +0 -1
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts +0 -8
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelTypeSelect.js +0 -34
- package/dist/components/PanelDrawer/PanelTypeSelect.js.map +0 -1
- package/dist/components/PanelDrawer/panel-editor-model.d.ts +0 -27
- package/dist/components/PanelDrawer/panel-editor-model.d.ts.map +0 -1
- package/dist/components/PanelDrawer/panel-editor-model.js +0 -133
- package/dist/components/PanelDrawer/panel-editor-model.js.map +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 -45
- package/dist/context/DashboardAppSlice.js.map +0 -1
- package/dist/context/DashboardProvider.d.ts +0 -36
- package/dist/context/DashboardProvider.d.ts.map +0 -1
- package/dist/context/DashboardProvider.js +0 -107
- package/dist/context/DashboardProvider.js.map +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 -43
- package/dist/context/LayoutsSlice.js.map +0 -1
- package/dist/context/QueryStringProvider.d.ts +0 -13
- package/dist/context/QueryStringProvider.d.ts.map +0 -1
- package/dist/context/QueryStringProvider.js +0 -40
- package/dist/context/QueryStringProvider.js.map +0 -1
|
@@ -28,51 +28,69 @@ const _jsxRuntime = require("react/jsx-runtime");
|
|
|
28
28
|
const _react = require("react");
|
|
29
29
|
const _material = require("@mui/material");
|
|
30
30
|
const _components = require("@perses-dev/components");
|
|
31
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
31
32
|
const _context = require("../../context");
|
|
32
|
-
const
|
|
33
|
-
const _panelTypeSelect = require("./PanelTypeSelect");
|
|
34
|
-
const _panelSpecEditor = require("./PanelSpecEditor");
|
|
33
|
+
const _panelPreview = require("./PanelPreview");
|
|
35
34
|
function PanelEditorForm(props) {
|
|
35
|
+
var ref;
|
|
36
36
|
const { initialValues , onSubmit } = props;
|
|
37
|
-
const
|
|
37
|
+
const panelGroups = (0, _context.useListPanelGroups)();
|
|
38
38
|
const [name, setName] = (0, _react.useState)(initialValues.name);
|
|
39
39
|
const [description, setDescription] = (0, _react.useState)(initialValues.description);
|
|
40
|
-
const [
|
|
40
|
+
const [groupId, setGroupId] = (0, _react.useState)(initialValues.groupId);
|
|
41
41
|
const [kind, setKind] = (0, _react.useState)(initialValues.kind);
|
|
42
|
-
const
|
|
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
|
+
});
|
|
43
55
|
// Ignore string values (which would be an "empty" value from the Select) since we don't allow them to unset it
|
|
44
56
|
const handleGroupChange = (e)=>{
|
|
45
57
|
const { value } = e.target;
|
|
46
58
|
if (typeof value === 'string') {
|
|
47
59
|
return;
|
|
48
60
|
}
|
|
49
|
-
|
|
61
|
+
setGroupId(value);
|
|
50
62
|
};
|
|
51
63
|
const handleSubmit = (e)=>{
|
|
52
64
|
e.preventDefault();
|
|
53
65
|
const values = {
|
|
54
66
|
name,
|
|
55
67
|
description,
|
|
56
|
-
|
|
68
|
+
groupId,
|
|
57
69
|
kind,
|
|
58
70
|
spec
|
|
59
71
|
};
|
|
60
72
|
onSubmit(values);
|
|
61
73
|
};
|
|
62
|
-
var
|
|
63
|
-
return
|
|
74
|
+
var _title, ref1;
|
|
75
|
+
return(// Grid maxHeight allows user to scroll inside Drawer to see all content
|
|
76
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("form", {
|
|
64
77
|
id: panelEditorFormId,
|
|
65
78
|
onSubmit: handleSubmit,
|
|
66
79
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
67
80
|
container: true,
|
|
68
81
|
spacing: 2,
|
|
82
|
+
sx: {
|
|
83
|
+
overflowY: 'scroll',
|
|
84
|
+
maxHeight: '90vh'
|
|
85
|
+
},
|
|
69
86
|
children: [
|
|
70
87
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
71
88
|
item: true,
|
|
72
89
|
xs: 8,
|
|
73
90
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
74
91
|
required: true,
|
|
75
|
-
|
|
92
|
+
fullWidth: true,
|
|
93
|
+
label: "Name",
|
|
76
94
|
value: name,
|
|
77
95
|
variant: "outlined",
|
|
78
96
|
onChange: (e)=>setName(e.target.value)
|
|
@@ -82,6 +100,7 @@ function PanelEditorForm(props) {
|
|
|
82
100
|
item: true,
|
|
83
101
|
xs: 4,
|
|
84
102
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
103
|
+
fullWidth: true,
|
|
85
104
|
children: [
|
|
86
105
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
87
106
|
id: "select-group",
|
|
@@ -91,15 +110,12 @@ function PanelEditorForm(props) {
|
|
|
91
110
|
required: true,
|
|
92
111
|
labelId: "select-group",
|
|
93
112
|
label: "Group",
|
|
94
|
-
value:
|
|
113
|
+
value: groupId,
|
|
95
114
|
onChange: handleGroupChange,
|
|
96
|
-
children:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
children: (ref = (ref1 = layout.spec.display) === null || ref1 === void 0 ? void 0 : ref1.title) !== null && ref !== void 0 ? ref : `Group ${index + 1}`
|
|
101
|
-
}, index);
|
|
102
|
-
})
|
|
115
|
+
children: panelGroups.map((panelGroup, index)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
116
|
+
value: panelGroup.id,
|
|
117
|
+
children: (_title = panelGroup.title) !== null && _title !== void 0 ? _title : `Group ${index + 1}`
|
|
118
|
+
}, panelGroup.id))
|
|
103
119
|
})
|
|
104
120
|
]
|
|
105
121
|
})
|
|
@@ -108,45 +124,77 @@ function PanelEditorForm(props) {
|
|
|
108
124
|
item: true,
|
|
109
125
|
xs: 8,
|
|
110
126
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
111
|
-
|
|
127
|
+
fullWidth: true,
|
|
128
|
+
label: "Description",
|
|
112
129
|
value: description,
|
|
113
130
|
variant: "outlined",
|
|
114
131
|
onChange: (e)=>setDescription(e.target.value)
|
|
115
132
|
})
|
|
116
133
|
}),
|
|
117
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
134
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
118
135
|
item: true,
|
|
119
136
|
xs: 4,
|
|
120
|
-
children:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
children: [
|
|
138
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
139
|
+
fullWidth: true,
|
|
140
|
+
disabled: pluginEditor.isLoading,
|
|
141
|
+
error: pluginEditor.error !== null,
|
|
142
|
+
children: [
|
|
143
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
144
|
+
id: "panel-type-label",
|
|
145
|
+
children: "Type"
|
|
146
|
+
}),
|
|
147
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginKindSelect, {
|
|
148
|
+
pluginType: "Panel",
|
|
149
|
+
required: true,
|
|
150
|
+
labelId: "panel-type-label",
|
|
151
|
+
label: "Type",
|
|
152
|
+
value: pluginEditor.pendingKind ? pluginEditor.pendingKind : kind,
|
|
153
|
+
onChange: pluginEditor.onKindChange
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
}),
|
|
157
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormHelperText, {
|
|
158
|
+
children: (ref1 = (ref = pluginEditor.error) === null || ref === void 0 ? void 0 : ref.message) !== null && ref1 !== void 0 ? ref1 : ''
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
}),
|
|
162
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
163
|
+
item: true,
|
|
164
|
+
xs: 12,
|
|
165
|
+
children: [
|
|
166
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
167
|
+
variant: "h4",
|
|
168
|
+
marginBottom: 1,
|
|
169
|
+
children: "Preview"
|
|
170
|
+
}),
|
|
171
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
172
|
+
FallbackComponent: _components.ErrorAlert,
|
|
173
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelPreview.PanelPreview, {
|
|
174
|
+
kind: kind,
|
|
175
|
+
name: name,
|
|
176
|
+
description: description,
|
|
177
|
+
spec: spec,
|
|
178
|
+
groupId: groupId
|
|
132
179
|
})
|
|
133
|
-
|
|
134
|
-
|
|
180
|
+
})
|
|
181
|
+
]
|
|
135
182
|
}),
|
|
136
183
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
137
184
|
item: true,
|
|
138
185
|
xs: 12,
|
|
139
186
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
140
187
|
FallbackComponent: _components.ErrorAlert,
|
|
141
|
-
children:
|
|
142
|
-
|
|
188
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginSpecEditor, {
|
|
189
|
+
pluginType: "Panel",
|
|
190
|
+
pluginKind: kind,
|
|
143
191
|
value: spec,
|
|
144
|
-
onChange: onSpecChange
|
|
192
|
+
onChange: pluginEditor.onSpecChange
|
|
145
193
|
})
|
|
146
194
|
})
|
|
147
195
|
})
|
|
148
196
|
]
|
|
149
197
|
})
|
|
150
|
-
});
|
|
198
|
+
}));
|
|
151
199
|
}
|
|
152
200
|
const panelEditorFormId = 'panel-editor-form';
|
|
@@ -0,0 +1,54 @@
|
|
|
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 , groupId }) {
|
|
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
|
+
// TODO: what should itemIndex be?
|
|
40
|
+
panelGroupItemId: {
|
|
41
|
+
panelGroupId: groupId,
|
|
42
|
+
itemIndex: 0
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
if (!kind) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
49
|
+
height: 300,
|
|
50
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
|
|
51
|
+
...previewValues
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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, "DeletePanelGroupDialog", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>DeletePanelGroupDialog
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _close = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Close"));
|
|
24
|
+
const _context = require("../../context");
|
|
25
|
+
function _interopRequireDefault(obj) {
|
|
26
|
+
return obj && obj.__esModule ? obj : {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const DeletePanelGroupDialog = ()=>{
|
|
31
|
+
const { deletePanelGroupDialog , closeDeletePanelGroupDialog , deletePanelGroup } = (0, _context.useDeletePanelGroupDialog)();
|
|
32
|
+
const panelGroupId = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.panelGroupId;
|
|
33
|
+
const handleDelete = (e)=>{
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
if (panelGroupId == undefined) {
|
|
36
|
+
throw new Error('group index is undefined');
|
|
37
|
+
}
|
|
38
|
+
deletePanelGroup(panelGroupId);
|
|
39
|
+
closeDeletePanelGroupDialog();
|
|
40
|
+
};
|
|
41
|
+
var ref;
|
|
42
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Dialog, {
|
|
43
|
+
open: deletePanelGroupDialog !== undefined,
|
|
44
|
+
children: [
|
|
45
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogTitle, {
|
|
46
|
+
children: "Delete Panel Group"
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
49
|
+
"aria-label": "Close",
|
|
50
|
+
onClick: ()=>closeDeletePanelGroupDialog(),
|
|
51
|
+
sx: (theme)=>({
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
top: theme.spacing(0.5),
|
|
54
|
+
right: theme.spacing(0.5)
|
|
55
|
+
}),
|
|
56
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_close.default, {})
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)("form", {
|
|
59
|
+
onSubmit: handleDelete,
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogContent, {
|
|
62
|
+
sx: {
|
|
63
|
+
width: '500px'
|
|
64
|
+
},
|
|
65
|
+
children: [
|
|
66
|
+
"Are you sure you want to delete ",
|
|
67
|
+
(ref = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.panelGroupName) !== null && ref !== void 0 ? ref : 'panel group',
|
|
68
|
+
"? This will delete all the panels within the group."
|
|
69
|
+
]
|
|
70
|
+
}),
|
|
71
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
|
|
72
|
+
children: [
|
|
73
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
74
|
+
variant: "contained",
|
|
75
|
+
type: "submit",
|
|
76
|
+
children: "Delete"
|
|
77
|
+
}),
|
|
78
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
79
|
+
onClick: ()=>closeDeletePanelGroupDialog(),
|
|
80
|
+
children: "Cancel"
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
};
|
|
@@ -14,136 +14,88 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "PanelGroupDialog", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()=>
|
|
19
|
+
get: ()=>PanelGroupDialog
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _react = require("react");
|
|
23
22
|
const _material = require("@mui/material");
|
|
24
23
|
const _close = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Close"));
|
|
24
|
+
const _react = require("react");
|
|
25
25
|
const _context = require("../../context");
|
|
26
|
+
const _panelGroupEditorForm = require("./PanelGroupEditorForm");
|
|
26
27
|
function _interopRequireDefault(obj) {
|
|
27
28
|
return obj && obj.__esModule ? obj : {
|
|
28
29
|
default: obj
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var ref;
|
|
41
|
-
e.preventDefault();
|
|
42
|
-
var _items;
|
|
43
|
-
const newLayout = {
|
|
44
|
-
kind: 'Grid',
|
|
45
|
-
spec: {
|
|
46
|
-
display: {
|
|
47
|
-
title: name !== null && name !== void 0 ? name : '',
|
|
48
|
-
collapse: {
|
|
49
|
-
open: !isCollapsed
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
items: groupIndex === undefined ? [] : (_items = (ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.spec.items) !== null && _items !== void 0 ? _items : []
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
updateLayout(newLayout, groupIndex);
|
|
56
|
-
closePanelGroupDialog();
|
|
32
|
+
function PanelGroupDialog() {
|
|
33
|
+
const panelGroupEditor = (0, _context.usePanelGroupEditor)();
|
|
34
|
+
// When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
|
|
35
|
+
const [isClosing, setIsClosing] = (0, _react.useState)(false);
|
|
36
|
+
const handleClose = ()=>setIsClosing(true);
|
|
37
|
+
// Don't call close on the store until the Dialog has completely transitioned out
|
|
38
|
+
const handleExited = ()=>{
|
|
39
|
+
panelGroupEditor === null || panelGroupEditor === void 0 ? void 0 : panelGroupEditor.close();
|
|
40
|
+
setIsClosing(false);
|
|
57
41
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
42
|
+
// Dialog is open if we have a model and we're not transitioning out
|
|
43
|
+
const isOpen = panelGroupEditor !== undefined && isClosing === false;
|
|
44
|
+
const handleSubmit = (values)=>{
|
|
45
|
+
// This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy
|
|
46
|
+
if (panelGroupEditor === undefined) {
|
|
47
|
+
throw new Error('Cannot apply changes');
|
|
48
|
+
}
|
|
49
|
+
panelGroupEditor.applyChanges(values);
|
|
50
|
+
handleClose();
|
|
61
51
|
};
|
|
62
|
-
return /*#__PURE__*/ (0, _jsxRuntime.
|
|
63
|
-
open:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
variant: "outlined",
|
|
93
|
-
value: name,
|
|
94
|
-
onChange: (e)=>setName(e.target.value)
|
|
95
|
-
})
|
|
96
|
-
}),
|
|
97
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
98
|
-
sx: {
|
|
99
|
-
display: 'flex',
|
|
100
|
-
alignItems: 'center',
|
|
101
|
-
width: '100%',
|
|
102
|
-
justifyContent: 'space-between'
|
|
103
|
-
},
|
|
104
|
-
children: [
|
|
105
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
106
|
-
children: "Collapse State"
|
|
107
|
-
}),
|
|
108
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Select, {
|
|
109
|
-
required: true,
|
|
110
|
-
displayEmpty: true,
|
|
111
|
-
labelId: "select-collapse-state",
|
|
112
|
-
size: "small",
|
|
113
|
-
value: isCollapsed ? 'Close' : 'Open',
|
|
114
|
-
onChange: handleSelectCollapsedStateChange,
|
|
115
|
-
children: [
|
|
116
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
117
|
-
value: 'Open',
|
|
118
|
-
children: "Open"
|
|
119
|
-
}, 'open'),
|
|
120
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
121
|
-
value: 'Close',
|
|
122
|
-
children: "Close"
|
|
123
|
-
}, 'close')
|
|
124
|
-
]
|
|
125
|
-
})
|
|
126
|
-
]
|
|
127
|
-
})
|
|
128
|
-
]
|
|
129
|
-
})
|
|
130
|
-
}),
|
|
131
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
|
|
132
|
-
children: [
|
|
133
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
134
|
-
variant: "contained",
|
|
135
|
-
type: "submit",
|
|
136
|
-
children: isEditingPanelGroup ? 'Apply' : 'Add'
|
|
137
|
-
}),
|
|
138
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
139
|
-
onClick: ()=>closePanelGroupDialog(),
|
|
140
|
-
children: "Cancel"
|
|
141
|
-
})
|
|
142
|
-
]
|
|
52
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Dialog, {
|
|
53
|
+
open: isOpen,
|
|
54
|
+
TransitionProps: {
|
|
55
|
+
onExited: handleExited
|
|
56
|
+
},
|
|
57
|
+
children: panelGroupEditor !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
58
|
+
children: [
|
|
59
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogTitle, {
|
|
60
|
+
children: [
|
|
61
|
+
panelGroupEditor.mode,
|
|
62
|
+
" Panel Group"
|
|
63
|
+
]
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
66
|
+
"aria-label": "Close",
|
|
67
|
+
onClick: panelGroupEditor.close,
|
|
68
|
+
sx: (theme)=>({
|
|
69
|
+
position: 'absolute',
|
|
70
|
+
top: theme.spacing(0.5),
|
|
71
|
+
right: theme.spacing(0.5)
|
|
72
|
+
}),
|
|
73
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_close.default, {})
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogContent, {
|
|
76
|
+
sx: {
|
|
77
|
+
width: '500px'
|
|
78
|
+
},
|
|
79
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelGroupEditorForm.PanelGroupEditorForm, {
|
|
80
|
+
initialValues: panelGroupEditor.initialValues,
|
|
81
|
+
onSubmit: handleSubmit
|
|
143
82
|
})
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
87
|
+
variant: "contained",
|
|
88
|
+
type: "submit",
|
|
89
|
+
form: _panelGroupEditorForm.panelGroupEditorFormId,
|
|
90
|
+
children: panelGroupEditor.mode === 'Edit' ? 'Apply' : 'Add'
|
|
91
|
+
}),
|
|
92
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
93
|
+
onClick: panelGroupEditor.close,
|
|
94
|
+
children: "Cancel"
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
})
|
|
147
100
|
});
|
|
148
|
-
}
|
|
149
|
-
const _default = PanelGroupDialog;
|
|
101
|
+
}
|
|
@@ -20,7 +20,8 @@ const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-librar
|
|
|
20
20
|
const _testUtils = require("react-dom/test-utils");
|
|
21
21
|
const _context = require("../../context");
|
|
22
22
|
const _test = require("../../test");
|
|
23
|
-
const
|
|
23
|
+
const _testDashboard = /*#__PURE__*/ _interopRequireDefault(require("../../test/testDashboard"));
|
|
24
|
+
const _panelGroupDialog = require("./PanelGroupDialog");
|
|
24
25
|
function _interopRequireDefault(obj) {
|
|
25
26
|
return obj && obj.__esModule ? obj : {
|
|
26
27
|
default: obj
|
|
@@ -36,7 +37,7 @@ describe('Add Panel Group', ()=>{
|
|
|
36
37
|
},
|
|
37
38
|
children: [
|
|
38
39
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardProviderSpy, {}),
|
|
39
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelGroupDialog.
|
|
40
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelGroupDialog.PanelGroupDialog, {})
|
|
40
41
|
]
|
|
41
42
|
}));
|
|
42
43
|
const { value: storeApi } = store;
|
|
@@ -46,56 +47,40 @@ describe('Add Panel Group', ()=>{
|
|
|
46
47
|
return storeApi;
|
|
47
48
|
};
|
|
48
49
|
it('should add new panel group', async ()=>{
|
|
49
|
-
// jest.spyOn(dashboardAppSlice, 'useDashboardApp').mockReturnValue(dashboardApp);
|
|
50
50
|
const storeApi = renderDialog();
|
|
51
51
|
// Open the dialog for a new panel group
|
|
52
|
-
(0, _testUtils.act)(()=>storeApi.getState().
|
|
52
|
+
(0, _testUtils.act)(()=>storeApi.getState().openAddPanelGroup());
|
|
53
53
|
const nameInput = await _react.screen.findByLabelText(/Name/);
|
|
54
54
|
_userEvent.default.type(nameInput, 'New Panel Group');
|
|
55
55
|
_userEvent.default.click(_react.screen.getByText('Add'));
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
open: true
|
|
64
|
-
}
|
|
65
|
-
},
|
|
56
|
+
// TODO: Figure out how to test this without coupling to the store state
|
|
57
|
+
const panelGroups = storeApi.getState().panelGroups;
|
|
58
|
+
expect(panelGroups).toMatchObject({
|
|
59
|
+
'3': {
|
|
60
|
+
id: 3,
|
|
61
|
+
title: 'New Panel Group',
|
|
62
|
+
isCollapsed: false,
|
|
66
63
|
items: []
|
|
67
64
|
}
|
|
68
65
|
});
|
|
69
66
|
});
|
|
70
67
|
it('should edit existing panel group', async ()=>{
|
|
68
|
+
var ref;
|
|
71
69
|
const storeApi = renderDialog();
|
|
72
70
|
// Open the dialog for an existing panel group
|
|
73
|
-
(0, _testUtils.act)(()=>storeApi.getState().
|
|
71
|
+
(0, _testUtils.act)(()=>storeApi.getState().openEditPanelGroup(0));
|
|
74
72
|
const nameInput = await _react.screen.findByLabelText(/Name/);
|
|
75
73
|
_userEvent.default.clear(nameInput);
|
|
76
74
|
_userEvent.default.type(nameInput, 'New Name');
|
|
77
75
|
_userEvent.default.click(_react.screen.getByText('Apply'));
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
items: [
|
|
89
|
-
{
|
|
90
|
-
content: {
|
|
91
|
-
$ref: '#/spec/panels/cpu'
|
|
92
|
-
},
|
|
93
|
-
height: 4,
|
|
94
|
-
width: 12,
|
|
95
|
-
x: 0,
|
|
96
|
-
y: 0
|
|
97
|
-
}
|
|
98
|
-
]
|
|
76
|
+
// TODO: Figure out how to test this without coupling to the store state
|
|
77
|
+
const panelGroups = storeApi.getState().panelGroups;
|
|
78
|
+
expect(panelGroups).toMatchObject({
|
|
79
|
+
'0': {
|
|
80
|
+
id: 0,
|
|
81
|
+
title: 'New Name',
|
|
82
|
+
isCollapsed: false,
|
|
83
|
+
items: (ref = _testDashboard.default.spec.layouts[0]) === null || ref === void 0 ? void 0 : ref.spec.items
|
|
99
84
|
}
|
|
100
85
|
});
|
|
101
86
|
});
|