From a5c435069501fe3866305560bc26d81548b6009f Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Fri, 14 Dec 2018 19:20:01 -0500 Subject: [PATCH 1/2] add redirect route for workflow viewer --- awx/ui/client/features/output/legacy.route.js | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/features/output/legacy.route.js b/awx/ui/client/features/output/legacy.route.js index 2db75d01d7..b2425c85af 100644 --- a/awx/ui/client/features/output/legacy.route.js +++ b/awx/ui/client/features/output/legacy.route.js @@ -1,4 +1,4 @@ -function LegacyRedirect ($stateRegistry) { +function LegacyRedirect ($http, $stateRegistry) { const destination = 'output'; const routes = [ { @@ -66,11 +66,35 @@ function LegacyRedirect ($stateRegistry) { 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)); } -LegacyRedirect.$inject = ['$stateRegistry']; +LegacyRedirect.$inject = ['$http', '$stateRegistry']; export default LegacyRedirect; From c8b15005b4e3c58cba29e6210e1cb0bec951db2e Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Fri, 14 Dec 2018 19:22:23 -0500 Subject: [PATCH 2/2] link to workflow playbook node route from workflow viewer --- .../workflows/workflow-chart/workflow-chart.directive.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/templates/workflows/workflow-chart/workflow-chart.directive.js b/awx/ui/client/src/templates/workflows/workflow-chart/workflow-chart.directive.js index b3f4110050..aa37b1a1d5 100644 --- a/awx/ui/client/src/templates/workflows/workflow-chart/workflow-chart.directive.js +++ b/awx/ui/client/src/templates/workflows/workflow-chart/workflow-chart.directive.js @@ -769,7 +769,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge let href = ""; if (d.job) { if(d.job.type === 'job') { - href = `/#/jobs/playbook/${d.job.id}`; + href = `/#/workflow_node_playbook_results/${d.job.id}`; } else if(d.job.type === 'inventory_update') { href = `/#/jobs/inventory/${d.job.id}`; @@ -1070,7 +1070,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge let href = ""; if (d.job) { if(d.job.type === 'job') { - href = `/#/jobs/playbook/${d.job.id}`; + href = `/#/workflow_node_playbook_results/${d.job.id}`; } else if(d.job.type === 'inventory_update') { href = `/#/jobs/inventory/${d.job.id}`;