From cadbf5f22d586bac25696e75b33321f33dd356af Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Wed, 4 Sep 2013 15:11:21 -0400 Subject: [PATCH] AC-395 Changed txt of 'No unassigned playbook directories' message. Message now displays in the form rather than via a modal dialog. The message is only displayed when scm_type is manual and all project directories are already assigned. --- awx/ui/static/js/controllers/Projects.js | 8 ++++++-- awx/ui/static/js/forms/Projects.js | 10 ++++++++++ awx/ui/static/js/helpers/ProjectPath.js | 11 ++++------- awx/ui/static/less/ansible-ui.less | 4 ++++ awx/ui/static/lib/ansible/form-generator.js | 9 +++++++++ 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/awx/ui/static/js/controllers/Projects.js b/awx/ui/static/js/controllers/Projects.js index 321d3793e9..7b484b60a0 100644 --- a/awx/ui/static/js/controllers/Projects.js +++ b/awx/ui/static/js/controllers/Projects.js @@ -161,7 +161,9 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam } } else { - data[fld] = scope[fld]; + if (form.fields[fld].type !== 'alertblock') { + data[fld] = scope[fld]; + } } } if (scope.scm_type) { @@ -339,7 +341,9 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara } } else { - params[fld] = scope[fld]; + if (form.fields[fld].type !== 'alertblock') { + params[fld] = scope[fld]; + } } } if (scope.scm_type) { diff --git a/awx/ui/static/js/forms/Projects.js b/awx/ui/static/js/forms/Projects.js index 0c33c92b82..6534cb0f0e 100644 --- a/awx/ui/static/js/forms/Projects.js +++ b/awx/ui/static/js/forms/Projects.js @@ -55,6 +55,16 @@ angular.module('ProjectFormDefinition', []) addRequired: false, editRequired: false }, + missing_path_alert: { + type: 'alertblock', + "class": 'alert-info col-lg-6 col-lg-offset-2', + ngShow: 'showMissingPlaybooksAlert && !scm_type', + alertTxt: '

WARNING: There are no unassigned playbook directories in the base project path {{ base_dir }}. Either the projects ' + + 'directory is empty, or all of the contents are already assigned to other projects. New projects can be checked out from source control by ' + + 'changing the SCM type option rather than specifying checkout paths manually. To continue with manual setup, log into the AWX server and ' + + 'ensure content is present in a subdirectory under {{ base_dir }}. Run "chown -R awx" on the content directory to ensure awx can read the ' + + 'playbooks.

' + }, base_dir: { label: 'Project Base Path', type: 'textarea', diff --git a/awx/ui/static/js/helpers/ProjectPath.js b/awx/ui/static/js/helpers/ProjectPath.js index 5c44ea214b..32df848d4c 100644 --- a/awx/ui/static/js/helpers/ProjectPath.js +++ b/awx/ui/static/js/helpers/ProjectPath.js @@ -16,6 +16,8 @@ angular.module('ProjectPathHelper', ['RestServices', 'Utilities']) var scope = params.scope; var master = params.master; + + scope.showMissingPlaybooksAlert = false; Rest.setUrl( GetBasePath('config') ); Rest.get() @@ -31,14 +33,9 @@ angular.module('ProjectPathHelper', ['RestServices', 'Utilities']) scope.base_dir = data.project_base_dir; master.base_dir = scope.base_dir; // Keep in master object so that it doesn't get // wiped out on form reset. - console.log('base_dir: ' + scope.base_dir); if (opts.length == 0) { - Alert('Missing Playbooks', - '

There are no unassigned playbook directories in the base project path (' + scope.base_dir + '). ' + - 'Either the project directory is empty, or all of the contents are already assigned to other AWX projects.

' + - '

To fix this, log into the AWX server and check out another playbook project from your SCM repository into ' + - scope.base_dir + '. After checking out the project, run "chown -R awx" on the content directory to ' + - 'ensure awx can read the playbooks.

', 'alert-info'); + // trigger display of alert block when scm_type == manual + scope.showMissingPlaybooksAlert = true; } }) .error( function(data, status, headers, config) { diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index 1fe7ac2421..a6a42a5b98 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -160,6 +160,10 @@ hr { color: @blue; } +.text-justify { + text-align: justify; +} + /* Using inline-block rather than block keeps brand img from right aligning into the collapse button on mobile screens */ diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index ce0a6aee68..e08607bc8e 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -337,6 +337,15 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies']) var html = ''; + if (field.type == 'alertblock') { + html += "
×\n"; + html += field.alertTxt; + html += "
\n"; + } + if (field.type == 'hidden') { if ( (options.mode == 'edit' && field.includeOnEdit) || (options.mode == 'add' && field.includeOnAdd) ) {