Skip to content

Commit

Permalink
fix: back button on execution detail screen (#190)
Browse files Browse the repository at this point in the history
Signed-off-by: Pianist038801 <[email protected]>

Co-authored-by: Pianist038801 <[email protected]>
  • Loading branch information
Pianist038801 and Pianist038801 authored Aug 26, 2021
1 parent c0173fd commit 291f02c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { interactiveTextDisabledColor } from 'components/Theme/constants';
import { Execution } from 'models/Execution/types';
import * as React from 'react';
import { Link as RouterLink } from 'react-router-dom';
import { history } from 'routes/history';
import { Routes } from 'routes/routes';
import { ExecutionInputsOutputsModal } from '../ExecutionInputsOutputsModal';
import { ExecutionStatusBadge } from '../ExecutionStatusBadge';
import { TerminateExecutionButton } from '../TerminateExecution/TerminateExecutionButton';
Expand Down Expand Up @@ -79,12 +81,20 @@ export const ExecutionDetailsAppBarContent: React.FC<{
const { domain, name, project } = execution.id;
const { phase } = execution.closure;
const sourceId = getExecutionSourceId(execution);
const { backLink = getExecutionBackLink(execution) } = useLocationState();
const {
backLink: originalBackLink = getExecutionBackLink(execution)
} = useLocationState();
const isRunning = executionIsRunning(execution);
const isTerminal = executionIsTerminal(execution);
const onClickShowInputsOutputs = () => setShowInputsOutputs(true);
const onClickRelaunch = () => setShowRelaunchForm(true);
const onCloseRelaunch = () => setShowRelaunchForm(false);
const fromExecutionNav = new URLSearchParams(history.location.search).get(
'fromExecutionNav'
);
const backLink = fromExecutionNav
? Routes.ProjectDetails.sections.executions.makeUrl(project, domain)
: originalBackLink;

let modalContent: JSX.Element | null = null;
if (showInputsOutputs) {
Expand Down
10 changes: 9 additions & 1 deletion src/components/Executions/Tables/WorkflowExecutionLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ import { WorkflowExecutionIdentifier } from 'models/Execution/types';
import * as React from 'react';
import { Link as RouterLink } from 'react-router-dom';
import { Routes } from 'routes/routes';
import { history } from 'routes/history';

/** A simple component to render a link to a specific WorkflowExecution */
export const WorkflowExecutionLink: React.FC<{
className?: string;
id: WorkflowExecutionIdentifier;
}> = ({ className, id }) => {
const commonStyles = useCommonStyles();
const {
location: { pathname }
} = history;
const fromExecutionNav = pathname.split('/').pop() === 'executions';

return (
<RouterLink
className={classnames(commonStyles.primaryLink, className)}
to={Routes.ExecutionDetails.makeUrl(id)}
to={`${Routes.ExecutionDetails.makeUrl(id)}${
fromExecutionNav ? '?fromExecutionNav=true' : ''
}`}
>
{id.name}
</RouterLink>
Expand Down

0 comments on commit 291f02c

Please sign in to comment.