From 6138f96396e75ace3be1403417607ae7d4ec5d23 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 11 May 2023 14:14:14 +0100 Subject: [PATCH] [v10.0.x] DS Picker: Do not create extra history entries for panel onboarding (#68284) DS Picker: Do not create extra history entries for panel onboarding (#68227) (cherry picked from commit 0565c3440fe6553f2ef2a29a5f027fb20e8a7f68) Co-authored-by: Ivan Ortega Alba --- 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 = () => {