diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-03 09:08:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-03 09:08:33 +0300 |
commit | bdfa808bfa4983d67a1ff54e4a3b7070be4d13eb (patch) | |
tree | ab5806e414125dfc8905ff38ed4900d73f072199 /app/assets/javascripts/issuable | |
parent | 00c0098252ac7b303061175ff4c3e002c07407d2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/issuable')
-rw-r--r-- | app/assets/javascripts/issuable/issuable_form.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/app/assets/javascripts/issuable/issuable_form.js b/app/assets/javascripts/issuable/issuable_form.js index adcf2f536e6..a1525ad2bec 100644 --- a/app/assets/javascripts/issuable/issuable_form.js +++ b/app/assets/javascripts/issuable/issuable_form.js @@ -6,6 +6,7 @@ import { parsePikadayDate, pikadayToString } from '~/lib/utils/datetime_utility' import { queryToObject, objectToQuery } from '~/lib/utils/url_utility'; import UsersSelect from '~/users_select'; import ZenMode from '~/zen_mode'; +import { containsSensitiveToken, confirmSensitiveAction, i18n } from '~/lib/utils/secret_detection'; const MR_SOURCE_BRANCH = 'merge_request[source_branch]'; const MR_TARGET_BRANCH = 'merge_request[target_branch]'; @@ -83,6 +84,8 @@ export default class IssuableForm { this.searchTerm = getSearchTerm(form[0].getAttribute(DATA_ISSUES_NEW_PATH)); this.fallbackKey = getFallbackKey(); this.titleField = this.form.find('input[name*="[title]"]'); + this.descriptionField = () => this.form.find('textarea[name*="[description]"]'); + this.submitButton = this.form.find('.js-issuable-submit-button'); this.draftCheck = document.querySelector('input.js-toggle-draft'); if (!this.titleField.length) return; @@ -138,7 +141,21 @@ export default class IssuableForm { return autosaveMap; } - handleSubmit() { + async handleSubmit(event) { + event.preventDefault(); + + const form = event.target; + const descriptionText = this.descriptionField().val(); + + if (containsSensitiveToken(descriptionText)) { + const confirmed = await confirmSensitiveAction(i18n.descriptionPrompt); + if (!confirmed) { + this.submitButton.removeAttr('disabled'); + this.submitButton.removeClass('disabled'); + return false; + } + } + form.submit(); return this.resetAutosave(); } |