diff options
author | kushalpandya <kushal@gitlab.com> | 2017-05-29 09:46:34 +0300 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-06-01 08:47:15 +0300 |
commit | 44f2504a811b107a35403d9c0a8b8fce66f502c8 (patch) | |
tree | 1e7a66d90e05c20200d764996e3f93e47614edf1 /app/assets/javascripts/integrations | |
parent | 095d9b5b238caf27ac9a9023bfed81629e9ecb5c (diff) |
Initialize canTestService from form meta
Diffstat (limited to 'app/assets/javascripts/integrations')
-rw-r--r-- | app/assets/javascripts/integrations/integration_settings_form.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/assets/javascripts/integrations/integration_settings_form.js b/app/assets/javascripts/integrations/integration_settings_form.js index 499d73b49a4..5d555a3776e 100644 --- a/app/assets/javascripts/integrations/integration_settings_form.js +++ b/app/assets/javascripts/integrations/integration_settings_form.js @@ -6,6 +6,7 @@ export default class IntegrationSettingsForm { // Form Metadata this.endPoint = this.$form.attr('action'); + this.canTestService = this.$form.data('can-test'); // Form Child Elements this.$serviceToggle = this.$form.find('#service_active'); @@ -31,7 +32,8 @@ export default class IntegrationSettingsForm { handleSettingsSave(e) { if (this.$serviceToggle.is(':checked')) { - if (this.$form.get(0).checkValidity()) { + if (this.$form.get(0).checkValidity() && + this.canTestService) { e.preventDefault(); this.testSettings(this.$form.serialize()); } @@ -43,7 +45,7 @@ export default class IntegrationSettingsForm { } toggleServiceState(serviceActive) { - this.toggleSubmitBtnLabel(serviceActive); + this.toggleSubmitBtnLabel(serviceActive, this.canTestService); if (serviceActive) { this.$form.removeAttr('novalidate'); } else if (!this.$form.attr('novalidate')) { @@ -54,9 +56,9 @@ export default class IntegrationSettingsForm { /** * Toggle Submit button label based on Integration status */ - toggleSubmitBtnLabel(serviceActive) { + toggleSubmitBtnLabel(serviceActive, canTestService) { this.$submitBtnLabel.text( - serviceActive ? + serviceActive && canTestService ? 'Test settings and save changes' : 'Save changes'); } |