summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/ide_repo_tree.vue
blob: 4651e345d7505edd101a4b1434847394a847dc1c (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
<script>
import { mapState } from 'vuex';
import repoPreviousDirectory from './repo_prev_directory.vue';
import repoFile from './repo_file.vue';
import skeletonLoadingContainer from '../../vue_shared/components/skeleton_loading_container.vue';
import { treeList } from '../stores/utils';

export default {
  components: {
    repoPreviousDirectory,
    repoFile,
    skeletonLoadingContainer,
  },
  props: {
    treeId: {
      type: String,
      required: true,
    },
  },
  computed: {
    ...mapState([
      'trees',
      'isRoot',
    ]),
    ...mapState({
      projectName(state) {
        return state.project.name;
      },
    }),
    fetchedList() {
      return treeList(this.$store.state, this.treeId);
    },
    hasPreviousDirectory() {
      return !this.isRoot && this.fetchedList.length;
    },
    showLoading() {
      if (this.trees[this.treeId]) {
        return this.trees[this.treeId].loading;
      }
      return true;
    },
  },
};
</script>

<template>
  <div>
    <div class="ide-file-list">
      <table class="table">
        <tbody
          v-if="treeId"
        >
          <repo-previous-directory
            v-if="hasPreviousDirectory"
          />
          <template v-if="showLoading">
            <div
              class="multi-file-loading-container"
              v-for="n in 3"
              :key="n"
            >
              <skeleton-loading-container />
            </div>
          </template>
          <repo-file
            v-for="file in fetchedList"
            :key="file.key"
            :file="file"
          />
        </tbody>
      </table>
    </div>
  </div>
</template>