Skip to content

Commit

Permalink
clear query and window on datasource selection
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>
  • Loading branch information
ps48 committed Oct 25, 2023
1 parent aa3712a commit 6711e9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const ACCELERATION_INDEX_NAME_INFO = `All OpenSearch acceleration indices
- All user given index names must be in lowercase letters. Index name cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \, |, ?, #, >, or < are not allowed.
`;

export const OPENSEARCH_SQL_INIT_QUERY = `SHOW tables LIKE '%';`;
export const TIMESTAMP_DATATYPE = 'timestamp';
export const FETCH_OPENSEARCH_INDICES_PATH = '/api/sql_console/sqlquery';
export const POLL_INTERVAL_MS = 2000;
Expand Down
10 changes: 7 additions & 3 deletions public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ChromeBreadcrumb, CoreStart } from '../../../../../src/core/public';
import {
ASYNC_QUERY_ENDPOINT,
ASYNC_QUERY_JOB_ENDPOINT,
OPENSEARCH_SQL_INIT_QUERY,
POLL_INTERVAL_MS,
} from '../../../common/constants';
import { AsyncQueryLoadingStatus } from '../../../common/types';
Expand Down Expand Up @@ -239,7 +240,7 @@ export class Main extends React.Component<MainProps, MainState> {
this.onChange = this.onChange.bind(this);
this.state = {
language: 'SQL',
sqlQueriesString: "SHOW tables LIKE '%';",
sqlQueriesString: OPENSEARCH_SQL_INIT_QUERY,
pplQueriesString: '',
queries: [],
queryTranslations: [],
Expand Down Expand Up @@ -816,8 +817,11 @@ export class Main extends React.Component<MainProps, MainState> {
}

handleDataSelect = (selectedItems: EuiComboBoxOptionOption[]) => {
if (selectedItems[0].label !== 'OpenSearch' && this.state.language === 'SQL') {
this.updateSQLQueries('');
this.updateSQLQueries('');
this.updatePPLQueries('');
this.onClear();
if (selectedItems[0].label === 'OpenSearch' && this.state.language === 'SQL') {
this.updateSQLQueries(OPENSEARCH_SQL_INIT_QUERY);
}
this.setState({
selectedDatasource: selectedItems,
Expand Down

0 comments on commit 6711e9d

Please sign in to comment.