mirror of
https://github.com/ansible/awx.git
synced 2026-03-28 14:25:05 -02:30
Merge pull request #6694 from mabashian/5717-insights-cred-project
Auto populate insights credential when creating insights project
This commit is contained in:
@@ -116,9 +116,12 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm',
|
|||||||
$scope.pathRequired = ($scope.scm_type.value === 'manual') ? true : false;
|
$scope.pathRequired = ($scope.scm_type.value === 'manual') ? true : false;
|
||||||
$scope.scmRequired = ($scope.scm_type.value !== 'manual') ? true : false;
|
$scope.scmRequired = ($scope.scm_type.value !== 'manual') ? true : false;
|
||||||
$scope.scmBranchLabel = ($scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
|
$scope.scmBranchLabel = ($scope.scm_type.value === 'svn') ? 'Revision #' : 'SCM Branch';
|
||||||
|
|
||||||
// Dynamically update popover values
|
// Dynamically update popover values
|
||||||
if ($scope.scm_type.value) {
|
if ($scope.scm_type.value) {
|
||||||
|
if(($scope.lookupType === 'insights_credential' && $scope.scm_type.value !== 'insights') || ($scope.lookupType === 'scm_credential' && $scope.scm_type.value === 'insights')) {
|
||||||
|
$scope.credential = null;
|
||||||
|
$scope.credential_name = '';
|
||||||
|
}
|
||||||
switch ($scope.scm_type.value) {
|
switch ($scope.scm_type.value) {
|
||||||
case 'git':
|
case 'git':
|
||||||
$scope.credentialLabel = "SCM Credential";
|
$scope.credentialLabel = "SCM Credential";
|
||||||
@@ -129,12 +132,16 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm',
|
|||||||
'<p>' + i18n.sprintf(i18n._('%sNote:%s When using SSH protocol for GitHub or Bitbucket, enter an SSH key only, ' +
|
'<p>' + i18n.sprintf(i18n._('%sNote:%s When using SSH protocol for GitHub or Bitbucket, enter an SSH key only, ' +
|
||||||
'do not enter a username (other than git). Additionally, GitHub and Bitbucket do not support password authentication when using ' +
|
'do not enter a username (other than git). Additionally, GitHub and Bitbucket do not support password authentication when using ' +
|
||||||
'SSH. GIT read only protocol (git://) does not use username or password information.'), '<strong>', '</strong>');
|
'SSH. GIT read only protocol (git://) does not use username or password information.'), '<strong>', '</strong>');
|
||||||
|
$scope.credRequired = false;
|
||||||
|
$scope.lookupType = 'scm_credential';
|
||||||
break;
|
break;
|
||||||
case 'svn':
|
case 'svn':
|
||||||
$scope.credentialLabel = "SCM Credential";
|
$scope.credentialLabel = "SCM Credential";
|
||||||
$scope.urlPopover = '<p>' + i18n._('Example URLs for Subversion SCM include:') + '</p>' +
|
$scope.urlPopover = '<p>' + i18n._('Example URLs for Subversion SCM include:') + '</p>' +
|
||||||
'<ul class=\"no-bullets\"><li>https://github.com/ansible/ansible</li><li>svn://servername.example.com/path</li>' +
|
'<ul class=\"no-bullets\"><li>https://github.com/ansible/ansible</li><li>svn://servername.example.com/path</li>' +
|
||||||
'<li>svn+ssh://servername.example.com/path</li></ul>';
|
'<li>svn+ssh://servername.example.com/path</li></ul>';
|
||||||
|
$scope.credRequired = false;
|
||||||
|
$scope.lookupType = 'scm_credential';
|
||||||
break;
|
break;
|
||||||
case 'hg':
|
case 'hg':
|
||||||
$scope.credentialLabel = "SCM Credential";
|
$scope.credentialLabel = "SCM Credential";
|
||||||
@@ -144,16 +151,21 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm',
|
|||||||
'<p>' + i18n.sprintf(i18n._('%sNote:%s Mercurial does not support password authentication for SSH. ' +
|
'<p>' + i18n.sprintf(i18n._('%sNote:%s Mercurial does not support password authentication for SSH. ' +
|
||||||
'Do not put the username and key in the URL. ' +
|
'Do not put the username and key in the URL. ' +
|
||||||
'If using Bitbucket and SSH, do not supply your Bitbucket username.'), '<strong>', '</strong>');
|
'If using Bitbucket and SSH, do not supply your Bitbucket username.'), '<strong>', '</strong>');
|
||||||
|
$scope.credRequired = false;
|
||||||
|
$scope.lookupType = 'scm_credential';
|
||||||
break;
|
break;
|
||||||
case 'insights':
|
case 'insights':
|
||||||
$scope.pathRequired = false;
|
$scope.pathRequired = false;
|
||||||
$scope.scmRequired = false;
|
$scope.scmRequired = false;
|
||||||
$scope.credRequired = true;
|
$scope.credRequired = true;
|
||||||
$scope.credentialLabel = "Credential";
|
$scope.credentialLabel = "Credential";
|
||||||
break;
|
$scope.lookupType = 'insights_credential';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$scope.credentialLabel = "SCM Credential";
|
$scope.credentialLabel = "SCM Credential";
|
||||||
$scope.urlPopover = '<p> ' + i18n._('URL popover text') + '</p>';
|
$scope.urlPopover = '<p> ' + i18n._('URL popover text') + '</p>';
|
||||||
|
$scope.credRequired = false;
|
||||||
|
$scope.lookupType = 'scm_credential';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,6 +251,10 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
|
|||||||
|
|
||||||
// Dynamically update popover values
|
// Dynamically update popover values
|
||||||
if ($scope.scm_type.value) {
|
if ($scope.scm_type.value) {
|
||||||
|
if(($scope.lookupType === 'insights_credential' && $scope.scm_type.value !== 'insights') || ($scope.lookupType === 'scm_credential' && $scope.scm_type.value === 'insights')) {
|
||||||
|
$scope.credential = null;
|
||||||
|
$scope.credential_name = '';
|
||||||
|
}
|
||||||
switch ($scope.scm_type.value) {
|
switch ($scope.scm_type.value) {
|
||||||
case 'git':
|
case 'git':
|
||||||
$scope.credentialLabel = "SCM Credential";
|
$scope.credentialLabel = "SCM Credential";
|
||||||
@@ -259,12 +263,16 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
|
|||||||
'<p>' + i18n.sprintf(i18n._('%sNote:%s When using SSH protocol for GitHub or Bitbucket, enter an SSH key only, ' +
|
'<p>' + i18n.sprintf(i18n._('%sNote:%s When using SSH protocol for GitHub or Bitbucket, enter an SSH key only, ' +
|
||||||
'do not enter a username (other than git). Additionally, GitHub and Bitbucket do not support password authentication when using ' +
|
'do not enter a username (other than git). Additionally, GitHub and Bitbucket do not support password authentication when using ' +
|
||||||
'SSH. GIT read only protocol (git://) does not use username or password information.'), '<strong>', '</strong>');
|
'SSH. GIT read only protocol (git://) does not use username or password information.'), '<strong>', '</strong>');
|
||||||
|
$scope.credRequired = false;
|
||||||
|
$scope.lookupType = 'scm_credential';
|
||||||
break;
|
break;
|
||||||
case 'svn':
|
case 'svn':
|
||||||
$scope.credentialLabel = "SCM Credential";
|
$scope.credentialLabel = "SCM Credential";
|
||||||
$scope.urlPopover = '<p>' + i18n._('Example URLs for Subversion SCM include:') + '</p>' +
|
$scope.urlPopover = '<p>' + i18n._('Example URLs for Subversion SCM include:') + '</p>' +
|
||||||
'<ul class=\"no-bullets\"><li>https://github.com/ansible/ansible</li><li>svn://servername.example.com/path</li>' +
|
'<ul class=\"no-bullets\"><li>https://github.com/ansible/ansible</li><li>svn://servername.example.com/path</li>' +
|
||||||
'<li>svn+ssh://servername.example.com/path</li></ul>';
|
'<li>svn+ssh://servername.example.com/path</li></ul>';
|
||||||
|
$scope.credRequired = false;
|
||||||
|
$scope.lookupType = 'scm_credential';
|
||||||
break;
|
break;
|
||||||
case 'hg':
|
case 'hg':
|
||||||
$scope.credentialLabel = "SCM Credential";
|
$scope.credentialLabel = "SCM Credential";
|
||||||
@@ -274,16 +282,21 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
|
|||||||
'<p>' + i18n.sprintf(i18n._('%sNote:%s Mercurial does not support password authentication for SSH. ' +
|
'<p>' + i18n.sprintf(i18n._('%sNote:%s Mercurial does not support password authentication for SSH. ' +
|
||||||
'Do not put the username and key in the URL. ' +
|
'Do not put the username and key in the URL. ' +
|
||||||
'If using Bitbucket and SSH, do not supply your Bitbucket username.'), '<strong>', '</strong>');
|
'If using Bitbucket and SSH, do not supply your Bitbucket username.'), '<strong>', '</strong>');
|
||||||
|
$scope.credRequired = false;
|
||||||
|
$scope.lookupType = 'scm_credential';
|
||||||
break;
|
break;
|
||||||
case 'insights':
|
case 'insights':
|
||||||
$scope.pathRequired = false;
|
$scope.pathRequired = false;
|
||||||
$scope.scmRequired = false;
|
$scope.scmRequired = false;
|
||||||
$scope.credRequired = true;
|
$scope.credRequired = true;
|
||||||
$scope.credentialLabel = "Credential";
|
$scope.credentialLabel = "Credential";
|
||||||
break;
|
$scope.lookupType = 'insights_credential';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$scope.credentialLabel = "SCM Credential";
|
$scope.credentialLabel = "SCM Credential";
|
||||||
$scope.urlPopover = '<p> ' + i18n._('URL popover text');
|
$scope.urlPopover = '<p> ' + i18n._('URL popover text');
|
||||||
|
$scope.credRequired = false;
|
||||||
|
$scope.lookupType = 'scm_credential';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,14 +135,13 @@ export default ['i18n', 'NotificationsList', function(i18n, NotificationsList) {
|
|||||||
// kind: 'scm'
|
// kind: 'scm'
|
||||||
// },
|
// },
|
||||||
ngClick: 'lookupCredential()',
|
ngClick: 'lookupCredential()',
|
||||||
autopopulateLookup: false,
|
|
||||||
awRequiredWhen: {
|
awRequiredWhen: {
|
||||||
reqExpression: "credRequired",
|
reqExpression: "credRequired",
|
||||||
init: false
|
init: false
|
||||||
},
|
},
|
||||||
ngShow: "scm_type && scm_type.value !== 'manual'",
|
ngShow: "scm_type && scm_type.value !== 'manual'",
|
||||||
sourceModel: 'credential',
|
sourceModel: 'credential',
|
||||||
awLookupType: 'scm_credential',
|
awLookupType: '{{lookupType}}',
|
||||||
sourceField: 'name',
|
sourceField: 'name',
|
||||||
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)',
|
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)',
|
||||||
subForm: 'sourceSubForm'
|
subForm: 'sourceSubForm'
|
||||||
|
|||||||
@@ -491,7 +491,6 @@ function(ConfigurationUtils, i18n, $rootScope) {
|
|||||||
autopopulateLookup,
|
autopopulateLookup,
|
||||||
modelKey = attrs.ngModel,
|
modelKey = attrs.ngModel,
|
||||||
modelName = attrs.source,
|
modelName = attrs.source,
|
||||||
lookupType = attrs.awlookuptype,
|
|
||||||
watcher = attrs.awRequiredWhen || undefined,
|
watcher = attrs.awRequiredWhen || undefined,
|
||||||
watchBasePath,
|
watchBasePath,
|
||||||
awLookupWhen = attrs.awLookupWhen;
|
awLookupWhen = attrs.awLookupWhen;
|
||||||
@@ -534,16 +533,20 @@ function(ConfigurationUtils, i18n, $rootScope) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
basePath = GetBasePath(elm.attr('data-basePath')) || elm.attr('data-basePath');
|
basePath = GetBasePath(elm.attr('data-basePath')) || elm.attr('data-basePath');
|
||||||
let switchType = lookupType ? lookupType : modelName;
|
let switchType = attrs.awlookuptype ? attrs.awlookuptype : modelName;console.log(switchType);
|
||||||
|
|
||||||
switch(switchType) {
|
switch(switchType) {
|
||||||
case 'credential':
|
case 'credential':
|
||||||
query = '?kind=ssh&role_level=use_role';
|
query = '?credential_type__kind=ssh&role_level=use_role';
|
||||||
break;
|
break;
|
||||||
case 'scm_credential':
|
case 'scm_credential':
|
||||||
query = '?kind=scm&role_level=use_role';
|
query = '?credential_type__kind=scm&role_level=use_role';
|
||||||
break;
|
break;
|
||||||
case 'network_credential':
|
case 'network_credential':
|
||||||
query = '?kind=net&role_level=use_role';
|
query = '?credential_type__kind=net&role_level=use_role';
|
||||||
|
break;
|
||||||
|
case 'insights_credential':
|
||||||
|
query = '?credential_type__kind=insights&role_level=use_role';
|
||||||
break;
|
break;
|
||||||
case 'organization':
|
case 'organization':
|
||||||
query = '?role_level=admin_role';
|
query = '?role_level=admin_role';
|
||||||
@@ -628,7 +631,7 @@ function(ConfigurationUtils, i18n, $rootScope) {
|
|||||||
query = elm.attr('data-query');
|
query = elm.attr('data-query');
|
||||||
query = query.replace(/\:value/, encodeURIComponent(viewValue));
|
query = query.replace(/\:value/, encodeURIComponent(viewValue));
|
||||||
|
|
||||||
let base = lookupType ? lookupType : ctrl.$name.split('_name')[0];
|
let base = attrs.awlookuptype ? attrs.awlookuptype : ctrl.$name.split('_name')[0];
|
||||||
if (attrs.watchbasepath !== undefined && scope[attrs.watchbasepath] !== undefined) {
|
if (attrs.watchbasepath !== undefined && scope[attrs.watchbasepath] !== undefined) {
|
||||||
basePath = scope[attrs.watchbasepath];
|
basePath = scope[attrs.watchbasepath];
|
||||||
query += '&role_level=use_role';
|
query += '&role_level=use_role';
|
||||||
|
|||||||
Reference in New Issue
Block a user