From d49193c42d9ffd98f645426697fcadded6c8ed8a Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 12 Jun 2017 14:42:12 -0500 Subject: Disable autocomplete on snippets comments Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/33594 Was supposedly fixed in MR for https://gitlab.com/gitlab-org/gitlab-ce/issues/32086 but seeing this pop up again --- app/assets/javascripts/dispatcher.js | 13 ++++++++++++- app/views/projects/_zen.html.haml | 6 +++++- app/views/projects/snippets/show.html.haml | 2 +- app/views/shared/notes/_form.html.haml | 3 ++- app/views/shared/notes/_notes_with_form.html.haml | 2 +- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 5f87a05067b..e4901f85647 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -79,7 +79,18 @@ import initSettingsPanels from './settings_panels'; path = page.split(':'); shortcut_handler = null; - new GfmAutoComplete(gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources).setup(); + $('.js-gfm-input').each((i, el) => { + const gfm = new GfmAutoComplete(gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources); + const enableGFM = gl.utils.convertPermissionToBoolean(el.dataset.supportsAutocomplete); + gfm.setup($(el), { + emojis: true, + members: enableGFM, + issues: enableGFM, + milestones: enableGFM, + mergeRequests: enableGFM, + labels: enableGFM, + }); + }); function initBlob() { new LineHighlighter(); diff --git a/app/views/projects/_zen.html.haml b/app/views/projects/_zen.html.haml index 3b3d08ddd3c..3112e4d57e6 100644 --- a/app/views/projects/_zen.html.haml +++ b/app/views/projects/_zen.html.haml @@ -4,7 +4,11 @@ .zen-backdrop - classes << ' js-gfm-input js-autosize markdown-area' - if defined?(f) && f - = f.text_area attr, class: classes, placeholder: placeholder, data: { supports_slash_commands: supports_slash_commands } + = f.text_area attr, + class: classes, + placeholder: placeholder, + data: { supports_slash_commands: supports_slash_commands, + supports_autocomplete: supports_autocomplete } - else = text_area_tag attr, current_text, class: classes, placeholder: placeholder %a.zen-control.zen-control-leave.js-zen-leave{ href: "#" } diff --git a/app/views/projects/snippets/show.html.haml b/app/views/projects/snippets/show.html.haml index 847f3c2f348..37b114e7a3a 100644 --- a/app/views/projects/snippets/show.html.haml +++ b/app/views/projects/snippets/show.html.haml @@ -9,4 +9,4 @@ .row-content-block.top-block.content-component-block = render 'award_emoji/awards_block', awardable: @snippet, inline: true - #notes= render "shared/notes/notes_with_form", :autocomplete => true + #notes= render "shared/notes/notes_with_form", :autocomplete => false diff --git a/app/views/shared/notes/_form.html.haml b/app/views/shared/notes/_form.html.haml index eaf50bc2115..a9c325f6cda 100644 --- a/app/views/shared/notes/_form.html.haml +++ b/app/views/shared/notes/_form.html.haml @@ -27,7 +27,8 @@ attr: :note, classes: 'note-textarea js-note-text', placeholder: "Write a comment or drag your files here...", - supports_slash_commands: supports_slash_commands + supports_slash_commands: supports_slash_commands, + supports_autocomplete: supports_autocomplete = render 'shared/notes/hints', supports_slash_commands: supports_slash_commands .error-alert diff --git a/app/views/shared/notes/_notes_with_form.html.haml b/app/views/shared/notes/_notes_with_form.html.haml index 5902798dfd0..0cca8d875d2 100644 --- a/app/views/shared/notes/_notes_with_form.html.haml +++ b/app/views/shared/notes/_notes_with_form.html.haml @@ -12,7 +12,7 @@ %a.author_link{ href: user_path(current_user) } = image_tag avatar_icon(current_user), alt: current_user.to_reference, class: 'avatar s40' .timeline-content.timeline-content-form - = render "shared/notes/form", view: diff_view + = render "shared/notes/form", view: diff_view, supports_autocomplete: autocomplete - elsif !current_user .disabled-comment.text-center.prepend-top-default Please -- cgit v1.2.1