All files / ee/app/assets/javascripts/pages/groups/saml_providers/saml_members/store actions.js

100% Statements 6/6
100% Branches 4/4
100% Functions 4/4
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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              2x           1x 1x 1x 2x               1x          
import Api from '~/api';
import { createAlert } from '~/alert';
import { normalizeHeaders, parseIntPagination } from '~/lib/utils/common_utils';
import { __ } from '~/locale';
import * as types from './mutation_types';
 
export function fetchPage({ commit, state }, newPage) {
  return Api.groupMembers(state.groupId, {
    with_saml_identity: 'true',
    page: newPage || state.pageInfo.page,
    per_page: state.pageInfo.perPage,
  })
    .then((response) => {
      const { headers, data } = response;
      const pageInfo = parseIntPagination(normalizeHeaders(headers));
      commit(types.RECEIVE_SAML_MEMBERS_SUCCESS, {
        members: data.map(({ group_saml_identity: identity, ...item }) => ({
          ...item,
          identity: identity ? identity.extern_uid : null,
        })),
        pageInfo,
      });
    })
    .catch(() => {
      createAlert({
        message: __('An error occurred while loading group members.'),
      });
    });
}