From 33c5cbf4de57516c82fee5eff938dd824de7293c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 11 Dec 2025 08:54:50 +0100 Subject: [PATCH] Dashboards: Update edit button and share button (#115093) * Dashboards: Update edit button and share button * update translations --- .../edit-pane/DashboardEditPaneSplitter.tsx | 5 - .../actions/EditDashboardSwitch.tsx | 26 +++-- .../actions/ShareDashboardButton.tsx | 2 +- .../actions/ShareExportDashboardButton.tsx | 19 +-- .../new-toolbar/actions/ToolbarSwitch.tsx | 108 ------------------ public/locales/en-US/grafana.json | 14 +-- 6 files changed, 36 insertions(+), 138 deletions(-) delete mode 100644 public/app/features/dashboard-scene/scene/new-toolbar/actions/ToolbarSwitch.tsx diff --git a/public/app/features/dashboard-scene/edit-pane/DashboardEditPaneSplitter.tsx b/public/app/features/dashboard-scene/edit-pane/DashboardEditPaneSplitter.tsx index 091e4805bae..e32dbcd090d 100644 --- a/public/app/features/dashboard-scene/edit-pane/DashboardEditPaneSplitter.tsx +++ b/public/app/features/dashboard-scene/edit-pane/DashboardEditPaneSplitter.tsx @@ -191,11 +191,6 @@ function getStyles(theme: GrafanaTheme2, headerHeight: number) { // Because the edit pane splitter handle area adds padding we can reduce it here paddingRight: theme.spacing(1), }), - editPane: css({ - flexDirection: 'column', - // borderLeft: `1px solid ${theme.colors.border.weak}`, - // background: theme.colors.background.primary, - }), controlsWrapperSticky: css({ [theme.breakpoints.up('md')]: { position: 'sticky', diff --git a/public/app/features/dashboard-scene/scene/new-toolbar/actions/EditDashboardSwitch.tsx b/public/app/features/dashboard-scene/scene/new-toolbar/actions/EditDashboardSwitch.tsx index 8389e11dfe4..777c3892860 100644 --- a/public/app/features/dashboard-scene/scene/new-toolbar/actions/EditDashboardSwitch.tsx +++ b/public/app/features/dashboard-scene/scene/new-toolbar/actions/EditDashboardSwitch.tsx @@ -1,22 +1,26 @@ import { selectors } from '@grafana/e2e-selectors'; import { t } from '@grafana/i18n'; +import { Button } from '@grafana/ui'; import { DashboardInteractions } from 'app/features/dashboard-scene/utils/interactions'; import { trackDashboardSceneEditButtonClicked } from 'app/features/dashboard-scene/utils/tracking'; import { playlistSrv } from 'app/features/playlist/PlaylistSrv'; import { ToolbarActionProps } from '../types'; -import { ToolbarSwitch } from './ToolbarSwitch'; - export const EditDashboardSwitch = ({ dashboard }: ToolbarActionProps) => { + const tooltip = dashboard.state.isEditing + ? t('dashboard.toolbar.edit-button.exit-tooltip', 'Exit edit mode') + : t('dashboard.toolbar.edit-button.enter-tooltip', 'Enter edit mode'); + + if (playlistSrv.state.isPlaying) { + return null; + } + return ( - { evt.preventDefault(); evt.stopPropagation(); @@ -29,6 +33,10 @@ export const EditDashboardSwitch = ({ dashboard }: ToolbarActionProps) => { dashboard.exitEditMode({ skipConfirm: false }); } }} - /> + > + {dashboard.state.isEditing + ? t('dashboard.toolbar.edit-button.exit', 'Exit edit') + : t('dashboard.toolbar.edit-button.enter', 'Edit')} + ); }; diff --git a/public/app/features/dashboard-scene/scene/new-toolbar/actions/ShareDashboardButton.tsx b/public/app/features/dashboard-scene/scene/new-toolbar/actions/ShareDashboardButton.tsx index 66eec343ea3..2bb4aa0d7ee 100644 --- a/public/app/features/dashboard-scene/scene/new-toolbar/actions/ShareDashboardButton.tsx +++ b/public/app/features/dashboard-scene/scene/new-toolbar/actions/ShareDashboardButton.tsx @@ -34,7 +34,7 @@ export const ShareDashboardButton = ({ dashboard }: ToolbarActionProps) => { arrowLabel={t('dashboard.toolbar.new.share.arrow', 'Share')} arrowTestId={newShareButtonSelector.arrowMenu} dashboard={dashboard} - variant={!dashboard.state.isEditing ? 'primary' : 'secondary'} + variant={!dashboard.state.isEditing ? 'primary' : 'canvas'} /> ); }; diff --git a/public/app/features/dashboard-scene/scene/new-toolbar/actions/ShareExportDashboardButton.tsx b/public/app/features/dashboard-scene/scene/new-toolbar/actions/ShareExportDashboardButton.tsx index 8783cd89751..ad9d28c11a0 100644 --- a/public/app/features/dashboard-scene/scene/new-toolbar/actions/ShareExportDashboardButton.tsx +++ b/public/app/features/dashboard-scene/scene/new-toolbar/actions/ShareExportDashboardButton.tsx @@ -1,7 +1,7 @@ import { ReactElement, useState } from 'react'; import { t } from '@grafana/i18n'; -import { Button, ButtonGroup, Dropdown } from '@grafana/ui'; +import { ButtonGroup, Dropdown, ToolbarButton } from '@grafana/ui'; import { appEvents } from 'app/core/app_events'; import { ShowConfirmModalEvent } from 'app/types/events'; @@ -17,7 +17,7 @@ interface Props extends ToolbarActionProps { onButtonClick?: () => void; arrowLabel: string; arrowTestId: string; - variant?: 'primary' | 'secondary'; + variant?: 'primary' | 'canvas'; } export const ShareExportDashboardButton = ({ @@ -31,7 +31,7 @@ export const ShareExportDashboardButton = ({ onButtonClick, arrowLabel, arrowTestId, - variant = 'secondary', + variant = 'canvas', }: Props) => { const [isOpen, setIsOpen] = useState(false); @@ -60,9 +60,15 @@ export const ShareExportDashboardButton = ({ } }} > - + - - - ); -}; - -const getStyles = (theme: GrafanaTheme2) => ({ - container: css({ - border: `1px solid ${theme.components.input.borderColor}`, - padding: theme.spacing(0.5), - backgroundColor: theme.components.input.background, - borderRadius: theme.shape.radius.default, - width: theme.spacing(6.5), - height: theme.spacing(theme.components.height.md), - cursor: 'pointer', - display: 'flex', - flexDirection: 'row', - alignItems: 'center', - - [theme.transitions.handleMotion('no-preference', 'reduce')]: { - transition: 'all 0.2s ease-in-out', - }, - - '&:hover': { - borderColor: theme.components.input.borderHover, - }, - }), - containerChecked: css({ - backgroundColor: theme.colors.primary.main, - borderColor: 'transparent', - - '&:hover': { - backgroundColor: theme.colors.primary.shade, - borderColor: 'transparent', - }, - }), - containerDisabled: css({ - cursor: 'initial', - background: theme.colors.action.disabledBackground, - borderColor: theme.colors.border.weak, - }), - box: css({ - background: theme.colors.background.primary, - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - width: theme.spacing(3.5), - height: '100%', - transform: 'translateX(0)', - position: 'relative', - borderRadius: styleMixins.getInternalRadius(theme, 2), - border: `1px solid ${theme.colors.border.weak}`, - - [theme.transitions.handleMotion('no-preference', 'reduce')]: { - transition: 'all 0.2s ease-in-out', - }, - }), - boxChecked: css({ - transform: `translateX(calc(100% - 14px))`, - borderColor: 'transparent', - }), -}); diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json index 2e23a60cff9..3ced02e0c08 100644 --- a/public/locales/en-US/grafana.json +++ b/public/locales/en-US/grafana.json @@ -5463,6 +5463,12 @@ "label": "Edit", "tooltip": "Enter edit mode" }, + "edit-button": { + "enter": "Edit", + "enter-tooltip": "Enter edit mode", + "exit": "Exit edit", + "exit-tooltip": "Exit edit mode" + }, "enter-edit-mode": { "label": "Make editable", "tooltip": "This dashboard was marked as read only" @@ -5484,14 +5490,6 @@ "edit-dashboard-v2-schema": { "tooltip": "Edit dashboard v2 schema" }, - "edit-toggle": { - "enter": { - "label": "Enter edit mode" - }, - "exit": { - "label": "Exit edit mode" - } - }, "enter-edit-mode": { "label": "Make editable", "tooltip": "This dashboard was marked as read only"