-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): properly update execution permalink on location change (#7152
) * fix(core): properly update execution permalink on location change * perf(core): limit re-rendering of Execution component on state changes
- Loading branch information
1 parent
9bd9624
commit 058007e
Showing
5 changed files
with
69 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/scripts/modules/core/src/pipeline/executions/execution/ExecutionPermalink.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { CopyToClipboard } from 'core/utils'; | ||
import { ReactInjector } from 'core/reactShims'; | ||
import * as React from 'react'; | ||
import * as ReactGA from 'react-ga'; | ||
|
||
export interface IExecutionPermalinkProps { | ||
standalone: boolean; | ||
} | ||
|
||
export const ExecutionPermalink = ({ standalone }: IExecutionPermalinkProps) => { | ||
const [url, setUrl] = React.useState(location.href); | ||
|
||
React.useEffect(() => { | ||
const subscription = ReactInjector.stateEvents.locationChangeSuccess.subscribe(() => { | ||
const newUrl = location.href; | ||
if (url !== newUrl) { | ||
if (!standalone) { | ||
setUrl(newUrl); | ||
} else { | ||
setUrl(newUrl.replace('/executions', '/executions/details')); | ||
} | ||
} | ||
}); | ||
return () => subscription.unsubscribe(); | ||
}, []); | ||
|
||
const handlePermalinkClick = (): void => { | ||
ReactGA.event({ category: 'Pipeline', action: 'Permalink clicked' }); | ||
}; | ||
|
||
return ( | ||
<> | ||
<a onClick={handlePermalinkClick} href={url}> | ||
Permalink | ||
</a> | ||
<CopyToClipboard text={url} toolTip="Copy permalink to clipboard" /> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters