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

100% Statements 29/29
100% Branches 0/0
100% Functions 3/3
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203                23x             23x               23x                                                                     92x   23x   23x     23x   23x         23x 46x 23x 23x 23x 23x 23x 23x 23x   23x                   23x                                                                                                                                   23x             23x                             23x                   23x 303x               23x 23x 23x  
import { n__, s__, __ } from '~/locale';
import { OPERATORS_IS } from '~/vue_shared/components/filtered_search_bar/constants';
import { helpPagePath } from '~/helpers/help_page_helper';
import GroupToken from './components/tokens/group_token.vue';
import MemberToken from './components/tokens/member_token.vue';
import ProjectToken from './components/tokens/project_token.vue';
import UserToken from './components/tokens/user_token.vue';
 
const DEFAULT_TOKEN_OPTIONS = {
  operators: OPERATORS_IS,
  unique: true,
};
 
// Due to the i18n eslint rule we can't have a capitalized string even if it is a case-aware URL param
/* eslint-disable @gitlab/require-i18n-strings */
export const ENTITY_TYPES = {
  USER: 'User',
  AUTHOR: 'Author',
  GROUP: 'Group',
  PROJECT: 'Project',
};
/* eslint-enable @gitlab/require-i18n-strings */
 
export const AUDIT_FILTER_CONFIGS = [
  {
    ...DEFAULT_TOKEN_OPTIONS,
    icon: 'user',
    title: s__('AuditLogs|User Events'),
    type: 'user',
    entityType: ENTITY_TYPES.USER,
    token: UserToken,
  },
  {
    ...DEFAULT_TOKEN_OPTIONS,
    icon: 'user',
    title: s__('AuditLogs|Member Events'),
    type: 'member',
    entityType: ENTITY_TYPES.AUTHOR,
    token: MemberToken,
  },
  {
    ...DEFAULT_TOKEN_OPTIONS,
    icon: 'bookmark',
    title: s__('AuditLogs|Project Events'),
    type: 'project',
    entityType: ENTITY_TYPES.PROJECT,
    token: ProjectToken,
  },
  {
    ...DEFAULT_TOKEN_OPTIONS,
    icon: 'group',
    title: s__('AuditLogs|Group Events'),
    type: 'group',
    entityType: ENTITY_TYPES.GROUP,
    token: GroupToken,
  },
];
 
export const AVAILABLE_TOKEN_TYPES = AUDIT_FILTER_CONFIGS.map((token) => token.type);
 
export const MAX_DATE_RANGE = 31;
 
export const SAME_DAY_OFFSET = 1;
 
// This creates a date with zero time, making it simpler to match to the query date values
export const CURRENT_DATE = new Date(new Date().toDateString());
 
export const AUDIT_EVENTS_TAB_TITLES = {
  LOG: s__('AuditLogs|Log'),
  STREAM: s__('AuditStreams|Streams'),
};
 
export const streamsLabel = (count) =>
  n__('AuditStreams|%d destination', 'AuditStreams|%d destinations', count);
export const ADD_STREAM = s__('AuditStreams|Add streaming destination');
export const ADD_HTTP = s__('AuditStreams|HTTP endpoint');
export const ADD_GCP_LOGGING = s__('AuditStreams|Google Cloud Logging');
export const ADD_AMAZON_S3 = s__('AuditStreams|AWS S3');
export const ADD_STREAM_MESSAGE = s__('AuditStreams|Stream added successfully');
export const UPDATE_STREAM_MESSAGE = s__('AuditStreams|Stream updated successfully');
export const DELETE_STREAM_MESSAGE = s__('AuditStreams|Stream deleted successfully');
 
export const STREAM_ITEMS_I18N = {
  FILTER_TOOLTIP_LABEL: s__(
    'AuditStreams|Destination has filters applied. %{linkStart}What are filters?%{linkEnd}',
  ),
  FILTER_TOOLTIP_LINK: helpPagePath('administration/audit_event_streaming', {
    anchor: 'event-type-filters',
  }),
  FILTER_BADGE_LABEL: s__('AuditStreams|filtered'),
};
 
