@perses-dev/dashboards 0.53.1 → 0.54.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/DashboardLinks/DashboardLinksEditor.js +366 -0
- package/dist/cjs/components/DashboardLinks/EditDashboardLinksButton.js +81 -0
- package/dist/cjs/components/DashboardLinks/index.js +31 -0
- package/dist/cjs/components/DashboardShortcuts/index.js +23 -0
- package/dist/cjs/components/DashboardShortcuts/useDashboardShortcuts.js +373 -0
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +16 -1
- package/dist/cjs/components/Datasources/EditDatasourcesButton.js +1 -7
- package/dist/cjs/components/GridLayout/GridItemContent.js +19 -6
- package/dist/cjs/components/{Panel/PanelLinks.js → LinksDisplay/LinksDisplay.js} +59 -10
- package/dist/cjs/components/LinksDisplay/index.js +30 -0
- package/dist/cjs/components/Panel/PanelActions.js +38 -23
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -4
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +3 -61
- package/dist/cjs/components/Variables/ListVariableListBox.js +6 -6
- package/dist/cjs/components/Variables/Variable.js +3 -3
- package/dist/cjs/components/index.js +2 -0
- package/dist/cjs/constants/user-interface-text.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +5 -1
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +16 -0
- package/dist/cjs/context/DashboardProvider/index.js +7 -0
- package/dist/cjs/context/DashboardProvider/links-slice.js +32 -0
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +2 -2
- package/dist/cjs/context/DashboardProvider/use-save-dashboard.js +104 -0
- package/dist/cjs/context/DatasourceStoreProvider.js +3 -9
- package/dist/cjs/context/VariableProvider/VariableProvider.js +7 -6
- package/dist/cjs/context/VariableProvider/hydrationUtils.js +3 -3
- package/dist/cjs/context/useDashboard.js +7 -4
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/keyboard-shortcuts/PanelFocusProvider.js +157 -0
- package/dist/cjs/keyboard-shortcuts/default-shortcuts/dashboard.js +75 -0
- package/dist/cjs/keyboard-shortcuts/default-shortcuts/global.js +121 -0
- package/dist/cjs/keyboard-shortcuts/default-shortcuts/index.js +33 -0
- package/dist/cjs/keyboard-shortcuts/default-shortcuts/panel.js +90 -0
- package/dist/cjs/keyboard-shortcuts/default-shortcuts/time-range.js +142 -0
- package/dist/cjs/keyboard-shortcuts/events.js +93 -0
- package/dist/cjs/keyboard-shortcuts/index.js +89 -0
- package/dist/cjs/keyboard-shortcuts/types.js +42 -0
- package/dist/cjs/keyboard-shortcuts/utils.js +76 -0
- package/dist/cjs/model/DashboardResource.js +16 -0
- package/dist/cjs/model/index.js +30 -0
- package/dist/cjs/test/render.js +18 -3
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +17 -2
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -1
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/DashboardLinks/DashboardLinksEditor.d.ts +9 -0
- package/dist/components/DashboardLinks/DashboardLinksEditor.d.ts.map +1 -0
- package/dist/components/DashboardLinks/DashboardLinksEditor.js +353 -0
- package/dist/components/DashboardLinks/DashboardLinksEditor.js.map +1 -0
- package/dist/components/DashboardLinks/EditDashboardLinksButton.d.ts +18 -0
- package/dist/components/DashboardLinks/EditDashboardLinksButton.d.ts.map +1 -0
- package/dist/components/DashboardLinks/EditDashboardLinksButton.js +68 -0
- package/dist/components/DashboardLinks/EditDashboardLinksButton.js.map +1 -0
- package/dist/components/DashboardLinks/index.d.ts +3 -0
- package/dist/components/DashboardLinks/index.d.ts.map +1 -0
- package/dist/components/DashboardLinks/index.js +16 -0
- package/dist/components/DashboardLinks/index.js.map +1 -0
- package/dist/components/DashboardShortcuts/index.d.ts +3 -0
- package/dist/components/DashboardShortcuts/index.d.ts.map +1 -0
- package/dist/components/DashboardShortcuts/index.js +15 -0
- package/dist/components/DashboardShortcuts/index.js.map +1 -0
- package/dist/components/DashboardShortcuts/useDashboardShortcuts.d.ts +12 -0
- package/dist/components/DashboardShortcuts/useDashboardShortcuts.d.ts.map +1 -0
- package/dist/components/DashboardShortcuts/useDashboardShortcuts.js +365 -0
- package/dist/components/DashboardShortcuts/useDashboardShortcuts.js.map +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +17 -2
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.d.ts +1 -1
- package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
- package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -1
- package/dist/components/Datasources/EditDatasourcesButton.js +1 -7
- package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
- package/dist/components/DownloadButton/serializeDashboard.d.ts +2 -2
- package/dist/components/DownloadButton/serializeDashboard.d.ts.map +1 -1
- package/dist/components/DownloadButton/serializeDashboard.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +21 -8
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts +1 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/GridLayout/Row.d.ts +2 -1
- package/dist/components/GridLayout/Row.d.ts.map +1 -1
- package/dist/components/GridLayout/Row.js.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.d.ts +3 -3
- package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -1
- package/dist/components/LinksDisplay/LinksDisplay.d.ts +10 -0
- package/dist/components/LinksDisplay/LinksDisplay.d.ts.map +1 -0
- package/dist/components/{Panel/PanelLinks.js → LinksDisplay/LinksDisplay.js} +59 -10
- package/dist/components/LinksDisplay/LinksDisplay.js.map +1 -0
- package/dist/components/LinksDisplay/index.d.ts +2 -0
- package/dist/components/LinksDisplay/index.d.ts.map +1 -0
- package/dist/components/LinksDisplay/index.js +15 -0
- package/dist/components/LinksDisplay/index.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +2 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.d.ts +1 -1
- package/dist/components/Panel/PanelActions.d.ts.map +1 -1
- package/dist/components/Panel/PanelActions.js +39 -24
- package/dist/components/Panel/PanelActions.js.map +1 -1
- package/dist/components/Panel/PanelContent.d.ts +1 -1
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +1 -1
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/Panel/PanelPluginLoader.d.ts +1 -1
- package/dist/components/Panel/PanelPluginLoader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +2 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.js.map +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.d.ts +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts +1 -1
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +4 -62
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
- package/dist/components/Variables/BuiltinVariableAccordions.d.ts +1 -1
- package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -1
- package/dist/components/Variables/EditVariablesButton.d.ts.map +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.d.ts +1 -1
- package/dist/components/Variables/Variable.js +1 -1
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +2 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +1 -1
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/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.d.ts +8 -6
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +5 -1
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +3 -2
- 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 +15 -2
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +14 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
- 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/index.d.ts +2 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js +1 -0
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/links-slice.d.ts +19 -0
- package/dist/context/DashboardProvider/links-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/links-slice.js +27 -0
- package/dist/context/DashboardProvider/links-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -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-editor-slice.d.ts +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.d.ts +1 -1
- package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/use-save-dashboard.d.ts +25 -0
- package/dist/context/DashboardProvider/use-save-dashboard.d.ts.map +1 -0
- package/dist/context/DashboardProvider/use-save-dashboard.js +105 -0
- package/dist/context/DashboardProvider/use-save-dashboard.js.map +1 -0
- package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +4 -2
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +3 -9
- package/dist/context/DatasourceStoreProvider.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 +2 -1
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/VariableProvider/hydrationUtils.d.ts +2 -1
- package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/VariableProvider/hydrationUtils.js +1 -1
- package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/VariableProvider/query-params.d.ts +1 -1
- package/dist/context/VariableProvider/query-params.js.map +1 -1
- package/dist/context/VariableProvider/utils.d.ts +2 -1
- package/dist/context/VariableProvider/utils.d.ts.map +1 -1
- package/dist/context/VariableProvider/utils.js.map +1 -1
- package/dist/context/useDashboard.d.ts +11 -3
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +6 -3
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/keyboard-shortcuts/PanelFocusProvider.d.ts +12 -0
- package/dist/keyboard-shortcuts/PanelFocusProvider.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/PanelFocusProvider.js +97 -0
- package/dist/keyboard-shortcuts/PanelFocusProvider.js.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/dashboard.d.ts +6 -0
- package/dist/keyboard-shortcuts/default-shortcuts/dashboard.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/dashboard.js +53 -0
- package/dist/keyboard-shortcuts/default-shortcuts/dashboard.js.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/global.d.ts +9 -0
- package/dist/keyboard-shortcuts/default-shortcuts/global.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/global.js +90 -0
- package/dist/keyboard-shortcuts/default-shortcuts/global.js.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/index.d.ts +5 -0
- package/dist/keyboard-shortcuts/default-shortcuts/index.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/index.js +18 -0
- package/dist/keyboard-shortcuts/default-shortcuts/index.js.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/panel.d.ts +7 -0
- package/dist/keyboard-shortcuts/default-shortcuts/panel.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/panel.js +65 -0
- package/dist/keyboard-shortcuts/default-shortcuts/panel.js.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/time-range.d.ts +10 -0
- package/dist/keyboard-shortcuts/default-shortcuts/time-range.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/default-shortcuts/time-range.js +108 -0
- package/dist/keyboard-shortcuts/default-shortcuts/time-range.js.map +1 -0
- package/dist/keyboard-shortcuts/events.d.ts +18 -0
- package/dist/keyboard-shortcuts/events.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/events.js +35 -0
- package/dist/keyboard-shortcuts/events.js.map +1 -0
- package/dist/keyboard-shortcuts/index.d.ts +9 -0
- package/dist/keyboard-shortcuts/index.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/index.js +21 -0
- package/dist/keyboard-shortcuts/index.js.map +1 -0
- package/dist/keyboard-shortcuts/types.d.ts +37 -0
- package/dist/keyboard-shortcuts/types.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/types.js +26 -0
- package/dist/keyboard-shortcuts/types.js.map +1 -0
- package/dist/keyboard-shortcuts/utils.d.ts +12 -0
- package/dist/keyboard-shortcuts/utils.d.ts.map +1 -0
- package/dist/keyboard-shortcuts/utils.js +51 -0
- package/dist/keyboard-shortcuts/utils.js.map +1 -0
- package/dist/model/DashboardResource.d.ts +15 -0
- package/dist/model/DashboardResource.d.ts.map +1 -0
- package/dist/model/DashboardResource.js +18 -0
- package/dist/model/DashboardResource.js.map +1 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +15 -0
- package/dist/model/index.js.map +1 -0
- 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.js.map +1 -1
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +18 -3
- package/dist/test/render.js.map +1 -1
- package/dist/test/testDashboard.d.ts +11 -2
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/panelUtils.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +5 -3
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +18 -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 +3 -2
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +5 -3
- package/dist/components/Panel/PanelLinks.d.ts +0 -6
- package/dist/components/Panel/PanelLinks.d.ts.map +0 -1
- package/dist/components/Panel/PanelLinks.js.map +0 -1
|
@@ -0,0 +1,373 @@
|
|
|
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, "useDashboardShortcuts", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return useDashboardShortcuts;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _react = require("react");
|
|
24
|
+
const _spec = require("@perses-dev/spec");
|
|
25
|
+
const _components = require("@perses-dev/components");
|
|
26
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
27
|
+
const _reacthotkeys = require("@tanstack/react-hotkeys");
|
|
28
|
+
const _keyboardshortcuts = require("../../keyboard-shortcuts");
|
|
29
|
+
const _DashboardProvider = require("../../context/DashboardProvider");
|
|
30
|
+
const SAVE_SHORTCUT_EDIT_MODE_MESSAGE = 'Enter edit mode to save this dashboard.';
|
|
31
|
+
const SAVE_SHORTCUT_READONLY_MESSAGE = 'This dashboard is read-only. Keyboard save is disabled.';
|
|
32
|
+
const SAVE_SHORTCUT_UNAVAILABLE_MESSAGE = 'Save action is unavailable for this dashboard.';
|
|
33
|
+
function parsePanelKey(panelKey) {
|
|
34
|
+
const dashIndex = panelKey.indexOf('-');
|
|
35
|
+
if (dashIndex === -1) return null;
|
|
36
|
+
const panelGroupId = parseInt(panelKey.substring(0, dashIndex), 10);
|
|
37
|
+
const panelGroupItemLayoutId = panelKey.substring(dashIndex + 1);
|
|
38
|
+
if (isNaN(panelGroupId)) return null;
|
|
39
|
+
return {
|
|
40
|
+
panelGroupId,
|
|
41
|
+
panelGroupItemLayoutId
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// Zoom limits: 1 second minimum, 10 years maximum
|
|
45
|
+
const MIN_ZOOM_DURATION_MS = 1_000;
|
|
46
|
+
const MAX_ZOOM_DURATION_MS = 10 * 365.25 * 24 * 60 * 60 * 1_000;
|
|
47
|
+
function resolveAbsoluteRange(timeRange) {
|
|
48
|
+
const absoluteRange = (0, _spec.isRelativeTimeRange)(timeRange) ? (0, _spec.toAbsoluteTimeRange)(timeRange) : timeRange;
|
|
49
|
+
const startMs = absoluteRange.start.getTime();
|
|
50
|
+
const endMs = absoluteRange.end.getTime();
|
|
51
|
+
const durationMs = endMs - startMs;
|
|
52
|
+
const midpointMs = Math.round(startMs + durationMs / 2);
|
|
53
|
+
return {
|
|
54
|
+
absoluteRange,
|
|
55
|
+
durationMs,
|
|
56
|
+
midpointMs
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const selectPanelStoreActions = (state)=>({
|
|
60
|
+
openEditPanel: state.openEditPanel,
|
|
61
|
+
duplicatePanel: state.duplicatePanel,
|
|
62
|
+
openDeletePanelDialog: state.openDeletePanelDialog,
|
|
63
|
+
setViewPanel: state.setViewPanel,
|
|
64
|
+
panelEditor: state.panelEditor
|
|
65
|
+
});
|
|
66
|
+
function useDashboardShortcuts({ onSave, onRefresh, isReadonly, onEditButtonClick, onCancelButtonClick, disabled = false }) {
|
|
67
|
+
const focusedPanelKey = (0, _keyboardshortcuts.useFocusedPanel)();
|
|
68
|
+
const { isEditMode, setEditMode } = (0, _DashboardProvider.useEditMode)();
|
|
69
|
+
const { timeRange, setTimeRange, refresh } = (0, _pluginsystem.useTimeRange)();
|
|
70
|
+
const { infoSnackbar, warningSnackbar } = (0, _components.useSnackbar)();
|
|
71
|
+
const viewPanel = (0, _DashboardProvider.useViewPanelGroup)();
|
|
72
|
+
const { openEditPanel, duplicatePanel, openDeletePanelDialog, setViewPanel, panelEditor } = (0, _DashboardProvider.useDashboardStore)(selectPanelStoreActions);
|
|
73
|
+
const { saveDashboard } = (0, _DashboardProvider.useSaveDashboard)(onSave);
|
|
74
|
+
const panelFocused = focusedPanelKey !== null;
|
|
75
|
+
// --- Handlers ---
|
|
76
|
+
const handleSave = (0, _react.useCallback)(()=>{
|
|
77
|
+
if (isReadonly) {
|
|
78
|
+
warningSnackbar(SAVE_SHORTCUT_READONLY_MESSAGE);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!isEditMode) {
|
|
82
|
+
infoSnackbar(SAVE_SHORTCUT_EDIT_MODE_MESSAGE);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!onSave) {
|
|
86
|
+
warningSnackbar(SAVE_SHORTCUT_UNAVAILABLE_MESSAGE);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
saveDashboard();
|
|
90
|
+
}, [
|
|
91
|
+
infoSnackbar,
|
|
92
|
+
isEditMode,
|
|
93
|
+
isReadonly,
|
|
94
|
+
onSave,
|
|
95
|
+
saveDashboard,
|
|
96
|
+
warningSnackbar
|
|
97
|
+
]);
|
|
98
|
+
const handleRefresh = (0, _react.useCallback)(()=>{
|
|
99
|
+
refresh();
|
|
100
|
+
infoSnackbar('Dashboard refreshed.');
|
|
101
|
+
if (onRefresh) {
|
|
102
|
+
onRefresh();
|
|
103
|
+
}
|
|
104
|
+
}, [
|
|
105
|
+
refresh,
|
|
106
|
+
infoSnackbar,
|
|
107
|
+
onRefresh
|
|
108
|
+
]);
|
|
109
|
+
const handleToggleEditMode = (0, _react.useCallback)(()=>{
|
|
110
|
+
if (isEditMode) {
|
|
111
|
+
// Switching from edit to view: delegate to cancel flow (shows discard dialog if needed)
|
|
112
|
+
if (onCancelButtonClick) {
|
|
113
|
+
onCancelButtonClick();
|
|
114
|
+
} else {
|
|
115
|
+
setEditMode(false);
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
// Switching from view to edit: delegate to edit flow (saves original state)
|
|
119
|
+
if (onEditButtonClick) {
|
|
120
|
+
onEditButtonClick();
|
|
121
|
+
} else {
|
|
122
|
+
setEditMode(true);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}, [
|
|
126
|
+
isEditMode,
|
|
127
|
+
setEditMode,
|
|
128
|
+
onCancelButtonClick,
|
|
129
|
+
onEditButtonClick
|
|
130
|
+
]);
|
|
131
|
+
// Time range handlers
|
|
132
|
+
const handleTimeZoomOut = (0, _react.useCallback)(()=>{
|
|
133
|
+
const { durationMs, midpointMs } = resolveAbsoluteRange(timeRange);
|
|
134
|
+
const newDuration = Math.min(durationMs * 2, MAX_ZOOM_DURATION_MS);
|
|
135
|
+
const halfNew = Math.round(newDuration / 2);
|
|
136
|
+
setTimeRange({
|
|
137
|
+
start: new Date(midpointMs - halfNew),
|
|
138
|
+
end: new Date(midpointMs + halfNew)
|
|
139
|
+
});
|
|
140
|
+
}, [
|
|
141
|
+
timeRange,
|
|
142
|
+
setTimeRange
|
|
143
|
+
]);
|
|
144
|
+
const handleTimeZoomIn = (0, _react.useCallback)(()=>{
|
|
145
|
+
const { durationMs, midpointMs } = resolveAbsoluteRange(timeRange);
|
|
146
|
+
const newDuration = Math.max(Math.round(durationMs / 2), MIN_ZOOM_DURATION_MS);
|
|
147
|
+
const halfNew = Math.round(newDuration / 2);
|
|
148
|
+
setTimeRange({
|
|
149
|
+
start: new Date(midpointMs - halfNew),
|
|
150
|
+
end: new Date(midpointMs + halfNew)
|
|
151
|
+
});
|
|
152
|
+
}, [
|
|
153
|
+
timeRange,
|
|
154
|
+
setTimeRange
|
|
155
|
+
]);
|
|
156
|
+
const handleTimeShiftBack = (0, _react.useCallback)(()=>{
|
|
157
|
+
const { absoluteRange, durationMs } = resolveAbsoluteRange(timeRange);
|
|
158
|
+
const shift = Math.round(durationMs / 2);
|
|
159
|
+
setTimeRange({
|
|
160
|
+
start: new Date(absoluteRange.start.getTime() - shift),
|
|
161
|
+
end: new Date(absoluteRange.end.getTime() - shift)
|
|
162
|
+
});
|
|
163
|
+
}, [
|
|
164
|
+
timeRange,
|
|
165
|
+
setTimeRange
|
|
166
|
+
]);
|
|
167
|
+
const handleTimeShiftForward = (0, _react.useCallback)(()=>{
|
|
168
|
+
const { absoluteRange, durationMs } = resolveAbsoluteRange(timeRange);
|
|
169
|
+
const shift = Math.round(durationMs / 2);
|
|
170
|
+
setTimeRange({
|
|
171
|
+
start: new Date(absoluteRange.start.getTime() + shift),
|
|
172
|
+
end: new Date(absoluteRange.end.getTime() + shift)
|
|
173
|
+
});
|
|
174
|
+
}, [
|
|
175
|
+
timeRange,
|
|
176
|
+
setTimeRange
|
|
177
|
+
]);
|
|
178
|
+
const handleTimeMakeAbsolute = (0, _react.useCallback)(()=>{
|
|
179
|
+
if ((0, _spec.isRelativeTimeRange)(timeRange)) {
|
|
180
|
+
setTimeRange((0, _spec.toAbsoluteTimeRange)(timeRange));
|
|
181
|
+
}
|
|
182
|
+
}, [
|
|
183
|
+
timeRange,
|
|
184
|
+
setTimeRange
|
|
185
|
+
]);
|
|
186
|
+
const handleTimeCopy = (0, _react.useCallback)(()=>{
|
|
187
|
+
const absoluteRange = (0, _spec.isRelativeTimeRange)(timeRange) ? (0, _spec.toAbsoluteTimeRange)(timeRange) : timeRange;
|
|
188
|
+
const text = `${absoluteRange.start.toISOString()} - ${absoluteRange.end.toISOString()}`;
|
|
189
|
+
navigator.clipboard.writeText(text).then(()=>{
|
|
190
|
+
infoSnackbar('Time range copied to clipboard.');
|
|
191
|
+
}).catch(()=>{
|
|
192
|
+
warningSnackbar('Failed to copy time range to clipboard.');
|
|
193
|
+
});
|
|
194
|
+
}, [
|
|
195
|
+
timeRange,
|
|
196
|
+
infoSnackbar,
|
|
197
|
+
warningSnackbar
|
|
198
|
+
]);
|
|
199
|
+
const handleTimePaste = (0, _react.useCallback)(()=>{
|
|
200
|
+
const FORMAT_HINT = 'Expected format: "<ISO date format> - <ISO date format>".';
|
|
201
|
+
navigator.clipboard.readText().then((text)=>{
|
|
202
|
+
const parts = text.split(' - ');
|
|
203
|
+
if (parts.length !== 2) {
|
|
204
|
+
warningSnackbar(`Clipboard does not contain a valid time range. ${FORMAT_HINT}`);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const [startStr, endStr] = parts;
|
|
208
|
+
const start = new Date(startStr.trim());
|
|
209
|
+
const end = new Date(endStr.trim());
|
|
210
|
+
if (isNaN(start.getTime()) || isNaN(end.getTime())) {
|
|
211
|
+
warningSnackbar(`Clipboard does not contain a valid time range. ${FORMAT_HINT}`);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (start >= end) {
|
|
215
|
+
warningSnackbar('Invalid time range: start must be before end.');
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const newRange = {
|
|
219
|
+
start,
|
|
220
|
+
end
|
|
221
|
+
};
|
|
222
|
+
setTimeRange(newRange);
|
|
223
|
+
infoSnackbar('Time range pasted from clipboard.');
|
|
224
|
+
}).catch(()=>{
|
|
225
|
+
warningSnackbar('Unable to read from clipboard. Check browser permissions.');
|
|
226
|
+
});
|
|
227
|
+
}, [
|
|
228
|
+
setTimeRange,
|
|
229
|
+
infoSnackbar,
|
|
230
|
+
warningSnackbar
|
|
231
|
+
]);
|
|
232
|
+
// Panel handlers
|
|
233
|
+
const handlePanelEditToggle = (0, _react.useCallback)(()=>{
|
|
234
|
+
if (panelEditor !== undefined) {
|
|
235
|
+
panelEditor.close();
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (focusedPanelKey && isEditMode) {
|
|
239
|
+
const panelId = parsePanelKey(focusedPanelKey);
|
|
240
|
+
if (panelId) {
|
|
241
|
+
openEditPanel(panelId);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}, [
|
|
245
|
+
focusedPanelKey,
|
|
246
|
+
isEditMode,
|
|
247
|
+
openEditPanel,
|
|
248
|
+
panelEditor
|
|
249
|
+
]);
|
|
250
|
+
const handlePanelFullscreenToggle = (0, _react.useCallback)(()=>{
|
|
251
|
+
if (viewPanel !== undefined) {
|
|
252
|
+
setViewPanel(undefined);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (focusedPanelKey) {
|
|
256
|
+
const panelId = parsePanelKey(focusedPanelKey);
|
|
257
|
+
if (panelId) {
|
|
258
|
+
setViewPanel(panelId);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}, [
|
|
262
|
+
focusedPanelKey,
|
|
263
|
+
setViewPanel,
|
|
264
|
+
viewPanel
|
|
265
|
+
]);
|
|
266
|
+
const handlePanelDuplicate = (0, _react.useCallback)(()=>{
|
|
267
|
+
if (focusedPanelKey && isEditMode) {
|
|
268
|
+
const panelId = parsePanelKey(focusedPanelKey);
|
|
269
|
+
if (panelId) {
|
|
270
|
+
duplicatePanel(panelId);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}, [
|
|
274
|
+
focusedPanelKey,
|
|
275
|
+
isEditMode,
|
|
276
|
+
duplicatePanel
|
|
277
|
+
]);
|
|
278
|
+
const handlePanelDelete = (0, _react.useCallback)(()=>{
|
|
279
|
+
if (focusedPanelKey && isEditMode) {
|
|
280
|
+
const panelId = parsePanelKey(focusedPanelKey);
|
|
281
|
+
if (panelId) {
|
|
282
|
+
openDeletePanelDialog(panelId);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}, [
|
|
286
|
+
focusedPanelKey,
|
|
287
|
+
isEditMode,
|
|
288
|
+
openDeletePanelDialog
|
|
289
|
+
]);
|
|
290
|
+
// Register shortcuts
|
|
291
|
+
(0, _reacthotkeys.useHotkeys)([
|
|
292
|
+
{
|
|
293
|
+
def: _keyboardshortcuts.SAVE_DASHBOARD_SHORTCUT,
|
|
294
|
+
enabled: !disabled,
|
|
295
|
+
callback: handleSave
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
def: _keyboardshortcuts.PANEL_EDIT_SHORTCUT,
|
|
299
|
+
enabled: !disabled && (panelFocused || panelEditor !== undefined),
|
|
300
|
+
callback: handlePanelEditToggle
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
def: _keyboardshortcuts.PANEL_FULLSCREEN_SHORTCUT,
|
|
304
|
+
enabled: !disabled && (panelFocused || viewPanel !== undefined),
|
|
305
|
+
callback: handlePanelFullscreenToggle
|
|
306
|
+
}
|
|
307
|
+
].map(({ def, enabled, callback })=>({
|
|
308
|
+
hotkey: (0, _keyboardshortcuts.requireShortcutHotkey)(def),
|
|
309
|
+
callback,
|
|
310
|
+
options: (0, _keyboardshortcuts.buildShortcutOptions)(def, enabled)
|
|
311
|
+
})));
|
|
312
|
+
(0, _reacthotkeys.useHotkeySequences)([
|
|
313
|
+
{
|
|
314
|
+
def: _keyboardshortcuts.REFRESH_DASHBOARD_SHORTCUT,
|
|
315
|
+
enabled: !disabled,
|
|
316
|
+
callback: handleRefresh
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
def: _keyboardshortcuts.TOGGLE_EDIT_MODE_SHORTCUT,
|
|
320
|
+
enabled: !disabled,
|
|
321
|
+
callback: handleToggleEditMode
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
def: _keyboardshortcuts.TIME_ZOOM_OUT_SHORTCUT,
|
|
325
|
+
enabled: !disabled,
|
|
326
|
+
callback: handleTimeZoomOut
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
def: _keyboardshortcuts.TIME_ZOOM_IN_SHORTCUT,
|
|
330
|
+
enabled: !disabled,
|
|
331
|
+
callback: handleTimeZoomIn
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
def: _keyboardshortcuts.TIME_SHIFT_BACK_SHORTCUT,
|
|
335
|
+
enabled: !disabled,
|
|
336
|
+
callback: handleTimeShiftBack
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
def: _keyboardshortcuts.TIME_SHIFT_FORWARD_SHORTCUT,
|
|
340
|
+
enabled: !disabled,
|
|
341
|
+
callback: handleTimeShiftForward
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
def: _keyboardshortcuts.TIME_MAKE_ABSOLUTE_SHORTCUT,
|
|
345
|
+
enabled: !disabled,
|
|
346
|
+
callback: handleTimeMakeAbsolute
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
def: _keyboardshortcuts.TIME_COPY_SHORTCUT,
|
|
350
|
+
enabled: !disabled,
|
|
351
|
+
callback: handleTimeCopy
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
def: _keyboardshortcuts.TIME_PASTE_SHORTCUT,
|
|
355
|
+
enabled: !disabled,
|
|
356
|
+
callback: handleTimePaste
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
def: _keyboardshortcuts.PANEL_DUPLICATE_SHORTCUT,
|
|
360
|
+
enabled: !disabled && panelFocused,
|
|
361
|
+
callback: handlePanelDuplicate
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
def: _keyboardshortcuts.PANEL_DELETE_SHORTCUT,
|
|
365
|
+
enabled: !disabled && panelFocused,
|
|
366
|
+
callback: handlePanelDelete
|
|
367
|
+
}
|
|
368
|
+
].map(({ def, enabled, callback })=>({
|
|
369
|
+
sequence: (0, _keyboardshortcuts.requireShortcutSequence)(def),
|
|
370
|
+
callback,
|
|
371
|
+
options: (0, _keyboardshortcuts.buildShortcutOptions)(def, enabled)
|
|
372
|
+
})));
|
|
373
|
+
}
|
|
@@ -34,10 +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 _DashboardLinks = require("../DashboardLinks");
|
|
38
|
+
const _LinksDisplay = require("../LinksDisplay");
|
|
37
39
|
const DashboardToolbar = (props)=>{
|
|
38
|
-
const { dashboardName, dashboardTitleComponent, initialVariableIsSticky, isReadonly, isVariableEnabled, isDatasourceEnabled, onEditButtonClick, onCancelButtonClick, onSave } = props;
|
|
40
|
+
const { dashboardName, dashboardTitleComponent, initialVariableIsSticky, isReadonly, isVariableEnabled, isDatasourceEnabled, isLinksEnabled = true, onEditButtonClick, onCancelButtonClick, onSave } = props;
|
|
39
41
|
const { isEditMode } = (0, _context.useEditMode)();
|
|
40
42
|
const { timeZone, setTimeZone } = (0, _pluginsystem.useTimeZoneParams)('local');
|
|
43
|
+
const dashboardLinks = (0, _context.useDashboardLinks)();
|
|
41
44
|
const isBiggerThanSm = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('sm'));
|
|
42
45
|
const isBiggerThanMd = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('md'));
|
|
43
46
|
const dashboardTitle = dashboardTitleComponent ? dashboardTitleComponent : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
@@ -54,10 +57,21 @@ const DashboardToolbar = (props)=>{
|
|
|
54
57
|
py: 1.5,
|
|
55
58
|
display: "flex",
|
|
56
59
|
sx: {
|
|
60
|
+
gap: 2,
|
|
57
61
|
backgroundColor: (theme)=>theme.palette.primary.main + (isEditMode ? '30' : '0')
|
|
58
62
|
},
|
|
59
63
|
children: [
|
|
60
64
|
dashboardTitle,
|
|
65
|
+
isLinksEnabled && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
66
|
+
display: "flex",
|
|
67
|
+
justifyItems: "center",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
justifyContent: "center",
|
|
70
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_LinksDisplay.LinksDisplay, {
|
|
71
|
+
links: dashboardLinks,
|
|
72
|
+
variant: "dashboard"
|
|
73
|
+
})
|
|
74
|
+
}),
|
|
61
75
|
isEditMode ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
62
76
|
direction: "row",
|
|
63
77
|
gap: 1,
|
|
@@ -79,6 +93,7 @@ const DashboardToolbar = (props)=>{
|
|
|
79
93
|
children: [
|
|
80
94
|
isVariableEnabled && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Variables.EditVariablesButton, {}),
|
|
81
95
|
isDatasourceEnabled && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Datasources.EditDatasourcesButton, {}),
|
|
96
|
+
isLinksEnabled && /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardLinks.EditDashboardLinksButton, {}),
|
|
82
97
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_AddPanelButton.AddPanelButton, {}),
|
|
83
98
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_AddGroupButton.AddGroupButton, {})
|
|
84
99
|
]
|
|
@@ -58,13 +58,7 @@ function EditDatasourcesButton() {
|
|
|
58
58
|
obj[key] = datasources[key];
|
|
59
59
|
return obj;
|
|
60
60
|
}, {});
|
|
61
|
-
setDashboard(
|
|
62
|
-
...dashboard,
|
|
63
|
-
spec: {
|
|
64
|
-
...dashboard.spec,
|
|
65
|
-
datasources: datasources
|
|
66
|
-
}
|
|
67
|
-
} : {
|
|
61
|
+
setDashboard({
|
|
68
62
|
...dashboard,
|
|
69
63
|
spec: {
|
|
70
64
|
...dashboard.spec,
|
|
@@ -27,6 +27,7 @@ const _pluginsystem = require("@perses-dev/plugin-system");
|
|
|
27
27
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
28
28
|
const _core = require("@perses-dev/core");
|
|
29
29
|
const _context = require("../../context");
|
|
30
|
+
const _keyboardshortcuts = require("../../keyboard-shortcuts");
|
|
30
31
|
const _Panel = require("../Panel");
|
|
31
32
|
const _QueryViewerDialog = require("../QueryViewerDialog");
|
|
32
33
|
function _getRequireWildcardCache(nodeInterop) {
|
|
@@ -77,11 +78,19 @@ function GridItemContent(props) {
|
|
|
77
78
|
const { isEditMode } = (0, _context.useEditMode)();
|
|
78
79
|
const { openEditPanel, openDeletePanelDialog, duplicatePanel, viewPanel } = (0, _context.usePanelActions)(panelGroupItemId);
|
|
79
80
|
const viewPanelGroupItemId = (0, _context.useViewPanelGroup)();
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
// Panel focus tracking for keyboard shortcuts
|
|
82
|
+
const { onMouseEnter, onMouseLeave } = (0, _keyboardshortcuts.usePanelFocusHandlers)(`${panelGroupItemId.panelGroupId}-${panelGroupItemId.panelGroupItemLayoutId}`);
|
|
83
|
+
const { ref: queryRef, inView: shouldQuery } = (0, _reactintersectionobserver.useInView)({
|
|
84
|
+
threshold: 0,
|
|
82
85
|
initialInView: false,
|
|
83
86
|
triggerOnce: true
|
|
84
87
|
});
|
|
88
|
+
const { ref: renderRef, inView: shouldRender } = (0, _reactintersectionobserver.useInView)({
|
|
89
|
+
threshold: 0.2,
|
|
90
|
+
initialInView: false,
|
|
91
|
+
triggerOnce: false
|
|
92
|
+
});
|
|
93
|
+
const mergedRef = (0, _material.useForkRef)(renderRef, queryRef);
|
|
85
94
|
const [openQueryViewer, setOpenQueryViewer] = (0, _react.useState)(false);
|
|
86
95
|
const viewQueriesHandler = (0, _react.useMemo)(()=>{
|
|
87
96
|
return isEditMode || !queries?.length ? undefined : {
|
|
@@ -124,10 +133,14 @@ function GridItemContent(props) {
|
|
|
124
133
|
});
|
|
125
134
|
const pluginQueryOptions = typeof plugin?.queryOptions === 'function' ? plugin?.queryOptions(panelDefinition.spec.plugin.spec) : plugin?.queryOptions;
|
|
126
135
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
127
|
-
ref:
|
|
136
|
+
ref: mergedRef,
|
|
137
|
+
tabIndex: -1,
|
|
138
|
+
onMouseEnter: onMouseEnter,
|
|
139
|
+
onMouseLeave: onMouseLeave,
|
|
128
140
|
sx: {
|
|
129
141
|
width: '100%',
|
|
130
|
-
height: '100%'
|
|
142
|
+
height: '100%',
|
|
143
|
+
outline: 'none'
|
|
131
144
|
},
|
|
132
145
|
children: [
|
|
133
146
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DataQueriesProvider, {
|
|
@@ -137,9 +150,9 @@ function GridItemContent(props) {
|
|
|
137
150
|
...pluginQueryOptions
|
|
138
151
|
},
|
|
139
152
|
queryOptions: {
|
|
140
|
-
enabled:
|
|
153
|
+
enabled: shouldQuery
|
|
141
154
|
},
|
|
142
|
-
children:
|
|
155
|
+
children: shouldRender && /*#__PURE__*/ (0, _jsxruntime.jsx)(_Panel.Panel, {
|
|
143
156
|
definition: panelDefinition,
|
|
144
157
|
readHandlers: readHandlers,
|
|
145
158
|
editHandlers: editHandlers,
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "LinksDisplay", {
|
|
18
18
|
enumerable: true,
|
|
19
19
|
get: function() {
|
|
20
|
-
return
|
|
20
|
+
return LinksDisplay;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
@@ -31,7 +31,7 @@ function _interop_require_default(obj) {
|
|
|
31
31
|
default: obj
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function LinksDisplay({ links, variant }) {
|
|
35
35
|
const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
|
|
36
36
|
const isMenuOpened = Boolean(anchorEl);
|
|
37
37
|
const handleOpenMenu = (event)=>{
|
|
@@ -40,21 +40,48 @@ function PanelLinks({ links }) {
|
|
|
40
40
|
const handleClose = ()=>{
|
|
41
41
|
setAnchorEl(null);
|
|
42
42
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (links.length === 0) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
// Panel variant: single link shows as icon button
|
|
47
|
+
if (variant === 'panel' && links.length === 1 && links[0]) {
|
|
46
48
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(LinkButton, {
|
|
47
|
-
link:
|
|
49
|
+
link: links[0]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Dashboard variant: 1-3 links show as chips
|
|
53
|
+
// Max character limit for the name and url to prevent overflow
|
|
54
|
+
// in the dashboard title area, but if either the name or url is too long,
|
|
55
|
+
// we will fall back to showing the links in a dropdown menu
|
|
56
|
+
if (variant === 'dashboard' && links.length <= 3) {
|
|
57
|
+
const canRenderAsChips = links.every((link)=>{
|
|
58
|
+
if (link.name) {
|
|
59
|
+
return link.name.length < 30;
|
|
60
|
+
}
|
|
61
|
+
if (link.url) {
|
|
62
|
+
return link.url.length < 70;
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
48
65
|
});
|
|
66
|
+
if (canRenderAsChips) {
|
|
67
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
68
|
+
direction: "row",
|
|
69
|
+
spacing: 1,
|
|
70
|
+
children: links.map((link)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(LinkChip, {
|
|
71
|
+
link: link
|
|
72
|
+
}, link.url))
|
|
73
|
+
});
|
|
74
|
+
}
|
|
49
75
|
}
|
|
50
|
-
//
|
|
76
|
+
// Default: show dropdown menu for multiple links
|
|
51
77
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
52
78
|
children: [
|
|
53
79
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
|
|
54
80
|
description: `${links.length} links`,
|
|
55
81
|
enterDelay: 100,
|
|
56
82
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
57
|
-
"aria-label":
|
|
83
|
+
"aria-label": `${(0, _material.capitalize)(variant)}-links`,
|
|
84
|
+
id: `${variant}-links-button`,
|
|
58
85
|
size: "small",
|
|
59
86
|
onClick: handleOpenMenu,
|
|
60
87
|
sx: (theme)=>({
|
|
@@ -75,7 +102,7 @@ function PanelLinks({ links }) {
|
|
|
75
102
|
open: isMenuOpened,
|
|
76
103
|
onClose: handleClose,
|
|
77
104
|
MenuListProps: {
|
|
78
|
-
'aria-labelledby':
|
|
105
|
+
'aria-labelledby': `${variant}-links-button`
|
|
79
106
|
},
|
|
80
107
|
children: links.map((link)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(LinkMenuItem, {
|
|
81
108
|
link: link
|
|
@@ -84,6 +111,28 @@ function PanelLinks({ links }) {
|
|
|
84
111
|
]
|
|
85
112
|
});
|
|
86
113
|
}
|
|
114
|
+
function LinkChip({ link }) {
|
|
115
|
+
const { url, name, tooltip, targetBlank } = useLink(link);
|
|
116
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
|
|
117
|
+
description: tooltip ?? url,
|
|
118
|
+
enterDelay: 100,
|
|
119
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
|
|
120
|
+
label: name ?? url,
|
|
121
|
+
component: "a",
|
|
122
|
+
href: url,
|
|
123
|
+
target: targetBlank ? '_blank' : '_self',
|
|
124
|
+
clickable: true,
|
|
125
|
+
size: "medium",
|
|
126
|
+
icon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Launch.default, {
|
|
127
|
+
color: "inherit",
|
|
128
|
+
fontSize: "small"
|
|
129
|
+
}),
|
|
130
|
+
sx: (theme)=>({
|
|
131
|
+
height: theme.spacing(3)
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
}
|
|
87
136
|
function LinkButton({ link }) {
|
|
88
137
|
const { url, name, tooltip, targetBlank } = useLink(link);
|
|
89
138
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
_export_star(require("./LinksDisplay"), 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
|
+
}
|