Commit 1aff4806 authored by Jacob Schatz's avatar Jacob Schatz

Updating dispatcher without code fixes

parent 45ec2653
/* 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 */ /* 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 { s__ } from "./locale"; import { s__ } from './locale';
import projectSelect from "./project_select"; import projectSelect from './project_select';
import IssuableIndex from "./issuable_index"; import IssuableIndex from './issuable_index';
import Milestone from "./milestone"; import Milestone from './milestone';
import IssuableForm from "./issuable_form"; import IssuableForm from './issuable_form';
import LabelsSelect from "./labels_select"; import LabelsSelect from './labels_select';
import MilestoneSelect from "./milestone_select"; import MilestoneSelect from './milestone_select';
import NewBranchForm from "./new_branch_form"; import NewBranchForm from './new_branch_form';
import NotificationsForm from "./notifications_form"; import NotificationsForm from './notifications_form';
import notificationsDropdown from "./notifications_dropdown"; import notificationsDropdown from './notifications_dropdown';
import groupAvatar from "./group_avatar"; import groupAvatar from './group_avatar';
import GroupLabelSubscription from "./group_label_subscription"; import GroupLabelSubscription from './group_label_subscription';
import LineHighlighter from "./line_highlighter"; import LineHighlighter from './line_highlighter';
import BuildArtifacts from "./build_artifacts"; import BuildArtifacts from './build_artifacts';
import CILintEditor from "./ci_lint_editor"; import CILintEditor from './ci_lint_editor';
import groupsSelect from "./groups_select"; import groupsSelect from './groups_select';
import Search from "./search"; import Search from './search';
import initAdmin from "./admin"; import initAdmin from './admin';
import NamespaceSelect from "./namespace_select"; import NamespaceSelect from './namespace_select';
import NewCommitForm from "./new_commit_form"; import NewCommitForm from './new_commit_form';
import Project from "./project"; import Project from './project';
import projectAvatar from "./project_avatar"; import projectAvatar from './project_avatar';
import MergeRequest from "./merge_request"; import MergeRequest from './merge_request';
import Compare from "./compare"; import Compare from './compare';
import initCompareAutocomplete from "./compare_autocomplete"; import initCompareAutocomplete from './compare_autocomplete';
import ProjectFindFile from "./project_find_file"; import ProjectFindFile from './project_find_file';
import ProjectNew from "./project_new"; import ProjectNew from './project_new';
import projectImport from "./project_import"; import projectImport from './project_import';
import Labels from "./labels"; import Labels from './labels';
import LabelManager from "./label_manager"; import LabelManager from './label_manager';
import Sidebar from "./right_sidebar"; import Sidebar from './right_sidebar';
import IssuableTemplateSelectors from "./templates/issuable_template_selectors"; import IssuableTemplateSelectors from './templates/issuable_template_selectors';
import Flash from "./flash"; import Flash from './flash';
import CommitsList from "./commits"; import CommitsList from './commits';
import Issue from "./issue"; import Issue from './issue';
import BindInOut from "./behaviors/bind_in_out"; import BindInOut from './behaviors/bind_in_out';
import SecretValues from "./behaviors/secret_values"; import SecretValues from './behaviors/secret_values';
import DeleteModal from "./branches/branches_delete_modal"; import DeleteModal from './branches/branches_delete_modal';
import Group from "./group"; import Group from './group';
import ProjectsList from "./projects_list"; import GroupsList from './groups_list';
import setupProjectEdit from "./project_edit"; import ProjectsList from './projects_list';
import MiniPipelineGraph from "./mini_pipeline_graph_dropdown"; import setupProjectEdit from './project_edit';
import BlobLinePermalinkUpdater from "./blob/blob_line_permalink_updater"; import MiniPipelineGraph from './mini_pipeline_graph_dropdown';
import BlobForkSuggestion from "./blob/blob_fork_suggestion"; import BlobLinePermalinkUpdater from './blob/blob_line_permalink_updater';
import UserCallout from "./user_callout"; import Landing from './landing';
import ShortcutsWiki from "./shortcuts_wiki"; import BlobForkSuggestion from './blob/blob_fork_suggestion';
import Pipelines from "./pipelines"; import UserCallout from './user_callout';
import BlobViewer from "./blob/viewer/index"; import ShortcutsWiki from './shortcuts_wiki';
import AutoWidthDropdownSelect from "./issuable/auto_width_dropdown_select"; import Pipelines from './pipelines';
import UsersSelect from "./users_select"; import BlobViewer from './blob/viewer/index';
import RefSelectDropdown from "./ref_select_dropdown"; import AutoWidthDropdownSelect from './issuable/auto_width_dropdown_select';
import GfmAutoComplete from "./gfm_auto_complete"; import UsersSelect from './users_select';
import ShortcutsBlob from "./shortcuts_blob"; import RefSelectDropdown from './ref_select_dropdown';
import SigninTabsMemoizer from "./signin_tabs_memoizer"; import GfmAutoComplete from './gfm_auto_complete';
import Star from "./star"; import ShortcutsBlob from './shortcuts_blob';
import Todos from "./todos"; import SigninTabsMemoizer from './signin_tabs_memoizer';
import TreeView from "./tree"; import Star from './star';
import UsagePing from "./usage_ping"; import Todos from './todos';
import UsernameValidator from "./username_validator"; import TreeView from './tree';
import VersionCheckImage from "./version_check_image"; import UsagePing from './usage_ping';
import Wikis from "./wikis"; import UsernameValidator from './username_validator';
import ZenMode from "./zen_mode"; import VersionCheckImage from './version_check_image';
import initSettingsPanels from "./settings_panels"; import Wikis from './wikis';
import initExperimentalFlags from "./experimental_flags"; import ZenMode from './zen_mode';
import OAuthRememberMe from "./oauth_remember_me"; import initSettingsPanels from './settings_panels';
import PerformanceBar from "./performance_bar"; import initExperimentalFlags from './experimental_flags';
import initBroadcastMessagesForm from "./broadcast_message"; import OAuthRememberMe from './oauth_remember_me';
import initNotes from "./init_notes"; import PerformanceBar from './performance_bar';
import initLegacyFilters from "./init_legacy_filters"; import initBroadcastMessagesForm from './broadcast_message';
import initIssuableSidebar from "./init_issuable_sidebar"; import initNotes from './init_notes';
import initProjectVisibilitySelector from "./project_visibility"; import initLegacyFilters from './init_legacy_filters';
import GpgBadges from "./gpg_badges"; import initIssuableSidebar from './init_issuable_sidebar';
import initChangesDropdown from "./init_changes_dropdown"; import initProjectVisibilitySelector from './project_visibility';
import NewGroupChild from "./groups/new_group_child"; import GpgBadges from './gpg_badges';
import AbuseReports from "./abuse_reports"; import initChangesDropdown from './init_changes_dropdown';
import { ajaxGet, convertPermissionToBoolean } from "./lib/utils/common_utils"; import NewGroupChild from './groups/new_group_child';
import AjaxLoadingSpinner from "./ajax_loading_spinner"; import AbuseReports from './abuse_reports';
import GlFieldErrors from "./gl_field_errors"; import { ajaxGet, convertPermissionToBoolean } from './lib/utils/common_utils';
import GLForm from "./gl_form"; import AjaxLoadingSpinner from './ajax_loading_spinner';
import Shortcuts from "./shortcuts"; import GlFieldErrors from './gl_field_errors';
import ShortcutsNavigation from "./shortcuts_navigation"; import GLForm from './gl_form';
import ShortcutsFindFile from "./shortcuts_find_file"; import Shortcuts from './shortcuts';
import ShortcutsIssuable from "./shortcuts_issuable"; import ShortcutsNavigation from './shortcuts_navigation';
import U2FAuthenticate from "./u2f/authenticate"; import ShortcutsFindFile from './shortcuts_find_file';
import Members from "./members"; import ShortcutsIssuable from './shortcuts_issuable';
import memberExpirationDate from "./member_expiration_date"; import U2FAuthenticate from './u2f/authenticate';
import DueDateSelectors from "./due_date_select"; import Members from './members';
import Diff from "./diff"; import memberExpirationDate from './member_expiration_date';
import ProjectLabelSubscription from "./project_label_subscription"; import DueDateSelectors from './due_date_select';
import SearchAutocomplete from "./search_autocomplete"; import Diff from './diff';
import Activities from "./activities"; import ProjectLabelSubscription from './project_label_subscription';
import SearchAutocomplete from './search_autocomplete';
import Activities from './activities';
(function() { (function() {
var Dispatcher; var Dispatcher;
...@@ -102,34 +104,27 @@ import Activities from "./activities"; ...@@ -102,34 +104,27 @@ import Activities from "./activities";
} }
Dispatcher.prototype.initPageScripts = function() { Dispatcher.prototype.initPageScripts = function() {
var path, var path, shortcut_handler, fileBlobPermalinkUrlElement, fileBlobPermalinkUrl;
shortcut_handler, const page = $('body').attr('data-page');
fileBlobPermalinkUrlElement,
fileBlobPermalinkUrl;
const page = $("body").attr("data-page");
if (!page) { if (!page) {
return false; return false;
} }
const fail = () => Flash("Error loading dynamic module"); const fail = () => Flash('Error loading dynamic module');
path = page.split(":"); path = page.split(':');
shortcut_handler = null; shortcut_handler = null;
$(".js-gfm-input:not(.js-vue-textarea)").each((i, el) => { $('.js-gfm-input:not(.js-vue-textarea)').each((i, el) => {
const gfm = new GfmAutoComplete( const gfm = new GfmAutoComplete(gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources);
gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources const enableGFM = convertPermissionToBoolean(el.dataset.supportsAutocomplete);
);
const enableGFM = convertPermissionToBoolean(
el.dataset.supportsAutocomplete
);
gfm.setup($(el), { gfm.setup($(el), {
emojis: true, emojis: true,
members: enableGFM, members: enableGFM,
issues: enableGFM, issues: enableGFM,
milestones: enableGFM, milestones: enableGFM,
mergeRequests: enableGFM, mergeRequests: enableGFM,
labels: enableGFM labels: enableGFM,
}); });
}); });
...@@ -137,335 +132,301 @@ import Activities from "./activities"; ...@@ -137,335 +132,301 @@ import Activities from "./activities";
new LineHighlighter(); new LineHighlighter();
new BlobLinePermalinkUpdater( new BlobLinePermalinkUpdater(
document.querySelector("#blob-content-holder"), document.querySelector('#blob-content-holder'),
".diff-line-num[data-line-number]", '.diff-line-num[data-line-number]',
document.querySelectorAll( document.querySelectorAll('.js-data-file-blob-permalink-url, .js-blob-blame-link'),
".js-data-file-blob-permalink-url, .js-blob-blame-link"
)
); );
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
fileBlobPermalinkUrlElement = document.querySelector( fileBlobPermalinkUrlElement = document.querySelector('.js-data-file-blob-permalink-url');
".js-data-file-blob-permalink-url" fileBlobPermalinkUrl = fileBlobPermalinkUrlElement && fileBlobPermalinkUrlElement.getAttribute('href');
);
fileBlobPermalinkUrl =
fileBlobPermalinkUrlElement &&
fileBlobPermalinkUrlElement.getAttribute("href");
new ShortcutsBlob({ new ShortcutsBlob({
skipResetBindings: true, skipResetBindings: true,
fileBlobPermalinkUrl fileBlobPermalinkUrl,
}); });
new BlobForkSuggestion({ new BlobForkSuggestion({
openButtons: document.querySelectorAll( openButtons: document.querySelectorAll('.js-edit-blob-link-fork-toggler'),
".js-edit-blob-link-fork-toggler" forkButtons: document.querySelectorAll('.js-fork-suggestion-button'),
), cancelButtons: document.querySelectorAll('.js-cancel-fork-suggestion-button'),
forkButtons: document.querySelectorAll(".js-fork-suggestion-button"), suggestionSections: document.querySelectorAll('.js-file-fork-suggestion-section'),
cancelButtons: document.querySelectorAll( actionTextPieces: document.querySelectorAll('.js-file-fork-suggestion-section-action'),
".js-cancel-fork-suggestion-button" })
), .init();
suggestionSections: document.querySelectorAll(
".js-file-fork-suggestion-section"
),
actionTextPieces: document.querySelectorAll(
".js-file-fork-suggestion-section-action"
)
}).init();
} }
const filteredSearchEnabled = const filteredSearchEnabled = gl.FilteredSearchManager && document.querySelector('.filtered-search');
gl.FilteredSearchManager && document.querySelector(".filtered-search");
switch (page) { switch (page) {
case "profiles:preferences:show": case 'profiles:preferences:show':
initExperimentalFlags(); initExperimentalFlags();
break; break;
case "sessions:new": case 'sessions:new':
new UsernameValidator(); new UsernameValidator();
new SigninTabsMemoizer(); new SigninTabsMemoizer();
new OAuthRememberMe({ new OAuthRememberMe({ container: $(".omniauth-container") }).bindEvents();
container: $(".omniauth-container")
}).bindEvents();
break; break;
case "projects:boards:show": case 'projects:boards:show':
case "projects:boards:index": case 'projects:boards:index':
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
new UsersSelect(); new UsersSelect();
break; break;
case "projects:merge_requests:index": case 'projects:merge_requests:index':
case "projects:issues:index": case 'projects:issues:index':
if (filteredSearchEnabled) { if (filteredSearchEnabled) {
const filteredSearchManager = new gl.FilteredSearchManager( const filteredSearchManager = new gl.FilteredSearchManager(page === 'projects:issues:index' ? 'issues' : 'merge_requests');
page === "projects:issues:index" ? "issues" : "merge_requests"
);
filteredSearchManager.setup(); filteredSearchManager.setup();
} }
const pagePrefix = const pagePrefix = page === 'projects:merge_requests:index' ? 'merge_request_' : 'issue_';
page === "projects:merge_requests:index"
? "merge_request_"
: "issue_";
new IssuableIndex(pagePrefix); new IssuableIndex(pagePrefix);
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
new UsersSelect(); new UsersSelect();
break; break;
case "projects:issues:show": case 'projects:issues:show':
new Issue(); new Issue();
shortcut_handler = new ShortcutsIssuable(); shortcut_handler = new ShortcutsIssuable();
new ZenMode(); new ZenMode();
initIssuableSidebar(); initIssuableSidebar();
break; break;
case "dashboard:milestones:index": case 'dashboard:milestones:index':
projectSelect(); projectSelect();
break; break;
case "projects:milestones:show": case 'projects:milestones:show':
case "groups:milestones:show": case 'groups:milestones:show':
case "dashboard:milestones:show": case 'dashboard:milestones:show':
new Milestone(); new Milestone();
new Sidebar(); new Sidebar();
break; break;
case "dashboard:issues": case 'dashboard:issues':
case "dashboard:merge_requests": case 'dashboard:merge_requests':
projectSelect(); projectSelect();
initLegacyFilters(); initLegacyFilters();
break; break;
case "groups:issues": case 'groups:issues':
case "groups:merge_requests": case 'groups:merge_requests':
if (filteredSearchEnabled) { if (filteredSearchEnabled) {
const filteredSearchManager = new gl.FilteredSearchManager( const filteredSearchManager = new gl.FilteredSearchManager(page === 'groups:issues' ? 'issues' : 'merge_requests');
page === "groups:issues" ? "issues" : "merge_requests"
);
filteredSearchManager.setup(); filteredSearchManager.setup();
} }
projectSelect(); projectSelect();
break; break;
case "dashboard:todos:index": case 'dashboard:todos:index':
new Todos(); new Todos();
break; break;
case "explore:projects:index":
case "explore:projects:trending": case 'explore:projects:index':
case "explore:projects:starred": case 'explore:projects:trending':
import("./pages/explore/projects") case 'explore:projects:starred':
import('./pages/explore/projects')
.then(module => module.default()) .then(module => module.default())
.catch(fail); .catch(fail);
break; break;
case "dashboard:projects:index": case 'dashboard:projects:index':
case "dashboard:projects:starred": case 'dashboard:projects:starred':
case "admin:projects:index": case 'admin:projects:index':
new ProjectsList(); new ProjectsList();
break; break;
case "explore:groups:index": case 'explore:groups:index':
import("./pages/explore/groups") import('./pages/explore/groups')
.then(module => module.default()) .then(module => module.default())
.catch(fail); .catch(fail);
break; break;
case "projects:milestones:new":
case "projects:milestones:edit": case 'admin:projects:index':
case "projects:milestones:update": new ProjectsList();
break;
case 'explore:groups:index':
new GroupsList();
const landingElement = document.querySelector('.js-explore-groups-landing');
if (!landingElement) break;
const exploreGroupsLanding = new Landing(
landingElement,
landingElement.querySelector('.dismiss-button'),
'explore_groups_landing_dismissed',
);
exploreGroupsLanding.toggle();
break;
case 'projects:milestones:new':
case 'projects:milestones:edit':
case 'projects:milestones:update':
new ZenMode(); new ZenMode();
new DueDateSelectors(); new DueDateSelectors();
new GLForm($(".milestone-form"), true); new GLForm($('.milestone-form'), true);
break; break;
case "groups:milestones:new": case 'groups:milestones:new':
case "groups:milestones:edit": case 'groups:milestones:edit':
case "groups:milestones:update": case 'groups:milestones:update':
new ZenMode(); new ZenMode();
new DueDateSelectors(); new DueDateSelectors();
new GLForm($(".milestone-form"), false); new GLForm($('.milestone-form'), false);
break; break;
case "projects:compare:show": case 'projects:compare:show':
new Diff(); new Diff();
const paddingTop = 16; const paddingTop = 16;
initChangesDropdown( initChangesDropdown(document.querySelector('.navbar-gitlab').offsetHeight - paddingTop);
document.querySelector(".navbar-gitlab").offsetHeight - paddingTop
);
break; break;
case "projects:branches:new": case 'projects:branches:new':
case "projects:branches:create": case 'projects:branches:create':
new NewBranchForm( new NewBranchForm($('.js-create-branch-form'), JSON.parse(document.getElementById('availableRefs').innerHTML));
$(".js-create-branch-form"),
JSON.parse(document.getElementById("availableRefs").innerHTML)
);
break; break;
case "projects:branches:index": case 'projects:branches:index':
AjaxLoadingSpinner.init(); AjaxLoadingSpinner.init();
new DeleteModal(); new DeleteModal();
break; break;
case "projects:issues:new": case 'projects:issues:new':
case "projects:issues:edit": case 'projects:issues:edit':
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
new GLForm($(".issue-form"), true); new GLForm($('.issue-form'), true);
new IssuableForm($(".issue-form")); new IssuableForm($('.issue-form'));
new LabelsSelect(); new LabelsSelect();
new MilestoneSelect(); new MilestoneSelect();
new IssuableTemplateSelectors(); new IssuableTemplateSelectors();
break; break;
case "projects:merge_requests:creations:new": case 'projects:merge_requests:creations:new':
const mrNewCompareNode = document.querySelector( const mrNewCompareNode = document.querySelector('.js-merge-request-new-compare');
".js-merge-request-new-compare"
);
if (mrNewCompareNode) { if (mrNewCompareNode) {
new Compare({ new Compare({
targetProjectUrl: mrNewCompareNode.dataset.targetProjectUrl, targetProjectUrl: mrNewCompareNode.dataset.targetProjectUrl,
sourceBranchUrl: mrNewCompareNode.dataset.sourceBranchUrl, sourceBranchUrl: mrNewCompareNode.dataset.sourceBranchUrl,
targetBranchUrl: mrNewCompareNode.dataset.targetBranchUrl targetBranchUrl: mrNewCompareNode.dataset.targetBranchUrl,
}); });
} else { } else {
const mrNewSubmitNode = document.querySelector( const mrNewSubmitNode = document.querySelector('.js-merge-request-new-submit');
".js-merge-request-new-submit"
);
new MergeRequest({ new MergeRequest({
action: mrNewSubmitNode.dataset.mrSubmitAction action: mrNewSubmitNode.dataset.mrSubmitAction,
}); });
} }
case "projects:merge_requests:creations:diffs": case 'projects:merge_requests:creations:diffs':
case "projects:merge_requests:edit": case 'projects:merge_requests:edit':
new Diff(); new Diff();
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
new GLForm($(".merge-request-form"), true); new GLForm($('.merge-request-form'), true);
new IssuableForm($(".merge-request-form")); new IssuableForm($('.merge-request-form'));
new LabelsSelect(); new LabelsSelect();
new MilestoneSelect(); new MilestoneSelect();
new IssuableTemplateSelectors(); new IssuableTemplateSelectors();
new AutoWidthDropdownSelect($(".js-target-branch-select")).init(); new AutoWidthDropdownSelect($('.js-target-branch-select')).init();
break; break;
case "projects:tags:new": case 'projects:tags:new':
new ZenMode(); new ZenMode();
new GLForm($(".tag-form"), true); new GLForm($('.tag-form'), true);
new RefSelectDropdown($(".js-branch-select")); new RefSelectDropdown($('.js-branch-select'));
break; break;
case "projects:snippets:show": case 'projects:snippets:show':
initNotes(); initNotes();
new ZenMode(); new ZenMode();
break; break;
case "projects:snippets:new": case 'projects:snippets:new':
case "projects:snippets:edit": case 'projects:snippets:edit':
case "projects:snippets:create": case 'projects:snippets:create':
case "projects:snippets:update": case 'projects:snippets:update':
new GLForm($(".snippet-form"), true); new GLForm($('.snippet-form'), true);
new ZenMode(); new ZenMode();
break; break;
case "snippets:new": case 'snippets:new':
case "snippets:edit": case 'snippets:edit':
case "snippets:create": case 'snippets:create':
case "snippets:update": case 'snippets:update':
new GLForm($(".snippet-form"), false); new GLForm($('.snippet-form'), false);
new ZenMode(); new ZenMode();
break; break;
case "projects:releases:edit": case 'projects:releases:edit':
new ZenMode(); new ZenMode();
new GLForm($(".release-form"), true); new GLForm($('.release-form'), true);
break; break;
case "projects:merge_requests:show": case 'projects:merge_requests:show':
new Diff(); new Diff();
new ZenMode(); new ZenMode();
initIssuableSidebar(); initIssuableSidebar();
initNotes(); initNotes();
const mrShowNode = document.querySelector(".merge-request"); const mrShowNode = document.querySelector('.merge-request');
window.mergeRequest = new MergeRequest({ window.mergeRequest = new MergeRequest({
action: mrShowNode.dataset.mrAction action: mrShowNode.dataset.mrAction,
}); });
shortcut_handler = new ShortcutsIssuable(true); shortcut_handler = new ShortcutsIssuable(true);
break; break;
case "dashboard:activity": case 'dashboard:activity':
new Activities(); new Activities();
break; break;
case "projects:commit:show": case 'projects:commit:show':
new Diff(); new Diff();
new ZenMode(); new ZenMode();
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
new MiniPipelineGraph({ new MiniPipelineGraph({
container: ".js-commit-pipeline-graph" container: '.js-commit-pipeline-graph',
}).bindEvents(); }).bindEvents();
initNotes(); initNotes();
const stickyBarPaddingTop = 16; const stickyBarPaddingTop = 16;
initChangesDropdown( initChangesDropdown(document.querySelector('.navbar-gitlab').offsetHeight - stickyBarPaddingTop);
document.querySelector(".navbar-gitlab").offsetHeight - $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath);
stickyBarPaddingTop
);
$(".commit-info.branches").load(
document.querySelector(".js-commit-box").dataset.commitPath
);
break; break;
case "projects:commit:pipelines": case 'projects:commit:pipelines':
new MiniPipelineGraph({ new MiniPipelineGraph({
container: ".js-commit-pipeline-graph" container: '.js-commit-pipeline-graph',
}).bindEvents(); }).bindEvents();
$(".commit-info.branches").load( $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath);
document.querySelector(".js-commit-box").dataset.commitPath
);
break; break;
case "projects:activity": case 'projects:activity':
new Activities(); new Activities();
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
break; break;
case "projects:commits:show": case 'projects:commits:show':
CommitsList.init( CommitsList.init(document.querySelector('.js-project-commits-show').dataset.commitsLimit);
document.querySelector(".js-project-commits-show").dataset
.commitsLimit
);
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
GpgBadges.fetch(); GpgBadges.fetch();
break; break;
case "projects:show": case 'projects:show':
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
new NotificationsForm(); new NotificationsForm();
new UserCallout({ new UserCallout({
setCalloutPerProject: true, setCalloutPerProject: true,
className: "js-autodevops-banner" className: 'js-autodevops-banner',
}); });
if ($("#tree-slider").length) new TreeView(); if ($('#tree-slider').length) new TreeView();
if ($(".blob-viewer").length) new BlobViewer(); if ($('.blob-viewer').length) new BlobViewer();
if ($(".project-show-activity").length) new Activities(); if ($('.project-show-activity').length) new Activities();
$("#tree-slider").waitForImages(function() { $('#tree-slider').waitForImages(function() {
ajaxGet( ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath);
document.querySelector(".js-tree-content").dataset.logsPath
);
}); });
break; break;
case "projects:edit": case 'projects:edit':
setupProjectEdit(); setupProjectEdit();
// Initialize expandable settings panels // Initialize expandable settings panels
initSettingsPanels(); initSettingsPanels();
break; break;
case "projects:imports:show": case 'projects:imports:show':
projectImport(); projectImport();
break; break;
case "projects:pipelines:new": case 'projects:pipelines:new':
case "projects:pipelines:create": case 'projects:pipelines:create':
new NewBranchForm($(".js-new-pipeline-form")); new NewBranchForm($('.js-new-pipeline-form'));
break; break;
case "projects:pipelines:builds": case 'projects:pipelines:builds':
case "projects:pipelines:failures": case 'projects:pipelines:failures':
case "projects:pipelines:show": case 'projects:pipelines:show':
const { controllerAction } = document.querySelector( const { controllerAction } = document.querySelector('.js-pipeline-container').dataset;
".js-pipeline-container" const pipelineStatusUrl = `${document.querySelector('.js-pipeline-tab-link a').getAttribute('href')}/status.json`;
).dataset;
const pipelineStatusUrl = `${document
.querySelector(".js-pipeline-tab-link a")
.getAttribute("href")}/status.json`;
new Pipelines({ new Pipelines({
initTabs: true, initTabs: true,
pipelineStatusUrl, pipelineStatusUrl,
tabsOptions: { tabsOptions: {
action: controllerAction, action: controllerAction,
defaultAction: "pipelines", defaultAction: 'pipelines',
parentEl: ".pipelines-tabs" parentEl: '.pipelines-tabs',
} },
}); });
break; break;
case "groups:activity": case 'groups:activity':
new Activities(); new Activities();
break; break;
case "groups:show": case 'groups:show':
const newGroupChildWrapper = document.querySelector( const newGroupChildWrapper = document.querySelector('.js-new-project-subgroup');
".js-new-project-subgroup"
);
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
new NotificationsForm(); new NotificationsForm();
notificationsDropdown(); notificationsDropdown();
...@@ -475,273 +436,259 @@ import Activities from "./activities"; ...@@ -475,273 +436,259 @@ import Activities from "./activities";
new NewGroupChild(newGroupChildWrapper); new NewGroupChild(newGroupChildWrapper);
} }
break; break;
case "groups:group_members:index": case 'groups:group_members:index':
memberExpirationDate(); memberExpirationDate();
new Members(); new Members();
new UsersSelect(); new UsersSelect();
break; break;
case "projects:project_members:index": case 'projects:project_members:index':
memberExpirationDate(".js-access-expiration-date-groups"); memberExpirationDate('.js-access-expiration-date-groups');
groupsSelect(); groupsSelect();
memberExpirationDate(); memberExpirationDate();
new Members(); new Members();
new UsersSelect(); new UsersSelect();
break; break;
case "groups:new": case 'groups:new':
case "admin:groups:new": case 'admin:groups:new':
case "groups:create": case 'groups:create':
case "admin:groups:create": case 'admin:groups:create':
BindInOut.initAll(); BindInOut.initAll();
new Group(); new Group();
groupAvatar(); groupAvatar();
break; break;
case "groups:edit": case 'groups:edit':
case "admin:groups:edit": case 'admin:groups:edit':
groupAvatar(); groupAvatar();
break; break;
case "projects:tree:show": case 'projects:tree:show':
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
new TreeView(); new TreeView();
new BlobViewer(); new BlobViewer();
new NewCommitForm($(".js-create-dir-form")); new NewCommitForm($('.js-create-dir-form'));
$("#tree-slider").waitForImages(function() { $('#tree-slider').waitForImages(function() {
ajaxGet( ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath);
document.querySelector(".js-tree-content").dataset.logsPath
);
}); });
break; break;
case "projects:find_file:show": case 'projects:find_file:show':
const findElement = document.querySelector(".js-file-finder"); const findElement = document.querySelector('.js-file-finder');
const projectFindFile = new ProjectFindFile( const projectFindFile = new ProjectFindFile($(".file-finder-holder"), {
$(".file-finder-holder"),
{
url: findElement.dataset.fileFindUrl, url: findElement.dataset.fileFindUrl,
treeUrl: findElement.dataset.findTreeUrl, treeUrl: findElement.dataset.findTreeUrl,
blobUrlTemplate: findElement.dataset.blobUrlTemplate blobUrlTemplate: findElement.dataset.blobUrlTemplate,
} });
);
new ShortcutsFindFile(projectFindFile); new ShortcutsFindFile(projectFindFile);
shortcut_handler = true; shortcut_handler = true;
break; break;
case "projects:blob:show": case 'projects:blob:show':
new BlobViewer(); new BlobViewer();
initBlob(); initBlob();
break; break;
case "projects:blame:show": case 'projects:blame:show':
initBlob(); initBlob();
break; break;
case "groups:labels:new": case 'groups:labels:new':
case "groups:labels:edit": case 'groups:labels:edit':
case "projects:labels:new": case 'projects:labels:new':
case "projects:labels:edit": case 'projects:labels:edit':
new Labels(); new Labels();
break; break;
case "groups:labels:index": case 'groups:labels:index':
case "projects:labels:index": case 'projects:labels:index':
if ($(".prioritized-labels").length) { if ($('.prioritized-labels').length) {
new LabelManager(); new LabelManager();
} }
$(".label-subscription").each((i, el) => { $('.label-subscription').each((i, el) => {
const $el = $(el); const $el = $(el);
if ($el.find(".dropdown-group-label").length) { if ($el.find('.dropdown-group-label').length) {
new GroupLabelSubscription($el); new GroupLabelSubscription($el);
} else { } else {
new ProjectLabelSubscription($el); new ProjectLabelSubscription($el);
} }
}); });
break; break;
case "projects:network:show": case 'projects:network:show':
// Ensure we don't create a particular shortcut handler here. This is // Ensure we don't create a particular shortcut handler here. This is
// already created, where the network graph is created. // already created, where the network graph is created.
shortcut_handler = true; shortcut_handler = true;
break; break;
case "projects:forks:new": case 'projects:forks:new':
import(/* webpackChunkName: 'project_fork' */ "./project_fork") import(/* webpackChunkName: 'project_fork' */ './project_fork')
.then(fork => fork.default()) .then(fork => fork.default())
.catch(() => {}); .catch(() => {});
break; break;
case "projects:artifacts:browse": case 'projects:artifacts:browse':
new ShortcutsNavigation(); new ShortcutsNavigation();
new BuildArtifacts(); new BuildArtifacts();
break; break;
case "projects:artifacts:file": case 'projects:artifacts:file':
new ShortcutsNavigation(); new ShortcutsNavigation();
new BlobViewer(); new BlobViewer();
break; break;
case "help:index": case 'help:index':
VersionCheckImage.bindErrorEvent($("img.js-version-status-badge")); VersionCheckImage.bindErrorEvent($('img.js-version-status-badge'));
break; break;
case "search:show": case 'search:show':
new Search(); new Search();
break; break;
case "projects:settings:repository:show": case 'projects:settings:repository:show':
// Initialize expandable settings panels // Initialize expandable settings panels
initSettingsPanels(); initSettingsPanels();
break; break;
case "projects:settings:ci_cd:show": case 'projects:settings:ci_cd:show':
// Initialize expandable settings panels // Initialize expandable settings panels
initSettingsPanels(); initSettingsPanels();
const runnerToken = document.querySelector(".js-secret-runner-token"); const runnerToken = document.querySelector('.js-secret-runner-token');
if (runnerToken) { if (runnerToken) {
const runnerTokenSecretValue = new SecretValues(runnerToken); const runnerTokenSecretValue = new SecretValues(runnerToken);
runnerTokenSecretValue.init(); runnerTokenSecretValue.init();
} }
case "groups:settings:ci_cd:show": case 'groups:settings:ci_cd:show':
const secretVariableTable = document.querySelector( const secretVariableTable = document.querySelector('.js-secret-variable-table');
".js-secret-variable-table"
);
if (secretVariableTable) { if (secretVariableTable) {
const secretVariableTableValues = new SecretValues( const secretVariableTableValues = new SecretValues(secretVariableTable);
secretVariableTable
);
secretVariableTableValues.init(); secretVariableTableValues.init();
} }
break; break;
case "ci:lints:create": case 'ci:lints:create':
case "ci:lints:show": case 'ci:lints:show':
new CILintEditor(); new CILintEditor();
break; break;
case "users:show": case 'users:show':
import("./pages/users/show") import('./pages/users/show').then(m => m.default()).catch(fail);
.then(m => m.default())
.catch(fail);
break; break;
case "admin:conversational_development_index:show": case 'admin:conversational_development_index:show':
new UserCallout(); new UserCallout();
break; break;
case "snippets:show": case 'snippets:show':
new LineHighlighter(); new LineHighlighter();
new BlobViewer(); new BlobViewer();
initNotes(); initNotes();
new ZenMode(); new ZenMode();
break; break;
case "import:fogbugz:new_user_map": case 'import:fogbugz:new_user_map':
new UsersSelect(); new UsersSelect();
break; break;
case "profiles:personal_access_tokens:index": case 'profiles:personal_access_tokens:index':
case "admin:impersonation_tokens:index": case 'admin:impersonation_tokens:index':
new DueDateSelectors(); new DueDateSelectors();
break; break;
case "projects:clusters:show": case 'projects:clusters:show':
import(/* webpackChunkName: "clusters" */ "./clusters/clusters_bundle") import(/* webpackChunkName: "clusters" */ './clusters/clusters_bundle')
.then(cluster => new cluster.default()) // eslint-disable-line new-cap .then(cluster => new cluster.default()) // eslint-disable-line new-cap
.catch(err => { .catch((err) => {
Flash(s__("ClusterIntegration|Problem setting up the cluster")); Flash(s__('ClusterIntegration|Problem setting up the cluster'));
throw err; throw err;
}); });
break; break;
case "projects:clusters:index": case 'projects:clusters:index':
import(/* webpackChunkName: "clusters_index" */ "./clusters/clusters_index") import(/* webpackChunkName: "clusters_index" */ './clusters/clusters_index')
.then(clusterIndex => clusterIndex.default()) .then(clusterIndex => clusterIndex.default())
.catch(err => { .catch((err) => {
Flash( Flash(s__('ClusterIntegration|Problem setting up the clusters list'));
s__("ClusterIntegration|Problem setting up the clusters list")
);
throw err; throw err;
}); });
break; break;
} }
switch (path[0]) { switch (path[0]) {
case "sessions": case 'sessions':
case "omniauth_callbacks": case 'omniauth_callbacks':
if (!gon.u2f) break; if (!gon.u2f) break;
const u2fAuthenticate = new U2FAuthenticate( const u2fAuthenticate = new U2FAuthenticate(
$("#js-authenticate-u2f"), $('#js-authenticate-u2f'),
"#js-login-u2f-form", '#js-login-u2f-form',
gon.u2f, gon.u2f,
document.querySelector("#js-login-2fa-device"), document.querySelector('#js-login-2fa-device'),
document.querySelector(".js-2fa-form") document.querySelector('.js-2fa-form'),
); );
u2fAuthenticate.start(); u2fAuthenticate.start();
// needed in rspec // needed in rspec
gl.u2fAuthenticate = u2fAuthenticate; gl.u2fAuthenticate = u2fAuthenticate;
case "admin": case 'admin':
initAdmin(); initAdmin();
switch (path[1]) { switch (path[1]) {
case "broadcast_messages": case 'broadcast_messages':
initBroadcastMessagesForm(); initBroadcastMessagesForm();
break; break;
case "cohorts": case 'cohorts':
new UsagePing(); new UsagePing();
break; break;
case "groups": case 'groups':
new UsersSelect(); new UsersSelect();
break; break;
case "projects": case 'projects':
document document.querySelectorAll('.js-namespace-select')
.querySelectorAll(".js-namespace-select")
.forEach(dropdown => new NamespaceSelect({ dropdown })); .forEach(dropdown => new NamespaceSelect({ dropdown }));
break; break;
case "labels": case 'labels':
switch (path[2]) { switch (path[2]) {
case "new": case 'new':
case "edit": case 'edit':
new Labels(); new Labels();
} }
case "abuse_reports": case 'abuse_reports':
new AbuseReports(); new AbuseReports();
break; break;
} }
break; break;
case "dashboard": case 'dashboard':
case "root": case 'root':
new UserCallout(); new UserCallout();
break; break;
case "profiles": case 'profiles':
new NotificationsForm(); new NotificationsForm();
notificationsDropdown(); notificationsDropdown();
break; break;
case "projects": case 'projects':
new Project(); new Project();
projectAvatar(); projectAvatar();
switch (path[1]) { switch (path[1]) {
case "compare": case 'compare':
initCompareAutocomplete(); initCompareAutocomplete();
break; break;
case "edit": case 'edit':
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
new ProjectNew(); new ProjectNew();
import(/* webpackChunkName: 'project_permissions' */ "./projects/permissions") import(/* webpackChunkName: 'project_permissions' */ './projects/permissions')
.then(permissions => permissions.default()) .then(permissions => permissions.default())
.catch(() => {}); .catch(() => {});
break; break;
case "new": case 'new':
new ProjectNew(); new ProjectNew();
initProjectVisibilitySelector(); initProjectVisibilitySelector();
break; break;
case "show": case 'show':
new Star(); new Star();
new ProjectNew(); new ProjectNew();
notificationsDropdown(); notificationsDropdown();
break; break;
case "wikis": case 'wikis':
new Wikis(); new Wikis();
shortcut_handler = new ShortcutsWiki(); shortcut_handler = new ShortcutsWiki();
new ZenMode(); new ZenMode();
new GLForm($(".wiki-form"), true); new GLForm($('.wiki-form'), true);
break; break;
case "snippets": case 'snippets':
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
if (path[2] === "show") { if (path[2] === 'show') {
new ZenMode(); new ZenMode();
new LineHighlighter(); new LineHighlighter();
new BlobViewer(); new BlobViewer();
} }
break; break;
case "labels": case 'labels':
case "graphs": case 'graphs':
case "compare": case 'compare':
case "pipelines": case 'pipelines':
case "forks": case 'forks':
case "milestones": case 'milestones':
case "project_members": case 'project_members':
case "deploy_keys": case 'deploy_keys':
case "builds": case 'builds':
case "hooks": case 'hooks':
case "services": case 'services':
case "protected_branches": case 'protected_branches':
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
} }
break; break;
...@@ -751,20 +698,20 @@ import Activities from "./activities"; ...@@ -751,20 +698,20 @@ import Activities from "./activities";
new Shortcuts(); new Shortcuts();
} }
if (document.querySelector("#peek")) { if (document.querySelector('#peek')) {
new PerformanceBar({ container: "#peek" }); new PerformanceBar({ container: '#peek' });
} }
}; };
Dispatcher.prototype.initSearch = function() { Dispatcher.prototype.initSearch = function() {
// Only when search form is present // Only when search form is present
if ($(".search").length) { if ($('.search').length) {
return new SearchAutocomplete(); return new SearchAutocomplete();
} }
}; };
Dispatcher.prototype.initFieldErrors = function() { Dispatcher.prototype.initFieldErrors = function() {
$(".gl-show-field-errors").each((i, form) => { $('.gl-show-field-errors').each((i, form) => {
new GlFieldErrors(form); new GlFieldErrors(form);
}); });
}; };
...@@ -772,7 +719,7 @@ import Activities from "./activities"; ...@@ -772,7 +719,7 @@ import Activities from "./activities";
return Dispatcher; return Dispatcher;
})(); })();
$(window).on("load", function() { $(window).on('load', function() {
new Dispatcher(); new Dispatcher();
}); });
}.call(window)); }).call(window);
import GroupsList from "~/groups_list"; import GroupsList from '~/groups_list';
import Landing from "~/landing"; import Landing from '~/landing';
export default function() { export default function() {
new GroupsList(); new GroupsList();
const landingElement = document.querySelector(".js-explore-groups-landing"); const landingElement = document.querySelector('.js-explore-groups-landing');
if (!landingElement) return; if (!landingElement) return;
const exploreGroupsLanding = new Landing( const exploreGroupsLanding = new Landing(
landingElement, landingElement,
landingElement.querySelector(".dismiss-button"), landingElement.querySelector('.dismiss-button'),
"explore_groups_landing_dismissed" 'explore_groups_landing_dismissed'
); );
exploreGroupsLanding.toggle(); exploreGroupsLanding.toggle();
} }
import ProjectsList from "~/projects_list"; import ProjectsList from '~/projects_list';
export default function() { export default function() {
new ProjectsList(); new ProjectsList();
......
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