diff --git a/public/app/features/dashboard/dashgrid/DashboardEmpty.tsx b/public/app/features/dashboard/dashgrid/DashboardEmpty.tsx index 581d8f5e3fe..47c5ec2146a 100644 --- a/public/app/features/dashboard/dashgrid/DashboardEmpty.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardEmpty.tsx @@ -43,7 +43,7 @@ export const DashboardEmpty = ({ dashboard, canCreate }: Props) => { onClick={() => { const id = onCreateNewPanel(dashboard, initialDatasource); reportInteraction('dashboards_emptydashboard_clicked', { item: 'add_visualization' }); - locationService.partial({ editPanel: id }); + locationService.partial({ editPanel: id, firstPanel: true }); dispatch(setInitialDatasource(undefined)); }} disabled={!canCreate} diff --git a/public/app/features/query/components/QueryGroup.tsx b/public/app/features/query/components/QueryGroup.tsx index c3cb601104c..e9f0f653f66 100644 --- a/public/app/features/query/components/QueryGroup.tsx +++ b/public/app/features/query/components/QueryGroup.tsx @@ -124,9 +124,7 @@ export class QueryGroup extends PureComponent { defaultDataSource, // TODO: Detect the first panel added into a new dashboard better. // This is flaky in case the UID is generated differently - isDataSourceModalOpen: - locationService.getLocation().pathname === '/dashboard/new' && - locationService.getSearchObject().editPanel === '1', + isDataSourceModalOpen: !!locationService.getSearchObject().firstPanel, }); } catch (error) { console.log('failed to load data source', error); @@ -261,6 +259,11 @@ export class QueryGroup extends PureComponent { this.setState({ isHelpOpen: false }); }; + onCloseDataSourceModal = () => { + this.setState({ isDataSourceModalOpen: false }); + locationService.partial({ firstPanel: null }); + }; + renderMixedPicker = () => { return ( { current: this.props.options.dataSource, onChange: (ds: DataSourceInstanceSettings) => { this.onChangeDataSource(ds); - this.setState({ isDataSourceModalOpen: false }); + this.onCloseDataSourceModal(); }, }; - const onDismiss = () => this.setState({ isDataSourceModalOpen: false }); return ( <> {isDataSourceModalOpen && config.featureToggles.advancedDataSourcePicker && ( - + )}