Commit 491e013d authored by Enrique Alcantara's avatar Enrique Alcantara Committed by Denys Mishunov

Only load required javascript in Wiki pages

Limit load clone panel in git_access page
Limit various edit applications to the create and edit pages
Only load diff stats dropdown in diff page
parent 0c7e4c55
import { initDiffStatsDropdown } from '~/init_diff_stats_dropdown';
initDiffStatsDropdown();
import { mountApplications } from '~/pages/shared/wikis/edit';
mountApplications();
import initClonePanel from '~/clone_panel';
initClonePanel();
import { initDiffStatsDropdown } from '~/init_diff_stats_dropdown'; import Wikis from '~/pages/shared/wikis/wikis';
import initWikis from '~/pages/shared/wikis';
initWikis(); export default new Wikis();
initDiffStatsDropdown();
import { mountApplications as mountEditApplications } from '~/pages/shared/wikis/async_edit';
mountEditApplications();
export const mountApplications = async () => {
const el = document.querySelector('.js-wiki-edit-page');
if (el) {
const { mountApplications: mountEditApplications } = await import(
/* webpackChunkName: 'wiki_edit' */ './edit'
);
mountEditApplications();
}
};
import $ from 'jquery'; import $ from 'jquery';
import Vue from 'vue'; import Vue from 'vue';
import ShortcutsWiki from '~/behaviors/shortcuts/shortcuts_wiki';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import csrf from '~/lib/utils/csrf'; import csrf from '~/lib/utils/csrf';
import Translate from '~/vue_shared/translate'; import Translate from '~/vue_shared/translate';
...@@ -9,14 +8,8 @@ import ZenMode from '../../../zen_mode'; ...@@ -9,14 +8,8 @@ import ZenMode from '../../../zen_mode';
import deleteWikiModal from './components/delete_wiki_modal.vue'; import deleteWikiModal from './components/delete_wiki_modal.vue';
import wikiAlert from './components/wiki_alert.vue'; import wikiAlert from './components/wiki_alert.vue';
import wikiForm from './components/wiki_form.vue'; import wikiForm from './components/wiki_form.vue';
import Wikis from './wikis';
const createModalVueApp = () => { const createModalVueApp = () => {
new Wikis(); // eslint-disable-line no-new
new ShortcutsWiki(); // eslint-disable-line no-new
new ZenMode(); // eslint-disable-line no-new
new GLForm($('.wiki-form')); // eslint-disable-line no-new
const deleteWikiModalWrapperEl = document.getElementById('delete-wiki-modal-wrapper'); const deleteWikiModalWrapperEl = document.getElementById('delete-wiki-modal-wrapper');
if (deleteWikiModalWrapperEl) { if (deleteWikiModalWrapperEl) {
...@@ -85,7 +78,10 @@ const createWikiFormApp = () => { ...@@ -85,7 +78,10 @@ const createWikiFormApp = () => {
} }
}; };
export default () => { export const mountApplications = () => {
new ZenMode(); // eslint-disable-line no-new
new GLForm($('.wiki-form')); // eslint-disable-line no-new
createModalVueApp(); createModalVueApp();
createAlertVueApp(); createAlertVueApp();
createWikiFormApp(); createWikiFormApp();
......
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import showToast from '~/vue_shared/plugins/global_toast'; import showToast from '~/vue_shared/plugins/global_toast';
import ShortcutsWiki from '~/behaviors/shortcuts/shortcuts_wiki';
const TRACKING_EVENT_NAME = 'view_wiki_page'; const TRACKING_EVENT_NAME = 'view_wiki_page';
const TRACKING_CONTEXT_SCHEMA = 'iglu:com.gitlab/wiki_page_context/jsonschema/1-0-1'; const TRACKING_CONTEXT_SCHEMA = 'iglu:com.gitlab/wiki_page_context/jsonschema/1-0-1';
...@@ -20,6 +21,7 @@ export default class Wikis { ...@@ -20,6 +21,7 @@ export default class Wikis {
Wikis.trackPageView(); Wikis.trackPageView();
Wikis.showToasts(); Wikis.showToasts();
Wikis.initShortcuts();
} }
handleToggleSidebar(e) { handleToggleSidebar(e) {
...@@ -64,4 +66,8 @@ export default class Wikis { ...@@ -64,4 +66,8 @@ export default class Wikis {
const toasts = document.querySelectorAll('.js-toast-message'); const toasts = document.querySelectorAll('.js-toast-message');
toasts.forEach((toast) => showToast(toast.dataset.message)); toasts.forEach((toast) => showToast(toast.dataset.message));
} }
static initShortcuts() {
new ShortcutsWiki(); // eslint-disable-line no-new
}
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
- if @error - if @error
#js-wiki-error{ data: { error: @error, wiki_page_path: wiki_page_path(@wiki, @page) } } #js-wiki-error{ data: { error: @error, wiki_page_path: wiki_page_path(@wiki, @page) } }
.wiki-page-header.top-area.has-sidebar-toggle.flex-column.flex-lg-row .js-wiki-edit-page.wiki-page-header.top-area.has-sidebar-toggle.flex-column.flex-lg-row
= wiki_sidebar_toggle_button = wiki_sidebar_toggle_button
%h3.page-title.gl-flex-grow-1 %h3.page-title.gl-flex-grow-1
......
import { initDiffStatsDropdown } from '~/init_diff_stats_dropdown';
initDiffStatsDropdown();
import { mountApplications } from '~/pages/shared/wikis/edit';
mountApplications();
import initClonePanel from '~/clone_panel';
initClonePanel();
import initClonePanel from '~/clone_panel'; import Wikis from '~/pages/shared/wikis/wikis';
import { initDiffStatsDropdown } from '~/init_diff_stats_dropdown';
import initWikis from '~/pages/shared/wikis';
initWikis(); export default new Wikis();
initClonePanel();
initDiffStatsDropdown();
import { mountApplications as mountEditApplications } from '~/pages/shared/wikis/async_edit';
mountEditApplications();
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