import React, { useMemo } from 'react'; import { selectors } from '@grafana/e2e-selectors'; import { locationService, reportInteraction } from '@grafana/runtime'; import { Menu } from '@grafana/ui'; import { t } from 'app/core/internationalization'; import { DashboardModel } from 'app/features/dashboard/state'; import { getCopiedPanelPlugin, onAddLibraryPanel, onCreateNewPanel, onCreateNewRow, onPasteCopiedPanel, } from 'app/features/dashboard/utils/dashboard'; interface Props { dashboard: DashboardModel; } export const AddPanelMenu = ({ dashboard }: Props) => { const copiedPanelPlugin = useMemo(() => getCopiedPanelPlugin(), []); return ( { reportInteraction('dashboards_toolbar_add_clicked', { item: 'add_visualization' }); const id = onCreateNewPanel(dashboard); locationService.partial({ editPanel: id }); }} /> { reportInteraction('dashboards_toolbar_add_clicked', { item: 'add_row' }); onCreateNewRow(dashboard); }} /> { reportInteraction('dashboards_toolbar_add_clicked', { item: 'import_from_library' }); onAddLibraryPanel(dashboard); }} /> { reportInteraction('dashboards_toolbar_add_clicked', { item: 'paste_panel' }); onPasteCopiedPanel(dashboard, copiedPanelPlugin); }} disabled={!copiedPanelPlugin} /> ); };