all files / src/components/FileTree/ index.vue

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1
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                                                                                                                                                         
<template>
  <div class="file-tree">
    <Loading v-if="isLoading" :text="'File Loading...'"></Loading>
    <div class="file-empty" v-if="tree.filesCount === 0">
      <p>NO FILE. WAIT FOR LOADING.</p>
    </div>
    <div class="file-container" v-else>
      <input type="text" class="search" v-model="searchInput" placeholder="Search Input...">
      <div class="content">
        <Folder v-for="(folder, index) in tree.folders" :key="index" :content="folder" :depth="0" />
      </div>
    </div>
  </div>
</template>
 
<script>
import Loading from '../Loading'
import Folder from './Folder'
import { mapGetters, mapActions } from 'vuex'
 
export default {
  name: 'FileTree',
  components: {
    Loading,
    Folder
  },
  data () {
    return {
      searchInput: ''
    }
  },
  computed: {
    ...mapGetters(['isLoading']),
    ...mapGetters('files', ['tree'])
  },
  watch: {
    searchInput: 'searchFile'
  },
  methods: {
    ...mapActions('files', ['searchFile'])
  }
}
</script>
 
<style lang="scss" scoped>
.file-tree {
  position: relative;
  .file-empty {
    p {
      font-size: 14px;
      font-weight: 300;
      text-align: center;
    }
  }
  .file-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    .search {
      display: block;
      flex: 0 0 40px;
      padding-left: 20px;
      margin-bottom: 10px;
      font-size: 14px;
      line-height: 40px;
      border-bottom: 1px solid rgba(255,255,255,0.2);
    }
    .content {
      flex: 1;
      overflow: auto;
      margin-right: -15px;
    }
  }
}
</style>