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

item.vue « components « issuable_suggestions « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6e265b1bf4242a402ef161b29cb031cfa2c0fc6d (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<script>
/* eslint-disable @gitlab/vue-require-i18n-strings */
import { uniqueId } from 'lodash';
import { GlLink, GlTooltip, GlTooltipDirective, GlIcon } from '@gitlab/ui';
import { __ } from '~/locale';
import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_image.vue';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import timeago from '~/vue_shared/mixins/timeago';

export default {
  components: {
    GlTooltip,
    GlLink,
    GlIcon,
    UserAvatarImage,
    TimeagoTooltip,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  mixins: [timeago],
  props: {
    suggestion: {
      type: Object,
      required: true,
    },
  },
  computed: {
    isOpen() {
      return this.suggestion.state === 'opened';
    },
    isClosed() {
      return this.suggestion.state === 'closed';
    },
    counts() {
      return [
        {
          id: uniqueId(),
          icon: 'thumb-up',
          tooltipTitle: __('Upvotes'),
          count: this.suggestion.upvotes,
        },
        {
          id: uniqueId(),
          icon: 'comment',
          tooltipTitle: __('Comments'),
          count: this.suggestion.userNotesCount,
        },
      ].filter(({ count }) => count);
    },
    stateIcon() {
      return this.isClosed ? 'issue-close' : 'issue-open-m';
    },
    stateTitle() {
      return this.isClosed ? __('Closed') : __('Opened');
    },
    closedOrCreatedDate() {
      return this.suggestion.closedAt || this.suggestion.createdAt;
    },
    hasUpdated() {
      return this.suggestion.updatedAt !== this.suggestion.createdAt;
    },
  },
};
</script>

<template>
  <div class="suggestion-item">
    <div class="d-flex align-items-center">
      <gl-icon
        v-if="suggestion.confidential"
        v-gl-tooltip.bottom
        :title="__('Confidential')"
        name="eye-slash"
        class="suggestion-help-hover mr-1 suggestion-confidential"
      />
      <gl-link
        :href="suggestion.webUrl"
        target="_blank"
        class="suggestion bold str-truncated-100 gl-text-gray-900!"
      >
        {{ suggestion.title }}
      </gl-link>
    </div>
    <div class="text-secondary suggestion-footer">
      <gl-icon
        ref="state"
        :name="stateIcon"
        :class="{
          'suggestion-state-open': isOpen,
          'suggestion-state-closed': isClosed,
        }"
        class="suggestion-help-hover"
      />
      <gl-tooltip :target="() => $refs.state" placement="bottom">
        <span class="d-block">
          <span class="bold"> {{ stateTitle }} </span> {{ timeFormatted(closedOrCreatedDate) }}
        </span>
        <span class="text-tertiary">{{ tooltipTitle(closedOrCreatedDate) }}</span>
      </gl-tooltip>
      #{{ suggestion.iid }} &bull;
      <timeago-tooltip
        :time="suggestion.createdAt"
        tooltip-placement="bottom"
        class="suggestion-help-hover"
      />
      by
      <gl-link :href="suggestion.author.webUrl">
        <user-avatar-image
          :img-src="suggestion.author.avatarUrl"
          :size="16"
          css-classes="mr-0 float-none"
          tooltip-placement="bottom"
          class="d-inline-block"
        >
          <span class="bold d-block">{{ __('Author') }}</span> {{ suggestion.author.name }}
          <span class="text-tertiary">@{{ suggestion.author.username }}</span>
        </user-avatar-image>
      </gl-link>
      <template v-if="hasUpdated">
        &bull; {{ __('updated') }}
        <timeago-tooltip
          :time="suggestion.updatedAt"
          tooltip-placement="bottom"
          class="suggestion-help-hover"
        />
      </template>
      <span class="suggestion-counts">
        <span
          v-for="{ count, icon, tooltipTitle, id } in counts"
          :key="id"
          v-gl-tooltip.bottom
          :title="tooltipTitle"
          class="suggestion-help-hover gl-ml-3 text-tertiary"
        >
          <gl-icon :name="icon" /> {{ count }}
        </span>
      </span>
    </div>
  </div>
</template>