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

56 lines
1.4 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() {
2021-02-22 17:27:13 +05:30
// eslint-disable-next-line @gitlab/no-global-event-off
2018-11-18 11:00:15 +05:30
$(this.$refs.dropdown)
.off('show.bs.dropdown')
.off('hide.bs.dropdown');
},
showDropdown() {
this.isVisibleDropdown = true;
},
hideDropdown() {
this.isVisibleDropdown = false;
},
},
};
</script>
<template>
2021-02-22 17:27:13 +05:30
<div ref="dropdown" class="btn-group ide-nav-dropdown dropdown" data-testid="ide-nav-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>