From b8e68177321935d788002f6f840b9152082eb9ee Mon Sep 17 00:00:00 2001 From: David Date: Thu, 30 Aug 2018 09:05:45 +0200 Subject: [PATCH] Explore: keep query when changing datasources (#13042) - clear `edited` state for each query when a new datasource is set --- public/app/containers/Explore/Explore.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/app/containers/Explore/Explore.tsx b/public/app/containers/Explore/Explore.tsx index 92712709858..16175747a06 100644 --- a/public/app/containers/Explore/Explore.tsx +++ b/public/app/containers/Explore/Explore.tsx @@ -173,6 +173,12 @@ export class Explore extends React.Component { datasource.init(); } + // Keep queries but reset edit state + const nextQueries = this.state.queries.map(q => ({ + ...q, + edited: false, + })); + this.setState( { datasource, @@ -182,6 +188,7 @@ export class Explore extends React.Component { supportsLogs, supportsTable, datasourceLoading: false, + queries: nextQueries, }, () => datasourceError === null && this.onSubmit() );