summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/constants.js
blob: c93dd95a886a62caeb37e1b6d165787b27844ae1 (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
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
import { __, n__, sprintf } from '~/locale';
import { IssuableType, WorkspaceType } from '~/issues/constants';

const INTERVALS = {
  minute: 'minute',
  hour: 'hour',
  day: 'day',
};

export const FILE_SYMLINK_MODE = '120000';

export const SHORT_DATE_FORMAT = 'mmm dd, yyyy';

export const ISO_SHORT_FORMAT = 'yyyy-mm-dd';

export const LONG_DATE_FORMAT_WITH_TZ = 'yyyy-mm-dd HH:MM:ss Z';

export const DATE_FORMATS = [SHORT_DATE_FORMAT, ISO_SHORT_FORMAT, LONG_DATE_FORMAT_WITH_TZ];

const getTimeLabel = (days) => n__('1 day', '%d days', days);

/* eslint-disable @gitlab/require-i18n-strings */
export const timeRanges = [
  {
    label: n__('1 minute', '%d minutes', 30),
    shortcut: '30_minutes',
    duration: { seconds: 60 * 30 },
    name: 'thirtyMinutes',
    interval: INTERVALS.minute,
  },
  {
    label: n__('1 hour', '%d hours', 3),
    shortcut: '3_hours',
    duration: { seconds: 60 * 60 * 3 },
    name: 'threeHours',
    interval: INTERVALS.hour,
  },
  {
    label: n__('1 hour', '%d hours', 8),
    shortcut: '8_hours',
    duration: { seconds: 60 * 60 * 8 },
    name: 'eightHours',
    default: true,
    interval: INTERVALS.hour,
  },
  {
    label: getTimeLabel(1),
    shortcut: '1_day',
    duration: { seconds: 60 * 60 * 24 * 1 },
    name: 'oneDay',
    interval: INTERVALS.hour,
  },
  {
    label: getTimeLabel(3),
    shortcut: '3_days',
    duration: { seconds: 60 * 60 * 24 * 3 },
    name: 'threeDays',
    interval: INTERVALS.hour,
  },
  {
    label: getTimeLabel(7),
    shortcut: '7_days',
    duration: { seconds: 60 * 60 * 24 * 7 * 1 },
    name: 'oneWeek',
    interval: INTERVALS.day,
  },
  {
    label: getTimeLabel(30),
    shortcut: '30_days',
    duration: { seconds: 60 * 60 * 24 * 30 },
    name: 'oneMonth',
    interval: INTERVALS.day,
  },
];
/* eslint-enable @gitlab/require-i18n-strings */

export const defaultTimeRange = timeRanges.find((tr) => tr.default);
export const getTimeWindow = (timeWindowName) =>
  timeRanges.find((tr) => tr.name === timeWindowName);

export const AVATAR_SHAPE_OPTION_CIRCLE = 'circle';
export const AVATAR_SHAPE_OPTION_RECT = 'rect';

export const confidentialityInfoText = (workspaceType, issuableType) =>
  sprintf(
    __(
      'Only %{workspaceType} members with %{permissions} can view or be notified about this %{issuableType}.',
    ),
    {
      workspaceType: workspaceType === WorkspaceType.project ? __('project') : __('group'),
      issuableType: issuableType === IssuableType.Issue ? __('issue') : __('epic'),
      permissions:
        issuableType === IssuableType.Issue
          ? __('at least the Reporter role, the author, and assignees')
          : __('at least the Reporter role'),
    },
  );

export const EDITING_MODE_MARKDOWN_FIELD = 'markdownField';
export const EDITING_MODE_CONTENT_EDITOR = 'contentEditor';