diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-03-27 21:42:23 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-03-27 21:42:23 +0000 |
commit | 89fdf64c8a3764cf8c646cb4b9eb9b11a3871eae (patch) | |
tree | 8b31028a23cbb3a8b39375b3992f7423b3d5705f /app/assets/javascripts/ci_variable_list | |
parent | 1b26f3c536682b8989710e70aeb702f76cad9b92 (diff) | |
download | gitlab-ce-89fdf64c8a3764cf8c646cb4b9eb9b11a3871eae.tar.gz |
Revert "Merge branch '13784-validate-variables-for-masking' into 'master'"
This reverts merge request !25476
Diffstat (limited to 'app/assets/javascripts/ci_variable_list')
-rw-r--r-- | app/assets/javascripts/ci_variable_list/ci_variable_list.js | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/app/assets/javascripts/ci_variable_list/ci_variable_list.js b/app/assets/javascripts/ci_variable_list/ci_variable_list.js index da3100b9386..5b20fa141cd 100644 --- a/app/assets/javascripts/ci_variable_list/ci_variable_list.js +++ b/app/assets/javascripts/ci_variable_list/ci_variable_list.js @@ -40,12 +40,6 @@ export default class VariableList { // converted. we need the value as a string. default: $('.js-ci-variable-input-protected').attr('data-default'), }, - masked: { - selector: '.js-ci-variable-input-masked', - // use `attr` instead of `data` as we don't want the value to be - // converted. we need the value as a string. - default: $('.js-ci-variable-input-masked').attr('data-default'), - }, environment_scope: { // We can't use a `.js-` class here because // gl_dropdown replaces the <input> and doesn't copy over the class @@ -94,16 +88,13 @@ export default class VariableList { } }); - this.$container.on('input trigger-change', inputSelector, e => { - // Always make sure there is an empty last row + // Always make sure there is an empty last row + this.$container.on('input trigger-change', inputSelector, () => { const $lastRow = this.$container.find('.js-row').last(); if (this.checkIfRowTouched($lastRow)) { this.insertRow($lastRow); } - - // If masked, validate value against regex - this.validateMaskability($(e.currentTarget).closest('.js-row')); }); } @@ -180,33 +171,12 @@ export default class VariableList { checkIfRowTouched($row) { return Object.keys(this.inputMap).some(name => { - // Row should not qualify as touched if only switches have been touched - if (['protected', 'masked'].includes(name)) return false; - const entry = this.inputMap[name]; const $el = $row.find(entry.selector); return $el.length && $el.val() !== entry.default; }); } - validateMaskability($row) { - const invalidInputClass = 'gl-field-error-outline'; - - const maskableRegex = /^\w{8,}$/; // Eight or more alphanumeric characters plus underscores - const variableValue = $row.find(this.inputMap.secret_value.selector).val(); - const isValueMaskable = maskableRegex.test(variableValue) || variableValue === ''; - const isMaskedChecked = $row.find(this.inputMap.masked.selector).val() === 'true'; - - // Show a validation error if the user wants to mask an unmaskable variable value - $row - .find(this.inputMap.secret_value.selector) - .toggleClass(invalidInputClass, isMaskedChecked && !isValueMaskable); - $row - .find('.js-secret-value-placeholder') - .toggleClass(invalidInputClass, isMaskedChecked && !isValueMaskable); - $row.find('.masking-validation-error').toggle(isMaskedChecked && !isValueMaskable); - } - toggleEnableRow(isEnabled = true) { this.$container.find(this.inputMap.key.selector).attr('disabled', !isEnabled); this.$container.find('.js-row-remove-button').attr('disabled', !isEnabled); |