summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/issues/show/components/incidents/utils.js
blob: 256e3025f1947ea5047cd53aa90542db89c4f411 (plain)
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
import { createAlert } from '~/flash';
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',
  issues: 'issues',
  status: 'status',
  default: 'comment',
};

export const getEventIcon = (actionName) => {
  return EVENT_ICONS[actionName] ?? EVENT_ICONS.default;
};

/**
 * Returns a date shifted by the current timezone offset. Allows
 * date.getHours() and similar to return UTC values.
 *
 * @returns {Date}
 */
export const getUtcShiftedDateNow = () => {
  const date = new Date();
  date.setMinutes(date.getMinutes() + date.getTimezoneOffset());
  return date;
};