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

add_extra_tokens_for_merge_requests.js « filtered_search « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1bfbab9ef9666588dd6b15196e14d4ab297696ec (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
import { __ } from '~/locale';

export default IssuableTokenKeys => {
  const draftToken = {
    token: {
      formattedKey: __('Draft'),
      key: 'draft',
      type: 'string',
      param: '',
      symbol: '',
      icon: 'admin',
      tag: __('Yes or No'),
      lowercaseValueOnSubmit: true,
      capitalizeTokenValue: true,
    },
    conditions: [
      {
        url: 'wip=yes',
        // eslint-disable-next-line @gitlab/require-i18n-strings
        replacementUrl: 'draft=yes',
        tokenKey: 'draft',
        value: __('Yes'),
        operator: '=',
      },
      {
        url: 'wip=no',
        // eslint-disable-next-line @gitlab/require-i18n-strings
        replacementUrl: 'draft=no',
        tokenKey: 'draft',
        value: __('No'),
        operator: '=',
      },
      {
        url: 'not[wip]=yes',
        replacementUrl: 'not[draft]=yes',
        tokenKey: 'draft',
        value: __('Yes'),
        operator: '!=',
      },
      {
        url: 'not[wip]=no',
        replacementUrl: 'not[draft]=no',
        tokenKey: 'draft',
        value: __('No'),
        operator: '!=',
      },
    ],
  };

  IssuableTokenKeys.tokenKeys.push(draftToken.token);
  IssuableTokenKeys.tokenKeysWithAlternative.push(draftToken.token);
  IssuableTokenKeys.conditions.push(...draftToken.conditions);

  const targetBranchToken = {
    formattedKey: __('Target-Branch'),
    key: 'target-branch',
    type: 'string',
    param: '',
    symbol: '',
    icon: 'arrow-right',
    tag: 'branch',
  };

  IssuableTokenKeys.tokenKeys.push(targetBranchToken);
  IssuableTokenKeys.tokenKeysWithAlternative.push(targetBranchToken);

  const approvedBy = {
    token: {
      formattedKey: __('Approved-By'),
      key: 'approved-by',
      type: 'array',
      param: 'usernames[]',
      symbol: '@',
      icon: 'approval',
      tag: '@approved-by',
    },
    condition: [
      {
        url: 'approved_by_usernames[]=None',
        tokenKey: 'approved-by',
        value: __('None'),
        operator: '=',
      },
      {
        url: 'not[approved_by_usernames][]=None',
        tokenKey: 'approved-by',
        value: __('None'),
        operator: '!=',
      },
      {
        url: 'approved_by_usernames[]=Any',
        tokenKey: 'approved-by',
        value: __('Any'),
        operator: '=',
      },
      {
        url: 'not[approved_by_usernames][]=Any',
        tokenKey: 'approved-by',
        value: __('Any'),
        operator: '!=',
      },
    ],
  };

  const tokenPosition = 2;
  IssuableTokenKeys.tokenKeys.splice(tokenPosition, 0, ...[approvedBy.token]);
  IssuableTokenKeys.tokenKeysWithAlternative.splice(tokenPosition, 0, ...[approvedBy.token]);
  IssuableTokenKeys.conditions.push(...approvedBy.condition);
};