diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-15 09:06:30 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-15 09:06:30 +0000 |
commit | e24153b0cb080b1b25076f8fd358b4273848f2e2 (patch) | |
tree | b3fc6d552241905fa927db14f8920c4809e74a6f /app | |
parent | 3fe34368770022c88fd89c8df58b39bf0789e646 (diff) | |
download | gitlab-ce-e24153b0cb080b1b25076f8fd358b4273848f2e2.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/lib/utils/notify.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/network/branch_graph.js | 112 | ||||
-rw-r--r-- | app/assets/javascripts/new_branch_form.js | 28 |
3 files changed, 65 insertions, 83 deletions
diff --git a/app/assets/javascripts/lib/utils/notify.js b/app/assets/javascripts/lib/utils/notify.js index cd509a13193..8db08099b3f 100644 --- a/app/assets/javascripts/lib/utils/notify.js +++ b/app/assets/javascripts/lib/utils/notify.js @@ -1,8 +1,7 @@ -/* eslint-disable no-var, consistent-return, no-return-assign */ +/* eslint-disable consistent-return, no-return-assign */ function notificationGranted(message, opts, onclick) { - var notification; - notification = new Notification(message, opts); + const notification = new Notification(message, opts); setTimeout( () => // Hide the notification after X amount of seconds @@ -21,8 +20,7 @@ function notifyPermissions() { } function notifyMe(message, body, icon, onclick) { - var opts; - opts = { + const opts = { body, icon, }; diff --git a/app/assets/javascripts/network/branch_graph.js b/app/assets/javascripts/network/branch_graph.js index a0ba2193d90..8173e23769a 100644 --- a/app/assets/javascripts/network/branch_graph.js +++ b/app/assets/javascripts/network/branch_graph.js @@ -1,12 +1,12 @@ -/* eslint-disable func-names, no-var, one-var, no-loop-func, consistent-return, camelcase */ +/* eslint-disable func-names, no-var, one-var, consistent-return, camelcase */ import $ from 'jquery'; import { __ } from '../locale'; import axios from '../lib/utils/axios_utils'; import Raphael from './raphael'; -export default (function() { - function BranchGraph(element1, options1) { +export default class BranchGraph { + constructor(element1, options1) { this.element = element1; this.options = options1; this.scrollTop = this.scrollTop.bind(this); @@ -28,7 +28,7 @@ export default (function() { this.load(); } - BranchGraph.prototype.load = function() { + load() { axios .get(this.options.url) .then(({ data }) => { @@ -37,9 +37,9 @@ export default (function() { this.buildGraph(); }) .catch(() => __('Error fetching network graph.')); - }; + } - BranchGraph.prototype.prepareData = function(days, commits) { + prepareData(days, commits) { var c, ch, cw, j, len, ref; this.days = days; this.commits = commits; @@ -61,34 +61,30 @@ export default (function() { this.markCommit(c); } return this.collectColors(); - }; + } - BranchGraph.prototype.collectParents = function() { + collectParents() { var c, j, len, p, ref, results; + var l, len1, ref1, results1; ref = this.commits; results = []; for (j = 0, len = ref.length; j < len; j += 1) { c = ref[j]; this.mtime = Math.max(this.mtime, c.time); this.mspace = Math.max(this.mspace, c.space); - results.push( - function() { - var l, len1, ref1, results1; - ref1 = c.parents; - results1 = []; - for (l = 0, len1 = ref1.length; l < len1; l += 1) { - p = ref1[l]; - this.parents[p[0]] = true; - results1.push((this.mspace = Math.max(this.mspace, p[1]))); - } - return results1; - }.call(this), - ); + ref1 = c.parents; + results1 = []; + for (l = 0, len1 = ref1.length; l < len1; l += 1) { + p = ref1[l]; + this.parents[p[0]] = true; + results1.push((this.mspace = Math.max(this.mspace, p[1]))); + } + results.push(results1); } return results; - }; + } - BranchGraph.prototype.collectColors = function() { + collectColors() { var k, results; k = 0; results = []; @@ -100,9 +96,9 @@ export default (function() { results.push((k += 1)); } return results; - }; + } - BranchGraph.prototype.buildGraph = function() { + buildGraph() { var cuday, cumonth, day, len, mm, ref; const { r } = this; cuday = 0; @@ -138,9 +134,9 @@ export default (function() { } this.renderPartialGraph(); return this.bindEvents(); - }; + } - BranchGraph.prototype.renderPartialGraph = function() { + renderPartialGraph() { var commit, end, i, isGraphEdge, start, x, y; start = Math.floor((this.element.scrollTop() - this.offsetY) / this.unitTime) - 10; if (start < 0) { @@ -170,49 +166,43 @@ export default (function() { } return this.top.toFront(); } - }; + } - BranchGraph.prototype.bindEvents = function() { + bindEvents() { const { element } = this; - return $(element).scroll( - (function(_this) { - return function() { - return _this.renderPartialGraph(); - }; - })(this), - ); - }; + return $(element).scroll(() => this.renderPartialGraph()); + } - BranchGraph.prototype.scrollDown = function() { + scrollDown() { this.element.scrollTop(this.element.scrollTop() + 50); return this.renderPartialGraph(); - }; + } - BranchGraph.prototype.scrollUp = function() { + scrollUp() { this.element.scrollTop(this.element.scrollTop() - 50); return this.renderPartialGraph(); - }; + } - BranchGraph.prototype.scrollLeft = function() { + scrollLeft() { this.element.scrollLeft(this.element.scrollLeft() - 50); return this.renderPartialGraph(); - }; + } - BranchGraph.prototype.scrollRight = function() { + scrollRight() { this.element.scrollLeft(this.element.scrollLeft() + 50); return this.renderPartialGraph(); - }; + } - BranchGraph.prototype.scrollBottom = function() { + scrollBottom() { return this.element.scrollTop(this.element.find('svg').height()); - }; + } - BranchGraph.prototype.scrollTop = function() { + scrollTop() { return this.element.scrollTop(0); - }; + } - BranchGraph.prototype.appendLabel = function(x, y, commit) { + appendLabel(x, y, commit) { var label, rect, shortrefs, text, textbox; if (!commit.refs) { @@ -248,9 +238,9 @@ export default (function() { label.transform(['t', -rect.getBBox().width - 15, 0]); // Set text to front return text.toFront(); - }; + } - BranchGraph.prototype.appendAnchor = function(x, y, commit) { + appendAnchor(x, y, commit) { const { r, top, options } = this; const anchor = r .circle(x, y, 10) @@ -270,9 +260,9 @@ export default (function() { }, ); return top.push(anchor); - }; + } - BranchGraph.prototype.drawDot = function(x, y, commit) { + drawDot(x, y, commit) { const { r } = this; r.circle(x, y, 3).attr({ fill: this.colors[commit.space], @@ -293,9 +283,9 @@ export default (function() { 'text-anchor': 'start', font: '14px Monaco, monospace', }); - }; + } - BranchGraph.prototype.drawLines = function(x, y, commit) { + drawLines(x, y, commit) { var arrow, color, i, len, offset, parent, parentCommit, parentX1, parentX2, parentY, route; const { r } = this; const ref = commit.parents; @@ -344,9 +334,9 @@ export default (function() { ); } return results; - }; + } - BranchGraph.prototype.markCommit = function(commit) { + markCommit(commit) { if (commit.id === this.options.commit_id) { const { r } = this; const x = this.offsetX + this.unitSpace * (this.mspace - commit.space); @@ -359,7 +349,5 @@ export default (function() { // Displayed in the center return this.element.scrollTop(y - this.graphHeight / 2); } - }; - - return BranchGraph; -})(); + } +} diff --git a/app/assets/javascripts/new_branch_form.js b/app/assets/javascripts/new_branch_form.js index 9f9db21d65b..52361e963bc 100644 --- a/app/assets/javascripts/new_branch_form.js +++ b/app/assets/javascripts/new_branch_form.js @@ -1,4 +1,4 @@ -/* eslint-disable func-names, no-var, one-var, consistent-return, no-return-assign, no-shadow, no-else-return, @gitlab/i18n/no-non-i18n-strings */ +/* eslint-disable func-names, consistent-return, no-return-assign, no-else-return, @gitlab/i18n/no-non-i18n-strings */ import $ from 'jquery'; import RefSelectDropdown from './ref_select_dropdown'; @@ -26,23 +26,22 @@ export default class NewBranchForm { } setupRestrictions() { - var endsWith, invalid, single, startsWith; - startsWith = { + const startsWith = { pattern: /^(\/|\.)/g, prefix: "can't start with", conjunction: 'or', }; - endsWith = { + const endsWith = { pattern: /(\/|\.|\.lock)$/g, prefix: "can't end in", conjunction: 'or', }; - invalid = { + const invalid = { pattern: /(\s|~|\^|:|\?|\*|\[|\\|\.\.|@\{|\/{2,}){1}/g, prefix: "can't contain", conjunction: ', ', }; - single = { + const single = { pattern: /^@+$/g, prefix: "can't be", conjunction: 'or', @@ -51,19 +50,17 @@ export default class NewBranchForm { } validate() { - var errorMessage, errors, formatter, unique, validator; const { indexOf } = []; this.branchNameError.empty(); - unique = function(values, value) { + const unique = function(values, value) { if (indexOf.call(values, value) === -1) { values.push(value); } return values; }; - formatter = function(values, restriction) { - var formatted; - formatted = values.map(value => { + const formatter = function(values, restriction) { + const formatted = values.map(value => { switch (false) { case !/\s/.test(value): return 'spaces'; @@ -75,10 +72,9 @@ export default class NewBranchForm { }); return `${restriction.prefix} ${formatted.join(restriction.conjunction)}`; }; - validator = (function(_this) { + const validator = (function(_this) { return function(errors, restriction) { - var matched; - matched = _this.name.val().match(restriction.pattern); + const matched = _this.name.val().match(restriction.pattern); if (matched) { return errors.concat(formatter(matched.reduce(unique, []), restriction)); } else { @@ -86,9 +82,9 @@ export default class NewBranchForm { } }; })(this); - errors = this.restrictions.reduce(validator, []); + const errors = this.restrictions.reduce(validator, []); if (errors.length > 0) { - errorMessage = $('<span/>').text(errors.join(', ')); + const errorMessage = $('<span/>').text(errors.join(', ')); return this.branchNameError.append(errorMessage); } } |