@perses-dev/dashboards 0.0.0-snapshot-color-palette-gen-test-0ebddd6 → 0.0.0-snapshot-saving-defaults-refinements-1b25cec
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/WithQueryParams.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/GridItemContent.js +22 -4
- package/dist/cjs/components/GridLayout/GridLayout.js +31 -2
- package/dist/cjs/components/GridLayout/GridTitle.js +30 -9
- package/dist/cjs/components/Panel/Panel.js +2 -2
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +41 -34
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +32 -18
- package/dist/cjs/components/PanelDrawer/usePanelEditor.js +87 -0
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +92 -0
- package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +28 -0
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +81 -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 +3 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +9 -8
- package/dist/cjs/context/DashboardProvider/common.js +26 -6
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +13 -4
- package/dist/cjs/context/DashboardProvider/index.js +1 -0
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +8 -32
- 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 +44 -0
- package/dist/cjs/context/useDashboard.js +4 -4
- package/dist/cjs/stories/decorators/WithDatasourceStore.js +2 -47
- package/dist/cjs/stories/decorators/index.js +0 -4
- package/dist/cjs/test/datasource-provider.js +70 -0
- package/dist/cjs/test/index.js +1 -0
- package/dist/cjs/test/plugin-registry.js +11 -5
- package/dist/cjs/test/render.js +35 -13
- package/dist/cjs/test/testDashboard.js +79 -79
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/{stories/decorators/WithQueryClient.js → utils/time.js} +9 -11
- 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 +2 -2
- 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/GridItemContent.d.ts +1 -0
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +22 -4
- 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 +31 -2
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +30 -9
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +1 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +3 -3
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +42 -35
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +32 -18
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.d.ts +15 -0
- package/dist/components/PanelDrawer/usePanelEditor.d.ts.map +1 -0
- package/dist/components/PanelDrawer/usePanelEditor.js +84 -0
- package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -0
- 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 +86 -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 +75 -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 +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -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 +9 -8
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +3 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js +17 -2
- package/dist/context/DashboardProvider/common.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/index.d.ts +1 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js +1 -0
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +3 -6
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +9 -33
- package/dist/context/DashboardProvider/panel-editor-slice.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 +10 -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 +7 -0
- package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/utils.js +40 -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 +1 -46
- 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 -4
- package/dist/stories/decorators/index.js.map +1 -1
- package/dist/test/datasource-provider.d.ts +6 -0
- package/dist/test/datasource-provider.d.ts.map +1 -0
- package/dist/test/datasource-provider.js +60 -0
- package/dist/test/datasource-provider.js.map +1 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +1 -0
- package/dist/test/index.js.map +1 -1
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +11 -5
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +35 -13
- package/dist/test/render.js.map +1 -1
- package/dist/test/testDashboard.js +79 -79
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/time.d.ts +5 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/time.js +23 -0
- package/dist/utils/time.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -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 +7 -6
- package/dist/cjs/stories/decorators/WithPluginRegistry.js +0 -91
- package/dist/cjs/stories/decorators/WithTimeRange.js +0 -38
- package/dist/stories/decorators/WithPluginRegistry.js +0 -46
- 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,87 @@
|
|
|
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, "usePanelEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>usePanelEditor
|
|
20
|
+
});
|
|
21
|
+
const _react = require("react");
|
|
22
|
+
const usePanelEditor = (panelDefinition)=>{
|
|
23
|
+
const { display , plugin: pluginDefinition , queries: initialQueries } = panelDefinition.spec;
|
|
24
|
+
const [name, setName] = (0, _react.useState)(display.name);
|
|
25
|
+
const [description, setDescription] = (0, _react.useState)(display.description);
|
|
26
|
+
const [plugin, setPlugin] = (0, _react.useState)(pluginDefinition);
|
|
27
|
+
// need to keep track of prevQueries if switching from a panel with no queries (ex: markdown) to one with queries
|
|
28
|
+
const [prevQueries, setPrevQueries] = (0, _react.useState)(initialQueries);
|
|
29
|
+
const [currentQueries, setCurrentQueries] = (0, _react.useState)(initialQueries);
|
|
30
|
+
/**
|
|
31
|
+
* If hideQueryEditor is true, set panelDefinition.spec.queries to undefined.
|
|
32
|
+
* If hideQueryEditor is false and query is undefined, set panelDefinition.spec.queries to previous queries.
|
|
33
|
+
*/ const setQueries = (0, _react.useCallback)((queries, hideQueryEditor)=>{
|
|
34
|
+
if (hideQueryEditor) {
|
|
35
|
+
setPrevQueries(currentQueries);
|
|
36
|
+
setCurrentQueries(undefined);
|
|
37
|
+
} else {
|
|
38
|
+
setCurrentQueries(queries === undefined ? prevQueries : queries);
|
|
39
|
+
}
|
|
40
|
+
}, [
|
|
41
|
+
setCurrentQueries,
|
|
42
|
+
currentQueries,
|
|
43
|
+
setPrevQueries,
|
|
44
|
+
prevQueries
|
|
45
|
+
]);
|
|
46
|
+
// reset panel definition
|
|
47
|
+
const setPanelDefinition = (0, _react.useCallback)((panelDefinition)=>{
|
|
48
|
+
const { display , plugin , queries } = panelDefinition.spec;
|
|
49
|
+
setName(display.name);
|
|
50
|
+
setDescription(display.description);
|
|
51
|
+
setPlugin(plugin);
|
|
52
|
+
setQueries(queries);
|
|
53
|
+
}, [
|
|
54
|
+
setName,
|
|
55
|
+
setDescription,
|
|
56
|
+
setPlugin,
|
|
57
|
+
setQueries
|
|
58
|
+
]);
|
|
59
|
+
return (0, _react.useMemo)(()=>({
|
|
60
|
+
panelDefinition: {
|
|
61
|
+
kind: 'Panel',
|
|
62
|
+
spec: {
|
|
63
|
+
display: {
|
|
64
|
+
name,
|
|
65
|
+
description
|
|
66
|
+
},
|
|
67
|
+
plugin,
|
|
68
|
+
queries: currentQueries
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
setName,
|
|
72
|
+
setDescription,
|
|
73
|
+
setQueries,
|
|
74
|
+
setPlugin,
|
|
75
|
+
setPanelDefinition
|
|
76
|
+
}), [
|
|
77
|
+
name,
|
|
78
|
+
description,
|
|
79
|
+
plugin,
|
|
80
|
+
currentQueries,
|
|
81
|
+
setName,
|
|
82
|
+
setDescription,
|
|
83
|
+
setQueries,
|
|
84
|
+
setPlugin,
|
|
85
|
+
setPanelDefinition
|
|
86
|
+
]);
|
|
87
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
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 { getSavedVariablesStatus } = (0, _context.useTemplateVariableActions)();
|
|
32
|
+
const { isSavedVariableModified , modifiedVariableNames } = getSavedVariablesStatus();
|
|
33
|
+
const { saveChangesConfirmationDialog: dialog } = (0, _context.useSaveChangesConfirmationDialog)();
|
|
34
|
+
const isOpen = dialog !== undefined;
|
|
35
|
+
const { timeRange } = (0, _pluginSystem.useTimeRange)();
|
|
36
|
+
const currentTimeRangeText = (0, _core.isRelativeTimeRange)(timeRange) ? `(Last ${timeRange.pastDuration})` : '(Absolute time ranges can not be saved)';
|
|
37
|
+
const saveTimeRangeText = `Save current time range as new default ${currentTimeRangeText}`;
|
|
38
|
+
const saveVariablesText = `Save current variable values as new default (${modifiedVariableNames.length > 0 ? modifiedVariableNames.join(', ') : 'No modified variables'})`;
|
|
39
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Dialog, {
|
|
40
|
+
open: isOpen,
|
|
41
|
+
children: dialog !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
42
|
+
children: [
|
|
43
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Dialog.Header, {
|
|
44
|
+
onClose: ()=>dialog.onCancel(),
|
|
45
|
+
children: "Save Dashboard"
|
|
46
|
+
}),
|
|
47
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.Dialog.Content, {
|
|
48
|
+
children: [
|
|
49
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
50
|
+
marginBottom: 2,
|
|
51
|
+
children: dialog.description || _core.SAVE_DEFAULTS_DIALOG_TEXT
|
|
52
|
+
}),
|
|
53
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormGroup, {
|
|
54
|
+
children: [
|
|
55
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControlLabel, {
|
|
56
|
+
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Checkbox, {
|
|
57
|
+
disabled: !(0, _core.isRelativeTimeRange)(timeRange),
|
|
58
|
+
checked: saveDefaultTimeRange && (0, _core.isRelativeTimeRange)(timeRange),
|
|
59
|
+
onChange: (e)=>setSaveDefaultTimeRange(e.target.checked)
|
|
60
|
+
}),
|
|
61
|
+
label: saveTimeRangeText
|
|
62
|
+
}),
|
|
63
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControlLabel, {
|
|
64
|
+
control: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Checkbox, {
|
|
65
|
+
disabled: !isSavedVariableModified,
|
|
66
|
+
checked: saveDefaultVariables && isSavedVariableModified,
|
|
67
|
+
onChange: (e)=>setSaveDefaultVariables(e.target.checked)
|
|
68
|
+
}),
|
|
69
|
+
label: saveVariablesText
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_components.Dialog.Actions, {
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Dialog.PrimaryButton, {
|
|
78
|
+
onClick: ()=>{
|
|
79
|
+
return dialog.onSaveChanges(saveDefaultTimeRange, saveDefaultVariables);
|
|
80
|
+
},
|
|
81
|
+
children: "Save Changes"
|
|
82
|
+
}),
|
|
83
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.Dialog.SecondaryButton, {
|
|
84
|
+
onClick: ()=>dialog.onCancel(),
|
|
85
|
+
children: "Cancel"
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
};
|
|
@@ -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("./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
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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 , setDashboard } = (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 = async ()=>{
|
|
59
|
+
if (onSave) {
|
|
60
|
+
try {
|
|
61
|
+
setSavingDashboard(true);
|
|
62
|
+
await onSave(dashboard);
|
|
63
|
+
closeSaveChangesConfirmationDialog();
|
|
64
|
+
setEditMode(false);
|
|
65
|
+
setDashboard(dashboard);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw new Error(`An error occurred while saving the dashboard. ${error}`);
|
|
68
|
+
} finally{
|
|
69
|
+
setSavingDashboard(false);
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
setEditMode(false);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
76
|
+
variant: variant,
|
|
77
|
+
onClick: onSaveButtonClick,
|
|
78
|
+
disabled: isDisabled || isSavingDashboard,
|
|
79
|
+
children: "Save"
|
|
80
|
+
});
|
|
81
|
+
};
|
|
@@ -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
|
}
|