mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 12:41:19 -03:30
implement model-based credential copy
This commit is contained in:
parent
21a32f90ce
commit
50d95ddc3f
@ -69,7 +69,15 @@ export default ['i18n', function(i18n) {
|
||||
dataPlacement: 'top',
|
||||
ngShow: 'credential.summary_fields.user_capabilities.edit'
|
||||
},
|
||||
|
||||
copy: {
|
||||
label: i18n._('Copy'),
|
||||
ngClick: 'copyCredential(credential)',
|
||||
"class": 'btn-danger btn-xs',
|
||||
awToolTip: i18n._('Copy credential'),
|
||||
dataPlacement: 'top',
|
||||
// requires future api rbac changes
|
||||
//ngShow: 'credential.summary_fields.user_capabilities.copy'
|
||||
},
|
||||
view: {
|
||||
ngClick: "editCredential(credential.id)",
|
||||
label: i18n._('View'),
|
||||
|
||||
@ -89,6 +89,21 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
|
||||
}
|
||||
}
|
||||
|
||||
$scope.copyCredential = credential => {
|
||||
Wait('start');
|
||||
new Credential('get', credential.id)
|
||||
.then(model => model.copy())
|
||||
.then(({ id }) => {
|
||||
const params = { credential_id: id };
|
||||
$state.go('credentials.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.addCredential = function() {
|
||||
$state.go('credentials.add');
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user