@perses-dev/dashboards 0.53.0 → 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 +58 -35
- package/dist/cjs/components/PanelDrawer/PanelQueriesSharedControls.js +16 -1
- 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 +59 -36
- 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.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelQueriesSharedControls.js +16 -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 +6 -4
- 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,353 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import { Button, Stack, Box, Typography, IconButton, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Collapse } from '@mui/material';
|
|
16
|
+
import AddIcon from 'mdi-material-ui/Plus';
|
|
17
|
+
import TrashIcon from 'mdi-material-ui/TrashCan';
|
|
18
|
+
import ArrowUp from 'mdi-material-ui/ArrowUp';
|
|
19
|
+
import ArrowDown from 'mdi-material-ui/ArrowDown';
|
|
20
|
+
import PencilIcon from 'mdi-material-ui/Pencil';
|
|
21
|
+
import ChevronUp from 'mdi-material-ui/ChevronUp';
|
|
22
|
+
import { useImmer } from 'use-immer';
|
|
23
|
+
import { InfoTooltip, LinkEditorForm } from '@perses-dev/components';
|
|
24
|
+
import { useDiscardChangesConfirmationDialog } from '../../context';
|
|
25
|
+
const DEFAULT_LINK = {
|
|
26
|
+
url: '',
|
|
27
|
+
name: '',
|
|
28
|
+
tooltip: '',
|
|
29
|
+
renderVariables: true,
|
|
30
|
+
targetBlank: true
|
|
31
|
+
};
|
|
32
|
+
export function DashboardLinksEditor({ links: initialLinks, onChange, onCancel }) {
|
|
33
|
+
const [links, setLinks] = useImmer(initialLinks);
|
|
34
|
+
const [expandedIndex, setExpandedIndex] = useState(null);
|
|
35
|
+
const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } = useDiscardChangesConfirmationDialog();
|
|
36
|
+
const handleCancel = ()=>{
|
|
37
|
+
if (JSON.stringify(initialLinks) !== JSON.stringify(links)) {
|
|
38
|
+
openDiscardChangesConfirmationDialog({
|
|
39
|
+
onDiscardChanges: ()=>{
|
|
40
|
+
closeDiscardChangesConfirmationDialog();
|
|
41
|
+
onCancel();
|
|
42
|
+
},
|
|
43
|
+
onCancel: closeDiscardChangesConfirmationDialog
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
onCancel();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const handleAdd = ()=>{
|
|
50
|
+
setLinks((draft)=>{
|
|
51
|
+
draft.push({
|
|
52
|
+
...DEFAULT_LINK
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
setExpandedIndex(links.length);
|
|
56
|
+
};
|
|
57
|
+
const handleRemove = (index)=>{
|
|
58
|
+
setLinks((draft)=>{
|
|
59
|
+
draft.splice(index, 1);
|
|
60
|
+
});
|
|
61
|
+
if (expandedIndex === index) {
|
|
62
|
+
setExpandedIndex(null);
|
|
63
|
+
} else if (expandedIndex !== null && expandedIndex > index) {
|
|
64
|
+
setExpandedIndex(expandedIndex - 1);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const handleMoveUp = (index)=>{
|
|
68
|
+
if (index === 0) return;
|
|
69
|
+
setLinks((draft)=>{
|
|
70
|
+
const temp = draft[index - 1];
|
|
71
|
+
if (temp && draft[index]) {
|
|
72
|
+
draft[index - 1] = draft[index];
|
|
73
|
+
draft[index] = temp;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
if (expandedIndex === index) {
|
|
77
|
+
setExpandedIndex(index - 1);
|
|
78
|
+
} else if (expandedIndex === index - 1) {
|
|
79
|
+
setExpandedIndex(index);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const handleMoveDown = (index)=>{
|
|
83
|
+
if (index >= links.length - 1) return;
|
|
84
|
+
setLinks((draft)=>{
|
|
85
|
+
const temp = draft[index + 1];
|
|
86
|
+
if (temp && draft[index]) {
|
|
87
|
+
draft[index + 1] = draft[index];
|
|
88
|
+
draft[index] = temp;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
if (expandedIndex === index) {
|
|
92
|
+
setExpandedIndex(index + 1);
|
|
93
|
+
} else if (expandedIndex === index + 1) {
|
|
94
|
+
setExpandedIndex(index);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const handleUpdateLink = (index, link)=>{
|
|
98
|
+
setLinks((draft)=>{
|
|
99
|
+
draft[index] = link;
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const isValid = links.every((link)=>link.url.trim().length > 0);
|
|
103
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
104
|
+
children: [
|
|
105
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
106
|
+
sx: {
|
|
107
|
+
display: 'flex',
|
|
108
|
+
alignItems: 'center',
|
|
109
|
+
padding: (theme)=>theme.spacing(1, 2),
|
|
110
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
111
|
+
},
|
|
112
|
+
children: [
|
|
113
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
114
|
+
variant: "h2",
|
|
115
|
+
children: "Edit Dashboard Links"
|
|
116
|
+
}),
|
|
117
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
118
|
+
direction: "row",
|
|
119
|
+
spacing: 1,
|
|
120
|
+
marginLeft: "auto",
|
|
121
|
+
children: [
|
|
122
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
123
|
+
disabled: !isValid,
|
|
124
|
+
variant: "contained",
|
|
125
|
+
onClick: ()=>onChange(links),
|
|
126
|
+
children: "Apply"
|
|
127
|
+
}),
|
|
128
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
129
|
+
color: "secondary",
|
|
130
|
+
variant: "outlined",
|
|
131
|
+
onClick: handleCancel,
|
|
132
|
+
children: "Cancel"
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
})
|
|
136
|
+
]
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
139
|
+
padding: 2,
|
|
140
|
+
sx: {
|
|
141
|
+
overflowY: 'scroll'
|
|
142
|
+
},
|
|
143
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
144
|
+
spacing: 2,
|
|
145
|
+
children: [
|
|
146
|
+
/*#__PURE__*/ _jsx(TableContainer, {
|
|
147
|
+
children: /*#__PURE__*/ _jsxs(Table, {
|
|
148
|
+
size: "small",
|
|
149
|
+
sx: {
|
|
150
|
+
tableLayout: 'fixed',
|
|
151
|
+
width: '100%'
|
|
152
|
+
},
|
|
153
|
+
"aria-label": "table of dashboard links",
|
|
154
|
+
children: [
|
|
155
|
+
/*#__PURE__*/ _jsx(TableHead, {
|
|
156
|
+
children: /*#__PURE__*/ _jsxs(TableRow, {
|
|
157
|
+
children: [
|
|
158
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
159
|
+
children: "Name"
|
|
160
|
+
}),
|
|
161
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
162
|
+
children: "URL"
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
165
|
+
width: 80,
|
|
166
|
+
children: "New Tab"
|
|
167
|
+
}),
|
|
168
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
169
|
+
align: "right",
|
|
170
|
+
width: 180,
|
|
171
|
+
children: "Actions"
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
})
|
|
175
|
+
}),
|
|
176
|
+
/*#__PURE__*/ _jsx(TableBody, {
|
|
177
|
+
children: links.map((link, index)=>/*#__PURE__*/ _jsx(LinkTableRow, {
|
|
178
|
+
link: link,
|
|
179
|
+
index: index,
|
|
180
|
+
isFirst: index === 0,
|
|
181
|
+
isLast: index === links.length - 1,
|
|
182
|
+
isExpanded: expandedIndex === index,
|
|
183
|
+
onToggleExpand: ()=>setExpandedIndex(expandedIndex === index ? null : index),
|
|
184
|
+
onUpdate: (updatedLink)=>handleUpdateLink(index, updatedLink),
|
|
185
|
+
onRemove: ()=>handleRemove(index),
|
|
186
|
+
onMoveUp: ()=>handleMoveUp(index),
|
|
187
|
+
onMoveDown: ()=>handleMoveDown(index)
|
|
188
|
+
}, index))
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
})
|
|
192
|
+
}),
|
|
193
|
+
links.length === 0 && /*#__PURE__*/ _jsx(Typography, {
|
|
194
|
+
variant: "body1",
|
|
195
|
+
color: "text.secondary",
|
|
196
|
+
fontStyle: "italic",
|
|
197
|
+
textAlign: "center",
|
|
198
|
+
py: 4,
|
|
199
|
+
children: "No links defined. Click 'Add Link' to create one."
|
|
200
|
+
}),
|
|
201
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
202
|
+
variant: "contained",
|
|
203
|
+
startIcon: /*#__PURE__*/ _jsx(AddIcon, {}),
|
|
204
|
+
onClick: handleAdd,
|
|
205
|
+
sx: {
|
|
206
|
+
alignSelf: 'flex-start'
|
|
207
|
+
},
|
|
208
|
+
children: "Add Link"
|
|
209
|
+
})
|
|
210
|
+
]
|
|
211
|
+
})
|
|
212
|
+
})
|
|
213
|
+
]
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function LinkTableRow({ link, index, isFirst, isLast, isExpanded, onToggleExpand, onUpdate, onRemove, onMoveUp, onMoveDown }) {
|
|
217
|
+
const displayName = link.name?.trim() || `Link ${index + 1}`;
|
|
218
|
+
const hasError = link.url.trim().length === 0;
|
|
219
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
220
|
+
children: [
|
|
221
|
+
/*#__PURE__*/ _jsxs(TableRow, {
|
|
222
|
+
children: [
|
|
223
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
224
|
+
component: "th",
|
|
225
|
+
scope: "row",
|
|
226
|
+
sx: {
|
|
227
|
+
fontWeight: 'bold',
|
|
228
|
+
overflow: 'hidden',
|
|
229
|
+
textOverflow: 'ellipsis'
|
|
230
|
+
},
|
|
231
|
+
children: displayName
|
|
232
|
+
}),
|
|
233
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
234
|
+
sx: {
|
|
235
|
+
overflow: 'hidden',
|
|
236
|
+
textOverflow: 'ellipsis',
|
|
237
|
+
whiteSpace: 'nowrap',
|
|
238
|
+
color: hasError ? 'error.main' : undefined
|
|
239
|
+
},
|
|
240
|
+
children: /*#__PURE__*/ _jsx(InfoTooltip, {
|
|
241
|
+
description: link.url,
|
|
242
|
+
enterDelay: 100,
|
|
243
|
+
children: link.url || '(no URL)'
|
|
244
|
+
})
|
|
245
|
+
}),
|
|
246
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
247
|
+
children: link.targetBlank ? 'Yes' : 'No'
|
|
248
|
+
}),
|
|
249
|
+
/*#__PURE__*/ _jsxs(TableCell, {
|
|
250
|
+
align: "right",
|
|
251
|
+
sx: {
|
|
252
|
+
whiteSpace: 'nowrap'
|
|
253
|
+
},
|
|
254
|
+
children: [
|
|
255
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
256
|
+
onClick: onMoveUp,
|
|
257
|
+
disabled: isFirst,
|
|
258
|
+
"aria-label": "Move link up",
|
|
259
|
+
children: /*#__PURE__*/ _jsx(ArrowUp, {})
|
|
260
|
+
}),
|
|
261
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
262
|
+
onClick: onMoveDown,
|
|
263
|
+
disabled: isLast,
|
|
264
|
+
"aria-label": "Move link down",
|
|
265
|
+
children: /*#__PURE__*/ _jsx(ArrowDown, {})
|
|
266
|
+
}),
|
|
267
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
268
|
+
onClick: onToggleExpand,
|
|
269
|
+
"aria-label": isExpanded ? 'Collapse link editor' : 'Edit link',
|
|
270
|
+
children: isExpanded ? /*#__PURE__*/ _jsx(ChevronUp, {}) : /*#__PURE__*/ _jsx(PencilIcon, {})
|
|
271
|
+
}),
|
|
272
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
273
|
+
onClick: onRemove,
|
|
274
|
+
"aria-label": "Remove link",
|
|
275
|
+
children: /*#__PURE__*/ _jsx(TrashIcon, {})
|
|
276
|
+
})
|
|
277
|
+
]
|
|
278
|
+
})
|
|
279
|
+
]
|
|
280
|
+
}),
|
|
281
|
+
/*#__PURE__*/ _jsx(TableRow, {
|
|
282
|
+
children: /*#__PURE__*/ _jsx(TableCell, {
|
|
283
|
+
colSpan: 4,
|
|
284
|
+
sx: {
|
|
285
|
+
paddingBottom: 0,
|
|
286
|
+
paddingTop: 0,
|
|
287
|
+
border: isExpanded ? undefined : 'none'
|
|
288
|
+
},
|
|
289
|
+
children: /*#__PURE__*/ _jsx(Collapse, {
|
|
290
|
+
in: isExpanded,
|
|
291
|
+
timeout: "auto",
|
|
292
|
+
unmountOnExit: true,
|
|
293
|
+
children: /*#__PURE__*/ _jsx(Box, {
|
|
294
|
+
sx: {
|
|
295
|
+
margin: 2
|
|
296
|
+
},
|
|
297
|
+
children: /*#__PURE__*/ _jsx(LinkEditorForm, {
|
|
298
|
+
mode: "modalEmbedded",
|
|
299
|
+
url: {
|
|
300
|
+
value: link.url,
|
|
301
|
+
label: 'URL',
|
|
302
|
+
error: {
|
|
303
|
+
hasError: hasError,
|
|
304
|
+
helperText: hasError ? 'URL is required' : undefined
|
|
305
|
+
},
|
|
306
|
+
placeholder: 'https://example.com/dashboard?var=$variable',
|
|
307
|
+
onChange: (url)=>onUpdate({
|
|
308
|
+
...link,
|
|
309
|
+
url
|
|
310
|
+
})
|
|
311
|
+
},
|
|
312
|
+
name: {
|
|
313
|
+
value: link.name ?? '',
|
|
314
|
+
label: 'Display Name',
|
|
315
|
+
onChange: (name)=>onUpdate({
|
|
316
|
+
...link,
|
|
317
|
+
name
|
|
318
|
+
})
|
|
319
|
+
},
|
|
320
|
+
tooltip: {
|
|
321
|
+
value: link.tooltip ?? '',
|
|
322
|
+
label: 'Tooltip',
|
|
323
|
+
onChange: (tooltip)=>onUpdate({
|
|
324
|
+
...link,
|
|
325
|
+
tooltip
|
|
326
|
+
})
|
|
327
|
+
},
|
|
328
|
+
renderVariables: {
|
|
329
|
+
value: link.renderVariables ?? true,
|
|
330
|
+
label: 'Replace variables in URL',
|
|
331
|
+
onChange: (renderVariables)=>onUpdate({
|
|
332
|
+
...link,
|
|
333
|
+
renderVariables
|
|
334
|
+
})
|
|
335
|
+
},
|
|
336
|
+
newTabOpen: {
|
|
337
|
+
value: link.targetBlank ?? true,
|
|
338
|
+
label: 'Open in new tab',
|
|
339
|
+
onChange: (targetBlank)=>onUpdate({
|
|
340
|
+
...link,
|
|
341
|
+
targetBlank
|
|
342
|
+
})
|
|
343
|
+
}
|
|
344
|
+
})
|
|
345
|
+
})
|
|
346
|
+
})
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
]
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
//# sourceMappingURL=DashboardLinksEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DashboardLinks/DashboardLinksEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState, ReactElement } from 'react';\nimport {\n Button,\n Stack,\n Box,\n Typography,\n IconButton,\n Table,\n TableBody,\n TableCell,\n TableContainer,\n TableHead,\n TableRow,\n Collapse,\n} from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\nimport ArrowUp from 'mdi-material-ui/ArrowUp';\nimport ArrowDown from 'mdi-material-ui/ArrowDown';\nimport PencilIcon from 'mdi-material-ui/Pencil';\nimport ChevronUp from 'mdi-material-ui/ChevronUp';\nimport { Link } from '@perses-dev/spec';\nimport { useImmer } from 'use-immer';\nimport { InfoTooltip, LinkEditorForm } from '@perses-dev/components';\nimport { useDiscardChangesConfirmationDialog } from '../../context';\n\nexport interface DashboardLinksEditorProps {\n links: Link[];\n onChange: (links: Link[]) => void;\n onCancel: () => void;\n}\n\nconst DEFAULT_LINK: Link = {\n url: '',\n name: '',\n tooltip: '',\n renderVariables: true,\n targetBlank: true,\n};\n\nexport function DashboardLinksEditor({\n links: initialLinks,\n onChange,\n onCancel,\n}: DashboardLinksEditorProps): ReactElement {\n const [links, setLinks] = useImmer(initialLinks);\n const [expandedIndex, setExpandedIndex] = useState<number | null>(null);\n\n const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const handleCancel = (): void => {\n if (JSON.stringify(initialLinks) !== JSON.stringify(links)) {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n closeDiscardChangesConfirmationDialog();\n onCancel();\n },\n onCancel: closeDiscardChangesConfirmationDialog,\n });\n } else {\n onCancel();\n }\n };\n\n const handleAdd = (): void => {\n setLinks((draft) => {\n draft.push({ ...DEFAULT_LINK });\n });\n setExpandedIndex(links.length);\n };\n\n const handleRemove = (index: number): void => {\n setLinks((draft) => {\n draft.splice(index, 1);\n });\n if (expandedIndex === index) {\n setExpandedIndex(null);\n } else if (expandedIndex !== null && expandedIndex > index) {\n setExpandedIndex(expandedIndex - 1);\n }\n };\n\n const handleMoveUp = (index: number): void => {\n if (index === 0) return;\n setLinks((draft) => {\n const temp = draft[index - 1];\n if (temp && draft[index]) {\n draft[index - 1] = draft[index]!;\n draft[index] = temp;\n }\n });\n if (expandedIndex === index) {\n setExpandedIndex(index - 1);\n } else if (expandedIndex === index - 1) {\n setExpandedIndex(index);\n }\n };\n\n const handleMoveDown = (index: number): void => {\n if (index >= links.length - 1) return;\n setLinks((draft) => {\n const temp = draft[index + 1];\n if (temp && draft[index]) {\n draft[index + 1] = draft[index]!;\n draft[index] = temp;\n }\n });\n if (expandedIndex === index) {\n setExpandedIndex(index + 1);\n } else if (expandedIndex === index + 1) {\n setExpandedIndex(index);\n }\n };\n\n const handleUpdateLink = (index: number, link: Link): void => {\n setLinks((draft) => {\n draft[index] = link;\n });\n };\n\n const isValid = links.every((link) => link.url.trim().length > 0);\n\n return (\n <>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">Edit Dashboard Links</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button disabled={!isValid} variant=\"contained\" onClick={() => onChange(links)}>\n Apply\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Stack spacing={2}>\n <TableContainer>\n <Table size=\"small\" sx={{ tableLayout: 'fixed', width: '100%' }} aria-label=\"table of dashboard links\">\n <TableHead>\n <TableRow>\n <TableCell>Name</TableCell>\n <TableCell>URL</TableCell>\n <TableCell width={80}>New Tab</TableCell>\n <TableCell align=\"right\" width={180}>\n Actions\n </TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {links.map((link, index) => (\n <LinkTableRow\n key={index}\n link={link}\n index={index}\n isFirst={index === 0}\n isLast={index === links.length - 1}\n isExpanded={expandedIndex === index}\n onToggleExpand={() => setExpandedIndex(expandedIndex === index ? null : index)}\n onUpdate={(updatedLink) => handleUpdateLink(index, updatedLink)}\n onRemove={() => handleRemove(index)}\n onMoveUp={() => handleMoveUp(index)}\n onMoveDown={() => handleMoveDown(index)}\n />\n ))}\n </TableBody>\n </Table>\n </TableContainer>\n {links.length === 0 && (\n <Typography variant=\"body1\" color=\"text.secondary\" fontStyle=\"italic\" textAlign=\"center\" py={4}>\n No links defined. Click 'Add Link' to create one.\n </Typography>\n )}\n <Button variant=\"contained\" startIcon={<AddIcon />} onClick={handleAdd} sx={{ alignSelf: 'flex-start' }}>\n Add Link\n </Button>\n </Stack>\n </Box>\n </>\n );\n}\n\ninterface LinkTableRowProps {\n link: Link;\n index: number;\n isFirst: boolean;\n isLast: boolean;\n isExpanded: boolean;\n onToggleExpand: () => void;\n onUpdate: (link: Link) => void;\n onRemove: () => void;\n onMoveUp: () => void;\n onMoveDown: () => void;\n}\n\nfunction LinkTableRow({\n link,\n index,\n isFirst,\n isLast,\n isExpanded,\n onToggleExpand,\n onUpdate,\n onRemove,\n onMoveUp,\n onMoveDown,\n}: LinkTableRowProps): ReactElement {\n const displayName = link.name?.trim() || `Link ${index + 1}`;\n const hasError = link.url.trim().length === 0;\n\n return (\n <>\n <TableRow>\n <TableCell component=\"th\" scope=\"row\" sx={{ fontWeight: 'bold', overflow: 'hidden', textOverflow: 'ellipsis' }}>\n {displayName}\n </TableCell>\n <TableCell\n sx={{\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: hasError ? 'error.main' : undefined,\n }}\n >\n <InfoTooltip description={link.url} enterDelay={100}>\n {link.url || '(no URL)'}\n </InfoTooltip>\n </TableCell>\n <TableCell>{link.targetBlank ? 'Yes' : 'No'}</TableCell>\n <TableCell align=\"right\" sx={{ whiteSpace: 'nowrap' }}>\n <IconButton onClick={onMoveUp} disabled={isFirst} aria-label=\"Move link up\">\n <ArrowUp />\n </IconButton>\n <IconButton onClick={onMoveDown} disabled={isLast} aria-label=\"Move link down\">\n <ArrowDown />\n </IconButton>\n <IconButton onClick={onToggleExpand} aria-label={isExpanded ? 'Collapse link editor' : 'Edit link'}>\n {isExpanded ? <ChevronUp /> : <PencilIcon />}\n </IconButton>\n <IconButton onClick={onRemove} aria-label=\"Remove link\">\n <TrashIcon />\n </IconButton>\n </TableCell>\n </TableRow>\n <TableRow>\n <TableCell colSpan={4} sx={{ paddingBottom: 0, paddingTop: 0, border: isExpanded ? undefined : 'none' }}>\n <Collapse in={isExpanded} timeout=\"auto\" unmountOnExit>\n <Box sx={{ margin: 2 }}>\n <LinkEditorForm\n mode=\"modalEmbedded\"\n url={{\n value: link.url,\n label: 'URL',\n error: { hasError: hasError, helperText: hasError ? 'URL is required' : undefined },\n placeholder: 'https://example.com/dashboard?var=$variable',\n onChange: (url) => onUpdate({ ...link, url }),\n }}\n name={{\n value: link.name ?? '',\n label: 'Display Name',\n onChange: (name) => onUpdate({ ...link, name }),\n }}\n tooltip={{\n value: link.tooltip ?? '',\n label: 'Tooltip',\n onChange: (tooltip) => onUpdate({ ...link, tooltip }),\n }}\n renderVariables={{\n value: link.renderVariables ?? true,\n label: 'Replace variables in URL',\n onChange: (renderVariables) => onUpdate({ ...link, renderVariables }),\n }}\n newTabOpen={{\n value: link.targetBlank ?? true,\n label: 'Open in new tab',\n onChange: (targetBlank) => onUpdate({ ...link, targetBlank }),\n }}\n />\n </Box>\n </Collapse>\n </TableCell>\n </TableRow>\n </>\n );\n}\n"],"names":["useState","Button","Stack","Box","Typography","IconButton","Table","TableBody","TableCell","TableContainer","TableHead","TableRow","Collapse","AddIcon","TrashIcon","ArrowUp","ArrowDown","PencilIcon","ChevronUp","useImmer","InfoTooltip","LinkEditorForm","useDiscardChangesConfirmationDialog","DEFAULT_LINK","url","name","tooltip","renderVariables","targetBlank","DashboardLinksEditor","links","initialLinks","onChange","onCancel","setLinks","expandedIndex","setExpandedIndex","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","handleCancel","JSON","stringify","onDiscardChanges","handleAdd","draft","push","length","handleRemove","index","splice","handleMoveUp","temp","handleMoveDown","handleUpdateLink","link","isValid","every","trim","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","onClick","color","overflowY","size","tableLayout","width","aria-label","align","map","LinkTableRow","isFirst","isLast","isExpanded","onToggleExpand","onUpdate","updatedLink","onRemove","onMoveUp","onMoveDown","fontStyle","textAlign","py","startIcon","alignSelf","displayName","hasError","component","scope","fontWeight","overflow","textOverflow","whiteSpace","undefined","description","enterDelay","colSpan","paddingBottom","paddingTop","border","in","timeout","unmountOnExit","margin","mode","value","label","error","helperText","placeholder","newTabOpen"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,QAAQ,QAAsB,QAAQ;AAC/C,SACEC,MAAM,EACNC,KAAK,EACLC,GAAG,EACHC,UAAU,EACVC,UAAU,EACVC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,cAAc,EACdC,SAAS,EACTC,QAAQ,EACRC,QAAQ,QACH,gBAAgB;AACvB,OAAOC,aAAa,uBAAuB;AAC3C,OAAOC,eAAe,2BAA2B;AACjD,OAAOC,aAAa,0BAA0B;AAC9C,OAAOC,eAAe,4BAA4B;AAClD,OAAOC,gBAAgB,yBAAyB;AAChD,OAAOC,eAAe,4BAA4B;AAElD,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,WAAW,EAAEC,cAAc,QAAQ,yBAAyB;AACrE,SAASC,mCAAmC,QAAQ,gBAAgB;AAQpE,MAAMC,eAAqB;IACzBC,KAAK;IACLC,MAAM;IACNC,SAAS;IACTC,iBAAiB;IACjBC,aAAa;AACf;AAEA,OAAO,SAASC,qBAAqB,EACnCC,OAAOC,YAAY,EACnB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CAAE9B;wCAAI;gCAC7C;gCACAC,MAAM;oCACJ0F,OAAO7D,KAAK7B,IAAI,IAAI;oCACpB2F,OAAO;oCACPpF,UAAU,CAACP,OAAS4D,SAAS;4CAAE,GAAG/B,IAAI;4CAAE7B;wCAAK;gCAC/C;gCACAC,SAAS;oCACPyF,OAAO7D,KAAK5B,OAAO,IAAI;oCACvB0F,OAAO;oCACPpF,UAAU,CAACN,UAAY2D,SAAS;4CAAE,GAAG/B,IAAI;4CAAE5B;wCAAQ;gCACrD;gCACAC,iBAAiB;oCACfwF,OAAO7D,KAAK3B,eAAe,IAAI;oCAC/ByF,OAAO;oCACPpF,UAAU,CAACL,kBAAoB0D,SAAS;4CAAE,GAAG/B,IAAI;4CAAE3B;wCAAgB;gCACrE;gCACA6F,YAAY;oCACVL,OAAO7D,KAAK1B,WAAW,IAAI;oCAC3BwF,OAAO;oCACPpF,UAAU,CAACJ,cAAgByD,SAAS;4CAAE,GAAG/B,IAAI;4CAAE1B;wCAAY;gCAC7D;;;;;;;;AAQhB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { ButtonProps } from '@mui/material';
|
|
3
|
+
export interface EditDashboardLinksButtonProps extends Pick<ButtonProps, 'fullWidth'> {
|
|
4
|
+
/**
|
|
5
|
+
* The variant to use to display the button.
|
|
6
|
+
*/
|
|
7
|
+
variant?: 'text' | 'outlined';
|
|
8
|
+
/**
|
|
9
|
+
* The color to use to display the button.
|
|
10
|
+
*/
|
|
11
|
+
color?: 'primary' | 'secondary';
|
|
12
|
+
/**
|
|
13
|
+
* The label used inside the button.
|
|
14
|
+
*/
|
|
15
|
+
label?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function EditDashboardLinksButton({ variant, label, color, fullWidth, }: EditDashboardLinksButtonProps): ReactElement;
|
|
18
|
+
//# sourceMappingURL=EditDashboardLinksButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditDashboardLinksButton.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardLinks/EditDashboardLinksButton.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAU,WAAW,EAAE,MAAM,eAAe,CAAC;AAQpD,MAAM,WAAW,6BAA8B,SAAQ,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IACnF;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAE9B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,wBAAwB,CAAC,EACvC,OAAgB,EAChB,KAAe,EACf,KAAiB,EACjB,SAAS,GACV,EAAE,6BAA6B,GAAG,YAAY,CA6C9C"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import { Button } from '@mui/material';
|
|
16
|
+
import PencilIcon from 'mdi-material-ui/PencilOutline';
|
|
17
|
+
import { Drawer, InfoTooltip } from '@perses-dev/components';
|
|
18
|
+
import { TOOLTIP_TEXT, editButtonStyle } from '../../constants';
|
|
19
|
+
import { useDashboardLinks, useDashboardLinksActions } from '../../context';
|
|
20
|
+
import { DashboardLinksEditor } from './DashboardLinksEditor';
|
|
21
|
+
export function EditDashboardLinksButton({ variant = 'text', label = 'Links', color = 'primary', fullWidth }) {
|
|
22
|
+
const [isLinksEditorOpen, setIsLinksEditorOpen] = useState(false);
|
|
23
|
+
const links = useDashboardLinks();
|
|
24
|
+
const { setLinks } = useDashboardLinksActions();
|
|
25
|
+
const openLinksEditor = ()=>{
|
|
26
|
+
setIsLinksEditorOpen(true);
|
|
27
|
+
};
|
|
28
|
+
const closeLinksEditor = ()=>{
|
|
29
|
+
setIsLinksEditorOpen(false);
|
|
30
|
+
};
|
|
31
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
32
|
+
children: [
|
|
33
|
+
/*#__PURE__*/ _jsx(InfoTooltip, {
|
|
34
|
+
description: TOOLTIP_TEXT.editLinks,
|
|
35
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
36
|
+
startIcon: /*#__PURE__*/ _jsx(PencilIcon, {}),
|
|
37
|
+
onClick: openLinksEditor,
|
|
38
|
+
"aria-label": TOOLTIP_TEXT.editLinks,
|
|
39
|
+
variant: variant,
|
|
40
|
+
color: color,
|
|
41
|
+
fullWidth: fullWidth,
|
|
42
|
+
sx: editButtonStyle,
|
|
43
|
+
children: label
|
|
44
|
+
})
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ _jsx(Drawer, {
|
|
47
|
+
isOpen: isLinksEditorOpen,
|
|
48
|
+
onClose: closeLinksEditor,
|
|
49
|
+
PaperProps: {
|
|
50
|
+
sx: {
|
|
51
|
+
width: '50%'
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"data-testid": "dashboard-links-editor",
|
|
55
|
+
children: /*#__PURE__*/ _jsx(DashboardLinksEditor, {
|
|
56
|
+
links: links,
|
|
57
|
+
onCancel: closeLinksEditor,
|
|
58
|
+
onChange: (updatedLinks)=>{
|
|
59
|
+
setLinks?.(updatedLinks);
|
|
60
|
+
setIsLinksEditorOpen(false);
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=EditDashboardLinksButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DashboardLinks/EditDashboardLinksButton.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useState } from 'react';\nimport { Button, ButtonProps } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport { Drawer, InfoTooltip } from '@perses-dev/components';\nimport { Link } from '@perses-dev/spec';\nimport { TOOLTIP_TEXT, editButtonStyle } from '../../constants';\nimport { useDashboardLinks, useDashboardLinksActions } from '../../context';\nimport { DashboardLinksEditor } from './DashboardLinksEditor';\n\nexport interface EditDashboardLinksButtonProps extends Pick<ButtonProps, 'fullWidth'> {\n /**\n * The variant to use to display the button.\n */\n variant?: 'text' | 'outlined';\n\n /**\n * The color to use to display the button.\n */\n color?: 'primary' | 'secondary';\n\n /**\n * The label used inside the button.\n */\n label?: string;\n}\n\nexport function EditDashboardLinksButton({\n variant = 'text',\n label = 'Links',\n color = 'primary',\n fullWidth,\n}: EditDashboardLinksButtonProps): ReactElement {\n const [isLinksEditorOpen, setIsLinksEditorOpen] = useState(false);\n const links = useDashboardLinks();\n const { setLinks } = useDashboardLinksActions();\n\n const openLinksEditor = (): void => {\n setIsLinksEditorOpen(true);\n };\n\n const closeLinksEditor = (): void => {\n setIsLinksEditorOpen(false);\n };\n\n return (\n <>\n <InfoTooltip description={TOOLTIP_TEXT.editLinks}>\n <Button\n startIcon={<PencilIcon />}\n onClick={openLinksEditor}\n aria-label={TOOLTIP_TEXT.editLinks}\n variant={variant}\n color={color}\n fullWidth={fullWidth}\n sx={editButtonStyle}\n >\n {label}\n </Button>\n </InfoTooltip>\n <Drawer\n isOpen={isLinksEditorOpen}\n onClose={closeLinksEditor}\n PaperProps={{ sx: { width: '50%' } }}\n data-testid=\"dashboard-links-editor\"\n >\n <DashboardLinksEditor\n links={links}\n onCancel={closeLinksEditor}\n onChange={(updatedLinks: Link[]) => {\n setLinks?.(updatedLinks);\n setIsLinksEditorOpen(false);\n }}\n />\n </Drawer>\n </>\n );\n}\n"],"names":["useState","Button","PencilIcon","Drawer","InfoTooltip","TOOLTIP_TEXT","editButtonStyle","useDashboardLinks","useDashboardLinksActions","DashboardLinksEditor","EditDashboardLinksButton","variant","label","color","fullWidth","isLinksEditorOpen","setIsLinksEditorOpen","links","setLinks","openLinksEditor","closeLinksEditor","description","editLinks","startIcon","onClick","aria-label","sx","isOpen","onClose","PaperProps","width","data-testid","onCancel","onChange","updatedLinks"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,MAAM,QAAqB,gBAAgB;AACpD,OAAOC,gBAAgB,gCAAgC;AACvD,SAASC,MAAM,EAAEC,WAAW,QAAQ,yBAAyB;AAE7D,SAASC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AAChE,SAASC,iBAAiB,EAAEC,wBAAwB,QAAQ,gBAAgB;AAC5E,SAASC,oBAAoB,QAAQ,yBAAyB;AAmB9D,OAAO,SAASC,yBAAyB,EACvCC,UAAU,MAAM,EAChBC,QAAQ,OAAO,EACfC,QAAQ,SAAS,EACjBC,SAAS,EACqB;IAC9B,MAAM,CAACC,mBAAmBC,qBAAqB,GAAGhB,SAAS;IAC3D,MAAMiB,QAAQV;IACd,MAAM,EAAEW,QAAQ,EAAE,GAAGV;IAErB,MAAMW,kBAAkB;QACtBH,qBAAqB;IACvB;IAEA,MAAMI,mBAAmB;QACvBJ,qBAAqB;IACvB;IAEA,qBACE;;0BACE,KAACZ;gBAAYiB,aAAahB,aAAaiB,SAAS;0BAC9C,cAAA,KAACrB;oBACCsB,yBAAW,KAACrB;oBACZsB,SAASL;oBACTM,cAAYpB,aAAaiB,SAAS;oBAClCX,SAASA;oBACTE,OAAOA;oBACPC,WAAWA;oBACXY,IAAIpB;8BAEHM;;;0BAGL,KAACT;gBACCwB,QAAQZ;gBACRa,SAASR;gBACTS,YAAY;oBAAEH,IAAI;wBAAEI,OAAO;oBAAM;gBAAE;gBACnCC,eAAY;0BAEZ,cAAA,KAACtB;oBACCQ,OAAOA;oBACPe,UAAUZ;oBACVa,UAAU,CAACC;wBACThB,WAAWgB;wBACXlB,qBAAqB;oBACvB;;;;;AAKV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardLinks/index.ts"],"names":[],"mappings":"AAaA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export * from './EditDashboardLinksButton';
|
|
14
|
+
export * from './DashboardLinksEditor';
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DashboardLinks/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './EditDashboardLinksButton';\nexport * from './DashboardLinksEditor';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,6BAA6B;AAC3C,cAAc,yBAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardShortcuts/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export { useDashboardShortcuts } from './useDashboardShortcuts';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DashboardShortcuts/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport { useDashboardShortcuts } from './useDashboardShortcuts';\nexport type { UseDashboardShortcutsOptions } from './useDashboardShortcuts';\n"],"names":["useDashboardShortcuts"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,qBAAqB,QAAQ,0BAA0B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OnSaveDashboard } from '../../context/DashboardProvider';
|
|
2
|
+
export interface UseDashboardShortcutsOptions {
|
|
3
|
+
onSave?: OnSaveDashboard;
|
|
4
|
+
onRefresh?: () => void;
|
|
5
|
+
isReadonly: boolean;
|
|
6
|
+
onEditButtonClick?: () => void;
|
|
7
|
+
onCancelButtonClick?: () => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Registers dashboard, time-range, and panel keyboard shortcuts. Requires DashboardProvider context. */
|
|
11
|
+
export declare function useDashboardShortcuts({ onSave, onRefresh, isReadonly, onEditButtonClick, onCancelButtonClick, disabled, }: UseDashboardShortcutsOptions): void;
|
|
12
|
+
//# sourceMappingURL=useDashboardShortcuts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDashboardShortcuts.d.ts","sourceRoot":"","sources":["../../../src/components/DashboardShortcuts/useDashboardShortcuts.ts"],"names":[],"mappings":"AAuCA,OAAO,EACL,eAAe,EAMhB,MAAM,iCAAiC,CAAC;AAmDzC,MAAM,WAAW,4BAA4B;IAC3C,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,yGAAyG;AACzG,wBAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,QAAgB,GACjB,EAAE,4BAA4B,GAAG,IAAI,CA4OrC"}
|