-
Notifications
You must be signed in to change notification settings - Fork 935
Commit
Signed-off-by: abbyhu2000 <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,5 @@ export { | |
LanguageService, | ||
LanguageConfig, | ||
EditorEnhancements, | ||
QueryControl, | ||
} from './language_service'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { i18n } from '@osd/i18n'; | ||
|
||
import { EuiButtonIcon, EuiLink, EuiPopover, EuiPopoverTitle, EuiText } from '@elastic/eui'; | ||
|
||
import React from 'react'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { IDataPluginServices } from '../../../types'; | ||
import { useOpenSearchDashboards } from '../../../../../opensearch_dashboards_react/public'; | ||
|
||
export const DefaultLanguageReference = () => { | ||
const opensearchDashboards = useOpenSearchDashboards<IDataPluginServices>(); | ||
const [isLanguageReferenceOpen, setIsLanguageReferenceOpen] = React.useState(false); | ||
const osdDQLDocs = opensearchDashboards.services.docLinks?.links.opensearchDashboards.dql.base; | ||
Check warning on line 18 in src/plugins/data/public/query/query_string/language_service/default_language_reference.tsx Codecov / codecov/patchsrc/plugins/data/public/query/query_string/language_service/default_language_reference.tsx#L16-L18
|
||
const dqlFullName = ( | ||
<FormattedMessage | ||
Check warning on line 20 in src/plugins/data/public/query/query_string/language_service/default_language_reference.tsx Codecov / codecov/patchsrc/plugins/data/public/query/query_string/language_service/default_language_reference.tsx#L20
|
||
id="data.query.queryBar.dqlFullLanguageName" | ||
defaultMessage="OpenSearch Dashboards Query Language" | ||
/> | ||
); | ||
|
||
const button = ( | ||
<div> | ||
Check warning on line 27 in src/plugins/data/public/query/query_string/language_service/default_language_reference.tsx Codecov / codecov/patchsrc/plugins/data/public/query/query_string/language_service/default_language_reference.tsx#L27
|
||
<EuiButtonIcon | ||
iconType={'iInCircle'} | ||
aria-label={i18n.translate('discover.queryControls.languageReference', { | ||
defaultMessage: `Language Reference`, | ||
})} | ||
onClick={() => setIsLanguageReferenceOpen(!isLanguageReferenceOpen)} | ||
Check warning on line 33 in src/plugins/data/public/query/query_string/language_service/default_language_reference.tsx Codecov / codecov/patchsrc/plugins/data/public/query/query_string/language_service/default_language_reference.tsx#L33
|
||
/> | ||
</div> | ||
); | ||
|
||
return ( | ||
Check warning on line 38 in src/plugins/data/public/query/query_string/language_service/default_language_reference.tsx Codecov / codecov/patchsrc/plugins/data/public/query/query_string/language_service/default_language_reference.tsx#L38
|
||
<EuiPopover | ||
id="languageReferencePopover" | ||
button={button} | ||
isOpen={isLanguageReferenceOpen} | ||
closePopover={() => setIsLanguageReferenceOpen(false)} | ||
Check warning on line 43 in src/plugins/data/public/query/query_string/language_service/default_language_reference.tsx Codecov / codecov/patchsrc/plugins/data/public/query/query_string/language_service/default_language_reference.tsx#L43
|
||
panelPaddingSize="s" | ||
anchorPosition="downLeft" | ||
anchorClassName="euiFormControlLayout__append" | ||
> | ||
<EuiPopoverTitle> | ||
<FormattedMessage | ||
id="data.query.queryBar.syntaxOptionsTitle" | ||
defaultMessage="Syntax options" | ||
/> | ||
</EuiPopoverTitle> | ||
<div style={{ width: '350px' }}> | ||
<EuiText size="s"> | ||
<p> | ||
<FormattedMessage | ||
id="data.query.queryBar.syntaxOptionsDescription" | ||
defaultMessage="The {docsLink} (DQL) offers a simplified query | ||
syntax and support for scripted fields." | ||
values={{ | ||
docsLink: ( | ||
<EuiLink href={osdDQLDocs} target="_blank"> | ||
{dqlFullName} | ||
</EuiLink> | ||
), | ||
}} | ||
/> | ||
</p> | ||
</EuiText> | ||
</div> | ||
</EuiPopover> | ||
); | ||
}; | ||
|
||
export const createDefaultLanguageReference = () => { | ||
return <DefaultLanguageReference />; | ||
}; |