summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRegis <boudinot.regis@yahoo.com>2017-01-09 09:19:55 -0700
committerRegis <boudinot.regis@yahoo.com>2017-01-09 09:19:55 -0700
commit76c68d1a185009b831bab014446829158ced2f17 (patch)
tree1cbed4cb52dd0774f21cacba1ea4b2d6427bf12c
parent3fff93ca01008e73c320ce87a686c69bada5dac3 (diff)
downloadgitlab-ce-76c68d1a185009b831bab014446829158ced2f17.tar.gz
namespace getParametersByName to gl.utils instead of just gl
-rw-r--r--app/assets/javascripts/lib/utils/param_helper.js.es67
-rw-r--r--app/assets/javascripts/vue_pagination/index.js.es62
-rw-r--r--app/assets/javascripts/vue_pipelines_index/pipelines.js.es66
-rw-r--r--spec/javascripts/vue_pagination/pagination_spec.js.es68
4 files changed, 13 insertions, 10 deletions
diff --git a/app/assets/javascripts/lib/utils/param_helper.js.es6 b/app/assets/javascripts/lib/utils/param_helper.js.es6
index 2b150c415c8..01b3a2ee07f 100644
--- a/app/assets/javascripts/lib/utils/param_helper.js.es6
+++ b/app/assets/javascripts/lib/utils/param_helper.js.es6
@@ -1,12 +1,15 @@
/* eslint-disable no-param-reassign */
-((w) => {
+((gl) => {
+ gl.utils = gl.utils || (gl.utils = {});
+
/**
this will take in the `name` of the param you want to parse in the url
if the name does not exist this function will return `null`
otherwise it will return the value of the param key provided
*/
- w.getParameterByName = (name) => {
+
+ gl.utils.getParameterByName = (name) => {
const url = window.location.href;
name = name.replace(/[[\]]/g, '\\$&');
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
diff --git a/app/assets/javascripts/vue_pagination/index.js.es6 b/app/assets/javascripts/vue_pagination/index.js.es6
index b69062e0849..b9678d8a97f 100644
--- a/app/assets/javascripts/vue_pagination/index.js.es6
+++ b/app/assets/javascripts/vue_pagination/index.js.es6
@@ -58,7 +58,7 @@
},
methods: {
changePage(e) {
- let apiScope = gl.getParameterByName('scope');
+ let apiScope = gl.utils.getParameterByName('scope');
if (!apiScope) apiScope = 'all';
diff --git a/app/assets/javascripts/vue_pipelines_index/pipelines.js.es6 b/app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
index d4166be4a34..eb9035146ba 100644
--- a/app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
+++ b/app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
@@ -28,8 +28,8 @@
},
props: ['scope', 'store', 'svgs'],
created() {
- const pagenum = gl.getParameterByName('p');
- const scope = gl.getParameterByName('scope');
+ const pagenum = gl.utils.getParameterByName('p');
+ const scope = gl.utils.getParameterByName('scope');
if (pagenum) this.pagenum = pagenum;
if (scope) this.apiScope = scope;
this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope, this.apiScope);
@@ -42,7 +42,7 @@
this.store.fetchDataLoop.call(this, Vue, pagenum, this.scope, apiScope);
},
author(pipeline) {
- if (!pipeline.commit) return ({ avatar_url: '', web_url: '', username: '' });
+ if (!pipeline.commit) return { avatar_url: '', web_url: '', username: '' };
if (pipeline.commit.author) return pipeline.commit.author;
return {
avatar_url: pipeline.commit.author_gravatar_url,
diff --git a/spec/javascripts/vue_pagination/pagination_spec.js.es6 b/spec/javascripts/vue_pagination/pagination_spec.js.es6
index 3a57f69676f..c5f70ba5bfb 100644
--- a/spec/javascripts/vue_pagination/pagination_spec.js.es6
+++ b/spec/javascripts/vue_pagination/pagination_spec.js.es6
@@ -147,8 +147,8 @@ describe('paramHelper', () => {
it('can parse url parameters correctly', () => {
window.history.pushState({}, null, '?scope=all&p=2');
- const scope = gl.getParameterByName('scope');
- const p = gl.getParameterByName('p');
+ const scope = gl.utils.getParameterByName('scope');
+ const p = gl.utils.getParameterByName('p');
expect(scope).toEqual('all');
expect(p).toEqual('2');
@@ -157,8 +157,8 @@ describe('paramHelper', () => {
it('returns null if param not in url', () => {
window.history.pushState({}, null, '?p=2');
- const scope = gl.getParameterByName('scope');
- const p = gl.getParameterByName('p');
+ const scope = gl.utils.getParameterByName('scope');
+ const p = gl.utils.getParameterByName('p');
expect(scope).toEqual(null);
expect(p).toEqual('2');