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:
parent
442c209899
commit
78893590d1
@ -10,14 +10,14 @@
|
||||
'ProcessErrors', 'GetBasePath', 'md5Setup', 'ParseTypeChange', 'Wait',
|
||||
'Empty', 'ToJSON', 'CallbackHelpInit', 'GetChoices', '$state', 'availableLabels',
|
||||
'CreateSelect2', '$q', 'i18n', 'Inventory', 'Project', 'InstanceGroupsService',
|
||||
'MultiCredentialService', 'ConfigData',
|
||||
'MultiCredentialService', 'ConfigData', 'resolvedModels',
|
||||
function(
|
||||
$filter, $scope,
|
||||
$stateParams, JobTemplateForm, GenerateForm, Rest, Alert,
|
||||
ProcessErrors, GetBasePath, md5Setup, ParseTypeChange, Wait,
|
||||
Empty, ToJSON, CallbackHelpInit, GetChoices,
|
||||
$state, availableLabels, CreateSelect2, $q, i18n, Inventory, Project, InstanceGroupsService,
|
||||
MultiCredentialService, ConfigData
|
||||
MultiCredentialService, ConfigData, resolvedModels
|
||||
) {
|
||||
|
||||
// Inject dynamic view
|
||||
@ -28,37 +28,38 @@
|
||||
selectPlaybook, checkSCMStatus,
|
||||
callback;
|
||||
|
||||
init();
|
||||
function init(){
|
||||
// apply form definition's default field values
|
||||
GenerateForm.applyDefaults(form, $scope);
|
||||
const jobTemplate = resolvedModels[0];
|
||||
|
||||
$scope.can_edit = true;
|
||||
$scope.allow_callbacks = false;
|
||||
$scope.playbook_options = [];
|
||||
$scope.mode = "add";
|
||||
$scope.parseType = 'yaml';
|
||||
$scope.credentialNotPresent = false;
|
||||
$scope.canGetAllRelatedResources = true;
|
||||
$scope.canAddJobTemplate = jobTemplate.options('actions.POST');
|
||||
|
||||
md5Setup({
|
||||
scope: $scope,
|
||||
master: master,
|
||||
check_field: 'allow_callbacks',
|
||||
default_val: false
|
||||
});
|
||||
CallbackHelpInit({ scope: $scope });
|
||||
// apply form definition's default field values
|
||||
GenerateForm.applyDefaults(form, $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()
|
||||
.then(({ data }) => {
|
||||
$scope.multiCredential = {
|
||||
credentialTypes: data.results,
|
||||
selectedCredentials: []
|
||||
};
|
||||
});
|
||||
}
|
||||
md5Setup({
|
||||
scope: $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.');
|
||||
|
||||
MultiCredentialService.getCredentialTypes()
|
||||
.then(({ data }) => {
|
||||
$scope.multiCredential = {
|
||||
credentialTypes: data.results,
|
||||
selectedCredentials: []
|
||||
};
|
||||
});
|
||||
|
||||
callback = function() {
|
||||
// Make sure the form controller knows there was a change
|
||||
|
@ -8,43 +8,47 @@ export default [
|
||||
'$scope', 'WorkflowForm', 'GenerateForm', 'Alert', 'ProcessErrors',
|
||||
'Wait', '$state', 'CreateSelect2', 'TemplatesService',
|
||||
'ToJSON', 'ParseTypeChange', '$q', 'Rest', 'GetBasePath', 'availableLabels', 'i18n',
|
||||
'resolvedModels',
|
||||
function($scope, WorkflowForm, GenerateForm, Alert, ProcessErrors,
|
||||
Wait, $state, CreateSelect2, TemplatesService, ToJSON,
|
||||
ParseTypeChange, $q, Rest, GetBasePath, availableLabels, i18n) {
|
||||
ParseTypeChange, $q, Rest, GetBasePath, availableLabels, i18n,
|
||||
resolvedModels) {
|
||||
|
||||
// Inject dynamic view
|
||||
let form = WorkflowForm(),
|
||||
generator = GenerateForm;
|
||||
|
||||
function init() {
|
||||
$scope.canEditOrg = true;
|
||||
$scope.parseType = 'yaml';
|
||||
$scope.can_edit = true;
|
||||
// apply form definition's default field values
|
||||
GenerateForm.applyDefaults(form, $scope);
|
||||
const workflowTemplate = resolvedModels[1];
|
||||
|
||||
// Make the variables textarea look pretty
|
||||
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.canAddWorkflowJobTemplate = workflowTemplate.options('actions.POST');
|
||||
|
||||
$scope.labelOptions = availableLabels
|
||||
.map((i) => ({label: i.name, value: i.id}));
|
||||
$scope.canEditOrg = true;
|
||||
$scope.parseType = 'yaml';
|
||||
$scope.can_edit = true;
|
||||
// apply form definition's default field values
|
||||
GenerateForm.applyDefaults(form, $scope);
|
||||
|
||||
CreateSelect2({
|
||||
element:'#workflow_job_template_labels',
|
||||
multiple: true,
|
||||
addNew: true
|
||||
});
|
||||
// Make the variables textarea look pretty
|
||||
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.workflowEditorTooltip = i18n._("Please save before defining the workflow graph.");
|
||||
$scope.surveyTooltip = i18n._('Please save before adding a survey to this workflow.');
|
||||
}
|
||||
$scope.labelOptions = availableLabels
|
||||
.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 () {
|
||||
let fld, data = {};
|
||||
@ -167,7 +171,5 @@ export default [
|
||||
$scope.formCancel = function () {
|
||||
$state.transitionTo('templates');
|
||||
};
|
||||
|
||||
init();
|
||||
}
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user