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

subscriptions_dropdown.vue « subscriptions « components « sidebar « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bacbe5d46a67bbf686c8066429fab15dabc9eb7f (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
<script>
import { GlCollapsibleListbox } from '@gitlab/ui';
import { __ } from '~/locale';
import { subscriptionsDropdownOptions } from '../../constants';

export default {
  subscriptionsDropdownOptions,
  i18n: {
    defaultDropdownText: __('Select subscription'),
    headerText: __('Change subscription'),
    resetText: __('Reset'),
  },
  components: {
    GlCollapsibleListbox,
  },
  data() {
    return {
      selectedValue: undefined,
    };
  },
  computed: {
    dropdownText() {
      const selected = this.$options.subscriptionsDropdownOptions.find(
        (option) => option.value === this.selectedValue,
      );
      return selected?.text || this.$options.i18n.defaultDropdownText;
    },
  },
  methods: {
    handleReset() {
      this.selectedValue = undefined;
    },
  },
};
</script>
<template>
  <div>
    <input type="hidden" name="update[subscription_event]" :value="selectedValue" />
    <gl-collapsible-listbox
      v-model="selectedValue"
      block
      :header-text="$options.i18n.headerText"
      :reset-button-label="$options.i18n.resetText"
      :toggle-text="dropdownText"
      :items="$options.subscriptionsDropdownOptions"
      @reset="handleReset"
    />
  </div>
</template>