diff --git a/app/assets/javascripts/app/controllers/_integration/ldap.coffee b/app/assets/javascripts/app/controllers/_integration/ldap.coffee index bdc280e56..6ad15ea1c 100644 --- a/app/assets/javascripts/app/controllers/_integration/ldap.coffee +++ b/app/assets/javascripts/app/controllers/_integration/ldap.coffee @@ -152,7 +152,7 @@ class ConnectionWizard extends App.WizardModal 'click .js-userMappingForm .js-add': 'addUserMapping' 'click .js-groupRoleForm .js-add': 'addGroupRoleMapping' 'click .js-goToSlide': 'goToSlide' - 'input .js-hostUrl': 'checkSslVerifyDisabled' + 'input .js-hostUrl': 'sslVerifyChange' elements: '.modal-body': 'body' @@ -205,13 +205,27 @@ class ConnectionWizard extends App.WizardModal showHost: => @$('.js-discover input[name="host_url"]').val(@wizardConfig.host_url) - @showSslVerify() + @checkSslVerifyVisibility(@wizardConfig.host_url) + + sslVerifyChange: (e) => + @checkSslVerifyVisibility($(e.currentTarget).val()) + + checkSslVerifyVisibility: (host_url) => + el = @$('.js-discover .js-sslVerify') + exists = el.length - showSslVerify: => disabled = true - if @wizardConfig.host_url && @wizardConfig.host_url.startsWith('ldaps') + if host_url && host_url.startsWith('ldaps') disabled = false + if exists && disabled + el.parent().remove() + else if !exists && !disabled + @$('.js-discover tbody tr').last().after(@buildRowSslVerify()) + + buildRowSslVerify: => + el = $(App.view('integration/ldap_ssl_verify_row')()) + ssl_verify = true if typeof @wizardConfig.ssl_verify != 'undefined' ssl_verify = @wizardConfig.ssl_verify @@ -221,15 +235,11 @@ class ConnectionWizard extends App.WizardModal null: false options: { true: 'yes', false: 'no' } default: ssl_verify - disabled: disabled translate: true class: 'form-control form-control--small' ) - @$('.js-discover .js-sslVerify').html sslVerifyElement - - checkSslVerifyDisabled: (e) => - enabled = $(e.currentTarget).val().startsWith('ldaps') - @$('.js-discover .js-sslVerify select[name="ssl_verify"]').prop('disabled', !enabled) + el.find('.js-sslVerify').html sslVerifyElement + el discover: (e) => e.preventDefault() diff --git a/app/assets/javascripts/app/views/integration/ldap_ssl_verify_row.jst.eco b/app/assets/javascripts/app/views/integration/ldap_ssl_verify_row.jst.eco new file mode 100644 index 000000000..5746838eb --- /dev/null +++ b/app/assets/javascripts/app/views/integration/ldap_ssl_verify_row.jst.eco @@ -0,0 +1,3 @@ +