mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Use URL isFirstPanel to enable panel editor onboarding (#67546)
This commit is contained in:
parent
7bceab4ad4
commit
cdf8555ace
@ -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}
|
||||
|
@ -124,9 +124,7 @@ export class QueryGroup extends PureComponent<Props, State> {
|
||||
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<Props, State> {
|
||||
this.setState({ isHelpOpen: false });
|
||||
};
|
||||
|
||||
onCloseDataSourceModal = () => {
|
||||
this.setState({ isDataSourceModalOpen: false });
|
||||
locationService.partial({ firstPanel: null });
|
||||
};
|
||||
|
||||
renderMixedPicker = () => {
|
||||
return (
|
||||
<DataSourcePicker
|
||||
@ -289,15 +292,14 @@ export class QueryGroup extends PureComponent<Props, State> {
|
||||
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 && (
|
||||
<DataSourceModal {...commonProps} onDismiss={onDismiss}></DataSourceModal>
|
||||
<DataSourceModal {...commonProps} onDismiss={this.onCloseDataSourceModal}></DataSourceModal>
|
||||
)}
|
||||
<DataSourcePicker
|
||||
{...commonProps}
|
||||
|
Loading…
Reference in New Issue
Block a user