summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/panes/right.vue
blob: 75a9a9e9b8f568519c90840805ce6a9433c9b533 (plain)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<script>
import { mapActions, mapState, mapGetters } from 'vuex';
import { __ } from '~/locale';
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';
import Clientside from '../preview/clientside.vue';

export default {
  directives: {
    tooltip,
  },
  components: {
    Icon,
    PipelinesList,
    JobsDetail,
    ResizablePanel,
    MergeRequestInfo,
    Clientside,
  },
  props: {
    extensionTabs: {
      type: Array,
      required: false,
      default: () => [],
    },
  },
  computed: {
    ...mapState(['rightPane', 'currentMergeRequestId', 'clientsidePreviewEnabled']),
    ...mapGetters(['packageJson']),
    pipelinesActive() {
      return (
        this.rightPane === rightSidebarViews.pipelines ||
        this.rightPane === rightSidebarViews.jobsDetail
      );
    },
    showLivePreview() {
      return this.packageJson && this.clientsidePreviewEnabled;
    },
    defaultTabs() {
      return [
        {
          show: this.currentMergeRequestId,
          title: __('Merge Request'),
          isActive: this.rightPane === rightSidebarViews.mergeRequestInfo,
          view: rightSidebarViews.mergeRequestInfo,
          icon: 'text-description',
        },
        {
          show: true,
          title: __('Pipelines'),
          isActive: this.pipelinesActive,
          view: rightSidebarViews.pipelines,
          icon: 'rocket',
        },
        {
          show: this.showLivePreview,
          title: __('Live preview'),
          isActive: this.rightPane === rightSidebarViews.clientSidePreview,
          view: rightSidebarViews.clientSidePreview,
          icon: 'live-preview',
        },
      ];
    },
    tabs() {
      return this.defaultTabs
        .concat(this.extensionTabs)
        .filter(tab => tab.show);
    },
  },
  methods: {
    ...mapActions(['setRightPane']),
    clickTab(e, view) {
      e.target.blur();

      this.setRightPane(view);
    },
  },
};
</script>

<template>
  <div
    class="multi-file-commit-panel ide-right-sidebar"
  >
    <resizable-panel
      v-if="rightPane"
      :collapsible="false"
      :initial-width="350"
      :min-size="350"
      :class="`ide-right-sidebar-${rightPane}`"
      side="right"
      class="multi-file-commit-panel-inner"
    >
      <component :is="rightPane" />
    </resizable-panel>
    <nav class="ide-activity-bar">
      <ul class="list-unstyled">
        <li
          v-for="tab of tabs"
          :key="tab.title"
        >
          <button
            v-tooltip
            :title="tab.title"
            :aria-label="tab.title"
            :class="{
              active: tab.isActive
            }"
            data-container="body"
            data-placement="left"
            class="ide-sidebar-link is-right"
            type="button"
            @click="clickTab($event, tab.view)"
          >
            <icon
              :size="16"
              :name="tab.icon"
            />
          </button>
        </li>
      </ul>
    </nav>
  </div>
</template>