export const ADD_STREAM_EDITOR_I18N = {
  WARNING_TITLE: s__('AuditStreams|Destinations receive all audit event data'),
  WARNING_CONTENT: s__(
    'AuditStreams|This could include sensitive information. Make sure you trust the destination endpoint.',
  ),
  DESTINATION_URL_LABEL: s__('AuditStreams|Destination URL'),
  DESTINATION_URL_PLACEHOLDER: 'https://api.gitlab.com',
  DESTINATION_NAME_LABEL: s__('AuditStreams|Destination Name'),
  VERIFICATION_TOKEN_LABEL: s__('AuditStreams|Verification token'),
  HEADERS_LABEL: s__('AuditStreams|Custom HTTP headers (optional)'),
  TABLE_COLUMN_NAME_LABEL: s__('AuditStreams|Header'),
  TABLE_COLUMN_VALUE_LABEL: s__('AuditStreams|Value'),
  TABLE_COLUMN_ACTIVE_LABEL: s__('AuditStreams|Active'),
  HEADER_INPUT_PLACEHOLDER: s__('AuditStreams|ex: limitation'),
  HEADER_INPUT_DUPLICATE_ERROR: s__('AuditStreams|A header with this name already exists.'),
  VALUE_INPUT_PLACEHOLDER: s__('AuditStreams|ex: 1000'),
  ADD_HEADER_ROW_BUTTON_TEXT: s__('AuditStreams|Add header'),
  ADD_HEADER_ROW_BUTTON_NAME: s__('AuditStreams|Add another custom header'),
  NO_HEADER_CREATED_TEXT: s__('AuditStreams|No header created yet.'),
  MAXIMUM_HEADERS_TEXT: s__('AuditStreams|Maximum of %{number} HTTP headers has been reached.'),
  REMOVE_BUTTON_LABEL: s__('AuditStreams|Remove custom header'),
  REMOVE_BUTTON_TOOLTIP: __('Remove'),
  ADD_BUTTON_TEXT: __('Add'),
  ADD_BUTTON_NAME: s__('AuditStreams|Add external stream destination'),
  SAVE_BUTTON_TEXT: __('Save'),
  SAVE_BUTTON_NAME: s__('AuditStreams|Save external stream destination'),
  CANCEL_BUTTON_TEXT: __('Cancel'),
  CANCEL_BUTTON_NAME: s__('AuditStreams|Cancel editing'),
  DELETE_BUTTON_TEXT: s__('AuditStreams|Delete destination'),
  HEADER_FILTERING: s__('AuditStreams|Event filtering (optional)'),
  FILTER_BY_AUDIT_EVENT_TYPE: s__('AuditStreams|Filter by audit event type'),
  FILTER_BY_NAMESPACE: s__('AuditStreams|Filter by groups or projects'),
  GCP_LOGGING_DESTINATION_NAME_LABEL: s__('AuditStreams|Destination Name'),
  GCP_LOGGING_DESTINATION_NAME_PLACEHOLDER: s__('AuditStreams|Destination Name'),
  GCP_LOGGING_DESTINATION_PROJECT_ID_LABEL: s__('AuditStreams|Project ID'),
  GCP_LOGGING_DESTINATION_PROJECT_ID_PLACEHOLDER: s__('AuditStreams|my-google-project'),
  GCP_LOGGING_DESTINATION_CLIENT_EMAIL_LABEL: s__('AuditStreams|Client Email'),
  GCP_LOGGING_DESTINATION_CLIENT_EMAIL_PLACEHOLDER: s__(
    'AuditStreams|my-email@my-google-project.iam.gservice.account.com',
  ),
  GCP_LOGGING_DESTINATION_LOG_ID_LABEL: s__('AuditStreams|Log ID'),
  GCP_LOGGING_DESTINATION_LOG_ID_PLACEHOLDER: s__('AuditStreams|audit-events'),
  GCP_LOGGING_DESTINATION_PASSWORD_LABEL: s__('AuditStreams|Private key'),
  GCP_LOGGING_DESTINATION_PASSWORD_SUBTEXT: s__(
    'AuditStreams|Use the Google Cloud console to view the private key. To change the private key, replace it with a new private key.',
  ),
  GCP_LOGGING_DESTINATION_PASSWORD_SUBTEXT_ADD_BUTTON: s__('AuditStreams|Add a new private key'),
 
  AMAZON_S3_DESTINATION_NAME_LABEL: s__('AuditStreams|Destination Name'),
  AMAZON_S3_DESTINATION_NAME_PLACEHOLDER: s__('AuditStreams|Destination Name'),
  AMAZON_S3_DESTINATION_ACCESS_KEY_XID_LABEL: s__('AuditStreams|Access Key ID'),
  AMAZON_S3_DESTINATION_ACCESS_KEY_XID_PLACEHOLDER: s__('AuditStreams|AKIA1231dsdsdsdsds23'),
  AMAZON_S3_DESTINATION_AWS_REGION_LABEL: s__('AuditStreams|AWS Region'),
  AMAZON_S3_DESTINATION_AWS_REGION_PLACEHOLDER: s__('AuditStreams|us-east-1'),
  AMAZON_S3_DESTINATION_BUCKET_NAME_LABEL: s__('AuditStreams|Bucket Name'),
  AMAZON_S3_DESTINATION_BUCKET_NAME_PLACEHOLDER: s__('AuditStreams|bucket-name'),
  AMAZON_S3_DESTINATION_SECRET_ACCESS_KEY_LABEL: s__('AuditStreams|Secret Access Key'),
 
  AMAZON_S3_DESTINATION_SECRET_ACCESS_KEY_SUBTEXT: s__(
    'AuditStreams|Use the AWS console to view the secret access key. To change the secret access key, replace it with a new secret access key.',
  ),
  AMAZON_S3_DESTINATION_SECRET_ACCESS_KEY_SUBTEXT_ADD_BUTTON: s__(
    'AuditStreams|Add a new secret access key',
  ),
};
 
