@perses-dev/dashboards 0.29.1 → 0.31.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/DashboardStickyToolbar/DashboardStickyToolbar.js +79 -0
- package/dist/cjs/{stories/decorators/WithQueryClient.js → components/DashboardStickyToolbar/index.js} +11 -12
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +8 -24
- package/dist/cjs/components/EditJsonButton/EditJsonButton.js +1 -0
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +5 -0
- package/dist/cjs/components/GridLayout/GridTitle.js +30 -9
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +88 -0
- package/dist/cjs/{stories/decorators/WithQueryParams.js → components/SaveChangesConfirmationDialog/index.js} +11 -12
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +78 -0
- package/dist/cjs/components/SaveDashboardButton/index.js +28 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +5 -5
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +124 -198
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +178 -0
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +1 -0
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
- package/dist/cjs/components/Variables/VariableList.js +16 -55
- package/dist/cjs/components/Variables/index.js +1 -0
- package/dist/cjs/components/index.js +2 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +5 -4
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +13 -4
- package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +33 -0
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +56 -7
- package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +2 -0
- package/dist/cjs/context/TemplateVariableProvider/utils.js +37 -0
- package/dist/cjs/context/useDashboard.js +4 -4
- package/dist/cjs/stories/decorators/index.js +0 -5
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +9 -0
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -0
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +68 -0
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -0
- package/dist/components/DashboardStickyToolbar/index.d.ts +2 -0
- package/dist/components/DashboardStickyToolbar/index.d.ts.map +1 -0
- package/dist/{stories/decorators/WithQueryClient.js → components/DashboardStickyToolbar/index.js} +2 -10
- package/dist/components/DashboardStickyToolbar/index.js.map +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +10 -26
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js +1 -0
- package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +5 -0
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +30 -9
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +3 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +82 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -0
- package/dist/components/SaveChangesConfirmationDialog/index.d.ts +2 -0
- package/dist/components/SaveChangesConfirmationDialog/index.d.ts.map +1 -0
- package/dist/{stories/decorators/WithQueryParams.js → components/SaveChangesConfirmationDialog/index.js} +2 -10
- package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +10 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +72 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -0
- package/dist/components/SaveDashboardButton/index.d.ts +2 -0
- package/dist/components/SaveDashboardButton/index.d.ts.map +1 -0
- package/dist/components/SaveDashboardButton/index.js +15 -0
- package/dist/components/SaveDashboardButton/index.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +6 -6
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +4 -2
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +127 -196
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +16 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +122 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/index.js +1 -0
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +1 -7
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +18 -52
- 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 +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +4 -3
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +5 -4
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +6 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +11 -3
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +15 -0
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js +27 -0
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +4 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +51 -7
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.js +2 -0
- package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.d.ts +4 -0
- package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/utils.js +33 -0
- package/dist/context/TemplateVariableProvider/utils.js.map +1 -0
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +4 -4
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/stories/decorators/WithDashboard.js.map +1 -1
- package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
- package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
- package/dist/stories/decorators/index.js +0 -5
- package/dist/stories/decorators/index.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +3 -2
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/package.json +6 -6
- package/dist/cjs/stories/decorators/WithDataQueriesProvider.js +0 -39
- package/dist/cjs/stories/decorators/WithPluginRegistry.js +0 -94
- package/dist/cjs/stories/decorators/WithTimeRange.js +0 -38
- package/dist/stories/decorators/WithDataQueriesProvider.js +0 -33
- package/dist/stories/decorators/WithDataQueriesProvider.js.map +0 -1
- package/dist/stories/decorators/WithPluginRegistry.js +0 -49
- package/dist/stories/decorators/WithPluginRegistry.js.map +0 -1
- package/dist/stories/decorators/WithQueryClient.js.map +0 -1
- package/dist/stories/decorators/WithQueryParams.js.map +0 -1
- package/dist/stories/decorators/WithTimeRange.js +0 -32
- package/dist/stories/decorators/WithTimeRange.js.map +0 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Copyright 2023 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, "DashboardStickyToolbar", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>DashboardStickyToolbar
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _pinOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PinOutline"));
|
|
25
|
+
const _pinOffOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PinOffOutline"));
|
|
26
|
+
const _variables = require("../Variables");
|
|
27
|
+
const _timeRangeControls = require("../TimeRangeControls");
|
|
28
|
+
function _interopRequireDefault(obj) {
|
|
29
|
+
return obj && obj.__esModule ? obj : {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function DashboardStickyToolbar(props) {
|
|
34
|
+
const [isPin, setIsPin] = (0, _react.useState)(props.initialVariableIsSticky);
|
|
35
|
+
const scrollTrigger = (0, _material.useScrollTrigger)({
|
|
36
|
+
disableHysteresis: true
|
|
37
|
+
});
|
|
38
|
+
const isSticky = scrollTrigger && props.initialVariableIsSticky && isPin;
|
|
39
|
+
return(// marginBottom={-1} counteracts the marginBottom={1} on every variable input.
|
|
40
|
+
// The margin on the inputs is for spacing between inputs, but is not meant to add space to bottom of the container.
|
|
41
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
42
|
+
marginBottom: -1,
|
|
43
|
+
"data-testid": "variable-list",
|
|
44
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.AppBar, {
|
|
45
|
+
color: "inherit",
|
|
46
|
+
position: isSticky ? 'fixed' : 'static',
|
|
47
|
+
elevation: isSticky ? 4 : 0,
|
|
48
|
+
sx: {
|
|
49
|
+
backgroundColor: 'inherit',
|
|
50
|
+
...props.sx
|
|
51
|
+
},
|
|
52
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
53
|
+
display: "flex",
|
|
54
|
+
justifyContent: "space-between",
|
|
55
|
+
children: [
|
|
56
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
57
|
+
display: "flex",
|
|
58
|
+
flexWrap: "wrap",
|
|
59
|
+
alignItems: "start",
|
|
60
|
+
my: isSticky ? 2 : 0,
|
|
61
|
+
ml: isSticky ? 2 : 0,
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {}),
|
|
64
|
+
props.initialVariableIsSticky && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
65
|
+
onClick: ()=>setIsPin(!isPin),
|
|
66
|
+
children: isPin ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pinOutline.default, {}) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pinOffOutline.default, {})
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
}),
|
|
70
|
+
isSticky && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
71
|
+
my: 2,
|
|
72
|
+
mr: 2,
|
|
73
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {})
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
@@ -14,16 +14,15 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
client: queryClient,
|
|
27
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
|
|
17
|
+
_exportStar(require("./DashboardStickyToolbar"), 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
|
+
});
|
|
28
26
|
});
|
|
29
|
-
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -19,7 +19,6 @@ Object.defineProperty(exports, "DashboardToolbar", {
|
|
|
19
19
|
get: ()=>DashboardToolbar
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _react = require("react");
|
|
23
22
|
const _material = require("@mui/material");
|
|
24
23
|
const _components = require("@perses-dev/components");
|
|
25
24
|
const _context = require("../../context");
|
|
@@ -30,30 +29,17 @@ const _timeRangeControls = require("../TimeRangeControls");
|
|
|
30
29
|
const _variables = require("../Variables");
|
|
31
30
|
const _editButton = require("../EditButton");
|
|
32
31
|
const _editJsonButton = require("../EditJsonButton");
|
|
32
|
+
const _saveDashboardButton = require("../SaveDashboardButton");
|
|
33
|
+
const _dashboardStickyToolbar = require("../DashboardStickyToolbar");
|
|
33
34
|
const DashboardToolbar = (props)=>{
|
|
34
35
|
const { dashboardName , dashboardTitleComponent , initialVariableIsSticky , isReadonly , onEditButtonClick , onCancelButtonClick , onSave , } = props;
|
|
35
|
-
const
|
|
36
|
-
const { isEditMode , setEditMode } = (0, _context.useEditMode)();
|
|
36
|
+
const { isEditMode } = (0, _context.useEditMode)();
|
|
37
37
|
const isBiggerThanMd = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('md'));
|
|
38
38
|
const isBiggerThanSm = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('sm'));
|
|
39
|
-
const [isSavingDashboard, setSavingDashboard] = (0, _react.useState)(false);
|
|
40
39
|
const dashboardTitle = dashboardTitleComponent ? dashboardTitleComponent : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
41
40
|
variant: "h2",
|
|
42
41
|
children: dashboardName
|
|
43
42
|
});
|
|
44
|
-
const onSaveButtonClick = ()=>{
|
|
45
|
-
if (onSave !== undefined) {
|
|
46
|
-
setSavingDashboard(true);
|
|
47
|
-
onSave(dashboard.dashboard).then(()=>{
|
|
48
|
-
setSavingDashboard(false);
|
|
49
|
-
setEditMode(false);
|
|
50
|
-
}).catch(()=>{
|
|
51
|
-
setSavingDashboard(false);
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
setEditMode(false);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
43
|
const testId = 'dashboard-toolbar';
|
|
58
44
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
59
45
|
children: isEditMode ? /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
@@ -81,11 +67,9 @@ const DashboardToolbar = (props)=>{
|
|
|
81
67
|
},
|
|
82
68
|
children: "Dashboard managed via code only. Download JSON and commit changes to save."
|
|
83
69
|
}),
|
|
84
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
disabled: isReadonly || isSavingDashboard,
|
|
88
|
-
children: "Save"
|
|
70
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_saveDashboardButton.SaveDashboardButton, {
|
|
71
|
+
onSave: onSave,
|
|
72
|
+
isDisabled: isReadonly
|
|
89
73
|
}),
|
|
90
74
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
91
75
|
variant: "outlined",
|
|
@@ -106,7 +90,7 @@ const DashboardToolbar = (props)=>{
|
|
|
106
90
|
children: [
|
|
107
91
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
108
92
|
FallbackComponent: _components.ErrorAlert,
|
|
109
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
93
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardStickyToolbar.DashboardStickyToolbar, {
|
|
110
94
|
initialVariableIsSticky: initialVariableIsSticky,
|
|
111
95
|
sx: {
|
|
112
96
|
backgroundColor: ({ palette })=>palette.mode === 'dark' ? palette.background.default : palette.background.paper
|
|
@@ -194,7 +178,7 @@ const DashboardToolbar = (props)=>{
|
|
|
194
178
|
paddingY: 2,
|
|
195
179
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
196
180
|
FallbackComponent: _components.ErrorAlert,
|
|
197
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
181
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardStickyToolbar.DashboardStickyToolbar, {
|
|
198
182
|
initialVariableIsSticky: initialVariableIsSticky,
|
|
199
183
|
sx: {
|
|
200
184
|
backgroundColor: ({ palette })=>palette.mode === 'dark' ? palette.background.default : palette.background.paper
|
|
@@ -34,6 +34,7 @@ const EditJsonButton = ()=>{
|
|
|
34
34
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
|
|
35
35
|
description: _constants.TOOLTIP_TEXT.editJson,
|
|
36
36
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_toolbarIconButton.ToolbarIconButton, {
|
|
37
|
+
"aria-label": _constants.TOOLTIP_TEXT.editJson,
|
|
37
38
|
variant: "outlined",
|
|
38
39
|
onClick: ()=>openEditJsonDialog(),
|
|
39
40
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_codeBraces.default, {})
|
|
@@ -22,6 +22,7 @@ const _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
const _react = require("react");
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
24
|
const _components = require("@perses-dev/components");
|
|
25
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
25
26
|
const _dashboardProvider = require("../../context/DashboardProvider");
|
|
26
27
|
const _useDashboard = require("../../context/useDashboard");
|
|
27
28
|
const EditJsonDialog = ()=>{
|
|
@@ -42,11 +43,15 @@ const EditJsonDialog = ()=>{
|
|
|
42
43
|
};
|
|
43
44
|
const EditJsonDialogForm = ()=>{
|
|
44
45
|
const { closeEditJsonDialog } = (0, _dashboardProvider.useEditJsonDialog)();
|
|
46
|
+
const { setTimeRange } = (0, _pluginSystem.useTimeRange)();
|
|
45
47
|
const { dashboard , setDashboard } = (0, _useDashboard.useDashboard)();
|
|
46
48
|
const [draftDashboard, setDraftDashboard] = (0, _react.useState)(dashboard);
|
|
47
49
|
const handleApply = (e)=>{
|
|
48
50
|
e.preventDefault();
|
|
49
51
|
setDashboard(draftDashboard);
|
|
52
|
+
setTimeRange({
|
|
53
|
+
pastDuration: draftDashboard.spec.duration
|
|
54
|
+
});
|
|
50
55
|
closeEditJsonDialog();
|
|
51
56
|
};
|
|
52
57
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.Dialog.Form, {
|
|
@@ -42,24 +42,25 @@ function GridTitle(props) {
|
|
|
42
42
|
const { isEditMode } = (0, _context.useEditMode)();
|
|
43
43
|
const text = /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
44
44
|
variant: "h2",
|
|
45
|
-
sx: {
|
|
46
|
-
marginLeft: collapse !== undefined ? 1 : undefined
|
|
47
|
-
},
|
|
48
45
|
children: title
|
|
49
46
|
});
|
|
50
47
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
48
|
+
onClick: collapse === null || collapse === void 0 ? void 0 : collapse.onToggleOpen,
|
|
51
49
|
sx: {
|
|
52
50
|
display: 'flex',
|
|
53
51
|
justifyContent: 'start',
|
|
54
52
|
alignItems: 'center',
|
|
55
53
|
padding: (theme)=>theme.spacing(1),
|
|
54
|
+
cursor: collapse ? 'pointer' : 'auto',
|
|
56
55
|
backgroundColor: ({ palette })=>palette.mode === 'dark' ? palette.background.paper : palette.background.default
|
|
57
56
|
},
|
|
58
57
|
"data-testid": "panel-group-header",
|
|
59
58
|
children: collapse ? /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
60
59
|
children: [
|
|
61
60
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
62
|
-
|
|
61
|
+
sx: {
|
|
62
|
+
marginRight: 1
|
|
63
|
+
},
|
|
63
64
|
"aria-label": `${collapse.isOpen ? 'collapse' : 'expand'} group ${title}`,
|
|
64
65
|
children: collapse.isOpen ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_chevronDown.default, {}) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_chevronRight.default, {})
|
|
65
66
|
}),
|
|
@@ -72,7 +73,11 @@ function GridTitle(props) {
|
|
|
72
73
|
description: _constants.TOOLTIP_TEXT.addPanelToGroup,
|
|
73
74
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
74
75
|
"aria-label": _constants.ARIA_LABEL_TEXT.addPanelToGroup(title),
|
|
75
|
-
onClick:
|
|
76
|
+
onClick: (e)=>{
|
|
77
|
+
// Don't trigger expand/collapse
|
|
78
|
+
e.stopPropagation();
|
|
79
|
+
openAddPanel();
|
|
80
|
+
},
|
|
76
81
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_chartBoxPlusOutline.default, {})
|
|
77
82
|
})
|
|
78
83
|
}),
|
|
@@ -80,7 +85,11 @@ function GridTitle(props) {
|
|
|
80
85
|
description: _constants.TOOLTIP_TEXT.editGroup,
|
|
81
86
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
82
87
|
"aria-label": _constants.ARIA_LABEL_TEXT.editGroup(title),
|
|
83
|
-
onClick:
|
|
88
|
+
onClick: (e)=>{
|
|
89
|
+
// Don't trigger expand/collapse
|
|
90
|
+
e.stopPropagation();
|
|
91
|
+
openEditPanelGroup();
|
|
92
|
+
},
|
|
84
93
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencilOutline.default, {})
|
|
85
94
|
})
|
|
86
95
|
}),
|
|
@@ -88,7 +97,11 @@ function GridTitle(props) {
|
|
|
88
97
|
description: _constants.TOOLTIP_TEXT.deleteGroup,
|
|
89
98
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
90
99
|
"aria-label": _constants.ARIA_LABEL_TEXT.deleteGroup(title),
|
|
91
|
-
onClick: ()=>
|
|
100
|
+
onClick: (e)=>{
|
|
101
|
+
// Don't trigger expand/collapse
|
|
102
|
+
e.stopPropagation();
|
|
103
|
+
openDeletePanelGroupDialog(panelGroupId);
|
|
104
|
+
},
|
|
92
105
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_deleteOutline.default, {})
|
|
93
106
|
})
|
|
94
107
|
}),
|
|
@@ -97,7 +110,11 @@ function GridTitle(props) {
|
|
|
97
110
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
98
111
|
"aria-label": _constants.ARIA_LABEL_TEXT.moveGroupDown(title),
|
|
99
112
|
disabled: moveDown === undefined,
|
|
100
|
-
onClick:
|
|
113
|
+
onClick: (e)=>{
|
|
114
|
+
// Don't trigger expand/collapse
|
|
115
|
+
e.stopPropagation();
|
|
116
|
+
moveDown && moveDown();
|
|
117
|
+
},
|
|
101
118
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowDown.default, {})
|
|
102
119
|
})
|
|
103
120
|
}),
|
|
@@ -106,7 +123,11 @@ function GridTitle(props) {
|
|
|
106
123
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
107
124
|
"aria-label": _constants.ARIA_LABEL_TEXT.moveGroupUp(title),
|
|
108
125
|
disabled: moveUp === undefined,
|
|
109
|
-
onClick:
|
|
126
|
+
onClick: (e)=>{
|
|
127
|
+
// Don't trigger expand/collapse
|
|
128
|
+
e.stopPropagation();
|
|
129
|
+
moveUp && moveUp();
|
|
130
|
+
},
|
|
110
131
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowUp.default, {})
|
|
111
132
|
})
|
|
112
133
|
})
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Copyright 2023 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, "SaveChangesConfirmationDialog", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>SaveChangesConfirmationDialog
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
25
|
+
const _core = require("@perses-dev/core");
|
|
26
|
+
const _components = require("@perses-dev/components");
|
|
27
|
+
const _context = require("../../context");
|
|
28
|
+
const SaveChangesConfirmationDialog = ()=>{
|
|
29
|
+
const [saveDefaultTimeRange, setSaveDefaultTimeRange] = (0, _react.useState)(true);
|
|
30
|
+
const [saveDefaultVariables, setSaveDefaultVariables] = (0, _react.useState)(true);
|
|
31
|
+
const { saveChangesConfirmationDialog: dialog } = (0, _context.useSaveChangesConfirmationDialog)();
|
|
32
|
+
const isOpen = dialog !== undefined;
|
|
33
|
+
const { timeRange } = (0, _pluginSystem.useTimeRange)();
|
|
34
|
+
const currentTimeRangeText = (0, _core.isRelativeTimeRange)(timeRange) ? `(Last ${timeRange.pastDuration})` : '(Absolute time ranges can not be saved)';
|
|
35
|
+
const timeRangeInfoText = `Save current time range as new default ${currentTimeRangeText}`;
|
|
36
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Dialog, {
|
|
37
|
+
open: isOpen,
|
|
38
|
+
children: dialog !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Dialog.Header, {
|
|
41
|
+
onClose: ()=>dialog.onCancel(),
|
|
42
|
+
children: "Save Dashboard"
|
|
43
|
+
}),
|
|
44
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.Dialog.Content, {
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
47
|
+
marginBottom: 2,
|
|
48
|
+
children: dialog.description || _core.SAVE_DEFAULTS_DIALOG_TEXT
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormGroup, {
|
|
51
|
+
children: [
|
|
52
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControlLabel, {
|
|
53
|
+
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Checkbox, {
|
|
54
|
+
disabled: !(0, _core.isRelativeTimeRange)(timeRange),
|
|
55
|
+
checked: saveDefaultTimeRange && (0, _core.isRelativeTimeRange)(timeRange),
|
|
56
|
+
onChange: (e)=>setSaveDefaultTimeRange(e.target.checked)
|
|
57
|
+
}),
|
|
58
|
+
label: timeRangeInfoText
|
|
59
|
+
}),
|
|
60
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControlLabel, {
|
|
61
|
+
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Checkbox, {
|
|
62
|
+
checked: saveDefaultVariables,
|
|
63
|
+
onChange: (e)=>setSaveDefaultVariables(e.target.checked)
|
|
64
|
+
}),
|
|
65
|
+
label: "Save current variable values as new default."
|
|
66
|
+
})
|
|
67
|
+
]
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
}),
|
|
71
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.Dialog.Actions, {
|
|
72
|
+
children: [
|
|
73
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Dialog.PrimaryButton, {
|
|
74
|
+
onClick: ()=>{
|
|
75
|
+
return dialog.onSaveChanges(saveDefaultTimeRange, saveDefaultVariables);
|
|
76
|
+
},
|
|
77
|
+
children: "Save Changes"
|
|
78
|
+
}),
|
|
79
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Dialog.SecondaryButton, {
|
|
80
|
+
onClick: ()=>dialog.onCancel(),
|
|
81
|
+
children: "Cancel"
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
};
|
|
@@ -14,16 +14,15 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
adapter: _window.WindowHistoryAdapter,
|
|
27
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
|
|
17
|
+
_exportStar(require("./SaveChangesConfirmationDialog"), 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
|
+
});
|
|
28
26
|
});
|
|
29
|
-
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright 2023 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, "SaveDashboardButton", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>SaveDashboardButton
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _core = require("@perses-dev/core");
|
|
25
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
26
|
+
const _context = require("../../context");
|
|
27
|
+
const SaveDashboardButton = ({ onSave , isDisabled , variant ='contained' })=>{
|
|
28
|
+
const [isSavingDashboard, setSavingDashboard] = (0, _react.useState)(false);
|
|
29
|
+
const { dashboard } = (0, _context.useDashboard)();
|
|
30
|
+
const { getSavedVariablesStatus , setVariableDefaultValues } = (0, _context.useTemplateVariableActions)();
|
|
31
|
+
const isSavedVariableModified = getSavedVariablesStatus();
|
|
32
|
+
const { timeRange } = (0, _pluginSystem.useTimeRange)();
|
|
33
|
+
const { setEditMode } = (0, _context.useEditMode)();
|
|
34
|
+
const { openSaveChangesConfirmationDialog , closeSaveChangesConfirmationDialog } = (0, _context.useSaveChangesConfirmationDialog)();
|
|
35
|
+
const onSaveButtonClick = ()=>{
|
|
36
|
+
const isSavedDurationModified = (0, _core.isRelativeTimeRange)(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;
|
|
37
|
+
// Save dashboard if active timeRange from plugin-system is relative and different than currently saved
|
|
38
|
+
if (isSavedDurationModified || isSavedVariableModified) {
|
|
39
|
+
openSaveChangesConfirmationDialog({
|
|
40
|
+
onSaveChanges: (saveDefaultTimeRange, saveDefaultVariables)=>{
|
|
41
|
+
if ((0, _core.isRelativeTimeRange)(timeRange) && saveDefaultTimeRange === true) {
|
|
42
|
+
dashboard.spec.duration = timeRange.pastDuration;
|
|
43
|
+
}
|
|
44
|
+
if (saveDefaultVariables === true) {
|
|
45
|
+
const variables = setVariableDefaultValues();
|
|
46
|
+
dashboard.spec.variables = variables;
|
|
47
|
+
}
|
|
48
|
+
saveDashboard();
|
|
49
|
+
},
|
|
50
|
+
onCancel: ()=>{
|
|
51
|
+
closeSaveChangesConfirmationDialog();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
saveDashboard();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const saveDashboard = ()=>{
|
|
59
|
+
if (onSave !== undefined) {
|
|
60
|
+
setSavingDashboard(true);
|
|
61
|
+
onSave(dashboard).then(()=>{
|
|
62
|
+
setSavingDashboard(false);
|
|
63
|
+
closeSaveChangesConfirmationDialog();
|
|
64
|
+
setEditMode(false);
|
|
65
|
+
}).catch(()=>{
|
|
66
|
+
setSavingDashboard(false);
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
setEditMode(false);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
73
|
+
variant: variant,
|
|
74
|
+
onClick: onSaveButtonClick,
|
|
75
|
+
disabled: isDisabled || isSavingDashboard,
|
|
76
|
+
children: "Save"
|
|
77
|
+
});
|
|
78
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2023 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("./SaveDashboardButton"), 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
|
+
}
|
|
@@ -98,17 +98,17 @@ const DEFAULT_HEIGHT = '34px';
|
|
|
98
98
|
function TimeRangeControls({ heightPx , showRefresh =true }) {
|
|
99
99
|
const { timeRange , setTimeRange , refresh } = (0, _pluginSystem.useTimeRange)();
|
|
100
100
|
// TODO: Remove this since it couples to the dashboard context
|
|
101
|
-
const
|
|
101
|
+
const dashboardDuration = (0, _context.useDashboardDuration)();
|
|
102
102
|
// Convert height to a string, then use the string for styling
|
|
103
103
|
const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
|
|
104
104
|
// add time shortcut if one does not match duration from dashboard JSON
|
|
105
|
-
if (!TIME_OPTIONS.some((option)=>option.value.pastDuration ===
|
|
106
|
-
if ((0, _core.isDurationString)(
|
|
105
|
+
if (!TIME_OPTIONS.some((option)=>option.value.pastDuration === dashboardDuration)) {
|
|
106
|
+
if ((0, _core.isDurationString)(dashboardDuration)) {
|
|
107
107
|
TIME_OPTIONS.push({
|
|
108
108
|
value: {
|
|
109
|
-
pastDuration:
|
|
109
|
+
pastDuration: dashboardDuration
|
|
110
110
|
},
|
|
111
|
-
display: `Last ${
|
|
111
|
+
display: `Last ${dashboardDuration}`
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
}
|