summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/components/ide_tree.vue
blob: 6399b510c1d9d7e93e6c3dce5ed8889f76123b65 (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
<script>
import { mapGetters, mapState, mapActions } from 'vuex';
import Icon from '~/vue_shared/components/icon.vue';
import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue';
import RepoFile from './repo_file.vue';
import NewDropdown from './new_dropdown/index.vue';

export default {
  components: {
    Icon,
    RepoFile,
    SkeletonLoadingContainer,
    NewDropdown,
  },
  computed: {
    ...mapState(['currentBranchId']),
    ...mapGetters(['currentProject', 'currentTree', 'activeFile']),
  },
  mounted() {
    if (this.activeFile && this.activeFile.pending) {
      this.$router.push(`/project${this.activeFile.url}`, () => {
        this.updateViewer('editor');
      });
    }
  },
  methods: {
    ...mapActions(['updateViewer']),
  },
};
</script>

<template>
  <div
    class="ide-file-list"
  >
    <template v-if="!currentTree || currentTree.loading">
      <div
        class="multi-file-loading-container"
        v-for="n in 3"
        :key="n"
      >
        <skeleton-loading-container />
      </div>
    </template>
    <template v-else>
      <header class="ide-tree-header">
        {{ __('Edit') }}
        <new-dropdown
          :project-id="currentProject.name_with_namespace"
          :branch="currentBranchId"
          path=""
        />
      </header>
      <repo-file
        v-for="file in currentTree.tree"
        :key="file.key"
        :file="file"
        :level="0"
      />
    </template>
  </div>
</template>