debian-mirror-gitlab/app/assets/javascripts/issues/show/components/incidents/utils.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-05-27 22:25:52 +05:30
import { createAlert } from '~/alert';
2022-07-23 23:45:48 +05:30
import { s__ } from '~/locale';
export const displayAndLogError = (error) =>
createAlert({
message: s__('Incident|Something went wrong while fetching incident timeline events.'),
captureError: true,
error,
});
const EVENT_ICONS = {
comment: 'comment',
2022-08-13 15:12:31 +05:30
issues: 'issues',
2022-08-27 11:52:29 +05:30
label: 'label',
2022-08-13 15:12:31 +05:30
status: 'status',
2022-07-23 23:45:48 +05:30
default: 'comment',
};
export const getEventIcon = (actionName) => {
return EVENT_ICONS[actionName] ?? EVENT_ICONS.default;
};
2022-08-13 15:12:31 +05:30
/**
2022-10-11 01:57:18 +05:30
* Returns a date shifted by the current timezone offset set to now
* by default but can accept an existing date as an ISO date string
* @param {string} ISOString
2022-08-13 15:12:31 +05:30
* @returns {Date}
*/
2022-10-11 01:57:18 +05:30
export const getUtcShiftedDate = (ISOString = null) => {
const date = ISOString ? new Date(ISOString) : new Date();
2022-08-13 15:12:31 +05:30
date.setMinutes(date.getMinutes() + date.getTimezoneOffset());
2022-10-11 01:57:18 +05:30
2022-08-13 15:12:31 +05:30
return date;
};
2023-04-23 21:23:45 +05:30
/**
* Returns an array of previously set event tags
* @param {array} timelineEventTagsNodes
* @returns {array}
*/
export const getPreviousEventTags = (timelineEventTagsNodes = []) =>
timelineEventTagsNodes.map(({ name }) => name);