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

Adjust nav enabled check. #383

Closed
wants to merge 4 commits into from
Closed
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
68 changes: 55 additions & 13 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 @@ -151,8 +151,10 @@
flintDataConnections: boolean;
}

const newNavEnabled = coreRefs?.chrome?.navGroup.getNavGroupEnabled();

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

Check warning on line 157 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 +182,7 @@
const dataRows: DataRow[] = [];

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

Check warning on line 185 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 +207,7 @@
}

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

Check warning on line 210 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 +220,7 @@
case 'describe':
case 'default':
for (const [id, field] of schema.entries()) {
let alias: any = null;

Check warning on line 223 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 @@ -303,7 +305,7 @@
}

componentDidMount() {
if (!coreRefs?.chrome?.navGroup.getNavGroupEnabled()) {
if (!newNavEnabled) {
this.props.setBreadcrumbs([
{
text: 'Query Workbench',
Expand All @@ -318,7 +320,9 @@
fetchFlintDataSources = () => {
fetchDataSources(
this.httpClient,
this.props.dataSourceMDSId,
newNavEnabled

Check failure on line 323 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `⏎········?·this.props.dataSourceMDSId⏎·······` with `·?·this.props.dataSourceMDSId`
? this.props.dataSourceMDSId
: this.state.selectedMDSDataConnectionId,
this.props.urlDataSource,
(dataOptions) => {
if (dataOptions.length > 0) {
Expand Down Expand Up @@ -440,7 +444,11 @@
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) =>
Expand Down Expand Up @@ -575,7 +583,9 @@
});
}
},
this.props.dataSourceMDSId,
newNavEnabled

Check failure on line 586 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `⏎············?·this.props.dataSourceMDSId⏎···········` with `·?·this.props.dataSourceMDSId`
? this.props.dataSourceMDSId
: this.state.selectedMDSDataConnectionId,
(errorDetails: string) => {
this.setState({
asyncLoading: false,
Expand Down Expand Up @@ -604,7 +614,11 @@
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');
Expand Down Expand Up @@ -656,7 +670,11 @@
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) =>
Expand Down Expand Up @@ -693,7 +711,11 @@
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(
Expand Down Expand Up @@ -731,7 +753,11 @@
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(
Expand Down Expand Up @@ -769,7 +795,11 @@
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(
Expand Down Expand Up @@ -952,7 +982,11 @@
openAccelerationFlyout={
this.props.isAccelerationFlyoutOpen && !this.state.isAccelerationFlyoutOpened
}
dataSourceMDSId={this.props.dataSourceMDSId}
dataSourceMDSId={
newNavEnabled

Check failure on line 986 in public/components/Main/main.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `⏎··············?·this.props.dataSourceMDSId⏎·············` with `·?·this.props.dataSourceMDSId`
? this.props.dataSourceMDSId
: this.state.selectedMDSDataConnectionId
}
setIsAccelerationFlyoutOpened={this.setIsAccelerationFlyoutOpened}
/>
);
Expand Down Expand Up @@ -1091,7 +1125,11 @@
onSelect={this.handleDataSelect}
urlDataSource={this.props.urlDataSource}
asyncLoading={this.state.asyncLoading}
dataSourceMDSId={this.props.dataSourceMDSId}
dataSourceMDSId={
newNavEnabled
? this.props.dataSourceMDSId
: this.state.selectedMDSDataConnectionId
}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand All @@ -1110,7 +1148,11 @@
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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading