Welcome to mirror list, hosted at ThFree Co, Russian Federation.

expires_at_field.vue « components « access_tokens « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5516fd0daf66b4d3f49b45498ad3f0a46cab4332 (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
<script>
import { GlDatepicker, GlFormGroup } from '@gitlab/ui';

import { __ } from '~/locale';
import { getDateInFuture } from '~/lib/utils/datetime_utility';

export default {
  name: 'ExpiresAtField',
  i18n: {
    label: __('Expiration date'),
  },
  components: {
    GlDatepicker,
    GlFormGroup,
    MaxExpirationDateMessage: () =>
      import('ee_component/access_tokens/components/max_expiration_date_message.vue'),
  },
  props: {
    inputAttrs: {
      type: Object,
      required: false,
      default: () => ({}),
    },
    minDate: {
      type: Date,
      required: false,
      default: () => new Date(),
    },
    maxDate: {
      type: Date,
      required: false,
      default: () => null,
    },
  },
  computed: {
    in30Days() {
      const today = new Date();
      return getDateInFuture(today, 30);
    },
  },
};
</script>

<template>
  <gl-form-group :label="$options.i18n.label" :label-for="inputAttrs.id">
    <gl-datepicker
      :target="null"
      :min-date="minDate"
      :max-date="maxDate"
      :default-date="in30Days"
      show-clear-button
      :input-name="inputAttrs.name"
      :input-id="inputAttrs.id"
      :placeholder="inputAttrs.placeholder"
      data-qa-selector="expiry_date_field"
    />
    <template #description>
      <max-expiration-date-message :max-date="maxDate" />
    </template>
  </gl-form-group>
</template>