From 8674f2002320aaa6c380488b0eab636a53c76705 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Mon, 11 Jan 2021 19:32:58 +0200 Subject: [PATCH] separated component --- src/components/notification/notification.js | 4 +- src/components/notification/notification.scss | 28 --------- src/components/notification/notification.vue | 33 +--------- src/components/report/report.js | 23 +++++++ src/components/report/report.scss | 39 ++++++++++++ src/components/report/report.vue | 63 +++++++++++++++++++ src/i18n/en.json | 10 +++ src/services/api/api.service.js | 32 +++++++++- 8 files changed, 171 insertions(+), 61 deletions(-) create mode 100644 src/components/report/report.js create mode 100644 src/components/report/report.scss create mode 100644 src/components/report/report.vue diff --git a/src/components/notification/notification.js b/src/components/notification/notification.js index a920bb3e..38211bb3 100644 --- a/src/components/notification/notification.js +++ b/src/components/notification/notification.js @@ -4,6 +4,7 @@ import Status from '../status/status.vue' import UserAvatar from '../user_avatar/user_avatar.vue' import UserCard from '../user_card/user_card.vue' import Timeago from '../timeago/timeago.vue' +import Report from '../report/report.vue' import { isStatusNotification } from '../../services/notification_utils/notification_utils.js' import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' @@ -44,7 +45,8 @@ const Notification = { UserAvatar, UserCard, Timeago, - Status + Status, + Report }, methods: { toggleUserExpanded () { diff --git a/src/components/notification/notification.scss b/src/components/notification/notification.scss index b103db86..f5905560 100644 --- a/src/components/notification/notification.scss +++ b/src/components/notification/notification.scss @@ -56,34 +56,6 @@ margin: 0 0.1em; } - .report-content { - margin: 0.5em 0; - } - - .reported-status { - border: 1px solid $fallback--faint; - border-color: var(--faint, $fallback--faint); - border-radius: $fallback--inputRadius; - border-radius: var(--inputRadius, $fallback--inputRadius); - color: $fallback--text; - color: var(--text, $fallback--text); - display: block; - padding: 0.5em; - margin: 0.5em 0; - - .status-content { - pointer-events: none; - } - - .reported-status-name { - font-weight: bold; - } - - .reported-status-timeago { - float: right; - } - } - &.-type--repeat .type-icon { color: $fallback--cGreen; color: var(--cGreen, $fallback--cGreen); diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue index 39e3bda0..3b74249d 100644 --- a/src/components/notification/notification.vue +++ b/src/components/notification/notification.vue @@ -183,37 +183,10 @@ @{{ notification.target.screen_name }} -
- Reported user: - - @{{ notification.report.acct.screen_name }} - - -
-
- Reported statuses: - - - {{ status.user.name }} - - - -
-
+ :report="notification.report" + /> + + + diff --git a/src/i18n/en.json b/src/i18n/en.json index 5936349a..3251de2a 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -237,6 +237,16 @@ "searching_for": "Searching for", "error": "Not found." }, + "report": { + "reporter": "Reporter:", + "reported_user": "Reported user:", + "reported_statuses": "Reported statuses:", + "notes": "Notes:", + "state": "State:", + "state_open": "Open", + "state_closed": "Closed", + "state_resolved": "Resolved" + }, "selectable_list": { "select_all": "Select all" }, diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 9a3494ff..e1e26151 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -87,6 +87,7 @@ const PLEROMA_CHAT_URL = id => `/api/v1/pleroma/chats/by-account-id/${id}` const PLEROMA_CHAT_MESSAGES_URL = id => `/api/v1/pleroma/chats/${id}/messages` const PLEROMA_CHAT_READ_URL = id => `/api/v1/pleroma/chats/${id}/read` const PLEROMA_DELETE_CHAT_MESSAGE_URL = (chatId, messageId) => `/api/v1/pleroma/chats/${chatId}/messages/${messageId}` +const PLEROMA_ADMIN_REPORTS = '/api/pleroma/admin/reports' const oldfetch = window.fetch @@ -759,7 +760,18 @@ const report = { "content": "This is the report created by "reporting_account". It reports "reported_account".", "created_at": "2020-09-03T14:22:59.000Z", "id": "9ymggNcUyfIW8Cq1zM", - "notes": [], + "notes": [ + { + "content": "Some note left here.", + "created_at": "2020-09-03T14:22:59.000Z", + "id": "1" + }, + { + "content": "Some other note that is much much much longer than the previous note left here.", + "created_at": "2020-09-03T14:23:59.000Z", + "id": "2" + } + ], "state": "open", "statuses": [ { @@ -1553,6 +1565,21 @@ const deleteChatMessage = ({ chatId, messageId, credentials }) => { }) } +const setReportState = ({ id, state, credentials }) => { + return promisedRequest({ + url: PLEROMA_ADMIN_REPORTS, + method: 'PATCH', + payload: { + 'reports': [ + { + id, + state + } + ] + } + }) +} + const apiService = { verifyCredentials, fetchTimeline, @@ -1638,7 +1665,8 @@ const apiService = { chatMessages, sendChatMessage, readChat, - deleteChatMessage + deleteChatMessage, + setReportState } export default apiService