export const AUDIT_STREAMS_EMPTY_STATE_I18N = {
  TITLE: s__('AuditStreams|Setup streaming for audit events'),
  DESCRIPTION: s__(
    'AuditStreams|Add an HTTP endpoint to manage audit logs in third-party systems. This is great for keeping everything in one place.',
  ),
};
 
export const AUDIT_STREAMS_NETWORK_ERRORS = {
  FETCHING_ERROR: s__(
    'AuditStreams|An error occurred when fetching external audit event streams. Please try it again',
  ),
  CREATING_ERROR: s__(
    'AuditStreams|An error occurred when creating external audit event stream destination. Please try it again.',
  ),
  UPDATING_ERROR: s__(
    'AuditStreams|An error occurred when updating external audit event stream destination. Please try it again.',
  ),
  DELETING_ERROR: s__(
    'AuditStreams|An error occurred when deleting external audit event stream destination. Please try it again.',
  ),
};
 
export const AUDIT_STREAMS_FILTERING = {
  SELECT_EVENTS: s__('AuditStreams|Select events'),
  SELECT_PROJECTS: s__('AuditStreams|Select projects'),
  SELECT_NAMESPACE: s__('AuditStreams|Select namespace'),
  SELECT_ALL: __('Select all'),
  UNSELECT_ALL: __('Unselect all'),
  NO_RESULT_TEXT: __('No results found'),
  SEARCH_PLACEHOLDER: __('Search'),
};
 
export const MAX_HEADERS = 20;
export const createBlankHeader = () => ({
  id: null,
  name: '',
  value: '',
  active: true,
  validationErrors: { name: '' },
});
 
export const DESTINATION_TYPE_HTTP = 'http';
export const DESTINATION_TYPE_GCP_LOGGING = 'gcpLogging';
export const DESTINATION_TYPE_AMAZON_S3 = 'amazonS3';