Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Security Solution][Detections] Follow up cleanup after two bugfixes (#87516) #87549

Merged
merged 1 commit into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
);
};