@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
|
@@ -21,22 +21,17 @@ Object.defineProperty(exports, "Dashboard", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _components = require("@perses-dev/components");
|
|
24
|
+
const _context = require("../context");
|
|
24
25
|
const _gridLayout = require("./GridLayout");
|
|
25
26
|
function Dashboard(props) {
|
|
26
|
-
const
|
|
27
|
+
const panelGroupIds = (0, _context.usePanelGroupIds)();
|
|
27
28
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
28
|
-
...
|
|
29
|
+
...props,
|
|
29
30
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
30
31
|
FallbackComponent: _components.ErrorAlert,
|
|
31
|
-
children:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
renderGridItemContent: (definition, groupIndex)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridLayout.GridItemContent, {
|
|
35
|
-
content: definition.content,
|
|
36
|
-
spec: spec,
|
|
37
|
-
groupIndex: groupIndex
|
|
38
|
-
})
|
|
39
|
-
}, `${JSON.stringify(spec.layouts)} ${idx}`))
|
|
32
|
+
children: panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridLayout.GridLayout, {
|
|
33
|
+
panelGroupId: panelGroupId
|
|
34
|
+
}, panelGroupId))
|
|
40
35
|
})
|
|
41
36
|
});
|
|
42
37
|
}
|
|
@@ -34,11 +34,17 @@ function _interopRequireDefault(obj) {
|
|
|
34
34
|
const DashboardToolbar = (props)=>{
|
|
35
35
|
const { dashboardName } = props;
|
|
36
36
|
const { isEditMode , setEditMode } = (0, _context.useEditMode)();
|
|
37
|
-
const {
|
|
37
|
+
const { openAddPanelGroup , openAddPanel , reset , save } = (0, _context.useDashboardActions)();
|
|
38
|
+
const isLaptopSize = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('sm'));
|
|
38
39
|
const onEditButtonClick = ()=>{
|
|
39
40
|
setEditMode(true);
|
|
40
41
|
};
|
|
41
42
|
const onCancelButtonClick = ()=>{
|
|
43
|
+
reset();
|
|
44
|
+
setEditMode(false);
|
|
45
|
+
};
|
|
46
|
+
const onSave = ()=>{
|
|
47
|
+
save();
|
|
42
48
|
setEditMode(false);
|
|
43
49
|
};
|
|
44
50
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
@@ -69,6 +75,7 @@ const DashboardToolbar = (props)=>{
|
|
|
69
75
|
children: [
|
|
70
76
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
71
77
|
variant: "contained",
|
|
78
|
+
onClick: onSave,
|
|
72
79
|
children: "Save"
|
|
73
80
|
}),
|
|
74
81
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
@@ -85,6 +92,7 @@ const DashboardToolbar = (props)=>{
|
|
|
85
92
|
sx: {
|
|
86
93
|
display: 'flex',
|
|
87
94
|
width: '100%',
|
|
95
|
+
alignItems: 'flex-start',
|
|
88
96
|
padding: (theme)=>theme.spacing(2)
|
|
89
97
|
},
|
|
90
98
|
children: [
|
|
@@ -101,14 +109,12 @@ const DashboardToolbar = (props)=>{
|
|
|
101
109
|
children: [
|
|
102
110
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
103
111
|
startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_plusBoxOutline.default, {}),
|
|
104
|
-
onClick:
|
|
112
|
+
onClick: openAddPanelGroup,
|
|
105
113
|
children: "Add Panel Group"
|
|
106
114
|
}),
|
|
107
115
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
108
116
|
startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_chartBoxPlusOutline.default, {}),
|
|
109
|
-
onClick:
|
|
110
|
-
groupIndex: 0
|
|
111
|
-
}),
|
|
117
|
+
onClick: openAddPanel,
|
|
112
118
|
children: "Add Panel"
|
|
113
119
|
}),
|
|
114
120
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.TimeRangeControls, {})
|
|
@@ -139,7 +145,7 @@ const DashboardToolbar = (props)=>{
|
|
|
139
145
|
},
|
|
140
146
|
children: [
|
|
141
147
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components1.TimeRangeControls, {}),
|
|
142
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
148
|
+
isLaptopSize && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
143
149
|
variant: "outlined",
|
|
144
150
|
startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencilOutline.default, {}),
|
|
145
151
|
onClick: onEditButtonClick,
|
|
@@ -19,21 +19,13 @@ Object.defineProperty(exports, "GridItemContent", {
|
|
|
19
19
|
get: ()=>GridItemContent
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const
|
|
23
|
-
const _core = require("@perses-dev/core");
|
|
22
|
+
const _context = require("../../context");
|
|
24
23
|
const _panel = require("../Panel/Panel");
|
|
25
24
|
function GridItemContent(props) {
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
panelKey: panelsKey
|
|
33
|
-
});
|
|
34
|
-
} catch (err) {
|
|
35
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorAlert, {
|
|
36
|
-
error: err
|
|
37
|
-
});
|
|
38
|
-
}
|
|
25
|
+
const { panelGroupItemId } = props;
|
|
26
|
+
const panelDefinition = (0, _context.usePanel)(panelGroupItemId);
|
|
27
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
|
|
28
|
+
definition: panelDefinition,
|
|
29
|
+
panelGroupItemId: panelGroupItemId
|
|
30
|
+
});
|
|
39
31
|
}
|
|
@@ -22,29 +22,18 @@ const _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
const _react = require("react");
|
|
23
23
|
const _reactGridLayout = require("react-grid-layout");
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
|
+
const _components = require("@perses-dev/components");
|
|
25
26
|
const _styles = require("../../css/styles");
|
|
26
27
|
const _context = require("../../context");
|
|
27
28
|
const _gridTitle = require("./GridTitle");
|
|
29
|
+
const _gridItemContent = require("./GridItemContent");
|
|
28
30
|
const ResponsiveGridLayout = (0, _reactGridLayout.WidthProvider)(_reactGridLayout.Responsive);
|
|
29
31
|
function GridLayout(props) {
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
var
|
|
33
|
-
const [isOpen, setIsOpen] = (0, _react.useState)((
|
|
32
|
+
const { panelGroupId , ...others } = props;
|
|
33
|
+
const groupDefinition = (0, _context.usePanelGroup)(panelGroupId);
|
|
34
|
+
var ref;
|
|
35
|
+
const [isOpen, setIsOpen] = (0, _react.useState)((ref = !groupDefinition.isCollapsed) !== null && ref !== void 0 ? ref : true);
|
|
34
36
|
const { isEditMode } = (0, _context.useEditMode)();
|
|
35
|
-
const gridItems = [];
|
|
36
|
-
spec.items.forEach((item, idx)=>{
|
|
37
|
-
const { x , y , width: w , height: h } = item;
|
|
38
|
-
gridItems.push(/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
39
|
-
"data-grid": {
|
|
40
|
-
x,
|
|
41
|
-
y,
|
|
42
|
-
w,
|
|
43
|
-
h
|
|
44
|
-
},
|
|
45
|
-
children: renderGridItemContent(item, groupIndex)
|
|
46
|
-
}, idx));
|
|
47
|
-
});
|
|
48
37
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
49
38
|
children: [
|
|
50
39
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.GlobalStyles, {
|
|
@@ -59,10 +48,10 @@ function GridLayout(props) {
|
|
|
59
48
|
}
|
|
60
49
|
},
|
|
61
50
|
children: [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
title:
|
|
65
|
-
collapse:
|
|
51
|
+
groupDefinition.title !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridTitle.GridTitle, {
|
|
52
|
+
panelGroupId: panelGroupId,
|
|
53
|
+
title: groupDefinition.title,
|
|
54
|
+
collapse: groupDefinition.isCollapsed === undefined ? undefined : {
|
|
66
55
|
isOpen,
|
|
67
56
|
onToggleOpen: ()=>setIsOpen((current)=>!current)
|
|
68
57
|
}
|
|
@@ -93,7 +82,23 @@ function GridLayout(props) {
|
|
|
93
82
|
],
|
|
94
83
|
isDraggable: isEditMode,
|
|
95
84
|
isResizable: isEditMode,
|
|
96
|
-
children:
|
|
85
|
+
children: groupDefinition.items.map(({ x , y , width , height }, itemIndex)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
86
|
+
"data-grid": {
|
|
87
|
+
x,
|
|
88
|
+
y,
|
|
89
|
+
w: width,
|
|
90
|
+
h: height
|
|
91
|
+
},
|
|
92
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
93
|
+
FallbackComponent: _components.ErrorAlert,
|
|
94
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridItemContent.GridItemContent, {
|
|
95
|
+
panelGroupItemId: {
|
|
96
|
+
panelGroupId,
|
|
97
|
+
itemIndex
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
}, itemIndex))
|
|
97
102
|
})
|
|
98
103
|
})
|
|
99
104
|
]
|
|
@@ -19,12 +19,15 @@ Object.defineProperty(exports, "GridTitle", {
|
|
|
19
19
|
get: ()=>GridTitle
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
22
23
|
const _material = require("@mui/material");
|
|
23
24
|
const _chevronUp = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ChevronUp"));
|
|
24
25
|
const _chevronDown = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ChevronDown"));
|
|
25
26
|
const _plus = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Plus"));
|
|
26
27
|
const _pencilOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PencilOutline"));
|
|
27
|
-
const
|
|
28
|
+
const _arrowUp = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ArrowUp"));
|
|
29
|
+
const _arrowDown = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ArrowDown"));
|
|
30
|
+
const _deleteOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/DeleteOutline"));
|
|
28
31
|
const _context = require("../../context");
|
|
29
32
|
function _interopRequireDefault(obj) {
|
|
30
33
|
return obj && obj.__esModule ? obj : {
|
|
@@ -32,9 +35,9 @@ function _interopRequireDefault(obj) {
|
|
|
32
35
|
};
|
|
33
36
|
}
|
|
34
37
|
function GridTitle(props) {
|
|
35
|
-
const {
|
|
38
|
+
const { panelGroupId , title , collapse } = props;
|
|
36
39
|
const [isHovered, setIsHovered] = (0, _react.useState)(false);
|
|
37
|
-
const {
|
|
40
|
+
const { openAddPanel , openEditPanelGroup , deletePanelGroup , moveUp , moveDown } = (0, _context.usePanelGroupActions)(panelGroupId);
|
|
38
41
|
const { isEditMode } = (0, _context.useEditMode)();
|
|
39
42
|
const text = /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
40
43
|
variant: "h2",
|
|
@@ -67,14 +70,31 @@ function GridTitle(props) {
|
|
|
67
70
|
},
|
|
68
71
|
children: [
|
|
69
72
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}),
|
|
73
|
+
"aria-label": "add panel to group",
|
|
74
|
+
onClick: openAddPanel,
|
|
73
75
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_plus.default, {})
|
|
74
76
|
}),
|
|
75
77
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
76
|
-
|
|
78
|
+
"aria-label": "edit group",
|
|
79
|
+
onClick: openEditPanelGroup,
|
|
77
80
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencilOutline.default, {})
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
83
|
+
"aria-label": "delete group",
|
|
84
|
+
onClick: deletePanelGroup,
|
|
85
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_deleteOutline.default, {})
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
88
|
+
"aria-label": "move group down",
|
|
89
|
+
disabled: moveDown === undefined,
|
|
90
|
+
onClick: moveDown,
|
|
91
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowDown.default, {})
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
94
|
+
"aria-label": "move group up",
|
|
95
|
+
disabled: moveUp === undefined,
|
|
96
|
+
onClick: moveUp,
|
|
97
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowUp.default, {})
|
|
78
98
|
})
|
|
79
99
|
]
|
|
80
100
|
})
|
|
@@ -0,0 +1,95 @@
|
|
|
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 DeletePanelDialog = ()=>{
|
|
31
|
+
const { deletePanelDialog , closeDeletePanelDialog } = (0, _context.useDeletePanelDialog)();
|
|
32
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Dialog, {
|
|
33
|
+
open: deletePanelDialog !== undefined,
|
|
34
|
+
children: [
|
|
35
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogTitle, {
|
|
36
|
+
children: "Delete Panel"
|
|
37
|
+
}),
|
|
38
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
39
|
+
"aria-label": "Close",
|
|
40
|
+
onClick: ()=>closeDeletePanelDialog(),
|
|
41
|
+
sx: (theme)=>({
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
top: theme.spacing(0.5),
|
|
44
|
+
right: theme.spacing(0.5)
|
|
45
|
+
}),
|
|
46
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_close.default, {})
|
|
47
|
+
}),
|
|
48
|
+
deletePanelDialog && /*#__PURE__*/ (0, _jsxRuntime.jsx)(DeletePanelForm, {
|
|
49
|
+
deletePanelDialog: deletePanelDialog
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const DeletePanelForm = ({ deletePanelDialog })=>{
|
|
55
|
+
const { deletePanels , closeDeletePanelDialog } = (0, _context.useDeletePanelDialog)();
|
|
56
|
+
const handleDelete = (e)=>{
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
const { panelGroupItemId } = deletePanelDialog;
|
|
59
|
+
deletePanels([
|
|
60
|
+
panelGroupItemId
|
|
61
|
+
]);
|
|
62
|
+
closeDeletePanelDialog();
|
|
63
|
+
};
|
|
64
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("form", {
|
|
65
|
+
onSubmit: handleDelete,
|
|
66
|
+
children: [
|
|
67
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogContent, {
|
|
68
|
+
sx: {
|
|
69
|
+
width: '500px'
|
|
70
|
+
},
|
|
71
|
+
children: [
|
|
72
|
+
"Are you sure you want to delete ",
|
|
73
|
+
deletePanelDialog.panelName,
|
|
74
|
+
" from ",
|
|
75
|
+
deletePanelDialog.panelGroupName,
|
|
76
|
+
"? This action cannot be undone."
|
|
77
|
+
]
|
|
78
|
+
}),
|
|
79
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
|
|
80
|
+
children: [
|
|
81
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
82
|
+
variant: "contained",
|
|
83
|
+
type: "submit",
|
|
84
|
+
children: "Delete"
|
|
85
|
+
}),
|
|
86
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
87
|
+
onClick: ()=>closeDeletePanelDialog(),
|
|
88
|
+
children: "Cancel"
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const _default = DeletePanelDialog;
|
|
@@ -26,6 +26,7 @@ const _components = require("@perses-dev/components");
|
|
|
26
26
|
const _material = require("@mui/material");
|
|
27
27
|
const _informationOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/InformationOutline"));
|
|
28
28
|
const _pencil = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Pencil"));
|
|
29
|
+
const _deleteOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/DeleteOutline"));
|
|
29
30
|
const _dragVertical = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/DragVertical"));
|
|
30
31
|
const _context = require("../../context");
|
|
31
32
|
const _panelContent = require("./PanelContent");
|
|
@@ -35,7 +36,7 @@ function _interopRequireDefault(obj) {
|
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
function Panel(props) {
|
|
38
|
-
const { definition ,
|
|
39
|
+
const { definition , panelGroupItemId , ...others } = props;
|
|
39
40
|
const [contentElement, setContentElement] = (0, _react.useState)(null);
|
|
40
41
|
const [isHovered, setIsHovered] = (0, _react.useState)(false);
|
|
41
42
|
const { width , height } = (0, _useResizeObserver.default)({
|
|
@@ -59,13 +60,7 @@ function Panel(props) {
|
|
|
59
60
|
// TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart
|
|
60
61
|
const panelPadding = 1.5;
|
|
61
62
|
const { isEditMode } = (0, _context.useEditMode)();
|
|
62
|
-
const {
|
|
63
|
-
const handleEditButtonClick = ()=>{
|
|
64
|
-
openPanelDrawer({
|
|
65
|
-
groupIndex,
|
|
66
|
-
panelKey
|
|
67
|
-
});
|
|
68
|
-
};
|
|
63
|
+
const { openEditPanel , openDeletePanelDialog } = (0, _context.usePanelActions)(panelGroupItemId);
|
|
69
64
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Card, {
|
|
70
65
|
ref: ref,
|
|
71
66
|
sx: {
|
|
@@ -125,9 +120,15 @@ function Panel(props) {
|
|
|
125
120
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(IconButton, {
|
|
126
121
|
"aria-label": "edit panel",
|
|
127
122
|
size: "small",
|
|
128
|
-
onClick:
|
|
123
|
+
onClick: openEditPanel,
|
|
129
124
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencil.default, {})
|
|
130
125
|
}),
|
|
126
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(IconButton, {
|
|
127
|
+
"aria-label": "delete panel",
|
|
128
|
+
size: "small",
|
|
129
|
+
onClick: openDeletePanelDialog,
|
|
130
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_deleteOutline.default, {})
|
|
131
|
+
}),
|
|
131
132
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(IconButton, {
|
|
132
133
|
"aria-label": "drag handle",
|
|
133
134
|
size: "small",
|
|
@@ -165,7 +166,8 @@ function Panel(props) {
|
|
|
165
166
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
166
167
|
FallbackComponent: _components.ErrorAlert,
|
|
167
168
|
children: inView === true && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelContent.PanelContent, {
|
|
168
|
-
|
|
169
|
+
panelPluginKind: definition.spec.plugin.kind,
|
|
170
|
+
spec: definition.spec.plugin.spec,
|
|
169
171
|
contentDimensions: contentDimensions
|
|
170
172
|
})
|
|
171
173
|
})
|
|
@@ -16,11 +16,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
18
18
|
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
19
|
-
require("intersection-observer");
|
|
20
19
|
const _react = require("@testing-library/react");
|
|
20
|
+
const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
|
|
21
21
|
const _test = require("../../test");
|
|
22
22
|
const _context = require("../../context");
|
|
23
23
|
const _panel = require("./Panel");
|
|
24
|
+
function _interopRequireDefault(obj) {
|
|
25
|
+
return obj && obj.__esModule ? obj : {
|
|
26
|
+
default: obj
|
|
27
|
+
};
|
|
28
|
+
}
|
|
24
29
|
describe('Panel', ()=>{
|
|
25
30
|
// Helper to create panel props for rendering tests
|
|
26
31
|
const createPanelProps = ()=>{
|
|
@@ -38,8 +43,10 @@ describe('Panel', ()=>{
|
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
},
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
panelGroupItemId: {
|
|
47
|
+
panelGroupId: 0,
|
|
48
|
+
itemIndex: 0
|
|
49
|
+
}
|
|
43
50
|
};
|
|
44
51
|
};
|
|
45
52
|
// Helper to render the panel with some context set
|
|
@@ -66,8 +73,10 @@ describe('Panel', ()=>{
|
|
|
66
73
|
});
|
|
67
74
|
it('should render edit icons when in edit mode', ()=>{
|
|
68
75
|
renderPanel(true);
|
|
69
|
-
_react.screen.
|
|
70
|
-
|
|
71
|
-
_react.screen.
|
|
76
|
+
const panelTitle = _react.screen.getByText('Fake Panel');
|
|
77
|
+
_userEvent.default.hover(panelTitle);
|
|
78
|
+
_react.screen.getByLabelText('drag handle');
|
|
79
|
+
_react.screen.getByLabelText('edit panel');
|
|
80
|
+
_react.screen.getByLabelText('delete panel');
|
|
72
81
|
});
|
|
73
82
|
});
|
|
@@ -22,7 +22,7 @@ const _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
24
|
function PanelContent(props) {
|
|
25
|
-
const {
|
|
25
|
+
const { panelPluginKind , contentDimensions , ...others } = props;
|
|
26
26
|
const { data: plugin , isLoading } = (0, _pluginSystem.usePlugin)('Panel', panelPluginKind, {
|
|
27
27
|
useErrorBoundary: true
|
|
28
28
|
});
|
|
@@ -38,6 +38,7 @@ function PanelContent(props) {
|
|
|
38
38
|
throw new Error(`Missing PanelComponent from panel plugin for kind '${panelPluginKind}'`);
|
|
39
39
|
}
|
|
40
40
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(PanelComponent, {
|
|
41
|
-
...
|
|
41
|
+
...others,
|
|
42
|
+
contentDimensions: contentDimensions
|
|
42
43
|
});
|
|
43
44
|
}
|
|
@@ -23,27 +23,25 @@ const _react = require("react");
|
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
24
|
const _components = require("@perses-dev/components");
|
|
25
25
|
const _context = require("../../context");
|
|
26
|
-
const _panelEditorModel = require("./panel-editor-model");
|
|
27
26
|
const _panelEditorForm = require("./PanelEditorForm");
|
|
28
27
|
const PanelDrawer = ()=>{
|
|
29
|
-
const
|
|
30
|
-
const model = (0, _panelEditorModel.usePanelDrawerModel)();
|
|
28
|
+
const panelEditor = (0, _context.usePanelEditor)();
|
|
31
29
|
// When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
|
|
32
30
|
const [isClosing, setIsClosing] = (0, _react.useState)(false);
|
|
33
31
|
const handleClose = ()=>setIsClosing(true);
|
|
34
32
|
// Don't call closeDrawer on the store until the Drawer has completely transitioned out
|
|
35
33
|
const handleExited = ()=>{
|
|
36
|
-
|
|
34
|
+
panelEditor === null || panelEditor === void 0 ? void 0 : panelEditor.close();
|
|
37
35
|
setIsClosing(false);
|
|
38
36
|
};
|
|
39
37
|
// Drawer is open if we have a model and we're not transitioning out
|
|
40
|
-
const isOpen =
|
|
38
|
+
const isOpen = panelEditor !== undefined && isClosing === false;
|
|
41
39
|
const handleSubmit = (values)=>{
|
|
42
40
|
// 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 (
|
|
41
|
+
if (panelEditor === undefined) {
|
|
44
42
|
throw new Error('Cannot apply changes');
|
|
45
43
|
}
|
|
46
|
-
|
|
44
|
+
panelEditor.applyChanges(values);
|
|
47
45
|
handleClose();
|
|
48
46
|
};
|
|
49
47
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Drawer, {
|
|
@@ -52,7 +50,7 @@ const PanelDrawer = ()=>{
|
|
|
52
50
|
SlideProps: {
|
|
53
51
|
onExited: handleExited
|
|
54
52
|
},
|
|
55
|
-
children:
|
|
53
|
+
children: panelEditor !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
56
54
|
children: [
|
|
57
55
|
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
58
56
|
sx: {
|
|
@@ -63,9 +61,12 @@ const PanelDrawer = ()=>{
|
|
|
63
61
|
borderBottom: (theme)=>`1px solid ${theme.palette.grey[100]}`
|
|
64
62
|
},
|
|
65
63
|
children: [
|
|
66
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
64
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
67
65
|
variant: "h2",
|
|
68
|
-
children:
|
|
66
|
+
children: [
|
|
67
|
+
panelEditor.mode,
|
|
68
|
+
" Panel"
|
|
69
|
+
]
|
|
69
70
|
}),
|
|
70
71
|
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
71
72
|
direction: "row",
|
|
@@ -78,7 +79,7 @@ const PanelDrawer = ()=>{
|
|
|
78
79
|
type: "submit",
|
|
79
80
|
variant: "contained",
|
|
80
81
|
form: _panelEditorForm.panelEditorFormId,
|
|
81
|
-
children:
|
|
82
|
+
children: panelEditor.mode === 'Add' ? 'Add' : 'Apply'
|
|
82
83
|
}),
|
|
83
84
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
84
85
|
variant: "outlined",
|
|
@@ -91,7 +92,7 @@ const PanelDrawer = ()=>{
|
|
|
91
92
|
}),
|
|
92
93
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelEditorForm.PanelEditorForm, {
|
|
93
94
|
onSubmit: handleSubmit,
|
|
94
|
-
initialValues:
|
|
95
|
+
initialValues: panelEditor.initialValues
|
|
95
96
|
})
|
|
96
97
|
]
|
|
97
98
|
})
|
|
@@ -30,7 +30,7 @@ function _interopRequireDefault(obj) {
|
|
|
30
30
|
describe('Panel Drawer', ()=>{
|
|
31
31
|
const renderPanelDrawer = ()=>{
|
|
32
32
|
const { addMockPlugin , pluginRegistryProps } = (0, _test.mockPluginRegistryProps)();
|
|
33
|
-
addMockPlugin('Panel', '
|
|
33
|
+
addMockPlugin('Panel', 'TimeSeriesChart', _test.FAKE_PANEL_PLUGIN);
|
|
34
34
|
const { store , DashboardProviderSpy } = (0, _test.createDashboardProviderSpy)();
|
|
35
35
|
(0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
|
|
36
36
|
...pluginRegistryProps,
|
|
@@ -54,10 +54,8 @@ describe('Panel Drawer', ()=>{
|
|
|
54
54
|
it('should add new panel', async ()=>{
|
|
55
55
|
const storeApi = renderPanelDrawer();
|
|
56
56
|
// Open the drawer for a new panel (i.e. no panel key)
|
|
57
|
-
(0, _testUtils.act)(()=>storeApi.getState().
|
|
58
|
-
|
|
59
|
-
}));
|
|
60
|
-
const nameInput = await _react.screen.findByLabelText(/Panel Name/);
|
|
57
|
+
(0, _testUtils.act)(()=>storeApi.getState().openAddPanel(0));
|
|
58
|
+
const nameInput = await _react.screen.findByLabelText(/Name/);
|
|
61
59
|
_userEvent.default.type(nameInput, 'New Panel');
|
|
62
60
|
_userEvent.default.click(_react.screen.getByText('Add'));
|
|
63
61
|
// TODO: Assert drawer is closed?
|
|
@@ -68,8 +66,7 @@ describe('Panel Drawer', ()=>{
|
|
|
68
66
|
kind: 'Panel',
|
|
69
67
|
spec: {
|
|
70
68
|
display: {
|
|
71
|
-
name: 'New Panel'
|
|
72
|
-
description: ''
|
|
69
|
+
name: 'New Panel'
|
|
73
70
|
},
|
|
74
71
|
plugin: {
|
|
75
72
|
kind: '',
|
|
@@ -82,11 +79,11 @@ describe('Panel Drawer', ()=>{
|
|
|
82
79
|
it('should edit an existing panel', async ()=>{
|
|
83
80
|
const storeApi = renderPanelDrawer();
|
|
84
81
|
// Open the drawer for an existing panel
|
|
85
|
-
(0, _testUtils.act)(()=>storeApi.getState().
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
(0, _testUtils.act)(()=>storeApi.getState().openEditPanel({
|
|
83
|
+
panelGroupId: 0,
|
|
84
|
+
itemIndex: 0
|
|
88
85
|
}));
|
|
89
|
-
const nameInput = await _react.screen.findByLabelText(/
|
|
86
|
+
const nameInput = await _react.screen.findByLabelText(/Name/);
|
|
90
87
|
_userEvent.default.clear(nameInput);
|
|
91
88
|
_userEvent.default.type(nameInput, 'cpu usage');
|
|
92
89
|
_userEvent.default.click(_react.screen.getByText('Apply'));
|
|
@@ -96,8 +93,7 @@ describe('Panel Drawer', ()=>{
|
|
|
96
93
|
kind: 'Panel',
|
|
97
94
|
spec: {
|
|
98
95
|
display: {
|
|
99
|
-
name: 'cpu usage'
|
|
100
|
-
description: ''
|
|
96
|
+
name: 'cpu usage'
|
|
101
97
|
},
|
|
102
98
|
plugin: {
|
|
103
99
|
kind: 'TimeSeriesChart',
|