Skip to content

Commit

Permalink
fix(core): Redirecting aged out executions to permalink (#8770)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
alanmquach and mergify[bot] committed Dec 7, 2020
1 parent 38b3138 commit 5409758
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/scripts/modules/core/src/pipeline/executions/Executions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export interface IExecutionsState {
reloadingForFilters: boolean;
}

// This Set ensures we only forward once from .executions to .executionDetails for an aged out execution
const forwardedExecutions = new Set();

export class Executions extends React.Component<IExecutionsProps, IExecutionsState> {
private executionsRefreshUnsubscribe: Function;
private groupsUpdatedSubscription: Subscription;
Expand Down Expand Up @@ -173,6 +176,21 @@ export class Executions extends React.Component<IExecutionsProps, IExecutionsSta
ReactInjector.$state.go('.', { startManualExecution: null }, { inherit: true, location: 'replace' });
}

private handleAgedOutExecutions(executionId: string): void {
const { $state, executionService } = ReactInjector;
if (executionId && !forwardedExecutions.has(executionId)) {
executionService.getExecution(executionId).then(() => {
const detailsState = $state.current.name.replace('executions.execution', 'executionDetails.execution');
const { stage, step, details } = $state.params;
forwardedExecutions.add(executionId);
$state.go(detailsState, { executionId, stage, step, details });
});
} else {
// Handles the case where we already forwarded once and user navigated back, so do not forward again.
$state.go('.^');
}
}

public componentDidMount(): void {
const { app } = this.props;
if (ExecutionState.filterModel.mostRecentApplication !== app.name) {
Expand Down Expand Up @@ -203,7 +221,7 @@ export class Executions extends React.Component<IExecutionsProps, IExecutionsSta
if ($state.params.executionId) {
const executions: IExecution[] = app.executions.data;
if (executions.every((e) => e.id !== $state.params.executionId)) {
$state.go('.^');
this.handleAgedOutExecutions($state.params.executionId);
}
}
},
Expand Down

0 comments on commit 5409758

Please sign in to comment.