summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkushalpandya <kushal@gitlab.com>2017-05-25 15:05:19 +0530
committerJarka Kadlecova <jarka@gitlab.com>2017-06-01 07:47:15 +0200
commitc5e28a7b411fee60b9151f1477c420af46bcdf02 (patch)
tree2c621450aa09cd5823b538b9463b730f1f363511
parent791e5024efbfaadf342f9a019b59e65af0249c3b (diff)
downloadgitlab-ce-c5e28a7b411fee60b9151f1477c420af46bcdf02.tar.gz
Validate config form only when service is marked active
-rw-r--r--app/assets/javascripts/integrations/integration_settings_form.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/app/assets/javascripts/integrations/integration_settings_form.js b/app/assets/javascripts/integrations/integration_settings_form.js
index bb551b5bb4c..499d73b49a4 100644
--- a/app/assets/javascripts/integrations/integration_settings_form.js
+++ b/app/assets/javascripts/integrations/integration_settings_form.js
@@ -22,7 +22,7 @@ export default class IntegrationSettingsForm {
init() {
// Initialize View
- this.toggleSubmitBtnLabel(this.$serviceToggle.is(':checked'));
+ this.toggleServiceState(this.$serviceToggle.is(':checked'));
// Bind Event Listeners
this.$serviceToggle.on('change', this.handleServiceToggle);
@@ -31,13 +31,24 @@ export default class IntegrationSettingsForm {
handleSettingsSave(e) {
if (this.$serviceToggle.is(':checked')) {
- e.preventDefault();
- this.testSettings(this.$form.serialize());
+ if (this.$form.get(0).checkValidity()) {
+ e.preventDefault();
+ this.testSettings(this.$form.serialize());
+ }
}
}
handleServiceToggle(e) {
- this.toggleSubmitBtnLabel($(e.currentTarget).is(':checked'));
+ this.toggleServiceState($(e.currentTarget).is(':checked'));
+ }
+
+ toggleServiceState(serviceActive) {
+ this.toggleSubmitBtnLabel(serviceActive);
+ if (serviceActive) {
+ this.$form.removeAttr('novalidate');
+ } else if (!this.$form.attr('novalidate')) {
+ this.$form.attr('novalidate', 'novalidate');
+ }
}
/**