@perses-dev/dashboards 0.11.0 → 0.13.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 → Dashboard/Dashboard.js} +2 -2
- package/dist/cjs/components/Dashboard/index.js +28 -0
- package/dist/cjs/components/{DashboardToolbar.js → DashboardToolbar/DashboardToolbar.js} +9 -16
- package/dist/cjs/components/DashboardToolbar/index.js +28 -0
- package/dist/cjs/components/{Panel → DeletePanelDialog}/DeletePanelDialog.js +4 -7
- package/dist/cjs/components/DeletePanelDialog/index.js +28 -0
- package/dist/cjs/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.js +0 -0
- package/dist/cjs/components/DeletePanelGroupDialog/index.js +28 -0
- package/dist/cjs/components/GridLayout/GridItemContent.js +11 -1
- package/dist/cjs/components/GridLayout/GridLayout.js +14 -16
- package/dist/cjs/components/Panel/Panel.js +30 -90
- package/dist/cjs/components/Panel/Panel.test.js +93 -46
- package/dist/cjs/components/Panel/PanelHeader.js +116 -0
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +21 -19
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +13 -20
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +16 -16
- package/dist/cjs/components/PanelGroupDialog/index.js +0 -1
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +1 -1
- package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +67 -0
- package/dist/cjs/components/UnsavedChangesConfirmationDialog/index.js +28 -0
- package/dist/cjs/components/Variables/Variable.js +18 -11
- package/dist/cjs/components/Variables/VariableEditor.js +7 -6
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +9 -5
- package/dist/cjs/components/index.js +4 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +32 -20
- package/dist/cjs/context/DashboardProvider/common.js +10 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +14 -16
- package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +70 -0
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +85 -0
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +74 -67
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +6 -19
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +54 -164
- package/dist/cjs/context/DashboardProvider/panel-slice.js +25 -0
- package/dist/cjs/context/{TemplateVariableProvider.js → TemplateVariableProvider/TemplateVariableProvider.js} +25 -12
- package/dist/cjs/context/TemplateVariableProvider/index.js +28 -0
- package/dist/cjs/context/TemplateVariableProvider/query-params.js +79 -0
- package/dist/cjs/context/TemplateVariableProvider/query-params.test.js +82 -0
- package/dist/cjs/context/index.js +1 -1
- package/dist/cjs/context/useDashboard.js +94 -0
- package/dist/cjs/test/plugin-registry.js +14 -54
- package/dist/cjs/test/render.js +6 -1
- package/dist/cjs/utils/component-ids.js +31 -0
- package/dist/cjs/utils/time-range-params.js +14 -8
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +40 -11
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +1 -1
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +1 -1
- package/dist/components/{Dashboard.d.ts → Dashboard/Dashboard.d.ts} +0 -0
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -0
- package/dist/components/{Dashboard.js → Dashboard/Dashboard.js} +2 -2
- package/dist/components/Dashboard/Dashboard.js.map +1 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/index.d.ts.map +1 -0
- package/dist/components/Dashboard/index.js +15 -0
- package/dist/components/Dashboard/index.js.map +1 -0
- package/dist/components/{DashboardToolbar.d.ts → DashboardToolbar/DashboardToolbar.d.ts} +2 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -0
- package/dist/components/{DashboardToolbar.js → DashboardToolbar/DashboardToolbar.js} +5 -12
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -0
- package/dist/components/DashboardToolbar/index.d.ts +2 -0
- package/dist/components/DashboardToolbar/index.d.ts.map +1 -0
- package/dist/components/DashboardToolbar/index.js +15 -0
- package/dist/components/DashboardToolbar/index.js.map +1 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +3 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -0
- package/dist/components/{Panel → DeletePanelDialog}/DeletePanelDialog.js +3 -6
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -0
- package/dist/components/DeletePanelDialog/index.d.ts +2 -0
- package/dist/components/DeletePanelDialog/index.d.ts.map +1 -0
- package/dist/components/DeletePanelDialog/index.js +15 -0
- package/dist/components/DeletePanelDialog/index.js.map +1 -0
- package/dist/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.d.ts +0 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
- package/dist/components/{PanelGroupDialog → DeletePanelGroupDialog}/DeletePanelGroupDialog.js +0 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
- package/dist/components/DeletePanelGroupDialog/index.d.ts +2 -0
- package/dist/components/DeletePanelGroupDialog/index.d.ts.map +1 -0
- package/dist/components/DeletePanelGroupDialog/index.js +15 -0
- package/dist/components/DeletePanelGroupDialog/index.js.map +1 -0
- package/dist/components/GridLayout/GridItemContent.d.ts +2 -2
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +12 -2
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +16 -18
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +3 -3
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +32 -92
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/Panel.test.js +95 -48
- package/dist/components/Panel/Panel.test.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +16 -0
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -0
- package/dist/components/Panel/PanelHeader.js +105 -0
- package/dist/components/Panel/PanelHeader.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.js +22 -20
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +2 -2
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +13 -20
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +16 -16
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
- package/dist/components/PanelGroupDialog/index.d.ts +0 -1
- package/dist/components/PanelGroupDialog/index.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/index.js +0 -1
- package/dist/components/PanelGroupDialog/index.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +8 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +56 -0
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +2 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +1 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.js +15 -0
- package/dist/components/UnsavedChangesConfirmationDialog/index.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +19 -12
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +7 -6
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +9 -5
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +4 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +8 -5
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +34 -22
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +7 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js +8 -1
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +6 -6
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +14 -16
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +23 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.js +64 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts +36 -0
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-slice.js +81 -0
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +3 -1
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +6 -35
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +74 -67
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -8
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +6 -19
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +14 -44
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +46 -162
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.d.ts +14 -0
- package/dist/context/DashboardProvider/panel-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-slice.js +21 -0
- package/dist/context/DashboardProvider/panel-slice.js.map +1 -0
- package/dist/context/{TemplateVariableProvider.d.ts → TemplateVariableProvider/TemplateVariableProvider.d.ts} +0 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -0
- package/dist/context/{TemplateVariableProvider.js → TemplateVariableProvider/TemplateVariableProvider.js} +25 -12
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -0
- package/dist/context/TemplateVariableProvider/index.d.ts +2 -0
- package/dist/context/TemplateVariableProvider/index.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/index.js +15 -0
- package/dist/context/TemplateVariableProvider/index.js.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.d.ts +12 -0
- package/dist/context/TemplateVariableProvider/query-params.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.js +64 -0
- package/dist/context/TemplateVariableProvider/query-params.js.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.test.d.ts +2 -0
- package/dist/context/TemplateVariableProvider/query-params.test.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/query-params.test.js +80 -0
- package/dist/context/TemplateVariableProvider/query-params.test.js.map +1 -0
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboard.d.ts +6 -0
- package/dist/context/useDashboard.d.ts.map +1 -0
- package/dist/context/useDashboard.js +88 -0
- package/dist/context/useDashboard.js.map +1 -0
- package/dist/test/plugin-registry.d.ts +2 -11
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +12 -49
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +6 -1
- package/dist/test/render.js.map +1 -1
- package/dist/utils/component-ids.d.ts +8 -0
- package/dist/utils/component-ids.d.ts.map +1 -0
- package/dist/utils/component-ids.js +27 -0
- package/dist/utils/component-ids.js.map +1 -0
- package/dist/utils/time-range-params.d.ts.map +1 -1
- package/dist/utils/time-range-params.js +15 -9
- package/dist/utils/time-range-params.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +40 -6
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
- package/package.json +4 -4
- package/dist/cjs/context/useDashboardSpec.js +0 -61
- package/dist/components/Dashboard.d.ts.map +0 -1
- package/dist/components/Dashboard.js.map +0 -1
- package/dist/components/DashboardToolbar.d.ts.map +0 -1
- package/dist/components/DashboardToolbar.js.map +0 -1
- package/dist/components/Panel/DeletePanelDialog.d.ts +0 -5
- package/dist/components/Panel/DeletePanelDialog.d.ts.map +0 -1
- package/dist/components/Panel/DeletePanelDialog.js.map +0 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +0 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +0 -1
- package/dist/context/TemplateVariableProvider.d.ts.map +0 -1
- package/dist/context/TemplateVariableProvider.js.map +0 -1
- package/dist/context/useDashboardSpec.d.ts +0 -3
- package/dist/context/useDashboardSpec.d.ts.map +0 -1
- package/dist/context/useDashboardSpec.js +0 -55
- package/dist/context/useDashboardSpec.js.map +0 -1
|
@@ -0,0 +1,116 @@
|
|
|
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, "PanelHeader", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>PanelHeader
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _components = require("@perses-dev/components");
|
|
24
|
+
const _informationOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/InformationOutline"));
|
|
25
|
+
const _pencilOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PencilOutline"));
|
|
26
|
+
const _deleteOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/DeleteOutline"));
|
|
27
|
+
const _dragVertical = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/DragVertical"));
|
|
28
|
+
function _interopRequireDefault(obj) {
|
|
29
|
+
return obj && obj.__esModule ? obj : {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function PanelHeader({ id , title , description , editHandlers , isHovered , sx , ...rest }) {
|
|
34
|
+
const titleElementId = `${id}-title`;
|
|
35
|
+
const descriptionTooltipId = `${id}-description`;
|
|
36
|
+
// Don't show any actions unless panel is hovered
|
|
37
|
+
let action = undefined;
|
|
38
|
+
if (isHovered) {
|
|
39
|
+
if (editHandlers !== undefined) {
|
|
40
|
+
// If there are edit handlers, always just show the edit buttons
|
|
41
|
+
action = /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
42
|
+
direction: "row",
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
spacing: 0.5,
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(HeaderIconButton, {
|
|
47
|
+
"aria-label": "edit panel",
|
|
48
|
+
size: "small",
|
|
49
|
+
onClick: editHandlers.onEditPanelClick,
|
|
50
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencilOutline.default, {})
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(HeaderIconButton, {
|
|
53
|
+
"aria-label": "delete panel",
|
|
54
|
+
size: "small",
|
|
55
|
+
onClick: editHandlers.onDeletePanelClick,
|
|
56
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_deleteOutline.default, {})
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(HeaderIconButton, {
|
|
59
|
+
"aria-label": "drag handle",
|
|
60
|
+
size: "small",
|
|
61
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dragVertical.default, {
|
|
62
|
+
className: "drag-handle",
|
|
63
|
+
sx: {
|
|
64
|
+
cursor: 'grab'
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
} else if (description !== undefined) {
|
|
71
|
+
// If there aren't edit handlers and we have a description, show a button with a tooltip for the panel description
|
|
72
|
+
action = /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
|
|
73
|
+
id: descriptionTooltipId,
|
|
74
|
+
description: description,
|
|
75
|
+
placement: _components.TooltipPlacement.Bottom,
|
|
76
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(HeaderIconButton, {
|
|
77
|
+
"aria-label": "Panel Description",
|
|
78
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_informationOutline.default, {
|
|
79
|
+
"aria-describedby": "info-tooltip",
|
|
80
|
+
"aria-hidden": false,
|
|
81
|
+
sx: {
|
|
82
|
+
color: (theme)=>theme.palette.grey[700]
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.CardHeader, {
|
|
90
|
+
id: id,
|
|
91
|
+
component: "header",
|
|
92
|
+
"aria-labelledby": titleElementId,
|
|
93
|
+
"aria-describedby": descriptionTooltipId,
|
|
94
|
+
disableTypography: true,
|
|
95
|
+
title: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
96
|
+
id: titleElementId,
|
|
97
|
+
variant: "subtitle1",
|
|
98
|
+
sx: {
|
|
99
|
+
whiteSpace: 'nowrap',
|
|
100
|
+
overflow: 'hidden',
|
|
101
|
+
textOverflow: 'ellipsis'
|
|
102
|
+
},
|
|
103
|
+
children: title
|
|
104
|
+
}),
|
|
105
|
+
action: action,
|
|
106
|
+
sx: (0, _components.combineSx)((theme)=>({
|
|
107
|
+
padding: theme.spacing(1),
|
|
108
|
+
borderBottom: `solid 1px ${theme.palette.divider}`
|
|
109
|
+
}), sx),
|
|
110
|
+
...rest
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const HeaderIconButton = (0, _material.styled)(_material.IconButton)(({ theme })=>({
|
|
114
|
+
borderRadius: theme.shape.borderRadius,
|
|
115
|
+
padding: '4px'
|
|
116
|
+
}));
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
-
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
19
18
|
const _react = require("@testing-library/react");
|
|
20
19
|
const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
|
|
21
20
|
const _testUtils = require("react-dom/test-utils");
|
|
@@ -29,21 +28,16 @@ function _interopRequireDefault(obj) {
|
|
|
29
28
|
}
|
|
30
29
|
describe('Panel Drawer', ()=>{
|
|
31
30
|
const renderPanelDrawer = ()=>{
|
|
32
|
-
const { addMockPlugin , pluginRegistryProps } = (0, _test.mockPluginRegistryProps)();
|
|
33
|
-
addMockPlugin('Panel', 'TimeSeriesChart', _test.FAKE_PANEL_PLUGIN);
|
|
34
31
|
const { store , DashboardProviderSpy } = (0, _test.createDashboardProviderSpy)();
|
|
35
|
-
(0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelDrawer.PanelDrawer, {})
|
|
45
|
-
]
|
|
46
|
-
})
|
|
32
|
+
(0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_dashboardProvider.DashboardProvider, {
|
|
33
|
+
initialState: {
|
|
34
|
+
dashboardResource: (0, _test.getTestDashboard)(),
|
|
35
|
+
isEditMode: true
|
|
36
|
+
},
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardProviderSpy, {}),
|
|
39
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelDrawer.PanelDrawer, {})
|
|
40
|
+
]
|
|
47
41
|
}));
|
|
48
42
|
const { value: storeApi } = store;
|
|
49
43
|
if (storeApi === undefined) {
|
|
@@ -53,8 +47,8 @@ describe('Panel Drawer', ()=>{
|
|
|
53
47
|
};
|
|
54
48
|
it('should add new panel', async ()=>{
|
|
55
49
|
const storeApi = renderPanelDrawer();
|
|
56
|
-
// Open the drawer for a new panel
|
|
57
|
-
(0, _testUtils.act)(()=>storeApi.getState().openAddPanel(
|
|
50
|
+
// Open the drawer for a new panel
|
|
51
|
+
(0, _testUtils.act)(()=>storeApi.getState().openAddPanel());
|
|
58
52
|
const nameInput = await _react.screen.findByLabelText(/Name/);
|
|
59
53
|
_userEvent.default.type(nameInput, 'New Panel');
|
|
60
54
|
_userEvent.default.click(_react.screen.getByText('Add'));
|
|
@@ -79,9 +73,17 @@ describe('Panel Drawer', ()=>{
|
|
|
79
73
|
it('should edit an existing panel', async ()=>{
|
|
80
74
|
const storeApi = renderPanelDrawer();
|
|
81
75
|
// Open the drawer for an existing panel
|
|
76
|
+
const group = Object.values(storeApi.getState().panelGroups).find((group)=>group.title === 'CPU Stats');
|
|
77
|
+
if (group === undefined) {
|
|
78
|
+
throw new Error('Test group not found');
|
|
79
|
+
}
|
|
80
|
+
const layout = Object.entries(group.itemPanelKeys).find(([, panelKey])=>panelKey === 'cpu');
|
|
81
|
+
if (layout === undefined) {
|
|
82
|
+
throw new Error('Test panel not found');
|
|
83
|
+
}
|
|
82
84
|
(0, _testUtils.act)(()=>storeApi.getState().openEditPanel({
|
|
83
|
-
panelGroupId:
|
|
84
|
-
|
|
85
|
+
panelGroupId: group.id,
|
|
86
|
+
panelGroupItemLayoutId: layout[0]
|
|
85
87
|
}));
|
|
86
88
|
const nameInput = await _react.screen.findByLabelText(/Name/);
|
|
87
89
|
_userEvent.default.clear(nameInput);
|
|
@@ -21,34 +21,27 @@ Object.defineProperty(exports, "PanelPreview", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
23
|
const _panel = require("../Panel");
|
|
24
|
-
function PanelPreview({ name , description , kind , spec
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
spec
|
|
36
|
-
}
|
|
24
|
+
function PanelPreview({ name , description , kind , spec }) {
|
|
25
|
+
const definition = {
|
|
26
|
+
kind: 'Panel',
|
|
27
|
+
spec: {
|
|
28
|
+
display: {
|
|
29
|
+
name,
|
|
30
|
+
description: description === '' ? undefined : description
|
|
31
|
+
},
|
|
32
|
+
plugin: {
|
|
33
|
+
kind,
|
|
34
|
+
spec
|
|
37
35
|
}
|
|
38
|
-
},
|
|
39
|
-
// TODO: what should itemIndex be?
|
|
40
|
-
panelGroupItemId: {
|
|
41
|
-
panelGroupId: groupId,
|
|
42
|
-
itemIndex: 0
|
|
43
36
|
}
|
|
44
37
|
};
|
|
45
|
-
if (
|
|
38
|
+
if (kind === '') {
|
|
46
39
|
return null;
|
|
47
40
|
}
|
|
48
41
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
49
42
|
height: 300,
|
|
50
43
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
|
|
51
|
-
|
|
44
|
+
definition: definition
|
|
52
45
|
})
|
|
53
46
|
});
|
|
54
47
|
}
|
|
@@ -20,7 +20,6 @@ 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"));
|
|
24
23
|
const _panelGroupDialog = require("./PanelGroupDialog");
|
|
25
24
|
function _interopRequireDefault(obj) {
|
|
26
25
|
return obj && obj.__esModule ? obj : {
|
|
@@ -32,7 +31,7 @@ describe('Add Panel Group', ()=>{
|
|
|
32
31
|
const { store , DashboardProviderSpy } = (0, _test.createDashboardProviderSpy)();
|
|
33
32
|
(0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_context.DashboardProvider, {
|
|
34
33
|
initialState: {
|
|
35
|
-
|
|
34
|
+
dashboardResource: (0, _test.getTestDashboard)(),
|
|
36
35
|
isEditMode: true
|
|
37
36
|
},
|
|
38
37
|
children: [
|
|
@@ -54,21 +53,23 @@ describe('Add Panel Group', ()=>{
|
|
|
54
53
|
_userEvent.default.type(nameInput, 'New Panel Group');
|
|
55
54
|
_userEvent.default.click(_react.screen.getByText('Add'));
|
|
56
55
|
// TODO: Figure out how to test this without coupling to the store state
|
|
57
|
-
const panelGroups = storeApi.getState().panelGroups;
|
|
58
|
-
expect(panelGroups).
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
56
|
+
const panelGroups = Object.values(storeApi.getState().panelGroups);
|
|
57
|
+
expect(panelGroups).toContainEqual({
|
|
58
|
+
id: expect.any(Number),
|
|
59
|
+
title: 'New Panel Group',
|
|
60
|
+
isCollapsed: false,
|
|
61
|
+
itemLayouts: expect.any(Array),
|
|
62
|
+
itemPanelKeys: expect.any(Object)
|
|
65
63
|
});
|
|
66
64
|
});
|
|
67
65
|
it('should edit existing panel group', async ()=>{
|
|
68
|
-
var ref;
|
|
69
66
|
const storeApi = renderDialog();
|
|
70
67
|
// Open the dialog for an existing panel group
|
|
71
|
-
|
|
68
|
+
const group = Object.values(storeApi.getState().panelGroups).find((group)=>group.title === 'CPU Stats');
|
|
69
|
+
if (group === undefined) {
|
|
70
|
+
throw new Error('Missing test group');
|
|
71
|
+
}
|
|
72
|
+
(0, _testUtils.act)(()=>storeApi.getState().openEditPanelGroup(group.id));
|
|
72
73
|
const nameInput = await _react.screen.findByLabelText(/Name/);
|
|
73
74
|
_userEvent.default.clear(nameInput);
|
|
74
75
|
_userEvent.default.type(nameInput, 'New Name');
|
|
@@ -76,11 +77,10 @@ describe('Add Panel Group', ()=>{
|
|
|
76
77
|
// TODO: Figure out how to test this without coupling to the store state
|
|
77
78
|
const panelGroups = storeApi.getState().panelGroups;
|
|
78
79
|
expect(panelGroups).toMatchObject({
|
|
79
|
-
|
|
80
|
-
id:
|
|
80
|
+
[group.id]: {
|
|
81
|
+
id: group.id,
|
|
81
82
|
title: 'New Name',
|
|
82
|
-
isCollapsed: false
|
|
83
|
-
items: (ref = _testDashboard.default.spec.layouts[0]) === null || ref === void 0 ? void 0 : ref.spec.items
|
|
83
|
+
isCollapsed: false
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
});
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./PanelGroupDialog"), exports);
|
|
18
|
-
_exportStar(require("./DeletePanelGroupDialog"), exports);
|
|
19
18
|
function _exportStar(from, to) {
|
|
20
19
|
Object.keys(from).forEach(function(k) {
|
|
21
20
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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, "UnsavedChangesConfirmationDialog", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>UnsavedChangesConfirmationDialog
|
|
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
|
+
function _interopRequireDefault(obj) {
|
|
25
|
+
return obj && obj.__esModule ? obj : {
|
|
26
|
+
default: obj
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const UnsavedChangesConfirmationDialog = ({ isOpen , onSave , onClose })=>{
|
|
30
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Dialog, {
|
|
31
|
+
open: isOpen,
|
|
32
|
+
children: [
|
|
33
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogTitle, {
|
|
34
|
+
children: "Unsaved Changes"
|
|
35
|
+
}),
|
|
36
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
37
|
+
"aria-label": "Close",
|
|
38
|
+
onClick: onClose,
|
|
39
|
+
sx: (theme)=>({
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
top: theme.spacing(0.5),
|
|
42
|
+
right: theme.spacing(0.5)
|
|
43
|
+
}),
|
|
44
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_close.default, {})
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogContent, {
|
|
47
|
+
sx: {
|
|
48
|
+
width: '500px'
|
|
49
|
+
},
|
|
50
|
+
children: "You have unsaved changes in this dashboard. Would you like to save these changes?"
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
55
|
+
variant: "contained",
|
|
56
|
+
onClick: onSave,
|
|
57
|
+
children: "Save"
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
60
|
+
onClick: onClose,
|
|
61
|
+
children: "Cancel"
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
_exportStar(require("./UnsavedChangesConfirmationDialog"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -75,14 +75,17 @@ function ListVariable({ name }) {
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
const variablesValueKey = getVariableValuesKey(variables);
|
|
78
|
+
const { timeRange } = (0, _pluginSystem.useTimeRange)();
|
|
78
79
|
const variablesOptionsQuery = (0, _reactQuery.useQuery)([
|
|
79
80
|
name,
|
|
80
81
|
definition,
|
|
81
|
-
variablesValueKey
|
|
82
|
+
variablesValueKey,
|
|
83
|
+
timeRange
|
|
82
84
|
], async ()=>{
|
|
83
85
|
const resp = await (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.getVariableOptions(spec, {
|
|
84
86
|
datasourceStore,
|
|
85
|
-
variables
|
|
87
|
+
variables,
|
|
88
|
+
timeRange
|
|
86
89
|
}));
|
|
87
90
|
var ref;
|
|
88
91
|
return (ref = resp === null || resp === void 0 ? void 0 : resp.data) !== null && ref !== void 0 ? ref : [];
|
|
@@ -128,22 +131,26 @@ function ListVariable({ name }) {
|
|
|
128
131
|
options,
|
|
129
132
|
allowAllValue
|
|
130
133
|
]);
|
|
131
|
-
(0, _react.
|
|
132
|
-
const firstOption = finalOptions === null || finalOptions === void 0 ? void 0 : finalOptions[0];
|
|
133
|
-
const valueIsInOptions = Boolean(finalOptions.find((v)=>{
|
|
134
|
+
const valueIsInOptions = (0, _react.useMemo)(()=>Boolean(finalOptions.find((v)=>{
|
|
134
135
|
if (allowMultiple) {
|
|
135
136
|
return value.includes(v.value);
|
|
136
137
|
}
|
|
137
138
|
return value === v.value;
|
|
138
|
-
}))
|
|
139
|
+
})), [
|
|
140
|
+
finalOptions,
|
|
141
|
+
value,
|
|
142
|
+
allowMultiple
|
|
143
|
+
]);
|
|
144
|
+
let selectValue = value;
|
|
145
|
+
if (!valueIsInOptions) {
|
|
146
|
+
selectValue = allowMultiple ? [] : '';
|
|
147
|
+
}
|
|
148
|
+
(0, _react.useEffect)(()=>{
|
|
149
|
+
const firstOption = finalOptions === null || finalOptions === void 0 ? void 0 : finalOptions[0];
|
|
139
150
|
// If there is no value but there are options, set the value to the first option.
|
|
140
151
|
if (!value && firstOption) {
|
|
141
152
|
setVariableValue(name, firstOption.value);
|
|
142
153
|
}
|
|
143
|
-
// If there is a value but it's not in the options, select the first value or set to null
|
|
144
|
-
if (value && !valueIsInOptions && !definition.spec.default_value) {
|
|
145
|
-
setVariableValue(name, (firstOption === null || firstOption === void 0 ? void 0 : firstOption.value) || null);
|
|
146
|
-
}
|
|
147
154
|
}, [
|
|
148
155
|
finalOptions,
|
|
149
156
|
setVariableValue,
|
|
@@ -167,7 +174,7 @@ function ListVariable({ name }) {
|
|
|
167
174
|
},
|
|
168
175
|
id: name,
|
|
169
176
|
label: name,
|
|
170
|
-
value:
|
|
177
|
+
value: selectValue,
|
|
171
178
|
onChange: (e)=>{
|
|
172
179
|
// Must be selected
|
|
173
180
|
if (e.target.value === null || e.target.value.length === 0) {
|
|
@@ -117,18 +117,19 @@ function VariableEditor(props) {
|
|
|
117
117
|
justifyContent: "end",
|
|
118
118
|
children: [
|
|
119
119
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
120
|
+
disabled: props.variableDefinitions === variableDefinitions,
|
|
121
|
+
variant: "contained",
|
|
120
122
|
onClick: ()=>{
|
|
121
|
-
props.
|
|
123
|
+
props.onChange(variableDefinitions);
|
|
122
124
|
},
|
|
123
|
-
children: "
|
|
125
|
+
children: "Apply"
|
|
124
126
|
}),
|
|
125
127
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
126
|
-
|
|
127
|
-
variant: "contained",
|
|
128
|
+
variant: "outlined",
|
|
128
129
|
onClick: ()=>{
|
|
129
|
-
props.
|
|
130
|
+
props.onCancel();
|
|
130
131
|
},
|
|
131
|
-
children: "
|
|
132
|
+
children: "Cancel"
|
|
132
133
|
})
|
|
133
134
|
]
|
|
134
135
|
}),
|
|
@@ -54,6 +54,7 @@ function VariableEditForm({ initialVariableDefinition , onChange , onCancel })
|
|
|
54
54
|
item: true,
|
|
55
55
|
xs: 6,
|
|
56
56
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
57
|
+
fullWidth: true,
|
|
57
58
|
label: "Name",
|
|
58
59
|
value: state.name,
|
|
59
60
|
onChange: (v)=>{
|
|
@@ -95,6 +96,7 @@ function VariableEditForm({ initialVariableDefinition , onChange , onCancel })
|
|
|
95
96
|
item: true,
|
|
96
97
|
xs: 6,
|
|
97
98
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
99
|
+
fullWidth: true,
|
|
98
100
|
label: "Label",
|
|
99
101
|
value: state.label,
|
|
100
102
|
onChange: (v)=>{
|
|
@@ -108,6 +110,7 @@ function VariableEditForm({ initialVariableDefinition , onChange , onCancel })
|
|
|
108
110
|
item: true,
|
|
109
111
|
xs: 12,
|
|
110
112
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
113
|
+
fullWidth: true,
|
|
111
114
|
label: "Description",
|
|
112
115
|
value: state.description,
|
|
113
116
|
onChange: (v)=>{
|
|
@@ -217,17 +220,18 @@ function VariableEditForm({ initialVariableDefinition , onChange , onCancel })
|
|
|
217
220
|
justifyContent: "end",
|
|
218
221
|
children: [
|
|
219
222
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
223
|
+
variant: "contained",
|
|
220
224
|
onClick: ()=>{
|
|
221
|
-
|
|
225
|
+
onChange((0, _variableEditorFormModel.getVariableDefinitionFromState)(state));
|
|
222
226
|
},
|
|
223
|
-
children: "
|
|
227
|
+
children: "Update"
|
|
224
228
|
}),
|
|
225
229
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
226
|
-
variant: "
|
|
230
|
+
variant: "outlined",
|
|
227
231
|
onClick: ()=>{
|
|
228
|
-
|
|
232
|
+
onCancel();
|
|
229
233
|
},
|
|
230
|
-
children: "
|
|
234
|
+
children: "Cancel"
|
|
231
235
|
})
|
|
232
236
|
]
|
|
233
237
|
})
|
|
@@ -15,11 +15,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./Dashboard"), exports);
|
|
18
|
+
_exportStar(require("./DashboardToolbar"), exports);
|
|
19
|
+
_exportStar(require("./DeletePanelDialog"), exports);
|
|
20
|
+
_exportStar(require("./DeletePanelGroupDialog"), exports);
|
|
18
21
|
_exportStar(require("./GridLayout"), exports);
|
|
19
22
|
_exportStar(require("./Panel"), exports);
|
|
20
23
|
_exportStar(require("./PanelDrawer"), exports);
|
|
21
24
|
_exportStar(require("./PanelGroupDialog"), exports);
|
|
22
25
|
_exportStar(require("./TimeRangeControls"), exports);
|
|
26
|
+
_exportStar(require("./UnsavedChangesConfirmationDialog"), exports);
|
|
23
27
|
_exportStar(require("./Variables"), exports);
|
|
24
28
|
function _exportStar(from, to) {
|
|
25
29
|
Object.keys(from).forEach(function(k) {
|
|
@@ -34,6 +34,9 @@ const _react = require("react");
|
|
|
34
34
|
const _panelGroupEditorSlice = require("./panel-group-editor-slice");
|
|
35
35
|
const _panelGroupSlice = require("./panel-group-slice");
|
|
36
36
|
const _panelEditorSlice = require("./panel-editor-slice");
|
|
37
|
+
const _panelSlice = require("./panel-slice");
|
|
38
|
+
const _deletePanelGroupSlice = require("./delete-panel-group-slice");
|
|
39
|
+
const _deletePanelSlice = require("./delete-panel-slice");
|
|
37
40
|
function _interopRequireDefault(obj) {
|
|
38
41
|
return obj && obj.__esModule ? obj : {
|
|
39
42
|
default: obj
|
|
@@ -48,35 +51,44 @@ function useDashboardStore(selector) {
|
|
|
48
51
|
return (0, _zustand.useStore)(store, selector, _shallow.default);
|
|
49
52
|
}
|
|
50
53
|
function DashboardProvider(props) {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
const createDashboardStore = (0, _react.useCallback)(initStore, [
|
|
55
|
+
props
|
|
56
|
+
]);
|
|
57
|
+
const [store] = (0, _react.useState)(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders
|
|
58
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardContext.Provider, {
|
|
59
|
+
value: store,
|
|
60
|
+
children: props.children
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function initStore(props) {
|
|
64
|
+
const { initialState: { dashboardResource , isEditMode } , } = props;
|
|
65
|
+
const { spec: { layouts , panels , duration } , metadata , } = dashboardResource;
|
|
66
|
+
const store = (0, _zustand.createStore)()((0, _immer.immer)((0, _middleware.devtools)((...args)=>{
|
|
67
|
+
const [set] = args;
|
|
55
68
|
return {
|
|
56
|
-
...(0, _panelGroupEditorSlice.createPanelGroupEditorSlice)(...args),
|
|
57
69
|
...(0, _panelGroupSlice.createPanelGroupSlice)(layouts)(...args),
|
|
58
|
-
...(0,
|
|
70
|
+
...(0, _panelSlice.createPanelSlice)(panels)(...args),
|
|
71
|
+
...(0, _panelGroupEditorSlice.createPanelGroupEditorSlice)(...args),
|
|
72
|
+
...(0, _deletePanelGroupSlice.createDeletePanelGroupSlice)(...args),
|
|
73
|
+
...(0, _panelEditorSlice.createPanelEditorSlice)()(...args),
|
|
74
|
+
...(0, _deletePanelSlice.createDeletePanelSlice)()(...args),
|
|
75
|
+
metadata,
|
|
59
76
|
defaultTimeRange: {
|
|
60
|
-
pastDuration:
|
|
77
|
+
pastDuration: duration
|
|
61
78
|
},
|
|
62
79
|
isEditMode: !!isEditMode,
|
|
63
80
|
setEditMode: (isEditMode)=>set({
|
|
64
81
|
isEditMode
|
|
65
82
|
}),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
savePanels();
|
|
74
|
-
savePanelGroups();
|
|
83
|
+
setDashboard: ({ spec: { panels , layouts } })=>{
|
|
84
|
+
set((state)=>{
|
|
85
|
+
const { panelGroups , panelGroupOrder } = (0, _panelGroupSlice.convertLayoutsToPanelGroups)(layouts);
|
|
86
|
+
state.panels = panels;
|
|
87
|
+
state.panelGroups = panelGroups;
|
|
88
|
+
state.panelGroupOrder = panelGroupOrder;
|
|
89
|
+
});
|
|
75
90
|
}
|
|
76
91
|
};
|
|
77
92
|
})));
|
|
78
|
-
return
|
|
79
|
-
value: dashboardStore,
|
|
80
|
-
children: children
|
|
81
|
-
});
|
|
93
|
+
return store;
|
|
82
94
|
}
|