diff --git a/ui/src/data_explorer/containers/DataExplorer.tsx b/ui/src/data_explorer/containers/DataExplorer.tsx index 425c674bd..9e6c91283 100644 --- a/ui/src/data_explorer/containers/DataExplorer.tsx +++ b/ui/src/data_explorer/containers/DataExplorer.tsx @@ -134,6 +134,7 @@ interface State { isWriteFormVisible: boolean isSendToDashboardVisible: boolean isStaticLegend: boolean + isComponentMounted: boolean } @ErrorHandling @@ -145,6 +146,7 @@ export class DataExplorer extends PureComponent { isWriteFormVisible: false, isSendToDashboardVisible: false, isStaticLegend: false, + isComponentMounted: false, } } @@ -157,10 +159,13 @@ export class DataExplorer extends PureComponent { handleGetDashboards, } = this.props const {query, script} = this.queryString + const isFlux = !!script - GlobalAutoRefresher.poll(autoRefresh) + await this.fetchFluxServices() - if (script || _.isEmpty(query)) { + if (isFlux) { + this.createNewQueryDraft() + } else if (_.isEmpty(query)) { let drafts = [] if (!_.isEmpty(queryDrafts)) { drafts = queryDrafts @@ -179,7 +184,9 @@ export class DataExplorer extends PureComponent { } await handleGetDashboards() - await this.fetchFluxServices() + + GlobalAutoRefresher.poll(autoRefresh) + this.setState({isComponentMounted: true}) } public componentDidUpdate(prevProps: Props) { @@ -213,7 +220,11 @@ export class DataExplorer extends PureComponent { notify, updateSourceLink, } = this.props - const {isStaticLegend} = this.state + const {isStaticLegend, isComponentMounted} = this.state + + if (!isComponentMounted) { + return

+ } return ( <> diff --git a/ui/src/shared/components/TimeMachine/TimeMachine.tsx b/ui/src/shared/components/TimeMachine/TimeMachine.tsx index ab2b0e837..ebf12b8ea 100644 --- a/ui/src/shared/components/TimeMachine/TimeMachine.tsx +++ b/ui/src/shared/components/TimeMachine/TimeMachine.tsx @@ -639,7 +639,10 @@ class TimeMachine extends PureComponent { } } - private updateQueryDraftsSource(selectedSource: Source, type: string) { + private updateQueryDraftsSource( + selectedSource: Source | Service, + type: string + ) { const {queryDrafts, updateQueryDrafts} = this.props const queries: CellQuery[] = queryDrafts.map(q => { @@ -650,7 +653,7 @@ class TimeMachine extends PureComponent { source: getDeep(selectedSource, 'links.self', ''), type, } - }) + }) as CellQuery[] updateQueryDrafts(queries, this.stateToUpdate) } @@ -665,8 +668,11 @@ class TimeMachine extends PureComponent { updateSourceLink(getDeep(selectedService, 'links.self', '')) } - const type = selectedService ? QueryType.Flux : QueryType.InfluxQL - this.updateQueryDraftsSource(selectedSource, type) + if (selectedService) { + this.updateQueryDraftsSource(selectedService, QueryType.Flux) + } else { + this.updateQueryDraftsSource(selectedSource, QueryType.InfluxQL) + } this.setState({selectedService, selectedSource}) }