mirror of
https://github.com/ansible/awx.git
synced 2026-04-10 12:39:22 -02:30
Merge pull request #4265 from AlanCoding/branch_feature_phase_2
Allow JT specification and prompting for project branch Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
@@ -343,6 +343,28 @@ function getProjectUpdateDetails (updateId) {
|
||||
return { link, tooltip };
|
||||
}
|
||||
|
||||
function getSCMBranchDetails (scmBranch) {
|
||||
const label = strings.get('labels.SCM_BRANCH');
|
||||
const value = scmBranch || resource.model.get('scm_branch');
|
||||
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return { label, value };
|
||||
}
|
||||
|
||||
function getSCMRefspecDetails (scmRefspec) {
|
||||
const label = strings.get('labels.SCM_REFSPEC');
|
||||
const value = scmRefspec || resource.model.get('scm_refspec');
|
||||
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return { label, value };
|
||||
}
|
||||
|
||||
function getInventoryScmDetails (updateId, updateStatus) {
|
||||
const projectId = resource.model.get('summary_fields.source_project.id');
|
||||
const projectName = resource.model.get('summary_fields.source_project.name');
|
||||
@@ -800,6 +822,8 @@ function JobDetailsController (
|
||||
vm.project = getProjectDetails();
|
||||
vm.projectUpdate = getProjectUpdateDetails();
|
||||
vm.projectStatus = getProjectStatusDetails();
|
||||
vm.scmBranch = getSCMBranchDetails();
|
||||
vm.scmRefspec = getSCMRefspecDetails();
|
||||
vm.scmRevision = getSCMRevisionDetails();
|
||||
vm.inventoryScm = getInventoryScmDetails();
|
||||
vm.playbook = getPlaybookDetails();
|
||||
@@ -840,6 +864,8 @@ function JobDetailsController (
|
||||
started,
|
||||
finished,
|
||||
scm,
|
||||
scmBranch,
|
||||
scmRefspec,
|
||||
inventoryScm,
|
||||
scmRevision,
|
||||
instanceGroup,
|
||||
@@ -851,6 +877,8 @@ function JobDetailsController (
|
||||
vm.finished = getFinishDetails(finished);
|
||||
vm.projectUpdate = getProjectUpdateDetails(scm.id);
|
||||
vm.projectStatus = getProjectStatusDetails(scm.status);
|
||||
vm.scmBranch = getSCMBranchDetails(scmBranch);
|
||||
vm.scmRefspec = getSCMRefspecDetails(scmRefspec);
|
||||
vm.environment = getEnvironmentDetails(environment);
|
||||
vm.artifacts = getArtifactsDetails(artifacts);
|
||||
vm.executionNode = getExecutionNodeDetails(executionNode);
|
||||
|
||||
@@ -218,6 +218,18 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BRANCH DETAIL -->
|
||||
<div class="JobResults-resultRow" ng-if="vm.scmBranch">
|
||||
<label class="JobResults-resultRowLabel">{{ vm.scmBranch.label }}</label>
|
||||
<div class="JobResults-resultRowText">{{ vm.scmBranch.value }}</div>
|
||||
</div>
|
||||
|
||||
<!-- REFSPEC DETAIL -->
|
||||
<div class="JobResults-resultRow" ng-if="vm.scmRefspec">
|
||||
<label class="JobResults-resultRowLabel">{{ vm.scmRefspec.label }}</label>
|
||||
<div class="JobResults-resultRowText">{{ vm.scmRefspec.value }}</div>
|
||||
</div>
|
||||
|
||||
<!-- INVENTORY SCM DETAIL -->
|
||||
<div class="JobResults-resultRow" ng-if="!vm.project && vm.inventoryScm">
|
||||
<label class="JobResults-resultRowLabel">{{ vm.inventoryScm.label }}</label>
|
||||
|
||||
@@ -78,6 +78,8 @@ function OutputStrings (BaseString) {
|
||||
OVERWRITE_VARS: t.s('Overwrite Vars'),
|
||||
PLAYBOOK: t.s('Playbook'),
|
||||
PROJECT: t.s('Project'),
|
||||
SCM_BRANCH: t.s('Branch'),
|
||||
SCM_REFSPEC: t.s('Refspec'),
|
||||
RESULT_TRACEBACK: t.s('Error Details'),
|
||||
SCM_REVISION: t.s('Revision'),
|
||||
SKIP_TAGS: t.s('Skip Tags'),
|
||||
|
||||
@@ -45,6 +45,8 @@ function JobStatusService (moment, message) {
|
||||
id: model.get('summary_fields.project_update.id'),
|
||||
status: model.get('summary_fields.project_update.status')
|
||||
},
|
||||
scmBranch: model.get('scm_branch'),
|
||||
scmRefspec: model.get('scm_refspec'),
|
||||
inventoryScm: {
|
||||
id: model.get('source_project_update'),
|
||||
status: model.get('summary_fields.inventory_source.status')
|
||||
|
||||
@@ -66,6 +66,8 @@ function TemplatesStrings (BaseString) {
|
||||
VALID_INTEGER: t.s('Please enter an answer that is a valid integer.'),
|
||||
VALID_DECIMAL: t.s('Please enter an answer that is a decimal number.'),
|
||||
PLAYBOOK_RUN: t.s('Playbook Run'),
|
||||
SCM_BRANCH: t.s('SCM Branch'),
|
||||
SCM_BRANCH_HELP: t.s('Branch to use in job run. Project default used if blank.'),
|
||||
CHECK: t.s('Check'),
|
||||
NO_CREDS_MATCHING_TYPE: t.s('No Credentials Matching This Type Have Been Created'),
|
||||
CREDENTIAL_TYPE_MISSING: typeLabel => t.s('This job template has a default {{typeLabel}} credential which must be included or replaced before proceeding.', { typeLabel })
|
||||
|
||||
@@ -115,6 +115,9 @@ function atRelaunchCtrl (
|
||||
},
|
||||
diffMode: {
|
||||
value: populatedJob.diff_mode
|
||||
},
|
||||
scmBranch: {
|
||||
value: populatedJob.scm_branch
|
||||
}
|
||||
},
|
||||
triggerModalOpen: true
|
||||
|
||||
@@ -68,6 +68,7 @@ function canLaunchWithoutPrompt () {
|
||||
!launchData.ask_skip_tags_on_launch &&
|
||||
!launchData.ask_variables_on_launch &&
|
||||
!launchData.ask_diff_mode_on_launch &&
|
||||
!launchData.ask_scm_branch_on_launch &&
|
||||
!launchData.survey_enabled &&
|
||||
launchData.variables_needed_to_start.length === 0
|
||||
);
|
||||
|
||||
@@ -61,6 +61,7 @@ function canLaunchWithoutPrompt () {
|
||||
!launchData.ask_skip_tags_on_launch &&
|
||||
!launchData.ask_variables_on_launch &&
|
||||
!launchData.ask_diff_mode_on_launch &&
|
||||
!launchData.ask_scm_branch_on_launch &&
|
||||
!launchData.survey_enabled
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ function canLaunchWithoutPrompt () {
|
||||
!launchData.ask_inventory_on_launch &&
|
||||
!launchData.ask_variables_on_launch &&
|
||||
!launchData.survey_enabled &&
|
||||
!launchData.ask_scm_branch_on_launch &&
|
||||
launchData.variables_needed_to_start.length === 0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,9 @@ export default ['i18n', function(i18n) {
|
||||
AWX_ROLES_ENABLED: {
|
||||
type: 'toggleSwitch',
|
||||
},
|
||||
AWX_COLLECTIONS_ENABLED: {
|
||||
type: 'toggleSwitch',
|
||||
},
|
||||
AWX_TASK_ENV: {
|
||||
type: 'textarea',
|
||||
reset: 'AWX_TASK_ENV',
|
||||
|
||||
@@ -128,10 +128,15 @@ export default
|
||||
job_launch_data.extra_credentials.push(extraCredential.id);
|
||||
});
|
||||
}
|
||||
|
||||
if(scope.ask_diff_mode_on_launch && _.has(scope, 'other_prompt_data.diff_mode')){
|
||||
job_launch_data.diff_mode = scope.other_prompt_data.diff_mode;
|
||||
}
|
||||
|
||||
if(scope.ask_scm_branch_on_launch && _.has(scope, 'other_prompt_data.scm_branch')){
|
||||
job_launch_data.scm_branch = scope.other_prompt_data.scm_branch;
|
||||
}
|
||||
|
||||
if(!Empty(scope.relaunchHostType)) {
|
||||
job_launch_data.hosts = scope.relaunchHostType;
|
||||
}
|
||||
|
||||
@@ -128,6 +128,7 @@ export default ['$scope', '$location', '$stateParams', 'GenerateForm',
|
||||
$scope.pathRequired = ($scope.scm_type.value === 'manual') ? true : false;
|
||||
$scope.scmRequired = ($scope.scm_type.value !== 'manual') ? true : false;
|
||||
$scope.scmBranchLabel = i18n._('SCM Branch');
|
||||
$scope.scmRefspecLabel = i18n._('SCM Refspec');
|
||||
// Dynamically update popover values
|
||||
if ($scope.scm_type.value) {
|
||||
if(($scope.lookupType === 'insights_credential' && $scope.scm_type.value !== 'insights') || ($scope.lookupType === 'scm_credential' && $scope.scm_type.value === 'insights')) {
|
||||
|
||||
@@ -250,6 +250,7 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
|
||||
$scope.pathRequired = ($scope.scm_type.value === 'manual') ? true : false;
|
||||
$scope.scmRequired = ($scope.scm_type.value !== 'manual') ? true : false;
|
||||
$scope.scmBranchLabel = i18n._('SCM Branch');
|
||||
$scope.scmRefspecLabel = i18n._('SCM Refspec');
|
||||
|
||||
// Dynamically update popover values
|
||||
if ($scope.scm_type.value) {
|
||||
|
||||
@@ -125,6 +125,24 @@ export default ['i18n', 'NotificationsList', 'TemplateList',
|
||||
type: 'text',
|
||||
ngShow: "scm_type && scm_type.value !== 'manual' && scm_type.value !== 'insights'",
|
||||
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)',
|
||||
awPopOver: '<p>' + i18n._("Branch to checkout. In addition to branches, you can input tags, commit hashes, and arbitrary refs. Some commit hashes and refs may not be availble unless you also provide a custom refspec.") + '</p>',
|
||||
dataTitle: i18n._('SCM Branch'),
|
||||
subForm: 'sourceSubForm',
|
||||
},
|
||||
scm_refspec: {
|
||||
labelBind: "scmRefspecLabel",
|
||||
type: 'text',
|
||||
ngShow: "scm_type && scm_type.value === 'git'",
|
||||
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)',
|
||||
awPopOver: '<p>' + i18n._('A refspec to fetch (passed to the Ansible git module). This parameter allows access to references via the branch field not otherwise available.') + '</p>' +
|
||||
'<p>' + i18n._('NOTE: This field assumes the remote name is "origin".') + '</p>' +
|
||||
'<p>' + i18n._('Examples include:') + '</p>' +
|
||||
'</p><ul class=\"no-bullets\"><li>refs/*:refs/remotes/origin/*</li>' +
|
||||
'<li>refs/pull/62/head:refs/remotes/origin/pull/62/head</li></ul>' +
|
||||
'<p>' + i18n._('The first fetches all references. The second fetches the Github pull request number 62, in this example the branch needs to be `pull/62/head`.') +
|
||||
'</p>' +
|
||||
'<p>' + i18n._('For more information, refer to the') + '<a target="_blank" href="https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html#manage-playbooks-using-source-control"> ' + i18n._('Ansible Tower Documentation') + '</a>.</p>',
|
||||
dataTitle: i18n._('SCM Refspec'),
|
||||
subForm: 'sourceSubForm',
|
||||
},
|
||||
credential: {
|
||||
@@ -183,6 +201,18 @@ export default ['i18n', 'NotificationsList', 'TemplateList',
|
||||
dataPlacement: 'right',
|
||||
labelClass: 'checkbox-options stack-inline',
|
||||
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)'
|
||||
},
|
||||
{
|
||||
name: 'allow_override',
|
||||
label: i18n._('Allow branch override'),
|
||||
type: 'checkbox',
|
||||
awPopOver: '<p>' + i18n._('Allow changing the SCM branch or revision in a job template that uses this project.') + '</p>',
|
||||
dataTitle: i18n._('Allow branch override'),
|
||||
dataContainer: 'body',
|
||||
dataPlacement: 'right',
|
||||
labelClass: 'checkbox-options stack-inline',
|
||||
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)',
|
||||
ngShow: "scm_type && scm_type.value !== 'insights'",
|
||||
}]
|
||||
},
|
||||
scm_update_cache_timeout: {
|
||||
|
||||
@@ -20,6 +20,20 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
||||
scheduler,
|
||||
job_type;
|
||||
|
||||
const shouldShowPromptButton = (launchConf) => launchConf.survey_enabled ||
|
||||
launchConf.ask_inventory_on_launch ||
|
||||
launchConf.ask_credential_on_launch ||
|
||||
launchConf.ask_verbosity_on_launch ||
|
||||
launchConf.ask_job_type_on_launch ||
|
||||
launchConf.ask_limit_on_launch ||
|
||||
launchConf.ask_tags_on_launch ||
|
||||
launchConf.ask_skip_tags_on_launch ||
|
||||
launchConf.ask_diff_mode_on_launch ||
|
||||
launchConf.credential_needed_to_start ||
|
||||
launchConf.ask_variables_on_launch ||
|
||||
launchConf.ask_scm_branch_on_launch ||
|
||||
launchConf.variables_needed_to_start.length !== 0;
|
||||
|
||||
var schedule_url = ParentObject.related.schedules || `${ParentObject.related.inventory_source}schedules`;
|
||||
if (ParentObject){
|
||||
$scope.parentObject = ParentObject;
|
||||
@@ -152,19 +166,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
||||
$scope.noVars = true;
|
||||
}
|
||||
|
||||
if (!launchConf.survey_enabled &&
|
||||
!launchConf.ask_inventory_on_launch &&
|
||||
!launchConf.ask_credential_on_launch &&
|
||||
!launchConf.ask_verbosity_on_launch &&
|
||||
!launchConf.ask_job_type_on_launch &&
|
||||
!launchConf.ask_limit_on_launch &&
|
||||
!launchConf.ask_tags_on_launch &&
|
||||
!launchConf.ask_skip_tags_on_launch &&
|
||||
!launchConf.ask_diff_mode_on_launch &&
|
||||
!launchConf.survey_enabled &&
|
||||
!launchConf.credential_needed_to_start &&
|
||||
!launchConf.inventory_needed_to_start &&
|
||||
launchConf.variables_needed_to_start.length === 0) {
|
||||
if (!shouldShowPromptButton(launchConf)) {
|
||||
$scope.showPromptButton = false;
|
||||
} else {
|
||||
$scope.showPromptButton = true;
|
||||
@@ -239,20 +241,8 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
|
||||
});
|
||||
};
|
||||
|
||||
if (!launchConf.survey_enabled &&
|
||||
!launchConf.ask_inventory_on_launch &&
|
||||
!launchConf.ask_credential_on_launch &&
|
||||
!launchConf.ask_verbosity_on_launch &&
|
||||
!launchConf.ask_job_type_on_launch &&
|
||||
!launchConf.ask_limit_on_launch &&
|
||||
!launchConf.ask_tags_on_launch &&
|
||||
!launchConf.ask_skip_tags_on_launch &&
|
||||
!launchConf.ask_diff_mode_on_launch &&
|
||||
!launchConf.survey_enabled &&
|
||||
!launchConf.credential_needed_to_start &&
|
||||
!launchConf.inventory_needed_to_start &&
|
||||
launchConf.variables_needed_to_start.length === 0) {
|
||||
$scope.showPromptButton = false;
|
||||
if (!shouldShowPromptButton(launchConf)) {
|
||||
$scope.showPromptButton = false;
|
||||
} else {
|
||||
$scope.showPromptButton = true;
|
||||
|
||||
|
||||
@@ -10,6 +10,21 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
||||
|
||||
let schedule, scheduler, scheduleCredentials = [];
|
||||
|
||||
const shouldShowPromptButton = (launchConf) => launchConf.survey_enabled ||
|
||||
launchConf.ask_inventory_on_launch ||
|
||||
launchConf.ask_credential_on_launch ||
|
||||
launchConf.ask_verbosity_on_launch ||
|
||||
launchConf.ask_job_type_on_launch ||
|
||||
launchConf.ask_limit_on_launch ||
|
||||
launchConf.ask_tags_on_launch ||
|
||||
launchConf.ask_skip_tags_on_launch ||
|
||||
launchConf.ask_diff_mode_on_launch ||
|
||||
launchConf.credential_needed_to_start ||
|
||||
launchConf.ask_variables_on_launch ||
|
||||
launchConf.ask_scm_branch_on_launch ||
|
||||
launchConf.passwords_needed_to_start.length !== 0 ||
|
||||
launchConf.variables_needed_to_start.length !== 0;
|
||||
|
||||
$scope.preventCredsWithPasswords = true;
|
||||
|
||||
// initial end @ midnight values
|
||||
@@ -326,20 +341,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
||||
// ask_variables_on_launch = true
|
||||
$scope.noVars = !launchConf.ask_variables_on_launch;
|
||||
|
||||
if (!launchConf.survey_enabled &&
|
||||
!launchConf.ask_inventory_on_launch &&
|
||||
!launchConf.ask_credential_on_launch &&
|
||||
!launchConf.ask_verbosity_on_launch &&
|
||||
!launchConf.ask_job_type_on_launch &&
|
||||
!launchConf.ask_limit_on_launch &&
|
||||
!launchConf.ask_tags_on_launch &&
|
||||
!launchConf.ask_skip_tags_on_launch &&
|
||||
!launchConf.ask_diff_mode_on_launch &&
|
||||
!launchConf.survey_enabled &&
|
||||
!launchConf.credential_needed_to_start &&
|
||||
!launchConf.inventory_needed_to_start &&
|
||||
launchConf.passwords_needed_to_start.length === 0 &&
|
||||
launchConf.variables_needed_to_start.length === 0) {
|
||||
if (!shouldShowPromptButton(launchConf)) {
|
||||
$scope.showPromptButton = false;
|
||||
|
||||
if (launchConf.ask_variables_on_launch) {
|
||||
@@ -424,20 +426,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
|
||||
currentValues: scheduleResolve
|
||||
});
|
||||
|
||||
if (!launchConf.survey_enabled &&
|
||||
!launchConf.ask_inventory_on_launch &&
|
||||
!launchConf.ask_credential_on_launch &&
|
||||
!launchConf.ask_verbosity_on_launch &&
|
||||
!launchConf.ask_job_type_on_launch &&
|
||||
!launchConf.ask_limit_on_launch &&
|
||||
!launchConf.ask_tags_on_launch &&
|
||||
!launchConf.ask_skip_tags_on_launch &&
|
||||
!launchConf.ask_diff_mode_on_launch &&
|
||||
!launchConf.survey_enabled &&
|
||||
!launchConf.credential_needed_to_start &&
|
||||
!launchConf.inventory_needed_to_start &&
|
||||
launchConf.passwords_needed_to_start.length === 0 &&
|
||||
launchConf.variables_needed_to_start.length === 0) {
|
||||
if (!shouldShowPromptButton(launchConf)) {
|
||||
$scope.showPromptButton = false;
|
||||
} else {
|
||||
$scope.showPromptButton = true;
|
||||
|
||||
@@ -182,41 +182,52 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
||||
}
|
||||
} else if (form) { //if no error code is detected it begins to loop through to see where the api threw an error
|
||||
fieldErrors = false;
|
||||
for (field in form.fields) {
|
||||
if (data[field] && form.fields[field].tab) {
|
||||
|
||||
const addApiErrors = (field, fld) => {
|
||||
if (data[fld] && field.tab) {
|
||||
// If the form is part of a tab group, activate the tab
|
||||
$('#' + form.name + "_tabs a[href=\"#" + form.fields[field].tab + '"]').tab('show');
|
||||
$('#' + form.name + "_tabs a[href=\"#" + field.tab + '"]').tab('show');
|
||||
}
|
||||
if (form.fields[field].realName) {
|
||||
if (data[form.fields[field].realName]) {
|
||||
scope[field + '_api_error'] = data[form.fields[field].realName][0];
|
||||
if (field.realName) {
|
||||
if (field.realName) {
|
||||
scope[fld + '_api_error'] = data[field.realName][0];
|
||||
//scope[form.name + '_form'][form.fields[field].realName].$setValidity('apiError', false);
|
||||
$('[name="' + form.fields[field].realName + '"]').addClass('ng-invalid');
|
||||
$('html, body').animate({scrollTop: $('[name="' + form.fields[field].realName + '"]').offset().top}, 0);
|
||||
$('[name="' + field.realName + '"]').addClass('ng-invalid');
|
||||
$('html, body').animate({scrollTop: $('[name="' + field.realName + '"]').offset().top}, 0);
|
||||
fieldErrors = true;
|
||||
}
|
||||
}
|
||||
if (form.fields[field].sourceModel) {
|
||||
if (data[field]) {
|
||||
scope[form.fields[field].sourceModel + '_' + form.fields[field].sourceField + '_api_error'] =
|
||||
data[field][0];
|
||||
if (field.sourceModel) {
|
||||
if (data[fld]) {
|
||||
scope[field.sourceModel + '_' + field.sourceField + '_api_error'] =
|
||||
data[fld][0];
|
||||
//scope[form.name + '_form'][form.fields[field].sourceModel + '_' + form.fields[field].sourceField].$setValidity('apiError', false);
|
||||
$('[name="' + form.fields[field].sourceModel + '_' + form.fields[field].sourceField + '"]').addClass('ng-invalid');
|
||||
$('[name="' + form.fields[field].sourceModel + '_' + form.fields[field].sourceField + '"]').ScrollTo({ "onlyIfOutside": true, "offsetTop": 100 });
|
||||
$('[name="' + field.sourceModel + '_' + field.sourceField + '"]').addClass('ng-invalid');
|
||||
$('[name="' + field.sourceModel + '_' + field.sourceField + '"]').ScrollTo({ "onlyIfOutside": true, "offsetTop": 100 });
|
||||
fieldErrors = true;
|
||||
}
|
||||
} else {
|
||||
if (data[field]) {
|
||||
scope[field + '_api_error'] = data[field][0];
|
||||
$('[name="' + field + '"]').addClass('ng-invalid');
|
||||
$('label[for="' + field + '"] span').addClass('error-color');
|
||||
$('html, body').animate({scrollTop: $('[name="' + field + '"]').offset().top}, 0);
|
||||
if (data[fld]) {
|
||||
scope[fld + '_api_error'] = data[fld][0];
|
||||
$('[name="' + fld + '"]').addClass('ng-invalid');
|
||||
$('label[for="' + fld + '"] span').addClass('error-color');
|
||||
$('html, body').animate({scrollTop: $('[name="' + fld + '"]').offset().top}, 0);
|
||||
fieldErrors = true;
|
||||
if(form.fields[field].codeMirror){
|
||||
$(`#cm-${field}-container .CodeMirror`).addClass('error-border');
|
||||
if(field.codeMirror){
|
||||
$(`#cm-${fld}-container .CodeMirror`).addClass('error-border');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (field in form.fields) {
|
||||
if (form.fields[field].type === "checkbox_group") {
|
||||
form.fields[field].fields.forEach(fld => {
|
||||
addApiErrors(fld, fld.name);
|
||||
});
|
||||
} else {
|
||||
addApiErrors(form.fields[field], field);
|
||||
}
|
||||
}
|
||||
if (defaultMsg) {
|
||||
Alert(defaultMsg.hdr, defaultMsg.msg);
|
||||
|
||||
@@ -1156,6 +1156,9 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
||||
field.max + "</div>\n";
|
||||
}
|
||||
html += "<div class=\"error api-error\" id=\"" + this.form.name + "-" + fld + "-api-error\" ng-bind=\"" + fld + "_api_error\"></div>\n";
|
||||
for (i = 0; i < field.fields.length; i++) {
|
||||
html += "<div class=\"error api-error\" id=\"" + this.form.name + "-" + field.fields[i].name + "-api-error\" ng-bind=\"" + field.fields[i].name + "_api_error\"></div>\n";
|
||||
}
|
||||
html += "</div><!-- checkbox-group -->\n";
|
||||
html += "</div>\n";
|
||||
}
|
||||
|
||||
@@ -104,7 +104,11 @@
|
||||
});
|
||||
CreateSelect2({
|
||||
element:'#playbook-select',
|
||||
multiple: false
|
||||
addNew: true,
|
||||
multiple: false,
|
||||
scope: $scope,
|
||||
options: 'playbook_options',
|
||||
model: 'playbook'
|
||||
});
|
||||
CreateSelect2({
|
||||
element:'#job_template_verbosity',
|
||||
@@ -155,7 +159,11 @@
|
||||
function sync_playbook_select2() {
|
||||
CreateSelect2({
|
||||
element:'#playbook-select',
|
||||
multiple: false
|
||||
addNew: true,
|
||||
multiple: false,
|
||||
scope: $scope,
|
||||
options: 'playbook_options',
|
||||
model: 'playbook'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -177,6 +185,9 @@
|
||||
for (i = 0; i < data.length; i++) {
|
||||
opts.push(data[i]);
|
||||
}
|
||||
if ($scope.playbook && opts.indexOf($scope.playbook) === -1) {
|
||||
opts.push($scope.playbook);
|
||||
}
|
||||
$scope.playbook_options = opts;
|
||||
sync_playbook_select2();
|
||||
Wait('stop');
|
||||
@@ -195,10 +206,14 @@
|
||||
|
||||
// Detect and alert user to potential SCM status issues
|
||||
checkSCMStatus = function (oldValue, newValue) {
|
||||
if (oldValue !== newValue && !Empty($scope.project)) {
|
||||
if ((oldValue !== newValue || (oldValue === undefined && newValue === undefined)) && !Empty($scope.project)) {
|
||||
Rest.setUrl(GetBasePath('projects') + $scope.project + '/');
|
||||
Rest.get()
|
||||
.then(({data}) => {
|
||||
$scope.allow_branch_override = data.allow_override;
|
||||
$scope.allow_playbook_selection = true;
|
||||
selectPlaybook('force_load');
|
||||
|
||||
var msg;
|
||||
switch (data.status) {
|
||||
case 'failed':
|
||||
@@ -219,6 +234,8 @@
|
||||
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||
msg: 'Failed to get project ' + $scope.project + '. GET returned status: ' + status });
|
||||
});
|
||||
} else {
|
||||
$scope.allow_playbook_selection = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -295,6 +312,7 @@
|
||||
}
|
||||
data.forks = $scope.forks || 0;
|
||||
data.ask_diff_mode_on_launch = $scope.ask_diff_mode_on_launch ? $scope.ask_diff_mode_on_launch : false;
|
||||
data.ask_scm_branch_on_launch = $scope.ask_scm_branch_on_launch ? $scope.ask_scm_branch_on_launch : false;
|
||||
data.ask_tags_on_launch = $scope.ask_tags_on_launch ? $scope.ask_tags_on_launch : false;
|
||||
data.ask_skip_tags_on_launch = $scope.ask_skip_tags_on_launch ? $scope.ask_skip_tags_on_launch : false;
|
||||
data.ask_limit_on_launch = $scope.ask_limit_on_launch ? $scope.ask_limit_on_launch : false;
|
||||
|
||||
@@ -104,7 +104,11 @@ export default
|
||||
playbookNotFound = false;
|
||||
}
|
||||
}
|
||||
if ($scope.playbook && $scope.playbook_options.indexOf($scope.playbook) === -1) {
|
||||
$scope.playbook_options.push($scope.playbook);
|
||||
}
|
||||
$scope.playbookNotFound = playbookNotFound;
|
||||
$scope.allow_playbook_selection = true;
|
||||
sync_playbook_select2();
|
||||
if ($scope.playbook) {
|
||||
jobTemplateLoadFinished();
|
||||
@@ -125,6 +129,7 @@ export default
|
||||
Rest.setUrl(GetBasePath('projects') + $scope.project + '/');
|
||||
promises.push(Rest.get()
|
||||
.then(({data}) => {
|
||||
$scope.allow_branch_override = data.allow_override;
|
||||
var msg;
|
||||
switch (data.status) {
|
||||
case 'failed':
|
||||
@@ -177,7 +182,11 @@ export default
|
||||
function sync_playbook_select2() {
|
||||
select2LoadDefer.push(CreateSelect2({
|
||||
element:'#playbook-select',
|
||||
multiple: false
|
||||
addNew: true,
|
||||
multiple: false,
|
||||
scope: $scope,
|
||||
options: 'playbook_options',
|
||||
model: 'playbook'
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -194,11 +203,6 @@ export default
|
||||
multiple: false
|
||||
}));
|
||||
|
||||
select2LoadDefer.push(CreateSelect2({
|
||||
element:'#playbook-select',
|
||||
multiple: false
|
||||
}));
|
||||
|
||||
select2LoadDefer.push(CreateSelect2({
|
||||
element:'#job_template_job_tags',
|
||||
multiple: true,
|
||||
@@ -377,6 +381,9 @@ export default
|
||||
$scope.ask_diff_mode_on_launch = (jobTemplateData.ask_diff_mode_on_launch) ? true : false;
|
||||
master.ask_diff_mode_on_launch = $scope.ask_diff_mode_on_launch;
|
||||
|
||||
$scope.ask_scm_branch_on_launch = (jobTemplateData.ask_scm_branch_on_launch) ? true : false;
|
||||
master.ask_scm_branch_on_launch = $scope.ask_scm_branch_on_launch;
|
||||
|
||||
$scope.job_tag_options = (jobTemplateData.job_tags) ? jobTemplateData.job_tags.split(',')
|
||||
.map((i) => ({name: i, label: i, value: i})) : [];
|
||||
$scope.job_tags = $scope.job_tag_options;
|
||||
@@ -652,8 +659,9 @@ export default
|
||||
for(var i=0; i<form.fields[fld].fields.length; i++) {
|
||||
data[form.fields[fld].fields[i].name] = $scope[form.fields[fld].fields[i].name];
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else if (fld === 'scm_branch' && $scope.allow_branch_override) {
|
||||
data[fld] = $scope[fld];
|
||||
} else {
|
||||
if (fld !== 'extra_vars' &&
|
||||
fld !== 'survey' &&
|
||||
fld !== 'forks') {
|
||||
@@ -664,6 +672,7 @@ export default
|
||||
|
||||
data.forks = $scope.forks || 0;
|
||||
data.ask_diff_mode_on_launch = $scope.ask_diff_mode_on_launch ? $scope.ask_diff_mode_on_launch : false;
|
||||
data.ask_scm_branch_on_launch = $scope.ask_scm_branch_on_launch && $scope.allow_branch_override ? $scope.ask_scm_branch_on_launch : false;
|
||||
data.ask_tags_on_launch = $scope.ask_tags_on_launch ? $scope.ask_tags_on_launch : false;
|
||||
data.ask_skip_tags_on_launch = $scope.ask_skip_tags_on_launch ? $scope.ask_skip_tags_on_launch : false;
|
||||
data.ask_limit_on_launch = $scope.ask_limit_on_launch ? $scope.ask_limit_on_launch : false;
|
||||
|
||||
@@ -103,15 +103,34 @@ function(NotificationsList, i18n) {
|
||||
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate) || !canGetAllRelatedResources',
|
||||
awLookupWhen: 'canGetAllRelatedResources'
|
||||
},
|
||||
scm_branch: {
|
||||
label: i18n._('SCM Branch'),
|
||||
type: 'text',
|
||||
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)',
|
||||
ngShow: 'allow_branch_override',
|
||||
column: 1,
|
||||
awPopOver: "<p>" + i18n._("Branch to use in job run. Project default used if blank.") + "</p>",
|
||||
dataTitle: i18n._('Project'),
|
||||
subCheckbox: {
|
||||
variable: 'ask_scm_branch_on_launch',
|
||||
text: i18n._('Prompt on launch'),
|
||||
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)'
|
||||
},
|
||||
dataPlacement: 'right',
|
||||
dataContainer: "body"
|
||||
},
|
||||
playbook: {
|
||||
label: i18n._('Playbook'),
|
||||
type:'select',
|
||||
defaultText: i18n._('Choose a playbook'),
|
||||
ngOptions: 'book for book in playbook_options track by book',
|
||||
ngShow: 'allow_playbook_selection',
|
||||
ngDisabled: "!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate) || !canGetAllRelatedResources",
|
||||
id: 'playbook-select',
|
||||
required: true,
|
||||
column: 1,
|
||||
awPopOver: "<p>" + i18n._("Select the playbook to be executed by this job.") + "</p>",
|
||||
awPopOver: "<p>" + i18n._("Select the playbook to be executed by this job." +
|
||||
"You can select from the dropdown or enter a file within the input.") + "</p>",
|
||||
dataTitle: i18n._('Playbook'),
|
||||
dataPlacement: 'right',
|
||||
dataContainer: "body",
|
||||
|
||||
@@ -157,7 +157,7 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f
|
||||
activeTab = activeTab || vm.steps.credential.tab;
|
||||
order++;
|
||||
}
|
||||
if(vm.promptDataClone.launchConf.ask_verbosity_on_launch || vm.promptDataClone.launchConf.ask_job_type_on_launch || vm.promptDataClone.launchConf.ask_limit_on_launch || vm.promptDataClone.launchConf.ask_tags_on_launch || vm.promptDataClone.launchConf.ask_skip_tags_on_launch || (vm.promptDataClone.launchConf.ask_variables_on_launch && !vm.promptDataClone.launchConf.ignore_ask_variables) || vm.promptDataClone.launchConf.ask_diff_mode_on_launch) {
|
||||
if(vm.promptDataClone.launchConf.ask_verbosity_on_launch || vm.promptDataClone.launchConf.ask_job_type_on_launch || vm.promptDataClone.launchConf.ask_limit_on_launch || vm.promptDataClone.launchConf.ask_tags_on_launch || vm.promptDataClone.launchConf.ask_skip_tags_on_launch || (vm.promptDataClone.launchConf.ask_variables_on_launch && !vm.promptDataClone.launchConf.ignore_ask_variables) || vm.promptDataClone.launchConf.ask_diff_mode_on_launch || vm.promptDataClone.launchConf.ask_scm_branch_on_launch) {
|
||||
vm.steps.other_prompts.includeStep = true;
|
||||
vm.steps.other_prompts.tab = {
|
||||
_active: order === 1 ? true : false,
|
||||
|
||||
@@ -10,7 +10,8 @@ function PromptService (Empty, $filter) {
|
||||
limit: {},
|
||||
tags: {},
|
||||
skipTags: {},
|
||||
diffMode: {}
|
||||
diffMode: {},
|
||||
scmBranch: {}
|
||||
};
|
||||
|
||||
prompts.credentials.value = _.has(params, 'launchConf.defaults.credentials') ? _.cloneDeep(params.launchConf.defaults.credentials) : [];
|
||||
@@ -41,7 +42,7 @@ function PromptService (Empty, $filter) {
|
||||
prompts.tags.value = (jobTags && jobTags !== "") ? jobTags.split(',').map((i) => ({name: i, label: i, value: i})) : [];
|
||||
prompts.skipTags.value = (skipTags && skipTags !== "") ? skipTags.split(',').map((i) => ({name: i, label: i, value: i})) : [];
|
||||
prompts.diffMode.value = _.has(params, 'currentValues.diff_mode') && typeof params.currentValues.diff_mode === 'boolean' ? params.currentValues.diff_mode : (_.has(params, 'launchConf.defaults.diff_mode') ? params.launchConf.defaults.diff_mode : null);
|
||||
|
||||
prompts.scmBranch.value = _.has(params, 'currentValues.scm_branch') && params.currentValues.scm_branch ? params.currentValues.scm_branch : (_.has(params, 'launchConf.defaults.scm_branch') ? params.launchConf.defaults.scm_branch : "");
|
||||
return prompts;
|
||||
};
|
||||
|
||||
@@ -163,6 +164,9 @@ function PromptService (Empty, $filter) {
|
||||
if (promptData.launchConf.ask_diff_mode_on_launch && _.has(promptData, 'prompts.diffMode.value')) {
|
||||
launchData.diff_mode = promptData.prompts.diffMode.value;
|
||||
}
|
||||
if (promptData.launchConf.ask_scm_branch_on_launch && _.has(promptData, 'prompts.scmBranch.value')) {
|
||||
launchData.scm_branch = promptData.prompts.scmBranch.value;
|
||||
}
|
||||
if (promptData.prompts.credentials.passwords) {
|
||||
_.forOwn(promptData.prompts.credentials.passwords, (val, key) => {
|
||||
if (!launchData.credential_passwords) {
|
||||
@@ -277,7 +281,9 @@ function PromptService (Empty, $filter) {
|
||||
if(_.has(params, 'promptData.prompts.diffMode.value') && _.get(params, 'promptData.launchConf.ask_diff_mode_on_launch')){
|
||||
promptDataToSave.diff_mode = launchConfDefaults.diff_mode && launchConfDefaults.diff_mode === params.promptData.prompts.diffMode.value ? null : params.promptData.prompts.diffMode.value;
|
||||
}
|
||||
|
||||
if(_.has(params, 'promptData.prompts.scmBranch.value') && _.get(params, 'promptData.launchConf.ask_scm_branch_on_launch')){
|
||||
promptDataToSave.scm_branch = launchConfDefaults.scm_branch && launchConfDefaults.scm_branch === params.promptData.prompts.scmBranch.value ? null : params.promptData.prompts.scmBranch.value;
|
||||
}
|
||||
return promptDataToSave;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,6 +22,22 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="promptData.launchConf.ask_scm_branch_on_launch">
|
||||
<label for="scm_branch">
|
||||
<span class="Form-inputLabel">{{:: vm.strings.get('prompt.SCM_BRANCH') }}</span>
|
||||
<a id="awp-scm-branch" href="" aw-pop-over="{{:: vm.strings.get('prompt.SCM_BRANCH_HELP') }}" data-placement="right" data-container="body" over-title="{{:: vm.strings.get('prompt.SCM_BRANCH') }}" class="help-link" data-original-title="" title="" tabindex="-1">
|
||||
<i class="fa fa-question-circle"></i>
|
||||
</a>
|
||||
</label>
|
||||
<div>
|
||||
<input
|
||||
type="text"
|
||||
ng-model="promptData.prompts.scmBranch.value"
|
||||
name="scm_branch"
|
||||
class="form-control Form-textInput"
|
||||
ng-disabled="readOnlyPrompts">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="promptData.launchConf.ask_limit_on_launch">
|
||||
<label for="limit">
|
||||
<span class="Form-inputLabel">{{:: vm.strings.get('prompt.LIMIT') }}</span>
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
<div class="Prompt-previewRowTitle">{{:: vm.strings.get('prompt.INVENTORY') }}</div>
|
||||
<div class="Prompt-previewRowValue" ng-bind="promptData.prompts.inventory.value.name"></div>
|
||||
</div>
|
||||
<div class="Prompt-previewRow--flex" ng-if="promptData.prompts.scmBranch.value">
|
||||
<div class="Prompt-previewRowTitle">{{:: vm.strings.get('prompt.SCM_BRANCH') }}</div>
|
||||
<div class="Prompt-previewRowValue" ng-bind="promptData.prompts.scmBranch.value"></div>
|
||||
</div>
|
||||
<div class="Prompt-previewRow--flex" ng-if="promptData.prompts.limit.value">
|
||||
<div class="Prompt-previewRowTitle">{{:: vm.strings.get('prompt.LIMIT') }}</div>
|
||||
<div class="Prompt-previewRowValue" ng-bind="promptData.prompts.limit.value"></div>
|
||||
|
||||
@@ -16,6 +16,20 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
|
||||
let promptWatcher, credentialsWatcher, surveyQuestionWatcher, listPromises = [];
|
||||
|
||||
const shouldShowPromptButton = (launchConf) => launchConf.survey_enabled ||
|
||||
launchConf.ask_inventory_on_launch ||
|
||||
launchConf.ask_credential_on_launch ||
|
||||
launchConf.ask_verbosity_on_launch ||
|
||||
launchConf.ask_job_type_on_launch ||
|
||||
launchConf.ask_limit_on_launch ||
|
||||
launchConf.ask_tags_on_launch ||
|
||||
launchConf.ask_skip_tags_on_launch ||
|
||||
launchConf.ask_diff_mode_on_launch ||
|
||||
launchConf.credential_needed_to_start ||
|
||||
launchConf.ask_variables_on_launch ||
|
||||
launchConf.ask_scm_branch_on_launch ||
|
||||
launchConf.variables_needed_to_start.length !== 0;
|
||||
|
||||
$scope.strings = TemplatesStrings;
|
||||
$scope.editNodeHelpMessage = null;
|
||||
|
||||
@@ -198,18 +212,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
$scope.promptData = _.cloneDeep($scope.nodeConfig.node.promptData);
|
||||
const launchConf = $scope.promptData.launchConf;
|
||||
|
||||
if (!launchConf.survey_enabled &&
|
||||
!launchConf.ask_inventory_on_launch &&
|
||||
!launchConf.ask_credential_on_launch &&
|
||||
!launchConf.ask_verbosity_on_launch &&
|
||||
!launchConf.ask_job_type_on_launch &&
|
||||
!launchConf.ask_limit_on_launch &&
|
||||
!launchConf.ask_tags_on_launch &&
|
||||
!launchConf.ask_skip_tags_on_launch &&
|
||||
!launchConf.ask_diff_mode_on_launch &&
|
||||
!launchConf.credential_needed_to_start &&
|
||||
!launchConf.ask_variables_on_launch &&
|
||||
launchConf.variables_needed_to_start.length === 0) {
|
||||
if (!shouldShowPromptButton(launchConf)) {
|
||||
$scope.showPromptButton = false;
|
||||
$scope.promptModalMissingReqFields = false;
|
||||
} else {
|
||||
@@ -305,18 +308,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
|
||||
$scope.credentialRequiresPassword = credentialRequiresPassword;
|
||||
|
||||
if (!launchConf.survey_enabled &&
|
||||
!launchConf.ask_inventory_on_launch &&
|
||||
!launchConf.ask_credential_on_launch &&
|
||||
!launchConf.ask_verbosity_on_launch &&
|
||||
!launchConf.ask_job_type_on_launch &&
|
||||
!launchConf.ask_limit_on_launch &&
|
||||
!launchConf.ask_tags_on_launch &&
|
||||
!launchConf.ask_skip_tags_on_launch &&
|
||||
!launchConf.ask_diff_mode_on_launch &&
|
||||
!launchConf.credential_needed_to_start &&
|
||||
!launchConf.ask_variables_on_launch &&
|
||||
launchConf.variables_needed_to_start.length === 0) {
|
||||
if (!shouldShowPromptButton(launchConf)) {
|
||||
$scope.showPromptButton = false;
|
||||
$scope.promptModalMissingReqFields = false;
|
||||
$scope.nodeFormDataLoaded = true;
|
||||
@@ -491,18 +483,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
$scope.selectedTemplateInvalid = selectedTemplateInvalid;
|
||||
$scope.selectedTemplate = angular.copy(selectedTemplate);
|
||||
|
||||
if (!launchConf.survey_enabled &&
|
||||
!launchConf.ask_inventory_on_launch &&
|
||||
!launchConf.ask_credential_on_launch &&
|
||||
!launchConf.ask_verbosity_on_launch &&
|
||||
!launchConf.ask_job_type_on_launch &&
|
||||
!launchConf.ask_limit_on_launch &&
|
||||
!launchConf.ask_tags_on_launch &&
|
||||
!launchConf.ask_skip_tags_on_launch &&
|
||||
!launchConf.ask_diff_mode_on_launch &&
|
||||
!launchConf.credential_needed_to_start &&
|
||||
!launchConf.ask_variables_on_launch &&
|
||||
launchConf.variables_needed_to_start.length === 0) {
|
||||
if (!shouldShowPromptButton(launchConf)) {
|
||||
$scope.showPromptButton = false;
|
||||
$scope.promptModalMissingReqFields = false;
|
||||
} else {
|
||||
|
||||
@@ -145,6 +145,7 @@
|
||||
nodeConfig.node.originalNodeObject.job_tags !== null ||
|
||||
nodeConfig.node.originalNodeObject.skip_tags !== null ||
|
||||
nodeConfig.node.originalNodeObject.diff_mode !== null ||
|
||||
nodeConfig.node.originalNodeObject.scm_branch !== null ||
|
||||
showExtraVars">
|
||||
{{:: strings.get('workflow_maker.READ_ONLY_PROMPT_VALUES')}}
|
||||
</div>
|
||||
@@ -158,6 +159,7 @@
|
||||
nodeConfig.node.originalNodeObject.job_tags !== null ||
|
||||
nodeConfig.node.originalNodeObject.skip_tags !== null ||
|
||||
nodeConfig.node.originalNodeObject.diff_mode !== null ||
|
||||
nodeConfig.node.originalNodeObject.scm_branch !== null ||
|
||||
showExtraVars)">
|
||||
{{:: strings.get('workflow_maker.READ_ONLY_NO_PROMPT_VALUES')}}
|
||||
</div>
|
||||
@@ -219,6 +221,10 @@
|
||||
<span ng-if="!promptData.prompts.diffMode.value">{{:: strings.get('OFF') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Prompt-previewRow--flex" ng-if="nodeConfig.node.originalNodeObject.scm_branch !== null">
|
||||
<div class="Prompt-previewRowTitle">{{:: strings.get('prompt.SCM_BRANCH') }}</div>
|
||||
<div class="Prompt-previewRowValue" ng-bind="nodeConfig.node.originalNodeObject.scm_branch"></div>
|
||||
</div>
|
||||
<div class="Prompt-previewRow--noflex" ng-show="showExtraVars">
|
||||
<div class="Prompt-previewRowTitle">{{:: strings.get('prompt.EXTRA_VARIABLES') }}</div>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user