@perses-dev/dashboards 0.54.0-beta.1 → 0.54.0-beta.11
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/Annotations/AnnotationsEditor.js +302 -0
- package/dist/cjs/components/Annotations/EditAnnotationsButton.js +83 -0
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +4 -2
- package/dist/cjs/components/GridLayout/GridItemContent.js +2 -9
- package/dist/cjs/components/Panel/Panel.js +4 -1
- package/dist/cjs/components/PanelDrawer/PanelQueriesSharedControls.js +3 -16
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +20 -3
- package/dist/cjs/components/Variables/VariableEditor.js +52 -18
- package/dist/cjs/constants/user-interface-text.js +1 -0
- package/dist/cjs/context/AnnotationProvider/AnnotationHydrationWrapper.js +50 -0
- package/dist/cjs/context/AnnotationProvider/AnnotationProvider.js +145 -0
- package/dist/{model/DashboardResource.js → cjs/context/AnnotationProvider/index.js} +18 -6
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +9 -2
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +14 -11
- package/dist/cjs/context/DashboardProvider/use-save-dashboard.js +12 -4
- package/dist/cjs/context/DatasourceStoreProvider.js +38 -5
- package/dist/cjs/context/VariableProvider/VariableProvider.js +11 -6
- package/dist/cjs/context/index.js +1 -0
- package/dist/cjs/context/useDashboard.js +11 -1
- package/dist/cjs/model/index.js +1 -1
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +9 -1
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +30 -25
- package/dist/components/AddGroupButton/AddGroupButton.js +1 -1
- package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
- package/dist/components/AddPanelButton/AddPanelButton.js +1 -1
- package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
- package/dist/components/Annotations/AnnotationsEditor.d.ts +8 -0
- package/dist/components/Annotations/AnnotationsEditor.d.ts.map +1 -0
- package/dist/components/Annotations/AnnotationsEditor.js +289 -0
- package/dist/components/Annotations/AnnotationsEditor.js.map +1 -0
- package/dist/components/Annotations/EditAnnotationsButton.d.ts +18 -0
- package/dist/components/Annotations/EditAnnotationsButton.d.ts.map +1 -0
- package/dist/components/Annotations/EditAnnotationsButton.js +70 -0
- package/dist/components/Annotations/EditAnnotationsButton.js.map +1 -0
- package/dist/components/Dashboard/Dashboard.js +1 -1
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/DashboardLinks/DashboardLinksEditor.js +1 -1
- package/dist/components/DashboardLinks/DashboardLinksEditor.js.map +1 -1
- package/dist/components/DashboardLinks/EditDashboardLinksButton.js +1 -1
- package/dist/components/DashboardLinks/EditDashboardLinksButton.js.map +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +5 -3
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.js +1 -1
- package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
- package/dist/components/Datasources/EditDatasourcesButton.js +1 -1
- package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.js +1 -1
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
- package/dist/components/DownloadButton/serializeDashboard.d.ts +1 -1
- package/dist/components/DownloadButton/serializeDashboard.d.ts.map +1 -1
- package/dist/components/DownloadButton/serializeDashboard.js.map +1 -1
- package/dist/components/EditButton/EditButton.js +1 -1
- package/dist/components/EditButton/EditButton.js.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.js +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
- package/dist/components/GridLayout/GridContainer.js +1 -1
- package/dist/components/GridLayout/GridContainer.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +3 -10
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +1 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +1 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/GridLayout/Row.js +1 -1
- package/dist/components/GridLayout/Row.js.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.d.ts +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.js +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -1
- package/dist/components/LinksDisplay/LinksDisplay.js +1 -1
- package/dist/components/LinksDisplay/LinksDisplay.js.map +1 -1
- package/dist/components/Panel/Panel.js +5 -2
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.js +1 -1
- package/dist/components/Panel/PanelActions.js.map +1 -1
- package/dist/components/Panel/PanelContent.js +1 -1
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/Panel/PanelHeader.js +1 -1
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/Panel/PanelPluginLoader.js +1 -1
- package/dist/components/Panel/PanelPluginLoader.js.map +1 -1
- package/dist/components/Panel/useSelectionItemActions.js +1 -1
- package/dist/components/Panel/useSelectionItemActions.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.js +5 -18
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js +1 -1
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +22 -5
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js +1 -1
- package/dist/components/Variables/EditVariablesButton.js.map +1 -1
- package/dist/components/Variables/ListVariableListBox.js +1 -1
- package/dist/components/Variables/ListVariableListBox.js.map +1 -1
- package/dist/components/Variables/Variable.js +2 -2
- 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 +57 -23
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.js +1 -1
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +1 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +1 -0
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/AnnotationProvider/AnnotationHydrationWrapper.d.ts +7 -0
- package/dist/context/AnnotationProvider/AnnotationHydrationWrapper.d.ts.map +1 -0
- package/dist/context/AnnotationProvider/AnnotationHydrationWrapper.js +48 -0
- package/dist/context/AnnotationProvider/AnnotationHydrationWrapper.js.map +1 -0
- package/dist/context/AnnotationProvider/AnnotationProvider.d.ts +40 -0
- package/dist/context/AnnotationProvider/AnnotationProvider.d.ts.map +1 -0
- package/dist/context/AnnotationProvider/AnnotationProvider.js +114 -0
- package/dist/context/AnnotationProvider/AnnotationProvider.js.map +1 -0
- package/dist/context/AnnotationProvider/index.d.ts +2 -0
- package/dist/context/AnnotationProvider/index.d.ts.map +1 -0
- package/dist/{cjs/model/DashboardResource.js → context/AnnotationProvider/index.js} +3 -4
- package/dist/context/AnnotationProvider/index.js.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +4 -2
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +10 -3
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +1 -1
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +2 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +14 -11
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +8 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
- package/dist/context/DashboardProvider/use-save-dashboard.d.ts.map +1 -1
- package/dist/context/DashboardProvider/use-save-dashboard.js +13 -5
- package/dist/context/DashboardProvider/use-save-dashboard.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +1 -2
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +40 -7
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/PanelEditorProvider/PanelEditorProvider.js +1 -1
- package/dist/context/PanelEditorProvider/PanelEditorProvider.js.map +1 -1
- package/dist/context/VariableProvider/VariableProvider.d.ts +2 -1
- package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -1
- package/dist/context/VariableProvider/VariableProvider.js +13 -8
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -0
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboard.d.ts +1 -1
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +11 -1
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/keyboard-shortcuts/PanelFocusProvider.js +1 -1
- package/dist/keyboard-shortcuts/PanelFocusProvider.js.map +1 -1
- package/dist/model/index.d.ts +1 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/test/dashboard-provider.d.ts +1 -1
- package/dist/test/dashboard-provider.d.ts.map +1 -1
- package/dist/test/dashboard-provider.js.map +1 -1
- package/dist/test/datasource-provider.d.ts +1 -1
- package/dist/test/datasource-provider.d.ts.map +1 -1
- package/dist/test/datasource-provider.js.map +1 -1
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/testDashboard.d.ts +1 -1
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +3 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +11 -3
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +32 -27
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +9 -10
- package/dist/model/DashboardResource.d.ts +0 -15
- package/dist/model/DashboardResource.d.ts.map +0 -1
- package/dist/model/DashboardResource.js.map +0 -1
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
// Copyright 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, "AnnotationEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return AnnotationEditor;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _react = require("react");
|
|
25
|
+
const _material = require("@mui/material");
|
|
26
|
+
const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
|
|
27
|
+
const _useimmer = require("use-immer");
|
|
28
|
+
const _Pencil = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Pencil"));
|
|
29
|
+
const _TrashCan = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/TrashCan"));
|
|
30
|
+
const _ArrowUp = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ArrowUp"));
|
|
31
|
+
const _ArrowDown = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ArrowDown"));
|
|
32
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
33
|
+
const _context = require("../../context");
|
|
34
|
+
function _interop_require_default(obj) {
|
|
35
|
+
return obj && obj.__esModule ? obj : {
|
|
36
|
+
default: obj
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function validateAnnotationSpecs(annotationSpecs) {
|
|
40
|
+
const errors = [];
|
|
41
|
+
const annotationNames = [];
|
|
42
|
+
for (const annotationSpec of annotationSpecs){
|
|
43
|
+
if (annotationNames.includes(annotationSpec.display.name)) {
|
|
44
|
+
errors.push(`Duplicate annotation name: ${annotationSpec.display.name}`);
|
|
45
|
+
} else {
|
|
46
|
+
annotationNames.push(annotationSpec.display.name);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
errors: errors,
|
|
51
|
+
isValid: errors.length === 0
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function AnnotationEditor(props) {
|
|
55
|
+
const [annotationSpecs, setAnnotationSpecs] = (0, _useimmer.useImmer)(props.annotationSpecs);
|
|
56
|
+
const [annotationEditIdx, setAnnotationEditIdx] = (0, _react.useState)(null);
|
|
57
|
+
const [annotationFormAction, setAnnotationFormAction] = (0, _react.useState)('update');
|
|
58
|
+
const validation = (0, _react.useMemo)(()=>validateAnnotationSpecs(annotationSpecs), [
|
|
59
|
+
annotationSpecs
|
|
60
|
+
]);
|
|
61
|
+
const currentEditingAnnotationSpec = annotationEditIdx !== null ? annotationSpecs[annotationEditIdx] : undefined;
|
|
62
|
+
const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } = (0, _context.useDiscardChangesConfirmationDialog)();
|
|
63
|
+
const handleCancel = ()=>{
|
|
64
|
+
if (JSON.stringify(props.annotationSpecs) !== JSON.stringify(annotationSpecs)) {
|
|
65
|
+
openDiscardChangesConfirmationDialog({
|
|
66
|
+
onDiscardChanges: ()=>{
|
|
67
|
+
closeDiscardChangesConfirmationDialog();
|
|
68
|
+
props.onCancel();
|
|
69
|
+
},
|
|
70
|
+
onCancel: ()=>{
|
|
71
|
+
closeDiscardChangesConfirmationDialog();
|
|
72
|
+
},
|
|
73
|
+
description: 'You have unapplied changes. Are you sure you want to discard these changes? Changes cannot be recovered.'
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
props.onCancel();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const removeAnnotation = (index)=>{
|
|
80
|
+
setAnnotationSpecs((draft)=>{
|
|
81
|
+
draft.splice(index, 1);
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const addAnnotation = ()=>{
|
|
85
|
+
setAnnotationFormAction('create');
|
|
86
|
+
setAnnotationSpecs((draft)=>{
|
|
87
|
+
draft.push({
|
|
88
|
+
display: {
|
|
89
|
+
name: 'NewAnnotation'
|
|
90
|
+
},
|
|
91
|
+
plugin: {}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
setAnnotationEditIdx(annotationSpecs.length);
|
|
95
|
+
};
|
|
96
|
+
const editAnnotation = (index)=>{
|
|
97
|
+
setAnnotationFormAction('update');
|
|
98
|
+
setAnnotationEditIdx(index);
|
|
99
|
+
};
|
|
100
|
+
const toggleAnnotationVisibility = (index, visible)=>{
|
|
101
|
+
setAnnotationSpecs((draft)=>{
|
|
102
|
+
const v = draft[index];
|
|
103
|
+
if (!v) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
v.display.hidden = !visible;
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
const changeAnnotationOrder = (index, direction)=>{
|
|
110
|
+
const step = direction === 'up' ? -1 : 1;
|
|
111
|
+
setAnnotationSpecs((draft)=>{
|
|
112
|
+
const current = draft[index];
|
|
113
|
+
const adjacent = draft[index + step];
|
|
114
|
+
if (!current || !adjacent) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
draft[index + step] = current;
|
|
118
|
+
draft[index] = adjacent;
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
|
|
122
|
+
children: annotationEditIdx !== null && currentEditingAnnotationSpec ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.ValidationProvider, {
|
|
123
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.AnnotationEditorForm, {
|
|
124
|
+
initialAnnotationSpec: currentEditingAnnotationSpec,
|
|
125
|
+
action: annotationFormAction,
|
|
126
|
+
isDraft: true,
|
|
127
|
+
onActionChange: setAnnotationFormAction,
|
|
128
|
+
onSave: (definition)=>{
|
|
129
|
+
setAnnotationSpecs((draft)=>{
|
|
130
|
+
draft[annotationEditIdx] = definition;
|
|
131
|
+
setAnnotationEditIdx(null);
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
onClose: ()=>{
|
|
135
|
+
if (annotationFormAction === 'create') {
|
|
136
|
+
removeAnnotation(annotationEditIdx);
|
|
137
|
+
}
|
|
138
|
+
setAnnotationEditIdx(null);
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
142
|
+
children: [
|
|
143
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
144
|
+
sx: {
|
|
145
|
+
display: 'flex',
|
|
146
|
+
alignItems: 'center',
|
|
147
|
+
padding: (theme)=>theme.spacing(1, 2),
|
|
148
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
149
|
+
},
|
|
150
|
+
children: [
|
|
151
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
152
|
+
variant: "h2",
|
|
153
|
+
children: "Edit Dashboard Annotations"
|
|
154
|
+
}),
|
|
155
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
156
|
+
direction: "row",
|
|
157
|
+
spacing: 1,
|
|
158
|
+
marginLeft: "auto",
|
|
159
|
+
children: [
|
|
160
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
161
|
+
disabled: props.annotationSpecs === annotationSpecs || !validation.isValid,
|
|
162
|
+
variant: "contained",
|
|
163
|
+
onClick: ()=>{
|
|
164
|
+
props.onChange(annotationSpecs);
|
|
165
|
+
},
|
|
166
|
+
children: "Apply"
|
|
167
|
+
}),
|
|
168
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
169
|
+
color: "secondary",
|
|
170
|
+
variant: "outlined",
|
|
171
|
+
onClick: handleCancel,
|
|
172
|
+
children: "Cancel"
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
}),
|
|
178
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
179
|
+
padding: 2,
|
|
180
|
+
sx: {
|
|
181
|
+
overflowY: 'scroll'
|
|
182
|
+
},
|
|
183
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
184
|
+
spacing: 2,
|
|
185
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
186
|
+
spacing: 2,
|
|
187
|
+
children: [
|
|
188
|
+
!validation.isValid && validation.errors.map((error)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Alert, {
|
|
189
|
+
severity: "error",
|
|
190
|
+
children: error
|
|
191
|
+
}, error)),
|
|
192
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableContainer, {
|
|
193
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Table, {
|
|
194
|
+
sx: {
|
|
195
|
+
minWidth: 650
|
|
196
|
+
},
|
|
197
|
+
"aria-label": "table of annotations",
|
|
198
|
+
children: [
|
|
199
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableHead, {
|
|
200
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TableRow, {
|
|
201
|
+
children: [
|
|
202
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
203
|
+
children: "Visibility"
|
|
204
|
+
}),
|
|
205
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
206
|
+
children: "Name"
|
|
207
|
+
}),
|
|
208
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
209
|
+
children: "Type"
|
|
210
|
+
}),
|
|
211
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
212
|
+
children: "Description"
|
|
213
|
+
}),
|
|
214
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
215
|
+
align: "right",
|
|
216
|
+
children: "Actions"
|
|
217
|
+
})
|
|
218
|
+
]
|
|
219
|
+
})
|
|
220
|
+
}),
|
|
221
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableBody, {
|
|
222
|
+
children: annotationSpecs.map((v, idx)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TableRow, {
|
|
223
|
+
children: [
|
|
224
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
225
|
+
component: "th",
|
|
226
|
+
scope: "row",
|
|
227
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
228
|
+
checked: v.display?.hidden !== true,
|
|
229
|
+
onChange: (e)=>{
|
|
230
|
+
toggleAnnotationVisibility(idx, e.target.checked);
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
}),
|
|
234
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
235
|
+
component: "th",
|
|
236
|
+
scope: "row",
|
|
237
|
+
sx: {
|
|
238
|
+
fontWeight: 'bold'
|
|
239
|
+
},
|
|
240
|
+
children: v.display.name
|
|
241
|
+
}),
|
|
242
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
243
|
+
children: v.plugin.kind
|
|
244
|
+
}),
|
|
245
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
246
|
+
children: v.display?.description ?? ''
|
|
247
|
+
}),
|
|
248
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(TableCell, {
|
|
249
|
+
align: "right",
|
|
250
|
+
sx: {
|
|
251
|
+
whiteSpace: 'nowrap'
|
|
252
|
+
},
|
|
253
|
+
children: [
|
|
254
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
255
|
+
onClick: ()=>changeAnnotationOrder(idx, 'up'),
|
|
256
|
+
disabled: idx === 0,
|
|
257
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ArrowUp.default, {})
|
|
258
|
+
}),
|
|
259
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
260
|
+
onClick: ()=>changeAnnotationOrder(idx, 'down'),
|
|
261
|
+
disabled: idx === annotationSpecs.length - 1,
|
|
262
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ArrowDown.default, {})
|
|
263
|
+
}),
|
|
264
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
265
|
+
onClick: ()=>editAnnotation(idx),
|
|
266
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Pencil.default, {})
|
|
267
|
+
}),
|
|
268
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
269
|
+
onClick: ()=>removeAnnotation(idx),
|
|
270
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_TrashCan.default, {})
|
|
271
|
+
})
|
|
272
|
+
]
|
|
273
|
+
})
|
|
274
|
+
]
|
|
275
|
+
}, v.display.name))
|
|
276
|
+
})
|
|
277
|
+
]
|
|
278
|
+
})
|
|
279
|
+
}),
|
|
280
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
281
|
+
display: "flex",
|
|
282
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
283
|
+
variant: "contained",
|
|
284
|
+
startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {}),
|
|
285
|
+
sx: {
|
|
286
|
+
marginLeft: 'auto'
|
|
287
|
+
},
|
|
288
|
+
onClick: addAnnotation,
|
|
289
|
+
children: "Add Annotation"
|
|
290
|
+
})
|
|
291
|
+
})
|
|
292
|
+
]
|
|
293
|
+
})
|
|
294
|
+
})
|
|
295
|
+
})
|
|
296
|
+
]
|
|
297
|
+
})
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
const TableCell = (0, _material.styled)(_material.TableCell)(({ theme })=>({
|
|
301
|
+
borderBottom: `solid 1px ${theme.palette.divider}`
|
|
302
|
+
}));
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Copyright 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, "EditAnnotationsButton", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return EditAnnotationsButton;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _react = require("react");
|
|
25
|
+
const _material = require("@mui/material");
|
|
26
|
+
const _PencilOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/PencilOutline"));
|
|
27
|
+
const _components = require("@perses-dev/components");
|
|
28
|
+
const _constants = require("../../constants");
|
|
29
|
+
const _context = require("../../context");
|
|
30
|
+
const _AnnotationsEditor = require("./AnnotationsEditor");
|
|
31
|
+
function _interop_require_default(obj) {
|
|
32
|
+
return obj && obj.__esModule ? obj : {
|
|
33
|
+
default: obj
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function EditAnnotationsButton({ variant = 'text', label = 'Annotations', color = 'primary', fullWidth }) {
|
|
37
|
+
const [isAnnotationEditorOpen, setIsAnnotationEditorOpen] = (0, _react.useState)(false);
|
|
38
|
+
const annotationSpecs = (0, _context.useAnnotationSpecs)();
|
|
39
|
+
const { setAnnotationSpecs } = (0, _context.useAnnotationActions)();
|
|
40
|
+
const openAnnotationEditor = ()=>{
|
|
41
|
+
setIsAnnotationEditorOpen(true);
|
|
42
|
+
};
|
|
43
|
+
const closeAnnotationEditor = ()=>{
|
|
44
|
+
setIsAnnotationEditorOpen(false);
|
|
45
|
+
};
|
|
46
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
47
|
+
children: [
|
|
48
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
|
|
49
|
+
description: _constants.TOOLTIP_TEXT.editAnnotations,
|
|
50
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
51
|
+
startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PencilOutline.default, {}),
|
|
52
|
+
onClick: openAnnotationEditor,
|
|
53
|
+
"aria-label": _constants.TOOLTIP_TEXT.editAnnotations,
|
|
54
|
+
variant: variant,
|
|
55
|
+
color: color,
|
|
56
|
+
fullWidth: fullWidth,
|
|
57
|
+
sx: _constants.editButtonStyle,
|
|
58
|
+
children: label
|
|
59
|
+
})
|
|
60
|
+
}),
|
|
61
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Drawer, {
|
|
62
|
+
isOpen: isAnnotationEditorOpen,
|
|
63
|
+
onClose: closeAnnotationEditor,
|
|
64
|
+
slotProps: {
|
|
65
|
+
paper: {
|
|
66
|
+
sx: {
|
|
67
|
+
width: '50%'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"data-testid": "annotation-editor",
|
|
72
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_AnnotationsEditor.AnnotationEditor, {
|
|
73
|
+
annotationSpecs: annotationSpecs,
|
|
74
|
+
onCancel: closeAnnotationEditor,
|
|
75
|
+
onChange: (annotations)=>{
|
|
76
|
+
setAnnotationSpecs(annotations);
|
|
77
|
+
setIsAnnotationEditorOpen(false);
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -34,12 +34,13 @@ const _EditButton = require("../EditButton");
|
|
|
34
34
|
const _EditJsonButton = require("../EditJsonButton");
|
|
35
35
|
const _SaveDashboardButton = require("../SaveDashboardButton");
|
|
36
36
|
const _DashboardStickyToolbar = require("../DashboardStickyToolbar");
|
|
37
|
+
const _EditAnnotationsButton = require("../Annotations/EditAnnotationsButton");
|
|
37
38
|
const _DashboardLinks = require("../DashboardLinks");
|
|
38
39
|
const _LinksDisplay = require("../LinksDisplay");
|
|
39
40
|
const DashboardToolbar = (props)=>{
|
|
40
|
-
const { dashboardName, dashboardTitleComponent, initialVariableIsSticky, isReadonly, isVariableEnabled, isDatasourceEnabled, isLinksEnabled = true, onEditButtonClick, onCancelButtonClick, onSave } = props;
|
|
41
|
+
const { dashboardName, dashboardTitleComponent, initialVariableIsSticky, isReadonly, isVariableEnabled, isAnnotationEnabled, isDatasourceEnabled, isLinksEnabled = true, timezone: toolbarTimezone, onEditButtonClick, onCancelButtonClick, onSave } = props;
|
|
41
42
|
const { isEditMode } = (0, _context.useEditMode)();
|
|
42
|
-
const { timeZone, setTimeZone } = (0, _pluginsystem.useTimeZoneParams)(
|
|
43
|
+
const { timeZone, setTimeZone } = (0, _pluginsystem.useTimeZoneParams)(toolbarTimezone);
|
|
43
44
|
const dashboardLinks = (0, _context.useDashboardLinks)();
|
|
44
45
|
const isBiggerThanSm = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('sm'));
|
|
45
46
|
const isBiggerThanMd = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('md'));
|
|
@@ -91,6 +92,7 @@ const DashboardToolbar = (props)=>{
|
|
|
91
92
|
ml: 1,
|
|
92
93
|
whiteSpace: "nowrap",
|
|
93
94
|
children: [
|
|
95
|
+
isAnnotationEnabled && /*#__PURE__*/ (0, _jsxruntime.jsx)(_EditAnnotationsButton.EditAnnotationsButton, {}),
|
|
94
96
|
isVariableEnabled && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Variables.EditVariablesButton, {}),
|
|
95
97
|
isDatasourceEnabled && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Datasources.EditDatasourcesButton, {}),
|
|
96
98
|
isLinksEnabled && /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardLinks.EditDashboardLinksButton, {}),
|
|
@@ -124,13 +124,6 @@ function GridItemContent(props) {
|
|
|
124
124
|
// map TimeSeriesQueryDefinition to Definition<UnknownSpec>
|
|
125
125
|
const suggestedStepMs = (0, _pluginsystem.useSuggestedStepMs)(width);
|
|
126
126
|
const { data: plugin } = (0, _pluginsystem.usePlugin)('Panel', panelDefinition.spec.plugin.kind);
|
|
127
|
-
const queryDefinitions = queries ?? [];
|
|
128
|
-
const definitions = queryDefinitions.map((query)=>{
|
|
129
|
-
return {
|
|
130
|
-
kind: query.spec.plugin.kind,
|
|
131
|
-
spec: query.spec.plugin.spec
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
127
|
const pluginQueryOptions = typeof plugin?.queryOptions === 'function' ? plugin?.queryOptions(panelDefinition.spec.plugin.spec) : plugin?.queryOptions;
|
|
135
128
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
136
129
|
ref: mergedRef,
|
|
@@ -144,7 +137,7 @@ function GridItemContent(props) {
|
|
|
144
137
|
},
|
|
145
138
|
children: [
|
|
146
139
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DataQueriesProvider, {
|
|
147
|
-
definitions:
|
|
140
|
+
definitions: queries ?? [],
|
|
148
141
|
options: {
|
|
149
142
|
suggestedStepMs,
|
|
150
143
|
...pluginQueryOptions
|
|
@@ -163,7 +156,7 @@ function GridItemContent(props) {
|
|
|
163
156
|
}),
|
|
164
157
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_QueryViewerDialog.QueryViewerDialog, {
|
|
165
158
|
open: openQueryViewer,
|
|
166
|
-
queryDefinitions:
|
|
159
|
+
queryDefinitions: queries ?? [],
|
|
167
160
|
onClose: ()=>setOpenQueryViewer(false)
|
|
168
161
|
})
|
|
169
162
|
]
|
|
@@ -79,7 +79,10 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
|
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
try {
|
|
82
|
-
const plugin = await getPlugin(
|
|
82
|
+
const plugin = await getPlugin({
|
|
83
|
+
kind: 'Panel',
|
|
84
|
+
name: panelPluginKind
|
|
85
|
+
});
|
|
83
86
|
// More defensive checking for plugin and actions
|
|
84
87
|
if (!plugin || typeof plugin !== 'object' || !plugin.actions || !Array.isArray(plugin.actions) || plugin.actions.length === 0) {
|
|
85
88
|
setPluginActions([]);
|
|
@@ -34,22 +34,12 @@ function PanelQueriesSharedControls({ plugin, control, panelDefinition, onQuerie
|
|
|
34
34
|
panelDefinition.spec.plugin.spec,
|
|
35
35
|
pluginPreview
|
|
36
36
|
]);
|
|
37
|
-
const [previewDefinition, setPreviewDefinition] = (0, _react.useState)(
|
|
38
|
-
return {
|
|
39
|
-
kind: query.spec.plugin.kind,
|
|
40
|
-
spec: query.spec.plugin.spec
|
|
41
|
-
};
|
|
42
|
-
}) ?? []);
|
|
37
|
+
const [previewDefinition, setPreviewDefinition] = (0, _react.useState)(panelDefinition.spec.queries ?? []);
|
|
43
38
|
const handleOnQueriesChange = (0, _react.useCallback)((queries)=>{
|
|
44
39
|
onQueriesChange(queries);
|
|
45
40
|
// If the number of queries has changed, force preview definition update to remove results of deleted queries.
|
|
46
41
|
if (queries.length !== previewDefinition.length) {
|
|
47
|
-
setPreviewDefinition(queries
|
|
48
|
-
return {
|
|
49
|
-
kind: query.spec.plugin.kind,
|
|
50
|
-
spec: query.spec.plugin.spec
|
|
51
|
-
};
|
|
52
|
-
}));
|
|
42
|
+
setPreviewDefinition(queries);
|
|
53
43
|
}
|
|
54
44
|
}, [
|
|
55
45
|
onQueriesChange,
|
|
@@ -60,10 +50,7 @@ function PanelQueriesSharedControls({ plugin, control, panelDefinition, onQuerie
|
|
|
60
50
|
const newDefinitions = [
|
|
61
51
|
...prev
|
|
62
52
|
];
|
|
63
|
-
newDefinitions[index] =
|
|
64
|
-
kind: newDef.spec.plugin.kind,
|
|
65
|
-
spec: newDef.spec.plugin.spec
|
|
66
|
-
};
|
|
53
|
+
newDefinitions[index] = newDef;
|
|
67
54
|
return newDefinitions;
|
|
68
55
|
});
|
|
69
56
|
}, []);
|
|
@@ -33,16 +33,20 @@ const SaveChangesConfirmationDialog = ()=>{
|
|
|
33
33
|
const isSavedDurationModified = dialog?.isSavedDurationModified ?? true;
|
|
34
34
|
const isSavedVariableModified = dialog?.isSavedVariableModified ?? true;
|
|
35
35
|
const isSavedRefreshIntervalModified = dialog?.isSavedRefreshIntervalModified ?? true;
|
|
36
|
+
const isSavedTimeZoneModified = dialog?.isTimeZoneModified ?? true;
|
|
36
37
|
const [saveDefaultTimeRange, setSaveDefaultTimeRange] = (0, _react.useState)(isSavedDurationModified);
|
|
37
38
|
const [saveDefaultVariables, setSaveDefaultVariables] = (0, _react.useState)(isSavedVariableModified);
|
|
38
39
|
const [saveDefaultRefreshInterval, setDefaultRefreshInterval] = (0, _react.useState)(isSavedRefreshIntervalModified);
|
|
40
|
+
const [saveDefaultTimeZone, setSaveDefaultTimeZone] = (0, _react.useState)(isSavedTimeZoneModified);
|
|
39
41
|
const { getSavedVariablesStatus } = (0, _context.useVariableDefinitionActions)();
|
|
40
42
|
const { modifiedVariableNames } = getSavedVariablesStatus();
|
|
41
43
|
const isOpen = dialog !== undefined;
|
|
42
44
|
const { timeRange, refreshInterval } = (0, _pluginsystem.useTimeRange)();
|
|
45
|
+
const { timeZone } = (0, _pluginsystem.useTimeZoneParams)();
|
|
43
46
|
const currentTimeRangeText = (0, _spec.isRelativeTimeRange)(timeRange) ? `(Last ${timeRange.pastDuration})` : '(Absolute time ranges can not be saved)';
|
|
44
|
-
const saveTimeRangeMessage = `Save current time range as new default ${currentTimeRangeText}`;
|
|
45
|
-
const
|
|
47
|
+
const saveTimeRangeMessage = `Save current time range as the new default ${currentTimeRangeText}`;
|
|
48
|
+
const saveTimeZoneMessage = `Save the current timezone as the new default (${timeZone})`;
|
|
49
|
+
const saveVariableMessage = `Save current variable values as the new default (${modifiedVariableNames.length > 0 ? modifiedVariableNames.join(', ') : 'No modified variables'})`;
|
|
46
50
|
const refreshIntervalDisplay = _pluginsystem.DEFAULT_REFRESH_INTERVAL_OPTIONS.some((i)=>i.display === refreshInterval) ? refreshInterval : _pluginsystem.DEFAULT_REFRESH_INTERVAL_OPTIONS.find((i)=>i.value.pastDuration === refreshInterval)?.display;
|
|
47
51
|
const saveRefreshIntervalMessage = `Save current refresh interval as new default ${refreshIntervalDisplay ? `(${refreshIntervalDisplay})` : 'refresh interval not modified'}`;
|
|
48
52
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog, {
|
|
@@ -84,6 +88,14 @@ const SaveChangesConfirmationDialog = ()=>{
|
|
|
84
88
|
onChange: (e)=>setSaveDefaultVariables(e.target.checked)
|
|
85
89
|
}),
|
|
86
90
|
label: saveVariableMessage
|
|
91
|
+
}),
|
|
92
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
93
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
|
|
94
|
+
disabled: !isSavedTimeZoneModified,
|
|
95
|
+
checked: saveDefaultTimeZone && isSavedTimeZoneModified,
|
|
96
|
+
onChange: (e)=>setSaveDefaultTimeZone(e.target.checked)
|
|
97
|
+
}),
|
|
98
|
+
label: saveTimeZoneMessage
|
|
87
99
|
})
|
|
88
100
|
]
|
|
89
101
|
})
|
|
@@ -93,7 +105,12 @@ const SaveChangesConfirmationDialog = ()=>{
|
|
|
93
105
|
children: [
|
|
94
106
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Dialog.PrimaryButton, {
|
|
95
107
|
onClick: ()=>{
|
|
96
|
-
return dialog.onSaveChanges(
|
|
108
|
+
return dialog.onSaveChanges({
|
|
109
|
+
saveDefaultTimeRange,
|
|
110
|
+
saveDefaultRefreshInterval,
|
|
111
|
+
saveDefaultVariables,
|
|
112
|
+
saveDefaultTimeZone
|
|
113
|
+
});
|
|
97
114
|
},
|
|
98
115
|
children: "Save Changes"
|
|
99
116
|
}),
|
|
@@ -83,7 +83,7 @@ function VariableEditor(props) {
|
|
|
83
83
|
externalVariableDefinitions,
|
|
84
84
|
variableDefinitions
|
|
85
85
|
]);
|
|
86
|
-
const currentEditingVariableDefinition =
|
|
86
|
+
const currentEditingVariableDefinition = variableEditIdx !== null ? variableDefinitions[variableEditIdx] : undefined;
|
|
87
87
|
const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } = (0, _context.useDiscardChangesConfirmationDialog)();
|
|
88
88
|
const handleCancel = ()=>{
|
|
89
89
|
if (JSON.stringify(props.variableDefinitions) !== JSON.stringify(variableDefinitions)) {
|
|
@@ -166,25 +166,25 @@ function VariableEditor(props) {
|
|
|
166
166
|
};
|
|
167
167
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
168
168
|
children: [
|
|
169
|
-
currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
180
|
-
},
|
|
181
|
-
onClose: ()=>{
|
|
182
|
-
if (variableFormAction === 'create') {
|
|
183
|
-
removeVariable(variableEditIdx);
|
|
184
|
-
}
|
|
169
|
+
variableEditIdx !== null && currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxruntime.jsx)(VariableEditorFormWithContext, {
|
|
170
|
+
variableDefinitions: variableDefinitions,
|
|
171
|
+
externalVariableDefinitions: externalVariableDefinitions,
|
|
172
|
+
builtinVariableDefinitions: builtinVariableDefinitions,
|
|
173
|
+
currentEditingVariableDefinition: currentEditingVariableDefinition,
|
|
174
|
+
variableFormAction: variableFormAction,
|
|
175
|
+
onActionChange: setVariableFormAction,
|
|
176
|
+
onSave: (definition)=>{
|
|
177
|
+
setVariableDefinitions((draft)=>{
|
|
178
|
+
draft[variableEditIdx] = definition;
|
|
185
179
|
setVariableEditIdx(null);
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
onClose: ()=>{
|
|
183
|
+
if (variableFormAction === 'create') {
|
|
184
|
+
removeVariable(variableEditIdx);
|
|
186
185
|
}
|
|
187
|
-
|
|
186
|
+
setVariableEditIdx(null);
|
|
187
|
+
}
|
|
188
188
|
}),
|
|
189
189
|
!currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
190
190
|
children: [
|
|
@@ -535,6 +535,40 @@ function VariableEditor(props) {
|
|
|
535
535
|
const TableCell = (0, _material.styled)(_material.TableCell)(({ theme })=>({
|
|
536
536
|
borderBottom: `solid 1px ${theme.palette.divider}`
|
|
537
537
|
}));
|
|
538
|
+
function VariableEditorFormWithContext({ variableDefinitions, externalVariableDefinitions, builtinVariableDefinitions, currentEditingVariableDefinition, variableFormAction, onActionChange, onSave, onClose }) {
|
|
539
|
+
const { initialVariableValues, isLoading } = (0, _pluginsystem.useResolveListVariableValues)(variableDefinitions);
|
|
540
|
+
if (isLoading) {
|
|
541
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
542
|
+
sx: {
|
|
543
|
+
display: 'flex',
|
|
544
|
+
alignItems: 'center',
|
|
545
|
+
justifyContent: 'center',
|
|
546
|
+
height: '100%',
|
|
547
|
+
width: '100%',
|
|
548
|
+
overflow: 'hidden'
|
|
549
|
+
},
|
|
550
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {
|
|
551
|
+
"aria-label": "loading"
|
|
552
|
+
})
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_context.VariableProvider, {
|
|
556
|
+
initialVariableDefinitions: variableDefinitions,
|
|
557
|
+
externalVariableDefinitions: externalVariableDefinitions,
|
|
558
|
+
builtinVariableDefinitions: builtinVariableDefinitions,
|
|
559
|
+
initialVariableValues: initialVariableValues,
|
|
560
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.ValidationProvider, {
|
|
561
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.VariableEditorForm, {
|
|
562
|
+
initialVariableDefinition: currentEditingVariableDefinition,
|
|
563
|
+
action: variableFormAction,
|
|
564
|
+
isDraft: true,
|
|
565
|
+
onActionChange: onActionChange,
|
|
566
|
+
onSave: onSave,
|
|
567
|
+
onClose: onClose
|
|
568
|
+
})
|
|
569
|
+
})
|
|
570
|
+
});
|
|
571
|
+
}
|
|
538
572
|
function VariableName(props) {
|
|
539
573
|
const { name, state } = props;
|
|
540
574
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|