debian-mirror-gitlab/app/assets/javascripts/ide/components/nav_dropdown.vue

55 lines
1.3 KiB
Vue
Raw Normal View History

2018-11-18 11:00:15 +05:30
<script>
import $ from 'jquery';
2020-03-13 15:44:24 +05:30
import { mapGetters } from 'vuex';
2018-11-18 11:00:15 +05:30
import NavForm from './nav_form.vue';
import NavDropdownButton from './nav_dropdown_button.vue';
export default {
components: {
NavDropdownButton,
NavForm,
},
data() {
return {
isVisibleDropdown: false,
};
},
2020-03-13 15:44:24 +05:30
computed: {
...mapGetters(['canReadMergeRequests']),
},
2018-11-18 11:00:15 +05:30
mounted() {
this.addDropdownListeners();
},
beforeDestroy() {
this.removeDropdownListeners();
},
methods: {
addDropdownListeners() {
$(this.$refs.dropdown)
.on('show.bs.dropdown', () => this.showDropdown())
.on('hide.bs.dropdown', () => this.hideDropdown());
},
removeDropdownListeners() {
$(this.$refs.dropdown)
.off('show.bs.dropdown')
.off('hide.bs.dropdown');
},
showDropdown() {
this.isVisibleDropdown = true;
},
hideDropdown() {
this.isVisibleDropdown = false;
},
},
};
</script>
<template>
2019-02-15 15:39:39 +05:30
<div ref="dropdown" class="btn-group ide-nav-dropdown dropdown">
2020-03-13 15:44:24 +05:30
<nav-dropdown-button :show-merge-requests="canReadMergeRequests" />
<div class="dropdown-menu dropdown-menu-left p-0">
<nav-form v-if="isVisibleDropdown" :show-merge-requests="canReadMergeRequests" />
</div>
2018-11-18 11:00:15 +05:30
</div>
</template>