mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
add redirect route for workflow viewer
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
function LegacyRedirect ($stateRegistry) {
|
function LegacyRedirect ($http, $stateRegistry) {
|
||||||
const destination = 'output';
|
const destination = 'output';
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
@@ -66,11 +66,35 @@ function LegacyRedirect ($stateRegistry) {
|
|||||||
return { state: 'schedules.edit', params: { schedule_id, schedule_search } };
|
return { state: 'schedules.edit', params: { schedule_id, schedule_search } };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'workflowPlaybookNodeRedirect',
|
||||||
|
url: '/workflow_node_playbook_results/:id',
|
||||||
|
redirectTo: (trans) => {
|
||||||
|
// The workflow job viewer uses this route for playbook job nodes. The provided id
|
||||||
|
// is used to lookup the corresponding unified job, which is then inspected to
|
||||||
|
// determine if we need to redirect to a split (workflow) job or a playbook job.
|
||||||
|
const { id } = trans.params();
|
||||||
|
const endpoint = '/api/v2/unified_jobs/';
|
||||||
|
|
||||||
|
return $http.get(endpoint, { params: { id } })
|
||||||
|
.then(({ data }) => {
|
||||||
|
const { results } = data;
|
||||||
|
const [obj] = results;
|
||||||
|
|
||||||
|
if (obj && obj.type === 'workflow_job') {
|
||||||
|
return { state: 'workflowResults', params: { id } };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { state: destination, params: { type: 'playbook', id } };
|
||||||
|
})
|
||||||
|
.catch(() => ({ state: 'dashboard' }));
|
||||||
|
}
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
routes.forEach(state => $stateRegistry.register(state));
|
routes.forEach(state => $stateRegistry.register(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
LegacyRedirect.$inject = ['$stateRegistry'];
|
LegacyRedirect.$inject = ['$http', '$stateRegistry'];
|
||||||
|
|
||||||
export default LegacyRedirect;
|
export default LegacyRedirect;
|
||||||
|
|||||||
Reference in New Issue
Block a user