debian-mirror-gitlab/app/assets/javascripts/whats_new/store/actions.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import axios from '~/lib/utils/axios_utils';
2021-01-29 00:20:46 +05:30
import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils';
2022-07-23 23:45:48 +05:30
import { joinPaths } from '~/lib/utils/url_utility';
2021-04-29 21:17:54 +05:30
import { STORAGE_KEY } from '../utils/notification';
2021-03-11 19:13:27 +05:30
import * as types from './mutation_types';
2020-10-24 23:57:45 +05:30
export default {
closeDrawer({ commit }) {
commit(types.CLOSE_DRAWER);
},
2021-04-29 21:17:54 +05:30
openDrawer({ commit }, versionDigest) {
2020-10-24 23:57:45 +05:30
commit(types.OPEN_DRAWER);
2021-01-03 14:25:43 +05:30
2021-04-29 21:17:54 +05:30
if (versionDigest) {
localStorage.setItem(STORAGE_KEY, versionDigest);
2021-01-03 14:25:43 +05:30
}
},
2021-06-08 01:23:25 +05:30
fetchItems({ commit, state }, { page, versionDigest } = { page: null, versionDigest: null }) {
2021-01-29 00:20:46 +05:30
if (state.fetching) {
return false;
}
commit(types.SET_FETCHING, true);
2021-06-08 01:23:25 +05:30
const v = versionDigest;
2021-01-29 00:20:46 +05:30
return axios
2022-07-23 23:45:48 +05:30
.get(joinPaths('/', gon.relative_url_root || '', '/-/whats_new'), {
2021-01-29 00:20:46 +05:30
params: {
page,
2021-06-08 01:23:25 +05:30
v,
2021-01-29 00:20:46 +05:30
},
})
.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);
2020-10-24 23:57:45 +05:30
},
};