All files / ee/app/assets/javascripts/approvals constants.js

100% Statements 27/27
100% Branches 0/0
100% Functions 0/0
100% Lines 27/27

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 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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180    43x 43x 43x   43x 43x         43x 43x 43x 43x 43x 43x   43x 43x 43x   43x 43x 43x   43x                                                     43x   43x                                       43x                           43x             43x                                                                                                             43x               43x 43x           43x                        
import { __, s__ } from '~/locale';
 
export const TYPE_USER = 'user';
export const TYPE_GROUP = 'group';
export const TYPE_HIDDEN_GROUPS = 'hidden_groups';
 
export const BRANCH_FETCH_DELAY = 250;
export const ALL_BRANCHES = {
  id: null,
  name: __('All branches'),
};
 
export const RULE_TYPE_FALLBACK = 'fallback';
export const RULE_TYPE_REGULAR = 'regular';
export const RULE_TYPE_REPORT_APPROVER = 'report_approver';
export const RULE_TYPE_CODE_OWNER = 'code_owner';
export const RULE_TYPE_ANY_APPROVER = 'any_approver';
export const RULE_NAME_ANY_APPROVER = 'All Members';
 
export const VULNERABILITY_CHECK_NAME = 'Vulnerability-Check';
export const LICENSE_CHECK_NAME = 'License-Check';
export const COVERAGE_CHECK_NAME = 'Coverage-Check';
 
export const REPORT_TYPE_LICENSE_SCANNING = 'license_scanning';
export const REPORT_TYPE_VULNERABILITY = 'vulnerability';
export const REPORT_TYPE_CODE_COVERAGE = 'code_coverage';
 
export const APPROVAL_RULE_CONFIGS = {
  [VULNERABILITY_CHECK_NAME]: {
    title: s__('SecurityApprovals|Vulnerability-Check'),
    popoverText: s__(
      'SecurityApprovals|A merge request approval is required when a security report contains a new vulnerability.',
    ),
    documentationText: s__('SecurityApprovals|Learn more about Vulnerability-Check'),
    reportType: REPORT_TYPE_VULNERABILITY,
  },
  [LICENSE_CHECK_NAME]: {
    title: s__('SecurityApprovals|License-Check'),
    popoverText: s__(
      'SecurityApprovals|A merge request approval is required when the license compliance report contains a denied license.',
    ),
    documentationText: s__('SecurityApprovals|Learn more about License-Check'),
    reportType: REPORT_TYPE_LICENSE_SCANNING,
  },
  [COVERAGE_CHECK_NAME]: {
    title: s__('SecurityApprovals|Coverage-Check'),
    popoverText: s__(
      'SecurityApprovals|A merge request approval is required when test coverage declines.',
    ),
    documentationText: s__('SecurityApprovals|Learn more about Coverage-Check'),
    reportType: REPORT_TYPE_CODE_COVERAGE,
  },
};
 
export const APPROVALS_HELP_PATH = 'user/project/merge_requests/approvals/settings';
 
export const APPROVAL_SETTINGS_I18N = {
  learnMore: __('Learn more.'),
  approvalSettingsHeader: __('Approval settings'),
  approvalSettingsDescription: __('Define how approval rules are applied to merge requests.'),
  saveChanges: __('Save changes'),
  loadingErrorMessage: s__(
    'ApprovalSettings|There was an error loading merge request approval settings.',
  ),
  savingErrorMessage: s__(
    'ApprovalSettings|There was an error updating merge request approval settings.',
  ),
  savingSuccessMessage: s__('ApprovalSettings|Merge request approval settings have been updated.'),
  lockedByAdmin: s__(
    'ApprovalSettings|This setting is configured at the instance level and can only be changed by an administrator.',
  ),
  lockedByGroupOwner: s__(
    'ApprovalSettings|This setting is configured in %{groupName} and can only be changed in the group settings by an administrator or group owner.',
  ),
};
 
export const PROJECT_APPROVAL_SETTINGS_LABELS_I18N = {
  authorApprovalLabel: s__('ApprovalSettings|Prevent approval by author'),
  preventMrApprovalRuleEditLabel: s__(
    'ApprovalSettings|Prevent editing approval rules in merge requests',
  ),
  preventCommittersApprovalLabel: s__(
    'ApprovalSettings|Prevent approvals by users who add commits',
  ),
  requireUserPasswordLabel: s__('ApprovalSettings|Require user password to approve'),
  removeApprovalsOnPushLabel: s__(
    'ApprovalSettings|Remove all approvals when commits are added to the source branch',
  ),
};
 
export const GROUP_APPROVAL_SETTINGS_LABELS_I18N = {
  ...PROJECT_APPROVAL_SETTINGS_LABELS_I18N,
  preventMrApprovalRuleEditLabel: s__(
    'ApprovalSettings|Prevent editing approval rules in projects and merge requests.',
  ),
};
 
