Skip to content

Commit

Permalink
MDS working changed how ID passed
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Tackett <[email protected]>
  • Loading branch information
Adam Tackett committed Jul 10, 2024
1 parent 0971f57 commit 6f77d47
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
4 changes: 3 additions & 1 deletion public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<WorkbenchApp
basename={appBasePath}
Expand All @@ -28,6 +29,7 @@ export const renderApp = (
dataSourceEnabled={!!dataSource}
dataSourceManagement={dataSourceManagement}
setActionMenu={setHeaderActionMenu}
dataSourceId={dataSourceId}
/>,
element
);
Expand Down
27 changes: 14 additions & 13 deletions public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ interface MainProps {
notifications: NotificationsStart;
dataSourceEnabled: boolean;
dataSourceManagement: DataSourceManagementPluginSetup;
dataSourceId: string;
setActionMenu: (menuMount: MountPoint | undefined) => void;
}

Expand Down Expand Up @@ -286,7 +287,7 @@ export class Main extends React.Component<MainProps, MainState> {
isCallOutVisible: false,
cluster: 'Indexes',
dataSourceOptions: [],
selectedMDSDataConnectionId: '',
selectedMDSDataConnectionId: this.props.dataSourceId,
mdsClusterName: '',
flintDataConnections: false,
};
Expand All @@ -299,11 +300,11 @@ export class Main extends React.Component<MainProps, MainState> {
componentDidMount() {
this.fetchFlintDataSources();
}

fetchFlintDataSources = () => {
fetchDataSources(
this.httpClient,
this.state.selectedMDSDataConnectionId,
this.props.dataSourceId,
this.props.urlDataSource,
(dataOptions) => {
if (dataOptions.length > 0) {
Expand Down Expand Up @@ -425,7 +426,7 @@ export class Main extends React.Component<MainProps, MainState> {
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) =>
Expand Down Expand Up @@ -560,7 +561,7 @@ export class Main extends React.Component<MainProps, MainState> {
});
}
},
this.state.selectedMDSDataConnectionId,
this.props.dataSourceId,
(errorDetails: string) => {
this.setState({
asyncLoading: false,
Expand Down Expand Up @@ -589,7 +590,7 @@ export class Main extends React.Component<MainProps, MainState> {
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');
Expand Down Expand Up @@ -641,7 +642,7 @@ export class Main extends React.Component<MainProps, MainState> {
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) =>
Expand Down Expand Up @@ -678,7 +679,7 @@ export class Main extends React.Component<MainProps, MainState> {
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(
Expand Down Expand Up @@ -716,7 +717,7 @@ export class Main extends React.Component<MainProps, MainState> {
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(
Expand Down Expand Up @@ -754,7 +755,7 @@ export class Main extends React.Component<MainProps, MainState> {
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(
Expand Down Expand Up @@ -926,7 +927,7 @@ export class Main extends React.Component<MainProps, MainState> {
openAccelerationFlyout={
this.props.isAccelerationFlyoutOpen && !this.state.isAccelerationFlyoutOpened
}
dataSourceMDSId={this.state.selectedMDSDataConnectionId}
dataSourceMDSId={this.props.dataSourceId}
setIsAccelerationFlyoutOpened={this.setIsAccelerationFlyoutOpened}
/>
);
Expand Down Expand Up @@ -1064,7 +1065,7 @@ export class Main extends React.Component<MainProps, MainState> {
onSelect={this.handleDataSelect}
urlDataSource={this.props.urlDataSource}
asyncLoading={this.state.asyncLoading}
dataSourceMDSId={this.state.selectedMDSDataConnectionId}
dataSourceMDSId={this.props.dataSourceId}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand All @@ -1083,7 +1084,7 @@ export class Main extends React.Component<MainProps, MainState> {
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}
Expand Down
5 changes: 5 additions & 0 deletions public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface WorkbenchAppDeps {
savedObjects: CoreStart['savedObjects'];
dataSourceEnabled: boolean;
dataSourceManagement: DataSourceManagementPluginSetup;
dataSourceId: string;
setActionMenu: (menuMount: MountPoint | undefined) => void;
}

Expand All @@ -36,6 +37,7 @@ export const WorkbenchApp = ({
savedObjects,
dataSourceEnabled,
dataSourceManagement,
dataSourceId,
setActionMenu,
}: WorkbenchAppDeps) => {
return (
Expand All @@ -59,6 +61,7 @@ export const WorkbenchApp = ({
savedObjects={savedObjects}
dataSourceEnabled={dataSourceEnabled}
dataSourceManagement={dataSourceManagement}
dataSourceId={dataSourceId}
setActionMenu={setActionMenu}
/>
)}
Expand All @@ -77,6 +80,7 @@ export const WorkbenchApp = ({
savedObjects={savedObjects}
dataSourceEnabled={dataSourceEnabled}
dataSourceManagement={dataSourceManagement}
dataSourceId={dataSourceId}
setActionMenu={setActionMenu}
/>
)}
Expand All @@ -95,6 +99,7 @@ export const WorkbenchApp = ({
savedObjects={savedObjects}
dataSourceEnabled={dataSourceEnabled}
dataSourceManagement={dataSourceManagement}
dataSourceId={dataSourceId}
setActionMenu={setActionMenu}
/>
)}
Expand Down
2 changes: 1 addition & 1 deletion public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class WorkbenchPlugin implements Plugin<WorkbenchPluginSetup, WorkbenchPl
coreStart,
depsStart as AppPluginStartDependencies,
params,
dataSourceManagement
dataSourceManagement,
);
},
});
Expand Down

0 comments on commit 6f77d47

Please sign in to comment.