From b69d7ac3c9de7b0ba3e60ede70f1de630a53dfe6 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 11 Jan 2018 12:38:30 +0000 Subject: [PATCH 1/5] Added dispatcher imports for some project routes --- app/assets/javascripts/dispatcher.js | 48 ++------ .../javascripts/pages/projects/edit/index.js | 6 + .../javascripts/pages/projects/index.js | 7 ++ .../javascripts/pages/projects/new/index.js | 7 ++ .../{ => pages/projects}/project.js | 4 +- .../components/project_feature_setting.vue | 2 +- .../components/project_setting_row.vue | 0 .../permissions/components/settings_panel.vue | 2 +- .../projects/shared}/permissions/constants.js | 0 .../projects/shared}/permissions/external.js | 0 .../projects/shared}/permissions/index.js | 0 .../projects/shared}/project_avatar.js | 0 .../projects/shared}/project_new.js | 2 +- .../javascripts/pages/projects/wikis/index.js | 11 ++ .../{ => pages/projects/wikis}/wikis.js | 4 +- .../javascripts/projects/project_new.js | 108 ------------------ .../mr_widget_options.js | 2 +- app/views/projects/new.html.haml | 2 - config/webpack.config.js | 1 - spec/javascripts/projects/project_new_spec.js | 2 +- 20 files changed, 52 insertions(+), 156 deletions(-) create mode 100644 app/assets/javascripts/pages/projects/index.js create mode 100644 app/assets/javascripts/pages/projects/new/index.js rename app/assets/javascripts/{ => pages/projects}/project.js (97%) rename app/assets/javascripts/{projects => pages/projects/shared}/permissions/components/project_feature_setting.vue (96%) rename app/assets/javascripts/{projects => pages/projects/shared}/permissions/components/project_setting_row.vue (100%) rename app/assets/javascripts/{projects => pages/projects/shared}/permissions/components/settings_panel.vue (99%) rename app/assets/javascripts/{projects => pages/projects/shared}/permissions/constants.js (100%) rename app/assets/javascripts/{projects => pages/projects/shared}/permissions/external.js (100%) rename app/assets/javascripts/{projects => pages/projects/shared}/permissions/index.js (100%) rename app/assets/javascripts/{ => pages/projects/shared}/project_avatar.js (100%) rename app/assets/javascripts/{ => pages/projects/shared}/project_new.js (98%) create mode 100644 app/assets/javascripts/pages/projects/wikis/index.js rename app/assets/javascripts/{ => pages/projects/wikis}/wikis.js (94%) delete mode 100644 app/assets/javascripts/projects/project_new.js diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 1c6336073e9..5609553a51c 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -9,11 +9,8 @@ import notificationsDropdown from './notifications_dropdown'; import groupAvatar from './group_avatar'; import GroupLabelSubscription from './group_label_subscription'; import LineHighlighter from './line_highlighter'; -import Project from './project'; -import projectAvatar from './project_avatar'; import MergeRequest from './merge_request'; import Compare from './compare'; -import ProjectNew from './project_new'; import Labels from './labels'; import LabelManager from './label_manager'; import Sidebar from './right_sidebar'; @@ -24,20 +21,17 @@ import SecretValues from './behaviors/secret_values'; import Group from './group'; import ProjectsList from './projects_list'; import UserCallout from './user_callout'; -import ShortcutsWiki from './shortcuts_wiki'; import BlobViewer from './blob/viewer/index'; import AutoWidthDropdownSelect from './issuable/auto_width_dropdown_select'; import UsersSelect from './users_select'; import GfmAutoComplete from './gfm_auto_complete'; import Star from './star'; import TreeView from './tree'; -import Wikis from './wikis'; 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 initProjectVisibilitySelector from './project_visibility'; import NewGroupChild from './groups/new_group_child'; import { ajaxGet, convertPermissionToBoolean } from './lib/utils/common_utils'; import GlFieldErrors from './gl_field_errors'; @@ -70,7 +64,7 @@ import Activities from './activities'; return false; } - const fail = () => Flash('Error loading dynamic module'); + const fail = (e) => { throw e; Flash('Error loading dynamic module'); } const callDefault = m => m.default(); path = page.split(':'); @@ -642,57 +636,39 @@ import Activities from './activities'; .catch(fail); break; case 'projects': - new Project(); - projectAvatar(); + import('./pages/projects') + .then(callDefault) + .catch(fail); + shortcut_handler = true; switch (path[1]) { case 'compare': import('./pages/projects/compare') .then(callDefault) .catch(fail); break; - case 'edit': - shortcut_handler = new ShortcutsNavigation(); - new ProjectNew(); - import(/* webpackChunkName: 'project_permissions' */ './projects/permissions') + case 'create': + case 'new': + import('./pages/projects/new') .then(callDefault) .catch(fail); break; - case 'new': - new ProjectNew(); - initProjectVisibilitySelector(); - break; case 'show': new Star(); - new ProjectNew(); notificationsDropdown(); break; case 'wikis': - new Wikis(); - shortcut_handler = new ShortcutsWiki(); - new ZenMode(); - new GLForm($('.wiki-form'), true); + import('./pages/projects/wikis') + .then(callDefault) + .catch(fail); + shortcut_handler = true; break; case 'snippets': - shortcut_handler = new ShortcutsNavigation(); if (path[2] === 'show') { new ZenMode(); new LineHighlighter(); new BlobViewer(); } break; - case 'labels': - case 'graphs': - case 'compare': - case 'pipelines': - case 'forks': - case 'milestones': - case 'project_members': - case 'deploy_keys': - case 'builds': - case 'hooks': - case 'services': - case 'protected_branches': - shortcut_handler = new ShortcutsNavigation(); } break; } diff --git a/app/assets/javascripts/pages/projects/edit/index.js b/app/assets/javascripts/pages/projects/edit/index.js index 7f662ef6b6a..9edf36d66b1 100644 --- a/app/assets/javascripts/pages/projects/edit/index.js +++ b/app/assets/javascripts/pages/projects/edit/index.js @@ -1,8 +1,14 @@ import initSettingsPanels from '~/settings_panels'; import setupProjectEdit from '~/project_edit'; +import ProjectNew from '../shared/project_new'; +import projectAvatar from '../shared/project_avatar'; +import initProjectPermissionsSettings from '../shared/permissions'; export default () => { + new ProjectNew(); // eslint-disable-line no-new setupProjectEdit(); // Initialize expandable settings panels initSettingsPanels(); + projectAvatar(); + initProjectPermissionsSettings(); }; diff --git a/app/assets/javascripts/pages/projects/index.js b/app/assets/javascripts/pages/projects/index.js new file mode 100644 index 00000000000..9b1d52692a3 --- /dev/null +++ b/app/assets/javascripts/pages/projects/index.js @@ -0,0 +1,7 @@ +import Project from './project'; +import ShortcutsNavigation from '../../shortcuts_navigation'; + +export default () => { + new Project(); // eslint-disable-line no-new + new ShortcutsNavigation(); // eslint-disable-line no-new +}; diff --git a/app/assets/javascripts/pages/projects/new/index.js b/app/assets/javascripts/pages/projects/new/index.js new file mode 100644 index 00000000000..45951461779 --- /dev/null +++ b/app/assets/javascripts/pages/projects/new/index.js @@ -0,0 +1,7 @@ +import ProjectNew from '../shared/project_new'; +import initProjectVisibilitySelector from '../../../project_visibility'; + +export default () => { + new ProjectNew(); // eslint-disable-line no-new + initProjectVisibilitySelector(); +}; diff --git a/app/assets/javascripts/project.js b/app/assets/javascripts/pages/projects/project.js similarity index 97% rename from app/assets/javascripts/project.js rename to app/assets/javascripts/pages/projects/project.js index d4f26b81f30..e30d558726b 100644 --- a/app/assets/javascripts/project.js +++ b/app/assets/javascripts/pages/projects/project.js @@ -1,8 +1,8 @@ /* eslint-disable func-names, space-before-function-paren, no-var, consistent-return, no-new, prefer-arrow-callback, no-return-assign, one-var, one-var-declaration-per-line, object-shorthand, no-else-return, newline-per-chained-call, no-shadow, vars-on-top, prefer-template, max-len */ import Cookies from 'js-cookie'; -import { visitUrl } from './lib/utils/url_utility'; -import projectSelect from './project_select'; +import { visitUrl } from '../../lib/utils/url_utility'; +import projectSelect from '../../project_select'; export default class Project { constructor() { diff --git a/app/assets/javascripts/projects/permissions/components/project_feature_setting.vue b/app/assets/javascripts/pages/projects/shared/permissions/components/project_feature_setting.vue similarity index 96% rename from app/assets/javascripts/projects/permissions/components/project_feature_setting.vue rename to app/assets/javascripts/pages/projects/shared/permissions/components/project_feature_setting.vue index 3ebfe82597a..9b13b2a524f 100644 --- a/app/assets/javascripts/projects/permissions/components/project_feature_setting.vue +++ b/app/assets/javascripts/pages/projects/shared/permissions/components/project_feature_setting.vue @@ -1,5 +1,5 @@