Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]fix for missing id in old nav #382

Merged
merged 6 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import {
EuiSmallButton,
EuiButtonIcon,
EuiCallOut,
EuiComboBoxOptionOption,
Expand All @@ -15,6 +14,7 @@
EuiPageContentBody,
EuiPageSideBar,
EuiPanel,
EuiSmallButton,
EuiSpacer,
EuiTitle,
} from '@elastic/eui';
Expand Down Expand Up @@ -62,8 +62,8 @@

interface ResponseData {
ok: boolean;
resp: any;

Check warning on line 65 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
body: any;

Check warning on line 66 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

export interface ResponseDetail<T> {
Expand All @@ -73,11 +73,11 @@
}

export interface TranslateResult {
[key: string]: any;

Check warning on line 76 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

export interface QueryMessage {
text: any;

Check warning on line 80 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
className: string;
}

Expand All @@ -97,13 +97,13 @@
[key: string]: {
nodes: Tree;
expandedRow?: {};
selectedNodes?: { [key: string]: any };

Check warning on line 100 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
};
}

export interface DataRow {
rowId: number;
data: { [key: string]: any };

Check warning on line 106 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

interface MainProps {
Expand Down Expand Up @@ -149,10 +149,11 @@
dataSourceOptions: DataSourceOption[];
mdsClusterName: string;
flintDataConnections: boolean;
newNavEnabled: boolean | undefined;
}

const SUCCESS_MESSAGE = 'Success';
const errorQueryResponse = (queryResultResponseDetail: any) => {

Check warning on line 156 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const errorMessage =
queryResultResponseDetail.errorMessage +
', this query is not runnable. \n \n' +
Expand Down Expand Up @@ -180,7 +181,7 @@
const dataRows: DataRow[] = [];

const schema: object[] = _.get(responseObj, 'schema');
const datarows: any[][] = _.get(responseObj, 'datarows');

Check warning on line 184 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
let queryType = 'default';

for (const column of schema.values()) {
Expand All @@ -205,7 +206,7 @@
}

for (const [id, field] of datarows.entries()) {
const row: { [key: string]: any } = {};

Check warning on line 209 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
row.TABLE_NAME = field[index];
const dataRow: DataRow = {
rowId: id,
Expand All @@ -218,7 +219,7 @@
case 'describe':
case 'default':
for (const [id, field] of schema.entries()) {
let alias: any = null;

Check warning on line 222 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
try {
alias = _.get(field, 'alias');
} catch (e) {
Expand Down Expand Up @@ -295,6 +296,7 @@
selectedMDSDataConnectionId: this.props.dataSourceMDSId,
mdsClusterName: '',
flintDataConnections: false,
newNavEnabled: coreRefs?.chrome?.navGroup.getNavGroupEnabled(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem to change, is it necessary to store as a state?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the state can change if its toggeled in the settings

};
this.httpClient = this.props.httpClient;
this.updateSQLQueries = _.debounce(this.updateSQLQueries, 250).bind(this);
Expand All @@ -303,22 +305,21 @@
}

componentDidMount() {
if (!coreRefs?.chrome?.navGroup.getNavGroupEnabled()) {
if (!this.state.newNavEnabled) {
this.props.setBreadcrumbs([
{
text: 'Query Workbench',
href: '#',
},
]);
}

this.fetchFlintDataSources();
}

fetchFlintDataSources = () => {
fetchDataSources(
this.httpClient,
this.props.dataSourceMDSId,
this.state.selectedMDSDataConnectionId,
this.props.urlDataSource,
(dataOptions) => {
if (dataOptions.length > 0) {
Expand Down Expand Up @@ -440,7 +441,9 @@
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.selectedMDSDataConnectionId,
};
}
const responsePromise = Promise.all(
queries.map((eachQuery: string) =>
Expand Down Expand Up @@ -575,7 +578,7 @@
});
}
},
this.props.dataSourceMDSId,
this.state.selectedMDSDataConnectionId,
(errorDetails: string) => {
this.setState({
asyncLoading: false,
Expand Down Expand Up @@ -604,7 +607,9 @@
if (queries.length > 0) {
let query = {};
if (this.props.dataSourceEnabled) {
query = { dataSourceMDSId: this.props.dataSourceMDSId };
query = {
dataSourceMDSId: this.state.selectedMDSDataConnectionId,
};
}
const endpoint =
'/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'translatesql' : 'translateppl');
Expand Down Expand Up @@ -656,7 +661,9 @@
if (queries.length > 0) {
let query = {};
if (this.props.dataSourceEnabled) {
query = { dataSourceMDSId: this.props.dataSourceMDSId };
query = {
dataSourceMDSId: this.state.selectedMDSDataConnectionId,
};
}
Promise.all(
queries.map((eachQuery: string) =>
Expand Down Expand Up @@ -693,7 +700,9 @@
if (queries.length > 0) {
let query = {};
if (this.props.dataSourceEnabled) {
query = { dataSourceMDSId: this.props.dataSourceMDSId };
query = {
dataSourceMDSId: this.state.selectedMDSDataConnectionId,
};
}
const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqlquery' : 'pplquery');
Promise.all(
Expand Down Expand Up @@ -731,7 +740,9 @@
if (queries.length > 0) {
let query = {};
if (this.props.dataSourceEnabled) {
query = { dataSourceMDSId: this.props.dataSourceMDSId };
query = {
dataSourceMDSId: this.state.selectedMDSDataConnectionId,
};
}
const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqlcsv' : 'pplcsv');
Promise.all(
Expand Down Expand Up @@ -769,7 +780,9 @@
if (queries.length > 0) {
let query = {};
if (this.props.dataSourceEnabled) {
query = { dataSourceMDSId: this.props.dataSourceMDSId };
query = {
dataSourceMDSId: this.state.selectedMDSDataConnectionId,
};
}
const endpoint = '/api/sql_console/' + (_.isEqual(language, 'SQL') ? 'sqltext' : 'ppltext');
Promise.all(
Expand Down Expand Up @@ -952,7 +965,7 @@
openAccelerationFlyout={
this.props.isAccelerationFlyoutOpen && !this.state.isAccelerationFlyoutOpened
}
dataSourceMDSId={this.props.dataSourceMDSId}
dataSourceMDSId={this.state.selectedMDSDataConnectionId}
setIsAccelerationFlyoutOpened={this.setIsAccelerationFlyoutOpened}
/>
);
Expand Down Expand Up @@ -1091,7 +1104,7 @@
onSelect={this.handleDataSelect}
urlDataSource={this.props.urlDataSource}
asyncLoading={this.state.asyncLoading}
dataSourceMDSId={this.props.dataSourceMDSId}
dataSourceMDSId={this.state.selectedMDSDataConnectionId}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand All @@ -1110,7 +1123,7 @@
updateSQLQueries={this.updateSQLQueries}
refreshTree={this.state.refreshTree}
dataSourceEnabled={this.props.dataSourceEnabled}
dataSourceMDSId={this.props.dataSourceMDSId}
dataSourceMDSId={this.state.selectedMDSDataConnectionId}
clusterTab={this.state.cluster}
language={this.state.language}
updatePPLQueries={this.updatePPLQueries}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
* 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';
Expand Down
Loading