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

62 lines
1.4 KiB
Vue
Raw Normal View History

2019-09-30 21:07:59 +05:30
<script>
2020-11-24 15:15:51 +05:30
import { GlDeprecatedDropdown, GlDeprecatedDropdownItem, GlIcon } from '@gitlab/ui';
2019-09-30 21:07:59 +05:30
import { __ } from '~/locale';
export default {
components: {
2020-10-24 23:57:45 +05:30
GlDeprecatedDropdown,
GlDeprecatedDropdownItem,
2020-11-24 15:15:51 +05:30
GlIcon,
2019-09-30 21:07:59 +05:30
},
props: {
projects: {
type: Array,
required: true,
},
selectedProject: {
type: Object,
required: false,
default: () => ({}),
},
},
computed: {
dropdownText() {
if (Object.keys(this.selectedProject).length) {
return this.selectedProject.name;
}
return __('Select private project');
},
},
methods: {
selectProject(project) {
this.$emit('click', project);
},
},
};
</script>
<template>
2020-10-24 23:57:45 +05:30
<gl-deprecated-dropdown toggle-class="d-flex align-items-center w-100" class="w-100">
2020-05-24 23:13:21 +05:30
<template #button-content>
2019-09-30 21:07:59 +05:30
<span class="str-truncated-100 mr-2">
2020-11-24 15:15:51 +05:30
<gl-icon name="lock" />
2019-09-30 21:07:59 +05:30
{{ dropdownText }}
</span>
2020-11-24 15:15:51 +05:30
<gl-icon name="chevron-down" class="ml-auto" />
2019-09-30 21:07:59 +05:30
</template>
2020-10-24 23:57:45 +05:30
<gl-deprecated-dropdown-item
v-for="project in projects"
:key="project.id"
@click="selectProject(project)"
>
2020-11-24 15:15:51 +05:30
<gl-icon
2019-09-30 21:07:59 +05:30
name="mobile-issue-close"
:class="{ icon: project.id !== selectedProject.id }"
class="js-active-project-check"
/>
<span class="ml-1">{{ project.name }}</span>
2020-10-24 23:57:45 +05:30
</gl-deprecated-dropdown-item>
</gl-deprecated-dropdown>
2019-09-30 21:07:59 +05:30
</template>