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
This commit is contained in:
Filipa Lacerda 2017-02-16 11:24:34 +00:00
commit 8ca90a68c4
4 changed files with 13 additions and 5 deletions

View file

@ -86,7 +86,7 @@ module.exports = Vue.component('environment-component', {
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;

View file

@ -56,7 +56,7 @@ class EnvironmentsStore {
return filteredEnvironments;
}
storePagination(pagination = {}) {
setPagination(pagination = {}) {
const normalizedHeaders = gl.utils.normalizeHeaders(pagination);
const paginationInformation = {
perPage: parseInt(normalizedHeaders['X-PER-PAGE'], 10),

View file

@ -35,8 +35,16 @@ require('../vue_shared/components/pipelines_table');
this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope, this.apiScope);
},
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}`);
},
},

View file

@ -51,7 +51,7 @@ const { environmentsList, serverData } = require('./mock_data');
previousPage: 2,
};
store.storePagination(pagination);
store.setPagination(pagination);
expect(store.state.paginationInformation).toEqual(expectedResult);
});
});