2018-11-08 19:23:39 +05:30
|
|
|
<script>
|
2018-11-18 11:00:15 +05:30
|
|
|
import { mapActions, mapState, mapGetters } from 'vuex';
|
2018-12-05 23:21:45 +05:30
|
|
|
import _ from 'underscore';
|
|
|
|
import { __ } from '~/locale';
|
2018-11-08 19:23:39 +05:30
|
|
|
import tooltip from '../../../vue_shared/directives/tooltip';
|
|
|
|
import Icon from '../../../vue_shared/components/icon.vue';
|
|
|
|
import { rightSidebarViews } from '../../constants';
|
|
|
|
import PipelinesList from '../pipelines/list.vue';
|
|
|
|
import JobsDetail from '../jobs/detail.vue';
|
|
|
|
import MergeRequestInfo from '../merge_requests/info.vue';
|
|
|
|
import ResizablePanel from '../resizable_panel.vue';
|
2018-11-18 11:00:15 +05:30
|
|
|
import Clientside from '../preview/clientside.vue';
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
directives: {
|
|
|
|
tooltip,
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
Icon,
|
|
|
|
PipelinesList,
|
|
|
|
JobsDetail,
|
|
|
|
ResizablePanel,
|
|
|
|
MergeRequestInfo,
|
2018-11-18 11:00:15 +05:30
|
|
|
Clientside,
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
props: {
|
|
|
|
extensionTabs: {
|
|
|
|
type: Array,
|
|
|
|
required: false,
|
|
|
|
default: () => [],
|
|
|
|
},
|
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
computed: {
|
2018-12-05 23:21:45 +05:30
|
|
|
...mapState(['currentMergeRequestId', 'clientsidePreviewEnabled']),
|
|
|
|
...mapState('rightPane', ['isOpen', 'currentView']),
|
2018-11-18 11:00:15 +05:30
|
|
|
...mapGetters(['packageJson']),
|
2018-12-05 23:21:45 +05:30
|
|
|
...mapGetters('rightPane', ['isActiveView', 'isAliveView']),
|
2018-11-18 11:00:15 +05:30
|
|
|
showLivePreview() {
|
|
|
|
return this.packageJson && this.clientsidePreviewEnabled;
|
|
|
|
},
|
2018-12-05 23:21:45 +05:30
|
|
|
defaultTabs() {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
show: this.currentMergeRequestId,
|
|
|
|
title: __('Merge Request'),
|
2018-12-13 13:39:08 +05:30
|
|
|
views: [rightSidebarViews.mergeRequestInfo],
|
2018-12-05 23:21:45 +05:30
|
|
|
icon: 'text-description',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
show: true,
|
|
|
|
title: __('Pipelines'),
|
2018-12-13 13:39:08 +05:30
|
|
|
views: [rightSidebarViews.pipelines, rightSidebarViews.jobsDetail],
|
2018-12-05 23:21:45 +05:30
|
|
|
icon: 'rocket',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
show: this.showLivePreview,
|
|
|
|
title: __('Live preview'),
|
2018-12-13 13:39:08 +05:30
|
|
|
views: [rightSidebarViews.clientSidePreview],
|
2018-12-05 23:21:45 +05:30
|
|
|
icon: 'live-preview',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
},
|
|
|
|
tabs() {
|
2018-12-13 13:39:08 +05:30
|
|
|
return this.defaultTabs.concat(this.extensionTabs).filter(tab => tab.show);
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
|
|
|
tabViews() {
|
|
|
|
return _.flatten(this.tabs.map(tab => tab.views));
|
|
|
|
},
|
|
|
|
aliveTabViews() {
|
|
|
|
return this.tabViews.filter(view => this.isAliveView(view.name));
|
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
methods: {
|
2018-12-05 23:21:45 +05:30
|
|
|
...mapActions('rightPane', ['toggleOpen', 'open']),
|
|
|
|
clickTab(e, tab) {
|
2018-11-08 19:23:39 +05:30
|
|
|
e.target.blur();
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
if (this.isActiveTab(tab)) {
|
|
|
|
this.toggleOpen();
|
|
|
|
} else {
|
|
|
|
this.open(tab.views[0]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
isActiveTab(tab) {
|
|
|
|
return tab.views.some(view => this.isActiveView(view.name));
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2019-02-15 15:39:39 +05:30
|
|
|
<div class="multi-file-commit-panel ide-right-sidebar">
|
2018-11-08 19:23:39 +05:30
|
|
|
<resizable-panel
|
2018-12-05 23:21:45 +05:30
|
|
|
v-show="isOpen"
|
2018-11-08 19:23:39 +05:30
|
|
|
:collapsible="false"
|
|
|
|
:initial-width="350"
|
|
|
|
:min-size="350"
|
2018-12-05 23:21:45 +05:30
|
|
|
:class="`ide-right-sidebar-${currentView}`"
|
2018-11-08 19:23:39 +05:30
|
|
|
side="right"
|
2018-11-18 11:00:15 +05:30
|
|
|
class="multi-file-commit-panel-inner"
|
2018-11-08 19:23:39 +05:30
|
|
|
>
|
2018-12-05 23:21:45 +05:30
|
|
|
<div
|
|
|
|
v-for="tabView in aliveTabViews"
|
|
|
|
v-show="isActiveView(tabView.name)"
|
|
|
|
:key="tabView.name"
|
|
|
|
class="h-100"
|
|
|
|
>
|
2019-02-15 15:39:39 +05:30
|
|
|
<component :is="tabView.component || tabView.name" />
|
2018-12-05 23:21:45 +05:30
|
|
|
</div>
|
2018-11-08 19:23:39 +05:30
|
|
|
</resizable-panel>
|
|
|
|
<nav class="ide-activity-bar">
|
|
|
|
<ul class="list-unstyled">
|
2019-02-15 15:39:39 +05:30
|
|
|
<li v-for="tab of tabs" :key="tab.title">
|
2018-11-08 19:23:39 +05:30
|
|
|
<button
|
|
|
|
v-tooltip
|
2018-12-05 23:21:45 +05:30
|
|
|
:title="tab.title"
|
|
|
|
:aria-label="tab.title"
|
2018-11-18 11:00:15 +05:30
|
|
|
:class="{
|
2019-02-15 15:39:39 +05:30
|
|
|
active: isActiveTab(tab) && isOpen,
|
2018-11-18 11:00:15 +05:30
|
|
|
}"
|
|
|
|
data-container="body"
|
|
|
|
data-placement="left"
|
|
|
|
class="ide-sidebar-link is-right"
|
|
|
|
type="button"
|
2019-03-02 22:35:43 +05:30
|
|
|
@click="clickTab($event, tab)"
|
2018-11-18 11:00:15 +05:30
|
|
|
>
|
2019-02-15 15:39:39 +05:30
|
|
|
<icon :size="16" :name="tab.icon" />
|
2018-11-18 11:00:15 +05:30
|
|
|
</button>
|
|
|
|
</li>
|
2018-11-08 19:23:39 +05:30
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
</template>
|