summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/packages/list/stores/mutations.js
blob: 2fe7981b3d96687357fa146c085e84d3af58c105 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import * as types from './mutation_types';
import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils';
import { GROUP_PAGE_TYPE } from '../constants';

export default {
  [types.SET_INITIAL_STATE](state, config) {
    const { comingSoonJson, ...rest } = config;
    state.config = {
      ...rest,
      isGroupPage: config.pageType === GROUP_PAGE_TYPE,
    };
  },

  [types.SET_PACKAGE_LIST_SUCCESS](state, packages) {
    state.packages = packages;
  },

  [types.SET_MAIN_LOADING](state, isLoading) {
    state.isLoading = isLoading;
  },

  [types.SET_PAGINATION](state, headers) {
    const normalizedHeaders = normalizeHeaders(headers);
    state.pagination = parseIntPagination(normalizedHeaders);
  },

  [types.SET_SORTING](state, sorting) {
    state.sorting = { ...state.sorting, ...sorting };
  },

  [types.SET_SELECTED_TYPE](state, type) {
    state.selectedType = type;
  },

  [types.SET_FILTER](state, query) {
    state.filterQuery = query;
  },
};