Skip to content

Commit

Permalink
feat(executions): Adding redirect for execution without application (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmquach authored and christopherthielen committed Jun 4, 2019
1 parent f89d97d commit 3f21c1f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import { ReactInjector } from 'core/reactShims';

export class ExecutionNotFound extends React.Component {
public render() {
const { params } = ReactInjector.$state;
return (
<div className="application">
<div>
<h2 className="text-center">Execution Not Found</h2>
<p className="text-center" style={{ marginBottom: '20px' }}>
Please check your URL - we can't find any data for <em>{params.executionId}</em>.
</p>
</div>
</div>
);
}
}
36 changes: 36 additions & 0 deletions app/scripts/modules/core/src/pipeline/pipeline.states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { INestedState, StateConfigProvider } from 'core/navigation/state.provide
import { filterModelConfig } from './filter/ExecutionFilterModel';

import { Executions } from 'core/pipeline/executions/Executions';
import { ExecutionNotFound } from 'core/pipeline/executions/ExecutionNotFound';
import { SingleExecutionDetails } from 'core/pipeline/details/SingleExecutionDetails';
import { ExecutionService } from './service/execution.service';

export const PIPELINE_STATES = 'spinnaker.core.pipeline.states';
module(PIPELINE_STATES, [APPLICATION_STATE_PROVIDER]).config([
Expand Down Expand Up @@ -92,5 +94,39 @@ module(PIPELINE_STATES, [APPLICATION_STATE_PROVIDER]).config([
};

applicationStateProvider.addChildState(pipelines);

const executionsLookup: INestedState = {
name: 'executionLookup',
url: '/executions/:executionId',
params: {
executionId: { dynamic: true },
},
redirectTo: transition => {
const { executionId } = transition.params();
const executionService: ExecutionService = transition.injector().get('executionService');

if (!executionId) {
return undefined;
}

return Promise.resolve()
.then(() => executionService.getExecution(executionId))
.then(execution =>
transition.router.stateService.target(
'home.applications.application.pipelines.executionDetails.execution',
{
application: execution.application,
executionId: execution.id,
},
),
)
.catch(() => {});
},
views: {
'main@': { component: ExecutionNotFound, $type: 'react' },
},
};

stateConfigProvider.addToRootState(executionsLookup);
},
]);

0 comments on commit 3f21c1f

Please sign in to comment.