Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES|QL] Enhances the inline documentation experience #192156

Merged
merged 43 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6e46314
Push flyout implementation
stratoula Sep 2, 2024
de146d8
Merge branch 'main' into esql-docs-flyout
stratoula Sep 4, 2024
3816c7b
Separate flyout content
stratoula Sep 4, 2024
d8884d8
Improve flyout width
stratoula Sep 5, 2024
f29fdb9
Flyout search and navigation
stratoula Sep 5, 2024
558dc9c
Small fixes
stratoula Sep 5, 2024
06250da
Inline documentation component
stratoula Sep 6, 2024
a2d31da
Merge with main and resolve conflicts
stratoula Sep 9, 2024
edb0a1c
Add flyout to the help menu
stratoula Sep 9, 2024
612d5f4
Fix wrong function removal
stratoula Sep 9, 2024
12524d5
Adds unit tests
stratoula Sep 9, 2024
31c560f
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Sep 9, 2024
d726cf7
Merge branch 'main' into esql-docs-flyout
stratoula Sep 10, 2024
aeb74f4
Cleanup
stratoula Sep 10, 2024
1f74945
Remove docs from editor when in not inline
stratoula Sep 10, 2024
317049f
Cloeanup
stratoula Sep 10, 2024
6a605ea
Move ESQL docs to the documentation package
stratoula Sep 10, 2024
3cf6fb4
i18n fix
stratoula Sep 10, 2024
cf5fa03
Merge branch 'main' into esql-docs-flyout
stratoula Sep 10, 2024
5e98010
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Sep 10, 2024
d9ed853
Fix paths
stratoula Sep 10, 2024
93f4e4d
Cleanup
stratoula Sep 10, 2024
6f7bb8a
Fix i18n check
stratoula Sep 10, 2024
ef10eb7
More i18n fixes
stratoula Sep 10, 2024
deac8a7
Cleanup unused translations
stratoula Sep 10, 2024
5c2d4cf
Merge with main and resolve conflicts
stratoula Sep 10, 2024
24ed1ab
Merge branch 'main' into esql-docs-flyout
stratoula Sep 11, 2024
bbd8615
Merge with main and resolve conflicts
stratoula Sep 12, 2024
3fa6639
Fix the wrong key
stratoula Sep 12, 2024
4ab9e09
Cleanup translations
stratoula Sep 12, 2024
6bff966
Fix the broken script
stratoula Sep 13, 2024
d8f69a0
Merge branch 'main' into esql-docs-flyout
stratoula Sep 16, 2024
a056700
Give a better layout in the ESQL alert layout
stratoula Sep 16, 2024
4d099f2
Revert the docs button from the footer
stratoula Sep 16, 2024
3b1998c
Change layout of flyout header
ryankeairns Sep 16, 2024
ad2a53b
Add search back
ryankeairns Sep 16, 2024
e426631
Merge pull request #34 from ryankeairns/esql-docs-flyout
stratoula Sep 17, 2024
46005df
Fixes in the merged PR
stratoula Sep 17, 2024
86c81d3
Close the popover when a child is clio
stratoula Sep 17, 2024
aaa8a39
Merge branch 'main' into esql-docs-flyout
stratoula Sep 18, 2024
fe970f4
fix docs generation script
drewdaemon Sep 18, 2024
aa0c6ab
Merge branch 'main' into esql-docs-flyout
elasticmachine Sep 18, 2024
937c5e4
Merge branch 'main' into esql-docs-flyout
elasticmachine Sep 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/kbn-text-based-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ In order to enable text based languages on your unified search bar add `textBase


## Languages supported
- SQL: based on the Elasticsearch sql api
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small cleanup

- ESQL: based on the Elastisearch esql api


Expand Down
58 changes: 10 additions & 48 deletions packages/kbn-text-based-editor/src/editor_footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React, { memo, useState, useCallback, useEffect, useMemo } from 'react';
import React, { memo, useState, useCallback, useMemo } from 'react';

import { i18n } from '@kbn/i18n';
import { EuiText, EuiFlexGroup, EuiFlexItem, EuiCode, EuiButtonIcon } from '@elastic/eui';
import { Interpolation, Theme, css } from '@emotion/react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import {
LanguageDocumentationFlyout,
LanguageDocumentationInline,
type LanguageDocumentationSections,
} from '@kbn/language-documentation-popover';
Expand All @@ -24,7 +22,6 @@ import { ErrorsWarningsFooterPopover } from './errors_warnings_popover';
import { QueryHistoryAction, QueryHistory } from './query_history';
import { SubmitFeedbackComponent } from './feedback_component';
import { QueryWrapComponent } from './query_wrap_component';
import type { TextBasedEditorDeps } from '../types';

const isMac = navigator.platform.toLowerCase().indexOf('mac') >= 0;
const COMMAND_KEY = isMac ? '⌘' : '^';
Expand Down Expand Up @@ -73,9 +70,6 @@ export const EditorFooter = memo(function EditorFooter({
measuredContainerWidth,
code,
}: EditorFooterProps) {
const kibana = useKibana<TextBasedEditorDeps>();
const { docLinks } = kibana.services;

const [isErrorPopoverOpen, setIsErrorPopoverOpen] = useState(false);
const [isLanguageComponentOpen, setIsLanguageComponentOpen] = useState(false);
const [isWarningPopoverOpen, setIsWarningPopoverOpen] = useState(false);
Expand All @@ -101,23 +95,17 @@ export const EditorFooter = memo(function EditorFooter({
setIsLanguageComponentOpen(false);
}, [isHistoryOpen, setIsHistoryOpen]);

const toggleLanguageComponent = useCallback(() => {
const toggleLanguageComponent = useCallback(async () => {
if (!documentationSections) {
const sections = await getDocumentationSections('esql');
setDocumentationSections(sections);
}
setIsLanguageComponentOpen(!isLanguageComponentOpen);
setIsHistoryOpen(false);
}, [isLanguageComponentOpen, setIsHistoryOpen]);
}, [documentationSections, isLanguageComponentOpen, setIsHistoryOpen]);

const limit = useMemo(() => getLimitFromESQLQuery(code), [code]);

useEffect(() => {
async function getDocumentation() {
const sections = await getDocumentationSections('esql');
setDocumentationSections(sections);
}
if (!documentationSections) {
getDocumentation();
}
}, [documentationSections]);

return (
<EuiFlexGroup
gutterSize="none"
Expand Down Expand Up @@ -294,30 +282,6 @@ export const EditorFooter = memo(function EditorFooter({
</EuiFlexGroup>
</EuiFlexItem>
)}
{documentationSections && !editorIsInline && (
<EuiFlexItem grow={false}>
<EuiButtonIcon
iconType="documentation"
onClick={() => setIsLanguageComponentOpen(!isLanguageComponentOpen)}
color="text"
size="xs"
data-test-subj="TextBasedLangEditor-documentation"
aria-label={i18n.translate(
'textBasedEditor.query.textBasedLanguagesEditor.documentationLabel',
{
defaultMessage: 'Documentation',
}
)}
/>
<LanguageDocumentationFlyout
sections={documentationSections}
searchInDescription
linkToDocumentation={docLinks?.links?.query?.queryESQL ?? ''}
isHelpMenuOpen={isLanguageComponentOpen}
onHelpMenuVisibilityChange={setIsLanguageComponentOpen}
/>
</EuiFlexItem>
)}
</EuiFlexGroup>
</EuiFlexItem>
{Boolean(editorIsInline) && (
Expand All @@ -332,11 +296,9 @@ export const EditorFooter = memo(function EditorFooter({
isSpaceReduced={true}
/>
)}
{documentationSections && (
<EuiFlexItem grow={false}>
<EuiButtonIcon iconType="documentation" onClick={toggleLanguageComponent} />
</EuiFlexItem>
)}
<EuiFlexItem grow={false}>
<EuiButtonIcon iconType="documentation" onClick={toggleLanguageComponent} />
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React, { useMemo, useState, useEffect } from 'react';
import React, { useMemo, useState, useCallback } from 'react';
import {
EuiPopover,
EuiButton,
Expand All @@ -18,7 +18,6 @@ import {
} from '@elastic/eui';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { i18n } from '@kbn/i18n';
import { getDocumentationSections } from '@kbn/text-based-editor';
import { FEEDBACK_LINK } from '@kbn/esql-utils';
import {
LanguageDocumentationFlyout,
Expand All @@ -35,15 +34,14 @@ export const ESQLMenuPopover = () => {
const [documentationSections, setDocumentationSections] =
useState<LanguageDocumentationSections>();

useEffect(() => {
async function getDocumentation() {
const toggleLanguageComponent = useCallback(async () => {
if (!documentationSections) {
const { getDocumentationSections } = await import('@kbn/text-based-editor');
const sections = await getDocumentationSections('esql');
setDocumentationSections(sections);
}
if (!documentationSections) {
getDocumentation();
}
}, [documentationSections]);
setIsLanguageComponentOpen(!isLanguageComponentOpen);
}, [documentationSections, isLanguageComponentOpen]);

const esqlPanelItems = useMemo(() => {
const panelItems: EuiContextMenuPanelProps['items'] = [];
Expand All @@ -52,7 +50,7 @@ export const ESQLMenuPopover = () => {
key="quickReference"
icon="documentation"
data-test-subj="esql-quick-reference"
onClick={() => setIsLanguageComponentOpen(!isLanguageComponentOpen)}
onClick={() => toggleLanguageComponent()}
>
{i18n.translate('unifiedSearch.query.queryBar.esqlMenu.quickReference', {
defaultMessage: 'Quick Reference',
Expand Down Expand Up @@ -97,7 +95,7 @@ export const ESQLMenuPopover = () => {
}, [
docLinks.links.query.queryESQL,
docLinks.links.query.queryESQLExamples,
isLanguageComponentOpen,
toggleLanguageComponent,
]);

return (
Expand Down