diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-17 09:10:18 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-17 09:10:18 +0300 |
commit | 58e2ed53aa00b26eb1c07e235adc6f0a0535faf1 (patch) | |
tree | e3ab04c034b403e125bc247d5fafb4779c470b93 /app/assets/javascripts/releases | |
parent | 158548078665a076f33ed161967f030653586f24 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/releases')
6 files changed, 31 insertions, 80 deletions
diff --git a/app/assets/javascripts/releases/components/releases_pagination.vue b/app/assets/javascripts/releases/components/releases_pagination.vue index aceea2bde2f..fddf85ead1e 100644 --- a/app/assets/javascripts/releases/components/releases_pagination.vue +++ b/app/assets/javascripts/releases/components/releases_pagination.vue @@ -1,24 +1,37 @@ <script> -import ReleasesPaginationGraphql from './releases_pagination_graphql.vue'; -import ReleasesPaginationRest from './releases_pagination_rest.vue'; +import { GlKeysetPagination } from '@gitlab/ui'; +import { mapActions, mapState } from 'vuex'; +import { historyPushState, buildUrlWithCurrentLocation } from '~/lib/utils/common_utils'; export default { - name: 'ReleasesPagination', - components: { ReleasesPaginationGraphql, ReleasesPaginationRest }, + name: 'ReleasesPaginationGraphql', + components: { GlKeysetPagination }, computed: { - // TODO: Remove the ReleasesPaginationRest component since - // it is never shown. - // https://gitlab.com/gitlab-org/gitlab/-/issues/329267 - useGraphQLEndpoint() { - return true; + ...mapState('index', ['pageInfo']), + showPagination() { + return this.pageInfo.hasPreviousPage || this.pageInfo.hasNextPage; + }, + }, + methods: { + ...mapActions('index', ['fetchReleases']), + onPrev(before) { + historyPushState(buildUrlWithCurrentLocation(`?before=${before}`)); + this.fetchReleases({ before }); + }, + onNext(after) { + historyPushState(buildUrlWithCurrentLocation(`?after=${after}`)); + this.fetchReleases({ after }); }, }, }; </script> - <template> <div class="gl-display-flex gl-justify-content-center"> - <releases-pagination-graphql v-if="useGraphQLEndpoint" /> - <releases-pagination-rest v-else /> + <gl-keyset-pagination + v-if="showPagination" + v-bind="pageInfo" + @prev="onPrev($event)" + @next="onNext($event)" + /> </div> </template> diff --git a/app/assets/javascripts/releases/components/releases_pagination_graphql.vue b/app/assets/javascripts/releases/components/releases_pagination_graphql.vue deleted file mode 100644 index 13cbf95b9af..00000000000 --- a/app/assets/javascripts/releases/components/releases_pagination_graphql.vue +++ /dev/null @@ -1,35 +0,0 @@ -<script> -import { GlKeysetPagination } from '@gitlab/ui'; -import { mapActions, mapState } from 'vuex'; -import { historyPushState, buildUrlWithCurrentLocation } from '~/lib/utils/common_utils'; - -export default { - name: 'ReleasesPaginationGraphql', - components: { GlKeysetPagination }, - computed: { - ...mapState('index', ['graphQlPageInfo']), - showPagination() { - return this.graphQlPageInfo.hasPreviousPage || this.graphQlPageInfo.hasNextPage; - }, - }, - methods: { - ...mapActions('index', ['fetchReleases']), - onPrev(before) { - historyPushState(buildUrlWithCurrentLocation(`?before=${before}`)); - this.fetchReleases({ before }); - }, - onNext(after) { - historyPushState(buildUrlWithCurrentLocation(`?after=${after}`)); - this.fetchReleases({ after }); - }, - }, -}; -</script> -<template> - <gl-keyset-pagination - v-if="showPagination" - v-bind="graphQlPageInfo" - @prev="onPrev($event)" - @next="onNext($event)" - /> -</template> diff --git a/app/assets/javascripts/releases/components/releases_pagination_rest.vue b/app/assets/javascripts/releases/components/releases_pagination_rest.vue deleted file mode 100644 index 5e97a5a0450..00000000000 --- a/app/assets/javascripts/releases/components/releases_pagination_rest.vue +++ /dev/null @@ -1,24 +0,0 @@ -<script> -import { mapActions, mapState } from 'vuex'; -import { historyPushState, buildUrlWithCurrentLocation } from '~/lib/utils/common_utils'; -import TablePagination from '~/vue_shared/components/pagination/table_pagination.vue'; - -export default { - name: 'ReleasesPaginationRest', - components: { TablePagination }, - computed: { - ...mapState('index', ['restPageInfo']), - }, - methods: { - ...mapActions('index', ['fetchReleases']), - onChangePage(page) { - historyPushState(buildUrlWithCurrentLocation(`?page=${page}`)); - this.fetchReleases({ page }); - }, - }, -}; -</script> - -<template> - <table-pagination :change="onChangePage" :page-info="restPageInfo" /> -</template> diff --git a/app/assets/javascripts/releases/stores/modules/index/actions.js b/app/assets/javascripts/releases/stores/modules/index/actions.js index 35996126658..00be25f089b 100644 --- a/app/assets/javascripts/releases/stores/modules/index/actions.js +++ b/app/assets/javascripts/releases/stores/modules/index/actions.js @@ -45,11 +45,11 @@ export const fetchReleases = ({ dispatch, commit, state }, { before, after }) => }, }) .then((response) => { - const { data, paginationInfo: graphQlPageInfo } = convertAllReleasesGraphQLResponse(response); + const { data, paginationInfo: pageInfo } = convertAllReleasesGraphQLResponse(response); commit(types.RECEIVE_RELEASES_SUCCESS, { data, - graphQlPageInfo, + pageInfo, }); }) .catch(() => dispatch('receiveReleasesError')); diff --git a/app/assets/javascripts/releases/stores/modules/index/mutations.js b/app/assets/javascripts/releases/stores/modules/index/mutations.js index e1aaa2e2a19..55a8a488be8 100644 --- a/app/assets/javascripts/releases/stores/modules/index/mutations.js +++ b/app/assets/javascripts/releases/stores/modules/index/mutations.js @@ -17,12 +17,11 @@ export default { * @param {Object} state * @param {Object} resp */ - [types.RECEIVE_RELEASES_SUCCESS](state, { data, restPageInfo, graphQlPageInfo }) { + [types.RECEIVE_RELEASES_SUCCESS](state, { data, pageInfo }) { state.hasError = false; state.isLoading = false; state.releases = data; - state.restPageInfo = restPageInfo; - state.graphQlPageInfo = graphQlPageInfo; + state.pageInfo = pageInfo; }, /** @@ -36,8 +35,7 @@ export default { state.isLoading = false; state.releases = []; state.hasError = true; - state.restPageInfo = {}; - state.graphQlPageInfo = {}; + state.pageInfo = {}; }, [types.SET_SORTING](state, sorting) { diff --git a/app/assets/javascripts/releases/stores/modules/index/state.js b/app/assets/javascripts/releases/stores/modules/index/state.js index 164a496d450..5e1aaab7b58 100644 --- a/app/assets/javascripts/releases/stores/modules/index/state.js +++ b/app/assets/javascripts/releases/stores/modules/index/state.js @@ -16,8 +16,7 @@ export default ({ isLoading: false, hasError: false, releases: [], - restPageInfo: {}, - graphQlPageInfo: {}, + pageInfo: {}, sorting: { sort: DESCENDING_ORDER, orderBy: RELEASED_AT, |