ide_repo_tree.vue 1.6 KB
Newer Older
1 2
<script>
import { mapState } from 'vuex';
3
import skeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue';
4 5
import repoPreviousDirectory from './repo_prev_directory.vue';
import repoFile from './repo_file.vue';
6 7 8 9
import { treeList } from '../stores/utils';

export default {
  components: {
10 11 12
    repoPreviousDirectory,
    repoFile,
    skeletonLoadingContainer,
13 14 15 16 17 18 19 20 21
  },
  props: {
    treeId: {
      type: String,
      required: true,
    },
  },
  computed: {
    ...mapState([
22
      'trees',
23 24 25 26 27 28 29 30 31 32 33 34 35 36
      'isRoot',
    ]),
    ...mapState({
      projectName(state) {
        return state.project.name;
      },
    }),
    fetchedList() {
      return treeList(this.$store.state, this.treeId);
    },
    hasPreviousDirectory() {
      return !this.isRoot && this.fetchedList.length;
    },
    showLoading() {
37 38 39 40
      if (this.trees[this.treeId]) {
        return this.trees[this.treeId].loading;
      }
      return true;
41 42 43 44 45 46
    },
  },
};
</script>

<template>
Filipa Lacerda's avatar
Filipa Lacerda committed
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
  <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>
73 74
  </div>
</template>