@perses-dev/dashboards 0.50.3 → 0.51.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Dashboard/Dashboard.js +1 -3
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +3 -3
- package/dist/cjs/components/Datasources/DatasourceEditor.js +2 -5
- package/dist/cjs/components/Datasources/EditDatasourcesButton.js +2 -5
- package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +4 -3
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +5 -7
- package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +1 -1
- package/dist/cjs/components/GridLayout/GridItemContent.js +4 -3
- package/dist/cjs/components/GridLayout/GridLayout.js +5 -6
- package/dist/cjs/components/GridLayout/GridTitle.js +3 -3
- package/dist/cjs/{stories/decorators/constants.js → components/Panel/HeaderIconButton.js} +8 -20
- package/dist/cjs/components/Panel/Panel.js +16 -10
- package/dist/cjs/components/Panel/PanelActions.js +365 -0
- package/dist/cjs/components/Panel/PanelContent.js +59 -13
- package/dist/cjs/components/Panel/PanelHeader.js +14 -141
- package/dist/cjs/components/Panel/PanelLinks.js +5 -6
- package/dist/cjs/components/Panel/PanelPluginLoader.js +56 -0
- package/dist/cjs/components/Panel/index.js +1 -0
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +9 -6
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +17 -33
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +4 -5
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
- package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -4
- package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +5 -12
- package/dist/cjs/components/Variables/Variable.js +20 -35
- package/dist/cjs/components/Variables/VariableEditor.js +14 -23
- package/dist/cjs/components/Variables/VariableList.js +4 -6
- package/dist/cjs/constants/styles.js +12 -0
- package/dist/cjs/constants/user-interface-text.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +5 -6
- package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +1 -1
- package/dist/cjs/context/DashboardProvider/common.js +2 -2
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +13 -3
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -2
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +3 -6
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +1 -2
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +3 -4
- package/dist/cjs/context/DashboardProvider/view-panel-slice.js +1 -2
- package/dist/cjs/context/DatasourceStoreProvider.js +15 -22
- package/dist/cjs/context/VariableProvider/VariableProvider.js +12 -20
- package/dist/cjs/context/VariableProvider/hydrationUtils.js +3 -6
- package/dist/cjs/context/VariableProvider/utils.js +2 -2
- package/dist/cjs/test/datasource-provider.js +1 -1
- package/dist/cjs/test/plugin-registry.js +8 -3
- package/dist/cjs/test/render.js +13 -11
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +4 -3
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -5
- package/dist/components/Dashboard/Dashboard.js +1 -3
- package/dist/components/Dashboard/Dashboard.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 +3 -3
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.js +2 -5
- package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
- package/dist/components/Datasources/EditDatasourcesButton.js +2 -5
- package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js +3 -1
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -4
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +5 -7
- 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.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +5 -4
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +6 -7
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +3 -3
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/HeaderIconButton.d.ts +5 -0
- package/dist/components/Panel/HeaderIconButton.d.ts.map +1 -0
- package/dist/{stories/decorators/index.js → components/Panel/HeaderIconButton.js} +7 -6
- package/dist/components/Panel/HeaderIconButton.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +7 -2
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +22 -11
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.d.ts +22 -0
- package/dist/components/Panel/PanelActions.d.ts.map +1 -0
- package/dist/components/Panel/PanelActions.js +352 -0
- package/dist/components/Panel/PanelActions.js.map +1 -0
- package/dist/components/Panel/PanelContent.d.ts +5 -4
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +61 -15
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +7 -11
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +18 -140
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/Panel/PanelLinks.js +5 -6
- package/dist/components/Panel/PanelLinks.js.map +1 -1
- package/dist/components/Panel/PanelPluginLoader.d.ts +13 -0
- package/dist/components/Panel/PanelPluginLoader.d.ts.map +1 -0
- package/dist/components/Panel/PanelPluginLoader.js +51 -0
- package/dist/components/Panel/PanelPluginLoader.js.map +1 -0
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +1 -0
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +10 -7
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +17 -33
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +4 -5
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -4
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
- package/dist/components/Variables/BuiltinVariableAccordions.js +5 -12
- package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -1
- package/dist/components/Variables/Variable.js +20 -35
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.js +14 -23
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.js +4 -6
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/constants/styles.d.ts +3 -0
- package/dist/constants/styles.d.ts.map +1 -1
- package/dist/constants/styles.js +3 -0
- package/dist/constants/styles.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/DashboardProvider/DashboardProvider.js +5 -6
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +1 -1
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -1
- package/dist/context/DashboardProvider/common.js +2 -2
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +11 -2
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +13 -4
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.js +1 -2
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +3 -6
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +1 -2
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +3 -4
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.js +1 -2
- package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +15 -22
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/VariableProvider/VariableProvider.js +9 -12
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/VariableProvider/hydrationUtils.js +3 -6
- package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/VariableProvider/query-params.js.map +1 -1
- package/dist/context/VariableProvider/utils.js +2 -2
- package/dist/context/VariableProvider/utils.js.map +1 -1
- package/dist/context/useDashboard.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 +1 -1
- package/dist/test/datasource-provider.js.map +1 -1
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +8 -3
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +9 -7
- package/dist/test/render.js.map +1 -1
- package/dist/utils/panelUtils.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +4 -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 +5 -5
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +9 -10
- package/dist/cjs/stories/decorators/WithDashboard.js +0 -41
- package/dist/cjs/stories/decorators/WithDatasourceStore.js +0 -39
- package/dist/cjs/stories/decorators/WithVariables.js +0 -37
- package/dist/cjs/stories/decorators/index.js +0 -33
- package/dist/stories/decorators/WithDashboard.js +0 -33
- package/dist/stories/decorators/WithDashboard.js.map +0 -1
- package/dist/stories/decorators/WithDatasourceStore.js +0 -31
- package/dist/stories/decorators/WithDatasourceStore.js.map +0 -1
- package/dist/stories/decorators/WithVariables.js +0 -29
- package/dist/stories/decorators/WithVariables.js.map +0 -1
- package/dist/stories/decorators/constants.js +0 -31
- package/dist/stories/decorators/constants.js.map +0 -1
- package/dist/stories/decorators/index.js.map +0 -1
|
@@ -50,14 +50,12 @@ function VariableList() {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
function VariableListItem({ spec, source }) {
|
|
53
|
-
var _ctx_state, _spec_display;
|
|
54
53
|
const ctx = (0, _context.useVariableDefinitionAndState)(spec.name, source);
|
|
55
|
-
if (
|
|
54
|
+
if (ctx.state?.overridden) {
|
|
56
55
|
return null;
|
|
57
56
|
}
|
|
58
|
-
var _ref, _ref1;
|
|
59
57
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
60
|
-
display:
|
|
58
|
+
display: spec.display?.hidden ? 'none' : undefined,
|
|
61
59
|
minWidth: `${_constants.MIN_VARIABLE_WIDTH}px`,
|
|
62
60
|
maxWidth: `${_constants.MAX_VARIABLE_WIDTH}px`,
|
|
63
61
|
flexShrink: 0,
|
|
@@ -65,6 +63,6 @@ function VariableListItem({ spec, source }) {
|
|
|
65
63
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Variable.Variable, {
|
|
66
64
|
name: spec.name,
|
|
67
65
|
source: source
|
|
68
|
-
}, (
|
|
69
|
-
}, (
|
|
66
|
+
}, (spec.name + source) ?? '')
|
|
67
|
+
}, (spec.name + source) ?? '');
|
|
70
68
|
}
|
|
@@ -21,6 +21,15 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
HEADER_ACTIONS_CONTAINER_NAME: function() {
|
|
25
|
+
return HEADER_ACTIONS_CONTAINER_NAME;
|
|
26
|
+
},
|
|
27
|
+
HEADER_MEDIUM_WIDTH: function() {
|
|
28
|
+
return HEADER_MEDIUM_WIDTH;
|
|
29
|
+
},
|
|
30
|
+
HEADER_SMALL_WIDTH: function() {
|
|
31
|
+
return HEADER_SMALL_WIDTH;
|
|
32
|
+
},
|
|
24
33
|
MAX_VARIABLE_WIDTH: function() {
|
|
25
34
|
return MAX_VARIABLE_WIDTH;
|
|
26
35
|
},
|
|
@@ -40,3 +49,6 @@ const editButtonStyle = {
|
|
|
40
49
|
};
|
|
41
50
|
const MIN_VARIABLE_WIDTH = 120;
|
|
42
51
|
const MAX_VARIABLE_WIDTH = 500;
|
|
52
|
+
const HEADER_SMALL_WIDTH = 170;
|
|
53
|
+
const HEADER_MEDIUM_WIDTH = 220;
|
|
54
|
+
const HEADER_ACTIONS_CONTAINER_NAME = 'header-actions-container';
|
|
@@ -64,5 +64,6 @@ const ARIA_LABEL_TEXT = {
|
|
|
64
64
|
editPanel: (panelName)=>`edit panel ${panelName}`,
|
|
65
65
|
duplicatePanel: (panelName)=>`duplicate panel ${panelName}`,
|
|
66
66
|
deletePanel: (panelName)=>`delete panel ${panelName}`,
|
|
67
|
+
showPanelActions: (panelName)=>`show panel actions for ${panelName}`,
|
|
67
68
|
movePanel: (panelName)=>`move panel ${panelName}`
|
|
68
69
|
};
|
|
@@ -66,13 +66,12 @@ function DashboardProvider(props) {
|
|
|
66
66
|
]);
|
|
67
67
|
// load plugin to retrieve initial spec if default panel kind is defined
|
|
68
68
|
const { defaultPluginKinds } = (0, _pluginsystem.usePluginRegistry)();
|
|
69
|
-
|
|
70
|
-
const defaultPanelKind = (_defaultPluginKinds_Panel = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds['Panel']) !== null && _defaultPluginKinds_Panel !== void 0 ? _defaultPluginKinds_Panel : '';
|
|
69
|
+
const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';
|
|
71
70
|
const { data: plugin } = (0, _pluginsystem.usePlugin)('Panel', defaultPanelKind);
|
|
72
71
|
const [store] = (0, _react.useState)(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders
|
|
73
72
|
(0, _react.useEffect)(()=>{
|
|
74
73
|
if (plugin === undefined) return;
|
|
75
|
-
const defaultPanelSpec = plugin.createInitialOptions();
|
|
74
|
+
const defaultPanelSpec = plugin.createInitialOptions ? plugin.createInitialOptions() : {};
|
|
76
75
|
// set default panel kind, spec, and queries for add panel editor
|
|
77
76
|
store.setState({
|
|
78
77
|
initialValues: {
|
|
@@ -95,8 +94,8 @@ function initStore(props) {
|
|
|
95
94
|
const ttl = 'ttl' in dashboardResource.spec ? dashboardResource.spec.ttl : undefined;
|
|
96
95
|
let { spec: { layouts, panels } } = dashboardResource;
|
|
97
96
|
// Set fallbacks in case the frontend is used with a non-Perses backend
|
|
98
|
-
layouts = layouts
|
|
99
|
-
panels = panels
|
|
97
|
+
layouts = layouts ?? [];
|
|
98
|
+
panels = panels ?? {};
|
|
100
99
|
const store = (0, _zustand.createStore)()((0, _immer.immer)((0, _middleware.devtools)((...args)=>{
|
|
101
100
|
const [set] = args;
|
|
102
101
|
return {
|
|
@@ -132,7 +131,7 @@ function initStore(props) {
|
|
|
132
131
|
state.panelGroups = panelGroups;
|
|
133
132
|
state.panelGroupOrder = panelGroupOrder;
|
|
134
133
|
state.duration = duration;
|
|
135
|
-
state.refreshInterval = refreshInterval
|
|
134
|
+
state.refreshInterval = refreshInterval ?? _core.DEFAULT_REFRESH_INTERVAL;
|
|
136
135
|
state.datasources = datasources;
|
|
137
136
|
// TODO: add ttl here to e.g allow edition from JSON view, but probably requires quite some refactoring
|
|
138
137
|
});
|
|
@@ -27,7 +27,7 @@ function DashboardProviderWithQueryParams({ children, initialState }) {
|
|
|
27
27
|
const [viewPanelRef, setViewPanelRef] = (0, _usequeryparams.useQueryParam)('viewPanelRef', _usequeryparams.StringParam);
|
|
28
28
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardProvider.DashboardProvider, {
|
|
29
29
|
initialState: {
|
|
30
|
-
viewPanelRef: viewPanelRef
|
|
30
|
+
viewPanelRef: viewPanelRef ?? undefined,
|
|
31
31
|
setViewPanelRef: setViewPanelRef,
|
|
32
32
|
...initialState
|
|
33
33
|
},
|
|
@@ -43,8 +43,8 @@ function createPanelDefinition(defaultPanelKind, defaultPanelSpec) {
|
|
|
43
43
|
description: undefined
|
|
44
44
|
},
|
|
45
45
|
plugin: {
|
|
46
|
-
kind: defaultPanelKind
|
|
47
|
-
spec: defaultPanelSpec
|
|
46
|
+
kind: defaultPanelKind ?? '',
|
|
47
|
+
spec: defaultPanelSpec ?? {}
|
|
48
48
|
},
|
|
49
49
|
queries: []
|
|
50
50
|
}
|
|
@@ -71,6 +71,9 @@ _export(exports, {
|
|
|
71
71
|
},
|
|
72
72
|
useViewPanel: function() {
|
|
73
73
|
return useViewPanel;
|
|
74
|
+
},
|
|
75
|
+
useViewPanelGroup: function() {
|
|
76
|
+
return useViewPanelGroup;
|
|
74
77
|
}
|
|
75
78
|
});
|
|
76
79
|
const _react = require("react");
|
|
@@ -186,8 +189,7 @@ function useDeletePanelGroupDialog() {
|
|
|
186
189
|
function usePanel(panelGroupItemId) {
|
|
187
190
|
const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
|
|
188
191
|
const panel = (0, _DashboardProvider.useDashboardStore)((0, _react.useCallback)((store)=>{
|
|
189
|
-
|
|
190
|
-
const panelKey = (_store_panelGroups_panelGroupId = store.panelGroups[panelGroupId]) === null || _store_panelGroups_panelGroupId === void 0 ? void 0 : _store_panelGroups_panelGroupId.itemPanelKeys[panelGroupLayoutId];
|
|
192
|
+
const panelKey = store.panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];
|
|
191
193
|
if (panelKey === undefined) return;
|
|
192
194
|
return store.panels[panelKey];
|
|
193
195
|
}, [
|
|
@@ -231,10 +233,18 @@ const selectDashboardDuration = (state)=>state.duration;
|
|
|
231
233
|
function useDashboardDuration() {
|
|
232
234
|
return (0, _DashboardProvider.useDashboardStore)(selectDashboardDuration);
|
|
233
235
|
}
|
|
234
|
-
const selectViewPanel = (state)=>
|
|
236
|
+
const selectViewPanel = (state)=>({
|
|
237
|
+
setViewPanel: state.setViewPanel,
|
|
238
|
+
getViewPanel: state.getViewPanel,
|
|
239
|
+
viewPanelId: state.getViewPanel()
|
|
240
|
+
});
|
|
235
241
|
function useViewPanel() {
|
|
236
242
|
return (0, _DashboardProvider.useDashboardStore)(selectViewPanel);
|
|
237
243
|
}
|
|
244
|
+
const selectViewPanelGroup = (state)=>state.getViewPanel();
|
|
245
|
+
function useViewPanelGroup() {
|
|
246
|
+
return (0, _DashboardProvider.useDashboardStore)(selectViewPanelGroup);
|
|
247
|
+
}
|
|
238
248
|
const selectSaveChangesConfirmationDialog = ({ saveChangesConfirmationDialog, openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog })=>({
|
|
239
249
|
saveChangesConfirmationDialog,
|
|
240
250
|
openSaveChangesConfirmationDialog,
|
|
@@ -60,11 +60,10 @@ function createDeletePanelSlice() {
|
|
|
60
60
|
throw new Error(`Could not find panel ${panelKey}`);
|
|
61
61
|
}
|
|
62
62
|
set((state)=>{
|
|
63
|
-
var _panelGroup_title;
|
|
64
63
|
state.deletePanelDialog = {
|
|
65
64
|
panelGroupItemId: panelGroupItemId,
|
|
66
65
|
panelName: panel.spec.display.name,
|
|
67
|
-
panelGroupName:
|
|
66
|
+
panelGroupName: panelGroup.title ?? ''
|
|
68
67
|
};
|
|
69
68
|
});
|
|
70
69
|
},
|
|
@@ -28,11 +28,10 @@ function createPanelEditorSlice() {
|
|
|
28
28
|
return (set, get)=>({
|
|
29
29
|
panelEditor: undefined,
|
|
30
30
|
openEditPanel (panelGroupItemId) {
|
|
31
|
-
var _panelGroups_panelGroupId;
|
|
32
31
|
const { panels, panelGroups } = get();
|
|
33
32
|
// Figure out the panel key at that location
|
|
34
33
|
const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
|
|
35
|
-
const panelKey =
|
|
34
|
+
const panelKey = panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];
|
|
36
35
|
if (panelKey === undefined) {
|
|
37
36
|
throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);
|
|
38
37
|
}
|
|
@@ -95,21 +94,19 @@ function createPanelEditorSlice() {
|
|
|
95
94
|
});
|
|
96
95
|
},
|
|
97
96
|
openAddPanel (panelGroupId) {
|
|
98
|
-
var _get_initialValues;
|
|
99
97
|
// If a panel group isn't supplied, add to the first group or create a group if there aren't any
|
|
100
98
|
let newGroup = undefined;
|
|
101
|
-
panelGroupId
|
|
99
|
+
panelGroupId ??= get().panelGroupOrder[0];
|
|
102
100
|
if (panelGroupId === undefined) {
|
|
103
101
|
newGroup = (0, _panelgroupslice.createEmptyPanelGroup)();
|
|
104
102
|
newGroup.title = 'Panel Group';
|
|
105
103
|
panelGroupId = newGroup.id;
|
|
106
104
|
}
|
|
107
|
-
var _get_initialValues_panelDefinition;
|
|
108
105
|
const editorState = {
|
|
109
106
|
mode: 'create',
|
|
110
107
|
initialValues: {
|
|
111
108
|
groupId: panelGroupId,
|
|
112
|
-
panelDefinition:
|
|
109
|
+
panelDefinition: get().initialValues?.panelDefinition ?? (0, _common.createPanelDefinition)()
|
|
113
110
|
},
|
|
114
111
|
applyChanges: (next)=>{
|
|
115
112
|
const name = next.panelDefinition.spec.display.name;
|
|
@@ -55,12 +55,11 @@ const createPanelGroupEditorSlice = (set, get)=>({
|
|
|
55
55
|
if (existingGroup === undefined) {
|
|
56
56
|
throw new Error(`Panel group with Id ${panelGroupId} does not exist`);
|
|
57
57
|
}
|
|
58
|
-
var _existingGroup_title;
|
|
59
58
|
// Create the editor state
|
|
60
59
|
const editor = {
|
|
61
60
|
mode: 'Edit',
|
|
62
61
|
initialValues: {
|
|
63
|
-
title:
|
|
62
|
+
title: existingGroup.title ?? '',
|
|
64
63
|
isCollapsed: existingGroup.isCollapsed
|
|
65
64
|
},
|
|
66
65
|
applyChanges (next) {
|
|
@@ -40,7 +40,7 @@ _export(exports, {
|
|
|
40
40
|
const _core = require("@perses-dev/core");
|
|
41
41
|
const _common = require("./common");
|
|
42
42
|
function isPanelGroupItemIdEqual(a, b) {
|
|
43
|
-
return
|
|
43
|
+
return a?.panelGroupId === b?.panelGroupId && a?.panelGroupItemLayoutId === b?.panelGroupItemLayoutId;
|
|
44
44
|
}
|
|
45
45
|
function createPanelGroupSlice(layouts) {
|
|
46
46
|
const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
|
|
@@ -81,7 +81,6 @@ function convertLayoutsToPanelGroups(layouts) {
|
|
|
81
81
|
const panelGroups = {};
|
|
82
82
|
const panelGroupIdOrder = [];
|
|
83
83
|
for (const layout of layouts){
|
|
84
|
-
var _layout_spec_display_collapse, _layout_spec_display, _layout_spec_display1;
|
|
85
84
|
const itemLayouts = [];
|
|
86
85
|
const itemPanelKeys = {};
|
|
87
86
|
// Split layout information from panel keys to make it easier to update just layouts on move/resize of panels
|
|
@@ -100,8 +99,8 @@ function convertLayoutsToPanelGroups(layouts) {
|
|
|
100
99
|
const panelGroupId = (0, _common.generateId)();
|
|
101
100
|
panelGroups[panelGroupId] = {
|
|
102
101
|
id: panelGroupId,
|
|
103
|
-
isCollapsed:
|
|
104
|
-
title:
|
|
102
|
+
isCollapsed: layout.spec.display?.collapse?.open === false,
|
|
103
|
+
title: layout.spec.display?.title,
|
|
105
104
|
itemLayouts,
|
|
106
105
|
itemPanelKeys
|
|
107
106
|
};
|
|
@@ -55,8 +55,7 @@ function getViewPanelGroupId(panelGroups, panelGroupItemId, panelRef) {
|
|
|
55
55
|
// Find the PanelGroupItemId of a Panel from a PanelRef
|
|
56
56
|
function findPanelGroupItemIdOfPanelRef(panelGroups, panelRef) {
|
|
57
57
|
for (const panelGroup of Object.values(panelGroups)){
|
|
58
|
-
|
|
59
|
-
const itemPanel = Object.entries((_panelGroup_itemPanelKeys = panelGroup.itemPanelKeys) !== null && _panelGroup_itemPanelKeys !== void 0 ? _panelGroup_itemPanelKeys : []).find(([_, value])=>value === panelRef);
|
|
58
|
+
const itemPanel = Object.entries(panelGroup.itemPanelKeys ?? []).find(([_, value])=>value === panelRef);
|
|
60
59
|
if (itemPanel) {
|
|
61
60
|
const [key] = itemPanel;
|
|
62
61
|
return {
|
|
@@ -27,9 +27,8 @@ const _pluginsystem = require("@perses-dev/plugin-system");
|
|
|
27
27
|
function DatasourceStoreProvider(props) {
|
|
28
28
|
const { projectName, datasourceApi, onCreate, children } = props;
|
|
29
29
|
const [dashboardResource, setDashboardResource] = (0, _react.useState)(props.dashboardResource);
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const project = projectName !== null && projectName !== void 0 ? projectName : dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.metadata.project;
|
|
30
|
+
const [savedDatasources, setSavedDatasources] = (0, _react.useState)(props.savedDatasources ?? {});
|
|
31
|
+
const project = projectName ?? dashboardResource?.metadata.project;
|
|
33
32
|
const { getPlugin, listPluginMetadata } = (0, _pluginsystem.usePluginRegistry)();
|
|
34
33
|
const findDatasource = (0, _core.useEvent)(async (selector)=>{
|
|
35
34
|
// Try to find it in dashboard spec
|
|
@@ -99,26 +98,26 @@ function DatasourceStoreProvider(props) {
|
|
|
99
98
|
getPlugin,
|
|
100
99
|
onCreate
|
|
101
100
|
]);
|
|
102
|
-
const listDatasourceSelectItems = (0, _core.useEvent)(async (
|
|
101
|
+
const listDatasourceSelectItems = (0, _core.useEvent)(async (datasourcePluginName)=>{
|
|
103
102
|
const [pluginMetadata, datasources, globalDatasources] = await Promise.all([
|
|
104
103
|
listPluginMetadata([
|
|
105
104
|
'Datasource'
|
|
106
105
|
]),
|
|
107
|
-
project ? datasourceApi.listDatasources(project,
|
|
108
|
-
datasourceApi.listGlobalDatasources(
|
|
106
|
+
project ? datasourceApi.listDatasources(project, datasourcePluginName) : [],
|
|
107
|
+
datasourceApi.listGlobalDatasources(datasourcePluginName)
|
|
109
108
|
]);
|
|
110
109
|
// Find the metadata for the plugin type they asked for, so we can use it for the name of the default datasource
|
|
111
|
-
const datasourcePluginMetadata = pluginMetadata.find((metadata)=>metadata.
|
|
110
|
+
const datasourcePluginMetadata = pluginMetadata.find((metadata)=>metadata.spec.name === datasourcePluginName);
|
|
112
111
|
if (datasourcePluginMetadata === undefined) {
|
|
113
|
-
throw new Error(`Could not find a Datasource plugin with kind '${
|
|
112
|
+
throw new Error(`Could not find a Datasource plugin with kind '${datasourcePluginName}'`);
|
|
114
113
|
}
|
|
115
114
|
// Get helper for computing results properly
|
|
116
|
-
const { results, addItem } = buildDatasourceSelectItemGroups(datasourcePluginMetadata.display.name);
|
|
115
|
+
const { results, addItem } = buildDatasourceSelectItemGroups(datasourcePluginMetadata.spec.display.name);
|
|
117
116
|
// Start with dashboard datasources with the highest precedence
|
|
118
|
-
if (dashboardResource
|
|
117
|
+
if (dashboardResource?.spec.datasources) {
|
|
119
118
|
for(const selectorName in dashboardResource.spec.datasources){
|
|
120
119
|
const spec = dashboardResource.spec.datasources[selectorName];
|
|
121
|
-
if (spec === undefined || spec.plugin.kind !==
|
|
120
|
+
if (spec === undefined || spec.plugin.kind !== datasourcePluginName) continue;
|
|
122
121
|
const saved = selectorName in savedDatasources;
|
|
123
122
|
addItem({
|
|
124
123
|
spec,
|
|
@@ -151,8 +150,7 @@ function DatasourceStoreProvider(props) {
|
|
|
151
150
|
return results;
|
|
152
151
|
});
|
|
153
152
|
const getLocalDatasources = (0, _react.useCallback)(()=>{
|
|
154
|
-
|
|
155
|
-
return (_dashboardResource_spec_datasources = dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.spec.datasources) !== null && _dashboardResource_spec_datasources !== void 0 ? _dashboardResource_spec_datasources : {};
|
|
153
|
+
return dashboardResource?.spec.datasources ?? {};
|
|
156
154
|
}, [
|
|
157
155
|
dashboardResource
|
|
158
156
|
]);
|
|
@@ -238,8 +236,7 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
238
236
|
const groupIndices = {};
|
|
239
237
|
let currentGroupIndex = 1; // 0 is the default group, always there as it contains at least the first item.
|
|
240
238
|
const addItem = ({ spec, selectorName, selectorGroup: group, editLink, saved })=>{
|
|
241
|
-
|
|
242
|
-
group = group !== null && group !== void 0 ? group : '';
|
|
239
|
+
group = group ?? '';
|
|
243
240
|
// Ensure the default group is always present as soon as an item is added.
|
|
244
241
|
if (isFirst) {
|
|
245
242
|
results.push({
|
|
@@ -247,9 +244,8 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
247
244
|
items: []
|
|
248
245
|
});
|
|
249
246
|
}
|
|
250
|
-
var _groupIndices_group;
|
|
251
247
|
// Create the group if necessary
|
|
252
|
-
let selectItemGroup = results[
|
|
248
|
+
let selectItemGroup = results[groupIndices[group] ?? -1];
|
|
253
249
|
if (!selectItemGroup) {
|
|
254
250
|
groupIndices[group] = currentGroupIndex;
|
|
255
251
|
selectItemGroup = {
|
|
@@ -262,9 +258,8 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
262
258
|
}
|
|
263
259
|
// Add item to the group
|
|
264
260
|
const isOverridden = usedNames.has(selectorName);
|
|
265
|
-
var _spec_display_name;
|
|
266
261
|
selectItemGroup.items.push({
|
|
267
|
-
name:
|
|
262
|
+
name: spec.display?.name ?? selectorName,
|
|
268
263
|
overridden: isOverridden,
|
|
269
264
|
saved,
|
|
270
265
|
selector: {
|
|
@@ -293,9 +288,7 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
293
288
|
// At the end, we make sure the overriding item(s) is well flagged so
|
|
294
289
|
if (isOverridden) {
|
|
295
290
|
for(let i = explicitDefaultAdded ? 1 : 0; i < currentGroupIndex; i++){
|
|
296
|
-
|
|
297
|
-
var _results_i_items;
|
|
298
|
-
((_results_i_items = (_results_i = results[i]) === null || _results_i === void 0 ? void 0 : _results_i.items) !== null && _results_i_items !== void 0 ? _results_i_items : []).filter((item)=>item.selector.name === selectorName).forEach((item)=>{
|
|
291
|
+
(results[i]?.items ?? []).filter((item)=>item.selector.name === selectorName).forEach((item)=>{
|
|
299
292
|
item.overriding = true;
|
|
300
293
|
});
|
|
301
294
|
}
|
|
@@ -53,17 +53,12 @@ const _traditional = require("zustand/traditional");
|
|
|
53
53
|
const _immer = require("zustand/middleware/immer");
|
|
54
54
|
const _middleware = require("zustand/middleware");
|
|
55
55
|
const _shallow = require("zustand/shallow");
|
|
56
|
-
const _immer1 =
|
|
56
|
+
const _immer1 = require("immer");
|
|
57
57
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
58
58
|
const _core = require("@perses-dev/core");
|
|
59
59
|
const _utils = require("./utils");
|
|
60
60
|
const _hydrationUtils = require("./hydrationUtils");
|
|
61
61
|
const _queryparams = require("./query-params");
|
|
62
|
-
function _interop_require_default(obj) {
|
|
63
|
-
return obj && obj.__esModule ? obj : {
|
|
64
|
-
default: obj
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
62
|
/**
|
|
68
63
|
* Context object for {@link VariableDefinitionStore}.
|
|
69
64
|
*/ const VariableDefinitionStoreContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
@@ -79,7 +74,7 @@ function useVariableDefinitionStates(variableNames) {
|
|
|
79
74
|
return (0, _traditional.useStoreWithEqualityFn)(store, (s)=>{
|
|
80
75
|
const varStates = {};
|
|
81
76
|
// Collect values of local variables, from the variable state
|
|
82
|
-
const names = variableNames
|
|
77
|
+
const names = variableNames ?? s.variableDefinitions.map((value)=>value.spec.name);
|
|
83
78
|
names.forEach((name)=>{
|
|
84
79
|
const varState = s.variableState.get({
|
|
85
80
|
name
|
|
@@ -112,12 +107,11 @@ function useVariableDefinitionStates(variableNames) {
|
|
|
112
107
|
function useVariableDefinitionAndState(name, source) {
|
|
113
108
|
const store = useVariableDefinitionStoreCtx();
|
|
114
109
|
return (0, _zustand.useStore)(store, (s)=>{
|
|
115
|
-
var _s_externalVariableDefinitions_find;
|
|
116
110
|
const state = s.variableState.get({
|
|
117
111
|
name,
|
|
118
112
|
source
|
|
119
113
|
});
|
|
120
|
-
const definitions = source ?
|
|
114
|
+
const definitions = source ? s.externalVariableDefinitions.find((v)=>v.source === source)?.definitions : s.variableDefinitions;
|
|
121
115
|
const definition = (definitions || []).find((v)=>v.spec.name === name);
|
|
122
116
|
return {
|
|
123
117
|
state,
|
|
@@ -163,12 +157,10 @@ function PluginProvider({ children, builtinVariables }) {
|
|
|
163
157
|
if (v.value === _core.DEFAULT_ALL_VALUE) {
|
|
164
158
|
const definition = (0, _utils.findVariableDefinitionByName)(name, definitions, externalDefinitions);
|
|
165
159
|
// If the variable is a list variable and has a custom all value, then use that value instead
|
|
166
|
-
if (
|
|
160
|
+
if (definition?.kind === 'ListVariable' && definition.spec.customAllValue) {
|
|
167
161
|
v.value = definition.spec.customAllValue;
|
|
168
162
|
} else {
|
|
169
|
-
|
|
170
|
-
var _v_options_map;
|
|
171
|
-
v.value = (_v_options_map = (_v_options = v.options) === null || _v_options === void 0 ? void 0 : _v_options.map((o)=>o.value)) !== null && _v_options_map !== void 0 ? _v_options_map : null;
|
|
163
|
+
v.value = v.options?.map((o)=>o.value) ?? null;
|
|
172
164
|
}
|
|
173
165
|
}
|
|
174
166
|
contextValues[name] = v;
|
|
@@ -247,7 +239,7 @@ function PluginProvider({ children, builtinVariables }) {
|
|
|
247
239
|
}
|
|
248
240
|
}
|
|
249
241
|
];
|
|
250
|
-
builtinVariables
|
|
242
|
+
builtinVariables?.forEach((def)=>result.push(def));
|
|
251
243
|
return result;
|
|
252
244
|
}, [
|
|
253
245
|
absoluteTimeRange,
|
|
@@ -330,17 +322,17 @@ function createVariableDefinitionStore({ initialVariableDefinitions = [], extern
|
|
|
330
322
|
setVariableDefaultValues: ()=>{
|
|
331
323
|
const variableDefinitions = get().variableDefinitions;
|
|
332
324
|
const variableState = get().variableState;
|
|
333
|
-
const updatedVariables = (0, _immer1.
|
|
325
|
+
const updatedVariables = (0, _immer1.produce)(variableDefinitions, (draft)=>{
|
|
334
326
|
draft.forEach((variable, index)=>{
|
|
335
327
|
const name = variable.spec.name;
|
|
336
328
|
if (variable.kind === 'ListVariable') {
|
|
337
329
|
const currentVariable = variableState.get({
|
|
338
330
|
name
|
|
339
331
|
});
|
|
340
|
-
if (
|
|
332
|
+
if (currentVariable?.value !== undefined) {
|
|
341
333
|
draft[index] = {
|
|
342
334
|
kind: 'ListVariable',
|
|
343
|
-
spec: (0, _immer1.
|
|
335
|
+
spec: (0, _immer1.produce)(variable.spec, (specDraft)=>{
|
|
344
336
|
specDraft.defaultValue = currentVariable.value;
|
|
345
337
|
})
|
|
346
338
|
};
|
|
@@ -349,11 +341,11 @@ function createVariableDefinitionStore({ initialVariableDefinitions = [], extern
|
|
|
349
341
|
const currentVariable = variableState.get({
|
|
350
342
|
name
|
|
351
343
|
});
|
|
352
|
-
const currentVariableValue = typeof
|
|
353
|
-
if (
|
|
344
|
+
const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';
|
|
345
|
+
if (currentVariable?.value !== undefined) {
|
|
354
346
|
draft[index] = {
|
|
355
347
|
kind: 'TextVariable',
|
|
356
|
-
spec: (0, _immer1.
|
|
348
|
+
spec: (0, _immer1.produce)(variable.spec, (specDraft)=>{
|
|
357
349
|
specDraft.value = currentVariableValue;
|
|
358
350
|
})
|
|
359
351
|
};
|
|
@@ -32,17 +32,14 @@ function hydrateVariableState(variable, initialValue) {
|
|
|
32
32
|
};
|
|
33
33
|
switch(variable.kind){
|
|
34
34
|
case 'TextVariable':
|
|
35
|
-
varState.value = initialValue
|
|
35
|
+
varState.value = initialValue ?? variable.spec.value;
|
|
36
36
|
break;
|
|
37
37
|
case 'ListVariable':
|
|
38
38
|
varState.options = [];
|
|
39
|
-
|
|
40
|
-
varState.value = (_ref = initialValue !== null && initialValue !== void 0 ? initialValue : variable.spec.defaultValue) !== null && _ref !== void 0 ? _ref : null;
|
|
39
|
+
varState.value = initialValue ?? variable.spec.defaultValue ?? null;
|
|
41
40
|
// TODO: smarter fallbacks for defaultValue when allowAllValue is true
|
|
42
41
|
if (varState.options.length > 0 && !varState.value) {
|
|
43
|
-
|
|
44
|
-
var _varState_options__value;
|
|
45
|
-
const firstOptionValue = (_varState_options__value = (_varState_options_ = varState.options[0]) === null || _varState_options_ === void 0 ? void 0 : _varState_options_.value) !== null && _varState_options__value !== void 0 ? _varState_options__value : null;
|
|
42
|
+
const firstOptionValue = varState.options[0]?.value ?? null;
|
|
46
43
|
if (firstOptionValue !== null) {
|
|
47
44
|
varState.value = variable.spec.allowMultiple ? [
|
|
48
45
|
firstOptionValue
|
|
@@ -43,7 +43,7 @@ function checkSavedDefaultVariableStatus(definitions, varState) {
|
|
|
43
43
|
const currentVariable = varState.get({
|
|
44
44
|
name
|
|
45
45
|
});
|
|
46
|
-
if (
|
|
46
|
+
if (currentVariable?.value !== null && currentVariable?.value !== savedVariable.spec.defaultValue) {
|
|
47
47
|
modifiedVariableNames.push(name);
|
|
48
48
|
isSavedVariableModified = true;
|
|
49
49
|
}
|
|
@@ -51,7 +51,7 @@ function checkSavedDefaultVariableStatus(definitions, varState) {
|
|
|
51
51
|
const currentVariable = varState.get({
|
|
52
52
|
name
|
|
53
53
|
});
|
|
54
|
-
const currentVariableValue = typeof
|
|
54
|
+
const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';
|
|
55
55
|
if (savedVariable.spec.value !== currentVariableValue) {
|
|
56
56
|
modifiedVariableNames.push(name);
|
|
57
57
|
isSavedVariableModified = true;
|
|
@@ -32,7 +32,7 @@ _export(exports, {
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
const _dashboardprovider = require("./dashboard-provider");
|
|
35
|
-
const prometheusDemoUrl = 'https://prometheus.demo.
|
|
35
|
+
const prometheusDemoUrl = 'https://prometheus.demo.prometheus.io';
|
|
36
36
|
const prometheusDemo = {
|
|
37
37
|
kind: 'GlobalDatasource',
|
|
38
38
|
metadata: {
|
|
@@ -38,11 +38,16 @@ const FakeTimeSeriesPlugin = {
|
|
|
38
38
|
content: FakeTimeSeriesChartOptionEditor
|
|
39
39
|
}
|
|
40
40
|
],
|
|
41
|
-
createInitialOptions: ()=>({})
|
|
41
|
+
createInitialOptions: ()=>({}),
|
|
42
|
+
supportedQueryTypes: [
|
|
43
|
+
'TimeSeriesQuery'
|
|
44
|
+
]
|
|
42
45
|
};
|
|
43
46
|
const MOCK_TIME_SERIES_PANEL = {
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
kind: 'Panel',
|
|
48
|
+
spec: {
|
|
49
|
+
name: 'TimeSeriesChart'
|
|
50
|
+
},
|
|
46
51
|
plugin: FakeTimeSeriesPlugin
|
|
47
52
|
};
|
|
48
53
|
const MOCK_PLUGINS = [
|
package/dist/cjs/test/render.js
CHANGED
|
@@ -21,15 +21,15 @@ Object.defineProperty(exports, "renderWithContext", {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
24
|
+
const _components = require("@perses-dev/components");
|
|
25
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
26
|
+
const _reactquery = require("@tanstack/react-query");
|
|
27
|
+
const _react = require("@testing-library/react");
|
|
27
28
|
const _history = require("history");
|
|
29
|
+
const _react1 = require("react");
|
|
30
|
+
const _reactrouterdom = require("react-router-dom");
|
|
28
31
|
const _usequeryparams = require("use-query-params");
|
|
29
32
|
const _reactrouter6 = require("use-query-params/adapters/react-router-6");
|
|
30
|
-
const _reactquery = require("@tanstack/react-query");
|
|
31
|
-
const _components = require("@perses-dev/components");
|
|
32
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
33
33
|
const _context = require("../context");
|
|
34
34
|
const _test = require("../test");
|
|
35
35
|
const _pluginregistry = require("./plugin-registry");
|
|
@@ -37,11 +37,11 @@ const _pluginregistry = require("./plugin-registry");
|
|
|
37
37
|
* Workaround for React router upgrade type errors.
|
|
38
38
|
* More details: https://stackoverflow.com/a/69948457/17575201
|
|
39
39
|
*/ const CustomRouter = ({ history, children })=>{
|
|
40
|
-
const [state, setState] = (0,
|
|
40
|
+
const [state, setState] = (0, _react1.useState)({
|
|
41
41
|
action: history.action,
|
|
42
42
|
location: history.location
|
|
43
43
|
});
|
|
44
|
-
(0,
|
|
44
|
+
(0, _react1.useLayoutEffect)(()=>history.listen(setState), [
|
|
45
45
|
history
|
|
46
46
|
]);
|
|
47
47
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactrouterdom.Router, {
|
|
@@ -61,7 +61,8 @@ function renderWithContext(ui, options, history) {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
|
-
const customHistory = history
|
|
64
|
+
const customHistory = history ?? (0, _history.createMemoryHistory)();
|
|
65
|
+
const mockRegistry = (0, _pluginsystem.mockPluginRegistry)(..._pluginregistry.MOCK_PLUGINS);
|
|
65
66
|
const BaseRender = ()=>/*#__PURE__*/ (0, _jsxruntime.jsx)(CustomRouter, {
|
|
66
67
|
history: customHistory,
|
|
67
68
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactquery.QueryClientProvider, {
|
|
@@ -76,7 +77,8 @@ function renderWithContext(ui, options, history) {
|
|
|
76
77
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ChartsProvider, {
|
|
77
78
|
chartsTheme: _components.testChartsTheme,
|
|
78
79
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PluginRegistry, {
|
|
79
|
-
|
|
80
|
+
pluginLoader: mockRegistry.pluginLoader,
|
|
81
|
+
defaultPluginKinds: mockRegistry.defaultPluginKinds,
|
|
80
82
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_context.DatasourceStoreProvider, {
|
|
81
83
|
..._test.defaultDatasourceProps,
|
|
82
84
|
children: ui
|
|
@@ -87,5 +89,5 @@ function renderWithContext(ui, options, history) {
|
|
|
87
89
|
})
|
|
88
90
|
})
|
|
89
91
|
});
|
|
90
|
-
return (0,
|
|
92
|
+
return (0, _react.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(BaseRender, {}), options);
|
|
91
93
|
}
|
|
@@ -28,7 +28,7 @@ const _pluginsystem = require("@perses-dev/plugin-system");
|
|
|
28
28
|
const _components1 = require("../../components");
|
|
29
29
|
const _context = require("../../context");
|
|
30
30
|
const DashboardApp = (props)=>{
|
|
31
|
-
const { dashboardResource, dashboardTitleComponent, emptyDashboardProps, onSave, onDiscard, initialVariableIsSticky, isReadonly, isCreating } = props;
|
|
31
|
+
const { dashboardResource, dashboardTitleComponent, emptyDashboardProps, onSave, onDiscard, initialVariableIsSticky, isReadonly, isVariableEnabled, isDatasourceEnabled, isCreating } = props;
|
|
32
32
|
const chartsTheme = (0, _components.useChartsTheme)();
|
|
33
33
|
const { isEditMode, setEditMode } = (0, _context.useEditMode)();
|
|
34
34
|
const { dashboard, setDashboard } = (0, _context.useDashboard)();
|
|
@@ -49,8 +49,7 @@ const DashboardApp = (props)=>{
|
|
|
49
49
|
const onEditButtonClick = ()=>{
|
|
50
50
|
setEditMode(true);
|
|
51
51
|
setOriginalDashboard(dashboard);
|
|
52
|
-
|
|
53
|
-
setSavedDatasources((_dashboard_spec_datasources = dashboard.spec.datasources) !== null && _dashboard_spec_datasources !== void 0 ? _dashboard_spec_datasources : {});
|
|
52
|
+
setSavedDatasources(dashboard.spec.datasources ?? {});
|
|
54
53
|
};
|
|
55
54
|
const onCancelButtonClick = ()=>{
|
|
56
55
|
// check if dashboard has been modified
|
|
@@ -82,6 +81,8 @@ const DashboardApp = (props)=>{
|
|
|
82
81
|
initialVariableIsSticky: initialVariableIsSticky,
|
|
83
82
|
onSave: onSave,
|
|
84
83
|
isReadonly: isReadonly,
|
|
84
|
+
isVariableEnabled: isVariableEnabled,
|
|
85
|
+
isDatasourceEnabled: isDatasourceEnabled,
|
|
85
86
|
onEditButtonClick: onEditButtonClick,
|
|
86
87
|
onCancelButtonClick: onCancelButtonClick
|
|
87
88
|
}),
|