Merge branch 'more-dispatcher-refactoring' into 'master'

More dispatcher refactoring

See merge request gitlab-org/gitlab-ce!17232
This commit is contained in:
Jacob Schatz 2018-02-21 12:56:06 +00:00
commit 2f2f63a055
19 changed files with 35 additions and 119 deletions

View file

@ -51,68 +51,9 @@ var Dispatcher;
case 'projects:merge_requests:creations:new': case 'projects:merge_requests:creations:new':
case 'projects:merge_requests:creations:diffs': case 'projects:merge_requests:creations:diffs':
case 'projects:merge_requests:edit': case 'projects:merge_requests:edit':
shortcut_handler = true;
break;
case 'projects:tags:new':
import('./pages/projects/tags/new')
.then(callDefault)
.catch(fail);
break;
case 'projects:snippets:show':
import('./pages/projects/snippets/show')
.then(callDefault)
.catch(fail);
break;
case 'projects:snippets:new':
case 'projects:snippets:create':
import('./pages/projects/snippets/new')
.then(callDefault)
.catch(fail);
break;
case 'projects:services:edit':
import('./pages/projects/services/edit')
.then(callDefault)
.catch(fail);
break;
case 'projects:snippets:edit':
case 'projects:snippets:update':
import('./pages/projects/snippets/edit')
.then(callDefault)
.catch(fail);
break;
case 'snippets:new':
import('./pages/snippets/new')
.then(callDefault)
.catch(fail);
break;
case 'snippets:edit':
import('./pages/snippets/edit')
.then(callDefault)
.catch(fail);
break;
case 'snippets:create':
import('./pages/snippets/new')
.then(callDefault)
.catch(fail);
break;
case 'snippets:update':
import('./pages/snippets/edit')
.then(callDefault)
.catch(fail);
break;
case 'projects:releases:edit':
import('./pages/projects/releases/edit')
.then(callDefault)
.catch(fail);
break;
case 'projects:merge_requests:show': case 'projects:merge_requests:show':
shortcut_handler = true; shortcut_handler = true;
break; break;
case 'dashboard:activity':
import('./pages/dashboard/activity')
.then(callDefault)
.catch(fail);
break;
case 'projects:commit:show': case 'projects:commit:show':
import('./pages/projects/commit/show') import('./pages/projects/commit/show')
.then(callDefault) .then(callDefault)
@ -314,11 +255,6 @@ var Dispatcher;
.then(callDefault) .then(callDefault)
.catch(fail); .catch(fail);
break; break;
case 'snippets:show':
import('./pages/snippets/show')
.then(callDefault)
.catch(fail);
break;
case 'import:fogbugz:new_user_map': case 'import:fogbugz:new_user_map':
import('./pages/import/fogbugz/new_user_map') import('./pages/import/fogbugz/new_user_map')
.then(callDefault) .then(callDefault)
@ -334,18 +270,6 @@ var Dispatcher;
.then(callDefault) .then(callDefault)
.catch(fail); .catch(fail);
break; break;
case 'projects:clusters:show':
case 'projects:clusters:update':
case 'projects:clusters:destroy':
import('./pages/projects/clusters/show')
.then(callDefault)
.catch(fail);
break;
case 'projects:clusters:index':
import('./pages/projects/clusters/index')
.then(callDefault)
.catch(fail);
break;
case 'dashboard:groups:index': case 'dashboard:groups:index':
import('./pages/dashboard/groups/index') import('./pages/dashboard/groups/index')
.then(callDefault) .then(callDefault)
@ -353,20 +277,7 @@ var Dispatcher;
break; break;
} }
switch (path[0]) { switch (path[0]) {
case 'sessions':
import('./pages/sessions')
.then(callDefault)
.catch(fail);
break;
case 'omniauth_callbacks':
import('./pages/omniauth_callbacks')
.then(callDefault)
.catch(fail);
break;
case 'admin': case 'admin':
import('./pages/admin')
.then(callDefault)
.catch(fail);
switch (path[1]) { switch (path[1]) {
case 'broadcast_messages': case 'broadcast_messages':
import('./pages/admin/broadcast_messages') import('./pages/admin/broadcast_messages')

View file

@ -61,7 +61,7 @@ gl.lazyLoader = new LazyLoader({
observerNode: '#content-body', observerNode: '#content-body',
}); });
$(() => { document.addEventListener('DOMContentLoaded', () => {
const $body = $('body'); const $body = $('body');
const $document = $(document); const $document = $(document);
const $window = $(window); const $window = $(window);

View file

@ -1,3 +1,3 @@
import initAdmin from './admin'; import initAdmin from './admin';
export default () => initAdmin(); document.addEventListener('DOMContentLoaded', initAdmin);

View file

@ -1,3 +1,3 @@
import Activities from '~/activities'; import Activities from '~/activities';
export default () => new Activities(); document.addEventListener('DOMContentLoaded', () => new Activities());

View file

@ -1,5 +1,3 @@
import initU2F from '../../shared/sessions/u2f'; import initU2F from '../../shared/sessions/u2f';
export default () => { document.addEventListener('DOMContentLoaded', initU2F);
initU2F();
};

View file

@ -0,0 +1,5 @@
import ClustersBundle from '~/clusters/clusters_bundle';
document.addEventListener('DOMContentLoaded', () => {
new ClustersBundle(); // eslint-disable-line no-new
});

View file

@ -1,5 +1,5 @@
import ClustersIndex from '~/clusters/clusters_index'; import ClustersIndex from '~/clusters/clusters_index';
export default () => { document.addEventListener('DOMContentLoaded', () => {
new ClustersIndex(); // eslint-disable-line no-new new ClustersIndex(); // eslint-disable-line no-new
}; });

View file

@ -1,5 +1,5 @@
import ClustersBundle from '~/clusters/clusters_bundle'; import ClustersBundle from '~/clusters/clusters_bundle';
export default () => { document.addEventListener('DOMContentLoaded', () => {
new ClustersBundle(); // eslint-disable-line no-new new ClustersBundle(); // eslint-disable-line no-new
}; });

View file

@ -0,0 +1,5 @@
import ClustersBundle from '~/clusters/clusters_bundle';
document.addEventListener('DOMContentLoaded', () => {
new ClustersBundle(); // eslint-disable-line no-new
});

View file

@ -1,3 +1,3 @@
import initForm from '~/pages/projects/init_form'; import initForm from '~/pages/projects/init_form';
export default initForm($('.release-form')); document.addEventListener('DOMContentLoaded', () => initForm($('.release-form')));

View file

@ -1,7 +1,7 @@
import IntegrationSettingsForm from '~/integrations/integration_settings_form'; import IntegrationSettingsForm from '~/integrations/integration_settings_form';
import PrometheusMetrics from '~/prometheus_metrics/prometheus_metrics'; import PrometheusMetrics from '~/prometheus_metrics/prometheus_metrics';
export default () => { document.addEventListener('DOMContentLoaded', () => {
const prometheusSettingsWrapper = document.querySelector('.js-prometheus-metrics-monitoring'); const prometheusSettingsWrapper = document.querySelector('.js-prometheus-metrics-monitoring');
const integrationSettingsForm = new IntegrationSettingsForm('.js-integration-settings-form'); const integrationSettingsForm = new IntegrationSettingsForm('.js-integration-settings-form');
integrationSettingsForm.init(); integrationSettingsForm.init();
@ -10,4 +10,4 @@ export default () => {
const prometheusMetrics = new PrometheusMetrics('.js-prometheus-metrics-monitoring'); const prometheusMetrics = new PrometheusMetrics('.js-prometheus-metrics-monitoring');
prometheusMetrics.loadActiveMetrics(); prometheusMetrics.loadActiveMetrics();
} }
}; });

View file

@ -1,3 +1,3 @@
import initForm from '~/pages/projects/init_form'; import initForm from '~/pages/projects/init_form';
export default initForm($('.snippet-form')); document.addEventListener('DOMContentLoaded', () => initForm($('.snippet-form')));

View file

@ -1,3 +1,3 @@
import initForm from '~/pages/projects/init_form'; import initForm from '~/pages/projects/init_form';
export default initForm($('.snippet-form')); document.addEventListener('DOMContentLoaded', () => initForm($('.snippet-form')));

View file

@ -3,9 +3,9 @@ import ZenMode from '~/zen_mode';
import LineHighlighter from '../../../../line_highlighter'; import LineHighlighter from '../../../../line_highlighter';
import BlobViewer from '../../../../blob/viewer'; import BlobViewer from '../../../../blob/viewer';
export default function () { document.addEventListener('DOMContentLoaded', () => {
new LineHighlighter(); // eslint-disable-line no-new new LineHighlighter(); // eslint-disable-line no-new
new BlobViewer(); // eslint-disable-line no-new new BlobViewer(); // eslint-disable-line no-new
initNotes(); initNotes();
new ZenMode(); // eslint-disable-line no-new new ZenMode(); // eslint-disable-line no-new
} });

View file

@ -2,8 +2,8 @@ import RefSelectDropdown from '../../../../ref_select_dropdown';
import ZenMode from '../../../../zen_mode'; import ZenMode from '../../../../zen_mode';
import GLForm from '../../../../gl_form'; import GLForm from '../../../../gl_form';
export default () => { document.addEventListener('DOMContentLoaded', () => {
new ZenMode(); // eslint-disable-line no-new new ZenMode(); // eslint-disable-line no-new
new GLForm($('.tag-form'), true); // eslint-disable-line no-new new GLForm($('.tag-form'), true); // eslint-disable-line no-new
new RefSelectDropdown($('.js-branch-select')); // eslint-disable-line no-new new RefSelectDropdown($('.js-branch-select')); // eslint-disable-line no-new
}; });

View file

@ -1,5 +1,3 @@
import initU2F from '../../shared/sessions/u2f'; import initU2F from '../../shared/sessions/u2f';
export default () => { document.addEventListener('DOMContentLoaded', initU2F);
initU2F();
};

View file

@ -1,3 +1,3 @@
import form from '../form'; import form from '../form';
export default form; document.addEventListener('DOMContentLoaded', form);

View file

@ -1,3 +1,3 @@
import form from '../form'; import form from '../form';
export default form; document.addEventListener('DOMContentLoaded', form);

View file

@ -1,12 +1,11 @@
/* eslint-disable no-new */
import LineHighlighter from '../../../line_highlighter'; import LineHighlighter from '../../../line_highlighter';
import BlobViewer from '../../../blob/viewer'; import BlobViewer from '../../../blob/viewer';
import ZenMode from '../../../zen_mode'; import ZenMode from '../../../zen_mode';
import initNotes from '../../../init_notes'; import initNotes from '../../../init_notes';
export default () => { document.addEventListener('DOMContentLoaded', () => {
new LineHighlighter(); new LineHighlighter(); // eslint-disable-line no-new
new BlobViewer(); new BlobViewer(); // eslint-disable-line no-new
initNotes(); initNotes();
new ZenMode(); new ZenMode(); // eslint-disable-line no-new
}; });