Commit 930e9f14 authored by Nick Thomas's avatar Nick Thomas

Merge remote-tracking branch 'upstream/master' into ce-to-ee-2017-08-03

parents f8b5265b 451943c0
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this */
/* global Flash */ /* global Flash */
import _ from 'underscore';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
const animationEndEventString = 'animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd'; const animationEndEventString = 'animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd';
......
import _ from 'underscore';
import '../commons/bootstrap'; import '../commons/bootstrap';
// Requires Input behavior // Requires Input behavior
...@@ -48,7 +49,9 @@ function hideOrShowHelpBlock(form) { ...@@ -48,7 +49,9 @@ function hideOrShowHelpBlock(form) {
$(() => { $(() => {
const $form = $('form.js-requires-input'); const $form = $('form.js-requires-input');
$form.requiresInput(); if ($form) {
hideOrShowHelpBlock($form); $form.requiresInput();
$('.select2.js-select-namespace').change(() => hideOrShowHelpBlock($form)); hideOrShowHelpBlock($form);
$('.select2.js-select-namespace').change(() => hideOrShowHelpBlock($form));
}
}); });
// Toggle button. Show/hide content inside parent container. // Toggle button. Show/hide content inside parent container.
// Button does not change visibility. If button has icon - it changes chevron style. // Button does not change visibility. If button has icon - it changes chevron style.
// //
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* global BoardService */ /* global BoardService */
/* global Flash */ /* global Flash */
import _ from 'underscore';
import Vue from 'vue'; import Vue from 'vue';
import VueResource from 'vue-resource'; import VueResource from 'vue-resource';
import FilteredSearchBoards from './filtered_search_boards'; import FilteredSearchBoards from './filtered_search_boards';
......
/* global ListLabel */ /* global ListLabel */
import _ from 'underscore';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
const Store = gl.issueBoards.BoardsStore; const Store = gl.issueBoards.BoardsStore;
......
/* eslint-disable comma-dangle, func-names, no-new, space-before-function-paren, one-var, /* eslint-disable comma-dangle, func-names, no-new, space-before-function-paren, one-var,
promise/catch-or-return */ promise/catch-or-return */
import _ from 'underscore';
window.gl = window.gl || {}; window.gl = window.gl || {};
window.gl.issueBoards = window.gl.issueBoards || {}; window.gl.issueBoards = window.gl.issueBoards || {};
......
/* eslint-disable comma-dangle, space-before-function-paren, one-var, no-shadow, dot-notation, max-len */ /* eslint-disable comma-dangle, space-before-function-paren, one-var, no-shadow, dot-notation, max-len */
/* global List */ /* global List */
import _ from 'underscore';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
window.gl = window.gl || {}; window.gl = window.gl || {};
......
import 'underscore';
import './polyfills'; import './polyfills';
import './jquery'; import './jquery';
import './bootstrap'; import './bootstrap';
/* eslint-disable class-methods-use-this, object-shorthand, no-unused-vars, no-use-before-define, no-new, max-len, no-restricted-syntax, guard-for-in, no-continue */ /* eslint-disable class-methods-use-this, object-shorthand, no-unused-vars, no-use-before-define, no-new, max-len, no-restricted-syntax, guard-for-in, no-continue */
import _ from 'underscore';
import './lib/utils/common_utils'; import './lib/utils/common_utils';
import { placeholderImage } from './lazy_loader'; import { placeholderImage } from './lazy_loader';
......
...@@ -90,10 +90,6 @@ import initGroupAnalytics from './init_group_analytics'; ...@@ -90,10 +90,6 @@ import initGroupAnalytics from './init_group_analytics';
(function() { (function() {
var Dispatcher; var Dispatcher;
$(function() {
return new Dispatcher();
});
Dispatcher = (function() { Dispatcher = (function() {
function Dispatcher() { function Dispatcher() {
this.initSearch(); this.initSearch();
...@@ -712,4 +708,8 @@ import initGroupAnalytics from './init_group_analytics'; ...@@ -712,4 +708,8 @@ import initGroupAnalytics from './init_group_analytics';
return Dispatcher; return Dispatcher;
})(); })();
$(function() {
new Dispatcher();
});
}).call(window); }).call(window);
/* eslint-disable func-names, space-before-function-paren, wrap-iife, max-len, one-var, no-var, one-var-declaration-per-line, no-unused-vars, camelcase, quotes, no-useless-concat, prefer-template, quote-props, comma-dangle, object-shorthand, consistent-return, prefer-arrow-callback */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, max-len, one-var, no-var, one-var-declaration-per-line, no-unused-vars, camelcase, quotes, no-useless-concat, prefer-template, quote-props, comma-dangle, object-shorthand, consistent-return, prefer-arrow-callback */
/* global Dropzone */ /* global Dropzone */
import _ from 'underscore';
import './preview_markdown'; import './preview_markdown';
window.DropzoneInput = (function() { window.DropzoneInput = (function() {
function DropzoneInput(form) { function DropzoneInput(form) {
Dropzone.autoDiscover = false;
const divHover = '<div class="div-dropzone-hover"></div>'; const divHover = '<div class="div-dropzone-hover"></div>';
const iconPaperclip = '<i class="fa fa-paperclip div-dropzone-icon"></i>'; const iconPaperclip = '<i class="fa fa-paperclip div-dropzone-icon"></i>';
const $attachButton = form.find('.button-attach-file'); const $attachButton = form.find('.button-attach-file');
......
import _ from 'underscore';
import emojiMap from 'emojis/digests.json'; import emojiMap from 'emojis/digests.json';
import emojiAliases from 'emojis/aliases.json'; import emojiAliases from 'emojis/aliases.json';
......
import _ from 'underscore';
/** /**
* Makes search request for content when user types a value in the search input. * Makes search request for content when user types a value in the search input.
* Updates the html content of the page with the received one. * Updates the html content of the page with the received one.
......
import _ from 'underscore';
import FilteredSearchContainer from './container'; import FilteredSearchContainer from './container';
class DropdownUtils { class DropdownUtils {
......
import _ from 'underscore';
import glRegexp from './lib/utils/regexp'; import glRegexp from './lib/utils/regexp';
import AjaxCache from './lib/utils/ajax_cache'; import AjaxCache from './lib/utils/ajax_cache';
......
/* eslint-disable func-names, space-before-function-paren, no-var, one-var, one-var-declaration-per-line, prefer-rest-params, max-len, vars-on-top, wrap-iife, no-unused-vars, quotes, no-shadow, no-cond-assign, prefer-arrow-callback, no-return-assign, no-else-return, camelcase, comma-dangle, no-lonely-if, guard-for-in, no-restricted-syntax, consistent-return, prefer-template, no-param-reassign, no-loop-func, no-mixed-operators */ /* eslint-disable func-names, space-before-function-paren, no-var, one-var, one-var-declaration-per-line, prefer-rest-params, max-len, vars-on-top, wrap-iife, no-unused-vars, quotes, no-shadow, no-cond-assign, prefer-arrow-callback, no-return-assign, no-else-return, camelcase, comma-dangle, no-lonely-if, guard-for-in, no-restricted-syntax, consistent-return, prefer-template, no-param-reassign, no-loop-func, no-mixed-operators */
/* global fuzzaldrinPlus */ /* global fuzzaldrinPlus */
import _ from 'underscore';
import { isObject } from './lib/utils/type_utility'; import { isObject } from './lib/utils/type_utility';
var GitLabDropdown, GitLabDropdownFilter, GitLabDropdownRemote; var GitLabDropdown, GitLabDropdownFilter, GitLabDropdownRemote;
......
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, camelcase, one-var-declaration-per-line, quotes, no-param-reassign, quote-props, comma-dangle, prefer-template, max-len, no-return-assign, no-shadow */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, one-var, camelcase, one-var-declaration-per-line, quotes, no-param-reassign, quote-props, comma-dangle, prefer-template, max-len, no-return-assign, no-shadow */
import _ from 'underscore';
import d3 from 'd3'; import d3 from 'd3';
import { ContributorsGraph, ContributorsAuthorGraph, ContributorsMasterGraph } from './stat_graph_contributors_graph'; import { ContributorsGraph, ContributorsAuthorGraph, ContributorsMasterGraph } from './stat_graph_contributors_graph';
import ContributorsStatGraphUtil from './stat_graph_contributors_util'; import ContributorsStatGraphUtil from './stat_graph_contributors_util';
......
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, max-len, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, comma-dangle, no-return-assign, prefer-arrow-callback, quotes, prefer-template, newline-per-chained-call, no-else-return, no-shadow */ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, max-len, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, comma-dangle, no-return-assign, prefer-arrow-callback, quotes, prefer-template, newline-per-chained-call, no-else-return, no-shadow */
import _ from 'underscore';
import d3 from 'd3'; import d3 from 'd3';
const extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; const extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
......
/* eslint-disable func-names, space-before-function-paren, object-shorthand, no-var, one-var, camelcase, one-var-declaration-per-line, comma-dangle, no-param-reassign, no-return-assign, quotes, prefer-arrow-callback, wrap-iife, consistent-return, no-unused-vars, max-len, no-cond-assign, no-else-return, max-len */ /* eslint-disable func-names, space-before-function-paren, object-shorthand, no-var, one-var, camelcase, one-var-declaration-per-line, comma-dangle, no-param-reassign, no-return-assign, quotes, prefer-arrow-callback, wrap-iife, consistent-return, no-unused-vars, max-len, no-cond-assign, no-else-return, max-len */
import _ from 'underscore';
export default { export default {
parse_log: function(log) { parse_log: function(log) {
......
/* eslint-disable comma-dangle, quotes, consistent-return, func-names, array-callback-return, space-before-function-paren, prefer-arrow-callback, max-len, no-unused-expressions, no-sequences, no-underscore-dangle, no-unused-vars, no-param-reassign */ /* eslint-disable comma-dangle, quotes, consistent-return, func-names, array-callback-return, space-before-function-paren, prefer-arrow-callback, max-len, no-unused-expressions, no-sequences, no-underscore-dangle, no-unused-vars, no-param-reassign */
/* global IssuableIndex */ /* global IssuableIndex */
/* global Flash */ /* global Flash */
import _ from 'underscore';
export default { export default {
init({ container, form, issues, prefixId } = {}) { init({ container, form, issues, prefixId } = {}) {
......
/* eslint-disable no-param-reassign, func-names, no-var, camelcase, no-unused-vars, object-shorthand, space-before-function-paren, no-return-assign, comma-dangle, consistent-return, one-var, one-var-declaration-per-line, quotes, prefer-template, prefer-arrow-callback, wrap-iife, max-len */ /* eslint-disable no-param-reassign, func-names, no-var, camelcase, no-unused-vars, object-shorthand, space-before-function-paren, no-return-assign, comma-dangle, consistent-return, one-var, one-var-declaration-per-line, quotes, prefer-template, prefer-arrow-callback, wrap-iife, max-len */
/* global IssuableIndex */ /* global IssuableIndex */
import _ from 'underscore';
import IssuableBulkUpdateSidebar from './issuable_bulk_update_sidebar'; import IssuableBulkUpdateSidebar from './issuable_bulk_update_sidebar';
import IssuableBulkUpdateActions from './issuable_bulk_update_actions'; import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
......
/* eslint-disable no-useless-return, func-names, space-before-function-paren, wrap-iife, no-var, no-underscore-dangle, prefer-arrow-callback, max-len, one-var, no-unused-vars, one-var-declaration-per-line, prefer-template, no-new, consistent-return, object-shorthand, comma-dangle, no-shadow, no-param-reassign, brace-style, vars-on-top, quotes, no-lonely-if, no-else-return, dot-notation, no-empty, no-return-assign, camelcase, prefer-spread */ /* eslint-disable no-useless-return, func-names, space-before-function-paren, wrap-iife, no-var, no-underscore-dangle, prefer-arrow-callback, max-len, one-var, no-unused-vars, one-var-declaration-per-line, prefer-template, no-new, consistent-return, object-shorthand, comma-dangle, no-shadow, no-param-reassign, brace-style, vars-on-top, quotes, no-lonely-if, no-else-return, dot-notation, no-empty, no-return-assign, camelcase, prefer-spread */
/* global Issuable */ /* global Issuable */
/* global ListLabel */ /* global ListLabel */
import _ from 'underscore';
import IssuableBulkUpdateActions from './issuable_bulk_update_actions'; import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
import DropdownUtils from './filtered_search/dropdown_utils'; import DropdownUtils from './filtered_search/dropdown_utils';
......
import _ from 'underscore';
(() => { (() => {
/* /*
* TODO: Make these methods more configurable (e.g. parseSeconds timePeriodContstraints, * TODO: Make these methods more configurable (e.g. parseSeconds timePeriodContstraints,
......
...@@ -36,9 +36,6 @@ import './shortcuts_find_file'; ...@@ -36,9 +36,6 @@ import './shortcuts_find_file';
import './shortcuts_issuable'; import './shortcuts_issuable';
import './shortcuts_network'; import './shortcuts_network';
// behaviors
import './behaviors/';
// templates // templates
import './templates/issuable_template_selector'; import './templates/issuable_template_selector';
import './templates/issuable_template_selectors'; import './templates/issuable_template_selectors';
...@@ -56,6 +53,9 @@ import './lib/utils/pretty_time'; ...@@ -56,6 +53,9 @@ import './lib/utils/pretty_time';
import './lib/utils/text_utility'; import './lib/utils/text_utility';
import './lib/utils/url_utility'; import './lib/utils/url_utility';
// behaviors
import './behaviors/';
// u2f // u2f
import './u2f/authenticate'; import './u2f/authenticate';
import './u2f/error'; import './u2f/error';
...@@ -86,7 +86,6 @@ import './copy_as_gfm'; ...@@ -86,7 +86,6 @@ import './copy_as_gfm';
import './copy_to_clipboard'; import './copy_to_clipboard';
import './create_label'; import './create_label';
import './diff'; import './diff';
import './dispatcher';
import './dropzone_input'; import './dropzone_input';
import './due_date_select'; import './due_date_select';
import './files_comment_button'; import './files_comment_button';
...@@ -150,6 +149,8 @@ import './subscription'; ...@@ -150,6 +149,8 @@ import './subscription';
import './subscription_select'; import './subscription_select';
import './syntax_highlight'; import './syntax_highlight';
import './dispatcher';
// EE-only scripts // EE-only scripts
import './admin_email_select'; import './admin_email_select';
import './application_settings'; import './application_settings';
...@@ -161,6 +162,8 @@ import './weight_select'; ...@@ -161,6 +162,8 @@ import './weight_select';
// eslint-disable-next-line global-require, import/no-commonjs // eslint-disable-next-line global-require, import/no-commonjs
if (process.env.NODE_ENV !== 'production') require('./test_utils/'); if (process.env.NODE_ENV !== 'production') require('./test_utils/');
Dropzone.autoDiscover = false;
document.addEventListener('beforeunload', function () { document.addEventListener('beforeunload', function () {
// Unbind scroll events // Unbind scroll events
$(document).off('scroll'); $(document).off('scroll');
......
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, no-underscore-dangle, prefer-arrow-callback, max-len, one-var, one-var-declaration-per-line, no-unused-vars, object-shorthand, comma-dangle, no-else-return, no-self-compare, consistent-return, no-param-reassign, no-shadow */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, no-underscore-dangle, prefer-arrow-callback, max-len, one-var, one-var-declaration-per-line, no-unused-vars, object-shorthand, comma-dangle, no-else-return, no-self-compare, consistent-return, no-param-reassign, no-shadow */
/* global Issuable */ /* global Issuable */
/* global ListMilestone */ /* global ListMilestone */
import _ from 'underscore';
(function() { (function() {
this.MilestoneSelect = (function() { this.MilestoneSelect = (function() {
......
...@@ -11,6 +11,7 @@ newline-per-chained-call, no-useless-escape, class-methods-use-this */ ...@@ -11,6 +11,7 @@ newline-per-chained-call, no-useless-escape, class-methods-use-this */
/* global mrRefreshWidgetUrl */ /* global mrRefreshWidgetUrl */
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import autosize from 'vendor/autosize'; import autosize from 'vendor/autosize';
import Dropzone from 'dropzone'; import Dropzone from 'dropzone';
......
<script> <script>
import _ from 'underscore';
export default { export default {
props: { props: {
initialCronInterval: { initialCronInterval: {
......
/* eslint-disable no-useless-escape, max-len, quotes, no-var, no-underscore-dangle, func-names, space-before-function-paren, no-unused-vars, no-return-assign, object-shorthand, one-var, one-var-declaration-per-line, comma-dangle, consistent-return, class-methods-use-this, new-parens */ /* eslint-disable no-useless-escape, max-len, quotes, no-var, no-underscore-dangle, func-names, space-before-function-paren, no-unused-vars, no-return-assign, object-shorthand, one-var, one-var-declaration-per-line, comma-dangle, consistent-return, class-methods-use-this, new-parens */
import _ from 'underscore';
import 'cropper'; import 'vendor/cropper';
((global) => { ((global) => {
// Matches everything but the file name // Matches everything but the file name
......
export default function setupProjectEdit() { export default function setupProjectEdit() {
const $transferForm = $('.js-project-transfer-form'); const $transferForm = $('.js-project-transfer-form');
const $selectNamespace = $transferForm.find('.select2'); const $selectNamespace = $transferForm.find('select.select2');
$selectNamespace.on('change', () => { $selectNamespace.on('change', () => {
$transferForm.find(':submit').prop('disabled', !$selectNamespace.val()); $transferForm.find(':submit').prop('disabled', !$selectNamespace.val());
......
import _ from 'underscore';
export default class ProtectedBranchDropdown { export default class ProtectedBranchDropdown {
/** /**
* @param {Object} options containing * @param {Object} options containing
......
import _ from 'underscore';
export default class ProtectedTagDropdown { export default class ProtectedTagDropdown {
/** /**
* @param {Object} options containing * @param {Object} options containing
......
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-unused-vars, consistent-return, one-var, one-var-declaration-per-line, quotes, prefer-template, object-shorthand, comma-dangle, no-else-return, no-param-reassign, max-len */ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-unused-vars, consistent-return, one-var, one-var-declaration-per-line, quotes, prefer-template, object-shorthand, comma-dangle, no-else-return, no-param-reassign, max-len */
import _ from 'underscore';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import SidebarHeightManager from './sidebar_height_manager'; import SidebarHeightManager from './sidebar_height_manager';
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
/* global ShortcutsNavigation */ /* global ShortcutsNavigation */
/* global sidebar */ /* global sidebar */
import _ from 'underscore';
import 'mousetrap'; import 'mousetrap';
import './shortcuts_navigation'; import './shortcuts_navigation';
...@@ -58,7 +59,7 @@ import './shortcuts_navigation'; ...@@ -58,7 +59,7 @@ import './shortcuts_navigation';
}); });
// If replyField already has some content, add a newline before our quote // If replyField already has some content, add a newline before our quote
separator = replyField.val().trim() !== "" && "\n\n" || ''; separator = replyField.val().trim() !== "" && "\n\n" || '';
replyField.val(function(_, current) { replyField.val(function(a, current) {
return current + separator + quote.join('') + "\n"; return current + separator + quote.join('') + "\n";
}); });
......
import _ from 'underscore';
import '~/smart_interval'; import '~/smart_interval';
import timeTracker from './time_tracker'; import timeTracker from './time_tracker';
......
import _ from 'underscore';
export default { export default {
init() { init() {
if (!this.initialized) { if (!this.initialized) {
...@@ -30,4 +32,3 @@ export default { ...@@ -30,4 +32,3 @@ export default {
} }
}, },
}; };
...@@ -52,6 +52,7 @@ export default class Todos { ...@@ -52,6 +52,7 @@ export default class Todos {
} }
updateRowStateClicked(e) { updateRowStateClicked(e) {
e.stopPropagation();
e.preventDefault(); e.preventDefault();
const target = e.target; const target = e.target;
...@@ -92,6 +93,7 @@ export default class Todos { ...@@ -92,6 +93,7 @@ export default class Todos {
} }
updateAllStateClicked(e) { updateAllStateClicked(e) {
e.stopPropagation();
e.preventDefault(); e.preventDefault();
const target = e.currentTarget; const target = e.currentTarget;
...@@ -142,6 +144,7 @@ export default class Todos { ...@@ -142,6 +144,7 @@ export default class Todos {
if (gl.utils.isMetaClick(e)) { if (gl.utils.isMetaClick(e)) {
const windowTarget = '_blank'; const windowTarget = '_blank';
const selected = e.target; const selected = e.target;
e.stopPropagation();
e.preventDefault(); e.preventDefault();
if (selected.tagName === 'IMG') { if (selected.tagName === 'IMG') {
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
/* global U2FError */ /* global U2FError */
/* global U2FUtil */ /* global U2FUtil */
import _ from 'underscore';
// Authenticate U2F (universal 2nd factor) devices for users to authenticate with. // Authenticate U2F (universal 2nd factor) devices for users to authenticate with.
// //
// State Flow #1: setup -> in_progress -> authenticated -> POST to server // State Flow #1: setup -> in_progress -> authenticated -> POST to server
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
/* global U2FError */ /* global U2FError */
/* global U2FUtil */ /* global U2FUtil */
import _ from 'underscore';
// Register U2F (universal 2nd factor) devices for users to authenticate with. // Register U2F (universal 2nd factor) devices for users to authenticate with.
// //
// State Flow #1: setup -> in_progress -> registered -> POST to server // State Flow #1: setup -> in_progress -> registered -> POST to server
......
/* eslint-disable comma-dangle, consistent-return, class-methods-use-this, arrow-parens, no-param-reassign, max-len */ /* eslint-disable comma-dangle, consistent-return, class-methods-use-this, arrow-parens, no-param-reassign, max-len */
import _ from 'underscore';
const debounceTimeoutDuration = 1000; const debounceTimeoutDuration = 1000;
const invalidInputClass = 'gl-field-error-outline'; const invalidInputClass = 'gl-field-error-outline';
const successInputClass = 'gl-field-success-outline'; const successInputClass = 'gl-field-success-outline';
......
import _ from 'underscore';
import d3 from 'd3'; import d3 from 'd3';
const LOADING_HTML = ` const LOADING_HTML = `
......
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, prefer-rest-params, wrap-iife, quotes, max-len, one-var-declaration-per-line, vars-on-top, prefer-arrow-callback, consistent-return, comma-dangle, object-shorthand, no-shadow, no-unused-vars, no-else-return, no-self-compare, prefer-template, no-unused-expressions, no-lonely-if, yoda, prefer-spread, no-void, camelcase, no-param-reassign */ /* eslint-disable func-names, space-before-function-paren, one-var, no-var, prefer-rest-params, wrap-iife, quotes, max-len, one-var-declaration-per-line, vars-on-top, prefer-arrow-callback, consistent-return, comma-dangle, object-shorthand, no-shadow, no-unused-vars, no-else-return, no-self-compare, prefer-template, no-unused-expressions, no-lonely-if, yoda, prefer-spread, no-void, camelcase, no-param-reassign */
/* global Issuable */ /* global Issuable */
/* global emitSidebarEvent */ /* global emitSidebarEvent */
import _ from 'underscore';
// TODO: remove eventHub hack after code splitting refactor // TODO: remove eventHub hack after code splitting refactor
window.emitSidebarEvent = window.emitSidebarEvent || $.noop; window.emitSidebarEvent = window.emitSidebarEvent || $.noop;
......
module DeferScriptTagHelper
# Override the default ActionView `javascript_include_tag` helper to support page specific deferred loading
def javascript_include_tag(*sources)
super(*sources, defer: true)
end
end
-# haml-lint:disable InlineJavaScript
:javascript :javascript
jQuery(document).ready(function() { window.onload = function() {
javascript:(function(){var s=document.createElement("script");s.onload=function(){bootlint.showLintReportForCurrentDocument([], {hasProblems: false, problemFree: false});};s.src="https://maxcdn.bootstrapcdn.com/bootlint/latest/bootlint.min.js";document.body.appendChild(s)})(); var s=document.createElement("script");s.onload=function(){bootlint.showLintReportForCurrentDocument([], {hasProblems: false, problemFree: false});};s.src="https://maxcdn.bootstrapcdn.com/bootlint/latest/bootlint.min.js";document.body.appendChild(s);
}); }
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
- if project - if project
-# haml-lint:disable InlineJavaScript -# haml-lint:disable InlineJavaScript
:javascript :javascript
gl = window.gl || {};
gl.GfmAutoComplete = gl.GfmAutoComplete || {}; gl.GfmAutoComplete = gl.GfmAutoComplete || {};
gl.GfmAutoComplete.dataSources = { gl.GfmAutoComplete.dataSources = {
members: "#{members_project_autocomplete_sources_path(project, type: noteable_type, type_id: params[:id])}", members: "#{members_project_autocomplete_sources_path(project, type: noteable_type, type_id: params[:id])}",
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
-# haml-lint:disable InlineJavaScript -# haml-lint:disable InlineJavaScript
:javascript :javascript
window.gl = window.gl || {};
window.gl.mrWidgetData = #{serialize_issuable(@merge_request)} window.gl.mrWidgetData = #{serialize_issuable(@merge_request)}
// Append static, server-generated data not included in merge request entity (EE-Only) // Append static, server-generated data not included in merge request entity (EE-Only)
......
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'optparse' require 'optparse'
require_relative '../lib/gitlab/sidekiq_config'
require_relative '../lib/gitlab/sidekiq_cluster' require_relative '../lib/gitlab/sidekiq_cluster'
require_relative '../lib/gitlab/sidekiq_cluster/cli' require_relative '../lib/gitlab/sidekiq_cluster/cli'
......
---
title: Allow excluding sidekiq queues from execution in sidekiq-cluster
merge_request: 2571
author:
...@@ -68,14 +68,12 @@ end ...@@ -68,14 +68,12 @@ end
# The Sidekiq client API always adds the queue to the Sidekiq queue # The Sidekiq client API always adds the queue to the Sidekiq queue
# list, but mail_room and gitlab-shell do not. This is only necessary # list, but mail_room and gitlab-shell do not. This is only necessary
# for monitoring. # for monitoring.
config = YAML.load_file(Rails.root.join('config', 'sidekiq_queues.yml').to_s) queues = Gitlab::SidekiqConfig.queues
begin begin
Sidekiq.redis do |conn| Sidekiq.redis do |conn|
conn.pipelined do conn.pipelined do
config[:queues].each do |queue| queues.each { |queue| conn.sadd('queues', queue) }
conn.sadd('queues', queue[0])
end
end end
end end
rescue Redis::BaseError, SocketError, Errno::ENOENT, Errno::EADDRNOTAVAIL, Errno::EAFNOSUPPORT, Errno::ECONNRESET, Errno::ECONNREFUSED rescue Redis::BaseError, SocketError, Errno::ENOENT, Errno::EADDRNOTAVAIL, Errno::EAFNOSUPPORT, Errno::ECONNRESET, Errno::ECONNREFUSED
......
...@@ -87,3 +87,21 @@ command, and not the PID(s) of the started Sidekiq processes. ...@@ -87,3 +87,21 @@ command, and not the PID(s) of the started Sidekiq processes.
The Rails environment can be set by passing the `--environment` flag to the The Rails environment can be set by passing the `--environment` flag to the
`sidekiq-cluster` command, or by setting `RAILS_ENV` to a non-empty value. The `sidekiq-cluster` command, or by setting `RAILS_ENV` to a non-empty value. The
default value is "development". default value is "development".
## All Queues With Exceptions
You're able to run all queues in `sidekiq_queues.yml` file on a single or
multiple processes with exceptions using the `--negate` flag.
For example, say you want to run a single process for all queues,
except "process_commit" and "post_receive". You can do so by executing:
```bash
sidekiq-cluster process_commit,post_receive --negate
```
For multiple processes of all queues (except "process_commit" and "post_receive"):
```bash
sidekiq-cluster process_commit,post_receive process_commit,post_receive --negate
```
...@@ -30,7 +30,14 @@ module Gitlab ...@@ -30,7 +30,14 @@ module Gitlab
option_parser.parse!(argv) option_parser.parse!(argv)
queues = SidekiqCluster.parse_queues(argv) parsed_queues = SidekiqCluster.parse_queues(argv)
queues =
if @negate_queues
parsed_queues.map { |queues| SidekiqConfig.queues(@rails_path, except: queues) }
else
parsed_queues
end
@logger.info("Starting cluster with #{queues.length} processes") @logger.info("Starting cluster with #{queues.length} processes")
...@@ -93,6 +100,10 @@ module Gitlab ...@@ -93,6 +100,10 @@ module Gitlab
@rails_path = path @rails_path = path
end end
opt.on('-n', '--negate', 'Run workers for all queues in sidekiq_queues.yml except the given ones') do
@negate_queues = true
end
opt.on('-i', '--interval INT', 'The number of seconds to wait between worker checks') do |int| opt.on('-i', '--interval INT', 'The number of seconds to wait between worker checks') do |int|
@interval = int.to_i @interval = int.to_i
end end
......
require 'yaml'
module Gitlab
module SidekiqConfig
def self.queues(rails_path = Rails.root.to_s, except: [])
queues_file_path = File.join(rails_path, 'config', 'sidekiq_queues.yml')
@queues_file = {}
@queues_file[queues_file_path] ||= YAML.load_file(queues_file_path)
@queues_file[queues_file_path].fetch(:queues).map { |queue, _| queue } - except
end
end
end
# coding: utf-8
require 'spec_helper'
describe DeferScriptTagHelper do
describe 'script tag' do
script_url = 'test.js'
it 'returns an script tag with defer=true' do
expect(javascript_include_tag(script_url).to_s)
.to eq "<script src=\"/javascripts/#{script_url}\" defer=\"defer\"></script>"
end
end
end
...@@ -19,6 +19,20 @@ describe Gitlab::SidekiqCluster::CLI do ...@@ -19,6 +19,20 @@ describe Gitlab::SidekiqCluster::CLI do
cli.run(%w(foo)) cli.run(%w(foo))
end end
context 'with --negate flag' do
it 'starts Sidekiq workers for all queues on sidekiq_queues.yml except the ones on argv' do
expect(Gitlab::SidekiqConfig).to receive(:queues).and_return(['baz'])
expect(Gitlab::SidekiqCluster).to receive(:start)
.with([['baz']], 'test', Dir.pwd)
.and_return([])
expect(cli).to receive(:write_pid)
expect(cli).to receive(:trap_signals)
expect(cli).to receive(:start_loop)
cli.run(%w(foo -n))
end
end
end end
end end
......
require 'rails_helper'
describe Gitlab::SidekiqConfig do
describe '.queues' do
let(:queues_file_path) { Rails.root.join('config', 'sidekiq_queues.yml') }
context 'without except argument' do
it 'returns all queues defined on config/sidekiq_queues.yml file' do
expected_queues = YAML.load_file(queues_file_path)[:queues].map { |queue, _| queue }
expect(described_class.queues).to eq(expected_queues)
end
end
context 'with except argument' do
it 'returns queues on config/sidekiq_queues.yml filtering out excluded ones' do
expected_queues =
YAML.load_file(queues_file_path)[:queues].map { |queue, _| queue } - ['webhook']
expect(described_class.queues(except: ['webhook'])).to eq(expected_queues)
end
end
end
end
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