Skip to content

Commit

Permalink
makes the ML link open in a new window
Browse files Browse the repository at this point in the history
  • Loading branch information
ogupte committed May 5, 2020
1 parent ccf4bb8 commit d56debc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ export function Contents({
</EuiFlexGroup>
</ContentLine>
<ContentLine>
<MLJobLink jobId={jobId}>{ANOMALY_DETECTION_LINK}</MLJobLink>
<MLJobLink external jobId={jobId}>
{ANOMALY_DETECTION_LINK}
</MLJobLink>
</ContentLine>
<EuiHorizontalRule margin="xs" />
</FlexColumnItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ interface PropsJobId {
jobId: string;
}

type Props = PropsServiceName | PropsJobId;
type Props = (PropsServiceName | PropsJobId) & {
external?: boolean;
};

export const MLJobLink: React.FC<Props> = props => {
const jobId =
Expand All @@ -32,6 +34,7 @@ export const MLJobLink: React.FC<Props> = props => {
children={props.children}
query={query}
path="/timeseriesexplorer"
external={props.external}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ interface Props {
query?: MlRisonData;
path?: string;
children?: React.ReactNode;
external?: boolean;
}

export function MLLink({ children, path = '', query = {} }: Props) {
export function MLLink({ children, path = '', query = {}, external }: Props) {
const { core } = useApmPluginContext();
const location = useLocation();

Expand All @@ -41,5 +42,12 @@ export function MLLink({ children, path = '', query = {} }: Props) {
hash: `${path}?_g=${rison.encode(risonQuery as RisonValue)}`
});

return <EuiLink children={children} href={href} />;
return (
<EuiLink
children={children}
href={href}
external={external}
target={external ? '_blank' : undefined}
/>
);
}

0 comments on commit d56debc

Please sign in to comment.