summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repo/components/repo_sidebar.vue
blob: 4ea219131297d9150558c7bf87f795d4f05da1b8 (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
<script>
import { mapState, mapGetters, mapActions } from 'vuex';
import RepoPreviousDirectory from './repo_prev_directory.vue';
import RepoFile from './repo_file.vue';
import RepoLoadingFile from './repo_loading_file.vue';

export default {
  components: {
    'repo-previous-directory': RepoPreviousDirectory,
    'repo-file': RepoFile,
    'repo-loading-file': RepoLoadingFile,
  },
  created() {
    window.addEventListener('popstate', this.popHistoryState);
  },
  destroyed() {
    window.removeEventListener('popstate', this.popHistoryState);
  },
  mounted() {
    this.getTreeData();
  },
  computed: {
    ...mapState([
      'loading',
      'isRoot',
    ]),
    ...mapState({
      projectName(state) {
        return state.project.name;
      },
    }),
    ...mapGetters([
      'treeList',
      'isCollapsed',
    ]),
  },
  methods: {
    ...mapActions([
      'getTreeData',
      'popHistoryState',
    ]),
  },
};
</script>

<template>
<div class="ide-file-list">
  <table class="table">
    <thead>
      <tr>
        <th
          v-if="isCollapsed"
        >
        </th>
        <template v-else>
          <th class="name multi-file-table-name">
            Name
          </th>
          <th class="hidden-sm hidden-xs last-commit">
            Last commit
          </th>
          <th class="hidden-xs last-update text-right">
            Last update
          </th>
        </template>
      </tr>
    </thead>
    <tbody>
      <repo-previous-directory
        v-if="!isRoot && treeList.length"
      />
      <repo-loading-file
        v-if="!treeList.length && loading"
        v-for="n in 5"
        :key="n"
      />
      <repo-file
        v-for="file in treeList"
        :key="file.key"
        :file="file"
      />
    </tbody>
  </table>
</div>
</template>