@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,50 @@
|
|
|
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, "AnnotationHydrationWrapper", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return AnnotationHydrationWrapper;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _react = require("react");
|
|
25
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
26
|
+
const _AnnotationProvider = require("./AnnotationProvider");
|
|
27
|
+
function AnnotationHydrationWrapper({ children }) {
|
|
28
|
+
const annotationSpecs = (0, _AnnotationProvider.useAnnotationSpecs)();
|
|
29
|
+
const { setAnnotationState } = (0, _AnnotationProvider.useAnnotationActions)();
|
|
30
|
+
const annotations = (0, _pluginsystem.useAnnotations)(annotationSpecs);
|
|
31
|
+
(0, _react.useEffect)(()=>{
|
|
32
|
+
for (const [index, definition] of annotationSpecs.entries()){
|
|
33
|
+
const query = annotations[index] ?? null;
|
|
34
|
+
if (query) {
|
|
35
|
+
setAnnotationState(definition.display.name, {
|
|
36
|
+
data: query.data ?? null,
|
|
37
|
+
isPending: query.isLoading,
|
|
38
|
+
error: query?.error ?? null
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, [
|
|
43
|
+
annotationSpecs,
|
|
44
|
+
annotations,
|
|
45
|
+
setAnnotationState
|
|
46
|
+
]);
|
|
47
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
get AnnotationProvider () {
|
|
25
|
+
return AnnotationProvider;
|
|
26
|
+
},
|
|
27
|
+
get useAnnotationActions () {
|
|
28
|
+
return useAnnotationActions;
|
|
29
|
+
},
|
|
30
|
+
get useAnnotationSpecAndState () {
|
|
31
|
+
return useAnnotationSpecAndState;
|
|
32
|
+
},
|
|
33
|
+
get useAnnotationSpecs () {
|
|
34
|
+
return useAnnotationSpecs;
|
|
35
|
+
},
|
|
36
|
+
get useAnnotationStates () {
|
|
37
|
+
return useAnnotationStates;
|
|
38
|
+
},
|
|
39
|
+
get useAnnotationStoreCtx () {
|
|
40
|
+
return useAnnotationStoreCtx;
|
|
41
|
+
},
|
|
42
|
+
get useAnnotationsWithData () {
|
|
43
|
+
return useAnnotationsWithData;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
47
|
+
const _react = require("react");
|
|
48
|
+
const _zustand = require("zustand");
|
|
49
|
+
const _traditional = require("zustand/traditional");
|
|
50
|
+
const _shallow = require("zustand/shallow");
|
|
51
|
+
const _middleware = require("zustand/middleware");
|
|
52
|
+
const _immer = require("zustand/middleware/immer");
|
|
53
|
+
const _AnnotationHydrationWrapper = require("./AnnotationHydrationWrapper");
|
|
54
|
+
const AnnotationStoreContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
55
|
+
function useAnnotationStoreCtx() {
|
|
56
|
+
const context = (0, _react.useContext)(AnnotationStoreContext);
|
|
57
|
+
if (!context) {
|
|
58
|
+
return createAnnotationStore({
|
|
59
|
+
initialAnnotationSpecs: []
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return context;
|
|
63
|
+
}
|
|
64
|
+
function useAnnotationSpecs() {
|
|
65
|
+
const store = useAnnotationStoreCtx();
|
|
66
|
+
return (0, _zustand.useStore)(store, (s)=>s.annotationSpecs);
|
|
67
|
+
}
|
|
68
|
+
function useAnnotationStates(annotationNames) {
|
|
69
|
+
const store = useAnnotationStoreCtx();
|
|
70
|
+
return (0, _traditional.useStoreWithEqualityFn)(store, (s)=>{
|
|
71
|
+
if (annotationNames) {
|
|
72
|
+
const result = {};
|
|
73
|
+
annotationNames.forEach((name)=>{
|
|
74
|
+
const s = store.getState().annotationState[name];
|
|
75
|
+
if (s) {
|
|
76
|
+
result[name] = s;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
return s.annotationState;
|
|
82
|
+
}, (left, right)=>{
|
|
83
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function useAnnotationActions() {
|
|
87
|
+
const store = useAnnotationStoreCtx();
|
|
88
|
+
return (0, _traditional.useStoreWithEqualityFn)(store, (s)=>{
|
|
89
|
+
return {
|
|
90
|
+
setAnnotationState: s.setAnnotationState,
|
|
91
|
+
setAnnotationSpecs: s.setAnnotationSpecs
|
|
92
|
+
};
|
|
93
|
+
}, _shallow.shallow);
|
|
94
|
+
}
|
|
95
|
+
function useAnnotationSpecAndState(name) {
|
|
96
|
+
const store = useAnnotationStoreCtx();
|
|
97
|
+
return (0, _zustand.useStore)(store, (s)=>{
|
|
98
|
+
return {
|
|
99
|
+
definition: s.annotationSpecs.find((d)=>d.display.name === name),
|
|
100
|
+
state: s.annotationState[name]
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function useAnnotationsWithData() {
|
|
105
|
+
const store = useAnnotationStoreCtx();
|
|
106
|
+
return (0, _zustand.useStore)(store, (s)=>{
|
|
107
|
+
return s.annotationSpecs.map((definition)=>{
|
|
108
|
+
const state = s.annotationState[definition.display.name];
|
|
109
|
+
return {
|
|
110
|
+
definition,
|
|
111
|
+
data: state?.data
|
|
112
|
+
};
|
|
113
|
+
}).filter((annotation)=>!!annotation.data);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function createAnnotationStore({ initialAnnotationSpecs = [] }) {
|
|
117
|
+
const store = (0, _zustand.createStore)()((0, _middleware.devtools)((0, _immer.immer)((set, _get)=>({
|
|
118
|
+
annotationSpecs: initialAnnotationSpecs,
|
|
119
|
+
annotationState: {},
|
|
120
|
+
setAnnotationSpecs (definitions) {
|
|
121
|
+
set((s)=>{
|
|
122
|
+
s.annotationSpecs = definitions;
|
|
123
|
+
}, false, '[Annotations] setAnnotationSpecs' // Used for action name in Redux devtools
|
|
124
|
+
);
|
|
125
|
+
},
|
|
126
|
+
setAnnotationState: (name, state)=>{
|
|
127
|
+
set((s)=>{
|
|
128
|
+
s.annotationState[name] = state;
|
|
129
|
+
}, false, '[Annotations] setAnnotationState' // Used for action name in Redux devtools
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}))));
|
|
133
|
+
return store;
|
|
134
|
+
}
|
|
135
|
+
function AnnotationProvider({ children, initialAnnotationSpecs = [] }) {
|
|
136
|
+
const [store] = (0, _react.useState)(()=>createAnnotationStore({
|
|
137
|
+
initialAnnotationSpecs
|
|
138
|
+
}));
|
|
139
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(AnnotationStoreContext.Provider, {
|
|
140
|
+
value: store,
|
|
141
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_AnnotationHydrationWrapper.AnnotationHydrationWrapper, {
|
|
142
|
+
children: children
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
}
|
|
@@ -10,9 +10,21 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_export_star(require("./AnnotationProvider"), exports);
|
|
18
|
+
function _export_star(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
21
|
+
Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return from;
|
|
30
|
+
}
|
|
@@ -92,7 +92,7 @@ function DashboardProvider(props) {
|
|
|
92
92
|
}
|
|
93
93
|
function initStore(props) {
|
|
94
94
|
const { initialState: { dashboardResource, isEditMode, viewPanelRef, setViewPanelRef } } = props;
|
|
95
|
-
const { kind, metadata, spec: { display, duration, refreshInterval = _constants.DEFAULT_REFRESH_INTERVAL, datasources, layouts = [], panels = {} } } = dashboardResource;
|
|
95
|
+
const { kind, metadata, spec: { display, timezone, duration, refreshInterval = _constants.DEFAULT_REFRESH_INTERVAL, datasources, layouts = [], panels = {} } } = dashboardResource;
|
|
96
96
|
const links = dashboardResource.spec.links ?? [];
|
|
97
97
|
const ttl = 'ttl' in dashboardResource.spec ? dashboardResource.spec.ttl : undefined;
|
|
98
98
|
const store = (0, _zustand.createStore)()((0, _immer.immer)((0, _middleware.devtools)((...args)=>{
|
|
@@ -113,6 +113,7 @@ function initStore(props) {
|
|
|
113
113
|
kind,
|
|
114
114
|
metadata,
|
|
115
115
|
display,
|
|
116
|
+
timezone,
|
|
116
117
|
duration,
|
|
117
118
|
refreshInterval,
|
|
118
119
|
datasources,
|
|
@@ -123,11 +124,12 @@ function initStore(props) {
|
|
|
123
124
|
isEditMode
|
|
124
125
|
});
|
|
125
126
|
},
|
|
126
|
-
setDashboard: ({ kind, metadata, spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {}, links = [] } })=>{
|
|
127
|
+
setDashboard: ({ kind, metadata, spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {}, links = [], timezone } })=>{
|
|
127
128
|
set((state)=>{
|
|
128
129
|
state.kind = kind;
|
|
129
130
|
state.metadata = metadata;
|
|
130
131
|
state.display = display;
|
|
132
|
+
state.timezone = timezone;
|
|
131
133
|
state.panels = panels;
|
|
132
134
|
const { panelGroups, panelGroupOrder } = (0, _panelgroupslice.convertLayoutsToPanelGroups)(layouts);
|
|
133
135
|
state.panelGroups = panelGroups;
|
|
@@ -138,6 +140,11 @@ function initStore(props) {
|
|
|
138
140
|
state.links = links;
|
|
139
141
|
// TODO: add ttl here to e.g allow edition from JSON view, but probably requires quite some refactoring
|
|
140
142
|
});
|
|
143
|
+
},
|
|
144
|
+
setMetadata: (metadata)=>{
|
|
145
|
+
set((state)=>{
|
|
146
|
+
state.metadata = typeof metadata === 'function' ? metadata(state.metadata) : metadata;
|
|
147
|
+
});
|
|
141
148
|
}
|
|
142
149
|
};
|
|
143
150
|
})));
|
|
@@ -78,23 +78,26 @@ function convertLayoutsToPanelGroups(layouts) {
|
|
|
78
78
|
const itemLayouts = [];
|
|
79
79
|
const itemPanelKeys = {};
|
|
80
80
|
// Split layout information from panel keys to make it easier to update just layouts on move/resize of panels
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
if ('items' in layout.spec) {
|
|
82
|
+
for (const item of layout.spec.items){
|
|
83
|
+
const panelGroupLayoutId = (0, _common.generateId)().toString();
|
|
84
|
+
itemLayouts.push({
|
|
85
|
+
i: panelGroupLayoutId,
|
|
86
|
+
w: item.width,
|
|
87
|
+
h: item.height,
|
|
88
|
+
x: item.x,
|
|
89
|
+
y: item.y
|
|
90
|
+
});
|
|
91
|
+
itemPanelKeys[panelGroupLayoutId] = (0, _spec.getPanelKeyFromRef)(item.content);
|
|
92
|
+
}
|
|
91
93
|
}
|
|
92
94
|
// Create the panel group and keep track of the ID order
|
|
95
|
+
const repeatVariable = 'repeatVariable' in layout.spec ? layout.spec.repeatVariable : undefined;
|
|
93
96
|
const panelGroupId = (0, _common.generateId)();
|
|
94
97
|
panelGroups[panelGroupId] = {
|
|
95
98
|
id: panelGroupId,
|
|
96
99
|
isCollapsed: layout.spec.display?.collapse?.open === false,
|
|
97
|
-
repeatVariable
|
|
100
|
+
repeatVariable,
|
|
98
101
|
title: layout.spec.display?.title,
|
|
99
102
|
itemLayouts,
|
|
100
103
|
itemPanelKeys
|
|
@@ -31,6 +31,7 @@ function useSaveDashboard(onSave) {
|
|
|
31
31
|
const { dashboard, setDashboard } = (0, _useDashboard.useDashboard)();
|
|
32
32
|
const { setEditMode } = (0, _dashboardproviderapi.useEditMode)();
|
|
33
33
|
const { timeRange, refreshInterval } = (0, _pluginsystem.useTimeRange)();
|
|
34
|
+
const { timeZone } = (0, _pluginsystem.useTimeZoneParams)();
|
|
34
35
|
const { getSavedVariablesStatus, setVariableDefaultValues } = (0, _VariableProvider.useVariableDefinitionActions)();
|
|
35
36
|
const { openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog } = (0, _dashboardproviderapi.useSaveChangesConfirmationDialog)();
|
|
36
37
|
const performSave = (0, _react.useCallback)(async ()=>{
|
|
@@ -59,12 +60,17 @@ function useSaveDashboard(onSave) {
|
|
|
59
60
|
const { isSavedVariableModified } = getSavedVariablesStatus();
|
|
60
61
|
const isSavedDurationModified = (0, _spec.isRelativeTimeRange)(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;
|
|
61
62
|
const isSavedRefreshIntervalModified = dashboard.spec.refreshInterval !== refreshInterval;
|
|
62
|
-
|
|
63
|
+
const isTimeZoneModified = timeZone === 'local' && !dashboard.spec.timezone ? false : dashboard.spec.timezone !== timeZone;
|
|
64
|
+
if (isSavedDurationModified || isSavedVariableModified || isSavedRefreshIntervalModified || isTimeZoneModified) {
|
|
63
65
|
openSaveChangesConfirmationDialog({
|
|
64
|
-
onSaveChanges: (
|
|
66
|
+
onSaveChanges: (options)=>{
|
|
67
|
+
const { saveDefaultRefreshInterval, saveDefaultTimeRange, saveDefaultTimeZone, saveDefaultVariables } = options;
|
|
65
68
|
if ((0, _spec.isRelativeTimeRange)(timeRange) && saveDefaultTimeRange) {
|
|
66
69
|
dashboard.spec.duration = timeRange.pastDuration;
|
|
67
70
|
}
|
|
71
|
+
if (saveDefaultTimeZone) {
|
|
72
|
+
dashboard.spec.timezone = timeZone;
|
|
73
|
+
}
|
|
68
74
|
if (saveDefaultVariables) {
|
|
69
75
|
const variables = setVariableDefaultValues();
|
|
70
76
|
dashboard.spec.variables = variables;
|
|
@@ -80,17 +86,19 @@ function useSaveDashboard(onSave) {
|
|
|
80
86
|
},
|
|
81
87
|
isSavedDurationModified,
|
|
82
88
|
isSavedVariableModified,
|
|
83
|
-
isSavedRefreshIntervalModified
|
|
89
|
+
isSavedRefreshIntervalModified,
|
|
90
|
+
isTimeZoneModified
|
|
84
91
|
});
|
|
85
92
|
} else {
|
|
86
93
|
performSave();
|
|
87
94
|
}
|
|
88
95
|
}, [
|
|
89
96
|
isSaving,
|
|
90
|
-
getSavedVariablesStatus,
|
|
91
97
|
timeRange,
|
|
92
98
|
dashboard,
|
|
93
99
|
refreshInterval,
|
|
100
|
+
timeZone,
|
|
101
|
+
getSavedVariablesStatus,
|
|
94
102
|
openSaveChangesConfirmationDialog,
|
|
95
103
|
setVariableDefaultValues,
|
|
96
104
|
setDashboard,
|
|
@@ -27,15 +27,24 @@ function DatasourceStoreProvider(props) {
|
|
|
27
27
|
const { projectName, datasourceApi, onCreate, children } = props;
|
|
28
28
|
const [dashboardResource, setDashboardResource] = (0, _react.useState)(props.dashboardResource);
|
|
29
29
|
const [savedDatasources, setSavedDatasources] = (0, _react.useState)(props.savedDatasources ?? {});
|
|
30
|
+
// Cache for synchronous datasource spec access
|
|
31
|
+
const datasourceSpecCache = (0, _react.useRef)(new Map());
|
|
30
32
|
const project = projectName ?? dashboardResource?.metadata.project;
|
|
31
33
|
const { getPlugin, listPluginMetadata } = (0, _pluginsystem.usePluginRegistry)();
|
|
34
|
+
// Helper to create cache key from DatasourceSelector
|
|
35
|
+
const createCacheKey = (0, _react.useCallback)((selector)=>{
|
|
36
|
+
const name = selector.name === undefined ? '__undefined__' : selector.name;
|
|
37
|
+
return `${selector.kind}:${name}:${project ?? 'global'}`;
|
|
38
|
+
}, [
|
|
39
|
+
project
|
|
40
|
+
]);
|
|
32
41
|
const findDatasource = (0, _pluginsystem.useEvent)(async (selector)=>{
|
|
33
42
|
// Try to find it in dashboard spec
|
|
34
43
|
if (dashboardResource) {
|
|
35
44
|
const { datasources } = dashboardResource.spec;
|
|
36
45
|
const dashboardDatasource = findDashboardDatasource(datasources, selector);
|
|
37
46
|
if (dashboardDatasource !== undefined) {
|
|
38
|
-
|
|
47
|
+
const result = {
|
|
39
48
|
spec: dashboardDatasource.spec,
|
|
40
49
|
proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
|
|
41
50
|
project: dashboardResource.metadata.project,
|
|
@@ -43,30 +52,42 @@ function DatasourceStoreProvider(props) {
|
|
|
43
52
|
name: dashboardDatasource.name
|
|
44
53
|
})
|
|
45
54
|
};
|
|
55
|
+
// Cache the spec for synchronous access
|
|
56
|
+
const cacheKey = createCacheKey(selector);
|
|
57
|
+
datasourceSpecCache.current.set(cacheKey, result.spec);
|
|
58
|
+
return result;
|
|
46
59
|
}
|
|
47
60
|
}
|
|
48
61
|
if (project) {
|
|
49
62
|
// Try to find it at the project level as a Datasource resource
|
|
50
63
|
const datasource = await datasourceApi.getDatasource(String(project), selector);
|
|
51
64
|
if (datasource !== undefined) {
|
|
52
|
-
|
|
65
|
+
const result = {
|
|
53
66
|
spec: datasource.spec,
|
|
54
67
|
proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
|
|
55
68
|
project: datasource.metadata.project,
|
|
56
69
|
name: datasource.metadata.name
|
|
57
70
|
})
|
|
58
71
|
};
|
|
72
|
+
// Cache the spec for synchronous access
|
|
73
|
+
const cacheKey = createCacheKey(selector);
|
|
74
|
+
datasourceSpecCache.current.set(cacheKey, result.spec);
|
|
75
|
+
return result;
|
|
59
76
|
}
|
|
60
77
|
}
|
|
61
78
|
// Try to find it at the global level as a GlobalDatasource resource
|
|
62
79
|
const globalDatasource = await datasourceApi.getGlobalDatasource(selector);
|
|
63
80
|
if (globalDatasource !== undefined) {
|
|
64
|
-
|
|
81
|
+
const result = {
|
|
65
82
|
spec: globalDatasource.spec,
|
|
66
83
|
proxyUrl: buildDatasourceProxyUrl(datasourceApi, {
|
|
67
84
|
name: globalDatasource.metadata.name
|
|
68
85
|
})
|
|
69
86
|
};
|
|
87
|
+
// Cache the spec for synchronous access
|
|
88
|
+
const cacheKey = createCacheKey(selector);
|
|
89
|
+
datasourceSpecCache.current.set(cacheKey, result.spec);
|
|
90
|
+
return result;
|
|
70
91
|
}
|
|
71
92
|
throw new Error(`No datasource found for kind '${selector.kind}' and name '${selector.name}'`);
|
|
72
93
|
});
|
|
@@ -82,7 +103,10 @@ function DatasourceStoreProvider(props) {
|
|
|
82
103
|
const { kind } = selector;
|
|
83
104
|
const [{ spec, proxyUrl }, plugin] = await Promise.all([
|
|
84
105
|
findDatasource(selector),
|
|
85
|
-
getPlugin(
|
|
106
|
+
getPlugin({
|
|
107
|
+
kind: 'Datasource',
|
|
108
|
+
name: kind
|
|
109
|
+
})
|
|
86
110
|
]);
|
|
87
111
|
// allows extending client
|
|
88
112
|
const client = plugin.createClient(spec.plugin.spec, {
|
|
@@ -158,6 +182,13 @@ function DatasourceStoreProvider(props) {
|
|
|
158
182
|
}, [
|
|
159
183
|
savedDatasources
|
|
160
184
|
]);
|
|
185
|
+
// Gets a cached datasource spec synchronously if available
|
|
186
|
+
const getDatasourceSpecSync = (0, _react.useCallback)((selector)=>{
|
|
187
|
+
const cacheKey = createCacheKey(selector);
|
|
188
|
+
return datasourceSpecCache.current.get(cacheKey);
|
|
189
|
+
}, [
|
|
190
|
+
createCacheKey
|
|
191
|
+
]);
|
|
161
192
|
const setLocalDatasources = (0, _react.useCallback)((datasources)=>{
|
|
162
193
|
if (dashboardResource) {
|
|
163
194
|
setDashboardResource({
|
|
@@ -174,6 +205,7 @@ function DatasourceStoreProvider(props) {
|
|
|
174
205
|
const ctxValue = (0, _react.useMemo)(()=>({
|
|
175
206
|
getDatasource,
|
|
176
207
|
getDatasourceClient,
|
|
208
|
+
getDatasourceSpecSync,
|
|
177
209
|
getLocalDatasources,
|
|
178
210
|
setLocalDatasources,
|
|
179
211
|
setSavedDatasources,
|
|
@@ -182,6 +214,7 @@ function DatasourceStoreProvider(props) {
|
|
|
182
214
|
}), [
|
|
183
215
|
getDatasource,
|
|
184
216
|
getDatasourceClient,
|
|
217
|
+
getDatasourceSpecSync,
|
|
185
218
|
getLocalDatasources,
|
|
186
219
|
setLocalDatasources,
|
|
187
220
|
listDatasourceSelectItems,
|
|
@@ -263,7 +296,7 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
263
296
|
});
|
|
264
297
|
usedNames.add(selectorName);
|
|
265
298
|
const isExplicitDefault = !isOverridden && spec.default && !explicitDefaultAdded;
|
|
266
|
-
if (results[0] &&
|
|
299
|
+
if (results[0] && isExplicitDefault) {
|
|
267
300
|
// If we haven't added a default yet and this is a default, add default option to the beginning of the results
|
|
268
301
|
results[0].items = [
|
|
269
302
|
{
|
|
@@ -55,7 +55,6 @@ const _middleware = require("zustand/middleware");
|
|
|
55
55
|
const _shallow = require("zustand/shallow");
|
|
56
56
|
const _immer1 = require("immer");
|
|
57
57
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
58
|
-
const _core = require("@perses-dev/core");
|
|
59
58
|
const _spec = require("@perses-dev/spec");
|
|
60
59
|
const _utils = require("./utils");
|
|
61
60
|
const _hydrationUtils = require("./hydrationUtils");
|
|
@@ -160,6 +159,7 @@ function PluginProvider({ children, builtinVariables }) {
|
|
|
160
159
|
// If the variable is a list variable and has a custom all value, then use that value instead
|
|
161
160
|
if (definition?.kind === 'ListVariable' && definition.spec.customAllValue) {
|
|
162
161
|
v.value = definition.spec.customAllValue;
|
|
162
|
+
v.customAllValue = definition.spec.customAllValue;
|
|
163
163
|
} else {
|
|
164
164
|
v.value = v.options?.map((o)=>o.value) ?? null;
|
|
165
165
|
}
|
|
@@ -204,7 +204,7 @@ function PluginProvider({ children, builtinVariables }) {
|
|
|
204
204
|
kind: 'BuiltinVariable',
|
|
205
205
|
spec: {
|
|
206
206
|
name: '__range',
|
|
207
|
-
value: ()=>(0, _spec.formatDuration)((0,
|
|
207
|
+
value: ()=>(0, _spec.formatDuration)((0, _spec.intervalToDuration)(absoluteTimeRange)),
|
|
208
208
|
source: 'Dashboard',
|
|
209
209
|
display: {
|
|
210
210
|
name: '__range',
|
|
@@ -258,8 +258,12 @@ function PluginProvider({ children, builtinVariables }) {
|
|
|
258
258
|
})
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
|
-
function createVariableDefinitionStore({ initialVariableDefinitions = [], externalVariableDefinitions = [], queryParams }) {
|
|
262
|
-
const
|
|
261
|
+
function createVariableDefinitionStore({ initialVariableDefinitions = [], externalVariableDefinitions = [], queryParams, initialVariableValues }) {
|
|
262
|
+
const queryParamValues = (0, _queryparams.getInitalValuesFromQueryParameters)(queryParams ? queryParams[0] : {});
|
|
263
|
+
const initialParams = {
|
|
264
|
+
...queryParamValues,
|
|
265
|
+
...initialVariableValues
|
|
266
|
+
};
|
|
263
267
|
const store = (0, _zustand.createStore)()((0, _middleware.devtools)((0, _immer.immer)((set, get)=>({
|
|
264
268
|
variableState: (0, _hydrationUtils.hydrateVariableDefinitionStates)(initialVariableDefinitions, initialParams, externalVariableDefinitions),
|
|
265
269
|
variableDefinitions: initialVariableDefinitions,
|
|
@@ -365,10 +369,11 @@ function createVariableDefinitionStore({ initialVariableDefinitions = [], extern
|
|
|
365
369
|
}))));
|
|
366
370
|
return store;
|
|
367
371
|
}
|
|
368
|
-
function VariableProvider({ children, initialVariableDefinitions = [], externalVariableDefinitions = [], builtinVariableDefinitions = [] }) {
|
|
372
|
+
function VariableProvider({ children, initialVariableDefinitions = [], externalVariableDefinitions = [], builtinVariableDefinitions = [], initialVariableValues }) {
|
|
369
373
|
const [store] = (0, _react.useState)(()=>createVariableDefinitionStore({
|
|
370
374
|
initialVariableDefinitions,
|
|
371
|
-
externalVariableDefinitions
|
|
375
|
+
externalVariableDefinitions,
|
|
376
|
+
initialVariableValues
|
|
372
377
|
}));
|
|
373
378
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(VariableDefinitionStoreContext.Provider, {
|
|
374
379
|
value: store,
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
+
_export_star(require("./AnnotationProvider"), exports);
|
|
17
18
|
_export_star(require("./DashboardProvider"), exports);
|
|
18
19
|
_export_star(require("./DatasourceStoreProvider"), exports);
|
|
19
20
|
_export_star(require("./VariableProvider"), exports);
|
|
@@ -23,14 +23,16 @@ Object.defineProperty(exports, "useDashboard", {
|
|
|
23
23
|
const _spec = require("@perses-dev/spec");
|
|
24
24
|
const _DashboardProvider = require("./DashboardProvider");
|
|
25
25
|
const _VariableProvider = require("./VariableProvider");
|
|
26
|
+
const _AnnotationProvider = require("./AnnotationProvider");
|
|
26
27
|
function useDashboard() {
|
|
27
|
-
const { panels, panelGroups, panelGroupOrder, setDashboard: setDashboardResource, kind, metadata, display, duration, refreshInterval, datasources, links, ttl } = (0, _DashboardProvider.useDashboardStore)(({ panels, panelGroups, panelGroupOrder, setDashboard, kind, metadata, display, duration, refreshInterval, datasources, links, ttl })=>({
|
|
28
|
+
const { panels, panelGroups, panelGroupOrder, setDashboard: setDashboardResource, kind, metadata, display, timezone, duration, refreshInterval, datasources, links, ttl } = (0, _DashboardProvider.useDashboardStore)(({ panels, panelGroups, panelGroupOrder, setDashboard, kind, metadata, timezone, display, duration, refreshInterval, datasources, links, ttl })=>({
|
|
28
29
|
panels,
|
|
29
30
|
panelGroups,
|
|
30
31
|
panelGroupOrder,
|
|
31
32
|
setDashboard,
|
|
32
33
|
kind,
|
|
33
34
|
metadata,
|
|
35
|
+
timezone,
|
|
34
36
|
display,
|
|
35
37
|
duration,
|
|
36
38
|
refreshInterval,
|
|
@@ -39,7 +41,9 @@ function useDashboard() {
|
|
|
39
41
|
ttl
|
|
40
42
|
}));
|
|
41
43
|
const { setVariableDefinitions } = (0, _VariableProvider.useVariableDefinitionActions)();
|
|
44
|
+
const { setAnnotationSpecs } = (0, _AnnotationProvider.useAnnotationActions)();
|
|
42
45
|
const variables = (0, _VariableProvider.useVariableDefinitions)();
|
|
46
|
+
const annotations = (0, _AnnotationProvider.useAnnotationSpecs)();
|
|
43
47
|
const layouts = convertPanelGroupsToLayouts(panelGroups, panelGroupOrder);
|
|
44
48
|
const dashboard = kind === 'Dashboard' ? {
|
|
45
49
|
kind,
|
|
@@ -49,7 +53,9 @@ function useDashboard() {
|
|
|
49
53
|
panels,
|
|
50
54
|
layouts,
|
|
51
55
|
variables,
|
|
56
|
+
annotations,
|
|
52
57
|
duration,
|
|
58
|
+
timezone,
|
|
53
59
|
refreshInterval,
|
|
54
60
|
datasources,
|
|
55
61
|
links
|
|
@@ -62,6 +68,7 @@ function useDashboard() {
|
|
|
62
68
|
panels,
|
|
63
69
|
layouts,
|
|
64
70
|
variables,
|
|
71
|
+
annotations,
|
|
65
72
|
duration,
|
|
66
73
|
refreshInterval,
|
|
67
74
|
datasources,
|
|
@@ -71,6 +78,9 @@ function useDashboard() {
|
|
|
71
78
|
};
|
|
72
79
|
const setDashboard = (dashboardResource)=>{
|
|
73
80
|
setVariableDefinitions(dashboardResource.spec.variables);
|
|
81
|
+
if (dashboardResource.spec.annotations) {
|
|
82
|
+
setAnnotationSpecs(dashboardResource.spec.annotations);
|
|
83
|
+
}
|
|
74
84
|
setDashboardResource(dashboardResource);
|
|
75
85
|
};
|
|
76
86
|
return {
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
_export_star(require("./DashboardResource"), exports);
|
|
18
17
|
_export_star(require("./PanelGroupDefinition"), exports);
|
|
18
|
+
_export_star(require("./VariableDefinition"), exports);
|
|
19
19
|
function _export_star(from, to) {
|
|
20
20
|
Object.keys(from).forEach(function(k) {
|
|
21
21
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -36,7 +36,7 @@ const DashboardApp = (props)=>{
|
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
const DashboardAppContent = (props)=>{
|
|
39
|
-
const { dashboardResource, emptyDashboardProps, isReadonly, isVariableEnabled, isDatasourceEnabled, disableShortcuts, isCreating, isInitialVariableSticky, isLeavingConfirmDialogEnabled, dashboardTitleComponent, onSave, onDiscard } = props;
|
|
39
|
+
const { dashboardResource, emptyDashboardProps, isReadonly, isVariableEnabled, isAnnotationEnabled, isDatasourceEnabled, disableShortcuts, isCreating, isInitialVariableSticky, isLeavingConfirmDialogEnabled, dashboardTitleComponent, userPreferenceTimezone, onSave, onDiscard } = props;
|
|
40
40
|
const chartsTheme = (0, _components.useChartsTheme)();
|
|
41
41
|
const { isEditMode, setEditMode } = (0, _context.useEditMode)();
|
|
42
42
|
const { dashboard, setDashboard } = (0, _context.useDashboard)();
|
|
@@ -81,6 +81,12 @@ const DashboardAppContent = (props)=>{
|
|
|
81
81
|
onCancelButtonClick,
|
|
82
82
|
disabled: disableShortcuts
|
|
83
83
|
});
|
|
84
|
+
const toolBarTimezone = (0, _react.useMemo)(()=>{
|
|
85
|
+
return dashboardResource.spec.timezone || userPreferenceTimezone || 'local';
|
|
86
|
+
}, [
|
|
87
|
+
dashboardResource.spec,
|
|
88
|
+
userPreferenceTimezone
|
|
89
|
+
]);
|
|
84
90
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
85
91
|
sx: {
|
|
86
92
|
flexGrow: 1,
|
|
@@ -92,11 +98,13 @@ const DashboardAppContent = (props)=>{
|
|
|
92
98
|
children: [
|
|
93
99
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components1.DashboardToolbar, {
|
|
94
100
|
dashboardName: dashboardResource.metadata.name,
|
|
101
|
+
timezone: toolBarTimezone,
|
|
95
102
|
dashboardTitleComponent: dashboardTitleComponent,
|
|
96
103
|
initialVariableIsSticky: isInitialVariableSticky,
|
|
97
104
|
onSave: onSave,
|
|
98
105
|
isReadonly: isReadonly,
|
|
99
106
|
isVariableEnabled: isVariableEnabled,
|
|
107
|
+
isAnnotationEnabled: isAnnotationEnabled,
|
|
100
108
|
isDatasourceEnabled: isDatasourceEnabled,
|
|
101
109
|
onEditButtonClick: onEditButtonClick,
|
|
102
110
|
onCancelButtonClick: onCancelButtonClick
|