diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-16 13:42:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-16 13:42:19 +0300 |
commit | 84d1bd786125c1c14a3ba5f63e38a4cc736a9027 (patch) | |
tree | f550fa965f507077e20dbb6d61a8269a99ef7107 /app/assets/javascripts/lib | |
parent | 3a105e36e689f7b75482236712f1a47fd5a76814 (diff) |
Add latest changes from gitlab-org/gitlab@16-8-stable-eev16.8.0-rc42
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/constants.js | 5 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/headers.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/number_utils.js | 45 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/secret_detection.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/text_utility.js | 2 |
6 files changed, 30 insertions, 34 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 674a901aebc..7dc776a1446 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -634,7 +634,7 @@ export const roundDownFloat = (number, precision = 0) => { * Represents navigation type constants of the Performance Navigation API. * Detailed explanation see https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigation. */ -export const NavigationType = { +export const navigationType = { TYPE_NAVIGATE: 0, TYPE_RELOAD: 1, TYPE_BACK_FORWARD: 2, diff --git a/app/assets/javascripts/lib/utils/constants.js b/app/assets/javascripts/lib/utils/constants.js index d9ac0abf7b3..77986539403 100644 --- a/app/assets/javascripts/lib/utils/constants.js +++ b/app/assets/javascripts/lib/utils/constants.js @@ -19,10 +19,5 @@ export const DRAWER_Z_INDEX = 252; export const MIN_USERNAME_LENGTH = 2; -export const BYTES_FORMAT_BYTES = 'B'; -export const BYTES_FORMAT_KIB = 'KiB'; -export const BYTES_FORMAT_MIB = 'MiB'; -export const BYTES_FORMAT_GIB = 'GiB'; - export const DEFAULT_CI_CONFIG_PATH = '.gitlab-ci.yml'; export const CI_CONFIG_PATH_EXTENSION = /(\.gitlab-ci\.yml)/; diff --git a/app/assets/javascripts/lib/utils/headers.js b/app/assets/javascripts/lib/utils/headers.js index 80ae3fb146f..fb635a124d6 100644 --- a/app/assets/javascripts/lib/utils/headers.js +++ b/app/assets/javascripts/lib/utils/headers.js @@ -1,3 +1,3 @@ -export const ContentTypeMultipartFormData = { +export const contentTypeMultipartFormData = { 'Content-Type': 'multipart/form-data', }; diff --git a/app/assets/javascripts/lib/utils/number_utils.js b/app/assets/javascripts/lib/utils/number_utils.js index d17719c0bc0..01c5bc1f1fc 100644 --- a/app/assets/javascripts/lib/utils/number_utils.js +++ b/app/assets/javascripts/lib/utils/number_utils.js @@ -1,12 +1,5 @@ import { sprintf, __ } from '~/locale'; -import { - BYTES_IN_KIB, - THOUSAND, - BYTES_FORMAT_BYTES, - BYTES_FORMAT_KIB, - BYTES_FORMAT_MIB, - BYTES_FORMAT_GIB, -} from './constants'; +import { BYTES_IN_KIB, THOUSAND } from './constants'; /** * Function that allows a number with an X amount of decimals @@ -73,47 +66,47 @@ export function bytesToGiB(number) { /** * Formats the bytes in number into a more understandable * representation. Returns an array with the first value being the human size - * and the second value being the format (e.g., [1.5, 'KiB']). + * and the second value being the label (e.g., [1.5, 'KiB']). * - * @param {Number} size - * @param {Number} digits - The number of digits to appear after the decimal point - * @returns {String} + * @param {number} size + * @param {number} [digits=2] - The number of digits to appear after the decimal point + * @returns {string[]} */ export function numberToHumanSizeSplit(size, digits = 2) { const abs = Math.abs(size); if (abs < BYTES_IN_KIB) { - return [size.toString(), BYTES_FORMAT_BYTES]; + return [size.toString(), __('B')]; } if (abs < BYTES_IN_KIB ** 2) { - return [bytesToKiB(size).toFixed(digits), BYTES_FORMAT_KIB]; + return [bytesToKiB(size).toFixed(digits), __('KiB')]; } if (abs < BYTES_IN_KIB ** 3) { - return [bytesToMiB(size).toFixed(digits), BYTES_FORMAT_MIB]; + return [bytesToMiB(size).toFixed(digits), __('MiB')]; } - return [bytesToGiB(size).toFixed(digits), BYTES_FORMAT_GIB]; + return [bytesToGiB(size).toFixed(digits), __('GiB')]; } /** * Port of rails number_to_human_size * Formats the bytes in number into a more understandable - * representation (e.g., giving it 1500 yields 1.5 KB). + * representation (e.g., giving it 1536 yields 1.5 KiB). * - * @param {Number} size - * @param {Number} digits - The number of digits to appear after the decimal point - * @returns {String} + * @param {number} size + * @param {number} [digits=2] - The number of digits to appear after the decimal point + * @returns {string} */ export function numberToHumanSize(size, digits = 2) { - const [humanSize, format] = numberToHumanSizeSplit(size, digits); + const [humanSize, label] = numberToHumanSizeSplit(size, digits); - switch (format) { - case BYTES_FORMAT_BYTES: + switch (label) { + case __('B'): return sprintf(__('%{size} B'), { size: humanSize }); - case BYTES_FORMAT_KIB: + case __('KiB'): return sprintf(__('%{size} KiB'), { size: humanSize }); - case BYTES_FORMAT_MIB: + case __('MiB'): return sprintf(__('%{size} MiB'), { size: humanSize }); - case BYTES_FORMAT_GIB: + case __('GiB'): return sprintf(__('%{size} GiB'), { size: humanSize }); default: return ''; diff --git a/app/assets/javascripts/lib/utils/secret_detection.js b/app/assets/javascripts/lib/utils/secret_detection.js index 4d8612aeeff..dad4af004cc 100644 --- a/app/assets/javascripts/lib/utils/secret_detection.js +++ b/app/assets/javascripts/lib/utils/secret_detection.js @@ -32,6 +32,14 @@ export const containsSensitiveToken = (message) => { name: 'GitLab Deploy Token', regex: `gldt-[0-9a-zA-Z_-]{20}`, }, + { + name: 'GitLab SCIM OAuth Access Token', + regex: `glsoat-[0-9a-zA-Z_-]{20}`, + }, + { + name: 'GitLab CI Build (Job) Token', + regex: `glcbt-[0-9a-zA-Z]{1,5}_[0-9a-zA-Z_-]{20}`, + }, ]; for (const rule of sensitiveDataPatterns) { diff --git a/app/assets/javascripts/lib/utils/text_utility.js b/app/assets/javascripts/lib/utils/text_utility.js index 6c30294cbbb..b30eba25aa8 100644 --- a/app/assets/javascripts/lib/utils/text_utility.js +++ b/app/assets/javascripts/lib/utils/text_utility.js @@ -173,7 +173,7 @@ export const truncateSha = (sha) => sha.substring(0, 8); * @return {String} */ export function capitalizeFirstCharacter(text) { - return `${text[0].toUpperCase()}${text.slice(1)}`; + return text?.length ? `${text[0].toUpperCase()}${text.slice(1)}` : ''; } /** |