From 0565c3440fe6553f2ef2a29a5f027fb20e8a7f68 Mon Sep 17 00:00:00 2001 From: Ivan Ortega Alba Date: Wed, 10 May 2023 18:57:10 +0200 Subject: [PATCH] DS Picker: Do not create extra history entries for panel onboarding (#68227) --- public/app/features/query/components/QueryGroup.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/public/app/features/query/components/QueryGroup.tsx b/public/app/features/query/components/QueryGroup.tsx index e9f0f653f66..c7a7c7a4ad1 100644 --- a/public/app/features/query/components/QueryGroup.tsx +++ b/public/app/features/query/components/QueryGroup.tsx @@ -65,7 +65,7 @@ export class QueryGroup extends PureComponent { querySubscription: Unsubscribable | null = null; state: State = { - isDataSourceModalOpen: false, + isDataSourceModalOpen: !!locationService.getSearchObject().firstPanel, isLoadingHelp: false, helpContent: null, isPickerOpen: false, @@ -87,6 +87,11 @@ export class QueryGroup extends PureComponent { }); this.setNewQueriesAndDatasource(options); + + // Clean up the first panel flag since the modal is now open + if (!!locationService.getSearchObject().firstPanel) { + locationService.partial({ firstPanel: null }, true); + } } componentWillUnmount() { @@ -117,14 +122,12 @@ export class QueryGroup extends PureComponent { datasource, ...q, })); + this.setState({ queries, dataSource: ds, dsSettings, defaultDataSource, - // TODO: Detect the first panel added into a new dashboard better. - // This is flaky in case the UID is generated differently - isDataSourceModalOpen: !!locationService.getSearchObject().firstPanel, }); } catch (error) { console.log('failed to load data source', error); @@ -261,7 +264,6 @@ export class QueryGroup extends PureComponent { onCloseDataSourceModal = () => { this.setState({ isDataSourceModalOpen: false }); - locationService.partial({ firstPanel: null }); }; renderMixedPicker = () => {