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

forwarding_settings.vue « components « group « settings « packages_and_registries « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c7fddadab1bace1bdfea29d4f75fe5ef04e9bae2 (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
<script>
import { GlFormCheckbox, GlFormGroup, GlSprintf } from '@gitlab/ui';
import { isEqual } from 'lodash';
import {
  PACKAGE_FORWARDING_CHECKBOX_LABEL,
  PACKAGE_FORWARDING_ENFORCE_LABEL,
} from '~/packages_and_registries/settings/group/constants';

export default {
  name: 'ForwardingSettings',
  i18n: {
    PACKAGE_FORWARDING_CHECKBOX_LABEL,
    PACKAGE_FORWARDING_ENFORCE_LABEL,
  },
  components: {
    GlFormCheckbox,
    GlFormGroup,
    GlSprintf,
  },
  props: {
    disabled: {
      type: Boolean,
      required: false,
      default: true,
    },
    forwarding: {
      type: Boolean,
      required: false,
      default: false,
    },
    label: {
      type: String,
      required: true,
    },
    lockForwarding: {
      type: Boolean,
      required: false,
      default: false,
    },
    modelNames: {
      type: Object,
      required: true,
      validator(value) {
        return isEqual(Object.keys(value), ['forwarding', 'lockForwarding', 'isLocked']);
      },
    },
  },
  computed: {
    fields() {
      return [
        {
          testid: 'forwarding-checkbox',
          label: PACKAGE_FORWARDING_CHECKBOX_LABEL,
          updateField: this.modelNames.forwarding,
          checked: this.forwarding,
        },
        {
          testid: 'lock-forwarding-checkbox',
          label: PACKAGE_FORWARDING_ENFORCE_LABEL,
          updateField: this.modelNames.lockForwarding,
          checked: this.lockForwarding,
        },
      ];
    },
  },
  methods: {
    update(type, value) {
      this.$emit('update', type, value);
    },
  },
};
</script>

<template>
  <gl-form-group :label="label">
    <gl-form-checkbox
      v-for="field in fields"
      :key="field.testid"
      :checked="field.checked"
      :disabled="disabled"
      :data-testid="field.testid"
      @change="update(field.updateField, $event)"
    >
      <gl-sprintf :message="field.label">
        <template #packageType>
          {{ label }}
        </template>
      </gl-sprintf>
    </gl-form-checkbox>
  </gl-form-group>
</template>