Commit b2363483 authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'fix-more-dispatcher-stuff' into 'master'

Remove more route-based chunks from dispatcher.js

See merge request gitlab-org/gitlab-ce!16901
parents 8462e229 b63674e2
...@@ -43,169 +43,14 @@ var Dispatcher; ...@@ -43,169 +43,14 @@ var Dispatcher;
}); });
switch (page) { switch (page) {
case 'projects:environments:metrics':
import('./pages/projects/environments/metrics')
.then(callDefault)
.catch(fail);
break;
case 'projects:merge_requests:index': case 'projects:merge_requests:index':
case 'projects:issues:index': case 'projects:issues:index':
case 'projects:issues:show': case 'projects:issues:show':
shortcut_handler = true;
break;
case 'projects:milestones:index':
import('./pages/projects/milestones/index')
.then(callDefault)
.catch(fail);
break;
case 'projects:milestones:show':
import('./pages/projects/milestones/show')
.then(callDefault)
.catch(fail);
break;
case 'groups:milestones:show':
import('./pages/groups/milestones/show')
.then(callDefault)
.catch(fail);
break;
case 'dashboard:milestones:show':
import('./pages/dashboard/milestones/show')
.then(callDefault)
.catch(fail);
break;
case 'dashboard:issues':
import('./pages/dashboard/issues')
.then(callDefault)
.catch(fail);
break;
case 'dashboard:merge_requests':
import('./pages/dashboard/merge_requests')
.then(callDefault)
.catch(fail);
break;
case 'groups:issues':
import('./pages/groups/issues')
.then(callDefault)
.catch(fail);
break;
case 'groups:merge_requests':
import('./pages/groups/merge_requests')
.then(callDefault)
.catch(fail);
break;
case 'dashboard:todos:index':
import('./pages/dashboard/todos/index')
.then(callDefault)
.catch(fail);
break;
case 'admin:jobs:index':
import('./pages/admin/jobs/index')
.then(callDefault)
.catch(fail);
break;
case 'admin:projects:index':
import('./pages/admin/projects/index/index')
.then(callDefault)
.catch(fail);
break;
case 'admin:users:index':
import('./pages/admin/users/shared')
.then(callDefault)
.catch(fail);
break;
case 'admin:users:show':
import('./pages/admin/users/shared')
.then(callDefault)
.catch(fail);
break;
case 'dashboard:projects:index':
case 'dashboard:projects:starred':
import('./pages/dashboard/projects')
.then(callDefault)
.catch(fail);
break;
case 'explore:projects:index':
case 'explore:projects:trending':
case 'explore:projects:starred':
import('./pages/explore/projects')
.then(callDefault)
.catch(fail);
break;
case 'explore:groups:index':
import('./pages/explore/groups')
.then(callDefault)
.catch(fail);
break;
case 'projects:milestones:new':
case 'projects:milestones:create':
import('./pages/projects/milestones/new')
.then(callDefault)
.catch(fail);
break;
case 'projects:milestones:edit':
case 'projects:milestones:update':
import('./pages/projects/milestones/edit')
.then(callDefault)
.catch(fail);
break;
case 'groups:milestones:new':
case 'groups:milestones:create':
import('./pages/groups/milestones/new')
.then(callDefault)
.catch(fail);
break;
case 'groups:milestones:edit':
case 'groups:milestones:update':
import('./pages/groups/milestones/edit')
.then(callDefault)
.catch(fail);
break;
case 'projects:compare:show':
import('./pages/projects/compare/show')
.then(callDefault)
.catch(fail);
break;
case 'projects:branches:new':
import('./pages/projects/branches/new')
.then(callDefault)
.catch(fail);
break;
case 'projects:branches:create':
import('./pages/projects/branches/new')
.then(callDefault)
.catch(fail);
break;
case 'projects:branches:index':
import('./pages/projects/branches/index')
.then(callDefault)
.catch(fail);
break;
case 'projects:issues:new': case 'projects:issues:new':
import('./pages/projects/issues/new')
.then(callDefault)
.catch(fail);
shortcut_handler = true;
break;
case 'projects:issues:edit': case 'projects:issues:edit':
import('./pages/projects/issues/edit')
.then(callDefault)
.catch(fail);
shortcut_handler = true;
break;
case 'projects:merge_requests:creations:new': case 'projects:merge_requests:creations:new':
import('./pages/projects/merge_requests/creations/new')
.then(callDefault)
.catch(fail);
case 'projects:merge_requests:creations:diffs': case 'projects:merge_requests:creations:diffs':
import('./pages/projects/merge_requests/creations/diffs')
.then(callDefault)
.catch(fail);
shortcut_handler = true;
break;
case 'projects:merge_requests:edit': case 'projects:merge_requests:edit':
import('./pages/projects/merge_requests/edit')
.then(callDefault)
.catch(fail);
shortcut_handler = true; shortcut_handler = true;
break; break;
case 'projects:tags:new': case 'projects:tags:new':
......
import Vue from 'vue'; import Vue from 'vue';
import Translate from '~/vue_shared/translate'; import Translate from '~/vue_shared/translate';
import stopJobsModal from './components/stop_jobs_modal.vue'; import stopJobsModal from './components/stop_jobs_modal.vue';
Vue.use(Translate); Vue.use(Translate);
export default () => { document.addEventListener('DOMContentLoaded', () => {
const stopJobsButton = document.getElementById('stop-jobs-button'); const stopJobsButton = document.getElementById('stop-jobs-button');
if (stopJobsButton) { if (stopJobsButton) {
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
...@@ -27,4 +25,4 @@ export default () => { ...@@ -27,4 +25,4 @@ export default () => {
}, },
}); });
} }
}; });
...@@ -5,7 +5,7 @@ import csrf from '~/lib/utils/csrf'; ...@@ -5,7 +5,7 @@ import csrf from '~/lib/utils/csrf';
import deleteProjectModal from './components/delete_project_modal.vue'; import deleteProjectModal from './components/delete_project_modal.vue';
export default () => { document.addEventListener('DOMContentLoaded', () => {
Vue.use(Translate); Vue.use(Translate);
const deleteProjectModalEl = document.getElementById('delete-project-modal'); const deleteProjectModalEl = document.getElementById('delete-project-modal');
...@@ -34,4 +34,4 @@ export default () => { ...@@ -34,4 +34,4 @@ export default () => {
deleteModal.projectName = buttonProps.projectName; deleteModal.projectName = buttonProps.projectName;
} }
}); });
}; });
...@@ -5,7 +5,7 @@ import csrf from '~/lib/utils/csrf'; ...@@ -5,7 +5,7 @@ import csrf from '~/lib/utils/csrf';
import deleteUserModal from './components/delete_user_modal.vue'; import deleteUserModal from './components/delete_user_modal.vue';
export default () => { document.addEventListener('DOMContentLoaded', () => {
Vue.use(Translate); Vue.use(Translate);
const deleteUserModalEl = document.getElementById('delete-user-modal'); const deleteUserModalEl = document.getElementById('delete-user-modal');
...@@ -40,4 +40,4 @@ export default () => { ...@@ -40,4 +40,4 @@ export default () => {
deleteModal.username = buttonProps.username; deleteModal.username = buttonProps.username;
} }
}); });
}; });
import projectSelect from '~/project_select'; import projectSelect from '~/project_select';
import initLegacyFilters from '~/init_legacy_filters'; import initLegacyFilters from '~/init_legacy_filters';
export default () => { document.addEventListener('DOMContentLoaded', () => {
projectSelect(); projectSelect();
initLegacyFilters(); initLegacyFilters();
}; });
import projectSelect from '~/project_select'; import projectSelect from '~/project_select';
import initLegacyFilters from '~/init_legacy_filters'; import initLegacyFilters from '~/init_legacy_filters';
export default () => { document.addEventListener('DOMContentLoaded', () => {
projectSelect(); projectSelect();
initLegacyFilters(); initLegacyFilters();
}; });
import Milestone from '~/milestone'; import Milestone from '~/milestone';
import Sidebar from '~/right_sidebar'; import Sidebar from '~/right_sidebar';
export default () => { document.addEventListener('DOMContentLoaded', () => {
new Milestone(); // eslint-disable-line no-new new Milestone(); // eslint-disable-line no-new
new Sidebar(); // eslint-disable-line no-new new Sidebar(); // eslint-disable-line no-new
}; });
import ProjectsList from '~/projects_list'; import ProjectsList from '~/projects_list';
export default () => new ProjectsList(); document.addEventListener('DOMContentLoaded', () => new ProjectsList());
import Todos from './todos'; import Todos from './todos';
export default () => new Todos(); document.addEventListener('DOMContentLoaded', () => new Todos());
...@@ -2,7 +2,7 @@ import GroupsList from '~/groups_list'; ...@@ -2,7 +2,7 @@ import GroupsList from '~/groups_list';
import Landing from '~/landing'; import Landing from '~/landing';
import initGroupsList from '../../../groups'; import initGroupsList from '../../../groups';
export default function () { document.addEventListener('DOMContentLoaded', () => {
new GroupsList(); // eslint-disable-line no-new new GroupsList(); // eslint-disable-line no-new
initGroupsList(); initGroupsList();
const landingElement = document.querySelector('.js-explore-groups-landing'); const landingElement = document.querySelector('.js-explore-groups-landing');
...@@ -13,4 +13,4 @@ export default function () { ...@@ -13,4 +13,4 @@ export default function () {
'explore_groups_landing_dismissed', 'explore_groups_landing_dismissed',
); );
exploreGroupsLanding.toggle(); exploreGroupsLanding.toggle();
} });
import ProjectsList from '~/projects_list'; import ProjectsList from '~/projects_list';
export default () => new ProjectsList(); document.addEventListener('DOMContentLoaded', () => new ProjectsList());
...@@ -2,9 +2,9 @@ import projectSelect from '~/project_select'; ...@@ -2,9 +2,9 @@ import projectSelect from '~/project_select';
import initFilteredSearch from '~/pages/search/init_filtered_search'; import initFilteredSearch from '~/pages/search/init_filtered_search';
import { FILTERED_SEARCH } from '~/pages/constants'; import { FILTERED_SEARCH } from '~/pages/constants';
export default () => { document.addEventListener('DOMContentLoaded', () => {
initFilteredSearch({ initFilteredSearch({
page: FILTERED_SEARCH.ISSUES, page: FILTERED_SEARCH.ISSUES,
}); });
projectSelect(); projectSelect();
}; });
...@@ -2,9 +2,9 @@ import projectSelect from '~/project_select'; ...@@ -2,9 +2,9 @@ import projectSelect from '~/project_select';
import initFilteredSearch from '~/pages/search/init_filtered_search'; import initFilteredSearch from '~/pages/search/init_filtered_search';
import { FILTERED_SEARCH } from '~/pages/constants'; import { FILTERED_SEARCH } from '~/pages/constants';
export default () => { document.addEventListener('DOMContentLoaded', () => {
initFilteredSearch({ initFilteredSearch({
page: FILTERED_SEARCH.MERGE_REQUESTS, page: FILTERED_SEARCH.MERGE_REQUESTS,
}); });
projectSelect(); projectSelect();
}; });
import initForm from '../../../../shared/milestones/form'; import initForm from '../../../../shared/milestones/form';
export default () => initForm(false); document.addEventListener('DOMContentLoaded', () => initForm(false));
import initForm from '../../../../shared/milestones/form'; import initForm from '../../../../shared/milestones/form';
export default () => initForm(false); document.addEventListener('DOMContentLoaded', () => initForm(false));
import initMilestonesShow from '~/pages/milestones/shared/init_milestones_show'; import initMilestonesShow from '~/pages/milestones/shared/init_milestones_show';
export default initMilestonesShow; document.addEventListener('DOMContentLoaded', initMilestonesShow);
import AjaxLoadingSpinner from '~/ajax_loading_spinner'; import AjaxLoadingSpinner from '~/ajax_loading_spinner';
import DeleteModal from '~/branches/branches_delete_modal'; import DeleteModal from '~/branches/branches_delete_modal';
export default () => { document.addEventListener('DOMContentLoaded', () => {
AjaxLoadingSpinner.init(); AjaxLoadingSpinner.init();
new DeleteModal(); // eslint-disable-line no-new new DeleteModal(); // eslint-disable-line no-new
}; });
import NewBranchForm from '~/new_branch_form'; import NewBranchForm from '~/new_branch_form';
export default () => new NewBranchForm($('.js-create-branch-form'), JSON.parse(document.getElementById('availableRefs').innerHTML)); document.addEventListener('DOMContentLoaded', () => (
new NewBranchForm($('.js-create-branch-form'), JSON.parse(document.getElementById('availableRefs').innerHTML))
));
import Diff from '~/diff'; import Diff from '~/diff';
import initChangesDropdown from '~/init_changes_dropdown'; import initChangesDropdown from '~/init_changes_dropdown';
export default () => { document.addEventListener('DOMContentLoaded', () => {
new Diff(); // eslint-disable-line no-new new Diff(); // eslint-disable-line no-new
const paddingTop = 16; const paddingTop = 16;
initChangesDropdown(document.querySelector('.navbar-gitlab').offsetHeight - paddingTop); initChangesDropdown(document.querySelector('.navbar-gitlab').offsetHeight - paddingTop);
}; });
import monitoringBundle from '~/monitoring/monitoring_bundle'; import monitoringBundle from '~/monitoring/monitoring_bundle';
export default monitoringBundle; document.addEventListener('DOMContentLoaded', monitoringBundle);
import initForm from '../form'; import initForm from '../form';
export default () => { document.addEventListener('DOMContentLoaded', initForm);
initForm();
};
import initForm from '../form'; import initForm from '../form';
export default () => { document.addEventListener('DOMContentLoaded', initForm);
initForm();
};
import initMergeRequest from '~/pages/projects/merge_requests/init_merge_request'; import initMergeRequest from '~/pages/projects/merge_requests/init_merge_request';
export default initMergeRequest; document.addEventListener('DOMContentLoaded', initMergeRequest);
import Compare from '~/compare'; import Compare from '~/compare';
import MergeRequest from '~/merge_request'; import MergeRequest from '~/merge_request';
export default () => { document.addEventListener('DOMContentLoaded', () => {
const mrNewCompareNode = document.querySelector('.js-merge-request-new-compare'); const mrNewCompareNode = document.querySelector('.js-merge-request-new-compare');
if (mrNewCompareNode) { if (mrNewCompareNode) {
new Compare({ // eslint-disable-line no-new new Compare({ // eslint-disable-line no-new
...@@ -15,4 +15,4 @@ export default () => { ...@@ -15,4 +15,4 @@ export default () => {
action: mrNewSubmitNode.dataset.mrSubmitAction, action: mrNewSubmitNode.dataset.mrSubmitAction,
}); });
} }
}; });
import initMergeRequest from '~/pages/projects/merge_requests/init_merge_request'; import initMergeRequest from '~/pages/projects/merge_requests/init_merge_request';
export default initMergeRequest; document.addEventListener('DOMContentLoaded', initMergeRequest);
import initForm from '../../../../shared/milestones/form'; import initForm from '../../../../shared/milestones/form';
export default () => initForm(); document.addEventListener('DOMContentLoaded', () => initForm());
import milestones from '~/pages/milestones/shared'; import milestones from '~/pages/milestones/shared';
export default milestones; document.addEventListener('DOMContentLoaded', milestones);
import initForm from '../../../../shared/milestones/form'; import initForm from '../../../../shared/milestones/form';
export default () => initForm(); document.addEventListener('DOMContentLoaded', () => initForm());
import initMilestonesShow from '~/pages/milestones/shared/init_milestones_show'; import initMilestonesShow from '~/pages/milestones/shared/init_milestones_show';
import milestones from '~/pages/milestones/shared'; import milestones from '~/pages/milestones/shared';
export default () => { document.addEventListener('DOMContentLoaded', () => {
initMilestonesShow(); initMilestonesShow();
milestones(); milestones();
}; });
...@@ -7,17 +7,24 @@ module WebpackHelper ...@@ -7,17 +7,24 @@ module WebpackHelper
def webpack_controller_bundle_tags def webpack_controller_bundle_tags
bundles = [] bundles = []
segments = [*controller.controller_path.split('/'), controller.action_name].compact
until segments.empty? action = case controller.action_name
when 'create' then 'new'
when 'update' then 'edit'
else controller.action_name
end
route = [*controller.controller_path.split('/'), action].compact
until route.empty?
begin begin
asset_paths = gitlab_webpack_asset_paths("pages.#{segments.join('.')}", extension: 'js') asset_paths = gitlab_webpack_asset_paths("pages.#{route.join('.')}", extension: 'js')
bundles.unshift(*asset_paths) bundles.unshift(*asset_paths)
rescue Webpack::Rails::Manifest::EntryPointMissingError rescue Webpack::Rails::Manifest::EntryPointMissingError
# no bundle exists for this path # no bundle exists for this path
end end
segments.pop route.pop
end end
javascript_include_tag(*bundles) javascript_include_tag(*bundles)
......
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