2020-11-24 15:15:51 +05:30
|
|
|
<script>
|
|
|
|
import { GlKeysetPagination } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { mapActions, mapState } from 'vuex';
|
2020-11-24 15:15:51 +05:30
|
|
|
import { historyPushState, buildUrlWithCurrentLocation } from '~/lib/utils/common_utils';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ReleasesPaginationGraphql',
|
|
|
|
components: { GlKeysetPagination },
|
|
|
|
computed: {
|
|
|
|
...mapState('list', ['graphQlPageInfo']),
|
|
|
|
showPagination() {
|
|
|
|
return this.graphQlPageInfo.hasPreviousPage || this.graphQlPageInfo.hasNextPage;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
2021-01-03 14:25:43 +05:30
|
|
|
...mapActions('list', ['fetchReleases']),
|
2020-11-24 15:15:51 +05:30
|
|
|
onPrev(before) {
|
|
|
|
historyPushState(buildUrlWithCurrentLocation(`?before=${before}`));
|
2021-01-03 14:25:43 +05:30
|
|
|
this.fetchReleases({ before });
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
|
|
|
onNext(after) {
|
|
|
|
historyPushState(buildUrlWithCurrentLocation(`?after=${after}`));
|
2021-01-03 14:25:43 +05:30
|
|
|
this.fetchReleases({ after });
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<gl-keyset-pagination
|
|
|
|
v-if="showPagination"
|
|
|
|
v-bind="graphQlPageInfo"
|
|
|
|
@prev="onPrev($event)"
|
|
|
|
@next="onNext($event)"
|
|
|
|
/>
|
|
|
|
</template>
|