diff --git a/awx/ui/client/src/notifications/notifications.list.js b/awx/ui/client/src/notifications/notifications.list.js index d146465f87..a08dd7692e 100644 --- a/awx/ui/client/src/notifications/notifications.list.js +++ b/awx/ui/client/src/notifications/notifications.list.js @@ -35,6 +35,19 @@ export default ['i18n', 'templateUrl', function(i18n, templateUrl){ excludeModal: true, columnClass: 'd-none d-sm-flex col-md-4 col-sm-3' }, + notification_templates_approvals: { + label: i18n._('Approval'), + columnClass: 'd-none d-md-flex justify-content-start col-md-1', + flag: 'notification_templates_approvals', + type: "toggle", + ngClick: "toggleNotification($event, notification.id, 'notification_templates_approvals')", + ngDisabled: "!sufficientRoleForNotifToggle", + awToolTip: "{{ schedule.play_tip }}", + dataTipWatch: "schedule.play_tip", + dataPlacement: "right", + nosort: true, + ngIf: "showApprovalColumn" + }, notification_templates_started: { label: i18n._("Start"), flag: 'notification_templates_started', diff --git a/awx/ui/client/src/notifications/shared/notification-list-init.factory.js b/awx/ui/client/src/notifications/shared/notification-list-init.factory.js index 03027feab9..7829f9e781 100644 --- a/awx/ui/client/src/notifications/shared/notification-list-init.factory.js +++ b/awx/ui/client/src/notifications/shared/notification-list-init.factory.js @@ -22,6 +22,10 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices', url = params.url, id = params.id; + if ($state.includes('templates.editWorkflowJobTemplate') || $state.includes('organizations.edit')) { + scope.showApprovalColumn = true; + } + scope.addNotificationTemplate = function() { var org_id; if($stateParams.hasOwnProperty('project_id')){ @@ -51,6 +55,10 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices', scope.relatednotificationsRemove = scope.$on('relatednotifications', function () { var columns = ['/notification_templates_started/', '/notification_templates_success/', '/notification_templates_error/']; + if ($state.includes('templates.editWorkflowJobTemplate') || $state.includes('organizations.edit')) { + columns.push('/notification_templates_approvals'); + } + GetChoices({ scope: scope, url: GetBasePath('notifications'), @@ -64,9 +72,17 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices', Rest.setUrl(notifier_url); Rest.get() .then(function(response) { - let checkForSuccessOrError = response.config.url.indexOf('success') > 0 ? "notification_templates_success" : "notification_templates_error"; + let type; - let type = response.config.url.indexOf('started') > 0 ? "notification_templates_started" : checkForSuccessOrError; + if (response.config.url.indexOf('started') > 0) { + type = "notification_templates_started"; + } else if (response.config.url.indexOf('success') > 0) { + type = "notification_templates_success"; + } else if (response.config.url.indexOf('error') > 0) { + type = "notification_templates_error"; + } else if (response.config.url.indexOf('approvals') > 0) { + type = "notification_templates_approvals"; + } if (response.data.results) { _.forEach(response.data.results, function(result){ diff --git a/awx/ui/client/src/shared/generator-helpers.js b/awx/ui/client/src/shared/generator-helpers.js index 60af4a17aa..c0489bd941 100644 --- a/awx/ui/client/src/shared/generator-helpers.js +++ b/awx/ui/client/src/shared/generator-helpers.js @@ -527,8 +527,9 @@ angular.module('GeneratorHelpers', [systemStatus.name]) } else if (field.type === 'template') { html = Template(field); } else if (field.type === 'toggle') { + const ngIf = field.ngIf ? `ng-if="${field.ngIf}"` : ''; html += ` -
+
`; diff --git a/awx/ui/client/src/shared/list-generator/list-generator.factory.js b/awx/ui/client/src/shared/list-generator/list-generator.factory.js index 11e932cc09..b63fa96f9b 100644 --- a/awx/ui/client/src/shared/list-generator/list-generator.factory.js +++ b/awx/ui/client/src/shared/list-generator/list-generator.factory.js @@ -546,7 +546,9 @@ export default ['$compile', 'Attr', 'Icon', for (fld in list.fields) { if (options.mode !== 'lookup' || (options.mode === 'lookup' && (fld === 'name' || _.has(list.fields[fld], 'includeModal')))){ let customClass = list.fields[fld].columnClass || ''; + const ngIf = list.fields[fld].ngIf ? `ng-if="${list.fields[fld].ngIf}"` : ''; html += `