@perses-dev/dashboards 0.8.0 → 0.9.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 +29 -14
- package/dist/cjs/components/DashboardToolbar.js +148 -20
- package/dist/cjs/components/GridLayout/GridItemContent.js +24 -18
- package/dist/cjs/components/GridLayout/GridLayout.js +88 -26
- package/dist/cjs/components/GridLayout/GridTitle.js +69 -31
- package/dist/cjs/components/GridLayout/index.js +18 -19
- package/dist/cjs/components/Panel/Panel.js +145 -55
- package/dist/cjs/components/Panel/Panel.test.js +50 -41
- package/dist/cjs/components/Panel/PanelContent.js +40 -12
- package/dist/cjs/components/Panel/index.js +16 -17
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +82 -107
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +91 -92
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +152 -0
- package/dist/cjs/components/PanelDrawer/PanelSpecEditor.js +40 -0
- package/dist/cjs/components/PanelDrawer/PanelTypeSelect.js +38 -0
- package/dist/cjs/components/PanelDrawer/index.js +28 -0
- package/dist/cjs/components/PanelDrawer/panel-editor-model.js +140 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +120 -31
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +90 -83
- 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 +186 -35
- package/dist/cjs/components/Variables/VariableList.js +100 -13
- package/dist/cjs/components/Variables/index.js +17 -18
- package/dist/cjs/components/index.js +21 -21
- package/dist/cjs/context/DashboardAppSlice.js +43 -31
- package/dist/cjs/context/DashboardProvider.js +88 -58
- package/dist/cjs/context/DatasourceStoreProvider.js +68 -0
- package/dist/cjs/context/LayoutsSlice.js +40 -27
- package/dist/cjs/context/QueryStringProvider.js +69 -15
- package/dist/cjs/context/TemplateVariableProvider.js +128 -136
- package/dist/cjs/context/TimeRangeProvider.js +79 -30
- package/dist/cjs/context/index.js +22 -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 +193 -109
- package/dist/cjs/utils/functions.js +9 -5
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +67 -0
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +83 -0
- package/dist/cjs/views/ViewDashboard/index.js +28 -0
- package/dist/cjs/views/index.js +16 -17
- package/dist/components/Dashboard.js +38 -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.js +35 -1
- package/dist/components/GridLayout/GridItemContent.js.map +1 -0
- package/dist/components/GridLayout/GridLayout.js +99 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -0
- package/dist/components/GridLayout/GridTitle.js +77 -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/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +170 -1
- package/dist/components/Panel/Panel.js.map +1 -0
- package/dist/components/Panel/Panel.test.js +71 -1
- package/dist/components/Panel/Panel.test.js.map +1 -0
- package/dist/components/Panel/PanelContent.d.ts +2 -4
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +40 -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 +95 -1
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.js +103 -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 +142 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts +7 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.js +34 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.js.map +1 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts +8 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.js +34 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.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/PanelDrawer/panel-editor-model.d.ts +27 -0
- package/dist/components/PanelDrawer/panel-editor-model.d.ts.map +1 -0
- package/dist/components/PanelDrawer/panel-editor-model.js +133 -0
- package/dist/components/PanelDrawer/panel-editor-model.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +138 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +95 -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 +202 -1
- package/dist/components/Variables/Variable.js.map +1 -0
- package/dist/components/Variables/VariableList.js +108 -1
- package/dist/components/Variables/VariableList.js.map +1 -0
- package/dist/components/Variables/index.js +16 -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/DashboardAppSlice.js +45 -1
- package/dist/context/DashboardAppSlice.js.map +1 -0
- package/dist/context/DashboardProvider.d.ts +4 -2
- package/dist/context/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider.js +107 -1
- package/dist/context/DashboardProvider.js.map +1 -0
- package/dist/context/DatasourceStoreProvider.d.ts +16 -0
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -0
- package/dist/context/DatasourceStoreProvider.js +64 -0
- package/dist/context/DatasourceStoreProvider.js.map +1 -0
- package/dist/context/LayoutsSlice.js +43 -1
- package/dist/context/LayoutsSlice.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 +6 -3
- package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider.js +192 -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 -2
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +21 -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 +2 -3
- 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 +274 -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 +7 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.js +56 -0
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -0
- package/dist/views/{ViewDashboard.d.ts → ViewDashboard/ViewDashboard.d.ts} +3 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.js +79 -0
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -0
- package/dist/views/ViewDashboard/index.d.ts +2 -0
- package/dist/views/ViewDashboard/index.d.ts.map +1 -0
- package/dist/views/ViewDashboard/index.js +15 -0
- package/dist/views/ViewDashboard/index.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/views/DashboardApp.js +0 -46
- package/dist/cjs/views/ViewDashboard.js +0 -43
- 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/views/DashboardApp.d.ts +0 -4
- package/dist/views/DashboardApp.d.ts.map +0 -1
- package/dist/views/DashboardApp.js +0 -1
- package/dist/views/ViewDashboard.d.ts.map +0 -1
- package/dist/views/ViewDashboard.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,90 @@ 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
|
-
const [
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const
|
|
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
|
-
}
|
|
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 _panelEditorModel = require("./panel-editor-model");
|
|
27
|
+
const _panelEditorForm = require("./PanelEditorForm");
|
|
28
|
+
const PanelDrawer = ()=>{
|
|
29
|
+
const { closePanelDrawer } = (0, _context.useDashboardApp)();
|
|
30
|
+
const model = (0, _panelEditorModel.usePanelDrawerModel)();
|
|
31
|
+
// When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
|
|
32
|
+
const [isClosing, setIsClosing] = (0, _react.useState)(false);
|
|
33
|
+
const handleClose = ()=>setIsClosing(true);
|
|
34
|
+
// Don't call closeDrawer on the store until the Drawer has completely transitioned out
|
|
35
|
+
const handleExited = ()=>{
|
|
84
36
|
closePanelDrawer();
|
|
37
|
+
setIsClosing(false);
|
|
85
38
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
39
|
+
// Drawer is open if we have a model and we're not transitioning out
|
|
40
|
+
const isOpen = model !== undefined && isClosing === false;
|
|
41
|
+
const handleSubmit = (values)=>{
|
|
42
|
+
// This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy
|
|
43
|
+
if (model === undefined) {
|
|
44
|
+
throw new Error('Cannot apply changes');
|
|
89
45
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
kind,
|
|
93
|
-
options,
|
|
94
|
-
display: { name: panelName, description: panelDescription },
|
|
95
|
-
}, panelDrawer.groupIndex);
|
|
46
|
+
model.applyChanges(values);
|
|
47
|
+
handleClose();
|
|
96
48
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
49
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Drawer, {
|
|
50
|
+
isOpen: isOpen,
|
|
51
|
+
onClose: handleClose,
|
|
52
|
+
SlideProps: {
|
|
53
|
+
onExited: handleExited
|
|
54
|
+
},
|
|
55
|
+
children: model !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
56
|
+
children: [
|
|
57
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
58
|
+
sx: {
|
|
59
|
+
display: 'flex',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
marginBottom: (theme)=>theme.spacing(2),
|
|
62
|
+
paddingBottom: (theme)=>theme.spacing(2),
|
|
63
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.grey[100]}`
|
|
64
|
+
},
|
|
65
|
+
children: [
|
|
66
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
67
|
+
variant: "h2",
|
|
68
|
+
children: model.drawerTitle
|
|
69
|
+
}),
|
|
70
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
71
|
+
direction: "row",
|
|
72
|
+
spacing: 1,
|
|
73
|
+
sx: {
|
|
74
|
+
marginLeft: 'auto'
|
|
75
|
+
},
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
78
|
+
type: "submit",
|
|
79
|
+
variant: "contained",
|
|
80
|
+
form: _panelEditorForm.panelEditorFormId,
|
|
81
|
+
children: model.submitButtonText
|
|
82
|
+
}),
|
|
83
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
84
|
+
variant: "outlined",
|
|
85
|
+
onClick: handleClose,
|
|
86
|
+
children: "Cancel"
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
}),
|
|
92
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelEditorForm.PanelEditorForm, {
|
|
93
|
+
onSubmit: handleSubmit,
|
|
94
|
+
initialValues: model.initialValues
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
})
|
|
98
|
+
});
|
|
123
99
|
};
|
|
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,101 @@ 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', 'LineChart', _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().openPanelDrawer({
|
|
58
|
+
groupIndex: 0
|
|
59
|
+
}));
|
|
60
|
+
const nameInput = await _react.screen.findByLabelText(/Panel Name/);
|
|
61
|
+
_userEvent.default.type(nameInput, 'New Panel');
|
|
62
|
+
_userEvent.default.click(_react.screen.getByText('Add'));
|
|
63
|
+
// TODO: Assert drawer is closed?
|
|
64
|
+
const panels = storeApi.getState().panels;
|
|
65
|
+
expect(panels).toMatchObject({
|
|
66
|
+
// Should have the new panel in the store
|
|
67
|
+
NewPanel: {
|
|
68
|
+
kind: 'Panel',
|
|
69
|
+
spec: {
|
|
70
|
+
display: {
|
|
71
|
+
name: 'New Panel',
|
|
72
|
+
description: ''
|
|
73
|
+
},
|
|
74
|
+
plugin: {
|
|
75
|
+
kind: '',
|
|
76
|
+
spec: {}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
92
81
|
});
|
|
93
|
-
it('should edit an existing panel', ()
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
82
|
+
it('should edit an existing panel', async ()=>{
|
|
83
|
+
const storeApi = renderPanelDrawer();
|
|
84
|
+
// Open the drawer for an existing panel
|
|
85
|
+
(0, _testUtils.act)(()=>storeApi.getState().openPanelDrawer({
|
|
97
86
|
groupIndex: 0,
|
|
98
|
-
panelKey: 'cpu'
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
expect(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
87
|
+
panelKey: 'cpu'
|
|
88
|
+
}));
|
|
89
|
+
const nameInput = await _react.screen.findByLabelText(/Panel Name/);
|
|
90
|
+
_userEvent.default.clear(nameInput);
|
|
91
|
+
_userEvent.default.type(nameInput, 'cpu usage');
|
|
92
|
+
_userEvent.default.click(_react.screen.getByText('Apply'));
|
|
93
|
+
const panels = storeApi.getState().panels;
|
|
94
|
+
expect(panels).toMatchObject({
|
|
95
|
+
cpu: {
|
|
96
|
+
kind: 'Panel',
|
|
97
|
+
spec: {
|
|
98
|
+
display: {
|
|
99
|
+
name: 'cpu usage',
|
|
100
|
+
description: ''
|
|
101
|
+
},
|
|
102
|
+
plugin: {
|
|
103
|
+
kind: 'TimeSeriesChart',
|
|
104
|
+
spec: {}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
109
108
|
});
|
|
110
109
|
});
|
|
111
110
|
});
|
|
@@ -0,0 +1,152 @@
|
|
|
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 _context = require("../../context");
|
|
32
|
+
const _panelEditorModel = require("./panel-editor-model");
|
|
33
|
+
const _panelTypeSelect = require("./PanelTypeSelect");
|
|
34
|
+
const _panelSpecEditor = require("./PanelSpecEditor");
|
|
35
|
+
function PanelEditorForm(props) {
|
|
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 [group, setGroup] = (0, _react.useState)(initialValues.group);
|
|
41
|
+
const [kind, setKind] = (0, _react.useState)(initialValues.kind);
|
|
42
|
+
const { spec , onSpecChange } = (0, _panelEditorModel.usePanelSpecState)(kind, initialValues.spec);
|
|
43
|
+
// Ignore string values (which would be an "empty" value from the Select) since we don't allow them to unset it
|
|
44
|
+
const handleGroupChange = (e)=>{
|
|
45
|
+
const { value } = e.target;
|
|
46
|
+
if (typeof value === 'string') {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
setGroup(value);
|
|
50
|
+
};
|
|
51
|
+
const handleSubmit = (e)=>{
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
const values = {
|
|
54
|
+
name,
|
|
55
|
+
description,
|
|
56
|
+
group,
|
|
57
|
+
kind,
|
|
58
|
+
spec
|
|
59
|
+
};
|
|
60
|
+
onSubmit(values);
|
|
61
|
+
};
|
|
62
|
+
var ref;
|
|
63
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("form", {
|
|
64
|
+
id: panelEditorFormId,
|
|
65
|
+
onSubmit: handleSubmit,
|
|
66
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
67
|
+
container: true,
|
|
68
|
+
spacing: 2,
|
|
69
|
+
children: [
|
|
70
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
71
|
+
item: true,
|
|
72
|
+
xs: 8,
|
|
73
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
74
|
+
required: true,
|
|
75
|
+
label: "Panel Name",
|
|
76
|
+
value: name,
|
|
77
|
+
variant: "outlined",
|
|
78
|
+
onChange: (e)=>setName(e.target.value)
|
|
79
|
+
})
|
|
80
|
+
}),
|
|
81
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
82
|
+
item: true,
|
|
83
|
+
xs: 4,
|
|
84
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
87
|
+
id: "select-group",
|
|
88
|
+
children: "Group"
|
|
89
|
+
}),
|
|
90
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Select, {
|
|
91
|
+
required: true,
|
|
92
|
+
labelId: "select-group",
|
|
93
|
+
label: "Group",
|
|
94
|
+
value: group !== null && group !== void 0 ? group : 0,
|
|
95
|
+
onChange: handleGroupChange,
|
|
96
|
+
children: layouts.map((layout, index)=>{
|
|
97
|
+
var ref1;
|
|
98
|
+
/*#__PURE__*/ return (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
99
|
+
value: index,
|
|
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
|
+
})
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
}),
|
|
107
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
108
|
+
item: true,
|
|
109
|
+
xs: 8,
|
|
110
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
111
|
+
label: "Panel Description",
|
|
112
|
+
value: description,
|
|
113
|
+
variant: "outlined",
|
|
114
|
+
onChange: (e)=>setDescription(e.target.value)
|
|
115
|
+
})
|
|
116
|
+
}),
|
|
117
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
118
|
+
item: true,
|
|
119
|
+
xs: 4,
|
|
120
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
121
|
+
children: [
|
|
122
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
123
|
+
id: "panel-type-label",
|
|
124
|
+
children: "Panel Type"
|
|
125
|
+
}),
|
|
126
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelTypeSelect.PanelTypeSelect, {
|
|
127
|
+
required: true,
|
|
128
|
+
labelId: "panel-type-label",
|
|
129
|
+
label: "Panel Type",
|
|
130
|
+
value: kind,
|
|
131
|
+
onChange: (e)=>setKind(e.target.value)
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
}),
|
|
136
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
137
|
+
item: true,
|
|
138
|
+
xs: 12,
|
|
139
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
140
|
+
FallbackComponent: _components.ErrorAlert,
|
|
141
|
+
children: spec !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelSpecEditor.PanelSpecEditor, {
|
|
142
|
+
panelPluginKind: kind,
|
|
143
|
+
value: spec,
|
|
144
|
+
onChange: onSpecChange
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
]
|
|
149
|
+
})
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const panelEditorFormId = 'panel-editor-form';
|
|
@@ -0,0 +1,40 @@
|
|
|
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, "PanelSpecEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>PanelSpecEditor
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
23
|
+
function PanelSpecEditor(props) {
|
|
24
|
+
const { panelPluginKind , ...others } = props;
|
|
25
|
+
const { data: plugin , isLoading } = (0, _pluginSystem.usePlugin)('Panel', panelPluginKind, {
|
|
26
|
+
useErrorBoundary: true,
|
|
27
|
+
enabled: panelPluginKind !== ''
|
|
28
|
+
});
|
|
29
|
+
// TODO: Proper loading indicator
|
|
30
|
+
if (isLoading) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
if (plugin === undefined) {
|
|
34
|
+
throw new Error(`Missing OptionsEditorComponent for Panel plugin with kind '${panelPluginKind}'`);
|
|
35
|
+
}
|
|
36
|
+
const { OptionsEditorComponent } = plugin;
|
|
37
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(OptionsEditorComponent, {
|
|
38
|
+
...others
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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, "PanelTypeSelect", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>PanelTypeSelect
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
24
|
+
function PanelTypeSelect(props) {
|
|
25
|
+
const { value: propValue , ...others } = props;
|
|
26
|
+
const { data , isLoading } = (0, _pluginSystem.useListPluginMetadata)('Panel');
|
|
27
|
+
// Pass an empty value while options are still loading so MUI doesn't complain about us using an "out of range" value
|
|
28
|
+
const value = propValue !== '' && isLoading ? '' : propValue;
|
|
29
|
+
// TODO: Does this need a loading indicator of some kind?
|
|
30
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Select, {
|
|
31
|
+
...others,
|
|
32
|
+
value: value,
|
|
33
|
+
children: data === null || data === void 0 ? void 0 : data.map((metadata)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
34
|
+
value: metadata.kind,
|
|
35
|
+
children: metadata.display.name
|
|
36
|
+
}, metadata.kind))
|
|
37
|
+
});
|
|
38
|
+
}
|