Merge branch '38869-issue' into 'master'

Remove issue and issue status select from global namespace

See merge request gitlab-org/gitlab-ce!15090
This commit is contained in:
Phil Hughes 2017-10-31 13:14:38 +00:00
commit c598283a16
7 changed files with 40 additions and 53 deletions

View file

@ -7,10 +7,12 @@ import { highCountTrim } from '~/lib/utils/text_utility';
* @param {jQuery.Event} e * @param {jQuery.Event} e
* @param {String} count * @param {String} count
*/ */
$(document).on('todo:toggle', (e, count) => { export default function initTodoToggle() {
const parsedCount = parseInt(count, 10); $(document).on('todo:toggle', (e, count) => {
const $todoPendingCount = $('.todos-count'); const parsedCount = parseInt(count, 10);
const $todoPendingCount = $('.todos-count');
$todoPendingCount.text(highCountTrim(parsedCount)); $todoPendingCount.text(highCountTrim(parsedCount));
$todoPendingCount.toggleClass('hidden', parsedCount === 0); $todoPendingCount.toggleClass('hidden', parsedCount === 0);
}); });
}

View file

@ -1,15 +1,15 @@
/* eslint-disable no-new */ /* eslint-disable no-new */
/* global LabelsSelect */ /* global LabelsSelect */
/* global MilestoneSelect */ /* global MilestoneSelect */
/* global IssueStatusSelect */
/* global SubscriptionSelect */ /* global SubscriptionSelect */
import UsersSelect from './users_select'; import UsersSelect from './users_select';
import issueStatusSelect from './issue_status_select';
export default () => { export default () => {
new UsersSelect(); new UsersSelect();
new LabelsSelect(); new LabelsSelect();
new MilestoneSelect(); new MilestoneSelect();
new IssueStatusSelect(); issueStatusSelect();
new SubscriptionSelect(); new SubscriptionSelect();
}; };

View file

@ -1,12 +1,11 @@
/* eslint-disable class-methods-use-this, no-new */ /* eslint-disable class-methods-use-this, no-new */
/* global LabelsSelect */ /* global LabelsSelect */
/* global MilestoneSelect */ /* global MilestoneSelect */
/* global IssueStatusSelect */
/* global SubscriptionSelect */ /* global SubscriptionSelect */
import IssuableBulkUpdateActions from './issuable_bulk_update_actions'; import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
import './milestone_select'; import './milestone_select';
import './issue_status_select'; import issueStatusSelect from './issue_status_select';
import './subscription_select'; import './subscription_select';
import './labels_select'; import './labels_select';
@ -49,7 +48,7 @@ export default class IssuableBulkUpdateSidebar {
initDropdowns() { initDropdowns() {
new LabelsSelect(); new LabelsSelect();
new MilestoneSelect(); new MilestoneSelect();
new IssueStatusSelect(); issueStatusSelect();
new SubscriptionSelect(); new SubscriptionSelect();
} }

View file

@ -6,7 +6,7 @@ import TaskList from './task_list';
import CreateMergeRequestDropdown from './create_merge_request_dropdown'; import CreateMergeRequestDropdown from './create_merge_request_dropdown';
import IssuablesHelper from './helpers/issuables_helper'; import IssuablesHelper from './helpers/issuables_helper';
class Issue { export default class Issue {
constructor() { constructor() {
if ($('a.btn-close').length) { if ($('a.btn-close').length) {
this.taskList = new TaskList({ this.taskList = new TaskList({
@ -147,5 +147,3 @@ class Issue {
}); });
} }
} }
export default Issue;

View file

@ -1,34 +1,23 @@
/* 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 issueStatusSelect() {
(function() { $('.js-issue-status').each((i, el) => {
this.IssueStatusSelect = (function() { const fieldName = $(el).data('field-name');
function IssueStatusSelect() { return $(el).glDropdown({
$('.js-issue-status').each(function(i, el) { selectable: true,
var fieldName; fieldName,
fieldName = $(el).data("field-name"); toggleLabel(selected, element, instance) {
return $(el).glDropdown({ let label = 'Author';
selectable: true, const $item = instance.dropdown.find('.is-active');
fieldName: fieldName, if ($item.length) {
toggleLabel: (function(_this) { label = $item.text();
return function(selected, el, instance) { }
var $item, label; return label;
label = 'Author'; },
$item = instance.dropdown.find('.is-active'); clicked(options) {
if ($item.length) { return options.e.preventDefault();
label = $item.text(); },
} id(obj, element) {
return label; return $(element).data('id');
}; },
})(this), });
clicked: function(options) { });
return options.e.preventDefault(); }
},
id: function(obj, el) {
return $(el).data("id");
}
});
});
}
return IssueStatusSelect;
})();
}).call(window);

View file

@ -54,11 +54,8 @@ import './gl_dropdown';
import './gl_field_error'; import './gl_field_error';
import './gl_field_errors'; import './gl_field_errors';
import './gl_form'; import './gl_form';
import './header'; import initTodoToggle from './header';
import initImporterStatus from './importer_status'; import initImporterStatus from './importer_status';
import './issuable_form';
import './issue';
import './issue_status_select';
import './labels_select'; import './labels_select';
import './layout_nav'; import './layout_nav';
import LazyLoader from './lazy_loader'; import LazyLoader from './lazy_loader';
@ -137,6 +134,7 @@ $(function () {
initBreadcrumbs(); initBreadcrumbs();
initImporterStatus(); initImporterStatus();
initTodoToggle();
// Set the default path for all cookies to GitLab's root directory // Set the default path for all cookies to GitLab's root directory
Cookies.defaults.path = gon.relative_url_root || '/'; Cookies.defaults.path = gon.relative_url_root || '/';

View file

@ -1,4 +1,4 @@
import '~/header'; import initTodoToggle from '~/header';
describe('Header', function () { describe('Header', function () {
const todosPendingCount = '.todos-count'; const todosPendingCount = '.todos-count';
@ -14,6 +14,7 @@ describe('Header', function () {
preloadFixtures(fixtureTemplate); preloadFixtures(fixtureTemplate);
beforeEach(() => { beforeEach(() => {
initTodoToggle();
loadFixtures(fixtureTemplate); loadFixtures(fixtureTemplate);
}); });