All files / app/assets/javascripts/operation_settings/components/form_group dashboard_timezone.vue

87.5% Statements 7/8
100% Branches 0/0
75% Functions 3/4
87.5% Lines 7/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  1x 1x 1x 1x                     14x             14x                                   57x                                        
<script>
import { GlFormGroup, GlFormSelect } from '@gitlab/ui';
import { mapState, mapActions } from 'vuex';
import { s__ } from '~/locale';
import { timezones } from '~/monitoring/format_date';
 
export default {
  components: {
    GlFormGroup,
    GlFormSelect,
  },
  computed: {
    ...mapState(['dashboardTimezone']),
    dashboardTimezoneModel: {
      get() {
        return this.dashboardTimezone.selected;
      },
      set(selected) {
        this.setDashboardTimezone(selected);
      },
    },
    options() {
      return [
        {
          value: timezones.LOCAL,
          text: s__("MetricsSettings|User's local timezone"),
        },
        {
          value: timezones.UTC,
          text: s__('MetricsSettings|UTC (Coordinated Universal Time)'),
        },
      ];
    },
  },
  methods: {
    ...mapActions(['setDashboardTimezone']),
  },
};
</script>
 
<template>
  <gl-form-group
    :label="s__('MetricsSettings|Dashboard timezone')"
    label-for="dashboard-timezone-setting"
  >
    <template #description>
      {{
        s__(
          "MetricsSettings|Choose whether to display dashboard metrics in UTC or the user's local timezone.",
        )
      }}
    </template>
 
    <gl-form-select
      id="dashboard-timezone-setting"
      v-model="dashboardTimezoneModel"
      :options="options"
    />
  </gl-form-group>
</template>