Skip to content

Commit

Permalink
fix(core): correctly build permalinks for executions (#7167)
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherchrisberry committed Jul 1, 2019
1 parent 5401a87 commit 7d3b83a
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 7d3b83a

Please sign in to comment.