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

actions.js « store « members « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4c31b3c974418cb41efeb4b05ad881340bc4d4fc (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
import * as types from './mutation_types';
import axios from '~/lib/utils/axios_utils';
import { formatDate } from '~/lib/utils/datetime_utility';

export const updateMemberRole = async ({ state, commit }, { memberId, accessLevel }) => {
  try {
    await axios.put(
      state.memberPath.replace(/:id$/, memberId),
      state.requestFormatter({ accessLevel: accessLevel.integerValue }),
    );

    commit(types.RECEIVE_MEMBER_ROLE_SUCCESS, { memberId, accessLevel });
  } catch (error) {
    commit(types.RECEIVE_MEMBER_ROLE_ERROR);

    throw error;
  }
};

export const showRemoveGroupLinkModal = ({ commit }, groupLink) => {
  commit(types.SHOW_REMOVE_GROUP_LINK_MODAL, groupLink);
};

export const hideRemoveGroupLinkModal = ({ commit }) => {
  commit(types.HIDE_REMOVE_GROUP_LINK_MODAL);
};

export const updateMemberExpiration = async ({ state, commit }, { memberId, expiresAt }) => {
  try {
    await axios.put(
      state.memberPath.replace(':id', memberId),
      state.requestFormatter({ expires_at: expiresAt ? formatDate(expiresAt, 'isoDate') : '' }),
    );

    commit(types.RECEIVE_MEMBER_EXPIRATION_SUCCESS, {
      memberId,
      expiresAt: expiresAt ? formatDate(expiresAt, 'isoUtcDateTime') : null,
    });
  } catch (error) {
    commit(types.RECEIVE_MEMBER_EXPIRATION_ERROR);

    throw error;
  }
};