diff --git a/awx/ui/client/features/output/details.directive.js b/awx/ui/client/features/output/details.directive.js index 80251e3d9d..e0015d0b94 100644 --- a/awx/ui/client/features/output/details.directive.js +++ b/awx/ui/client/features/output/details.directive.js @@ -184,7 +184,6 @@ function getInventoryDetails () { function getProjectDetails () { const project = resource.model.get('summary_fields.project'); - const projectUpdate = resource.model.get('summary_fields.project_update'); if (!project) { return null; @@ -195,17 +194,32 @@ function getProjectDetails () { const value = $filter('sanitize')(project.name); const tooltip = strings.get('resourceTooltips.PROJECT'); - if (projectUpdate) { - const update = { - link: `/#/jobz/project/${projectUpdate.id}`, - tooltip: strings.get('resourceTooltips.PROJECT_UPDATE'), - status: projectUpdate.status, - }; + return { label, link, value, tooltip }; +} - return { label, link, value, tooltip, update }; +function getProjectStatusDetails (projectStatus) { + const project = resource.model.get('summary_fields.project'); + const jobStatus = projectStatus || resource.model.get('summary_fields.project_update.status'); + + if (!project) { + return null; } - return { label, link, value, tooltip }; + return jobStatus; +} + +function getProjectUpdateDetails (updateId) { + const project = resource.model.get('summary_fields.project'); + const jobId = updateId || resource.model.get('summary_fields.project_update.id'); + + if (!project) { + return null; + } + + const link = `/#/jobz/project/${jobId}`; + const tooltip = strings.get('resourceTooltips.PROJECT_UPDATE'); + + return { link, tooltip }; } function getSCMRevisionDetails () { @@ -495,6 +509,8 @@ function AtJobDetailsController ( vm.sourceWorkflowJob = getSourceWorkflowJobDetails(); vm.inventory = getInventoryDetails(); vm.project = getProjectDetails(); + vm.projectUpdate = getProjectUpdateDetails(); + vm.projectStatus = getProjectStatusDetails(); vm.scmRevision = getSCMRevisionDetails(); vm.playbook = getPlaybookDetails(); vm.resultTraceback = getResultTracebackDetails(); @@ -533,16 +549,15 @@ function AtJobDetailsController ( vm.deleteJob = deleteJob; vm.toggleLabels = toggleLabels; - $scope.$watch(status.getStarted, value => { vm.started = getStartDetails(value); }); - $scope.$watch(status.getJobStatus, value => { vm.status = getStatusDetails(value); }); - $scope.$watch(status.getFinished, value => { vm.finished = getFinishDetails(value); }); + const observe = (getter, transform, key) => { + $scope.$watch(getter, value => { vm[key] = transform(value); }); + }; - $scope.$watch(status.getProjectStatus, value => { - if (!value) return; - - vm.project.update = vm.project.update || {}; - vm.project.update.status = value; - }); + observe(status.getStarted, getStartDetails, 'started'); + observe(status.getJobStatus, getStatusDetails, 'status'); + observe(status.getFinished, getFinishDetails, 'finished'); + observe(status.getProjectUpdateId, getProjectUpdateDetails, 'projectUpdate'); + observe(status.getProjectStatus, getProjectStatusDetails, 'projectStatus'); }; } diff --git a/awx/ui/client/features/output/details.partial.html b/awx/ui/client/features/output/details.partial.html index db5864647f..cc3f18b19d 100644 --- a/awx/ui/client/features/output/details.partial.html +++ b/awx/ui/client/features/output/details.partial.html @@ -119,11 +119,11 @@