@perses-dev/dashboards 0.9.0 → 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 +7 -11
- package/dist/cjs/components/DashboardToolbar.js +4 -4
- package/dist/cjs/components/GridLayout/GridItemContent.js +13 -13
- package/dist/cjs/components/GridLayout/GridLayout.js +24 -21
- package/dist/cjs/components/GridLayout/GridTitle.js +27 -5
- package/dist/cjs/components/Panel/DeletePanelDialog.js +91 -0
- package/dist/cjs/components/Panel/Panel.js +16 -5
- package/dist/cjs/components/Panel/Panel.test.js +12 -4
- 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 +8 -12
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +77 -35
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +48 -0
- package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +86 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +12 -19
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +10 -31
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +2 -2
- package/dist/cjs/components/Variables/Variable.js +19 -11
- 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 +50 -69
- package/dist/cjs/components/Variables/index.js +1 -0
- 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/{context/DashboardAppSlice.js → cjs/context/DashboardProvider/panel-group-slice.js} +18 -25
- package/dist/cjs/context/DatasourceStoreProvider.js +109 -7
- package/dist/cjs/context/TemplateVariableProvider.js +8 -1
- package/dist/cjs/context/index.js +0 -2
- package/dist/cjs/test/testDashboard.js +13 -1
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +6 -7
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +165 -0
- package/dist/components/Dashboard.d.ts +1 -4
- package/dist/components/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard.js +8 -12
- package/dist/components/Dashboard.js.map +1 -1
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +5 -5
- package/dist/components/DashboardToolbar.js.map +1 -1
- 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 +14 -14
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- 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 +24 -21
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +28 -6
- 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 +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 +17 -6
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/Panel.test.js +7 -4
- 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 +8 -12
- 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 +78 -36
- 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 +42 -0
- package/dist/components/PanelDrawer/PanelPreview.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 +13 -20
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +10 -31
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +3 -3
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/Variable.js +21 -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 +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 +48 -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/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 +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/index.d.ts +0 -2
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +0 -2
- package/dist/context/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/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +13 -1
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +6 -7
- package/dist/views/ViewDashboard/DashboardApp.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 +158 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
- package/package.json +4 -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/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.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
|
@@ -28,38 +28,53 @@ 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
37
|
const { layouts } = (0, _context.useLayouts)();
|
|
38
38
|
const [name, setName] = (0, _react.useState)(initialValues.name);
|
|
39
39
|
const [description, setDescription] = (0, _react.useState)(initialValues.description);
|
|
40
|
-
const [
|
|
40
|
+
const [groupIndex, setGroupIndex] = (0, _react.useState)(initialValues.groupIndex);
|
|
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
|
+
setGroupIndex(value);
|
|
50
62
|
};
|
|
51
63
|
const handleSubmit = (e)=>{
|
|
52
64
|
e.preventDefault();
|
|
65
|
+
if (spec === undefined) {
|
|
66
|
+
throw new Error('Cannot submit without a plugin spec');
|
|
67
|
+
}
|
|
53
68
|
const values = {
|
|
54
69
|
name,
|
|
55
70
|
description,
|
|
56
|
-
|
|
71
|
+
groupIndex,
|
|
57
72
|
kind,
|
|
58
73
|
spec
|
|
59
74
|
};
|
|
60
75
|
onSubmit(values);
|
|
61
76
|
};
|
|
62
|
-
var
|
|
77
|
+
var _title, ref1;
|
|
63
78
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("form", {
|
|
64
79
|
id: panelEditorFormId,
|
|
65
80
|
onSubmit: handleSubmit,
|
|
@@ -72,7 +87,7 @@ function PanelEditorForm(props) {
|
|
|
72
87
|
xs: 8,
|
|
73
88
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
74
89
|
required: true,
|
|
75
|
-
label: "
|
|
90
|
+
label: "Name",
|
|
76
91
|
value: name,
|
|
77
92
|
variant: "outlined",
|
|
78
93
|
onChange: (e)=>setName(e.target.value)
|
|
@@ -91,15 +106,12 @@ function PanelEditorForm(props) {
|
|
|
91
106
|
required: true,
|
|
92
107
|
labelId: "select-group",
|
|
93
108
|
label: "Group",
|
|
94
|
-
value:
|
|
109
|
+
value: groupIndex !== null && groupIndex !== void 0 ? groupIndex : 0,
|
|
95
110
|
onChange: handleGroupChange,
|
|
96
|
-
children: layouts.map((layout, index)
|
|
97
|
-
var ref1;
|
|
98
|
-
/*#__PURE__*/ return (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
111
|
+
children: layouts.map((layout, index)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
99
112
|
value: index,
|
|
100
|
-
children: (
|
|
101
|
-
}, index)
|
|
102
|
-
})
|
|
113
|
+
children: (_title = layout.title) !== null && _title !== void 0 ? _title : `Group ${index + 1}`
|
|
114
|
+
}, index))
|
|
103
115
|
})
|
|
104
116
|
]
|
|
105
117
|
})
|
|
@@ -108,40 +120,70 @@ function PanelEditorForm(props) {
|
|
|
108
120
|
item: true,
|
|
109
121
|
xs: 8,
|
|
110
122
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
111
|
-
label: "
|
|
123
|
+
label: "Description",
|
|
112
124
|
value: description,
|
|
113
125
|
variant: "outlined",
|
|
114
126
|
onChange: (e)=>setDescription(e.target.value)
|
|
115
127
|
})
|
|
116
128
|
}),
|
|
117
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
129
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
118
130
|
item: true,
|
|
119
131
|
xs: 4,
|
|
120
|
-
children:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
|
132
173
|
})
|
|
133
|
-
|
|
134
|
-
|
|
174
|
+
})
|
|
175
|
+
]
|
|
135
176
|
}),
|
|
136
177
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
137
178
|
item: true,
|
|
138
179
|
xs: 12,
|
|
139
180
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
140
181
|
FallbackComponent: _components.ErrorAlert,
|
|
141
|
-
children:
|
|
142
|
-
|
|
182
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginSpecEditor, {
|
|
183
|
+
pluginType: "Panel",
|
|
184
|
+
pluginKind: kind,
|
|
143
185
|
value: spec,
|
|
144
|
-
onChange: onSpecChange
|
|
186
|
+
onChange: pluginEditor.onSpecChange
|
|
145
187
|
})
|
|
146
188
|
})
|
|
147
189
|
})
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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, "default", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>_default
|
|
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
|
+
var ref;
|
|
32
|
+
const { layouts , deletePanelGroup } = (0, _context.useLayouts)();
|
|
33
|
+
const { deletePanelGroupDialog , closeDeletePanelGroupDialog } = (0, _context.usePanelGroupDialog)();
|
|
34
|
+
const groupIndex = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.groupIndex;
|
|
35
|
+
const handleDelete = (e)=>{
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
if (groupIndex == undefined) {
|
|
38
|
+
throw new Error('group index is undefined');
|
|
39
|
+
}
|
|
40
|
+
deletePanelGroup(groupIndex);
|
|
41
|
+
closeDeletePanelGroupDialog();
|
|
42
|
+
};
|
|
43
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Dialog, {
|
|
44
|
+
open: deletePanelGroupDialog !== undefined,
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogTitle, {
|
|
47
|
+
children: "Delete Panel Group"
|
|
48
|
+
}),
|
|
49
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
50
|
+
"aria-label": "Close",
|
|
51
|
+
onClick: ()=>closeDeletePanelGroupDialog(),
|
|
52
|
+
sx: (theme)=>({
|
|
53
|
+
position: 'absolute',
|
|
54
|
+
top: theme.spacing(0.5),
|
|
55
|
+
right: theme.spacing(0.5)
|
|
56
|
+
}),
|
|
57
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_close.default, {})
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)("form", {
|
|
60
|
+
onSubmit: handleDelete,
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogContent, {
|
|
63
|
+
sx: {
|
|
64
|
+
width: '500px'
|
|
65
|
+
},
|
|
66
|
+
children: `Are you sure you want to delete ${groupIndex !== undefined && layouts[groupIndex] !== undefined ? (ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.title : 'panel group'}? This will delete all the panels within the group.`
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
|
|
69
|
+
children: [
|
|
70
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
71
|
+
variant: "contained",
|
|
72
|
+
type: "submit",
|
|
73
|
+
children: "Delete"
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
76
|
+
onClick: ()=>closeDeletePanelGroupDialog(),
|
|
77
|
+
children: "Cancel"
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const _default = DeletePanelGroupDialog;
|
|
@@ -29,30 +29,23 @@ function _interopRequireDefault(obj) {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
const PanelGroupDialog = ()=>{
|
|
32
|
-
var ref, ref1
|
|
33
|
-
const { layouts ,
|
|
34
|
-
const { panelGroupDialog , closePanelGroupDialog } = (0, _context.
|
|
32
|
+
var ref, ref1;
|
|
33
|
+
const { layouts , updatePanelGroup } = (0, _context.useLayouts)();
|
|
34
|
+
const { panelGroupDialog , closePanelGroupDialog } = (0, _context.usePanelGroupDialog)();
|
|
35
35
|
const groupIndex = panelGroupDialog === null || panelGroupDialog === void 0 ? void 0 : panelGroupDialog.groupIndex;
|
|
36
36
|
const isEditingPanelGroup = groupIndex !== undefined;
|
|
37
|
-
const [isCollapsed, setIsCollapsed] = (0, _react.useState)(isEditingPanelGroup &&
|
|
38
|
-
const [name, setName] = (0, _react.useState)(isEditingPanelGroup ? (
|
|
37
|
+
const [isCollapsed, setIsCollapsed] = (0, _react.useState)(isEditingPanelGroup && ((ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.isCollapsed));
|
|
38
|
+
const [name, setName] = (0, _react.useState)(isEditingPanelGroup ? (ref1 = layouts[groupIndex]) === null || ref1 === void 0 ? void 0 : ref1.title : '');
|
|
39
39
|
const handleSubmit = (e)=>{
|
|
40
40
|
var ref;
|
|
41
41
|
e.preventDefault();
|
|
42
|
-
var
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
}
|
|
42
|
+
var ref1;
|
|
43
|
+
const newGroup = {
|
|
44
|
+
isCollapsed,
|
|
45
|
+
title: name !== null && name !== void 0 ? name : '',
|
|
46
|
+
items: groupIndex === undefined ? [] : (ref1 = (ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.items) !== null && ref1 !== void 0 ? ref1 : []
|
|
54
47
|
};
|
|
55
|
-
|
|
48
|
+
updatePanelGroup(newGroup, groupIndex);
|
|
56
49
|
closePanelGroupDialog();
|
|
57
50
|
};
|
|
58
51
|
const handleSelectCollapsedStateChange = (e)=>{
|
|
@@ -60,7 +53,7 @@ const PanelGroupDialog = ()=>{
|
|
|
60
53
|
setIsCollapsed(isCollapsed);
|
|
61
54
|
};
|
|
62
55
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Dialog, {
|
|
63
|
-
open:
|
|
56
|
+
open: panelGroupDialog !== undefined,
|
|
64
57
|
children: [
|
|
65
58
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogTitle, {
|
|
66
59
|
children: "Panel Group"
|
|
@@ -20,6 +20,7 @@ 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 _testDashboard = /*#__PURE__*/ _interopRequireDefault(require("../../test/testDashboard"));
|
|
23
24
|
const _panelGroupDialog = /*#__PURE__*/ _interopRequireDefault(require("./PanelGroupDialog"));
|
|
24
25
|
function _interopRequireDefault(obj) {
|
|
25
26
|
return obj && obj.__esModule ? obj : {
|
|
@@ -46,7 +47,6 @@ 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
52
|
(0, _testUtils.act)(()=>storeApi.getState().openPanelGroupDialog());
|
|
@@ -55,19 +55,14 @@ describe('Add Panel Group', ()=>{
|
|
|
55
55
|
_userEvent.default.click(_react.screen.getByText('Add'));
|
|
56
56
|
const layouts = storeApi.getState().layouts;
|
|
57
57
|
expect(layouts).toContainEqual({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
collapse: {
|
|
63
|
-
open: true
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
items: []
|
|
67
|
-
}
|
|
58
|
+
id: 3,
|
|
59
|
+
title: 'New Panel Group',
|
|
60
|
+
isCollapsed: false,
|
|
61
|
+
items: []
|
|
68
62
|
});
|
|
69
63
|
});
|
|
70
64
|
it('should edit existing panel group', async ()=>{
|
|
65
|
+
var ref;
|
|
71
66
|
const storeApi = renderDialog();
|
|
72
67
|
// Open the dialog for an existing panel group
|
|
73
68
|
(0, _testUtils.act)(()=>storeApi.getState().openPanelGroupDialog(0));
|
|
@@ -77,26 +72,10 @@ describe('Add Panel Group', ()=>{
|
|
|
77
72
|
_userEvent.default.click(_react.screen.getByText('Apply'));
|
|
78
73
|
const layouts = storeApi.getState().layouts;
|
|
79
74
|
expect(layouts).toContainEqual({
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
collapse: {
|
|
85
|
-
open: true
|
|
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
|
-
]
|
|
99
|
-
}
|
|
75
|
+
id: 0,
|
|
76
|
+
title: 'New Name',
|
|
77
|
+
isCollapsed: false,
|
|
78
|
+
items: (ref = _testDashboard.default.spec.layouts[0]) === null || ref === void 0 ? void 0 : ref.spec.items
|
|
100
79
|
});
|
|
101
80
|
});
|
|
102
81
|
});
|
|
@@ -89,9 +89,9 @@ const TIME_OPTIONS = [
|
|
|
89
89
|
];
|
|
90
90
|
function TimeRangeControls() {
|
|
91
91
|
const { timeRange , setTimeRange } = (0, _pluginSystem.useTimeRange)();
|
|
92
|
-
const
|
|
92
|
+
const dashboardDefaultTimeRange = (0, _context.useDefaultTimeRange)();
|
|
93
93
|
const { queryString } = (0, _pluginSystem.useQueryString)();
|
|
94
|
-
const defaultTimeRange = (0, _core.getDefaultTimeRange)(
|
|
94
|
+
const defaultTimeRange = (0, _core.getDefaultTimeRange)(dashboardDefaultTimeRange, queryString);
|
|
95
95
|
// selected form value can be relative or absolute, timeRange from plugin-system is only absolute
|
|
96
96
|
const [selectedTimeRange, setSelectedTimeRange] = (0, _react.useState)(defaultTimeRange);
|
|
97
97
|
const [showCustomDateSelector, setShowCustomDateSelector] = (0, _react.useState)(false);
|
|
@@ -51,7 +51,7 @@ function TemplateVariable({ name }) {
|
|
|
51
51
|
return Object.values(v).map((v)=>JSON.stringify(v.value)).join(',');
|
|
52
52
|
}
|
|
53
53
|
function ListVariable({ name }) {
|
|
54
|
-
var ref, ref1, ref2;
|
|
54
|
+
var ref, ref1, ref2, ref3;
|
|
55
55
|
const ctx = (0, _context.useTemplateVariable)(name);
|
|
56
56
|
const definition = ctx.definition;
|
|
57
57
|
const { data: variablePlugin } = (0, _pluginSystem.usePlugin)('Variable', definition.spec.plugin.kind);
|
|
@@ -65,6 +65,8 @@ function ListVariable({ name }) {
|
|
|
65
65
|
const variables = (0, _pluginSystem.useTemplateVariableValues)(dependsOnVariables);
|
|
66
66
|
const allowMultiple = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_multiple) === true;
|
|
67
67
|
const allowAllValue = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_all_value) === true;
|
|
68
|
+
var ref4;
|
|
69
|
+
const label = (ref4 = (ref = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || ref === void 0 ? void 0 : ref.label) !== null && ref4 !== void 0 ? ref4 : name;
|
|
68
70
|
let waitToLoad = false;
|
|
69
71
|
if (dependsOnVariables) {
|
|
70
72
|
waitToLoad = dependsOnVariables.some((v)=>{
|
|
@@ -98,9 +100,9 @@ function ListVariable({ name }) {
|
|
|
98
100
|
setVariableLoading,
|
|
99
101
|
setVariableOptions
|
|
100
102
|
]);
|
|
101
|
-
let value = (
|
|
102
|
-
const options = (
|
|
103
|
-
const loading = (
|
|
103
|
+
let value = (ref1 = ctx.state) === null || ref1 === void 0 ? void 0 : ref1.value;
|
|
104
|
+
const options = (ref2 = ctx.state) === null || ref2 === void 0 ? void 0 : ref2.options;
|
|
105
|
+
const loading = (ref3 = ctx.state) === null || ref3 === void 0 ? void 0 : ref3.loading;
|
|
104
106
|
// Make sure value is an array if allowMultiple is true
|
|
105
107
|
if (allowMultiple && !Array.isArray(value)) {
|
|
106
108
|
value = typeof value === 'string' ? [
|
|
@@ -155,7 +157,7 @@ function ListVariable({ name }) {
|
|
|
155
157
|
children: [
|
|
156
158
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
157
159
|
id: name,
|
|
158
|
-
children:
|
|
160
|
+
children: label
|
|
159
161
|
}),
|
|
160
162
|
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Select, {
|
|
161
163
|
sx: {
|
|
@@ -195,13 +197,19 @@ function ListVariable({ name }) {
|
|
|
195
197
|
}
|
|
196
198
|
function TextVariable({ name }) {
|
|
197
199
|
const { state } = (0, _context.useTemplateVariable)(name);
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
const
|
|
200
|
+
var ref;
|
|
201
|
+
const [tempValue, setTempValue] = (0, _react.useState)((ref = state === null || state === void 0 ? void 0 : state.value) !== null && ref !== void 0 ? ref : '');
|
|
202
|
+
const { setVariableValue } = (0, _context.useTemplateVariableActions)();
|
|
203
|
+
(0, _react.useEffect)(()=>{
|
|
204
|
+
var ref;
|
|
205
|
+
setTempValue((ref = state === null || state === void 0 ? void 0 : state.value) !== null && ref !== void 0 ? ref : '');
|
|
206
|
+
}, [
|
|
207
|
+
state === null || state === void 0 ? void 0 : state.value
|
|
208
|
+
]);
|
|
201
209
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
onBlur: (
|
|
210
|
+
value: tempValue,
|
|
211
|
+
onChange: (e)=>setTempValue(e.target.value),
|
|
212
|
+
onBlur: ()=>setVariableValue(name, tempValue),
|
|
205
213
|
placeholder: name,
|
|
206
214
|
label: name
|
|
207
215
|
});
|