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

settings_form.vue « components « settings « registry « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ad2fdb4fd405e2774a3ab7ec4aed1692db68ec85 (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
<script>
import { mapActions, mapState, mapGetters } from 'vuex';
import Tracking from '~/tracking';
import {
  UPDATE_SETTINGS_ERROR_MESSAGE,
  UPDATE_SETTINGS_SUCCESS_MESSAGE,
} from '../../shared/constants';
import { mapComputed } from '~/vuex_shared/bindings';
import ExpirationPolicyForm from '../../shared/components/expiration_policy_form.vue';

export default {
  components: {
    ExpirationPolicyForm,
  },
  mixins: [Tracking.mixin()],
  labelsConfig: {
    cols: 3,
    align: 'right',
  },
  data() {
    return {
      tracking: {
        label: 'docker_container_retention_and_expiration_policies',
      },
    };
  },
  computed: {
    ...mapState(['formOptions', 'isLoading']),
    ...mapGetters({ isEdited: 'getIsEdited' }),
    ...mapComputed([{ key: 'settings', getter: 'getSettings' }], 'updateSettings'),
  },
  methods: {
    ...mapActions(['resetSettings', 'saveSettings']),
    reset() {
      this.track('reset_form');
      this.resetSettings();
    },
    submit() {
      this.track('submit_form');
      this.saveSettings()
        .then(() => this.$toast.show(UPDATE_SETTINGS_SUCCESS_MESSAGE, { type: 'success' }))
        .catch(() => this.$toast.show(UPDATE_SETTINGS_ERROR_MESSAGE, { type: 'error' }));
    },
  },
};
</script>

<template>
  <expiration-policy-form
    v-model="settings"
    :form-options="formOptions"
    :is-loading="isLoading"
    :disable-cancel-button="!isEdited"
    @submit="submit"
    @reset="reset"
  />
</template>