Use URL isFirstPanel to enable panel editor onboarding (#67546)

pull/66918/head
Ivan Ortega Alba 2 years ago committed by GitHub
parent 7bceab4ad4
commit cdf8555ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      public/app/features/dashboard/dashgrid/DashboardEmpty.tsx
  2. 14
      public/app/features/query/components/QueryGroup.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}

@ -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…
Cancel
Save