Rename return property of 'extractNotificationDataOfCurrentUser'

- Renamed 'report' to 'filedReport'.
- Commented on the need of deep nested and similair properties for GQL of notifications.
This commit is contained in:
Wolfgang Huß 2020-04-03 15:25:07 +02:00
parent 2697408b65
commit b417667d31
5 changed files with 65 additions and 10 deletions

View File

@ -215,6 +215,8 @@ describe('given some notifications', () => {
})
describe('notifications', () => {
// properties should be deep nested and the same as in the "markAsReadMutation"
// reason is to test if all deep nested data is collected correctly with the Cypher statement. if not there will be a GraphQL error
const notificationQuery = gql`
query($read: Boolean, $orderBy: NotificationOrdering) {
notifications(read: $read, orderBy: $orderBy) {
@ -556,21 +558,67 @@ describe('given some notifications', () => {
})
describe('markAsRead', () => {
// properties should be deep nested and the same as in the "notificationQuery"
// reason is to test if all deep nested data is collected correctly with the Cypher statement. if not there will be a GraphQL error
const markAsReadMutation = gql`
mutation($id: ID!) {
markAsRead(id: $id) {
createdAt
updatedAt
read
reason
from {
__typename
... on Post {
content
author {
id
}
}
... on Comment {
content
author {
id
}
post {
id
author {
id
}
}
}
... on FiledReport {
reportId
reasonCategory
reasonDescription
resource {
__typename
... on User {
id
name
}
... on Post {
id
title
content
author {
id
}
}
... on Comment {
id
content
author {
id
}
post {
id
author {
id
}
}
}
}
}
}
}

View File

@ -30,16 +30,16 @@
<div v-if="notificationData.isReport">
<ds-space margin-bottom="x-small" />
<strong>{{ $t(`notifications.report.category`) }}:</strong>
{{ $t('report.reason.category.options.' + notificationData.report.reasonCategory) }}
{{ $t('report.reason.category.options.' + notificationData.filedReport.reasonCategory) }}
<br />
<strong>{{ $t(`notifications.report.description`) }}:</strong>
<span
v-if="
notificationData.report.reasonDescription &&
notificationData.report.reasonDescription !== ''
notificationData.filedReport.reasonDescription &&
notificationData.filedReport.reasonDescription !== ''
"
>
{{ notificationData.report.reasonDescription }}
{{ notificationData.filedReport.reasonDescription }}
</span>
<span v-else>

View File

@ -48,15 +48,18 @@
<span class="notification-content-header-text">
{{ $t(`notifications.report.category`) }}:
</span>
{{ $t('report.reason.category.options.' + scope.row.report.reasonCategory) }}
{{ $t('report.reason.category.options.' + scope.row.filedReport.reasonCategory) }}
<br />
<span class="notification-content-header-text">
{{ $t(`notifications.report.description`) }}:
</span>
<span
v-if="scope.row.report.reasonDescription && scope.row.report.reasonDescription !== ''"
v-if="
scope.row.filedReport.reasonDescription &&
scope.row.filedReport.reasonDescription !== ''
"
>
{{ scope.row.report.reasonDescription }}
{{ scope.row.filedReport.reasonDescription }}
</span>
<span v-else>

View File

@ -137,7 +137,7 @@ export const extractNotificationDataOfCurrentUser = (notification, currentUser)
let post = null
let comment = null
let contentExcerpt = null
let report = null
let filedReport = null
let isUser = false
let isPost = false
let isComment = false
@ -165,7 +165,7 @@ export const extractNotificationDataOfCurrentUser = (notification, currentUser)
triggerer = post.author
break
case 'FiledReport':
report = {
filedReport = {
reasonCategory: from.reasonCategory,
reasonDescription: from.reasonDescription,
}
@ -237,7 +237,7 @@ export const extractNotificationDataOfCurrentUser = (notification, currentUser)
author,
title,
contentExcerpt,
report,
filedReport,
reasonTranslationExtention,
linkTo: { name: linkName, params: linkParams, ...linkHashParam },
}

View File

@ -61,6 +61,7 @@ export const minimisedUserQuery = () => {
`
}
// properties have be in all notifications queries, mutations, and subscriptions here the same !!!
export const notificationQuery = (i18n) => {
return gql`
${userFragment}
@ -129,6 +130,7 @@ export const notificationQuery = (i18n) => {
`
}
// properties have be in all notifications queries, mutations, and subscriptions here the same !!!
export const markAsReadMutation = (i18n) => {
return gql`
${userFragment}
@ -197,6 +199,7 @@ export const markAsReadMutation = (i18n) => {
`
}
// properties have be in all notifications queries, mutations, and subscriptions here the same !!!
export const notificationAdded = () => {
return gql`
${userFragment}
@ -264,6 +267,7 @@ export const notificationAdded = () => {
}
`
}
export const followUserMutation = (i18n) => {
return gql`
${userFragment}