debian-mirror-gitlab/app/assets/javascripts/runner/components/runner_pagination.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.3 KiB
Vue
Raw Normal View History

2021-09-04 01:27:46 +05:30
<script>
import { GlPagination } from '@gitlab/ui';
export default {
components: {
GlPagination,
},
props: {
value: {
required: false,
type: Object,
default: () => ({
page: 1,
}),
},
pageInfo: {
required: false,
type: Object,
default: () => ({}),
},
},
computed: {
prevPage() {
return this.pageInfo?.hasPreviousPage ? this.value?.page - 1 : null;
},
nextPage() {
return this.pageInfo?.hasNextPage ? this.value?.page + 1 : null;
},
},
methods: {
handlePageChange(page) {
2022-04-04 11:22:00 +05:30
if (page === 1) {
// Small optimization for first page
// If we have loaded using "first",
// page is already cached.
this.$emit('input', {
page,
});
} else if (page > this.value.page) {
2021-09-04 01:27:46 +05:30
this.$emit('input', {
page,
after: this.pageInfo.endCursor,
});
} else {
this.$emit('input', {
page,
before: this.pageInfo.startCursor,
});
}
},
},
};
</script>
<template>
<gl-pagination
2022-04-04 11:22:00 +05:30
v-bind="$attrs"
2021-09-04 01:27:46 +05:30
:value="value.page"
:prev-page="prevPage"
:next-page="nextPage"
align="center"
2022-04-04 11:22:00 +05:30
class="gl-pagination"
2021-09-04 01:27:46 +05:30
@input="handlePageChange"
/>
</template>