mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user