Commit 8ca90a68 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'fe-paginated-environments-api-add-pagination' into...

Merge branch 'fe-paginated-environments-api-add-pagination' into fe-paginated-environments-api-add-subview

* fe-paginated-environments-api-add-pagination:
  Changes after review
  Rename storePagination to setPagination
parents 605195c2 19791b65
...@@ -86,7 +86,7 @@ module.exports = Vue.component('environment-component', { ...@@ -86,7 +86,7 @@ module.exports = Vue.component('environment-component', {
this.store.storeAvailableCount(response.body.available_count); this.store.storeAvailableCount(response.body.available_count);
this.store.storeStoppedCount(response.body.stopped_count); this.store.storeStoppedCount(response.body.stopped_count);
this.store.storeEnvironments(response.body.environments); this.store.storeEnvironments(response.body.environments);
this.store.storePagination(response.headers); this.store.setPagination(response.headers);
}) })
.then(() => { .then(() => {
this.isLoading = false; this.isLoading = false;
......
...@@ -56,7 +56,7 @@ class EnvironmentsStore { ...@@ -56,7 +56,7 @@ class EnvironmentsStore {
return filteredEnvironments; return filteredEnvironments;
} }
storePagination(pagination = {}) { setPagination(pagination = {}) {
const normalizedHeaders = gl.utils.normalizeHeaders(pagination); const normalizedHeaders = gl.utils.normalizeHeaders(pagination);
const paginationInformation = { const paginationInformation = {
perPage: parseInt(normalizedHeaders['X-PER-PAGE'], 10), perPage: parseInt(normalizedHeaders['X-PER-PAGE'], 10),
......
...@@ -35,8 +35,16 @@ require('../vue_shared/components/pipelines_table'); ...@@ -35,8 +35,16 @@ require('../vue_shared/components/pipelines_table');
this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope, this.apiScope); this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope, this.apiScope);
}, },
methods: { methods: {
change(pagenum, apiScope) {
if (!apiScope) apiScope = 'all'; /**
* Changes the URL according to the pagination component.
*
* If no scope is provided, 'all' is assumed.
*
* @param {Number} pagenum
* @param {String} apiScope = 'all'
*/
change(pagenum, apiScope = 'all') {
gl.utils.visitUrl(`?scope=${apiScope}&p=${pagenum}`); gl.utils.visitUrl(`?scope=${apiScope}&p=${pagenum}`);
}, },
}, },
......
...@@ -51,7 +51,7 @@ const { environmentsList, serverData } = require('./mock_data'); ...@@ -51,7 +51,7 @@ const { environmentsList, serverData } = require('./mock_data');
previousPage: 2, previousPage: 2,
}; };
store.storePagination(pagination); store.setPagination(pagination);
expect(store.state.paginationInformation).toEqual(expectedResult); expect(store.state.paginationInformation).toEqual(expectedResult);
}); });
}); });
......
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