Welcome to mirror list, hosted at ThFree Co, Russian Federation.

project_list_item.vue « project_selector « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e053a9ddaa698bef2c180c778b254e6a989e20f8 (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
<script>
import { GlDeprecatedButton } from '@gitlab/ui';
import { isString } from 'lodash';
import Icon from '~/vue_shared/components/icon.vue';
import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue';
import highlight from '~/lib/utils/highlight';
import { truncateNamespace } from '~/lib/utils/text_utility';

export default {
  name: 'ProjectListItem',
  components: { Icon, ProjectAvatar, GlDeprecatedButton },
  props: {
    project: {
      type: Object,
      required: true,
      validator: p =>
        (Number.isFinite(p.id) || isString(p.id)) &&
        isString(p.name) &&
        (isString(p.name_with_namespace) || isString(p.nameWithNamespace)),
    },
    selected: { type: Boolean, required: true },
    matcher: { type: String, required: false, default: '' },
  },
  computed: {
    projectNameWithNamespace() {
      return this.project.nameWithNamespace || this.project.name_with_namespace;
    },
    truncatedNamespace() {
      return truncateNamespace(this.projectNameWithNamespace);
    },
    highlightedProjectName() {
      return highlight(this.project.name, this.matcher);
    },
  },
  methods: {
    onClick() {
      this.$emit('click');
    },
  },
};
</script>
<template>
  <gl-deprecated-button
    class="d-flex align-items-center btn pt-1 pb-1 border-0 project-list-item"
    @click="onClick"
  >
    <icon
      class="gl-ml-3 gl-mr-3 flex-shrink-0 position-top-0 js-selected-icon"
      :class="{ 'js-selected visible': selected, 'js-unselected invisible': !selected }"
      name="mobile-issue-close"
    />
    <project-avatar class="flex-shrink-0 js-project-avatar" :project="project" :size="32" />
    <div class="d-flex flex-wrap project-namespace-name-container">
      <div
        v-if="truncatedNamespace"
        :title="projectNameWithNamespace"
        class="text-secondary text-truncate js-project-namespace"
      >
        {{ truncatedNamespace }}
        <span v-if="truncatedNamespace" class="text-secondary">/&nbsp;</span>
      </div>
      <div
        :title="project.name"
        class="js-project-name text-truncate"
        v-html="highlightedProjectName"
      ></div>
    </div>
  </gl-deprecated-button>
</template>