diff options
Diffstat (limited to 'app/assets/javascripts/dispatcher.js')
-rw-r--r-- | app/assets/javascripts/dispatcher.js | 109 |
1 files changed, 49 insertions, 60 deletions
diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index f2479ec33d7..96e5c8c890c 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -1,32 +1,23 @@ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, wrap-iife, no-shadow, consistent-return, one-var, one-var-declaration-per-line, camelcase, default-case, no-new, quotes, no-duplicate-case, no-case-declarations, no-fallthrough, max-len */ import Milestone from './milestone'; -import NotificationsForm from './notifications_form'; import notificationsDropdown from './notifications_dropdown'; import LineHighlighter from './line_highlighter'; import MergeRequest from './merge_request'; import Sidebar from './right_sidebar'; import Flash from './flash'; -import SecretValues from './behaviors/secret_values'; -import UserCallout from './user_callout'; import BlobViewer from './blob/viewer/index'; import GfmAutoComplete from './gfm_auto_complete'; import Star from './star'; -import TreeView from './tree'; import ZenMode from './zen_mode'; -import initSettingsPanels from './settings_panels'; import PerformanceBar from './performance_bar'; import initNotes from './init_notes'; import initIssuableSidebar from './init_issuable_sidebar'; -import { ajaxGet, convertPermissionToBoolean } from './lib/utils/common_utils'; +import { convertPermissionToBoolean } from './lib/utils/common_utils'; import GlFieldErrors from './gl_field_errors'; -import GLForm from './gl_form'; import Shortcuts from './shortcuts'; -import ShortcutsNavigation from './shortcuts_navigation'; import ShortcutsIssuable from './shortcuts_issuable'; -import U2FAuthenticate from './u2f/authenticate'; import Diff from './diff'; import SearchAutocomplete from './search_autocomplete'; -import Activities from './activities'; (function() { var Dispatcher; @@ -131,7 +122,9 @@ import Activities from './activities'; .catch(fail); break; case 'dashboard:todos:index': - import('./pages/dashboard/todos/index').then(callDefault).catch(fail); + import('./pages/dashboard/todos/index') + .then(callDefault) + .catch(fail); break; case 'admin:jobs:index': import('./pages/admin/jobs/index') @@ -234,15 +227,21 @@ import Activities from './activities'; .catch(fail); break; case 'projects:snippets:show': - initNotes(); - new ZenMode(); + import('./pages/projects/snippets/show') + .then(callDefault) + .catch(fail); break; case 'projects:snippets:new': - case 'projects:snippets:edit': case 'projects:snippets:create': + import('./pages/projects/snippets/new') + .then(callDefault) + .catch(fail); + break; + case 'projects:snippets:edit': case 'projects:snippets:update': - new GLForm($('.snippet-form'), true); - new ZenMode(); + import('./pages/projects/snippets/edit') + .then(callDefault) + .catch(fail); break; case 'snippets:new': import('./pages/snippets/new') @@ -265,8 +264,9 @@ import Activities from './activities'; .catch(fail); break; case 'projects:releases:edit': - new ZenMode(); - new GLForm($('.release-form'), true); + import('./pages/projects/releases/edit') + .then(callDefault) + .catch(fail); break; case 'projects:merge_requests:show': new Diff(); @@ -310,19 +310,10 @@ import Activities from './activities'; shortcut_handler = true; break; case 'projects:show': - shortcut_handler = new ShortcutsNavigation(); - new NotificationsForm(); - new UserCallout({ - setCalloutPerProject: true, - className: 'js-autodevops-banner', - }); - - if ($('#tree-slider').length) new TreeView(); - if ($('.blob-viewer').length) new BlobViewer(); - if ($('.project-show-activity').length) new Activities(); - $('#tree-slider').waitForImages(function() { - ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath); - }); + import('./pages/projects/show') + .then(callDefault) + .catch(fail); + shortcut_handler = true; break; case 'projects:edit': import('./pages/projects/edit') @@ -477,18 +468,15 @@ import Activities from './activities'; .catch(fail); break; case 'projects:settings:repository:show': - // Initialize expandable settings panels - initSettingsPanels(); + import('./pages/projects/settings/repository/show') + .then(callDefault) + .catch(fail); break; case 'projects:settings:ci_cd:show': - // Initialize expandable settings panels - initSettingsPanels(); - - const runnerToken = document.querySelector('.js-secret-runner-token'); - if (runnerToken) { - const runnerTokenSecretValue = new SecretValues(runnerToken); - runnerTokenSecretValue.init(); - } + import('./pages/projects/settings/ci_cd/show') + .then(callDefault) + .catch(fail); + break; case 'groups:settings:ci_cd:show': import('./pages/groups/settings/ci_cd/show') .then(callDefault) @@ -496,13 +484,19 @@ import Activities from './activities'; break; case 'ci:lints:create': case 'ci:lints:show': - import('./pages/ci/lints').then(m => m.default()).catch(fail); + import('./pages/ci/lints') + .then(callDefault) + .catch(fail); break; case 'users:show': - import('./pages/users/show').then(callDefault).catch(fail); + import('./pages/users/show') + .then(callDefault) + .catch(fail); break; case 'admin:conversational_development_index:show': - import('./pages/admin/conversational_development_index/show').then(m => m.default()).catch(fail); + import('./pages/admin/conversational_development_index/show') + .then(callDefault) + .catch(fail); break; case 'snippets:show': import('./pages/snippets/show') @@ -510,7 +504,9 @@ import Activities from './activities'; .catch(fail); break; case 'import:fogbugz:new_user_map': - import('./pages/import/fogbugz/new_user_map').then(m => m.default()).catch(fail); + import('./pages/import/fogbugz/new_user_map') + .then(callDefault) + .catch(fail); break; case 'profiles:personal_access_tokens:index': import('./pages/profiles/personal_access_tokens') @@ -537,18 +533,15 @@ import Activities from './activities'; } switch (path[0]) { case 'sessions': + import('./pages/sessions') + .then(callDefault) + .catch(fail); + break; case 'omniauth_callbacks': - if (!gon.u2f) break; - const u2fAuthenticate = new U2FAuthenticate( - $('#js-authenticate-u2f'), - '#js-login-u2f-form', - gon.u2f, - document.querySelector('#js-login-2fa-device'), - document.querySelector('.js-2fa-form'), - ); - u2fAuthenticate.start(); - // needed in rspec - gl.u2fAuthenticate = u2fAuthenticate; + import('./pages/omniauth_callbacks') + .then(callDefault) + .catch(fail); + break; case 'admin': import('./pages/admin') .then(callDefault) @@ -598,10 +591,6 @@ import Activities from './activities'; break; } break; - case 'dashboard': - case 'root': - new UserCallout(); - break; case 'profiles': import('./pages/profiles/index/') .then(callDefault) |