diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/i18n.ts index fc0ebea3342e4..78f7218dce22e 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/i18n.ts +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/i18n.ts @@ -37,13 +37,27 @@ export const txtUrlTemplateLabel = i18n.translate( } ); -export const txtUrlTemplateHelpLinkText = i18n.translate( - 'xpack.uiActionsEnhanced.drilldowns.urlDrilldownCollectConfig.urlTemplateHelpLinkText', +export const txtUrlTemplateSyntaxHelpLinkText = i18n.translate( + 'xpack.uiActionsEnhanced.drilldowns.urlDrilldownCollectConfig.urlTemplateSyntaxHelpLinkText', { defaultMessage: 'Syntax help', } ); +export const txtUrlTemplateVariablesHelpLinkText = i18n.translate( + 'xpack.uiActionsEnhanced.drilldowns.urlDrilldownCollectConfig.urlTemplateVariablesHelpLinkText', + { + defaultMessage: 'Help', + } +); + +export const txtUrlTemplateVariablesFilterPlaceholderText = i18n.translate( + 'xpack.uiActionsEnhanced.drilldowns.urlDrilldownCollectConfig.urlTemplateVariablesFilterPlaceholderText', + { + defaultMessage: 'Filter variables', + } +); + export const txtUrlTemplatePreviewLabel = i18n.translate( 'xpack.uiActionsEnhanced.drilldowns.urlDrilldownCollectConfig.urlPreviewLabel', { diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/url_drilldown_collect_config.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/url_drilldown_collect_config.tsx index df067cda169da..dabf09e4b6e9f 100644 --- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/url_drilldown_collect_config.tsx +++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/url_drilldown/components/url_drilldown_collect_config/url_drilldown_collect_config.tsx @@ -6,15 +6,17 @@ import React, { useRef, useState } from 'react'; import { - EuiContextMenuItem, - EuiContextMenuPanel, + EuiCheckbox, EuiFormRow, EuiIcon, EuiLink, EuiPopover, - EuiCheckbox, + EuiPopoverFooter, + EuiPopoverTitle, + EuiSelectable, EuiText, EuiTextArea, + EuiSelectableOption, } from '@elastic/eui'; import { UrlDrilldownConfig, UrlDrilldownScope } from '../../types'; import { compile } from '../../url_template'; @@ -24,7 +26,9 @@ import './index.scss'; import { txtAddVariableButtonTitle, txtUrlPreviewHelpText, - txtUrlTemplateHelpLinkText, + txtUrlTemplateSyntaxHelpLinkText, + txtUrlTemplateVariablesHelpLinkText, + txtUrlTemplateVariablesFilterPlaceholderText, txtUrlTemplateLabel, txtUrlTemplateOpenInNewTab, txtUrlTemplatePlaceholder, @@ -84,13 +88,14 @@ export const UrlDrilldownCollectConfig: React.FC = ({ helpText={ syntaxHelpDocsLink && ( - {txtUrlTemplateHelpLinkText} + {txtUrlTemplateSyntaxHelpLinkText} ) } labelAppend={ { if (textAreaRef.current) { updateUrlTemplate( @@ -154,28 +159,23 @@ export const UrlDrilldownCollectConfig: React.FC = ({ function AddVariableButton({ variables, onSelect, + variablesHelpLink, }: { variables: string[]; onSelect: (variable: string) => void; + variablesHelpLink?: string; }) { const [isVariablesPopoverOpen, setIsVariablesPopoverOpen] = useState(false); + const closePopover = () => setIsVariablesPopoverOpen(false); - const renderVariables = () => - variables.map((variable: string) => ( - { - onSelect(variable); - setIsVariablesPopoverOpen(false); - }} - > - {`{{${variable}}}`} - - )); + const options: EuiSelectableOption[] = variables.map((variable: string) => ({ + key: variable, + label: variable, + })); return ( setIsVariablesPopoverOpen(true)}> @@ -184,12 +184,43 @@ function AddVariableButton({ } isOpen={isVariablesPopoverOpen} - closePopover={() => setIsVariablesPopoverOpen(false)} + closePopover={closePopover} panelPaddingSize="none" anchorPosition="downLeft" withTitle > - + { + const selected = newOptions.find((o) => o.checked === 'on'); + if (!selected) return; + onSelect(selected.key!); + closePopover(); + }} + listProps={{ + showIcons: false, + }} + > + {(list, search) => ( +
+ {search} + {list} + {variablesHelpLink && ( + + + {txtUrlTemplateVariablesHelpLinkText} + + + )} +
+ )} +
); }