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

visibility_level_dropdown.vue « components « groups « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0933045fc387b9fcc132a89fed45f9831192eac5 (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
<script>
import { GlDropdown, GlDropdownItem } from '@gitlab/ui';

export default {
  components: {
    GlDropdown,
    GlDropdownItem,
  },
  props: {
    visibilityLevelOptions: {
      type: Array,
      required: true,
    },
    defaultLevel: {
      type: Number,
      required: true,
    },
  },
  data() {
    return {
      selectedOption: this.getDefaultOption(),
    };
  },
  methods: {
    getDefaultOption() {
      return this.visibilityLevelOptions.find((option) => option.level === this.defaultLevel);
    },
    onClick(option) {
      this.selectedOption = option;
    },
  },
};
</script>
<template>
  <div>
    <input type="hidden" name="group[visibility_level]" :value="selectedOption.level" />
    <gl-dropdown :text="selectedOption.label" class="gl-w-full" menu-class="gl-w-full! gl-mb-0">
      <gl-dropdown-item
        v-for="option in visibilityLevelOptions"
        :key="option.level"
        :secondary-text="option.description"
        @click="onClick(option)"
      >
        <div class="gl-font-weight-bold gl-mb-1">{{ option.label }}</div>
      </gl-dropdown-item>
    </gl-dropdown>
  </div>
</template>