summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/ide_context_bar.vue
blob: 78c01272af611f63cda72f2d432a091e5af644b3 (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
<script>
import { mapGetters, mapState, mapActions } from 'vuex';
import repoCommitSection from './repo_commit_section.vue';
import icon from '../../vue_shared/components/icon.vue';
import panelResizer from '../../vue_shared/components/panel_resizer.vue';

export default {
  data() {
    return {
      width: 290,
    };
  },
  components: {
    repoCommitSection,
    icon,
    panelResizer,
  },
  computed: {
    ...mapState([
      'rightPanelCollapsed',
    ]),
    ...mapGetters([
      'changedFiles',
    ]),
    currentIcon() {
      return this.rightPanelCollapsed ? 'angle-double-left' : 'angle-double-right';
    },
    maxSize() {
      return window.innerWidth / 2;
    },
    panelStyle() {
      if (!this.rightPanelCollapsed) {
        return { width: `${this.width}px` };
      }
      return {};
    },
  },
  methods: {
    ...mapActions([
      'setPanelCollapsedStatus',
      'setResizingStatus',
    ]),
    toggleCollapsed() {
      this.setPanelCollapsedStatus({
        side: 'right',
        collapsed: !this.rightPanelCollapsed,
      });
    },
    resizingStarted() {
      this.setResizingStatus(true);
    },
    resizingEnded() {
      this.setResizingStatus(false);
    },
  },
};
</script>

<template>
  <div
    class="multi-file-commit-panel"
    :class="{
      'is-collapsed': rightPanelCollapsed,
    }"
    :style="panelStyle"
  >
    <div 
      class="multi-file-commit-panel-section">
      <header
        class="multi-file-commit-panel-header"
        :class="{
            'is-collapsed': rightPanelCollapsed,
          }"
        >
        <div
          class="multi-file-commit-panel-header-title"
          v-if="!rightPanelCollapsed">
          <icon
            name="list-bulleted"
            :size="18"
          />
          Staged
        </div>
        <button
          type="button"
          class="btn btn-transparent multi-file-commit-panel-collapse-btn"
          @click="toggleCollapsed"
        >
          <icon
            :name="currentIcon"
            :size="18"
          />
        </button>
      </header>
      <repo-commit-section 
        class=""/>
    </div>
    <panel-resizer
      :size.sync="width"
      :enabled="!rightPanelCollapsed"
      :start-size="290"
      :min-size="200"
      :max-size="maxSize"
      @resize-start="resizingStarted"
      @resize-end="resizingEnded"
      side="left"/>
  </div>
</template>