From 7d3b83a34ed8464462866f66dea57d699c317b47 Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Mon, 1 Jul 2019 17:04:51 -0500 Subject: [PATCH] fix(core): correctly build permalinks for executions (#7167) --- .../executions/execution/ExecutionPermalink.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/scripts/modules/core/src/pipeline/executions/execution/ExecutionPermalink.tsx b/app/scripts/modules/core/src/pipeline/executions/execution/ExecutionPermalink.tsx index 953665b4fd1..bf8750dc82f 100644 --- a/app/scripts/modules/core/src/pipeline/executions/execution/ExecutionPermalink.tsx +++ b/app/scripts/modules/core/src/pipeline/executions/execution/ExecutionPermalink.tsx @@ -8,17 +8,14 @@ export interface IExecutionPermalinkProps { } export const ExecutionPermalink = ({ standalone }: IExecutionPermalinkProps) => { - const [url, setUrl] = React.useState(location.href); + const asPermalink = (link: string) => (standalone ? link : link.replace('/executions', '/executions/details')); + + const [url, setUrl] = React.useState(asPermalink(location.href)); React.useEffect(() => { - const subscription = ReactInjector.stateEvents.locationChangeSuccess.subscribe(() => { - const newUrl = location.href; + const subscription = ReactInjector.stateEvents.locationChangeSuccess.subscribe(newUrl => { if (url !== newUrl) { - if (!standalone) { - setUrl(newUrl); - } else { - setUrl(newUrl.replace('/executions', '/executions/details')); - } + setUrl(asPermalink(newUrl)); } }); return () => subscription.unsubscribe();