From 73accafe430f56cd3065774c6118de3db0a45734 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Mon, 13 Feb 2017 14:49:19 +0000 Subject: [PATCH] Use common util to get parameter name --- .../components/environment.js.es6 | 24 ++++--------------- .../folder/environments_folder_view.js.es6 | 7 +++--- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment.js.es6 b/app/assets/javascripts/environments/components/environment.js.es6 index 42f74e114c9..2cbfbcad023 100644 --- a/app/assets/javascripts/environments/components/environment.js.es6 +++ b/app/assets/javascripts/environments/components/environment.js.es6 @@ -7,6 +7,7 @@ const EnvironmentsService = require('../services/environments_service'); const EnvironmentTable = require('./environments_table'); const Store = require('../stores/environments_store'); require('../../vue_shared/components/table_pagination'); +require('../../lib/utils/common_utils'); module.exports = Vue.component('environment-component', { @@ -45,7 +46,7 @@ module.exports = Vue.component('environment-component', { computed: { scope() { - return this.$options.getQueryParameter('scope'); + return gl.utils.getParameterByName('scope'); }, canReadEnvironmentParsed() { @@ -67,8 +68,8 @@ module.exports = Vue.component('environment-component', { * Toggles loading property. */ created() { - const scope = this.$options.getQueryParameter('scope') || this.visibility; - const pageNumber = this.$options.getQueryParameter('page') || this.pageNumber; + const scope = gl.utils.getParameterByName('scope') || this.visibility; + const pageNumber = gl.utils.getParameterByName('page') || this.pageNumber; const endpoint = `${this.endpoint}?scope=${scope}&page=${pageNumber}`; @@ -96,21 +97,6 @@ module.exports = Vue.component('environment-component', { }); }, - /** - * Transforms the url parameter into an object and - * returns the one requested. - * - * @param {String} param - * @returns {String} The value of the requested parameter. - */ - getQueryParameter(parameter) { - return window.location.search.substring(1).split('&').reduce((acc, param) => { - const paramSplited = param.split('='); - acc[paramSplited[0]] = paramSplited[1]; - return acc; - }, {})[parameter]; - }, - /** * Converts permission provided as strings to booleans. * @param {String} string @@ -158,7 +144,7 @@ module.exports = Vue.component('environment-component', {