Commit 26484cf1 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'ph-es-modules' into 'master'

Converted JS files into exported modules

See merge request gitlab-org/gitlab-ce!15933
parents 391bb437 adb84833
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { localTimeAgo } from './lib/utils/datetime_utility'; import { localTimeAgo } from './lib/utils/datetime_utility';
class Activities { export default class Activities {
constructor() { constructor() {
Pager.init(20, true, false, data => data, this.updateTooltips); Pager.init(20, true, false, data => data, this.updateTooltips);
...@@ -34,6 +34,3 @@ class Activities { ...@@ -34,6 +34,3 @@ class Activities {
$sender.closest('li').toggleClass('active'); $sender.closest('li').toggleClass('active');
} }
} }
window.gl = window.gl || {};
window.gl.Activities = Activities;
/* eslint-disable func-names, space-before-function-paren, wrap-iife, one-var, no-var, one-var-declaration-per-line, no-unused-vars, no-else-return, prefer-arrow-callback, camelcase, quotes, comma-dangle, max-len */
import { refreshCurrentPage } from './lib/utils/url_utility'; import { refreshCurrentPage } from './lib/utils/url_utility';
window.Admin = (function() { function showBlacklistType() {
function Admin() { if ($('input[name="blacklist_type"]:checked').val() === 'file') {
var modal, showBlacklistType; $('.blacklist-file').show();
$('input#user_force_random_password').on('change', function(elem) { $('.blacklist-raw').hide();
var elems; } else {
elems = $('#user_password, #user_password_confirmation'); $('.blacklist-file').hide();
$('.blacklist-raw').show();
}
}
export default function adminInit() {
const modal = $('.change-owner-holder');
$('input#user_force_random_password').on('change', function randomPasswordClick() {
const $elems = $('#user_password, #user_password_confirmation');
if ($(this).attr('checked')) { if ($(this).attr('checked')) {
return elems.val('').attr('disabled', true); $elems.val('').attr('disabled', true);
} else { } else {
return elems.removeAttr('disabled'); $elems.removeAttr('disabled');
} }
}); });
$('body').on('click', '.js-toggle-colors-link', function(e) {
$('body').on('click', '.js-toggle-colors-link', (e) => {
e.preventDefault(); e.preventDefault();
return $('.js-toggle-colors-container').toggle(); $('.js-toggle-colors-container').toggle();
}); });
$('.log-tabs a').click(function(e) {
$('.log-tabs a').on('click', function logTabsClick(e) {
e.preventDefault(); e.preventDefault();
return $(this).tab('show'); $(this).tab('show');
}); });
$('.log-bottom').click(function(e) {
var visible_log; $('.log-bottom').on('click', (e) => {
e.preventDefault(); e.preventDefault();
visible_log = $(".file-content:visible"); const $visibleLog = $('.file-content:visible');
return visible_log.animate({ $visibleLog.animate({
scrollTop: visible_log.find('ol').height() scrollTop: $visibleLog.find('ol').height(),
}, "fast"); }, 'fast');
}); });
modal = $('.change-owner-holder');
$('.change-owner-link').bind("click", function(e) { $('.change-owner-link').on('click', function changeOwnerLinkClick(e) {
e.preventDefault(); e.preventDefault();
$(this).hide(); $(this).hide();
return modal.show(); modal.show();
}); });
$('.change-owner-cancel-link').bind("click", function(e) {
$('.change-owner-cancel-link').on('click', (e) => {
e.preventDefault(); e.preventDefault();
modal.hide(); modal.hide();
return $('.change-owner-link').show(); $('.change-owner-link').show();
}); });
$('li.project_member').bind('ajax:success', function() {
return refreshCurrentPage();
});
$('li.group_member').bind('ajax:success', function() {
return refreshCurrentPage();
});
showBlacklistType = function() {
if ($("input[name='blacklist_type']:checked").val() === 'file') {
$('.blacklist-file').show();
return $('.blacklist-raw').hide();
} else {
$('.blacklist-file').hide();
return $('.blacklist-raw').show();
}
};
$("input[name='blacklist_type']").click(showBlacklistType);
showBlacklistType();
}
return Admin; $('li.project_member, li.group_member').on('ajax:success', refreshCurrentPage);
})();
$("input[name='blacklist_type']").on('click', showBlacklistType);
showBlacklistType();
}
/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, prefer-arrow-callback, no-var, one-var, one-var-declaration-per-line, no-else-return, max-len */
window.Aside = (function() {
function Aside() {
$(document).off("click", "a.show-aside");
$(document).on("click", 'a.show-aside', function(e) {
var btn, icon;
e.preventDefault();
btn = $(e.currentTarget);
icon = btn.find('i');
if (icon.hasClass('fa-angle-left')) {
btn.parent().find('section').hide();
btn.parent().find('aside').fadeIn();
return icon.removeClass('fa-angle-left').addClass('fa-angle-right');
} else {
btn.parent().find('aside').hide();
btn.parent().find('section').fadeIn();
return icon.removeClass('fa-angle-right').addClass('fa-angle-left');
}
});
}
return Aside;
})();
...@@ -16,7 +16,7 @@ import BuildArtifacts from './build_artifacts'; ...@@ -16,7 +16,7 @@ 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';
/* global 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';
...@@ -92,6 +92,7 @@ import Diff from './diff'; ...@@ -92,6 +92,7 @@ import Diff from './diff';
import ProjectLabelSubscription from './project_label_subscription'; import ProjectLabelSubscription from './project_label_subscription';
import ProjectVariables from './project_variables'; import ProjectVariables from './project_variables';
import SearchAutocomplete from './search_autocomplete'; import SearchAutocomplete from './search_autocomplete';
import Activities from './activities';
(function() { (function() {
var Dispatcher; var Dispatcher;
...@@ -334,7 +335,7 @@ import SearchAutocomplete from './search_autocomplete'; ...@@ -334,7 +335,7 @@ import SearchAutocomplete from './search_autocomplete';
shortcut_handler = new ShortcutsIssuable(true); shortcut_handler = new ShortcutsIssuable(true);
break; break;
case 'dashboard:activity': case 'dashboard:activity':
new gl.Activities(); new Activities();
break; break;
case 'projects:commit:show': case 'projects:commit:show':
new Diff(); new Diff();
...@@ -355,7 +356,7 @@ import SearchAutocomplete from './search_autocomplete'; ...@@ -355,7 +356,7 @@ import SearchAutocomplete from './search_autocomplete';
$('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath); $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath);
break; break;
case 'projects:activity': case 'projects:activity':
new gl.Activities(); new Activities();
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
break; break;
case 'projects:commits:show': case 'projects:commits:show':
...@@ -373,7 +374,7 @@ import SearchAutocomplete from './search_autocomplete'; ...@@ -373,7 +374,7 @@ import SearchAutocomplete from './search_autocomplete';
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 gl.Activities(); if ($('.project-show-activity').length) new Activities();
$('#tree-slider').waitForImages(function() { $('#tree-slider').waitForImages(function() {
ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath); ajaxGet(document.querySelector('.js-tree-content').dataset.logsPath);
}); });
...@@ -407,7 +408,7 @@ import SearchAutocomplete from './search_autocomplete'; ...@@ -407,7 +408,7 @@ import SearchAutocomplete from './search_autocomplete';
}); });
break; break;
case 'groups:activity': case 'groups:activity':
new gl.Activities(); new Activities();
break; break;
case 'groups:show': case 'groups:show':
const newGroupChildWrapper = document.querySelector('.js-new-project-subgroup'); const newGroupChildWrapper = document.querySelector('.js-new-project-subgroup');
...@@ -584,7 +585,7 @@ import SearchAutocomplete from './search_autocomplete'; ...@@ -584,7 +585,7 @@ import SearchAutocomplete from './search_autocomplete';
// needed in rspec // needed in rspec
gl.u2fAuthenticate = u2fAuthenticate; gl.u2fAuthenticate = u2fAuthenticate;
case 'admin': case 'admin':
new Admin(); initAdmin();
switch (path[1]) { switch (path[1]) {
case 'broadcast_messages': case 'broadcast_messages':
initBroadcastMessagesForm(); initBroadcastMessagesForm();
......
/* eslint-disable func-names, space-before-function-paren, no-var, quotes, consistent-return, prefer-arrow-callback, comma-dangle, object-shorthand, no-new, max-len, no-multi-spaces, import/newline-after-import, import/first */ /* eslint-disable func-names, space-before-function-paren, no-var, quotes, consistent-return, prefer-arrow-callback, comma-dangle, object-shorthand, no-new, max-len, no-multi-spaces, import/newline-after-import, import/first */
/* global ConfirmDangerModal */ /* global ConfirmDangerModal */
/* global Aside */
import jQuery from 'jquery'; import jQuery from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
...@@ -37,7 +36,6 @@ import './behaviors/'; ...@@ -37,7 +36,6 @@ import './behaviors/';
// everything else // everything else
import './activities'; import './activities';
import './admin'; import './admin';
import './aside';
import loadAwardsHandler from './awards_handler'; import loadAwardsHandler from './awards_handler';
import bp from './breakpoints'; import bp from './breakpoints';
import './confirm_danger_modal'; import './confirm_danger_modal';
...@@ -273,7 +271,6 @@ $(function () { ...@@ -273,7 +271,6 @@ $(function () {
return fitSidebarForSize(); return fitSidebarForSize();
}); });
loadAwardsHandler(); loadAwardsHandler();
new Aside();
renderTimeago(); renderTimeago();
......
import Activities from '../activities';
import ActivityCalendar from './activity_calendar'; import ActivityCalendar from './activity_calendar';
import { localTimeAgo } from '../lib/utils/datetime_utility'; import { localTimeAgo } from '../lib/utils/datetime_utility';
...@@ -170,7 +171,7 @@ export default class UserTabs { ...@@ -170,7 +171,7 @@ export default class UserTabs {
}); });
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new gl.Activities(); new Activities();
this.loaded.activity = true; this.loaded.activity = true;
} }
......
...@@ -111,21 +111,4 @@ ...@@ -111,21 +111,4 @@
aside:not(.right-sidebar) { aside:not(.right-sidebar) {
display: none; display: none;
} }
.show-aside {
display: block !important;
}
}
.show-aside {
display: none;
position: fixed;
right: 0;
top: 30%;
padding: 5px 15px;
background: $show-aside-bg;
font-size: 20px;
color: $show-aside-color;
z-index: 100;
box-shadow: 0 1px 2px $show-aside-shadow;
} }
...@@ -245,9 +245,6 @@ $btn-sm-side-margin: 7px; ...@@ -245,9 +245,6 @@ $btn-sm-side-margin: 7px;
$btn-xs-side-margin: 5px; $btn-xs-side-margin: 5px;
$issue-status-expired: $orange-500; $issue-status-expired: $orange-500;
$issuable-sidebar-color: $gl-text-color-secondary; $issuable-sidebar-color: $gl-text-color-secondary;
$show-aside-bg: #eee;
$show-aside-color: #777;
$show-aside-shadow: #ddd;
$group-path-color: #999; $group-path-color: #999;
$namespace-kind-color: #aaa; $namespace-kind-color: #aaa;
$panel-heading-link-color: #777; $panel-heading-link-color: #777;
......
= link_to '#aside', class: 'show-aside' do
%i.fa.fa-angle-left
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import 'vendor/jquery.endless-scroll'; import 'vendor/jquery.endless-scroll';
import '~/pager'; import '~/pager';
import '~/activities'; import Activities from '~/activities';
(() => { (() => {
window.gon || (window.gon = {}); window.gon || (window.gon = {});
...@@ -35,7 +35,7 @@ import '~/activities'; ...@@ -35,7 +35,7 @@ import '~/activities';
describe('Activities', () => { describe('Activities', () => {
beforeEach(() => { beforeEach(() => {
loadFixtures(fixtureTemplate); loadFixtures(fixtureTemplate);
new gl.Activities(); new Activities();
}); });
for (let i = 0; i < filters.length; i += 1) { for (let i = 0; i < filters.length; i += 1) {
......
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