export const APPROVAL_DIALOG_I18N = {
  form: {
    approvalsRequiredLabel: s__('ApprovalRule|Approvals required'),
    approvalTypeLabel: s__('ApprovalRule|Approver Type'),
    approversLabel: s__('ApprovalRule|Add approvers'),
    nameLabel: s__('ApprovalRule|Rule name'),
    nameDescription: s__('ApprovalRule|Examples: QA, Security.'),
    protectedBranchLabel: s__('ApprovalRule|Target branch'),
    protectedBranchDescription: __(
      'Apply this approval rule to all branches or a specific protected branch.',
    ),
    scannersLabel: s__('ApprovalRule|Security scanners'),
    scannersSelectLabel: s__('ApprovalRule|Select scanners'),
    scannersDescription: s__(
      'ApprovalRule|Apply this approval rule to consider only the selected security scanners.',
    ),
    selectAllLabel: s__('ApprovalRule|Select All'),
    allScannersSelectedLabel: s__('ApprovalRule|All scanners'),
    multipleSelectedLabel: s__('ApprovalRule|%{firstLabel} +%{numberOfAdditionalLabels} more'),
    vulnerabilitiesAllowedLabel: s__('ApprovalRule|Vulnerabilities allowed'),
    vulnerabilitiesAllowedDescription: s__(
      'ApprovalRule|Number of vulnerabilities allowed before approval rule is triggered.',
    ),
    vulnerabilityStatesLabel: s__('ApprovalRule|Vulnerability states'),
    vulnerabilityStatesDescription: s__(
      'ApprovalRule|Apply this approval rule to consider only the selected vulnerability states.',
    ),
    vulnerabilityStatesSelectLabel: s__('ApprovalRule|Select vulnerability states'),
    allVulnerabilityStatesSelectedLabel: s__('ApprovalRule|All vulnerability states'),
    severityLevelsLabel: s__('ApprovalRule|Severity levels'),
    severityLevelsDescription: s__(
      'ApprovalRule|Apply this approval rule to consider only the selected severity levels.',
    ),
    severityLevelsSelectLabel: s__('ApprovalRule|Select severity levels'),
    allSeverityLevelsSelectedLabel: s__('ApprovalRule|All severity levels'),
  },
  validations: {
    approvalsRequiredNegativeNumber: __('Please enter a non-negative number'),
    approvalsRequiredNotNumber: __('Please enter a valid number'),
    approvalsRequiredMinimum: __(
      'Please enter a number greater than %{number} (from the project settings)',
    ),
    approversRequired: __('Please select and add a member'),
    branchesRequired: __('Please select a valid target branch'),
    ruleNameTaken: __('Rule name is already taken.'),
    ruleNameMissing: __('Please provide a name'),
    scannersRequired: s__('ApprovalRule|Please select at least one security scanner'),
    vulnerabilitiesAllowedMinimum: s__(
      'ApprovalRule|Please enter a number equal or greater than zero',
    ),
    severityLevelsRequired: s__('ApprovalRule|Please select at least one severity level'),
    vulnerabilityStatesRequired: s__('ApprovalRule|Please select at least one vulnerability state'),
  },
};
 
export const APPROVAL_VULNERABILITY_STATES = {
  newly_detected: s__('ApprovalRule|Newly detected'),
  detected: s__('ApprovalRule|Previously detected'),
  confirmed: s__('ApprovalRule|Confirmed'),
  dismissed: s__('ApprovalRule|Dismissed'),
  resolved: s__('ApprovalRule|Resolved'),
};
 
export const MR_APPROVALS_PROMO_DISMISSED = 'mr_approvals_promo.dismissed';
export const MR_APPROVALS_PROMO_TRACKING_EVENTS = {
  learnMoreClick: { action: 'click_link', label: 'learn_more_merge_approval' },
  tryNowClick: { action: 'click_button', label: 'start_trial' },
  collapsePromo: { action: 'click_button', label: 'collapse_approval_rules' },
  expandPromo: { action: 'click_button', label: 'expand_approval_rules' },
};
export const MR_APPROVALS_PROMO_I18N = {
  accordionTitle: s__('ApprovalRule|Approval rules'),
  learnMore: s__('ApprovalRule|Learn more about merge request approval rules.'),
  promoTitle: s__("ApprovalRule|Improve your organization's code review with required approvals."),
  summary: __('Approvals are optional.'),
  tryNow: s__('ApprovalRule|Try for free'),
  valueStatements: [
    s__('ApprovalRule|Select eligible approvers by expertise or files changed.'),
    s__('ApprovalRule|Increase quality and maintain standards.'),
    s__('ApprovalRule|Reduce your time to merge.'),
  ],
};