mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Security Solution][Detections] Follow up cleanup after two bugfixes (#87516)
## 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
This commit is contained in:
parent
48694bbbad
commit
e50ad384f7
3 changed files with 31 additions and 14 deletions
|
@ -122,16 +122,16 @@ const getAvailableFields = (
|
|||
selectedFields: IFieldType[],
|
||||
fieldTypeFilter: string[]
|
||||
): IFieldType[] => {
|
||||
const map = new Map<string, IFieldType>();
|
||||
const fieldsByName = new Map<string, IFieldType>();
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -22,7 +22,11 @@ const DocLink: FC<DocLinkProps> = ({ guidePath = 'security', docPath, linkText }
|
|||
const url = `${ELASTIC_WEBSITE_URL}guide/en/${guidePath}/${DOC_LINK_VERSION}/${docPath}`;
|
||||
const ariaLabel = `${linkText} - ${COMMON_ARIA_LABEL_ENDING}`;
|
||||
|
||||
return <ExternalLink url={url} text={linkText} ariaLabel={ariaLabel} />;
|
||||
return (
|
||||
<ExternalLink url={url} ariaLabel={ariaLabel}>
|
||||
{linkText}
|
||||
</ExternalLink>
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<ExternalLinkProps> = ({ url, text, ariaLabel }) => {
|
||||
export const ExternalLink: FC<ExternalLinkProps> = ({ url, children, ariaLabel }) => {
|
||||
if (!children) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<EuiLink href={url} aria-label={ariaLabel} external target="_blank" rel="noopener">
|
||||
{text}
|
||||
</EuiLink>
|
||||
<EuiToolTip content={url} position="top" data-test-subj="externalLinkTooltip">
|
||||
<EuiLink
|
||||
href={url}
|
||||
aria-label={ariaLabel}
|
||||
external
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
data-test-subj="externalLink"
|
||||
>
|
||||
{children}
|
||||
</EuiLink>
|
||||
</EuiToolTip>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue