assorted UI work to support the new branch field

update project to have allow branch override checkbox
add new text input for branch field
adjust show/hide for branch and playbook jt fields
make playbook field allowed to add a new option not in the dropdown
update job results ui to show branch
update prompting to support new branch field
This commit is contained in:
John Mitchell
2019-07-01 15:43:10 -04:00
committed by AlanCoding
parent ac86dc4fb9
commit 76dcd57ac6
21 changed files with 144 additions and 10 deletions

View File

@@ -343,6 +343,17 @@ 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 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 +811,7 @@ function JobDetailsController (
vm.project = getProjectDetails();
vm.projectUpdate = getProjectUpdateDetails();
vm.projectStatus = getProjectStatusDetails();
vm.scmBranch = getSCMBranchDetails();
vm.scmRevision = getSCMRevisionDetails();
vm.inventoryScm = getInventoryScmDetails();
vm.playbook = getPlaybookDetails();
@@ -840,6 +852,7 @@ function JobDetailsController (
started,
finished,
scm,
scmBranch,
inventoryScm,
scmRevision,
instanceGroup,
@@ -851,6 +864,7 @@ function JobDetailsController (
vm.finished = getFinishDetails(finished);
vm.projectUpdate = getProjectUpdateDetails(scm.id);
vm.projectStatus = getProjectStatusDetails(scm.status);
vm.scmBranch = getSCMBranchDetails(scmBranch);
vm.environment = getEnvironmentDetails(environment);
vm.artifacts = getArtifactsDetails(artifacts);
vm.executionNode = getExecutionNodeDetails(executionNode);

View File

@@ -218,6 +218,12 @@
</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>
<!-- INVENTORY SCM DETAIL -->
<div class="JobResults-resultRow" ng-if="!vm.project && vm.inventoryScm">
<label class="JobResults-resultRowLabel">{{ vm.inventoryScm.label }}</label>

View File

@@ -78,6 +78,7 @@ function OutputStrings (BaseString) {
OVERWRITE_VARS: t.s('Overwrite Vars'),
PLAYBOOK: t.s('Playbook'),
PROJECT: t.s('Project'),
SCM_BRANCH: t.s('Branch'),
RESULT_TRACEBACK: t.s('Error Details'),
SCM_REVISION: t.s('Revision'),
SKIP_TAGS: t.s('Skip Tags'),

View File

@@ -45,6 +45,7 @@ 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'),
inventoryScm: {
id: model.get('source_project_update'),
status: model.get('summary_fields.inventory_source.status')

View File

@@ -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 })

View File

@@ -115,6 +115,9 @@ function atRelaunchCtrl (
},
diffMode: {
value: populatedJob.diff_mode
},
scmBranch: {
value: populatedJob.scm_branch
}
},
triggerModalOpen: true

View File

@@ -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
);

View File

@@ -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
);
}

View File

@@ -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
);
}

View File

@@ -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;
}

View File

@@ -183,6 +183,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: {

View File

@@ -161,6 +161,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
!launchConf.ask_tags_on_launch &&
!launchConf.ask_skip_tags_on_launch &&
!launchConf.ask_diff_mode_on_launch &&
!launchConf.ask_scm_branch_on_launch &&
!launchConf.survey_enabled &&
!launchConf.credential_needed_to_start &&
!launchConf.inventory_needed_to_start &&
@@ -248,6 +249,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait',
!launchConf.ask_tags_on_launch &&
!launchConf.ask_skip_tags_on_launch &&
!launchConf.ask_diff_mode_on_launch &&
!launchConf.ask_scm_branch_on_launch &&
!launchConf.survey_enabled &&
!launchConf.credential_needed_to_start &&
!launchConf.inventory_needed_to_start &&

View File

@@ -335,6 +335,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
!launchConf.ask_tags_on_launch &&
!launchConf.ask_skip_tags_on_launch &&
!launchConf.ask_diff_mode_on_launch &&
!launchConf.ask_scm_branch_on_launch &&
!launchConf.survey_enabled &&
!launchConf.credential_needed_to_start &&
!launchConf.inventory_needed_to_start &&
@@ -433,6 +434,7 @@ function($filter, $state, $stateParams, Wait, $scope, moment,
!launchConf.ask_tags_on_launch &&
!launchConf.ask_skip_tags_on_launch &&
!launchConf.ask_diff_mode_on_launch &&
!launchConf.ask_scm_branch_on_launch &&
!launchConf.survey_enabled &&
!launchConf.credential_needed_to_start &&
!launchConf.inventory_needed_to_start &&

View File

@@ -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;

View File

@@ -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'
}));
}
@@ -377,6 +386,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;
@@ -656,7 +668,8 @@ export default
else {
if (fld !== 'extra_vars' &&
fld !== 'survey' &&
fld !== 'forks') {
fld !== 'forks' &&
(fld === 'scm_branch' && $scope.allow_branch_override)) {
data[fld] = $scope[fld];
}
}
@@ -664,6 +677,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;

View File

@@ -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",

View File

@@ -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,

View File

@@ -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;
};
}

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>