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

mutations.js « show « store « user_lists « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bb5f9abe79e1ef5e6a5900b3b6ce057e6f7114bf (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
import { states } from '../../constants/show';
import { parseUserIds } from '../utils';
import * as types from './mutation_types';

export default {
  [types.REQUEST_USER_LIST](state) {
    state.state = states.LOADING;
  },
  [types.RECEIVE_USER_LIST_SUCCESS](state, userList) {
    state.state = states.SUCCESS;
    state.userIds = userList.user_xids?.length > 0 ? parseUserIds(userList.user_xids) : [];
    state.userList = userList;
  },
  [types.RECEIVE_USER_LIST_ERROR](state) {
    state.state = states.ERROR;
  },
  [types.DISMISS_ERROR_ALERT](state) {
    state.state = states.ERROR_DISMISSED;
  },
  [types.ADD_USER_IDS](state, ids) {
    state.userIds = [
      ...state.userIds,
      ...parseUserIds(ids).filter((id) => id && !state.userIds.includes(id)),
    ];
  },
  [types.REMOVE_USER_ID](state, id) {
    state.userIds = state.userIds.filter((uid) => uid !== id);
  },
};