From eb3973b7f018cbdb75738d74ad70de81b4dee03e Mon Sep 17 00:00:00 2001 From: Georgii Gorbachev Date: Thu, 7 Jan 2021 15:55:04 +0100 Subject: [PATCH] [Security Solution][Detections] Follow up cleanup after two bugfixes (#87516) (#87550) ## Summary This is a follow-up PR addressing some of the comments in: - https://github.com/elastic/kibana/pull/86908 - https://github.com/elastic/kibana/pull/87004 --- .../common/components/autocomplete/field.tsx | 12 ++++----- .../components/links_to_docs/doc_link.tsx | 6 ++++- .../links_to_docs/external_link.tsx | 27 ++++++++++++++----- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/autocomplete/field.tsx b/x-pack/plugins/security_solution/public/common/components/autocomplete/field.tsx index f87bf3137765f..2aa71f0d9b5ad 100644 --- a/x-pack/plugins/security_solution/public/common/components/autocomplete/field.tsx +++ b/x-pack/plugins/security_solution/public/common/components/autocomplete/field.tsx @@ -122,16 +122,16 @@ const getAvailableFields = ( selectedFields: IFieldType[], fieldTypeFilter: string[] ): IFieldType[] => { - const map = new Map(); + const fieldsByName = new Map(); - existingFields.forEach((f) => map.set(f.name, f)); - selectedFields.forEach((f) => map.set(f.name, f)); + existingFields.forEach((f) => fieldsByName.set(f.name, f)); + selectedFields.forEach((f) => fieldsByName.set(f.name, f)); - const array = Array.from(map.values()); + const uniqueFields = Array.from(fieldsByName.values()); if (fieldTypeFilter.length > 0) { - return array.filter(({ type }) => fieldTypeFilter.includes(type)); + return uniqueFields.filter(({ type }) => fieldTypeFilter.includes(type)); } - return array; + return uniqueFields; }; diff --git a/x-pack/plugins/security_solution/public/common/components/links_to_docs/doc_link.tsx b/x-pack/plugins/security_solution/public/common/components/links_to_docs/doc_link.tsx index f02e4390db02f..6bd180c6fd510 100644 --- a/x-pack/plugins/security_solution/public/common/components/links_to_docs/doc_link.tsx +++ b/x-pack/plugins/security_solution/public/common/components/links_to_docs/doc_link.tsx @@ -22,7 +22,11 @@ const DocLink: FC = ({ guidePath = 'security', docPath, linkText } const url = `${ELASTIC_WEBSITE_URL}guide/en/${guidePath}/${DOC_LINK_VERSION}/${docPath}`; const ariaLabel = `${linkText} - ${COMMON_ARIA_LABEL_ENDING}`; - return ; + return ( + + {linkText} + + ); }; /** diff --git a/x-pack/plugins/security_solution/public/common/components/links_to_docs/external_link.tsx b/x-pack/plugins/security_solution/public/common/components/links_to_docs/external_link.tsx index f83c6f8fe31e4..d953ed2d706e5 100644 --- a/x-pack/plugins/security_solution/public/common/components/links_to_docs/external_link.tsx +++ b/x-pack/plugins/security_solution/public/common/components/links_to_docs/external_link.tsx @@ -5,21 +5,34 @@ */ import React, { FC } from 'react'; -import { EuiLink } from '@elastic/eui'; +import { EuiLink, EuiToolTip } from '@elastic/eui'; interface ExternalLinkProps { url: string; - text: string; + children?: React.ReactNode; ariaLabel?: string; } /** - * A simplistic text link for opening external urls in a new browser tab. + * A link for opening external urls in a new browser tab. */ -export const ExternalLink: FC = ({ url, text, ariaLabel }) => { +export const ExternalLink: FC = ({ url, children, ariaLabel }) => { + if (!children) { + return null; + } + return ( - - {text} - + + + {children} + + ); };