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

abuse_report_row.vue « components « abuse_reports « admin « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b229dd9e993828cc2c524f6db940dd1d7e12e3e3 (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 { GlLink } from '@gitlab/ui';
import { getTimeago } from '~/lib/utils/datetime_utility';
import { queryToObject } from '~/lib/utils/url_utility';
import { s__, __, sprintf } from '~/locale';
import ListItem from '~/vue_shared/components/registry/list_item.vue';
import { SORT_UPDATED_AT } from '../constants';
import AbuseCategory from './abuse_category.vue';

export default {
  name: 'AbuseReportRow',
  components: {
    GlLink,
    ListItem,
    AbuseCategory,
  },
  props: {
    report: {
      type: Object,
      required: true,
    },
  },
  computed: {
    displayDate() {
      const { sort } = queryToObject(window.location.search);
      const { createdAt, updatedAt } = this.report;
      const { template, timeAgo } = Object.values(SORT_UPDATED_AT.sortDirection).includes(sort)
        ? { template: __('Updated %{timeAgo}'), timeAgo: updatedAt }
        : { template: __('Created %{timeAgo}'), timeAgo: createdAt };

      return sprintf(template, { timeAgo: getTimeago().format(timeAgo) });
    },
    title() {
      const { reportedUser, category, reporter } = this.report;
      const template = s__('AbuseReports|%{reportedUser} reported for %{category} by %{reporter}');
      return sprintf(template, {
        reportedUser: reportedUser?.name || s__('AbuseReports|Deleted user'),
        reporter: reporter?.name || s__('AbuseReports|Deleted user'),
        category,
      });
    },
  },
};
</script>

<template>
  <list-item data-testid="abuse-report-row">
    <template #left-primary>
      <gl-link
        :href="report.reportPath"
        class="gl-font-weight-normal gl-pt-4 gl-text-gray-900"
        data-testid="abuse-report-title"
      >
        {{ title }}
      </gl-link>
    </template>
    <template #left-secondary>
      <abuse-category
        :category="report.category"
        class="gl-mt-2 gl-mb-3"
        data-testid="abuse-report-category"
      />
    </template>

    <template #right-secondary>
      <div class="gl-mt-7" data-testid="abuse-report-date">{{ displayDate }}</div>
    </template>
  </list-item>
</template>