diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula.scss b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula.scss index 5e97f592a0474..56d0960862e7c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula.scss +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula.scss @@ -10,12 +10,17 @@ flex: 1; min-height: 0; } + + & > * + * { + border-top: $euiBorderThin; + } } .lnsFormula__editor { border-bottom: $euiBorderThin; .lnsIndexPatternDimensionEditor-isFullscreen & { + border-bottom: none; display: flex; flex-direction: column; } @@ -94,7 +99,18 @@ .lnsFormula__docsNav { @include euiYScroll; background: $euiColorLightestShade; +} + +.lnsFormula__docsNavGroup { padding: $euiSizeS; + + & + & { + border-top: $euiBorderThin; + } +} + +.lnsFormula__docsNavGroupLink { + font-weight: inherit; } .lnsFormula__docsText { @@ -102,6 +118,16 @@ padding: $euiSize; } +.lnsFormula__docsTextGroup, +.lnsFormula__docsTextItem { + margin-top: $euiSizeXXL; +} + +.lnsFormula__docsTextGroup { + border-top: $euiBorderThin; + padding-top: $euiSizeXXL; +} + .lnsFormulaOverflow { // Needs to be higher than the modal and all flyouts z-index: $euiZLevel9 + 1; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_help.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_help.tsx index 0ff120ea110db..c5b18ea36957e 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_help.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/editor/formula_help.tsx @@ -10,13 +10,12 @@ import { i18n } from '@kbn/i18n'; import { EuiFlexGroup, EuiFlexItem, + EuiLink, EuiPopoverTitle, EuiText, EuiListGroupItem, - EuiSelectableOption, EuiListGroup, - EuiHorizontalRule, - EuiSpacer, + EuiTitle, } from '@elastic/eui'; import { Markdown } from '../../../../../../../../../src/plugins/kibana_react/public'; import { GenericOperationDefinition } from '../../index'; @@ -34,7 +33,7 @@ function FormulaHelp({ isFullscreen: boolean; }) { const [selectedFunction, setSelectedFunction] = useState(); - const scrollTargets = useRef>({}); + const scrollTargets = useRef>({}); useEffect(() => { if (selectedFunction && scrollTargets.current[selectedFunction]) { @@ -42,24 +41,28 @@ function FormulaHelp({ } }, [selectedFunction]); - const helpItems: Array = []; + const helpGroups: Array<{ + label: string; + description?: JSX.Element; + items: Array<{ label: string; description?: JSX.Element }>; + }> = []; - helpItems.push({ + helpGroups.push({ label: i18n.translate('xpack.lens.formulaDocumentation.mathSection', { defaultMessage: 'Math', }), - isGroupLabel: true, description: ( - + {i18n.translate('xpack.lens.formulaDocumentation.mathSectionDescription', { defaultMessage: 'These functions will be executed for reach row of the resulting table using single values from the same row calculated using other functions.', })} ), + items: [], }); - helpItems.push( + helpGroups[0].items.push( ...getPossibleFunctions(indexPattern) .filter((key) => key in tinymathFunctions) .sort() @@ -69,23 +72,23 @@ function FormulaHelp({ })) ); - helpItems.push({ + helpGroups.push({ label: i18n.translate('xpack.lens.formulaDocumentation.elasticsearchSection', { defaultMessage: 'Elasticsearch', }), - isGroupLabel: true, description: ( - + {i18n.translate('xpack.lens.formulaDocumentation.elasticsearchSectionDescription', { defaultMessage: 'These functions will be executed on the raw documents for each row of the resulting table, aggregating all documents matching the break down dimensions into a single value.', })} ), + items: [], }); // Es aggs - helpItems.push( + helpGroups[1].items.push( ...getPossibleFunctions(indexPattern) .filter( (key) => @@ -99,23 +102,23 @@ function FormulaHelp({ })) ); - helpItems.push({ + helpGroups.push({ label: i18n.translate('xpack.lens.formulaDocumentation.columnCalculationSection', { defaultMessage: 'Column-wise calculation', }), - isGroupLabel: true, description: ( - + {i18n.translate('xpack.lens.formulaDocumentation.columnCalculationSectionDescription', { defaultMessage: 'These functions will be executed for reach row of the resulting table, using data from cells from other rows as well as the current value.', })} ), + items: [], }); // Calculations aggs - helpItems.push( + helpGroups[2].items.push( ...getPossibleFunctions(indexPattern) .filter( (key) => @@ -143,35 +146,40 @@ function FormulaHelp({ - - {helpItems.map((helpItem) => { - if (helpItem.isGroupLabel) { - return ( - { - setSelectedFunction(helpItem.label); - }} - /> - ); - } else { - return ( - { - setSelectedFunction(helpItem.label); - }} - /> - ); - } - })} - + {helpGroups.map((helpGroup, index) => { + return ( + + ); + })} @@ -215,30 +223,38 @@ Use the symbols +, -, /, and * to perform basic math. 'Text is in markdown. Do not translate function names or field names like sum(bytes)', })} /> - - {helpItems.map((item, index) => { + + {helpGroups.map((helpGroup, index) => { return ( -
{ if (el) { - scrollTargets.current[item.label] = el; + scrollTargets.current[helpGroup.label] = el; } }} > - {item.isGroupLabel ? ( - -

{item.label}

- {item.description} - -
- ) : ( - - {item.description} - {helpItems.length - 1 !== index && } - - )} -
+

{helpGroup.label}

+ + {helpGroup.description} + + {helpGroups[index].items.map((helpItem) => { + return ( +
{ + if (el) { + scrollTargets.current[helpItem.label] = el; + } + }} + > + {helpItem.description} +
+ ); + })} + ); })}