diff --git a/app/assets/javascripts/environments/components/environment.js.es6 b/app/assets/javascripts/environments/components/environment.js.es6 index d096f837285..0cbf952ea5c 100644 --- a/app/assets/javascripts/environments/components/environment.js.es6 +++ b/app/assets/javascripts/environments/components/environment.js.es6 @@ -5,7 +5,7 @@ const Vue = require('vue'); Vue.use(require('vue-resource')); const EnvironmentsService = require('../services/environments_service'); const EnvironmentTable = require('./environments_table'); -const Store = require('../stores/environments_store'); +const EnvironmentsStore = require('../stores/environments_store'); require('../../vue_shared/components/table_pagination'); require('../../lib/utils/common_utils'); @@ -18,7 +18,7 @@ module.exports = Vue.component('environment-component', { data() { const environmentsData = document.querySelector('#environments-list-view').dataset; - const store = new Store(); + const store = new EnvironmentsStore(); return { store, diff --git a/app/assets/javascripts/environments/folder/environments_folder_view.js.es6 b/app/assets/javascripts/environments/folder/environments_folder_view.js.es6 index f67e5eab64a..0b1204559da 100644 --- a/app/assets/javascripts/environments/folder/environments_folder_view.js.es6 +++ b/app/assets/javascripts/environments/folder/environments_folder_view.js.es6 @@ -5,7 +5,7 @@ const Vue = require('vue'); Vue.use(require('vue-resource')); const EnvironmentsService = require('../services/environments_service'); const EnvironmentTable = require('../components/environments_table'); -const Store = require('../stores/environments_store'); +const EnvironmentsStore = require('../stores/environments_store'); require('../../vue_shared/components/table_pagination'); require('../../lib/utils/common_utils'); @@ -18,9 +18,10 @@ module.exports = Vue.component('environment-folder-view', { data() { const environmentsData = document.querySelector('#environments-folder-list-view').dataset; - const store = new Store(); - const endpoint = `${window.location.pathname}.json`; - const folderName = window.location.pathname.substr(window.location.pathname.lastIndexOf('/') + 1); + const store = new EnvironmentsStore(); + const pathname = window.location.pathname; + const endpoint = `${pathname}.json`; + const folderName = pathname.substr(pathname.lastIndexOf('/') + 1); return { store, @@ -99,7 +100,7 @@ module.exports = Vue.component('environment-folder-view', { this.store.storeAvailableCount(response.body.available_count); this.store.storeStoppedCount(response.body.stopped_count); this.store.storeEnvironments(response.body.environments); - this.store.storePagination(response.headers); + this.store.setPagination(response.headers); }) .then(() => { this.isLoading = false; diff --git a/app/assets/javascripts/lib/utils/common_utils.js.es6 b/app/assets/javascripts/lib/utils/common_utils.js.es6 index 276ff01ab89..9c010e49284 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js.es6 +++ b/app/assets/javascripts/lib/utils/common_utils.js.es6 @@ -256,19 +256,19 @@ */ w.gl.utils.setParamInURL = (param, value) => { let search; + const locationSearch = window.location.search; - if (window.location.search.length === 0) { + if (locationSearch.length === 0) { search = `?${param}=${value}`; } - if (window.location.search.indexOf(param) !== -1) { + if (locationSearch.indexOf(param) !== -1) { const regex = new RegExp(param + '=\\d'); - search = window.location.search.replace(regex, `${param}=${value}`); + search = locationSearch.replace(regex, `${param}=${value}`); } - if (window.location.search.length && - window.location.search.indexOf(param) === -1) { - search = `${window.location.search}&${param}=${value}`; + if (locationSearch.length && locationSearch.indexOf(param) === -1) { + search = `${locationSearch}&${param}=${value}`; } return search;