1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<script>
import { mapActions, mapState } from 'vuex';
import IdeSidebarNav from '../ide_sidebar_nav.vue';
export default {
name: 'CollapsibleSidebar',
components: {
IdeSidebarNav,
},
props: {
extensionTabs: {
type: Array,
required: false,
default: () => [],
},
initOpenView: {
type: String,
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() {
// eslint-disable-next-line @gitlab/require-i18n-strings
return `${this.side}Pane`;
},
tabs() {
return this.extensionTabs.filter((tab) => tab.show);
},
tabViews() {
return this.tabs.map((tab) => tab.views).flat();
},
aliveTabViews() {
return this.tabViews.filter((view) => this.isAliveView(view.name));
},
},
created() {
this.openViewByName(this.initOpenView);
},
methods: {
...mapActions({
toggleOpen(dispatch) {
return dispatch(`${this.namespace}/toggleOpen`);
},
open(dispatch, view) {
return dispatch(`${this.namespace}/open`, view);
},
}),
openViewByName(viewName) {
const view = viewName && this.tabViews.find((x) => x.name === viewName);
if (view) {
this.open(view);
}
},
},
};
</script>
<template>
<div
:class="`ide-${side}-sidebar`"
:data-qa-selector="`ide_${side}_sidebar`"
class="multi-file-commit-panel ide-sidebar"
>
<div
v-show="isOpen"
:class="`ide-${side}-sidebar-${currentView}`"
class="multi-file-commit-panel-inner"
>
<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" />
</div>
</div>
<ide-sidebar-nav
:tabs="tabs"
:side="side"
:current-view="currentView"
:is-open="isOpen"
@open="open"
@close="toggleOpen"
/>
</div>
</template>
|