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