Skip to content

Commit

Permalink
dropdown working
Browse files Browse the repository at this point in the history
Signed-off-by: abbyhu2000 <[email protected]>
  • Loading branch information
abbyhu2000 committed Nov 15, 2023
1 parent 8e69ed3 commit b3924db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function QueryLanguageSwitcher(props: Props) {
label: 'DQL'
},
{
label: 'Lucene',
label: 'lucene',
},
{
label: 'PPL'
Expand Down Expand Up @@ -98,14 +98,11 @@ export function QueryLanguageSwitcher(props: Props) {
</EuiButtonEmpty>
);

const handleLanguageChange = useCallback(
(selectedLanguage: any) => {
setSelectedLanguage(selectedLanguage)
console.log("selectedLanguage", selectedLanguage)
props.onSelectLanguage(selectedLanguage)
},
[setSelectedLanguage]
)
const handleLanguageChange = (newLanguage:any) => {
const queryLanguage = newLanguage[0].label === 'DQL' ? 'kuery' : newLanguage[0].label;
props.onSelectLanguage(queryLanguage)
setSelectedLanguage(newLanguage)
}

if(props.currentApp$ && useObservable(props.currentApp$, '') === "data-explorer"){
return (
Expand Down Expand Up @@ -175,7 +172,6 @@ export function QueryLanguageSwitcher(props: Props) {
checked={props.language === 'kuery'}
onChange={() => {
const newLanguage = props.language === 'lucene' ? 'kuery' : 'lucene';
//console.log("new language", newLanguage)
props.onSelectLanguage(newLanguage);
}}
data-test-subj="languageToggle"
Expand All @@ -185,7 +181,6 @@ export function QueryLanguageSwitcher(props: Props) {
</div>
</EuiPopover>
)

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export default class QueryStringInputUI extends Component<Props, State> {
this.persistedLog.add(query.query);
}

console.log("on submit query language", query.language)
this.props.onSubmit({ query: fromUser(query.query), language: query.language });
}
};
Expand Down Expand Up @@ -462,15 +463,16 @@ export default class QueryStringInputUI extends Component<Props, State> {
};

private onSelectLanguage = (language: string) => {
if(language === 'PPL'){

}
// Send telemetry info every time the user opts in or out of kuery
// As a result it is important this function only ever gets called in the
// UI component's change handler.
this.services.http.post('/api/opensearch-dashboards/dql_opt_in_stats', {
body: JSON.stringify({ opt_in: language === 'kuery' }),
});

console.log("new language", language)

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

const newQuery = { query: '', language };
Expand Down

0 comments on commit b3924db

Please sign in to comment.