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

90 lines
2 KiB
Vue
Raw Normal View History

2020-03-13 15:44:24 +05:30
<script>
import { mapActions, mapState } from 'vuex';
2020-06-23 00:09:42 +05:30
import IdeSidebarNav from '../ide_sidebar_nav.vue';
2020-03-13 15:44:24 +05:30
export default {
name: 'CollapsibleSidebar',
components: {
2020-06-23 00:09:42 +05:30
IdeSidebarNav,
2020-03-13 15:44:24 +05:30
},
props: {
extensionTabs: {
type: Array,
required: false,
default: () => [],
},
side: {
type: String,
required: true,
},
},
computed: {
...mapState({
isOpen(state) {
return state[this.namespace].isOpen;
},
currentView(state) {
return state[this.namespace].currentView;
},
isAliveView(_state, getters) {
return getters[`${this.namespace}/isAliveView`];
},
}),
namespace() {
2020-04-22 19:07:51 +05:30
// eslint-disable-next-line @gitlab/require-i18n-strings
2020-03-13 15:44:24 +05:30
return `${this.side}Pane`;
},
tabs() {
2021-03-08 18:12:59 +05:30
return this.extensionTabs.filter((tab) => tab.show);
2020-03-13 15:44:24 +05:30
},
tabViews() {
2021-03-08 18:12:59 +05:30
return this.tabs.map((tab) => tab.views).flat();
2020-03-13 15:44:24 +05:30
},
aliveTabViews() {
2021-03-08 18:12:59 +05:30
return this.tabViews.filter((view) => this.isAliveView(view.name));
2020-03-13 15:44:24 +05:30
},
},
methods: {
...mapActions({
toggleOpen(dispatch) {
return dispatch(`${this.namespace}/toggleOpen`);
},
open(dispatch, view) {
return dispatch(`${this.namespace}/open`, view);
},
}),
},
};
</script>
<template>
<div
:class="`ide-${side}-sidebar`"
:data-qa-selector="`ide_${side}_sidebar`"
class="multi-file-commit-panel ide-sidebar"
>
2020-06-23 00:09:42 +05:30
<div
2020-03-13 15:44:24 +05:30
v-show="isOpen"
:class="`ide-${side}-sidebar-${currentView}`"
class="multi-file-commit-panel-inner"
>
2020-06-23 00:09:42 +05:30
<div
v-for="tabView in aliveTabViews"
v-show="tabView.name === currentView"
:key="tabView.name"
class="flex-fill gl-overflow-hidden js-tab-view gl-h-full"
>
<component :is="tabView.component" />
2020-03-13 15:44:24 +05:30
</div>
2020-06-23 00:09:42 +05:30
</div>
<ide-sidebar-nav
:tabs="tabs"
:side="side"
:current-view="currentView"
:is-open="isOpen"
@open="open"
@close="toggleOpen"
/>
2020-03-13 15:44:24 +05:30
</div>
</template>