mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
implement model-based copy for notification templates
This commit is contained in:
parent
29f1d695ae
commit
09d3e6cd98
@ -7,12 +7,12 @@
|
||||
export default ['$scope', 'Wait', 'NotificationTemplatesList',
|
||||
'GetBasePath', 'Rest', 'ProcessErrors', 'Prompt', '$state',
|
||||
'ngToast', '$filter', 'Dataset', 'rbacUiControlService',
|
||||
'i18n', 'NotificationTemplateModel',
|
||||
'i18n', 'NotificationTemplate',
|
||||
function(
|
||||
$scope, Wait, NotificationTemplatesList,
|
||||
GetBasePath, Rest, ProcessErrors, Prompt, $state,
|
||||
ngToast, $filter, Dataset, rbacUiControlService,
|
||||
i18n) {
|
||||
i18n, NotificationTemplate) {
|
||||
|
||||
var defaultUrl = GetBasePath('notification_templates'),
|
||||
list = NotificationTemplatesList;
|
||||
@ -88,6 +88,24 @@
|
||||
notification_template.template_status_html = html;
|
||||
}
|
||||
|
||||
$scope.copyNotification = notificationTemplate => {
|
||||
Wait('start');
|
||||
new NotificationTemplate('get', notificationTemplate.id)
|
||||
.then(model => model.copy())
|
||||
.then(({ id }) => {
|
||||
const params = {
|
||||
notification_template_id: id,
|
||||
notification_template: this.notification_templates
|
||||
};
|
||||
$state.go('notifications.edit', params, { reload: true });
|
||||
})
|
||||
.catch(({ data, status }) => {
|
||||
const params = { hdr: 'Error!', msg: `Call to copy failed. Return status: ${status}` };
|
||||
ProcessErrors($scope, data, status, null, params);
|
||||
})
|
||||
.finally(() => Wait('stop'));
|
||||
};
|
||||
|
||||
$scope.testNotification = function() {
|
||||
var name = $filter('sanitize')(this.notification_template.name),
|
||||
pending_retries = 10;
|
||||
@ -152,6 +170,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$scope.addNotification = function() {
|
||||
$state.go('notifications.add');
|
||||
};
|
||||
|
@ -77,6 +77,15 @@ export default ['i18n', function(i18n){
|
||||
dataPlacement: 'top',
|
||||
ngShow: 'notification_template.summary_fields.user_capabilities.edit'
|
||||
},
|
||||
copy: {
|
||||
label: i18n._('Copy'),
|
||||
ngClick: 'copyNotification(notification_template)',
|
||||
"class": 'btn-danger btn-xs',
|
||||
awToolTip: i18n._('Copy notification'),
|
||||
dataPlacement: 'top',
|
||||
// requires future api rbac changes
|
||||
//ngShow: 'notification_template.summary_fields.user_capabilities.copy'
|
||||
},
|
||||
view: {
|
||||
ngClick: "editNotification(notification_template.id)",
|
||||
label: i18n._('View'),
|
||||
|
Loading…
Reference in New Issue
Block a user