Commit 030de8b3 authored by Filipa Lacerda's avatar Filipa Lacerda

Export code as ES6 modules

parent 2b594daf
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var, quotes, vars-on-top, no-unused-vars, no-new, max-len */ /* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var, quotes, vars-on-top, no-unused-vars, no-new, max-len */
/* global EditBlob */ /* global EditBlob */
/* global NewCommitForm */ import NewCommitForm from '../new_commit_form';
import EditBlob from './edit_blob'; import EditBlob from './edit_blob';
import BlobFileDropzone from '../blob/blob_file_dropzone'; import BlobFileDropzone from '../blob/blob_file_dropzone';
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
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';
/* global 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';
/* global MilestoneSelect */ /* global MilestoneSelect */
/* global NewBranchForm */ import NewBranchForm from './new_branch_form';
/* global NotificationsForm */ /* global NotificationsForm */
/* global NotificationsDropdown */ /* global NotificationsDropdown */
import groupAvatar from './group_avatar'; import groupAvatar from './group_avatar';
...@@ -18,8 +18,7 @@ import groupsSelect from './groups_select'; ...@@ -18,8 +18,7 @@ import groupsSelect from './groups_select';
/* global Search */ /* global Search */
/* global Admin */ /* global Admin */
import NamespaceSelect from './namespace_select'; import NamespaceSelect from './namespace_select';
/* global NewCommitForm */ import NewCommitForm from './new_commit_form';
/* global NewBranchForm */
import Project from './project'; import Project from './project';
import projectAvatar from './project_avatar'; import projectAvatar from './project_avatar';
/* global MergeRequest */ /* global MergeRequest */
......
/* eslint-disable no-new */ /* eslint-disable no-new */
import LabelsSelect from './labels_select'; import LabelsSelect from './labels_select';
/* global MilestoneSelect */ /* global MilestoneSelect */
/* global SubscriptionSelect */ import subscriptionSelect from './subscription_select';
import UsersSelect from './users_select'; import UsersSelect from './users_select';
import issueStatusSelect from './issue_status_select'; import issueStatusSelect from './issue_status_select';
...@@ -11,5 +10,5 @@ export default () => { ...@@ -11,5 +10,5 @@ export default () => {
new LabelsSelect(); new LabelsSelect();
new MilestoneSelect(); new MilestoneSelect();
issueStatusSelect(); issueStatusSelect();
new SubscriptionSelect(); subscriptionSelect();
}; };
/* eslint-disable class-methods-use-this, no-new */ /* eslint-disable class-methods-use-this, no-new */
/* global MilestoneSelect */ /* global MilestoneSelect */
/* global SubscriptionSelect */
import IssuableBulkUpdateActions from './issuable_bulk_update_actions'; import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
import './milestone_select'; import './milestone_select';
import issueStatusSelect from './issue_status_select'; import issueStatusSelect from './issue_status_select';
import './subscription_select'; import subscriptionSelect from './subscription_select';
import LabelsSelect from './labels_select'; import LabelsSelect from './labels_select';
const HIDDEN_CLASS = 'hidden'; const HIDDEN_CLASS = 'hidden';
...@@ -48,7 +47,7 @@ export default class IssuableBulkUpdateSidebar { ...@@ -48,7 +47,7 @@ export default class IssuableBulkUpdateSidebar {
new LabelsSelect(); new LabelsSelect();
new MilestoneSelect(); new MilestoneSelect();
issueStatusSelect(); issueStatusSelect();
new SubscriptionSelect(); subscriptionSelect();
} }
setupBulkUpdateActions() { setupBulkUpdateActions() {
......
...@@ -58,11 +58,7 @@ import './line_highlighter'; ...@@ -58,11 +58,7 @@ import './line_highlighter';
import initLogoAnimation from './logo'; import initLogoAnimation from './logo';
import './merge_request'; import './merge_request';
import './merge_request_tabs'; import './merge_request_tabs';
import './milestone';
import './milestone_select'; import './milestone_select';
import './namespace_select';
import './new_branch_form';
import './new_commit_form';
import './notes'; import './notes';
import './notifications_dropdown'; import './notifications_dropdown';
import './notifications_form'; import './notifications_form';
...@@ -78,8 +74,6 @@ import './render_gfm'; ...@@ -78,8 +74,6 @@ import './render_gfm';
import './right_sidebar'; import './right_sidebar';
import './search'; import './search';
import './search_autocomplete'; import './search_autocomplete';
import './smart_interval';
import './subscription_select';
import initBreadcrumbs from './breadcrumb'; import initBreadcrumbs from './breadcrumb';
import './dispatcher'; import './dispatcher';
......
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-use-before-define, camelcase, quotes, object-shorthand, no-shadow, no-unused-vars, comma-dangle, no-var, prefer-template, no-underscore-dangle, consistent-return, one-var, one-var-declaration-per-line, default-case, prefer-arrow-callback, max-len */
/* global Sortable */ /* global Sortable */
import Flash from './flash'; import Flash from './flash';
(function() { export default class Milestone {
this.Milestone = (function() { constructor() {
function Milestone() {
this.bindTabsSwitching(); this.bindTabsSwitching();
// Load merge request tab if it is active // Load merge request tab if it is active
...@@ -15,24 +13,24 @@ import Flash from './flash'; ...@@ -15,24 +13,24 @@ import Flash from './flash';
this.loadInitialTab(); this.loadInitialTab();
} }
Milestone.prototype.bindTabsSwitching = function() { bindTabsSwitching() {
return $('a[data-toggle="tab"]').on('show.bs.tab', (e) => { return $('a[data-toggle="tab"]').on('show.bs.tab', (e) => {
const $target = $(e.target); const $target = $(e.target);
location.hash = $target.attr('href'); location.hash = $target.attr('href');
this.loadTab($target); this.loadTab($target);
}); });
}; }
// eslint-disable-next-line class-methods-use-this
Milestone.prototype.loadInitialTab = function() { loadInitialTab() {
const $target = $(`.js-milestone-tabs a[href="${location.hash}"]`); const $target = $(`.js-milestone-tabs a[href="${location.hash}"]`);
if ($target.length) { if ($target.length) {
$target.tab('show'); $target.tab('show');
} }
}; }
// eslint-disable-next-line class-methods-use-this
Milestone.prototype.loadTab = function($target) { loadTab($target) {
const endpoint = $target.data('endpoint'); const endpoint = $target.data('endpoint');
const tabElId = $target.attr('href'); const tabElId = $target.attr('href');
...@@ -47,8 +45,5 @@ import Flash from './flash'; ...@@ -47,8 +45,5 @@ import Flash from './flash';
$target.addClass('is-loaded'); $target.addClass('is-loaded');
}); });
} }
}; }
}
return Milestone;
})();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, no-var, one-var, prefer-rest-params, max-len, vars-on-top, wrap-iife, consistent-return, comma-dangle, one-var-declaration-per-line, quotes, no-return-assign, prefer-arrow-callback, prefer-template, no-shadow, no-else-return, max-len, object-shorthand */ /* eslint-disable func-names, space-before-function-paren, no-var, one-var, prefer-rest-params, max-len, vars-on-top, wrap-iife, consistent-return, comma-dangle, one-var-declaration-per-line, quotes, no-return-assign, prefer-arrow-callback, prefer-template, no-shadow, no-else-return, max-len, object-shorthand */
import RefSelectDropdown from '~/ref_select_dropdown'; import RefSelectDropdown from './ref_select_dropdown';
(function() { export default class NewBranchForm {
this.NewBranchForm = (function() { constructor(form, availableRefs) {
function NewBranchForm(form, availableRefs) {
this.validate = this.validate.bind(this); this.validate = this.validate.bind(this);
this.branchNameError = form.find('.js-branch-name-error'); this.branchNameError = form.find('.js-branch-name-error');
this.name = form.find('.js-branch-name'); this.name = form.find('.js-branch-name');
...@@ -14,17 +13,17 @@ import RefSelectDropdown from '~/ref_select_dropdown'; ...@@ -14,17 +13,17 @@ import RefSelectDropdown from '~/ref_select_dropdown';
this.init(); this.init();
} }
NewBranchForm.prototype.addBinding = function() { addBinding() {
return this.name.on('blur', this.validate); return this.name.on('blur', this.validate);
}; }
NewBranchForm.prototype.init = function() { init() {
if (this.name.length && this.name.val().length > 0) { if (this.name.length && this.name.val().length > 0) {
return this.name.trigger('blur'); return this.name.trigger('blur');
} }
}; }
NewBranchForm.prototype.setupRestrictions = function() { setupRestrictions() {
var endsWith, invalid, single, startsWith; var endsWith, invalid, single, startsWith;
startsWith = { startsWith = {
pattern: /^(\/|\.)/g, pattern: /^(\/|\.)/g,
...@@ -47,9 +46,9 @@ import RefSelectDropdown from '~/ref_select_dropdown'; ...@@ -47,9 +46,9 @@ import RefSelectDropdown from '~/ref_select_dropdown';
conjunction: "or" conjunction: "or"
}; };
return this.restrictions = [startsWith, invalid, endsWith, single]; return this.restrictions = [startsWith, invalid, endsWith, single];
}; }
NewBranchForm.prototype.validate = function() { validate() {
var errorMessage, errors, formatter, unique, validator; var errorMessage, errors, formatter, unique, validator;
const indexOf = [].indexOf; const indexOf = [].indexOf;
...@@ -90,8 +89,5 @@ import RefSelectDropdown from '~/ref_select_dropdown'; ...@@ -90,8 +89,5 @@ import RefSelectDropdown from '~/ref_select_dropdown';
errorMessage = $("<span/>").text(errors.join(', ')); errorMessage = $("<span/>").text(errors.join(', '));
return this.branchNameError.append(errorMessage); return this.branchNameError.append(errorMessage);
} }
}; }
}
return NewBranchForm;
})();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-return-assign, max-len */ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-return-assign, max-len */
(function() { export default class NewCommitForm {
this.NewCommitForm = (function() { constructor(form) {
function NewCommitForm(form) {
this.form = form; this.form = form;
this.renderDestination = this.renderDestination.bind(this); this.renderDestination = this.renderDestination.bind(this);
this.branchName = form.find('.js-branch-name'); this.branchName = form.find('.js-branch-name');
...@@ -12,7 +11,7 @@ ...@@ -12,7 +11,7 @@
this.renderDestination(); this.renderDestination();
} }
NewCommitForm.prototype.renderDestination = function() { renderDestination() {
var different; var different;
different = this.branchName.val() !== this.originalBranch.val(); different = this.branchName.val() !== this.originalBranch.val();
if (different) { if (different) {
...@@ -25,8 +24,5 @@ ...@@ -25,8 +24,5 @@
this.createMergeRequest.prop('checked', false); this.createMergeRequest.prop('checked', false);
} }
return this.wasDifferent = different; return this.wasDifferent = different;
}; }
}
return NewCommitForm;
})();
}).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, quotes, object-shorthand, no-unused-vars, no-shadow, one-var, one-var-declaration-per-line, comma-dangle, max-len */ export default function subscriptionSelect() {
$('.js-subscription-event').each((i, element) => {
const fieldName = $(element).data('field-name');
class SubscriptionSelect { return $(element).glDropdown({
constructor() {
$('.js-subscription-event').each(function(i, el) {
var fieldName;
fieldName = $(el).data("field-name");
return $(el).glDropdown({
selectable: true, selectable: true,
fieldName: fieldName, fieldName,
toggleLabel: (function(_this) { toggleLabel(selected, el, instance) {
return function(selected, el, instance) { let label = 'Subscription';
var $item, label; const $item = instance.dropdown.find('.is-active');
label = 'Subscription';
$item = instance.dropdown.find('.is-active');
if ($item.length) { if ($item.length) {
label = $item.text(); label = $item.text();
} }
return label; return label;
}; },
})(this), clicked(options) {
clicked: function(options) {
return options.e.preventDefault(); return options.e.preventDefault();
}, },
id: function(obj, el) { id(obj, el) {
return $(el).data("id"); return $(el).data('id');
} },
}); });
}); });
}
} }
window.SubscriptionSelect = SubscriptionSelect;
/* eslint-disable space-before-function-paren, one-var, no-var, one-var-declaration-per-line, no-return-assign, quotes, max-len */ /* eslint-disable space-before-function-paren, one-var, no-var, one-var-declaration-per-line, no-return-assign, quotes, max-len */
/* global NewBranchForm */
import '~/new_branch_form'; import NewBranchForm from '~/new_branch_form';
(function() { (function() {
describe('Branch', function() { describe('Branch', function() {
......
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