summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/lib/utils')
-rw-r--r--app/assets/javascripts/lib/utils/confirm_via_gl_modal/confirm_modal.vue32
-rw-r--r--app/assets/javascripts/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal.js12
-rw-r--r--app/assets/javascripts/lib/utils/css_utils.js4
-rw-r--r--app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js14
-rw-r--r--app/assets/javascripts/lib/utils/datetime/date_format_utility.js22
-rw-r--r--app/assets/javascripts/lib/utils/datetime/timeago_utility.js48
-rw-r--r--app/assets/javascripts/lib/utils/text_markdown.js11
-rw-r--r--app/assets/javascripts/lib/utils/unit_format/formatter_factory.js52
-rw-r--r--app/assets/javascripts/lib/utils/unit_format/index.js108
-rw-r--r--app/assets/javascripts/lib/utils/webpack.js2
10 files changed, 259 insertions, 46 deletions
diff --git a/app/assets/javascripts/lib/utils/confirm_via_gl_modal/confirm_modal.vue b/app/assets/javascripts/lib/utils/confirm_via_gl_modal/confirm_modal.vue
index f3380b7b4ba..1d8eb73d3d7 100644
--- a/app/assets/javascripts/lib/utils/confirm_via_gl_modal/confirm_modal.vue
+++ b/app/assets/javascripts/lib/utils/confirm_via_gl_modal/confirm_modal.vue
@@ -26,6 +26,16 @@ export default {
required: false,
default: 'confirm',
},
+ secondaryText: {
+ type: String,
+ required: false,
+ default: '',
+ },
+ secondaryVariant: {
+ type: String,
+ required: false,
+ default: 'confirm',
+ },
modalHtmlMessage: {
type: String,
required: false,
@@ -39,7 +49,26 @@ export default {
},
computed: {
primaryAction() {
- return { text: this.primaryText, attributes: { variant: this.primaryVariant } };
+ return {
+ text: this.primaryText,
+ attributes: {
+ variant: this.primaryVariant,
+ 'data-qa-selector': 'confirm_ok_button',
+ },
+ };
+ },
+ secondaryAction() {
+ if (!this.secondaryText) {
+ return null;
+ }
+
+ return {
+ text: this.secondaryText,
+ attributes: {
+ variant: this.secondaryVariant,
+ category: 'secondary',
+ },
+ };
},
cancelAction() {
return this.hideCancel ? null : this.$options.cancelAction;
@@ -63,6 +92,7 @@ export default {
:title="title"
:action-primary="primaryAction"
:action-cancel="cancelAction"
+ :action-secondary="secondaryAction"
:hide-header="!shouldShowHeader"
@primary="$emit('confirmed')"
@hidden="$emit('closed')"
diff --git a/app/assets/javascripts/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal.js b/app/assets/javascripts/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal.js
index a8a89d0644a..1adb6f9c26f 100644
--- a/app/assets/javascripts/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal.js
+++ b/app/assets/javascripts/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal.js
@@ -2,7 +2,15 @@ import Vue from 'vue';
export function confirmAction(
message,
- { primaryBtnVariant, primaryBtnText, modalHtmlMessage, title, hideCancel } = {},
+ {
+ primaryBtnVariant,
+ primaryBtnText,
+ secondaryBtnVariant,
+ secondaryBtnText,
+ modalHtmlMessage,
+ title,
+ hideCancel,
+ } = {},
) {
return new Promise((resolve) => {
let confirmed = false;
@@ -16,6 +24,8 @@ export function confirmAction(
'confirm-modal',
{
props: {
+ secondaryText: secondaryBtnText,
+ secondaryVariant: secondaryBtnVariant,
primaryVariant: primaryBtnVariant,
primaryText: primaryBtnText,
title,
diff --git a/app/assets/javascripts/lib/utils/css_utils.js b/app/assets/javascripts/lib/utils/css_utils.js
index 76ac442a470..e4f68dd1b6c 100644
--- a/app/assets/javascripts/lib/utils/css_utils.js
+++ b/app/assets/javascripts/lib/utils/css_utils.js
@@ -19,3 +19,7 @@ export function loadCSSFile(path) {
}
});
}
+
+export function getCssVariable(variable) {
+ return getComputedStyle(document.documentElement).getPropertyValue(variable).trim();
+}
diff --git a/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js b/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js
index 396c1703c1e..4e7086e62c5 100644
--- a/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js
+++ b/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js
@@ -1,5 +1,5 @@
import { isNumber } from 'lodash';
-import { __, n__ } from '../../../locale';
+import { __, n__ } from '~/locale';
import { getDayName, parseSeconds } from './date_format_utility';
const DAYS_IN_WEEK = 7;
@@ -189,13 +189,21 @@ export const getDateInFuture = (date, daysInFuture) =>
*/
export const isValidDate = (date) => date instanceof Date && !Number.isNaN(date.getTime());
-/*
+/**
* Appending T00:00:00 makes JS assume local time and prevents it from shifting the date
* to match the user's time zone. We want to display the date in server time for now, to
* be consistent with the "edit issue -> due date" UI.
+ *
+ * @param {String} date Date without time, e.g. `2022-03-22`
+ * @return {Date} new Date object
*/
-
export const newDateAsLocaleTime = (date) => {
+ if (!date || typeof date !== 'string') {
+ return null;
+ }
+ if (date.includes('T')) {
+ return new Date(date);
+ }
const suffix = 'T00:00:00';
return new Date(`${date}${suffix}`);
};
diff --git a/app/assets/javascripts/lib/utils/datetime/date_format_utility.js b/app/assets/javascripts/lib/utils/datetime/date_format_utility.js
index 7bff2bf3e47..830f4604382 100644
--- a/app/assets/javascripts/lib/utils/datetime/date_format_utility.js
+++ b/app/assets/javascripts/lib/utils/datetime/date_format_utility.js
@@ -2,7 +2,7 @@ import dateFormat from 'dateformat';
import { isString, mapValues, reduce, isDate, unescape } from 'lodash';
import { roundToNearestHalf } from '~/lib/utils/common_utils';
import { sanitize } from '~/lib/dompurify';
-import { s__, n__, __, sprintf } from '../../../locale';
+import { s__, n__, __, sprintf } from '~/locale';
/**
* Returns i18n month names array.
@@ -386,3 +386,23 @@ export const formatTimeAsSummary = ({ seconds, hours, days, minutes, weeks, mont
}
return '-';
};
+
+export const durationTimeFormatted = (duration) => {
+ const date = new Date(duration * 1000);
+
+ let hh = date.getUTCHours();
+ let mm = date.getUTCMinutes();
+ let ss = date.getSeconds();
+
+ if (hh < 10) {
+ hh = `0${hh}`;
+ }
+ if (mm < 10) {
+ mm = `0${mm}`;
+ }
+ if (ss < 10) {
+ ss = `0${ss}`;
+ }
+
+ return `${hh}:${mm}:${ss}`;
+};
diff --git a/app/assets/javascripts/lib/utils/datetime/timeago_utility.js b/app/assets/javascripts/lib/utils/datetime/timeago_utility.js
index d68682ebed1..095a29a2eff 100644
--- a/app/assets/javascripts/lib/utils/datetime/timeago_utility.js
+++ b/app/assets/javascripts/lib/utils/datetime/timeago_utility.js
@@ -1,5 +1,5 @@
import * as timeago from 'timeago.js';
-import { languageCode, s__, createDateTimeFormat } from '../../../locale';
+import { languageCode, s__, createDateTimeFormat } from '~/locale';
import { formatDate } from './date_format_utility';
/**
@@ -70,8 +70,41 @@ const memoizedLocale = () => {
};
};
+/**
+ * Registers timeago time duration
+ */
+const memoizedLocaleDuration = () => {
+ const cache = [];
+
+ const durations = [
+ () => [s__('Duration|%s seconds')],
+ () => [s__('Duration|%s seconds')],
+ () => [s__('Duration|1 minute')],
+ () => [s__('Duration|%s minutes')],
+ () => [s__('Duration|1 hour')],
+ () => [s__('Duration|%s hours')],
+ () => [s__('Duration|1 day')],
+ () => [s__('Duration|%s days')],
+ () => [s__('Duration|1 week')],
+ () => [s__('Duration|%s weeks')],
+ () => [s__('Duration|1 month')],
+ () => [s__('Duration|%s months')],
+ () => [s__('Duration|1 year')],
+ () => [s__('Duration|%s years')],
+ ];
+
+ return (_, index) => {
+ if (cache[index]) {
+ return cache[index];
+ }
+ cache[index] = durations[index] && durations[index]();
+ return cache[index];
+ };
+};
+
timeago.register(timeagoLanguageCode, memoizedLocale());
timeago.register(`${timeagoLanguageCode}-remaining`, memoizedLocaleRemaining());
+timeago.register(`${timeagoLanguageCode}-duration`, memoizedLocaleDuration());
let memoizedFormatter = null;
@@ -133,3 +166,16 @@ export const timeFor = (time, expiredLabel) => {
}
return timeago.format(time, `${timeagoLanguageCode}-remaining`).trim();
};
+
+/**
+ * Returns a duration of time given an amount.
+ *
+ * @param {number} milliseconds - Duration in milliseconds.
+ * @returns {string} A formatted duration, e.g. "10 minutes".
+ */
+export const duration = (milliseconds) => {
+ const now = new Date();
+ return timeago
+ .format(now.getTime() - Math.abs(milliseconds), `${timeagoLanguageCode}-duration`)
+ .trim();
+};
diff --git a/app/assets/javascripts/lib/utils/text_markdown.js b/app/assets/javascripts/lib/utils/text_markdown.js
index ac2eb34260c..52fa90c7791 100644
--- a/app/assets/javascripts/lib/utils/text_markdown.js
+++ b/app/assets/javascripts/lib/utils/text_markdown.js
@@ -9,7 +9,10 @@ const LINK_TAG_PATTERN = '[{text}](url)';
// a bullet point character (*+-) and an optional checkbox ([ ] [x])
// OR a number with a . after it and an optional checkbox ([ ] [x])
// followed by one or more whitespace characters
-const LIST_LINE_HEAD_PATTERN = /^(?<indent>\s*)(?<leader>((?<isUl>[*+-])|(?<isOl>\d+\.))( \[([x ])\])?\s)(?<content>.)?/;
+const LIST_LINE_HEAD_PATTERN = /^(?<indent>\s*)(?<leader>((?<isUl>[*+-])|(?<isOl>\d+\.))( \[([xX\s])\])?\s)(?<content>.)?/;
+
+// detect a horizontal rule that might be mistaken for a list item (not full pattern for an <hr>)
+const HR_PATTERN = /^((\s{0,3}-+\s*-+\s*-+\s*[\s-]*)|(\s{0,3}\*+\s*\*+\s*\*+\s*[\s*]*))$/;
function selectedText(text, textarea) {
return text.substring(textarea.selectionStart, textarea.selectionEnd);
@@ -381,16 +384,20 @@ function handleContinueList(e, textArea) {
let itemToInsert;
+ // Behaviors specific to either `ol` or `ul`
if (isOl) {
const nextLine = lineAfter(textArea.value, textArea, false);
const nextLineResult = nextLine.match(LIST_LINE_HEAD_PATTERN);
itemToInsert = continueOlText(result, nextLineResult);
} else {
- // isUl
+ if (currentLine.match(HR_PATTERN)) return;
+
itemToInsert = `${indent}${leader}`;
}
+ itemToInsert = itemToInsert.replace(/\[x\]/i, '[ ]');
+
e.preventDefault();
updateText({
diff --git a/app/assets/javascripts/lib/utils/unit_format/formatter_factory.js b/app/assets/javascripts/lib/utils/unit_format/formatter_factory.js
index 418cc69bf5a..08c32944181 100644
--- a/app/assets/javascripts/lib/utils/unit_format/formatter_factory.js
+++ b/app/assets/javascripts/lib/utils/unit_format/formatter_factory.js
@@ -5,7 +5,7 @@ import { formatNumber } from '~/locale';
*
* @param {Number} number to be converted
*
- * @param {options.maxCharLength} Max output char length at the
+ * @param {options.maxLength} Max output char length at the
* expense of precision, if the output is longer than this,
* the formatter switches to using exponential notation.
*
@@ -16,10 +16,10 @@ import { formatNumber } from '~/locale';
* `formatNumber` such as `valueFactor`, `unit` and `style`.
*
*/
-const formatNumberNormalized = (value, { maxCharLength, valueFactor = 1, ...options }) => {
+const formatNumberNormalized = (value, { maxLength, valueFactor = 1, ...options }) => {
const formatted = formatNumber(value * valueFactor, options);
- if (maxCharLength !== undefined && formatted.length > maxCharLength) {
+ if (maxLength !== undefined && formatted.length > maxLength) {
// 123456 becomes 1.23e+8
return value.toExponential(2);
}
@@ -27,6 +27,25 @@ const formatNumberNormalized = (value, { maxCharLength, valueFactor = 1, ...opti
};
/**
+ * This function converts the old positional arguments into an options
+ * object.
+ *
+ * This is done so we can support legacy fractionDigits and maxLength as positional
+ * arguments, as well as the better options object.
+ *
+ * @param {Object|Number} options
+ * @returns {Object} options given to the formatter
+ */
+const getFormatterArguments = (options) => {
+ if (typeof options === 'object' && options !== null) {
+ return options;
+ }
+ return {
+ maxLength: options,
+ };
+};
+
+/**
* Formats a number as a string scaling it up according to units.
*
* While the number is scaled down, the units are scaled up.
@@ -40,7 +59,9 @@ const scaledFormatter = (units, unitFactor = 1000) => {
return new RangeError(`unitFactor cannot have the value 0.`);
}
- return (value, fractionDigits) => {
+ return (value, fractionDigits, options) => {
+ const { maxLength, unitSeparator = '' } = getFormatterArguments(options);
+
if (value === null) {
return '';
}
@@ -66,11 +87,13 @@ const scaledFormatter = (units, unitFactor = 1000) => {
}
const unit = units[scale];
+ const length = maxLength !== undefined ? maxLength - unit.length : undefined;
return `${formatNumberNormalized(num, {
+ maxLength: length,
maximumFractionDigits: fractionDigits,
minimumFractionDigits: fractionDigits,
- })}${unit}`;
+ })}${unitSeparator}${unit}`;
};
};
@@ -78,14 +101,16 @@ const scaledFormatter = (units, unitFactor = 1000) => {
* Returns a function that formats a number as a string.
*/
export const numberFormatter = (style = 'decimal', valueFactor = 1) => {
- return (value, fractionDigits, maxCharLength) => {
- return `${formatNumberNormalized(value, {
- maxCharLength,
+ return (value, fractionDigits, options) => {
+ const { maxLength } = getFormatterArguments(options);
+
+ return formatNumberNormalized(value, {
+ maxLength,
valueFactor,
style,
maximumFractionDigits: fractionDigits,
minimumFractionDigits: fractionDigits,
- })}`;
+ });
};
};
@@ -93,15 +118,16 @@ export const numberFormatter = (style = 'decimal', valueFactor = 1) => {
* Returns a function that formats a number as a string with a suffix.
*/
export const suffixFormatter = (unit = '', valueFactor = 1) => {
- return (value, fractionDigits, maxCharLength) => {
- const length = maxCharLength !== undefined ? maxCharLength - unit.length : undefined;
+ return (value, fractionDigits, options) => {
+ const { maxLength, unitSeparator = '' } = getFormatterArguments(options);
+ const length = maxLength !== undefined ? maxLength - unit.length : undefined;
return `${formatNumberNormalized(value, {
- maxCharLength: length,
+ maxLength: length,
valueFactor,
maximumFractionDigits: fractionDigits,
minimumFractionDigits: fractionDigits,
- })}${unit}`;
+ })}${unitSeparator}${unit}`;
};
};
diff --git a/app/assets/javascripts/lib/utils/unit_format/index.js b/app/assets/javascripts/lib/utils/unit_format/index.js
index bc82c6aa74d..5c5210027e4 100644
--- a/app/assets/javascripts/lib/utils/unit_format/index.js
+++ b/app/assets/javascripts/lib/utils/unit_format/index.js
@@ -126,9 +126,11 @@ export const getFormatter = (format = SUPPORTED_FORMATS.engineering) => {
*
* @function
* @param {Number} value - Number to format
- * @param {Number} fractionDigits - precision decimals
- * @param {Number} maxLength - Max length of formatted number
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
* if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const number = getFormatter(SUPPORTED_FORMATS.number);
@@ -137,9 +139,11 @@ export const number = getFormatter(SUPPORTED_FORMATS.number);
*
* @function
* @param {Number} value - Number to format, `1` is rendered as `100%`
- * @param {Number} fractionDigits - number of precision decimals
- * @param {Number} maxLength - Max length of formatted number
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
* if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const percent = getFormatter(SUPPORTED_FORMATS.percent);
@@ -148,9 +152,11 @@ export const percent = getFormatter(SUPPORTED_FORMATS.percent);
*
* @function
* @param {Number} value - Number to format, `100` is rendered as `100%`
- * @param {Number} fractionDigits - number of precision decimals
- * @param {Number} maxLength - Max length of formatted number
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
* if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const percentHundred = getFormatter(SUPPORTED_FORMATS.percentHundred);
@@ -159,9 +165,11 @@ export const percentHundred = getFormatter(SUPPORTED_FORMATS.percentHundred);
*
* @function
* @param {Number} value - Number to format, `1` is rendered as `1s`
- * @param {Number} fractionDigits - number of precision decimals
- * @param {Number} maxLength - Max length of formatted number
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
* if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const seconds = getFormatter(SUPPORTED_FORMATS.seconds);
@@ -170,9 +178,11 @@ export const seconds = getFormatter(SUPPORTED_FORMATS.seconds);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1ms`
- * @param {Number} fractionDigits - number of precision decimals
- * @param {Number} maxLength - Max length of formatted number
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
* if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const milliseconds = getFormatter(SUPPORTED_FORMATS.milliseconds);
@@ -182,7 +192,11 @@ export const milliseconds = getFormatter(SUPPORTED_FORMATS.milliseconds);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1B`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const decimalBytes = getFormatter(SUPPORTED_FORMATS.decimalBytes);
@@ -192,7 +206,11 @@ export const decimalBytes = getFormatter(SUPPORTED_FORMATS.decimalBytes);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1kB`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const kilobytes = getFormatter(SUPPORTED_FORMATS.kilobytes);
@@ -202,7 +220,11 @@ export const kilobytes = getFormatter(SUPPORTED_FORMATS.kilobytes);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1MB`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const megabytes = getFormatter(SUPPORTED_FORMATS.megabytes);
@@ -212,7 +234,11 @@ export const megabytes = getFormatter(SUPPORTED_FORMATS.megabytes);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1GB`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const gigabytes = getFormatter(SUPPORTED_FORMATS.gigabytes);
@@ -222,7 +248,11 @@ export const gigabytes = getFormatter(SUPPORTED_FORMATS.gigabytes);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1GB`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const terabytes = getFormatter(SUPPORTED_FORMATS.terabytes);
@@ -232,7 +262,11 @@ export const terabytes = getFormatter(SUPPORTED_FORMATS.terabytes);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1PB`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const petabytes = getFormatter(SUPPORTED_FORMATS.petabytes);
@@ -242,7 +276,11 @@ export const petabytes = getFormatter(SUPPORTED_FORMATS.petabytes);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1B`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const bytes = getFormatter(SUPPORTED_FORMATS.bytes);
@@ -252,7 +290,11 @@ export const bytes = getFormatter(SUPPORTED_FORMATS.bytes);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1kB`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const kibibytes = getFormatter(SUPPORTED_FORMATS.kibibytes);
@@ -262,7 +304,11 @@ export const kibibytes = getFormatter(SUPPORTED_FORMATS.kibibytes);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1MB`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const mebibytes = getFormatter(SUPPORTED_FORMATS.mebibytes);
@@ -272,7 +318,11 @@ export const mebibytes = getFormatter(SUPPORTED_FORMATS.mebibytes);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1GB`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const gibibytes = getFormatter(SUPPORTED_FORMATS.gibibytes);
@@ -282,7 +332,11 @@ export const gibibytes = getFormatter(SUPPORTED_FORMATS.gibibytes);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1GB`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const tebibytes = getFormatter(SUPPORTED_FORMATS.tebibytes);
@@ -292,7 +346,11 @@ export const tebibytes = getFormatter(SUPPORTED_FORMATS.tebibytes);
*
* @function
* @param {Number} value - Number to format, `1` is formatted as `1PB`
- * @param {Number} fractionDigits - number of precision decimals
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - number of precision decimals
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const pebibytes = getFormatter(SUPPORTED_FORMATS.pebibytes);
@@ -301,6 +359,10 @@ export const pebibytes = getFormatter(SUPPORTED_FORMATS.pebibytes);
*
* @function
* @param {Number} value - Value to format
- * @param {Number} fractionDigits - precision decimals - Defaults to 2
+ * @param {Object} options - Formatting options
+ * @param {Number} options.fractionDigits - precision decimals, defaults to 2
+ * @param {Number} options.maxLength - Max length of formatted number
+ * if length is exceeded, exponential format is used.
+ * @param {String} options.unitSeparator - Separator between value and unit
*/
export const engineering = getFormatter();
diff --git a/app/assets/javascripts/lib/utils/webpack.js b/app/assets/javascripts/lib/utils/webpack.js
index a88f1bd82fc..38d2f3d7551 100644
--- a/app/assets/javascripts/lib/utils/webpack.js
+++ b/app/assets/javascripts/lib/utils/webpack.js
@@ -10,5 +10,5 @@ export function resetServiceWorkersPublicPath() {
// see: https://webpack.js.org/guides/public-path/
const relativeRootPath = (gon && gon.relative_url_root) || '';
const webpackAssetPath = joinPaths(relativeRootPath, '/assets/webpack/');
- __webpack_public_path__ = webpackAssetPath; // eslint-disable-line babel/camelcase
+ __webpack_public_path__ = webpackAssetPath; // eslint-disable-line camelcase
}