debian-mirror-gitlab/app/assets/javascripts/confidential_merge_request/components/dropdown.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.1 KiB
Vue
Raw Normal View History

2019-09-30 21:07:59 +05:30
<script>
2023-04-23 21:23:45 +05:30
import { GlCollapsibleListbox } from '@gitlab/ui';
2019-09-30 21:07:59 +05:30
import { __ } from '~/locale';
export default {
components: {
2023-04-23 21:23:45 +05:30
GlCollapsibleListbox,
2019-09-30 21:07:59 +05:30
},
props: {
projects: {
type: Array,
required: true,
},
selectedProject: {
type: Object,
required: false,
default: () => ({}),
},
},
computed: {
2023-04-23 21:23:45 +05:30
selectedProjectValue() {
return this.selectedProject?.id && String(this.selectedProject.id);
},
toggleText() {
return this.selectedProject?.name || __('Select private project');
},
listboxItems() {
return this.projects.map(({ id, name }) => {
return {
value: String(id),
text: name,
};
});
2019-09-30 21:07:59 +05:30
},
},
methods: {
2023-04-23 21:23:45 +05:30
selectProject(projectId) {
const project = this.projects.find(({ id }) => String(id) === projectId);
this.$emit('select', project);
2019-09-30 21:07:59 +05:30
},
},
};
</script>
<template>
2023-04-23 21:23:45 +05:30
<gl-collapsible-listbox
icon="lock"
:items="listboxItems"
:selected="selectedProjectValue"
:toggle-text="toggleText"
block
@select="selectProject"
/>
2019-09-30 21:07:59 +05:30
</template>