diff options
Diffstat (limited to 'app/assets/javascripts/releases/stores/modules/list/actions.js')
-rw-r--r-- | app/assets/javascripts/releases/stores/modules/list/actions.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/assets/javascripts/releases/stores/modules/list/actions.js b/app/assets/javascripts/releases/stores/modules/list/actions.js index 02e67415e63..a62f7c25464 100644 --- a/app/assets/javascripts/releases/stores/modules/list/actions.js +++ b/app/assets/javascripts/releases/stores/modules/list/actions.js @@ -42,6 +42,10 @@ export const fetchReleasesGraphQl = ( ) => { commit(types.REQUEST_RELEASES); + const { sort, orderBy } = state.sorting; + const orderByParam = orderBy === 'created_at' ? 'created' : orderBy; + const sortParams = `${orderByParam}_${sort}`.toUpperCase(); + let paginationParams; if (!before && !after) { paginationParams = { first: PAGE_SIZE }; @@ -60,6 +64,7 @@ export const fetchReleasesGraphQl = ( query: allReleasesQuery, variables: { fullPath: state.projectPath, + sort: sortParams, ...paginationParams, }, }) @@ -80,8 +85,10 @@ export const fetchReleasesGraphQl = ( export const fetchReleasesRest = ({ dispatch, commit, state }, { page }) => { commit(types.REQUEST_RELEASES); + const { sort, orderBy } = state.sorting; + api - .releases(state.projectId, { page }) + .releases(state.projectId, { page, sort, order_by: orderBy }) .then(({ data, headers }) => { const restPageInfo = parseIntPagination(normalizeHeaders(headers)); const camelCasedReleases = convertObjectPropsToCamelCase(data, { deep: true }); @@ -98,3 +105,5 @@ export const receiveReleasesError = ({ commit }) => { commit(types.RECEIVE_RELEASES_ERROR); createFlash(__('An error occurred while fetching the releases. Please try again.')); }; + +export const setSorting = ({ commit }, data) => commit(types.SET_SORTING, data); |