diff --git a/public/components/Main/main.tsx b/public/components/Main/main.tsx index 6f7f2ed..37711bf 100644 --- a/public/components/Main/main.tsx +++ b/public/components/Main/main.tsx @@ -4,7 +4,6 @@ */ import { - EuiSmallButton, EuiButtonIcon, EuiCallOut, EuiComboBoxOptionOption, @@ -15,6 +14,7 @@ import { EuiPageContentBody, EuiPageSideBar, EuiPanel, + EuiSmallButton, EuiSpacer, EuiTitle, } from '@elastic/eui'; @@ -151,6 +151,8 @@ interface MainState { flintDataConnections: boolean; } +const newNavEnabled = coreRefs?.chrome?.navGroup.getNavGroupEnabled(); + const SUCCESS_MESSAGE = 'Success'; const errorQueryResponse = (queryResultResponseDetail: any) => { const errorMessage = @@ -303,7 +305,7 @@ export class Main extends React.Component { } componentDidMount() { - if (!coreRefs?.chrome?.navGroup.getNavGroupEnabled()) { + if (!newNavEnabled) { this.props.setBreadcrumbs([ { text: 'Query Workbench', @@ -318,7 +320,9 @@ export class Main extends React.Component { fetchFlintDataSources = () => { fetchDataSources( this.httpClient, - this.props.dataSourceMDSId, + newNavEnabled + ? this.props.dataSourceMDSId + : this.state.selectedMDSDataConnectionId, this.props.urlDataSource, (dataOptions) => { if (dataOptions.length > 0) { @@ -440,7 +444,11 @@ export class Main extends React.Component { const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqlquery' : 'pplquery'); let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.props.dataSourceMDSId }; + query = { + dataSourceMDSId: newNavEnabled + ? this.props.dataSourceMDSId + : this.state.selectedMDSDataConnectionId, + }; } const responsePromise = Promise.all( queries.map((eachQuery: string) => @@ -575,7 +583,9 @@ export class Main extends React.Component { }); } }, - this.props.dataSourceMDSId, + newNavEnabled + ? this.props.dataSourceMDSId + : this.state.selectedMDSDataConnectionId, (errorDetails: string) => { this.setState({ asyncLoading: false, @@ -604,7 +614,11 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.props.dataSourceMDSId }; + query = { + dataSourceMDSId: newNavEnabled + ? this.props.dataSourceMDSId + : this.state.selectedMDSDataConnectionId, + }; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'translatesql' : 'translateppl'); @@ -656,7 +670,11 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.props.dataSourceMDSId }; + query = { + dataSourceMDSId: newNavEnabled + ? this.props.dataSourceMDSId + : this.state.selectedMDSDataConnectionId, + }; } Promise.all( queries.map((eachQuery: string) => @@ -693,7 +711,11 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.props.dataSourceMDSId }; + query = { + dataSourceMDSId: newNavEnabled + ? this.props.dataSourceMDSId + : this.state.selectedMDSDataConnectionId, + }; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqlquery' : 'pplquery'); Promise.all( @@ -731,7 +753,11 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.props.dataSourceMDSId }; + query = { + dataSourceMDSId: newNavEnabled + ? this.props.dataSourceMDSId + : this.state.selectedMDSDataConnectionId, + }; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqlcsv' : 'pplcsv'); Promise.all( @@ -769,7 +795,11 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.props.dataSourceMDSId }; + query = { + dataSourceMDSId: newNavEnabled + ? this.props.dataSourceMDSId + : this.state.selectedMDSDataConnectionId, + }; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqltext' : 'ppltext'); Promise.all( @@ -952,7 +982,11 @@ export class Main extends React.Component { openAccelerationFlyout={ this.props.isAccelerationFlyoutOpen && !this.state.isAccelerationFlyoutOpened } - dataSourceMDSId={this.props.dataSourceMDSId} + dataSourceMDSId={ + newNavEnabled + ? this.props.dataSourceMDSId + : this.state.selectedMDSDataConnectionId + } setIsAccelerationFlyoutOpened={this.setIsAccelerationFlyoutOpened} /> ); @@ -1091,7 +1125,11 @@ export class Main extends React.Component { onSelect={this.handleDataSelect} urlDataSource={this.props.urlDataSource} asyncLoading={this.state.asyncLoading} - dataSourceMDSId={this.props.dataSourceMDSId} + dataSourceMDSId={ + newNavEnabled + ? this.props.dataSourceMDSId + : this.state.selectedMDSDataConnectionId + } /> @@ -1110,7 +1148,11 @@ export class Main extends React.Component { updateSQLQueries={this.updateSQLQueries} refreshTree={this.state.refreshTree} dataSourceEnabled={this.props.dataSourceEnabled} - dataSourceMDSId={this.props.dataSourceMDSId} + dataSourceMDSId={ + newNavEnabled + ? this.props.dataSourceMDSId + : this.state.selectedMDSDataConnectionId + } clusterTab={this.state.cluster} language={this.state.language} updatePPLQueries={this.updatePPLQueries} diff --git a/public/components/acceleration/selectors/source_selector.tsx b/public/components/acceleration/selectors/source_selector.tsx index 1f73419..6e13245 100644 --- a/public/components/acceleration/selectors/source_selector.tsx +++ b/public/components/acceleration/selectors/source_selector.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { EuiCompressedComboBox, EuiComboBoxOptionOption, EuiCompressedFormRow, EuiSpacer, EuiText } from '@elastic/eui'; +import { EuiComboBoxOptionOption, EuiCompressedComboBox, EuiCompressedFormRow, EuiSpacer, EuiText } from '@elastic/eui'; import producer from 'immer'; import React, { useEffect, useState } from 'react'; import { CoreStart } from '../../../../../../src/core/public';