mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Scenes: Add reporting tab in share modal (#85086)
This commit is contained in:
parent
5e48804364
commit
bb5c5f38db
@ -3,14 +3,13 @@ import React from 'react';
|
||||
import { useAsync } from 'react-use';
|
||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
||||
|
||||
import { SceneComponentProps, SceneObjectBase, SceneObjectRef } from '@grafana/scenes';
|
||||
import { SceneComponentProps, SceneObjectBase } from '@grafana/scenes';
|
||||
import { Button, ClipboardButton, CodeEditor, Field, Modal, Switch, VerticalGroup } from '@grafana/ui';
|
||||
import { t, Trans } from 'app/core/internationalization';
|
||||
import { DashboardExporter } from 'app/features/dashboard/components/DashExportModal';
|
||||
import { shareDashboardType } from 'app/features/dashboard/components/ShareModal/utils';
|
||||
import { DashboardModel } from 'app/features/dashboard/state';
|
||||
|
||||
import { DashboardScene } from '../scene/DashboardScene';
|
||||
import { transformSceneToSaveModel } from '../serialization/transformSceneToSaveModel';
|
||||
import { DashboardInteractions } from '../utils/interactions';
|
||||
|
||||
@ -19,7 +18,6 @@ import { SceneShareTabState } from './types';
|
||||
const exportExternallyTranslation = t('share-modal.export.share-externally-label', `Export for sharing externally`);
|
||||
|
||||
interface ShareExportTabState extends SceneShareTabState {
|
||||
dashboardRef: SceneObjectRef<DashboardScene>;
|
||||
isSharingExternally?: boolean;
|
||||
isViewingJSON?: boolean;
|
||||
}
|
||||
|
@ -7,14 +7,12 @@ import { shareDashboardType } from 'app/features/dashboard/components/ShareModal
|
||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
||||
|
||||
import { DashboardGridItem } from '../scene/DashboardGridItem';
|
||||
import { DashboardScene } from '../scene/DashboardScene';
|
||||
import { gridItemToPanel, transformSceneToSaveModel } from '../serialization/transformSceneToSaveModel';
|
||||
|
||||
import { SceneShareTabState } from './types';
|
||||
|
||||
export interface ShareLibraryPanelTabState extends SceneShareTabState {
|
||||
panelRef?: SceneObjectRef<VizPanel>;
|
||||
dashboardRef: SceneObjectRef<DashboardScene>;
|
||||
}
|
||||
|
||||
export class ShareLibraryPanelTab extends SceneObjectBase<ShareLibraryPanelTabState> {
|
||||
|
@ -11,14 +11,12 @@ import { createShortLink } from 'app/core/utils/shortLinks';
|
||||
import { ThemePicker } from 'app/features/dashboard/components/ShareModal/ThemePicker';
|
||||
import { shareDashboardType } from 'app/features/dashboard/components/ShareModal/utils';
|
||||
|
||||
import { DashboardScene } from '../scene/DashboardScene';
|
||||
import { DashboardInteractions } from '../utils/interactions';
|
||||
import { getDashboardUrl } from '../utils/urlBuilders';
|
||||
|
||||
import { SceneShareTabState } from './types';
|
||||
export interface ShareLinkTabState extends SceneShareTabState, ShareOptions {
|
||||
panelRef?: SceneObjectRef<VizPanel>;
|
||||
dashboardRef: SceneObjectRef<DashboardScene>;
|
||||
}
|
||||
|
||||
interface ShareOptions {
|
||||
|
@ -18,7 +18,7 @@ import { ShareLinkTab } from './ShareLinkTab';
|
||||
import { SharePanelEmbedTab } from './SharePanelEmbedTab';
|
||||
import { ShareSnapshotTab } from './ShareSnapshotTab';
|
||||
import { SharePublicDashboardTab } from './public-dashboards/SharePublicDashboardTab';
|
||||
import { ModalSceneObjectLike, SceneShareTab } from './types';
|
||||
import { ModalSceneObjectLike, SceneShareTab, SceneShareTabState } from './types';
|
||||
|
||||
interface ShareModalState extends SceneObjectState {
|
||||
dashboardRef: SceneObjectRef<DashboardScene>;
|
||||
@ -27,6 +27,13 @@ interface ShareModalState extends SceneObjectState {
|
||||
activeTab: string;
|
||||
}
|
||||
|
||||
type customDashboardTabType = new (...args: SceneShareTabState[]) => SceneShareTab;
|
||||
const customDashboardTabs: customDashboardTabType[] = [];
|
||||
|
||||
export function addDashboardShareTab(tab: customDashboardTabType) {
|
||||
customDashboardTabs.push(tab);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for full dashboard share modal and the panel level share modal
|
||||
*/
|
||||
@ -67,6 +74,10 @@ export class ShareModal extends SceneObjectBase<ShareModalState> implements Moda
|
||||
}
|
||||
}
|
||||
|
||||
if (!panelRef) {
|
||||
tabs.push(...customDashboardTabs.map((Tab) => new Tab({ dashboardRef })));
|
||||
}
|
||||
|
||||
if (isPublicDashboardsEnabled()) {
|
||||
tabs.push(new SharePublicDashboardTab({ dashboardRef, modalRef: this.getRef() }));
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import { SceneShareTabState } from './types';
|
||||
|
||||
export interface SharePanelEmbedTabState extends SceneShareTabState {
|
||||
panelRef: SceneObjectRef<VizPanel>;
|
||||
dashboardRef: SceneObjectRef<DashboardScene>;
|
||||
}
|
||||
|
||||
export class SharePanelEmbedTab extends SceneObjectBase<SharePanelEmbedTabState> {
|
||||
|
@ -9,7 +9,6 @@ import { t, Trans } from 'app/core/internationalization';
|
||||
import { shareDashboardType } from 'app/features/dashboard/components/ShareModal/utils';
|
||||
import { getDashboardSnapshotSrv, SnapshotSharingOptions } from 'app/features/dashboard/services/SnapshotSrv';
|
||||
|
||||
import { DashboardScene } from '../scene/DashboardScene';
|
||||
import { transformSceneToSaveModel, trimDashboardForSnapshot } from '../serialization/transformSceneToSaveModel';
|
||||
import { DashboardInteractions } from '../utils/interactions';
|
||||
|
||||
@ -44,7 +43,6 @@ const getDefaultExpireOption = () => {
|
||||
|
||||
export interface ShareSnapshotTabState extends SceneShareTabState {
|
||||
panelRef?: SceneObjectRef<VizPanel>;
|
||||
dashboardRef: SceneObjectRef<DashboardScene>;
|
||||
snapshotName?: string;
|
||||
selectedExpireOption?: SelectableValue<number>;
|
||||
|
||||
|
@ -1,23 +1,18 @@
|
||||
import React from 'react';
|
||||
|
||||
import { SceneComponentProps, SceneObjectBase, SceneObjectRef } from '@grafana/scenes';
|
||||
import { SceneComponentProps, SceneObjectBase } from '@grafana/scenes';
|
||||
import { t } from 'app/core/internationalization';
|
||||
import { useGetPublicDashboardQuery } from 'app/features/dashboard/api/publicDashboardApi';
|
||||
import { Loader } from 'app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboard';
|
||||
import { publicDashboardPersisted } from 'app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboardUtils';
|
||||
import { shareDashboardType } from 'app/features/dashboard/components/ShareModal/utils';
|
||||
|
||||
import { DashboardScene } from '../../scene/DashboardScene';
|
||||
import { SceneShareTabState } from '../types';
|
||||
|
||||
import { ConfigPublicDashboard } from './ConfigPublicDashboard';
|
||||
import { CreatePublicDashboard } from './CreatePublicDashboard';
|
||||
|
||||
export interface SharePublicDashboardTabState extends SceneShareTabState {
|
||||
dashboardRef: SceneObjectRef<DashboardScene>;
|
||||
}
|
||||
|
||||
export class SharePublicDashboardTab extends SceneObjectBase<SharePublicDashboardTabState> {
|
||||
export class SharePublicDashboardTab extends SceneObjectBase<SceneShareTabState> {
|
||||
public tabId = shareDashboardType.publicDashboard;
|
||||
static Component = SharePublicDashboardTabRenderer;
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
import { SceneObject, SceneObjectRef, SceneObjectState } from '@grafana/scenes';
|
||||
|
||||
import { DashboardScene } from '../scene/DashboardScene';
|
||||
|
||||
export interface ModalSceneObjectLike {
|
||||
onDismiss: () => void;
|
||||
}
|
||||
|
||||
export interface SceneShareTabState extends SceneObjectState {
|
||||
dashboardRef: SceneObjectRef<DashboardScene>;
|
||||
modalRef?: SceneObjectRef<ModalSceneObjectLike>;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user