Commit 04923963 authored by Illya Klymov's avatar Illya Klymov

Merge branch 'mg-remove-sanitize-html-from-main-bundle' into 'master'

Remove sanitize-html dependency from the main bundle

See merge request gitlab-org/gitlab!32628
parents 40ddc92c d1e5923f
import $ from 'jquery'; import $ from 'jquery';
import Vue from 'vue'; import Vue from 'vue';
import Translate from '~/vue_shared/translate'; import Translate from '~/vue_shared/translate';
import eventHub from '~/frequent_items/event_hub'; import eventHub from './event_hub';
import frequentItems from './components/app.vue';
Vue.use(Translate); Vue.use(Translate);
...@@ -17,7 +16,7 @@ const frequentItemDropdowns = [ ...@@ -17,7 +16,7 @@ const frequentItemDropdowns = [
}, },
]; ];
const initFrequentItemDropdowns = () => { export default function initFrequentItemDropdowns() {
frequentItemDropdowns.forEach(dropdown => { frequentItemDropdowns.forEach(dropdown => {
const { namespace, key } = dropdown; const { namespace, key } = dropdown;
const el = document.getElementById(`js-${namespace}-dropdown`); const el = document.getElementById(`js-${namespace}-dropdown`);
...@@ -29,45 +28,40 @@ const initFrequentItemDropdowns = () => { ...@@ -29,45 +28,40 @@ const initFrequentItemDropdowns = () => {
return; return;
} }
$(navEl).on('shown.bs.dropdown', () => { $(navEl).on('shown.bs.dropdown', () =>
eventHub.$emit(`${namespace}-dropdownOpen`); import('./components/app.vue').then(({ default: FrequentItems }) => {
}); // eslint-disable-next-line no-new
new Vue({
el,
data() {
const { dataset } = this.$options.el;
const item = {
id: Number(dataset[`${key}Id`]),
name: dataset[`${key}Name`],
namespace: dataset[`${key}Namespace`],
webUrl: dataset[`${key}WebUrl`],
avatarUrl: dataset[`${key}AvatarUrl`] || null,
lastAccessedOn: Date.now(),
};
// eslint-disable-next-line no-new return {
new Vue({ currentUserName: dataset.userName,
el, currentItem: item,
components: { };
frequentItems, },
}, render(createElement) {
data() { return createElement(FrequentItems, {
const { dataset } = this.$options.el; props: {
const item = { namespace,
id: Number(dataset[`${key}Id`]), currentUserName: this.currentUserName,
name: dataset[`${key}Name`], currentItem: this.currentItem,
namespace: dataset[`${key}Namespace`], },
webUrl: dataset[`${key}WebUrl`], });
avatarUrl: dataset[`${key}AvatarUrl`] || null,
lastAccessedOn: Date.now(),
};
return {
currentUserName: dataset.userName,
currentItem: item,
};
},
render(createElement) {
return createElement('frequent-items', {
props: {
namespace,
currentUserName: this.currentUserName,
currentItem: this.currentItem,
}, },
}); });
},
});
});
};
document.addEventListener('DOMContentLoaded', () => { eventHub.$emit(`${namespace}-dropdownOpen`);
requestIdleCallback(initFrequentItemDropdowns); }),
}); );
});
}
...@@ -28,7 +28,7 @@ import initLayoutNav from './layout_nav'; ...@@ -28,7 +28,7 @@ import initLayoutNav from './layout_nav';
import './feature_highlight/feature_highlight_options'; import './feature_highlight/feature_highlight_options';
import LazyLoader from './lazy_loader'; import LazyLoader from './lazy_loader';
import initLogoAnimation from './logo'; import initLogoAnimation from './logo';
import './frequent_items'; import initFrequentItemDropdowns from './frequent_items';
import initBreadcrumbs from './breadcrumb'; import initBreadcrumbs from './breadcrumb';
import initUsagePingConsent from './usage_ping_consent'; import initUsagePingConsent from './usage_ping_consent';
import initPerformanceBar from './performance_bar'; import initPerformanceBar from './performance_bar';
...@@ -107,6 +107,7 @@ function deferredInitialisation() { ...@@ -107,6 +107,7 @@ function deferredInitialisation() {
initUsagePingConsent(); initUsagePingConsent();
initUserPopovers(); initUserPopovers();
initBroadcastNotifications(); initBroadcastNotifications();
initFrequentItemDropdowns();
const recoverySettingsCallout = document.querySelector('.js-recovery-settings-callout'); const recoverySettingsCallout = document.querySelector('.js-recovery-settings-callout');
PersistentUserCallout.factory(recoverySettingsCallout); PersistentUserCallout.factory(recoverySettingsCallout);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment