mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
implement model-based credential copy
This commit is contained in:
@@ -69,7 +69,15 @@ export default ['i18n', function(i18n) {
|
|||||||
dataPlacement: 'top',
|
dataPlacement: 'top',
|
||||||
ngShow: 'credential.summary_fields.user_capabilities.edit'
|
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: {
|
view: {
|
||||||
ngClick: "editCredential(credential.id)",
|
ngClick: "editCredential(credential.id)",
|
||||||
label: i18n._('View'),
|
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() {
|
$scope.addCredential = function() {
|
||||||
$state.go('credentials.add');
|
$state.go('credentials.add');
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user