From ba8113c3238d04ed753c49303b81a4b8e5ec3f23 Mon Sep 17 00:00:00 2001 From: Sam Bigelow Date: Fri, 26 Apr 2019 10:14:29 -0400 Subject: [PATCH] Init MR Popovers on system note mounted All `renderGFM()` calls are finished before the system note is mounted so this MR inits the popover for each system note, and only the elements in the system note --- .../vue_shared/components/notes/system_note.vue | 4 ++++ .../60855-mr-popover-is-not-attached-in-system-notes.yml | 5 +++++ .../vue_shared/components/notes/system_note_spec.js | 7 +++++++ 3 files changed, 16 insertions(+) create mode 100644 changelogs/unreleased/60855-mr-popover-is-not-attached-in-system-notes.yml diff --git a/app/assets/javascripts/vue_shared/components/notes/system_note.vue b/app/assets/javascripts/vue_shared/components/notes/system_note.vue index acc179b3834..3c86b7e4c61 100644 --- a/app/assets/javascripts/vue_shared/components/notes/system_note.vue +++ b/app/assets/javascripts/vue_shared/components/notes/system_note.vue @@ -22,6 +22,7 @@ import noteHeader from '~/notes/components/note_header.vue'; import Icon from '~/vue_shared/components/icon.vue'; import TimelineEntryItem from './timeline_entry_item.vue'; import { spriteIcon } from '../../../lib/utils/common_utils'; +import initMRPopovers from '~/mr_popover/'; const MAX_VISIBLE_COMMIT_LIST_COUNT = 3; @@ -71,6 +72,9 @@ export default { ); }, }, + mounted() { + initMRPopovers(this.$el.querySelectorAll('.gfm-merge_request')); + }, }; diff --git a/changelogs/unreleased/60855-mr-popover-is-not-attached-in-system-notes.yml b/changelogs/unreleased/60855-mr-popover-is-not-attached-in-system-notes.yml new file mode 100644 index 00000000000..d8bc0fbb4d4 --- /dev/null +++ b/changelogs/unreleased/60855-mr-popover-is-not-attached-in-system-notes.yml @@ -0,0 +1,5 @@ +--- +title: Fix bug where system note MR has no popover +merge_request: 27747 +author: +type: fixed diff --git a/spec/frontend/vue_shared/components/notes/system_note_spec.js b/spec/frontend/vue_shared/components/notes/system_note_spec.js index adcb1c858aa..dc66150ab8d 100644 --- a/spec/frontend/vue_shared/components/notes/system_note_spec.js +++ b/spec/frontend/vue_shared/components/notes/system_note_spec.js @@ -1,6 +1,9 @@ import Vue from 'vue'; import issueSystemNote from '~/vue_shared/components/notes/system_note.vue'; import createStore from '~/notes/stores'; +import initMRPopovers from '~/mr_popover/index'; + +jest.mock('~/mr_popover/index', () => jest.fn()); describe('system note component', () => { let vm; @@ -56,4 +59,8 @@ describe('system note component', () => { it('removes wrapping paragraph from note HTML', () => { expect(vm.$el.querySelector('.system-note-message').innerHTML).toEqual('closed'); }); + + it('should initMRPopovers onMount', () => { + expect(initMRPopovers).toHaveBeenCalled(); + }); });