Skip to content

Commit

Permalink
[Security Solution][Detections] Follow up cleanup after two bugfixes (e…
Browse files Browse the repository at this point in the history
…lastic#87516) (elastic#87550)

## Summary

This is a follow-up PR addressing some of the comments in:

- elastic#86908
- elastic#87004
  • Loading branch information
banderror authored Jan 7, 2021
1 parent e2d16df commit eb3973b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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>
);
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
);
};

0 comments on commit eb3973b

Please sign in to comment.