diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-28 21:10:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-28 21:10:12 +0300 |
commit | 52e32e255f7d868c4ec952a201bb8813b5e03703 (patch) | |
tree | 4b1678207027093c6f0cf0ad0dfa07979fad2092 /app/assets/javascripts/releases | |
parent | 42d13aebd3c47671337d871e8b349385dade5252 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/releases')
6 files changed, 17 insertions, 81 deletions
diff --git a/app/assets/javascripts/releases/components/app_index.vue b/app/assets/javascripts/releases/components/app_index.vue index 262b5614d65..31d335fa15d 100644 --- a/app/assets/javascripts/releases/components/app_index.vue +++ b/app/assets/javascripts/releases/components/app_index.vue @@ -51,12 +51,8 @@ export default { }), fetchReleases() { this.fetchReleasesStoreAction({ - // these two parameters are only used in "GraphQL mode" before: getParameterByName('before'), after: getParameterByName('after'), - - // this parameter is only used when in "REST mode" - page: getParameterByName('page'), }); }, }, @@ -73,17 +69,17 @@ export default { :aria-describedby="shouldRenderEmptyState && 'releases-description'" category="primary" variant="success" - class="js-new-release-btn" + data-testid="new-release-button" > {{ __('New release') }} </gl-button> </div> - <release-skeleton-loader v-if="isLoading" class="js-loading" /> + <release-skeleton-loader v-if="isLoading" /> <gl-empty-state v-else-if="shouldRenderEmptyState" - class="js-empty-state" + data-testid="empty-state" :title="__('Getting started with releases')" :svg-path="illustrationPath" > @@ -101,7 +97,7 @@ export default { </template> </gl-empty-state> - <div v-else-if="shouldRenderSuccessState" class="js-success-state"> + <div v-else-if="shouldRenderSuccessState" data-testid="success-state"> <release-block v-for="(release, index) in releases" :key="index" diff --git a/app/assets/javascripts/releases/components/releases_pagination.vue b/app/assets/javascripts/releases/components/releases_pagination.vue index 062c72b445b..aceea2bde2f 100644 --- a/app/assets/javascripts/releases/components/releases_pagination.vue +++ b/app/assets/javascripts/releases/components/releases_pagination.vue @@ -1,5 +1,4 @@ <script> -import { mapGetters } from 'vuex'; import ReleasesPaginationGraphql from './releases_pagination_graphql.vue'; import ReleasesPaginationRest from './releases_pagination_rest.vue'; @@ -7,7 +6,12 @@ export default { name: 'ReleasesPagination', components: { ReleasesPaginationGraphql, ReleasesPaginationRest }, computed: { - ...mapGetters(['useGraphQLEndpoint']), + // TODO: Remove the ReleasesPaginationRest component since + // it is never shown. + // https://gitlab.com/gitlab-org/gitlab/-/issues/329267 + useGraphQLEndpoint() { + return true; + }, }, }; </script> diff --git a/app/assets/javascripts/releases/mount_index.js b/app/assets/javascripts/releases/mount_index.js index 0b453467c13..bb21ec7c43f 100644 --- a/app/assets/javascripts/releases/mount_index.js +++ b/app/assets/javascripts/releases/mount_index.js @@ -15,11 +15,6 @@ export default () => { modules: { index: createIndexModule(el.dataset), }, - featureFlags: { - graphqlReleaseData: Boolean(gon.features?.graphqlReleaseData), - graphqlReleasesPage: Boolean(gon.features?.graphqlReleasesPage), - graphqlMilestoneStats: Boolean(gon.features?.graphqlMilestoneStats), - }, }), render: (h) => h(ReleaseIndexApp), }); diff --git a/app/assets/javascripts/releases/stores/getters.js b/app/assets/javascripts/releases/stores/getters.js deleted file mode 100644 index 2a06f398e26..00000000000 --- a/app/assets/javascripts/releases/stores/getters.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * @returns {Boolean} `true` if all the feature flags - * required to enable the GraphQL endpoint are enabled - */ -export const useGraphQLEndpoint = (rootState) => { - return Boolean( - rootState.featureFlags.graphqlReleaseData && - rootState.featureFlags.graphqlReleasesPage && - rootState.featureFlags.graphqlMilestoneStats, - ); -}; diff --git a/app/assets/javascripts/releases/stores/index.js b/app/assets/javascripts/releases/stores/index.js index cc8b586964f..b2e93d789d7 100644 --- a/app/assets/javascripts/releases/stores/index.js +++ b/app/assets/javascripts/releases/stores/index.js @@ -1,9 +1,7 @@ import Vuex from 'vuex'; -import * as getters from './getters'; export default ({ modules, featureFlags }) => new Vuex.Store({ modules, state: { featureFlags }, - getters, }); diff --git a/app/assets/javascripts/releases/stores/modules/index/actions.js b/app/assets/javascripts/releases/stores/modules/index/actions.js index f1add54626a..8496cceffe6 100644 --- a/app/assets/javascripts/releases/stores/modules/index/actions.js +++ b/app/assets/javascripts/releases/stores/modules/index/actions.js @@ -1,45 +1,21 @@ -import api from '~/api'; import { deprecatedCreateFlash as createFlash } from '~/flash'; -import { - normalizeHeaders, - parseIntPagination, - convertObjectPropsToCamelCase, -} from '~/lib/utils/common_utils'; import { __ } from '~/locale'; +import { PAGE_SIZE } from '~/releases/constants'; import allReleasesQuery from '~/releases/queries/all_releases.query.graphql'; -import { PAGE_SIZE } from '../../../constants'; -import { gqClient, convertAllReleasesGraphQLResponse } from '../../../util'; +import { gqClient, convertAllReleasesGraphQLResponse } from '~/releases/util'; import * as types from './mutation_types'; /** - * Gets a paginated list of releases from the server + * Gets a paginated list of releases from the GraphQL endpoint * * @param {Object} vuexParams * @param {Object} actionParams - * @param {Number} [actionParams.page] The page number of results to fetch - * (this parameter is only used when fetching results from the REST API) * @param {String} [actionParams.before] A GraphQL cursor. If provided, - * the items returned will proceed the provided cursor (this parameter is only - * used when fetching results from the GraphQL API). + * the items returned will proceed the provided cursor. * @param {String} [actionParams.after] A GraphQL cursor. If provided, - * the items returned will follow the provided cursor (this parameter is only - * used when fetching results from the GraphQL API). + * the items returned will follow the provided cursor. */ -export const fetchReleases = ({ dispatch, rootGetters }, { page = 1, before, after }) => { - if (rootGetters.useGraphQLEndpoint) { - dispatch('fetchReleasesGraphQl', { before, after }); - } else { - dispatch('fetchReleasesRest', { page }); - } -}; - -/** - * Gets a paginated list of releases from the GraphQL endpoint - */ -export const fetchReleasesGraphQl = ( - { dispatch, commit, state }, - { before = null, after = null }, -) => { +export const fetchReleases = ({ dispatch, commit, state }, { before, after }) => { commit(types.REQUEST_RELEASES); const { sort, orderBy } = state.sorting; @@ -55,7 +31,7 @@ export const fetchReleasesGraphQl = ( paginationParams = { first: PAGE_SIZE, after }; } else { throw new Error( - 'Both a `before` and an `after` parameter were provided to fetchReleasesGraphQl. These parameters cannot be used together.', + 'Both a `before` and an `after` parameter were provided to fetchReleases. These parameters cannot be used together.', ); } @@ -79,28 +55,6 @@ export const fetchReleasesGraphQl = ( .catch(() => dispatch('receiveReleasesError')); }; -/** - * Gets a paginated list of releases from the REST endpoint - */ -export const fetchReleasesRest = ({ dispatch, commit, state }, { page }) => { - commit(types.REQUEST_RELEASES); - - const { sort, orderBy } = state.sorting; - - api - .releases(state.projectId, { page, sort, order_by: orderBy }) - .then(({ data, headers }) => { - const restPageInfo = parseIntPagination(normalizeHeaders(headers)); - const camelCasedReleases = convertObjectPropsToCamelCase(data, { deep: true }); - - commit(types.RECEIVE_RELEASES_SUCCESS, { - data: camelCasedReleases, - restPageInfo, - }); - }) - .catch(() => dispatch('receiveReleasesError')); -}; - export const receiveReleasesError = ({ commit }) => { commit(types.RECEIVE_RELEASES_ERROR); createFlash(__('An error occurred while fetching the releases. Please try again.')); |