diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/assets/javascripts/blob_edit | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/assets/javascripts/blob_edit')
-rw-r--r-- | app/assets/javascripts/blob_edit/blob_bundle.js | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/app/assets/javascripts/blob_edit/blob_bundle.js b/app/assets/javascripts/blob_edit/blob_bundle.js index 2d426ee663a..f84e39baa53 100644 --- a/app/assets/javascripts/blob_edit/blob_bundle.js +++ b/app/assets/javascripts/blob_edit/blob_bundle.js @@ -8,11 +8,40 @@ import initPopover from '~/blob/suggest_gitlab_ci_yml'; import { disableButtonIfEmptyField, setCookie } from '~/lib/utils/common_utils'; import Tracking from '~/tracking'; +const initPopovers = () => { + const suggestEl = document.querySelector('.js-suggest-gitlab-ci-yml'); + + if (suggestEl) { + const commitButton = document.querySelector('#commit-changes'); + + initPopover(suggestEl); + + if (commitButton) { + const { dismissKey, humanAccess } = suggestEl.dataset; + const urlParams = new URLSearchParams(window.location.search); + const mergeRequestPath = urlParams.get('mr_path') || true; + + const commitCookieName = `suggest_gitlab_ci_yml_commit_${dismissKey}`; + const commitTrackLabel = 'suggest_gitlab_ci_yml_commit_changes'; + const commitTrackValue = '20'; + + commitButton.addEventListener('click', () => { + setCookie(commitCookieName, mergeRequestPath); + + Tracking.event(undefined, 'click_button', { + label: commitTrackLabel, + property: humanAccess, + value: commitTrackValue, + }); + }); + } + } +}; + export default () => { const editBlobForm = $('.js-edit-blob-form'); const uploadBlobForm = $('.js-upload-blob-form'); const deleteBlobForm = $('.js-delete-blob-form'); - const suggestEl = document.querySelector('.js-suggest-gitlab-ci-yml'); if (editBlobForm.length) { const urlRoot = editBlobForm.data('relativeUrlRoot'); @@ -33,6 +62,7 @@ export default () => { projectId, isMarkdown, }); + initPopovers(); }) .catch(e => createFlash(e)); @@ -62,30 +92,4 @@ export default () => { if (deleteBlobForm.length) { new NewCommitForm(deleteBlobForm); } - - if (suggestEl) { - const commitButton = document.querySelector('#commit-changes'); - - initPopover(suggestEl); - - if (commitButton) { - const { dismissKey, humanAccess } = suggestEl.dataset; - const urlParams = new URLSearchParams(window.location.search); - const mergeRequestPath = urlParams.get('mr_path') || true; - - const commitCookieName = `suggest_gitlab_ci_yml_commit_${dismissKey}`; - const commitTrackLabel = 'suggest_gitlab_ci_yml_commit_changes'; - const commitTrackValue = '20'; - - commitButton.addEventListener('click', () => { - setCookie(commitCookieName, mergeRequestPath); - - Tracking.event(undefined, 'click_button', { - label: commitTrackLabel, - property: humanAccess, - value: commitTrackValue, - }); - }); - } - } }; |