Merge pull request #2 from jakemcdermott/wf-details-click

add output redirect route for workflow playbook nodes
This commit is contained in:
Michael Abashian 2018-12-17 09:41:41 -05:00 committed by GitHub
commit 2d237b6dbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 4 deletions

View File

@ -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;

View File

@ -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}`;