Welcome to mirror list, hosted at ThFree Co, Russian Federation.

actions.js « store « whats_new « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1dc92ea26062b7c58d1689f0ca22974f1a25dbb1 (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
39
40
41
42
43
44
45
46
import axios from '~/lib/utils/axios_utils';
import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils';
import { STORAGE_KEY } from '../utils/notification';
import * as types from './mutation_types';

export default {
  closeDrawer({ commit }) {
    commit(types.CLOSE_DRAWER);
  },
  openDrawer({ commit }, versionDigest) {
    commit(types.OPEN_DRAWER);

    if (versionDigest) {
      localStorage.setItem(STORAGE_KEY, versionDigest);
    }
  },
  fetchItems({ commit, state }, { page } = { page: null }) {
    if (state.fetching) {
      return false;
    }

    commit(types.SET_FETCHING, true);

    return axios
      .get('/-/whats_new', {
        params: {
          page,
        },
      })
      .then(({ data, headers }) => {
        commit(types.ADD_FEATURES, data);

        const normalizedHeaders = normalizeHeaders(headers);
        const { nextPage } = parseIntPagination(normalizedHeaders);
        commit(types.SET_PAGE_INFO, {
          nextPage,
        });
      })
      .finally(() => {
        commit(types.SET_FETCHING, false);
      });
  },
  setDrawerBodyHeight({ commit }, height) {
    commit(types.SET_DRAWER_BODY_HEIGHT, height);
  },
};