New Dashboard: Fix "build a dashboard" when empty dash page feature is enabled (#66816)

* New Dashboard: Fix "build a dashboard" when used with empty dash page feature

Closes #66659
This commit is contained in:
kay delaney
2023-04-27 11:11:19 +01:00
committed by GitHub
parent 7460a53ab9
commit 2dc5872bd6
6 changed files with 43 additions and 16 deletions

View File

@@ -12,6 +12,9 @@ import {
onCreateNewRow,
onPasteCopiedPanel,
} from 'app/features/dashboard/utils/dashboard';
import { useDispatch, useSelector } from 'app/types';
import { setInitialDatasource } from '../../state/reducers';
interface Props {
dashboard: DashboardModel;
@@ -19,6 +22,8 @@ interface Props {
export const AddPanelMenu = ({ dashboard }: Props) => {
const copiedPanelPlugin = useMemo(() => getCopiedPanelPlugin(), []);
const dispatch = useDispatch();
const initialDatasource = useSelector((state) => state.dashboard.initialDatasource);
return (
<Menu>
@@ -27,9 +32,10 @@ export const AddPanelMenu = ({ dashboard }: Props) => {
label={t('dashboard.add-menu.visualization', 'Visualization')}
testId={selectors.components.PageToolbar.itemButton('Add new visualization menu item')}
onClick={() => {
const id = onCreateNewPanel(dashboard, initialDatasource);
reportInteraction('dashboards_toolbar_add_clicked', { item: 'add_visualization' });
const id = onCreateNewPanel(dashboard);
locationService.partial({ editPanel: id });
dispatch(setInitialDatasource(undefined));
}}
/>
<Menu.Item