Skip to content

Commit

Permalink
add some small ui things
Browse files Browse the repository at this point in the history
Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla committed Apr 1, 2024
1 parent 93d9f91 commit 15742f1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import { QueryLanguageSwitcher } from './language_switcher';
import { PersistedLog, getQueryLog, matchPairs, toUser, fromUser } from '../../query';
import { SuggestionsListSize } from '../typeahead/suggestions_component';
import { SuggestionsComponent } from '..';
import { getUiService } from '../../services';

export interface QueryStringInputProps {
indexPatterns: Array<IIndexPattern | string>;
Expand Down Expand Up @@ -466,10 +467,16 @@ export default class QueryStringInputUI extends Component<Props, State> {
});

this.services.storage.set('opensearchDashboards.userQueryLanguage', language);

const newQuery = { query: '', language };
const queryEnhancements = getUiService().queryEnhancements;
// TODO: SQL proof you can modify search bar
// Will work on adding more to search bar of UI service
const input = queryEnhancements.get(language)?.input;
const submitOnLanguageSelect = input?.submitOnLanguageSelect ?? true;
const newQuery = { query: input?.placeholder ?? '', language };
this.onChange(newQuery);
this.onSubmit(newQuery);
if (submitOnLanguageSelect) {
this.onSubmit(newQuery);
}
};

private onOutsideClick = () => {
Expand Down Expand Up @@ -619,6 +626,12 @@ export default class QueryStringInputUI extends Component<Props, State> {
return (
<div className={className}>
{this.props.prepend}
<QueryLanguageSwitcher
language={this.props.query.language}
anchorPosition={this.props.languageSwitcherPopoverAnchorPosition}
onSelectLanguage={this.onSelectLanguage}
/>

<EuiOutsideClickDetector onOutsideClick={this.onOutsideClick}>
<div
{...ariaCombobox}
Expand Down Expand Up @@ -696,12 +709,6 @@ export default class QueryStringInputUI extends Component<Props, State> {
</EuiPortal>
</div>
</EuiOutsideClickDetector>

<QueryLanguageSwitcher
language={this.props.query.language}
anchorPosition={this.props.languageSwitcherPopoverAnchorPosition}
onSelectLanguage={this.onSelectLanguage}
/>
</div>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/data/public/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import { StatefulSearchBarProps } from './search_bar';
export interface QueryEnhancement {
language: string;
search: SearchInterceptor;
input?: {
placeholder?: string;
submitOnLanguageSelect?: boolean;
};
}

export interface UiEnhancements {
Expand Down

0 comments on commit 15742f1

Please sign in to comment.