summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/groups/components/project_folder.vue
blob: 15128264516dfa7bc39c09125c7dcd81be8c0d0f (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
<script>
import { MAX_PROJECT_COUNT } from '../constants';
import projectItem from './project_item.vue';
import identicon from '../../vue_shared/components/identicon.vue';

export default {
  components: {
    projectItem,
    identicon,
  },
  props: {
    groupPath: {
      type: String,
      required: true,
    },
    projects: {
      type: Array,
      required: true,
    },
    hasSiblingGroups: {
      type: Boolean,
      required: true,
    },
    projectCount: {
      type: Number,
      required: true,
    },
  },
  computed: {
    hasMoreItems() {
      return this.projectCount > MAX_PROJECT_COUNT;
    },
    countOfMoreProjects() {
      return this.projectCount - MAX_PROJECT_COUNT;
    },
    moreProjectsLinkText() {
      // eslint-disable-next-line no-underscore-dangle
      return `${this.countOfMoreProjects} more ${this.n__('project', 'projects', this.countOfMoreProjects)}`;
    },
  },
};
</script>

<template>
  <ul
    class="content-list group-list-tree project-list"
    :class="{ 'has-sibling-groups': hasSiblingGroups, 'has-more-items': hasMoreItems }"
  >
    <project-item
      v-for="(project, index) in projects"
      :key="index"
      :project="project"
    />
    <li
      v-if="hasMoreItems"
      class="has-more-items-link"
    >
      <a
        :href="this.groupPath">
        <i
          class="fa fa-external-link"
          aria-hidden="true"/>
        {{moreProjectsLinkText}}
      </a>
    </li>
  </ul>
</template>