diff --git a/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.ts b/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.ts index 0f0e291daf9..16189017918 100644 --- a/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.ts +++ b/public/app/features/dashboard-scene/scene/DashboardSceneUrlSync.ts @@ -1,7 +1,7 @@ import { Unsubscribable } from 'rxjs'; import { AppEvents } from '@grafana/data'; -import { locationService } from '@grafana/runtime'; +import { config, locationService } from '@grafana/runtime'; import { SceneGridLayout, SceneObjectBase, @@ -16,6 +16,7 @@ import { KioskMode } from 'app/types'; import { PanelInspectDrawer } from '../inspect/PanelInspectDrawer'; import { buildPanelEditScene } from '../panel-edit/PanelEditor'; import { createDashboardEditViewFor } from '../settings/utils'; +import { ShareDrawer } from '../sharing/ShareDrawer/ShareDrawer'; import { ShareModal } from '../sharing/ShareModal'; import { findVizPanelByKey, getDashboardSceneFor, getLibraryPanel, isPanelClone } from '../utils/utils'; @@ -157,9 +158,13 @@ export class DashboardSceneUrlSync implements SceneObjectUrlSyncHandler { if (typeof values.shareView === 'string') { update.shareView = values.shareView; - update.overlay = new ShareModal({ - activeTab: values.shareView, - }); + update.overlay = config.featureToggles.newDashboardSharingComponent + ? new ShareDrawer({ + shareView: values.shareView, + }) + : new ShareModal({ + activeTab: values.shareView, + }); } else if (shareView && values.shareView === null) { update.overlay = undefined; update.shareView = undefined; diff --git a/public/app/features/dashboard-scene/scene/NavToolbarActions.tsx b/public/app/features/dashboard-scene/scene/NavToolbarActions.tsx index 4140343a9cc..07ab8bfd828 100644 --- a/public/app/features/dashboard-scene/scene/NavToolbarActions.tsx +++ b/public/app/features/dashboard-scene/scene/NavToolbarActions.tsx @@ -24,6 +24,7 @@ import { Trans, t } from 'app/core/internationalization'; import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv'; import { playlistSrv } from 'app/features/playlist/PlaylistSrv'; +import { shareDashboardType } from '../../dashboard/components/ShareModal/utils'; import { PanelEditor, buildPanelEditScene } from '../panel-edit/PanelEditor'; import ExportButton from '../sharing/ExportButton/ExportButton'; import ShareButton from '../sharing/ShareButton/ShareButton'; @@ -313,7 +314,7 @@ export function ToolbarActions({ dashboard }: Props) { fill="outline" onClick={() => { DashboardInteractions.toolbarShareClick(); - locationService.partial({ shareView: 'link' }); + locationService.partial({ shareView: shareDashboardType.link }); }} data-testid={selectors.components.NavToolbar.shareDashboard} > diff --git a/public/app/features/dashboard-scene/scene/PanelMenuBehavior.tsx b/public/app/features/dashboard-scene/scene/PanelMenuBehavior.tsx index 35ac461c992..9d3d657401b 100644 --- a/public/app/features/dashboard-scene/scene/PanelMenuBehavior.tsx +++ b/public/app/features/dashboard-scene/scene/PanelMenuBehavior.tsx @@ -22,12 +22,8 @@ import { createExtensionSubMenu } from 'app/features/plugins/extensions/utils'; import { addDataTrailPanelAction } from 'app/features/trails/Integrations/dashboardIntegration'; import { ShowConfirmModalEvent } from 'app/types/events'; -import { ShareSnapshot } from '../sharing/ShareButton/share-snapshot/ShareSnapshot'; import { ShareDrawer } from '../sharing/ShareDrawer/ShareDrawer'; -import { ShareLibraryPanelTab } from '../sharing/ShareLibraryPanelTab'; import { ShareModal } from '../sharing/ShareModal'; -import { SharePanelEmbedTab } from '../sharing/SharePanelEmbedTab'; -import { SharePanelInternally } from '../sharing/panel-share/SharePanelInternally'; import { DashboardInteractions } from '../utils/interactions'; import { getEditPanelUrl, getInspectUrl, getViewPanelUrl, tryGetExploreUrlForPanel } from '../utils/urlBuilders'; import { getDashboardSceneFor, getPanelIdForVizPanel, getQueryRunnerFor } from '../utils/utils'; @@ -91,8 +87,8 @@ export function panelMenuBehavior(menu: VizPanelMenu, isRepeat = false) { shortcut: 'p u', onClick: () => { const drawer = new ShareDrawer({ - title: t('share-panel.drawer.share-link-title', 'Link settings'), - body: new SharePanelInternally({ panelRef: panel.getRef() }), + shareView: shareDashboardType.link, + panelRef: panel.getRef(), }); dashboard.showModal(drawer); @@ -104,8 +100,8 @@ export function panelMenuBehavior(menu: VizPanelMenu, isRepeat = false) { shortcut: 'p e', onClick: () => { const drawer = new ShareDrawer({ - title: t('share-panel.drawer.share-embed-title', 'Share embed'), - body: new SharePanelEmbedTab({ panelRef: panel.getRef() }), + shareView: shareDashboardType.embed, + panelRef: panel.getRef(), }); dashboard.showModal(drawer); @@ -119,8 +115,8 @@ export function panelMenuBehavior(menu: VizPanelMenu, isRepeat = false) { shortcut: 'p s', onClick: () => { const drawer = new ShareDrawer({ - title: t('share-panel.drawer.share-snapshot-title', 'Share snapshot'), - body: new ShareSnapshot({ dashboardRef: dashboard.getRef(), panelRef: panel.getRef() }), + shareView: shareDashboardType.snapshot, + panelRef: panel.getRef(), }); dashboard.showModal(drawer); @@ -192,8 +188,8 @@ export function panelMenuBehavior(menu: VizPanelMenu, isRepeat = false) { text: t('share-panel.menu.new-library-panel-title', 'New library panel'), onClick: () => { const drawer = new ShareDrawer({ - title: t('share-panel.drawer.new-library-panel-title', 'New library panel'), - body: new ShareLibraryPanelTab({ panelRef: panel.getRef() }), + shareView: shareDashboardType.libraryPanel, + panelRef: panel.getRef(), }); dashboard.showModal(drawer); diff --git a/public/app/features/dashboard-scene/scene/keyboardShortcuts.ts b/public/app/features/dashboard-scene/scene/keyboardShortcuts.ts index 90d2baa7093..4e025631e01 100644 --- a/public/app/features/dashboard-scene/scene/keyboardShortcuts.ts +++ b/public/app/features/dashboard-scene/scene/keyboardShortcuts.ts @@ -2,15 +2,12 @@ import { SetPanelAttentionEvent } from '@grafana/data'; import { config, locationService } from '@grafana/runtime'; import { sceneGraph, VizPanel } from '@grafana/scenes'; import appEvents from 'app/core/app_events'; -import { t } from 'app/core/internationalization'; import { KeybindingSet } from 'app/core/services/KeybindingSet'; import { contextSrv } from 'app/core/services/context_srv'; -import { ShareSnapshot } from '../sharing/ShareButton/share-snapshot/ShareSnapshot'; +import { shareDashboardType } from '../../dashboard/components/ShareModal/utils'; import { ShareDrawer } from '../sharing/ShareDrawer/ShareDrawer'; import { ShareModal } from '../sharing/ShareModal'; -import { SharePanelEmbedTab } from '../sharing/SharePanelEmbedTab'; -import { SharePanelInternally } from '../sharing/panel-share/SharePanelInternally'; import { dashboardSceneGraph } from '../utils/dashboardSceneGraph'; import { getEditPanelUrl, getInspectUrl, getViewPanelUrl, tryGetExploreUrlForPanel } from '../utils/urlBuilders'; import { getPanelIdForVizPanel } from '../utils/utils'; @@ -56,8 +53,8 @@ export function setupKeyboardShortcuts(scene: DashboardScene) { key: 'p u', onTrigger: withFocusedPanel(scene, async (vizPanel: VizPanel) => { const drawer = new ShareDrawer({ - title: t('share-panel.drawer.share-link-title', 'Link settings'), - body: new SharePanelInternally({ panelRef: vizPanel.getRef() }), + shareView: shareDashboardType.link, + panelRef: vizPanel.getRef(), }); scene.showModal(drawer); @@ -67,8 +64,8 @@ export function setupKeyboardShortcuts(scene: DashboardScene) { key: 'p e', onTrigger: withFocusedPanel(scene, async (vizPanel: VizPanel) => { const drawer = new ShareDrawer({ - title: t('share-panel.drawer.share-embed-title', 'Share embed'), - body: new SharePanelEmbedTab({ panelRef: vizPanel.getRef() }), + shareView: shareDashboardType.embed, + panelRef: vizPanel.getRef(), }); scene.showModal(drawer); @@ -80,8 +77,8 @@ export function setupKeyboardShortcuts(scene: DashboardScene) { key: 'p s', onTrigger: withFocusedPanel(scene, async (vizPanel: VizPanel) => { const drawer = new ShareDrawer({ - title: t('share-panel.drawer.share-snapshot-title', 'Share snapshot'), - body: new ShareSnapshot({ dashboardRef: scene.getRef(), panelRef: vizPanel.getRef() }), + shareView: shareDashboardType.snapshot, + panelRef: vizPanel.getRef(), }); scene.showModal(drawer); diff --git a/public/app/features/dashboard-scene/sharing/ExportButton/ExportAsJson.tsx b/public/app/features/dashboard-scene/sharing/ExportButton/ExportAsJson.tsx index b0b60158096..42fd0ef7a51 100644 --- a/public/app/features/dashboard-scene/sharing/ExportButton/ExportAsJson.tsx +++ b/public/app/features/dashboard-scene/sharing/ExportButton/ExportAsJson.tsx @@ -8,20 +8,22 @@ import { SceneComponentProps } from '@grafana/scenes'; import { Button, ClipboardButton, CodeEditor, Label, Spinner, Stack, Switch, useStyles2 } from '@grafana/ui'; import { notifyApp } from 'app/core/actions'; import { createSuccessNotification } from 'app/core/copy/appNotification'; -import { Trans, t } from 'app/core/internationalization'; +import { t, Trans } from 'app/core/internationalization'; import { dispatch } from 'app/store/store'; -import { getDashboardSceneFor } from '../../utils/utils'; import { ShareExportTab } from '../ShareExportTab'; const selector = e2eSelectors.pages.ExportDashboardDrawer.ExportAsJson; export class ExportAsJson extends ShareExportTab { static Component = ExportAsJsonRenderer; + + public getTabLabel(): string { + return t('export.json.title', 'Save dashboard JSON'); + } } function ExportAsJsonRenderer({ model }: SceneComponentProps) { - const dashboard = getDashboardSceneFor(model); const styles = useStyles2(getStyles); const { isSharingExternally } = model.useState(); @@ -98,7 +100,7 @@ function ExportAsJsonRenderer({ model }: SceneComponentProps) {