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

reported_content.vue « components « abuse_report « admin « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 84d6f25ac05463e598d9cc3dd07c3d96b12c4f88 (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
<script>
import { GlButton, GlModal, GlCard, GlLink, GlAvatar, GlTruncateText } from '@gitlab/ui';
import { __ } from '~/locale';
import SafeHtml from '~/vue_shared/directives/safe_html';
import { renderGFM } from '~/behaviors/markdown/render_gfm';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import { REPORTED_CONTENT_I18N } from '../constants';

export default {
  name: 'ReportedContent',
  components: {
    GlButton,
    GlModal,
    GlCard,
    GlLink,
    GlAvatar,
    GlTruncateText,
    TimeAgoTooltip,
  },
  modalId: 'abuse-report-screenshot-modal',
  directives: {
    SafeHtml,
  },
  props: {
    report: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      showScreenshotModal: false,
    };
  },
  computed: {
    reporter() {
      return this.report.reporter;
    },
    reporterName() {
      return this.reporter?.name || this.$options.i18n.deletedReporter;
    },
    reportType() {
      return this.report.type || 'unknown';
    },
  },
  mounted() {
    renderGFM(this.$refs.gfmContent);
  },
  methods: {
    toggleScreenshotModal() {
      this.showScreenshotModal = !this.showScreenshotModal;
    },
  },
  i18n: REPORTED_CONTENT_I18N,
  screenshotModalButtonAttributes: {
    text: __('Close'),
    attributes: {
      variant: 'confirm',
    },
  },
  safeHtmlConfig: { ADD_TAGS: ['gl-emoji'] },
};
</script>

<template>
  <div class="gl-pt-6">
    <div
      class="gl-pb-3 gl-display-flex gl-justify-content-space-between gl-xs-flex-direction-column gl-align-items-center"
    >
      <h2 class="gl-font-lg gl-mt-2 gl-mb-2">
        {{ $options.i18n.reportTypes[reportType] }}
      </h2>

      <div
        class="gl-display-flex gl-align-items-stretch gl-xs-flex-direction-column gl-mt-3 gl-sm-mt-0"
      >
        <template v-if="report.screenshot">
          <gl-button data-testid="screenshot-button" @click="toggleScreenshotModal">
            {{ $options.i18n.viewScreenshot }}
          </gl-button>
          <gl-modal
            v-model="showScreenshotModal"
            :title="$options.i18n.screenshotTitle"
            :modal-id="$options.modalId"
            :action-primary="$options.screenshotModalButtonAttributes"
          >
            <img
              :src="report.screenshot"
              :alt="$options.i18n.screenshotTitle"
              class="gl-w-full gl-h-auto"
            />
          </gl-modal>
        </template>
        <gl-button
          v-if="report.url"
          data-testid="report-url-button"
          :href="report.url"
          class="gl-sm-ml-3 gl-mt-3 gl-sm-mt-0"
        >
          {{ $options.i18n.goToType[reportType] }}
        </gl-button>
      </div>
    </div>
    <gl-card
      header-class="gl-bg-white js-test-card-header"
      body-class="gl-bg-gray-50 gl-px-5 gl-py-3 js-test-card-body"
      footer-class="gl-bg-white js-test-card-footer"
    >
      <template v-if="report.content" #header>
        <gl-truncate-text>
          <div
            ref="gfmContent"
            v-safe-html:[$options.safeHtmlConfig]="report.content"
            class="md"
          ></div>
        </gl-truncate-text>
      </template>
      {{ $options.i18n.reportedBy }}
      <template #footer>
        <div class="gl-display-flex gl-align-items-center gl-mb-2">
          <gl-avatar :size="32" :src="reporter && reporter.avatarUrl" />
          <div class="gl-display-flex gl-flex-wrap">
            <span class="gl-ml-3 gl-font-weight-bold">
              {{ reporterName }}
            </span>
            <gl-link v-if="reporter" :href="reporter.path" class="gl-ml-3">
              @{{ reporter.username }}
            </gl-link>
            <time-ago-tooltip
              :time="report.reportedAt"
              class="gl-ml-3 gl-text-secondary gl-xs-w-full"
            />
          </div>
        </div>
        <p v-if="report.message" class="gl-pl-8 gl-mb-0">{{ report.message }}</p>
      </template>
    </gl-card>
  </div>
</template>