summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/admin/background_migrations/components/database_listbox.vue
blob: 8e814cd55efa6f116e505345e2dc23159ce2e1b8 (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
<script>
import { GlCollapsibleListbox } from '@gitlab/ui';
import { s__ } from '~/locale';
import { setUrlParams, visitUrl } from '~/lib/utils/url_utility';

export default {
  name: 'BackgroundMigrationsDatabaseListbox',
  i18n: {
    database: s__('BackgroundMigrations|Database'),
  },
  components: {
    GlCollapsibleListbox,
  },
  props: {
    databases: {
      type: Array,
      required: true,
    },
    selectedDatabase: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      selected: this.selectedDatabase,
    };
  },
  methods: {
    selectDatabase(database) {
      visitUrl(setUrlParams({ database }));
    },
  },
};
</script>

<template>
  <div class="gl-display-flex gl-align-items-center" data-testid="database-listbox">
    <label id="label" class="gl-font-weight-bold gl-mr-4 gl-mb-0">{{
      $options.i18n.database
    }}</label>
    <gl-collapsible-listbox
      v-model="selected"
      :items="databases"
      right
      :toggle-text="selectedDatabase"
      toggle-aria-labelled-by="label"
      @select="selectDatabase"
    />
  </div>
</template>