diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 06:09:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 06:09:43 +0300 |
commit | b4b9b3854eddd2a4829113ebfc1812c3a332a7d9 (patch) | |
tree | 6a21e491917e1606d81329af710459b0217eb1a4 /app/assets/javascripts/vue_shared | |
parent | 2e31c85a97183814ffa7ba5cc58f7bbad668fb2b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/vue_shared')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/date_time_picker/date_time_picker.vue | 6 | ||||
-rw-r--r-- | app/assets/javascripts/vue_shared/constants.js | 56 |
2 files changed, 62 insertions, 0 deletions
diff --git a/app/assets/javascripts/vue_shared/components/date_time_picker/date_time_picker.vue b/app/assets/javascripts/vue_shared/components/date_time_picker/date_time_picker.vue index 9ac687f5e2c..7b09337eb15 100644 --- a/app/assets/javascripts/vue_shared/components/date_time_picker/date_time_picker.vue +++ b/app/assets/javascripts/vue_shared/components/date_time_picker/date_time_picker.vue @@ -43,6 +43,11 @@ export default { required: false, default: () => defaultTimeRanges, }, + customEnabled: { + type: Boolean, + required: false, + default: true, + }, }, data() { return { @@ -166,6 +171,7 @@ export default { > <div class="d-flex justify-content-between gl-p-2"> <gl-form-group + v-if="customEnabled" :label="__('Custom range')" label-for="custom-from-time" label-class="gl-pb-1" diff --git a/app/assets/javascripts/vue_shared/constants.js b/app/assets/javascripts/vue_shared/constants.js new file mode 100644 index 00000000000..63ce4212717 --- /dev/null +++ b/app/assets/javascripts/vue_shared/constants.js @@ -0,0 +1,56 @@ +import { __ } from '~/locale'; + +const INTERVALS = { + minute: 'minute', + hour: 'hour', + day: 'day', +}; + +export const timeRanges = [ + { + label: __('30 minutes'), + duration: { seconds: 60 * 30 }, + name: 'thirtyMinutes', + interval: INTERVALS.minute, + }, + { + label: __('3 hours'), + duration: { seconds: 60 * 60 * 3 }, + name: 'threeHours', + interval: INTERVALS.hour, + }, + { + label: __('8 hours'), + duration: { seconds: 60 * 60 * 8 }, + name: 'eightHours', + default: true, + interval: INTERVALS.hour, + }, + { + label: __('1 day'), + duration: { seconds: 60 * 60 * 24 * 1 }, + name: 'oneDay', + interval: INTERVALS.hour, + }, + { + label: __('3 days'), + duration: { seconds: 60 * 60 * 24 * 3 }, + name: 'threeDays', + interval: INTERVALS.hour, + }, + { + label: __('1 week'), + duration: { seconds: 60 * 60 * 24 * 7 * 1 }, + name: 'oneWeek', + interval: INTERVALS.day, + }, + { + label: __('1 month'), + duration: { seconds: 60 * 60 * 24 * 30 }, + name: 'oneMonth', + interval: INTERVALS.day, + }, +]; + +export const defaultTimeRange = timeRanges.find(tr => tr.default); +export const getTimeWindow = timeWindowName => timeRanges.find(tr => tr.name === timeWindowName); |