diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-10-30 18:56:30 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-10-31 20:10:36 +0300 |
commit | 87444fb6eda755a0340ab2e38ad83bb8edc67f6f (patch) | |
tree | 77db423177d0f04d8090fce754592f0a9aebda4b /app/assets/javascripts/pipelines/mixins | |
parent | fc892db6f02c992bef32bf994a694efd5205f61b (diff) |
Adds pagination to pipelines table in merge request page
Diffstat (limited to 'app/assets/javascripts/pipelines/mixins')
-rw-r--r-- | app/assets/javascripts/pipelines/mixins/pipelines.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/assets/javascripts/pipelines/mixins/pipelines.js b/app/assets/javascripts/pipelines/mixins/pipelines.js index 8929b397f6c..85781f548c6 100644 --- a/app/assets/javascripts/pipelines/mixins/pipelines.js +++ b/app/assets/javascripts/pipelines/mixins/pipelines.js @@ -23,6 +23,15 @@ export default { hasMadeRequest: false, }; }, + computed: { + shouldRenderPagination() { + return ( + !this.isLoading && + this.state.pipelines.length && + this.state.pageInfo.total > this.state.pageInfo.perPage + ); + }, + }, beforeMount() { this.poll = new Poll({ resource: this.service, @@ -65,6 +74,35 @@ export default { this.poll.stop(); }, methods: { + /** + * Handles URL and query parameter changes. + * When the user uses the pagination or the tabs, + * - update URL + * - Make API request to the server with new parameters + * - Update the polling function + * - Update the internal state + */ + updateContent(parameters) { + this.updateInternalState(parameters); + + // fetch new data + return this.service + .getPipelines(this.requestData) + .then(response => { + this.isLoading = false; + this.successCallback(response); + + // restart polling + this.poll.restart({ data: this.requestData }); + }) + .catch(() => { + this.isLoading = false; + this.errorCallback(); + + // restart polling + this.poll.restart({ data: this.requestData }); + }); + }, updateTable() { // Cancel ongoing request if (this.isMakingRequest) { |