mirror of
https://github.com/ansible/awx.git
synced 2026-01-19 21:51:26 -03:30
Merge pull request #3490 from jakemcdermott/fix-3487
handle insights credential lookups for projects
This commit is contained in:
commit
231c76c9cb
@ -7,10 +7,10 @@
|
||||
export default ['$scope', '$location', '$stateParams', 'GenerateForm',
|
||||
'ProjectsForm', 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath',
|
||||
'GetProjectPath', 'GetChoices', 'Wait', '$state', 'CreateSelect2', 'i18n',
|
||||
'ConfigData', 'resolvedModels', 'scmCredentialType',
|
||||
'ConfigData', 'resolvedModels', 'scmCredentialType', 'insightsCredentialType',
|
||||
function($scope, $location, $stateParams, GenerateForm, ProjectsForm, Rest,
|
||||
Alert, ProcessErrors, GetBasePath, GetProjectPath, GetChoices, Wait, $state,
|
||||
CreateSelect2, i18n, ConfigData, resolvedModels, scmCredentialType) {
|
||||
CreateSelect2, i18n, ConfigData, resolvedModels, scmCredentialType, insightsCredentialType) {
|
||||
|
||||
let form = ProjectsForm(),
|
||||
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||
@ -191,9 +191,13 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm',
|
||||
$scope.lookupCredential = function(){
|
||||
// Perform a lookup on the credential_type. Git, Mercurial, and Subversion
|
||||
// all use SCM as their credential type.
|
||||
let lookupCredentialType = scmCredentialType;
|
||||
if ($scope.scm_type.value === 'insights') {
|
||||
lookupCredentialType = insightsCredentialType;
|
||||
}
|
||||
$state.go('.credential', {
|
||||
credential_search: {
|
||||
credential_type: scmCredentialType,
|
||||
credential_type: lookupCredentialType,
|
||||
page_size: '5',
|
||||
page: '1'
|
||||
}
|
||||
|
||||
@ -8,12 +8,12 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
|
||||
'Alert', 'ProcessErrors', 'GenerateForm', 'Prompt', 'isNotificationAdmin',
|
||||
'GetBasePath', 'GetProjectPath', 'Authorization', 'GetChoices', 'Empty',
|
||||
'Wait', 'ProjectUpdate', '$state', 'CreateSelect2', 'ToggleNotification',
|
||||
'i18n', 'OrgAdminLookup', 'ConfigData', 'scmCredentialType',
|
||||
'i18n', 'OrgAdminLookup', 'ConfigData', 'scmCredentialType', 'insightsCredentialType',
|
||||
function($scope, $rootScope, $stateParams, ProjectsForm, Rest, Alert,
|
||||
ProcessErrors, GenerateForm, Prompt, isNotificationAdmin, GetBasePath,
|
||||
GetProjectPath, Authorization, GetChoices, Empty, Wait, ProjectUpdate,
|
||||
$state, CreateSelect2, ToggleNotification, i18n, OrgAdminLookup,
|
||||
ConfigData, scmCredentialType) {
|
||||
ConfigData, scmCredentialType, insightsCredentialType) {
|
||||
|
||||
let form = ProjectsForm(),
|
||||
defaultUrl = GetBasePath('projects') + $stateParams.project_id + '/',
|
||||
@ -310,10 +310,13 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
|
||||
$scope.lookupCredential = function(){
|
||||
// Perform a lookup on the credential_type. Git, Mercurial, and Subversion
|
||||
// all use SCM as their credential type.
|
||||
|
||||
let lookupCredentialType = scmCredentialType;
|
||||
if ($scope.scm_type.value === 'insights') {
|
||||
lookupCredentialType = insightsCredentialType;
|
||||
}
|
||||
$state.go('.credential', {
|
||||
credential_search: {
|
||||
credential_type: scmCredentialType,
|
||||
credential_type: lookupCredentialType,
|
||||
page_size: '5',
|
||||
page: '1'
|
||||
}
|
||||
|
||||
@ -36,7 +36,23 @@ function ResolveScmCredentialType (GetBasePath, Rest, ProcessErrors) {
|
||||
});
|
||||
}
|
||||
|
||||
function ResolveInsightsCredentialType (GetBasePath, Rest, ProcessErrors) {
|
||||
Rest.setUrl(GetBasePath('credential_types') + '?name=Insights');
|
||||
|
||||
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
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ResolveScmCredentialType.$inject = ['GetBasePath', 'Rest', 'ProcessErrors'];
|
||||
ResolveInsightsCredentialType.$inject = ['GetBasePath', 'Rest', 'ProcessErrors'];
|
||||
|
||||
|
||||
export default
|
||||
@ -70,6 +86,7 @@ angular.module('Projects', [])
|
||||
const stateIndex = res.states.findIndex(s => s.name === projectsAddName);
|
||||
|
||||
res.states[stateIndex].resolve.scmCredentialType = ResolveScmCredentialType;
|
||||
res.states[stateIndex].resolve.insightsCredentialType = ResolveInsightsCredentialType;
|
||||
|
||||
return res;
|
||||
});
|
||||
@ -113,6 +130,7 @@ angular.module('Projects', [])
|
||||
const stateIndex = res.states.findIndex(s => s.name === projectsEditName);
|
||||
|
||||
res.states[stateIndex].resolve.scmCredentialType = ResolveScmCredentialType;
|
||||
res.states[stateIndex].resolve.insightsCredentialType = ResolveInsightsCredentialType;
|
||||
|
||||
return res;
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user