mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 03:10:42 -03:30
fix adhoc command cred lookup when many credential types exist
This commit is contained in:
parent
0f85c867a0
commit
ceb9bfe486
@ -12,7 +12,7 @@
|
||||
function adhocController($q, $scope, $stateParams,
|
||||
$state, CheckPasswords, PromptForPasswords, CreateLaunchDialog, CreateSelect2, adhocForm,
|
||||
GenerateForm, Rest, ProcessErrors, GetBasePath, GetChoices,
|
||||
KindChange, Wait, ParseTypeChange, credentialTypes) {
|
||||
KindChange, Wait, ParseTypeChange, machineCredentialType) {
|
||||
|
||||
// this is done so that we can access private functions for testing, but
|
||||
// we don't want to populate the "public" scope with these internal
|
||||
@ -302,12 +302,9 @@ function adhocController($q, $scope, $stateParams,
|
||||
};
|
||||
|
||||
$scope.lookupCredential = function(){
|
||||
let credType = _.filter(credentialTypes, function(credType){
|
||||
return credType.kind === "ssh";
|
||||
});
|
||||
$state.go('.credential', {
|
||||
credential_search: {
|
||||
credential_type: credType[0].id,
|
||||
credential_type: machineCredentialType,
|
||||
page_size: '5',
|
||||
page: '1'
|
||||
}
|
||||
@ -319,5 +316,5 @@ function adhocController($q, $scope, $stateParams,
|
||||
export default ['$q', '$scope', '$stateParams',
|
||||
'$state', 'CheckPasswords', 'PromptForPasswords', 'CreateLaunchDialog', 'CreateSelect2',
|
||||
'adhocForm', 'GenerateForm', 'Rest', 'ProcessErrors', 'GetBasePath',
|
||||
'GetChoices', 'KindChange', 'Wait', 'ParseTypeChange', 'credentialTypes',
|
||||
'GetChoices', 'KindChange', 'Wait', 'ParseTypeChange', 'machineCredentialType',
|
||||
adhocController];
|
||||
|
||||
@ -7,6 +7,23 @@
|
||||
import {templateUrl} from '../../../shared/template-url/template-url.factory';
|
||||
import { N_ } from '../../../i18n';
|
||||
|
||||
function ResolveMachineCredentialType (GetBasePath, Rest, ProcessErrors) {
|
||||
Rest.setUrl(GetBasePath('credential_types') + '?kind=ssh');
|
||||
|
||||
return Rest.get()
|
||||
.then(({ data }) => {
|
||||
return data.results[0].id;
|
||||
})
|
||||
.catch(({ data, status }) => {
|
||||
ProcessErrors(null, data, status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Failed to get credential type data: ' + status
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ResolveMachineCredentialType.$inject = ['GetBasePath', 'Rest', 'ProcessErrors'];
|
||||
|
||||
export default {
|
||||
url: '/adhoc',
|
||||
params:{
|
||||
@ -28,12 +45,6 @@ export default {
|
||||
label: N_("RUN COMMAND")
|
||||
},
|
||||
resolve: {
|
||||
credentialTypes: ['CredentialTypeModel', (CredentialType) =>
|
||||
new CredentialType('get')
|
||||
.then((model) => {
|
||||
const credentialTypeRes = model.get();
|
||||
return credentialTypeRes.results;
|
||||
})
|
||||
]
|
||||
machineCredentialType: ResolveMachineCredentialType,
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user