mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Add notification custom message fields for workflow pause/approval
This commit is contained in:
parent
12d735ec8f
commit
ad5857e06b
@ -671,6 +671,98 @@ export default ['i18n', function(i18n) {
|
||||
"|| notification_type.value == 'webhook')",
|
||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
|
||||
},
|
||||
approved_message: {
|
||||
label: i18n._('Workflow Approved Message'),
|
||||
class: 'Form-formGroup--fullWidth',
|
||||
type: 'syntax_highlight',
|
||||
mode: 'jinja2',
|
||||
default: '',
|
||||
ngShow: "customize_messages && notification_type.value != 'webhook'",
|
||||
rows: 2,
|
||||
oneLine: 'true',
|
||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
|
||||
},
|
||||
approved_body: {
|
||||
label: i18n._('Workflow Approved Message Body'),
|
||||
class: 'Form-formGroup--fullWidth',
|
||||
type: 'syntax_highlight',
|
||||
mode: 'jinja2',
|
||||
default: '',
|
||||
ngShow: "customize_messages && " +
|
||||
"(notification_type.value == 'email' " +
|
||||
"|| notification_type.value == 'pagerduty' " +
|
||||
"|| notification_type.value == 'webhook')",
|
||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
|
||||
},
|
||||
denied_message: {
|
||||
label: i18n._('Workflow Denied Message'),
|
||||
class: 'Form-formGroup--fullWidth',
|
||||
type: 'syntax_highlight',
|
||||
mode: 'jinja2',
|
||||
default: '',
|
||||
ngShow: "customize_messages && notification_type.value != 'webhook'",
|
||||
rows: 2,
|
||||
oneLine: 'true',
|
||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
|
||||
},
|
||||
denied_body: {
|
||||
label: i18n._('Workflow Denied Message Body'),
|
||||
class: 'Form-formGroup--fullWidth',
|
||||
type: 'syntax_highlight',
|
||||
mode: 'jinja2',
|
||||
default: '',
|
||||
ngShow: "customize_messages && " +
|
||||
"(notification_type.value == 'email' " +
|
||||
"|| notification_type.value == 'pagerduty' " +
|
||||
"|| notification_type.value == 'webhook')",
|
||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
|
||||
},
|
||||
running_message: {
|
||||
label: i18n._('Workflow Running Message'),
|
||||
class: 'Form-formGroup--fullWidth',
|
||||
type: 'syntax_highlight',
|
||||
mode: 'jinja2',
|
||||
default: '',
|
||||
ngShow: "customize_messages && notification_type.value != 'webhook'",
|
||||
rows: 2,
|
||||
oneLine: 'true',
|
||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
|
||||
},
|
||||
running_body: {
|
||||
label: i18n._('Workflow Running Message Body'),
|
||||
class: 'Form-formGroup--fullWidth',
|
||||
type: 'syntax_highlight',
|
||||
mode: 'jinja2',
|
||||
default: '',
|
||||
ngShow: "customize_messages && " +
|
||||
"(notification_type.value == 'email' " +
|
||||
"|| notification_type.value == 'pagerduty' " +
|
||||
"|| notification_type.value == 'webhook')",
|
||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
|
||||
},
|
||||
timed_out_message: {
|
||||
label: i18n._('Workflow Timed Out Message'),
|
||||
class: 'Form-formGroup--fullWidth',
|
||||
type: 'syntax_highlight',
|
||||
mode: 'jinja2',
|
||||
default: '',
|
||||
ngShow: "customize_messages && notification_type.value != 'webhook'",
|
||||
rows: 2,
|
||||
oneLine: 'true',
|
||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
|
||||
},
|
||||
timed_out_body: {
|
||||
label: i18n._('Workflow Timed Out Message Body'),
|
||||
class: 'Form-formGroup--fullWidth',
|
||||
type: 'syntax_highlight',
|
||||
mode: 'jinja2',
|
||||
default: '',
|
||||
ngShow: "customize_messages && " +
|
||||
"(notification_type.value == 'email' " +
|
||||
"|| notification_type.value == 'pagerduty' " +
|
||||
"|| notification_type.value == 'webhook')",
|
||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
|
||||
},
|
||||
},
|
||||
|
||||
buttons: { //for now always generates <button> tags
|
||||
|
@ -1,19 +1,20 @@
|
||||
|
||||
const emptyDefaults = {
|
||||
started: {
|
||||
message: '',
|
||||
body: '',
|
||||
},
|
||||
success: {
|
||||
message: '',
|
||||
body: '',
|
||||
},
|
||||
error: {
|
||||
message: '',
|
||||
body: '',
|
||||
},
|
||||
started: { message: '', body: '' },
|
||||
success: { message: '', body: '' },
|
||||
error: { message: '', body: '' },
|
||||
workflow_approval: {
|
||||
approved: { message: '', body: '' },
|
||||
denied: { message: '', body: '' },
|
||||
running: { message: '', body: '' },
|
||||
timed_out: { message: '', body: '' },
|
||||
}
|
||||
};
|
||||
|
||||
function getMessageIfUpdated(message, defaultValue) {
|
||||
return message === defaultValue ? null : message;
|
||||
}
|
||||
|
||||
export default [function() {
|
||||
return {
|
||||
getMessagesObj: function ($scope, defaultMessages) {
|
||||
@ -23,22 +24,34 @@ export default [function() {
|
||||
const defaults = defaultMessages[$scope.notification_type.value] || {};
|
||||
return {
|
||||
started: {
|
||||
message: $scope.started_message === defaults.started.message ?
|
||||
null : $scope.started_message,
|
||||
body: $scope.started_body === defaults.started.body ?
|
||||
null : $scope.started_body,
|
||||
message: getMessageIfUpdated($scope.started_message, defaults.started.message),
|
||||
body: getMessageIfUpdated($scope.started_body, defaults.started.body),
|
||||
},
|
||||
success: {
|
||||
message: $scope.success_message === defaults.success.message ?
|
||||
null : $scope.success_message,
|
||||
body: $scope.success_body === defaults.success.body ?
|
||||
null : $scope.success_body,
|
||||
message: getMessageIfUpdated($scope.success_message, defaults.success.message),
|
||||
body: getMessageIfUpdated($scope.success_body, defaults.success.body),
|
||||
},
|
||||
error: {
|
||||
message: $scope.error_message === defaults.error.message ?
|
||||
null : $scope.error_message,
|
||||
body: $scope.error_body === defaults.error.body ?
|
||||
null : $scope.error_body,
|
||||
message: getMessageIfUpdated($scope.error_message, defaults.error.message),
|
||||
body: getMessageIfUpdated($scope.error_body, defaults.error.body),
|
||||
},
|
||||
workflow_approval: {
|
||||
approved: {
|
||||
message: getMessageIfUpdated($scope.approved_message, defaults.workflow_approval.approved.message),
|
||||
body: getMessageIfUpdated($scope.approved_body, defaults.workflow_approval.approved.body),
|
||||
},
|
||||
denied: {
|
||||
message: getMessageIfUpdated($scope.denied_message, defaults.workflow_approval.denied.message),
|
||||
body: getMessageIfUpdated($scope.denied_body, defaults.workflow_approval.denied.body),
|
||||
},
|
||||
running: {
|
||||
message: getMessageIfUpdated($scope.running_message, defaults.workflow_approval.running.message),
|
||||
body: getMessageIfUpdated($scope.running_body, defaults.workflow_approval.running.body),
|
||||
},
|
||||
timed_out: {
|
||||
message: getMessageIfUpdated($scope.timed_out_message, defaults.workflow_approval.timed_out.message),
|
||||
body: getMessageIfUpdated($scope.timed_out_body, defaults.workflow_approval.timed_out.body),
|
||||
},
|
||||
}
|
||||
};
|
||||
},
|
||||
@ -56,6 +69,15 @@ export default [function() {
|
||||
$scope.success_body = defaults.success.body;
|
||||
$scope.error_message = defaults.error.message;
|
||||
$scope.error_body = defaults.error.body;
|
||||
$scope.approved_message = defaults.workflow_approval.approved.message;
|
||||
$scope.approved_body = defaults.workflow_approval.approved.body;
|
||||
$scope.denied_message = defaults.workflow_approval.denied.message;
|
||||
$scope.denied_body = defaults.workflow_approval.denied.body;
|
||||
$scope.running_message = defaults.workflow_approval.running.message;
|
||||
$scope.running_body = defaults.workflow_approval.running.body;
|
||||
$scope.timed_out_message = defaults.workflow_approval.timed_out.message;
|
||||
$scope.timed_out_body = defaults.workflow_approval.timed_out.body;
|
||||
|
||||
if (!messages) {
|
||||
return;
|
||||
}
|
||||
@ -84,6 +106,48 @@ export default [function() {
|
||||
isCustomized = true;
|
||||
$scope.error_body = messages.error.body;
|
||||
}
|
||||
if (messages.workflow_approval) {
|
||||
if (messages.workflow_approval.approved
|
||||
&& messages.workflow_approval.approved.message) {
|
||||
isCustomized = true;
|
||||
$scope.approved_message = messages.workflow_approval.approved.message;
|
||||
}
|
||||
if (messages.workflow_approval.approved
|
||||
&& messages.workflow_approval.approved.body) {
|
||||
isCustomized = true;
|
||||
$scope.approved_body = messages.workflow_approval.approved.body;
|
||||
}
|
||||
if (messages.workflow_approval.denied
|
||||
&& messages.workflow_approval.denied.message) {
|
||||
isCustomized = true;
|
||||
$scope.denied_message = messages.workflow_approval.denied.message;
|
||||
}
|
||||
if (messages.workflow_approval.denied
|
||||
&& messages.workflow_approval.denied.body) {
|
||||
isCustomized = true;
|
||||
$scope.denied_body = messages.workflow_approval.denied.body;
|
||||
}
|
||||
if (messages.workflow_approval.running
|
||||
&& messages.workflow_approval.running.message) {
|
||||
isCustomized = true;
|
||||
$scope.running_message = messages.workflow_approval.running.message;
|
||||
}
|
||||
if (messages.workflow_approval.running
|
||||
&& messages.workflow_approval.running.body) {
|
||||
isCustomized = true;
|
||||
$scope.running_body = messages.workflow_approval.running.body;
|
||||
}
|
||||
if (messages.workflow_approval.timed_out
|
||||
&& messages.workflow_approval.timed_out.message) {
|
||||
isCustomized = true;
|
||||
$scope.timed_out_message = messages.workflow_approval.timed_out.message;
|
||||
}
|
||||
if (messages.workflow_approval.timed_out
|
||||
&& messages.workflow_approval.timed_out.body) {
|
||||
isCustomized = true;
|
||||
$scope.timed_out_body = messages.workflow_approval.timed_out.body;
|
||||
}
|
||||
}
|
||||
$scope.customize_messages = isCustomized;
|
||||
},
|
||||
|
||||
@ -110,6 +174,30 @@ export default [function() {
|
||||
if ($scope.error_body === oldDefaults.error.body) {
|
||||
$scope.error_body = newDefaults.error.body;
|
||||
}
|
||||
if ($scope.approved_message === oldDefaults.workflow_approval.approved.message) {
|
||||
$scope.approved_message = newDefaults.workflow_approval.approved.message;
|
||||
}
|
||||
if ($scope.approved_body === oldDefaults.workflow_approval.approved.body) {
|
||||
$scope.approved_body = newDefaults.workflow_approval.approved.body;
|
||||
}
|
||||
if ($scope.denied_message === oldDefaults.workflow_approval.denied.message) {
|
||||
$scope.denied_message = newDefaults.workflow_approval.denied.message;
|
||||
}
|
||||
if ($scope.denied_body === oldDefaults.workflow_approval.denied.body) {
|
||||
$scope.denied_body = newDefaults.workflow_approval.denied.body;
|
||||
}
|
||||
if ($scope.running_message === oldDefaults.workflow_approval.running.message) {
|
||||
$scope.running_message = newDefaults.workflow_approval.running.message;
|
||||
}
|
||||
if ($scope.running_body === oldDefaults.workflow_approval.running.body) {
|
||||
$scope.running_body = newDefaults.workflow_approval.running.body;
|
||||
}
|
||||
if ($scope.timed_out_message === oldDefaults.workflow_approval.timed_out.message) {
|
||||
$scope.timed_out_message = newDefaults.workflow_approval.timed_out.message;
|
||||
}
|
||||
if ($scope.timed_out_body === oldDefaults.workflow_approval.timed_out.body) {
|
||||
$scope.timed_out_body = newDefaults.workflow_approval.timed_out.body;
|
||||
}
|
||||
}
|
||||
};
|
||||
}];
|
||||
|
Loading…
Reference in New Issue
Block a user