From 41162df09654d6a14deb4044d7f13559c8b90ffa Mon Sep 17 00:00:00 2001 From: sumukhswamy Date: Fri, 30 Aug 2024 15:56:26 -0700 Subject: [PATCH] fix for missing id in old nav Signed-off-by: sumukhswamy --- public/components/Main/main.tsx | 24 ++++++++++--------- .../selectors/source_selector.tsx | 1 + 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/public/components/Main/main.tsx b/public/components/Main/main.tsx index d64bcbcd..c5ff8d43 100644 --- a/public/components/Main/main.tsx +++ b/public/components/Main/main.tsx @@ -149,6 +149,7 @@ interface MainState { dataSourceOptions: DataSourceOption[]; mdsClusterName: string; flintDataConnections: boolean; + newNavEnabled: boolean | undefined; } const SUCCESS_MESSAGE = 'Success'; @@ -295,6 +296,7 @@ export class Main extends React.Component { selectedMDSDataConnectionId: this.props.dataSourceMDSId, mdsClusterName: '', flintDataConnections: false, + newNavEnabled: coreRefs?.chrome?.navGroup.getNavGroupEnabled() }; this.httpClient = this.props.httpClient; this.updateSQLQueries = _.debounce(this.updateSQLQueries, 250).bind(this); @@ -318,7 +320,7 @@ export class Main extends React.Component { fetchFlintDataSources = () => { fetchDataSources( this.httpClient, - this.props.dataSourceMDSId, + this.state.newNavEnabled ? this.props.dataSourceMDSId : this.state.selectedMDSDataConnectionId , this.props.urlDataSource, (dataOptions) => { if (dataOptions.length > 0) { @@ -440,7 +442,7 @@ 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: this.state.newNavEnabled? this.props.dataSourceMDSId: this.state.selectedMDSDataConnectionId }; } const responsePromise = Promise.all( queries.map((eachQuery: string) => @@ -575,7 +577,7 @@ export class Main extends React.Component { }); } }, - this.props.dataSourceMDSId, + this.state.newNavEnabled? this.props.dataSourceMDSId: this.state.selectedMDSDataConnectionId, (errorDetails: string) => { this.setState({ asyncLoading: false, @@ -604,7 +606,7 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.props.dataSourceMDSId }; + query = { dataSourceMDSId: this.state.newNavEnabled? this.props.dataSourceMDSId: this.state.selectedMDSDataConnectionId }; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'translatesql' : 'translateppl'); @@ -656,7 +658,7 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.props.dataSourceMDSId }; + query = { dataSourceMDSId: this.state.newNavEnabled? this.props.dataSourceMDSId: this.state.selectedMDSDataConnectionId}; } Promise.all( queries.map((eachQuery: string) => @@ -693,7 +695,7 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.props.dataSourceMDSId }; + query = { dataSourceMDSId: this.state.newNavEnabled? this.props.dataSourceMDSId: this.state.selectedMDSDataConnectionId}; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqlquery' : 'pplquery'); Promise.all( @@ -731,7 +733,7 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.props.dataSourceMDSId }; + query = { dataSourceMDSId: this.state.newNavEnabled? this.props.dataSourceMDSId: this.state.selectedMDSDataConnectionId }; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqlcsv' : 'pplcsv'); Promise.all( @@ -769,7 +771,7 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.props.dataSourceMDSId }; + query = { dataSourceMDSId: this.state.newNavEnabled? this.props.dataSourceMDSId: this.state.selectedMDSDataConnectionId }; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqltext' : 'ppltext'); Promise.all( @@ -952,7 +954,7 @@ export class Main extends React.Component { openAccelerationFlyout={ this.props.isAccelerationFlyoutOpen && !this.state.isAccelerationFlyoutOpened } - dataSourceMDSId={this.props.dataSourceMDSId} + dataSourceMDSId={this.state.newNavEnabled? this.props.dataSourceMDSId: this.state.selectedMDSDataConnectionId} setIsAccelerationFlyoutOpened={this.setIsAccelerationFlyoutOpened} /> ); @@ -1091,7 +1093,7 @@ export class Main extends React.Component { onSelect={this.handleDataSelect} urlDataSource={this.props.urlDataSource} asyncLoading={this.state.asyncLoading} - dataSourceMDSId={this.props.dataSourceMDSId} + dataSourceMDSId={coreRefs?.chrome?.navGroup.getNavGroupEnabled()? this.props.dataSourceMDSId : this.state.selectedMDSDataConnectionId} /> @@ -1110,7 +1112,7 @@ export class Main extends React.Component { updateSQLQueries={this.updateSQLQueries} refreshTree={this.state.refreshTree} dataSourceEnabled={this.props.dataSourceEnabled} - dataSourceMDSId={this.props.dataSourceMDSId} + dataSourceMDSId={coreRefs?.chrome?.navGroup.getNavGroupEnabled()? 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 793fcffd..5cd32fc1 100644 --- a/public/components/acceleration/selectors/source_selector.tsx +++ b/public/components/acceleration/selectors/source_selector.tsx @@ -29,6 +29,7 @@ export const AccelerationDataSourceSelector = ({ setAccelerationFormData, selectedDatasource, }: AccelerationDataSourceSelectorProps) => { + console.log(selectedDatasource) const { setToast } = useToast(); const [dataConnections, setDataConnections] = useState>>( []