Skip to content

Commit 5bf8243

Browse files
committed
rebase and address comments
Signed-off-by: abbyhu2000 <[email protected]>
1 parent d8d2e5c commit 5bf8243

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TODO: removed the following CSS
2+
// when https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5628 is completed
13
.languageSwitcher {
24
max-width: 150px;
35
}

src/plugins/data/public/ui/query_string_input/language_switcher.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ export function QueryLanguageSwitcher(props: Props) {
7878
{
7979
label: 'PPL',
8080
},
81+
{
82+
label: 'SQL',
83+
},
8184
];
82-
const [selectedLanguage, setSelectedLanguage] = useState([dataExplorerOptions[0]]);
8385

8486
const osdDQLDocs = useOpenSearchDashboards().services.docLinks?.links.opensearchDashboards.dql
8587
.base;
@@ -109,20 +111,26 @@ export function QueryLanguageSwitcher(props: Props) {
109111
);
110112

111113
const handleLanguageChange = (newLanguage: EuiComboBoxOptionOption[]) => {
114+
if (['PPL', 'SQL'].includes(newLanguage[0].label)) {
115+
application?.navigateToUrl('../observability-logs#/explorer');
116+
return;
117+
}
112118
const queryLanguage = newLanguage[0].label === 'DQL' ? 'kuery' : newLanguage[0].label;
113119
props.onSelectLanguage(queryLanguage);
114-
setSelectedLanguage(newLanguage);
115120
};
116121

117122
// The following is a temporary solution for adding PPL navigation, and should be replaced once final solution is determined.
118123
// Follow-up issue: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/5628
119124
if (useObservable(currentApp$!, '') === 'data-explorer' && useNewQuerySelector) {
125+
const selectedLanguage = {
126+
label: props.language === 'kuery' ? 'DQL' : props.language,
127+
};
120128
return (
121129
<EuiComboBox
122130
className="languageSwitcher"
123131
data-test-subj="languageSelect"
124132
options={dataExplorerOptions}
125-
selectedOptions={selectedLanguage}
133+
selectedOptions={[selectedLanguage]}
126134
onChange={handleLanguageChange}
127135
singleSelection={{ asPlainText: true }}
128136
isClearable={false}

src/plugins/data/public/ui/query_string_input/query_string_input.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ interface State {
9393
selectionEnd: number | null;
9494
indexPatterns: IIndexPattern[];
9595
queryBarRect: DOMRect | undefined;
96-
currentApp: string | undefined;
9796
}
9897

9998
const KEY_CODES = {
@@ -120,7 +119,6 @@ export default class QueryStringInputUI extends Component<Props, State> {
120119
selectionEnd: null,
121120
indexPatterns: [],
122121
queryBarRect: undefined,
123-
currentApp: undefined,
124122
};
125123

126124
public inputRef: HTMLTextAreaElement | null = null;
@@ -459,10 +457,6 @@ export default class QueryStringInputUI extends Component<Props, State> {
459457
};
460458

461459
private onSelectLanguage = (language: string) => {
462-
if (language === 'PPL') {
463-
this.services.application?.navigateToUrl('../observability-logs#/explorer');
464-
return;
465-
}
466460
// Send telemetry info every time the user opts in or out of kuery
467461
// As a result it is important this function only ever gets called in the
468462
// UI component's change handler.

0 commit comments

Comments
 (0)