From 6f77d475e55896e77e11ae82352cadb6c19b1a1b Mon Sep 17 00:00:00 2001 From: Adam Tackett Date: Wed, 10 Jul 2024 09:29:05 -0700 Subject: [PATCH] MDS working changed how ID passed Signed-off-by: Adam Tackett --- public/application.tsx | 4 +++- public/components/Main/main.tsx | 27 ++++++++++++++------------- public/components/app.tsx | 5 +++++ public/plugin.ts | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/public/application.tsx b/public/application.tsx index 885e512..4c6d278 100644 --- a/public/application.tsx +++ b/public/application.tsx @@ -14,9 +14,10 @@ import { AppPluginStartDependencies } from './types'; export const renderApp = ( { notifications, http, chrome, savedObjects }: CoreStart, { navigation, dataSource }: AppPluginStartDependencies, - { appBasePath, element, setHeaderActionMenu }: AppMountParameters, + { appBasePath, element, setHeaderActionMenu, dataSourceId }: AppMountParameters, dataSourceManagement: DataSourceManagementPluginSetup ) => { + console.log(dataSourceId); ReactDOM.render( , element ); diff --git a/public/components/Main/main.tsx b/public/components/Main/main.tsx index 4c60483..fb392b8 100644 --- a/public/components/Main/main.tsx +++ b/public/components/Main/main.tsx @@ -110,6 +110,7 @@ interface MainProps { notifications: NotificationsStart; dataSourceEnabled: boolean; dataSourceManagement: DataSourceManagementPluginSetup; + dataSourceId: string; setActionMenu: (menuMount: MountPoint | undefined) => void; } @@ -286,7 +287,7 @@ export class Main extends React.Component { isCallOutVisible: false, cluster: 'Indexes', dataSourceOptions: [], - selectedMDSDataConnectionId: '', + selectedMDSDataConnectionId: this.props.dataSourceId, mdsClusterName: '', flintDataConnections: false, }; @@ -299,11 +300,11 @@ export class Main extends React.Component { componentDidMount() { this.fetchFlintDataSources(); } - + fetchFlintDataSources = () => { fetchDataSources( this.httpClient, - this.state.selectedMDSDataConnectionId, + this.props.dataSourceId, this.props.urlDataSource, (dataOptions) => { if (dataOptions.length > 0) { @@ -425,7 +426,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.state.selectedMDSDataConnectionId }; + query = { dataSourceMDSId: this.props.dataSourceId }; } const responsePromise = Promise.all( queries.map((eachQuery: string) => @@ -560,7 +561,7 @@ export class Main extends React.Component { }); } }, - this.state.selectedMDSDataConnectionId, + this.props.dataSourceId, (errorDetails: string) => { this.setState({ asyncLoading: false, @@ -589,7 +590,7 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.state.selectedMDSDataConnectionId }; + query = { dataSourceMDSId: this.props.dataSourceId }; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'translatesql' : 'translateppl'); @@ -641,7 +642,7 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.state.selectedMDSDataConnectionId }; + query = { dataSourceMDSId: this.props.dataSourceId }; } Promise.all( queries.map((eachQuery: string) => @@ -678,7 +679,7 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.state.selectedMDSDataConnectionId }; + query = { dataSourceMDSId: this.props.dataSourceId }; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqlquery' : 'pplquery'); Promise.all( @@ -716,7 +717,7 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.state.selectedMDSDataConnectionId }; + query = { dataSourceMDSId: this.props.dataSourceId }; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqlcsv' : 'pplcsv'); Promise.all( @@ -754,7 +755,7 @@ export class Main extends React.Component { if (queries.length > 0) { let query = {}; if (this.props.dataSourceEnabled) { - query = { dataSourceMDSId: this.state.selectedMDSDataConnectionId }; + query = { dataSourceMDSId: this.props.dataSourceId }; } const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqltext' : 'ppltext'); Promise.all( @@ -926,7 +927,7 @@ export class Main extends React.Component { openAccelerationFlyout={ this.props.isAccelerationFlyoutOpen && !this.state.isAccelerationFlyoutOpened } - dataSourceMDSId={this.state.selectedMDSDataConnectionId} + dataSourceMDSId={this.props.dataSourceId} setIsAccelerationFlyoutOpened={this.setIsAccelerationFlyoutOpened} /> ); @@ -1064,7 +1065,7 @@ export class Main extends React.Component { onSelect={this.handleDataSelect} urlDataSource={this.props.urlDataSource} asyncLoading={this.state.asyncLoading} - dataSourceMDSId={this.state.selectedMDSDataConnectionId} + dataSourceMDSId={this.props.dataSourceId} /> @@ -1083,7 +1084,7 @@ export class Main extends React.Component { updateSQLQueries={this.updateSQLQueries} refreshTree={this.state.refreshTree} dataSourceEnabled={this.props.dataSourceEnabled} - dataSourceMDSId={this.state.selectedMDSDataConnectionId} + dataSourceMDSId={this.props.dataSourceId} clusterTab={this.state.cluster} language={this.state.language} updatePPLQueries={this.updatePPLQueries} diff --git a/public/components/app.tsx b/public/components/app.tsx index 61709cc..61dafb4 100644 --- a/public/components/app.tsx +++ b/public/components/app.tsx @@ -24,6 +24,7 @@ interface WorkbenchAppDeps { savedObjects: CoreStart['savedObjects']; dataSourceEnabled: boolean; dataSourceManagement: DataSourceManagementPluginSetup; + dataSourceId: string; setActionMenu: (menuMount: MountPoint | undefined) => void; } @@ -36,6 +37,7 @@ export const WorkbenchApp = ({ savedObjects, dataSourceEnabled, dataSourceManagement, + dataSourceId, setActionMenu, }: WorkbenchAppDeps) => { return ( @@ -59,6 +61,7 @@ export const WorkbenchApp = ({ savedObjects={savedObjects} dataSourceEnabled={dataSourceEnabled} dataSourceManagement={dataSourceManagement} + dataSourceId={dataSourceId} setActionMenu={setActionMenu} /> )} @@ -77,6 +80,7 @@ export const WorkbenchApp = ({ savedObjects={savedObjects} dataSourceEnabled={dataSourceEnabled} dataSourceManagement={dataSourceManagement} + dataSourceId={dataSourceId} setActionMenu={setActionMenu} /> )} @@ -95,6 +99,7 @@ export const WorkbenchApp = ({ savedObjects={savedObjects} dataSourceEnabled={dataSourceEnabled} dataSourceManagement={dataSourceManagement} + dataSourceId={dataSourceId} setActionMenu={setActionMenu} /> )} diff --git a/public/plugin.ts b/public/plugin.ts index 8f2258f..077cca2 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -43,7 +43,7 @@ export class WorkbenchPlugin implements Plugin