1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Fixed bug where job/workflow templates add forms were fully disabled for users with add access

This commit is contained in:
mabashian 2018-04-05 13:34:16 -04:00
parent 442c209899
commit 78893590d1
2 changed files with 60 additions and 57 deletions

View File

@ -10,14 +10,14 @@
'ProcessErrors', 'GetBasePath', 'md5Setup', 'ParseTypeChange', 'Wait', 'ProcessErrors', 'GetBasePath', 'md5Setup', 'ParseTypeChange', 'Wait',
'Empty', 'ToJSON', 'CallbackHelpInit', 'GetChoices', '$state', 'availableLabels', 'Empty', 'ToJSON', 'CallbackHelpInit', 'GetChoices', '$state', 'availableLabels',
'CreateSelect2', '$q', 'i18n', 'Inventory', 'Project', 'InstanceGroupsService', 'CreateSelect2', '$q', 'i18n', 'Inventory', 'Project', 'InstanceGroupsService',
'MultiCredentialService', 'ConfigData', 'MultiCredentialService', 'ConfigData', 'resolvedModels',
function( function(
$filter, $scope, $filter, $scope,
$stateParams, JobTemplateForm, GenerateForm, Rest, Alert, $stateParams, JobTemplateForm, GenerateForm, Rest, Alert,
ProcessErrors, GetBasePath, md5Setup, ParseTypeChange, Wait, ProcessErrors, GetBasePath, md5Setup, ParseTypeChange, Wait,
Empty, ToJSON, CallbackHelpInit, GetChoices, Empty, ToJSON, CallbackHelpInit, GetChoices,
$state, availableLabels, CreateSelect2, $q, i18n, Inventory, Project, InstanceGroupsService, $state, availableLabels, CreateSelect2, $q, i18n, Inventory, Project, InstanceGroupsService,
MultiCredentialService, ConfigData MultiCredentialService, ConfigData, resolvedModels
) { ) {
// Inject dynamic view // Inject dynamic view
@ -28,37 +28,38 @@
selectPlaybook, checkSCMStatus, selectPlaybook, checkSCMStatus,
callback; callback;
init(); const jobTemplate = resolvedModels[0];
function init(){
// apply form definition's default field values
GenerateForm.applyDefaults(form, $scope);
$scope.can_edit = true; $scope.canAddJobTemplate = jobTemplate.options('actions.POST');
$scope.allow_callbacks = false;
$scope.playbook_options = [];
$scope.mode = "add";
$scope.parseType = 'yaml';
$scope.credentialNotPresent = false;
$scope.canGetAllRelatedResources = true;
md5Setup({ // apply form definition's default field values
scope: $scope, GenerateForm.applyDefaults(form, $scope);
master: master,
check_field: 'allow_callbacks',
default_val: false
});
CallbackHelpInit({ scope: $scope });
$scope.surveyTooltip = i18n._('Please save before adding a survey to this job template.'); $scope.can_edit = true;
$scope.allow_callbacks = false;
$scope.playbook_options = [];
$scope.mode = "add";
$scope.parseType = 'yaml';
$scope.credentialNotPresent = false;
$scope.canGetAllRelatedResources = true;
MultiCredentialService.getCredentialTypes() md5Setup({
.then(({ data }) => { scope: $scope,
$scope.multiCredential = { master: master,
credentialTypes: data.results, check_field: 'allow_callbacks',
selectedCredentials: [] default_val: false
}; });
}); CallbackHelpInit({ scope: $scope });
}
$scope.surveyTooltip = i18n._('Please save before adding a survey to this job template.');
MultiCredentialService.getCredentialTypes()
.then(({ data }) => {
$scope.multiCredential = {
credentialTypes: data.results,
selectedCredentials: []
};
});
callback = function() { callback = function() {
// Make sure the form controller knows there was a change // Make sure the form controller knows there was a change

View File

@ -8,43 +8,47 @@ export default [
'$scope', 'WorkflowForm', 'GenerateForm', 'Alert', 'ProcessErrors', '$scope', 'WorkflowForm', 'GenerateForm', 'Alert', 'ProcessErrors',
'Wait', '$state', 'CreateSelect2', 'TemplatesService', 'Wait', '$state', 'CreateSelect2', 'TemplatesService',
'ToJSON', 'ParseTypeChange', '$q', 'Rest', 'GetBasePath', 'availableLabels', 'i18n', 'ToJSON', 'ParseTypeChange', '$q', 'Rest', 'GetBasePath', 'availableLabels', 'i18n',
'resolvedModels',
function($scope, WorkflowForm, GenerateForm, Alert, ProcessErrors, function($scope, WorkflowForm, GenerateForm, Alert, ProcessErrors,
Wait, $state, CreateSelect2, TemplatesService, ToJSON, Wait, $state, CreateSelect2, TemplatesService, ToJSON,
ParseTypeChange, $q, Rest, GetBasePath, availableLabels, i18n) { ParseTypeChange, $q, Rest, GetBasePath, availableLabels, i18n,
resolvedModels) {
// Inject dynamic view // Inject dynamic view
let form = WorkflowForm(), let form = WorkflowForm(),
generator = GenerateForm; generator = GenerateForm;
function init() { const workflowTemplate = resolvedModels[1];
$scope.canEditOrg = true;
$scope.parseType = 'yaml';
$scope.can_edit = true;
// apply form definition's default field values
GenerateForm.applyDefaults(form, $scope);
// Make the variables textarea look pretty $scope.canAddWorkflowJobTemplate = workflowTemplate.options('actions.POST');
ParseTypeChange({
scope: $scope,
field_id: 'workflow_job_template_variables',
onChange: function() {
// Make sure the form controller knows there was a change
$scope[form.name + '_form'].$setDirty();
}
});
$scope.labelOptions = availableLabels $scope.canEditOrg = true;
.map((i) => ({label: i.name, value: i.id})); $scope.parseType = 'yaml';
$scope.can_edit = true;
// apply form definition's default field values
GenerateForm.applyDefaults(form, $scope);
CreateSelect2({ // Make the variables textarea look pretty
element:'#workflow_job_template_labels', ParseTypeChange({
multiple: true, scope: $scope,
addNew: true field_id: 'workflow_job_template_variables',
}); onChange: function() {
// Make sure the form controller knows there was a change
$scope[form.name + '_form'].$setDirty();
}
});
$scope.workflowEditorTooltip = i18n._("Please save before defining the workflow graph."); $scope.labelOptions = availableLabels
$scope.surveyTooltip = i18n._('Please save before adding a survey to this workflow.'); .map((i) => ({label: i.name, value: i.id}));
}
CreateSelect2({
element:'#workflow_job_template_labels',
multiple: true,
addNew: true
});
$scope.workflowEditorTooltip = i18n._("Please save before defining the workflow graph.");
$scope.surveyTooltip = i18n._('Please save before adding a survey to this workflow.');
$scope.formSave = function () { $scope.formSave = function () {
let fld, data = {}; let fld, data = {};
@ -167,7 +171,5 @@ export default [
$scope.formCancel = function () { $scope.formCancel = function () {
$state.transitionTo('templates'); $state.transitionTo('templates');
}; };
init();
} }
]; ];