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

api_responses.js « mock_data « invite_members « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9190f85d7a046973c0c8be708e7e05399bbed55e (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
const EMAIL_INVALID = {
  message: { error: 'email contains an invalid email address' },
};

const ERROR_EMAIL_INVALID = {
  error: 'email contains an invalid email address',
};

const BASE_ERROR_MEMBER_NOT_ALLOWED = `The member's email address is not allowed for this project. \
Go to the 'Admin area > Sign-up restrictions', and check`;

const ALLOWED_DOMAIN_ERROR = `${BASE_ERROR_MEMBER_NOT_ALLOWED} 'Allowed domains for sign-ups'.`;
const DOMAIN_DENYLIST_ERROR = `${BASE_ERROR_MEMBER_NOT_ALLOWED} the 'Domain denylist'.`;

function htmlDecode(input) {
  const doc = new DOMParser().parseFromString(input, 'text/html');
  return doc.documentElement.textContent;
}

const DECODED_ALLOWED_DOMAIN_ERROR = htmlDecode(ALLOWED_DOMAIN_ERROR);
const DECODED_DOMAIN_DENYLIST_ERROR = htmlDecode(DOMAIN_DENYLIST_ERROR);

const EMAIL_RESTRICTED = {
  message: {
    'email@example.com': ALLOWED_DOMAIN_ERROR,
  },
  parsedMessage: {
    'email@example.com': DECODED_ALLOWED_DOMAIN_ERROR,
  },
  status: 'error',
};

const MULTIPLE_RESTRICTED = {
  message: {
    'email@example.com': ALLOWED_DOMAIN_ERROR,
    'email4@example.com': DOMAIN_DENYLIST_ERROR,
    root: ALLOWED_DOMAIN_ERROR,
  },
  parsedMessage: {
    'email@example.com': DECODED_ALLOWED_DOMAIN_ERROR,
    'email4@example.com': DECODED_DOMAIN_DENYLIST_ERROR,
    root: DECODED_ALLOWED_DOMAIN_ERROR,
  },
  status: 'error',
};

const EXPANDED_RESTRICTED = {
  message: {
    'email@example.com': ALLOWED_DOMAIN_ERROR,
    'email4@example.com': DOMAIN_DENYLIST_ERROR,
    'email5@example.com': DOMAIN_DENYLIST_ERROR,
    root: ALLOWED_DOMAIN_ERROR,
  },
  parsedMessage: {
    'email@example.com': DECODED_ALLOWED_DOMAIN_ERROR,
    'email4@example.com': DECODED_DOMAIN_DENYLIST_ERROR,
    'email5@example.com': DECODED_DOMAIN_DENYLIST_ERROR,
    root: DECODED_ALLOWED_DOMAIN_ERROR,
  },
  status: 'error',
};

const EMAIL_TAKEN = {
  message: {
    'email@example.org': "The member's email address has already been taken",
  },
  status: 'error',
};

const INVITE_LIMIT = {
  message: 'Invite limit of 5 per day exceeded.',
  status: 'error',
};

export const GROUPS_INVITATIONS_PATH = '/api/v4/groups/1/invitations';

export const invitationsApiResponse = {
  EMAIL_INVALID,
  ERROR_EMAIL_INVALID,
  EMAIL_RESTRICTED,
  MULTIPLE_RESTRICTED,
  EMAIL_TAKEN,
  EXPANDED_RESTRICTED,
  INVITE_LIMIT,
};

export const IMPORT_PROJECT_MEMBERS_PATH = '/api/v4/projects/1/import_project_members/2';
const EXPANDED_IMPORT_ERRORS = {
  message: {
    bob_smith: 'Something is wrong for this member.',
    john_smith: 'Something is wrong for this member.',
    doug_logan: 'Something is wrong for this member.',
    root: 'Something is wrong for this member.',
  },
  total_members_count: '4',
  status: 'error',
};
const NO_COLLAPSE_IMPORT_ERRORS = {
  message: {
    bob_smith: 'Something is wrong for this member.',
    john_smith: 'Something is wrong for this member.',
  },
  total_members_count: '2',
  status: 'error',
};
export const importProjectMembersApiResponse = {
  EXPANDED_IMPORT_ERRORS,
  NO_COLLAPSE_IMPORT_ERRORS,
};