Commit 7629c9ec authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'remove-iife-cycle-analytics-bundle' into 'master'

Remove IIFEs from files in cycle_analytics_bundle.js

See merge request !10613
parents 1f7631e3 e1e6e946
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
import Vue from 'vue'; import Vue from 'vue';
((global) => { const global = window.gl || (window.gl = {});
global.cycleAnalytics = global.cycleAnalytics || {}; global.cycleAnalytics = global.cycleAnalytics || {};
global.cycleAnalytics.StageCodeComponent = Vue.extend({ global.cycleAnalytics.StageCodeComponent = Vue.extend({
props: { props: {
items: Array, items: Array,
stage: Object, stage: Object,
...@@ -43,5 +43,4 @@ import Vue from 'vue'; ...@@ -43,5 +43,4 @@ import Vue from 'vue';
</ul> </ul>
</div> </div>
`, `,
}); });
})(window.gl || (window.gl = {}));
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
import Vue from 'vue'; import Vue from 'vue';
((global) => { const global = window.gl || (window.gl = {});
global.cycleAnalytics = global.cycleAnalytics || {}; global.cycleAnalytics = global.cycleAnalytics || {};
global.cycleAnalytics.StageIssueComponent = Vue.extend({ global.cycleAnalytics.StageIssueComponent = Vue.extend({
props: { props: {
items: Array, items: Array,
stage: Object, stage: Object,
...@@ -45,5 +45,4 @@ import Vue from 'vue'; ...@@ -45,5 +45,4 @@ import Vue from 'vue';
</ul> </ul>
</div> </div>
`, `,
}); });
})(window.gl || (window.gl = {}));
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
import Vue from 'vue'; import Vue from 'vue';
import iconCommit from '../svg/icon_commit.svg'; import iconCommit from '../svg/icon_commit.svg';
((global) => { const global = window.gl || (window.gl = {});
global.cycleAnalytics = global.cycleAnalytics || {}; global.cycleAnalytics = global.cycleAnalytics || {};
global.cycleAnalytics.StagePlanComponent = Vue.extend({ global.cycleAnalytics.StagePlanComponent = Vue.extend({
props: { props: {
items: Array, items: Array,
stage: Object, stage: Object,
...@@ -47,5 +47,4 @@ import iconCommit from '../svg/icon_commit.svg'; ...@@ -47,5 +47,4 @@ import iconCommit from '../svg/icon_commit.svg';
</ul> </ul>
</div> </div>
`, `,
}); });
})(window.gl || (window.gl = {}));
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
import Vue from 'vue'; import Vue from 'vue';
((global) => { const global = window.gl || (window.gl = {});
global.cycleAnalytics = global.cycleAnalytics || {}; global.cycleAnalytics = global.cycleAnalytics || {};
global.cycleAnalytics.StageProductionComponent = Vue.extend({ global.cycleAnalytics.StageProductionComponent = Vue.extend({
props: { props: {
items: Array, items: Array,
stage: Object, stage: Object,
...@@ -45,5 +45,4 @@ import Vue from 'vue'; ...@@ -45,5 +45,4 @@ import Vue from 'vue';
</ul> </ul>
</div> </div>
`, `,
}); });
})(window.gl || (window.gl = {}));
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
import Vue from 'vue'; import Vue from 'vue';
((global) => { const global = window.gl || (window.gl = {});
global.cycleAnalytics = global.cycleAnalytics || {}; global.cycleAnalytics = global.cycleAnalytics || {};
global.cycleAnalytics.StageReviewComponent = Vue.extend({ global.cycleAnalytics.StageReviewComponent = Vue.extend({
props: { props: {
items: Array, items: Array,
stage: Object, stage: Object,
...@@ -55,5 +55,4 @@ import Vue from 'vue'; ...@@ -55,5 +55,4 @@ import Vue from 'vue';
</ul> </ul>
</div> </div>
`, `,
}); });
})(window.gl || (window.gl = {}));
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
import Vue from 'vue'; import Vue from 'vue';
import iconBranch from '../svg/icon_branch.svg'; import iconBranch from '../svg/icon_branch.svg';
((global) => { const global = window.gl || (window.gl = {});
global.cycleAnalytics = global.cycleAnalytics || {}; global.cycleAnalytics = global.cycleAnalytics || {};
global.cycleAnalytics.StageStagingComponent = Vue.extend({ global.cycleAnalytics.StageStagingComponent = Vue.extend({
props: { props: {
items: Array, items: Array,
stage: Object, stage: Object,
...@@ -45,5 +45,4 @@ import iconBranch from '../svg/icon_branch.svg'; ...@@ -45,5 +45,4 @@ import iconBranch from '../svg/icon_branch.svg';
</ul> </ul>
</div> </div>
`, `,
}); });
})(window.gl || (window.gl = {}));
...@@ -3,10 +3,10 @@ import Vue from 'vue'; ...@@ -3,10 +3,10 @@ import Vue from 'vue';
import iconBuildStatus from '../svg/icon_build_status.svg'; import iconBuildStatus from '../svg/icon_build_status.svg';
import iconBranch from '../svg/icon_branch.svg'; import iconBranch from '../svg/icon_branch.svg';
((global) => { const global = window.gl || (window.gl = {});
global.cycleAnalytics = global.cycleAnalytics || {}; global.cycleAnalytics = global.cycleAnalytics || {};
global.cycleAnalytics.StageTestComponent = Vue.extend({ global.cycleAnalytics.StageTestComponent = Vue.extend({
props: { props: {
items: Array, items: Array,
stage: Object, stage: Object,
...@@ -46,5 +46,4 @@ import iconBranch from '../svg/icon_branch.svg'; ...@@ -46,5 +46,4 @@ import iconBranch from '../svg/icon_branch.svg';
</ul> </ul>
</div> </div>
`, `,
}); });
})(window.gl || (window.gl = {}));
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
import Vue from 'vue'; import Vue from 'vue';
((global) => { const global = window.gl || (window.gl = {});
global.cycleAnalytics = global.cycleAnalytics || {}; global.cycleAnalytics = global.cycleAnalytics || {};
global.cycleAnalytics.TotalTimeComponent = Vue.extend({ global.cycleAnalytics.TotalTimeComponent = Vue.extend({
props: { props: {
time: Object, time: Object,
}, },
...@@ -22,5 +22,4 @@ import Vue from 'vue'; ...@@ -22,5 +22,4 @@ import Vue from 'vue';
</template> </template>
</span> </span>
`, `,
}); });
})(window.gl || (window.gl = {}));
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
((global) => {
global.cycleAnalytics = global.cycleAnalytics || {};
class CycleAnalyticsService { const global = window.gl || (window.gl = {});
global.cycleAnalytics = global.cycleAnalytics || {};
class CycleAnalyticsService {
constructor(options) { constructor(options) {
this.requestPath = options.requestPath; this.requestPath = options.requestPath;
} }
...@@ -35,7 +36,6 @@ ...@@ -35,7 +36,6 @@
}, },
}); });
} }
} }
global.cycleAnalytics.CycleAnalyticsService = CycleAnalyticsService; global.cycleAnalytics.CycleAnalyticsService = CycleAnalyticsService;
})(window.gl || (window.gl = {}));
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
require('../lib/utils/text_utility'); require('../lib/utils/text_utility');
const DEFAULT_EVENT_OBJECTS = require('./default_event_objects'); const DEFAULT_EVENT_OBJECTS = require('./default_event_objects');
((global) => { const global = window.gl || (window.gl = {});
global.cycleAnalytics = global.cycleAnalytics || {}; global.cycleAnalytics = global.cycleAnalytics || {};
const EMPTY_STAGE_TEXTS = { const EMPTY_STAGE_TEXTS = {
issue: 'The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.', issue: 'The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage.',
plan: 'The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.', plan: 'The planning stage shows the time from the previous step to pushing your first commit. This time will be added automatically once you push your first commit.',
code: 'The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.', code: 'The coding stage shows the time from the first commit to creating the merge request. The data will automatically be added here once you create your first merge request.',
...@@ -14,9 +14,9 @@ const DEFAULT_EVENT_OBJECTS = require('./default_event_objects'); ...@@ -14,9 +14,9 @@ const DEFAULT_EVENT_OBJECTS = require('./default_event_objects');
review: 'The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.', review: 'The review stage shows the time from creating the merge request to merging it. The data will automatically be added after you merge your first merge request.',
staging: 'The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.', staging: 'The staging stage shows the time between merging the MR and deploying code to the production environment. The data will be automatically added once you deploy to production for the first time.',
production: 'The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.', production: 'The production stage shows the total time it takes between creating an issue and deploying the code to production. The data will be automatically added once you have completed the full idea to production cycle.',
}; };
global.cycleAnalytics.CycleAnalyticsStore = { global.cycleAnalytics.CycleAnalyticsStore = {
state: { state: {
summary: '', summary: '',
stats: '', stats: '',
...@@ -100,5 +100,4 @@ const DEFAULT_EVENT_OBJECTS = require('./default_event_objects'); ...@@ -100,5 +100,4 @@ const DEFAULT_EVENT_OBJECTS = require('./default_event_objects');
currentActiveStage() { currentActiveStage() {
return this.state.stages.find(stage => stage.active); return this.state.stages.find(stage => stage.active);
}, },
}; };
})(window.gl || (window.gl = {}));
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, no-param-reassign, no-cond-assign, quotes, one-var, one-var-declaration-per-line, operator-assignment, no-else-return, prefer-template, prefer-arrow-callback, no-empty, max-len, consistent-return, no-unused-vars, no-return-assign, max-len */ /* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, no-param-reassign, no-cond-assign, quotes, one-var, one-var-declaration-per-line, operator-assignment, no-else-return, prefer-template, prefer-arrow-callback, no-empty, max-len, consistent-return, no-unused-vars, no-return-assign, max-len, vars-on-top */
require('vendor/latinise'); require('vendor/latinise');
(function() { var base;
(function(w) { var w = window;
var base; if (w.gl == null) {
if (w.gl == null) {
w.gl = {}; w.gl = {};
} }
if ((base = w.gl).text == null) { if ((base = w.gl).text == null) {
base.text = {}; base.text = {};
} }
gl.text.addDelimiter = function(text) { gl.text.addDelimiter = function(text) {
return text ? text.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : text; return text ? text.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : text;
}; };
gl.text.highCountTrim = function(count) { gl.text.highCountTrim = function(count) {
return count > 99 ? '99+' : count; return count > 99 ? '99+' : count;
}; };
gl.text.randomString = function() { gl.text.randomString = function() {
return Math.random().toString(36).substring(7); return Math.random().toString(36).substring(7);
}; };
gl.text.replaceRange = function(s, start, end, substitute) { gl.text.replaceRange = function(s, start, end, substitute) {
return s.substring(0, start) + substitute + s.substring(end); return s.substring(0, start) + substitute + s.substring(end);
}; };
gl.text.getTextWidth = function(text, font) { gl.text.getTextWidth = function(text, font) {
/** /**
* Uses canvas.measureText to compute and return the width of the given text of given font in pixels. * Uses canvas.measureText to compute and return the width of the given text of given font in pixels.
* *
...@@ -37,19 +35,19 @@ require('vendor/latinise'); ...@@ -37,19 +35,19 @@ require('vendor/latinise');
var context = canvas.getContext('2d'); var context = canvas.getContext('2d');
context.font = font; context.font = font;
return context.measureText(text).width; return context.measureText(text).width;
}; };
gl.text.selectedText = function(text, textarea) { gl.text.selectedText = function(text, textarea) {
return text.substring(textarea.selectionStart, textarea.selectionEnd); return text.substring(textarea.selectionStart, textarea.selectionEnd);
}; };
gl.text.lineBefore = function(text, textarea) { gl.text.lineBefore = function(text, textarea) {
var split; var split;
split = text.substring(0, textarea.selectionStart).trim().split('\n'); split = text.substring(0, textarea.selectionStart).trim().split('\n');
return split[split.length - 1]; return split[split.length - 1];
}; };
gl.text.lineAfter = function(text, textarea) { gl.text.lineAfter = function(text, textarea) {
return text.substring(textarea.selectionEnd).trim().split('\n')[0]; return text.substring(textarea.selectionEnd).trim().split('\n')[0];
}; };
gl.text.blockTagText = function(text, textArea, blockTag, selected) { gl.text.blockTagText = function(text, textArea, blockTag, selected) {
var lineAfter, lineBefore; var lineAfter, lineBefore;
lineBefore = this.lineBefore(text, textArea); lineBefore = this.lineBefore(text, textArea);
lineAfter = this.lineAfter(text, textArea); lineAfter = this.lineAfter(text, textArea);
...@@ -63,8 +61,8 @@ require('vendor/latinise'); ...@@ -63,8 +61,8 @@ require('vendor/latinise');
} else { } else {
return blockTag + "\n" + selected + "\n" + blockTag; return blockTag + "\n" + selected + "\n" + blockTag;
} }
}; };
gl.text.insertText = function(textArea, text, tag, blockTag, selected, wrap) { gl.text.insertText = function(textArea, text, tag, blockTag, selected, wrap) {
var insertText, inserted, selectedSplit, startChar, removedLastNewLine, removedFirstNewLine, currentLineEmpty, lastNewLine; var insertText, inserted, selectedSplit, startChar, removedLastNewLine, removedFirstNewLine, currentLineEmpty, lastNewLine;
removedLastNewLine = false; removedLastNewLine = false;
removedFirstNewLine = false; removedFirstNewLine = false;
...@@ -132,8 +130,8 @@ require('vendor/latinise'); ...@@ -132,8 +130,8 @@ require('vendor/latinise');
} catch (error) {} } catch (error) {}
} }
return this.moveCursor(textArea, tag, wrap, removedLastNewLine); return this.moveCursor(textArea, tag, wrap, removedLastNewLine);
}; };
gl.text.moveCursor = function(textArea, tag, wrapped, removedLastNewLine) { gl.text.moveCursor = function(textArea, tag, wrapped, removedLastNewLine) {
var pos; var pos;
if (!textArea.setSelectionRange) { if (!textArea.setSelectionRange) {
return; return;
...@@ -151,8 +149,8 @@ require('vendor/latinise'); ...@@ -151,8 +149,8 @@ require('vendor/latinise');
return textArea.setSelectionRange(pos, pos); return textArea.setSelectionRange(pos, pos);
} }
}; };
gl.text.updateText = function(textArea, tag, blockTag, wrap) { gl.text.updateText = function(textArea, tag, blockTag, wrap) {
var $textArea, selected, text; var $textArea, selected, text;
$textArea = $(textArea); $textArea = $(textArea);
textArea = $textArea.get(0); textArea = $textArea.get(0);
...@@ -160,8 +158,8 @@ require('vendor/latinise'); ...@@ -160,8 +158,8 @@ require('vendor/latinise');
selected = this.selectedText(text, textArea); selected = this.selectedText(text, textArea);
$textArea.focus(); $textArea.focus();
return this.insertText(textArea, text, tag, blockTag, selected, wrap); return this.insertText(textArea, text, tag, blockTag, selected, wrap);
}; };
gl.text.init = function(form) { gl.text.init = function(form) {
var self; var self;
self = this; self = this;
return $('.js-md', form).off('click').on('click', function() { return $('.js-md', form).off('click').on('click', function() {
...@@ -169,24 +167,22 @@ require('vendor/latinise'); ...@@ -169,24 +167,22 @@ require('vendor/latinise');
$this = $(this); $this = $(this);
return self.updateText($this.closest('.md-area').find('textarea'), $this.data('md-tag'), $this.data('md-block'), !$this.data('md-prepend')); return self.updateText($this.closest('.md-area').find('textarea'), $this.data('md-tag'), $this.data('md-block'), !$this.data('md-prepend'));
}); });
}; };
gl.text.removeListeners = function(form) { gl.text.removeListeners = function(form) {
return $('.js-md', form).off(); return $('.js-md', form).off();
}; };
gl.text.humanize = function(string) { gl.text.humanize = function(string) {
return string.charAt(0).toUpperCase() + string.replace(/_/g, ' ').slice(1); return string.charAt(0).toUpperCase() + string.replace(/_/g, ' ').slice(1);
}; };
gl.text.pluralize = function(str, count) { gl.text.pluralize = function(str, count) {
return str + (count > 1 || count === 0 ? 's' : ''); return str + (count > 1 || count === 0 ? 's' : '');
}; };
gl.text.truncate = function(string, maxLength) { gl.text.truncate = function(string, maxLength) {
return string.substr(0, (maxLength - 3)) + '...'; return string.substr(0, (maxLength - 3)) + '...';
}; };
gl.text.dasherize = function(str) { gl.text.dasherize = function(str) {
return str.replace(/[_\s]+/g, '-'); return str.replace(/[_\s]+/g, '-');
}; };
gl.text.slugify = function(str) { gl.text.slugify = function(str) {
return str.trim().toLowerCase().latinise(); return str.trim().toLowerCase().latinise();
}; };
})(window);
}).call(window);
require('~/lib/utils/text_utility'); require('~/lib/utils/text_utility');
(() => { describe('text_utility', () => {
describe('text_utility', () => {
describe('gl.text.getTextWidth', () => { describe('gl.text.getTextWidth', () => {
it('returns zero width when no text is passed', () => { it('returns zero width when no text is passed', () => {
expect(gl.text.getTextWidth('')).toBe(0); expect(gl.text.getTextWidth('')).toBe(0);
...@@ -106,5 +105,4 @@ require('~/lib/utils/text_utility'); ...@@ -106,5 +105,4 @@ require('~/lib/utils/text_utility');
}); });
}); });
}); });
}); });
})();
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