Skip to content

Commit

Permalink
fix redirection issue
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <[email protected]>
  • Loading branch information
ps48 committed Oct 18, 2023
1 parent b782d02 commit 9a34f6d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
14 changes: 13 additions & 1 deletion public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ interface MainState {
asyncLoading: boolean;
asyncLoadingStatus: AsyncQueryLoadingStatus;
asyncJobId: string;
isAccelerationFlyoutOpened: boolean;
}

const SUCCESS_MESSAGE = 'Success';
Expand Down Expand Up @@ -246,6 +247,7 @@ export class Main extends React.Component<MainProps, MainState> {
asyncLoading: false,
asyncLoadingStatus: 'SUCCESS',
asyncJobId: '',
isAccelerationFlyoutOpened: false,
};
this.httpClient = this.props.httpClient;
this.updateSQLQueries = _.debounce(this.updateSQLQueries, 250).bind(this);
Expand Down Expand Up @@ -789,7 +791,7 @@ export class Main extends React.Component<MainProps, MainState> {
});
}

handleDataSelect = (selectedItems: []) => {
handleDataSelect = (selectedItems: EuiComboBoxOptionOption[]) => {
if (selectedItems[0].label !== 'OpenSearch' && this.state.language === 'SQL') {
this.updateSQLQueries('');
}
Expand All @@ -798,6 +800,12 @@ export class Main extends React.Component<MainProps, MainState> {
});
};

setIsAccelerationFlyoutOpened = (value: boolean) => {
this.setState({
isAccelerationFlyoutOpened: value,
});
};

render() {
let page;
let link;
Expand All @@ -819,6 +827,10 @@ export class Main extends React.Component<MainProps, MainState> {
updateSQLQueries={this.updateSQLQueries}
selectedDatasource={this.state.selectedDatasource}
asyncLoading={this.state.asyncLoading}
openAccelerationFlyout={
this.props.isAccelerationFlyoutOpen && !this.state.isAccelerationFlyoutOpened
}
setIsAccelerationFlyoutOpened={this.setIsAccelerationFlyoutOpened}
/>
);
link = 'https://opensearch.org/docs/latest/search-plugins/sql/index/';
Expand Down
17 changes: 17 additions & 0 deletions public/components/SQLPage/SQLPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ interface SQLPageProps {
sqlTranslations: ResponseDetail<TranslateResult>[];
selectedDatasource: EuiComboBoxOptionOption[];
asyncLoading: boolean;
openAccelerationFlyout: boolean;
setIsAccelerationFlyoutOpened: (value: boolean) => void;
}

interface SQLPageState {
Expand Down Expand Up @@ -80,6 +82,21 @@ export class SQLPage extends React.Component<SQLPageProps, SQLPageState> {
});
};

componentDidUpdate(prevProps: SQLPageProps) {
const { selectedDatasource, openAccelerationFlyout } = this.props;
const prevDataSource = prevProps.selectedDatasource[0].label;
const currentDataSource = selectedDatasource[0].label;

if (
currentDataSource !== prevDataSource &&
currentDataSource !== 'OpenSearch' &&
openAccelerationFlyout
) {
this.setAccelerationFlyout();
this.props.setIsAccelerationFlyoutOpened(true);
}
}

render() {
const closeModal = () => this.setIsModalVisible(false);
const showModal = () => this.setIsModalVisible(true);
Expand Down

0 comments on commit 9a34f6d

Please sign in to comment.