mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Rename variables, parameters and properties
This commit is contained in:
parent
b4f47997b3
commit
935252a16e
@ -2,14 +2,14 @@ import uuid from 'uuid/v4'
|
||||
|
||||
export default {
|
||||
Mutation: {
|
||||
report: async (_parent, { id, reasonCategory, description }, { driver, req, user }, _resolveInfo) => {
|
||||
report: async (_parent, { resourceId, reasonCategory, reasonDescription }, { driver, req, user }, _resolveInfo) => {
|
||||
const reportId = uuid()
|
||||
const session = driver.session()
|
||||
const reportProperties = {
|
||||
id: reportId,
|
||||
createdAt: new Date().toISOString(),
|
||||
reasonCategory,
|
||||
description,
|
||||
reasonDescription,
|
||||
}
|
||||
|
||||
const reportQueryRes = await session.run(
|
||||
@ -18,7 +18,7 @@ export default {
|
||||
RETURN labels(resource)[0] as label
|
||||
`,
|
||||
{
|
||||
resourceId: id,
|
||||
resourceId,
|
||||
submitterId: user.id,
|
||||
},
|
||||
)
|
||||
@ -43,7 +43,7 @@ export default {
|
||||
RETURN report, submitter, resource, labels(resource)[0] as type
|
||||
`,
|
||||
{
|
||||
resourceId: id,
|
||||
resourceId,
|
||||
userId: user.id,
|
||||
reportProperties,
|
||||
},
|
||||
|
||||
@ -18,9 +18,9 @@ describe('report', () => {
|
||||
beforeEach(async () => {
|
||||
returnedObject = '{ id }'
|
||||
variables = {
|
||||
id: 'whatever',
|
||||
resourceId: 'whatever',
|
||||
reasonCategory: 'reason-category-dummy',
|
||||
description: 'Violates code of conduct !!!',
|
||||
reasonDescription: 'Violates code of conduct !!!',
|
||||
}
|
||||
headers = {}
|
||||
user = await factory.create('User', {
|
||||
@ -49,8 +49,8 @@ describe('report', () => {
|
||||
const action = () => {
|
||||
// because of the template `${returnedObject}` the 'gql' tag from 'jest/helpers' is not working here
|
||||
reportMutation = `
|
||||
mutation($id: ID!, $reasonCategory: String!, $description: String!) {
|
||||
report( id: $id, reasonCategory: $reasonCategory, description: $description) ${returnedObject}
|
||||
mutation($resourceId: ID!, $reasonCategory: String!, $reasonDescription: String!) {
|
||||
report( resourceId: $resourceId, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription) ${returnedObject}
|
||||
}
|
||||
`
|
||||
client = new GraphQLClient(host, {
|
||||
@ -86,7 +86,7 @@ describe('report', () => {
|
||||
beforeEach(async () => {
|
||||
variables = {
|
||||
...variables,
|
||||
id: 'u2',
|
||||
resourceId: 'u2',
|
||||
}
|
||||
})
|
||||
|
||||
@ -146,12 +146,12 @@ describe('report', () => {
|
||||
it('returns the reason description', async () => {
|
||||
variables = {
|
||||
...variables,
|
||||
description: 'My reason!',
|
||||
reasonDescription: 'My reason!',
|
||||
}
|
||||
returnedObject = '{ description }'
|
||||
returnedObject = '{ reasonDescription }'
|
||||
await expect(action()).resolves.toEqual({
|
||||
report: {
|
||||
description: 'My reason!',
|
||||
reasonDescription: 'My reason!',
|
||||
},
|
||||
})
|
||||
})
|
||||
@ -167,7 +167,7 @@ describe('report', () => {
|
||||
})
|
||||
variables = {
|
||||
...variables,
|
||||
id: 'p23',
|
||||
resourceId: 'p23',
|
||||
}
|
||||
})
|
||||
|
||||
@ -221,7 +221,7 @@ describe('report', () => {
|
||||
})
|
||||
variables = {
|
||||
...variables,
|
||||
id: 'c34',
|
||||
resourceId: 'c34',
|
||||
}
|
||||
})
|
||||
|
||||
@ -256,7 +256,7 @@ describe('report', () => {
|
||||
})
|
||||
variables = {
|
||||
...variables,
|
||||
id: 't23',
|
||||
resourceId: 't23',
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ type Mutation {
|
||||
changePassword(oldPassword: String!, newPassword: String!): String!
|
||||
requestPasswordReset(email: String!): Boolean!
|
||||
resetPassword(email: String!, nonce: String!, newPassword: String!): Boolean!
|
||||
report(id: ID!, reasonCategory: String!, description: String!): Report
|
||||
report(resourceId: ID!, reasonCategory: String!, reasonDescription: String!): Report
|
||||
disable(id: ID!): ID
|
||||
enable(id: ID!): ID
|
||||
# Shout the given Type and ID
|
||||
@ -39,7 +39,7 @@ type Report {
|
||||
id: ID!
|
||||
createdAt: String!
|
||||
reasonCategory: String!
|
||||
description: String!
|
||||
reasonDescription: String!
|
||||
submitter: User @relation(name: "REPORTED", direction: "IN")
|
||||
type: String!
|
||||
@cypher(statement: "MATCH (resource)<-[:REPORTED]-(this) RETURN labels(resource)[0]")
|
||||
|
||||
@ -650,8 +650,8 @@ import { gql } from '../jest/helpers'
|
||||
authenticatedUser = null
|
||||
|
||||
const reportMutation = gql`
|
||||
mutation($id: ID!, $description: String!) {
|
||||
report(description: $description, id: $id) {
|
||||
mutation($resourceId: ID!, $reasonDescription: String!) {
|
||||
report(reasonDescription: $reasonDescription, resourceId: $resourceId) {
|
||||
id
|
||||
}
|
||||
}
|
||||
@ -661,22 +661,22 @@ import { gql } from '../jest/helpers'
|
||||
mutate({
|
||||
mutation: reportMutation,
|
||||
variables: {
|
||||
description: 'This comment is bigoted',
|
||||
id: 'c1',
|
||||
reasonDescription: 'This comment is bigoted',
|
||||
resourceId: 'c1',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: reportMutation,
|
||||
variables: {
|
||||
description: 'This post is bigoted',
|
||||
id: 'p1',
|
||||
reasonDescription: 'This post is bigoted',
|
||||
resourceId: 'p1',
|
||||
},
|
||||
}),
|
||||
mutate({
|
||||
mutation: reportMutation,
|
||||
variables: {
|
||||
description: 'This user is harassing me with bigoted remarks',
|
||||
id: 'u1',
|
||||
reasonDescription: 'This user is harassing me with bigoted remarks',
|
||||
resourceId: 'u1',
|
||||
},
|
||||
}),
|
||||
])
|
||||
|
||||
@ -122,13 +122,13 @@ Given('somebody reported the following posts:', table => {
|
||||
cy.factory()
|
||||
.create('User', submitter)
|
||||
.authenticateAs(submitter)
|
||||
.mutate(`mutation($id: ID!, $description: String!) {
|
||||
report(description: $description, id: $id) {
|
||||
.mutate(`mutation($resourceId: ID!, $reasonDescription: String!) {
|
||||
report(reasonDescription: $reasonDescription, resourceId: $resourceId) {
|
||||
id
|
||||
}
|
||||
}`, {
|
||||
id,
|
||||
description: 'Offensive content'
|
||||
resourceId,
|
||||
reasonDescription: 'Offensive content'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -28,24 +28,24 @@
|
||||
:options="form.reasonCategoryOptions"
|
||||
/>
|
||||
<!-- Wolle <ds-input
|
||||
model="reasonAddText"
|
||||
:label="$t('report.reason.addText.label')"
|
||||
:placeholder="$t('report.reason.addText.placeholder')"
|
||||
model="reasonDescription"
|
||||
:label="$t('report.reason.description.label')"
|
||||
:placeholder="$t('report.reason.description.placeholder')"
|
||||
type="textarea"
|
||||
rows="5"
|
||||
class="reasonAddText"
|
||||
class="reasonDescription"
|
||||
/> -->
|
||||
<ds-input
|
||||
:value="form.reasonAddText"
|
||||
:schema="formSchema.reasonAddText"
|
||||
:label="$t('report.reason.addText.label')"
|
||||
:placeholder="$t('report.reason.addText.placeholder')"
|
||||
:value="form.reasonDescription"
|
||||
:schema="formSchema.reasonDescription"
|
||||
:label="$t('report.reason.description.label')"
|
||||
:placeholder="$t('report.reason.description.placeholder')"
|
||||
type="textarea"
|
||||
rows="5"
|
||||
class="reasonAddText"
|
||||
class="reasonDescription"
|
||||
/>
|
||||
<small class="smallTag">
|
||||
{{ form.reasonAddText.length }}/{{ formSchema.reasonAddText.max }}
|
||||
{{ form.reasonDescription.length }}/{{ formSchema.reasonDescription.max }}
|
||||
</small>
|
||||
<ds-space />
|
||||
<!-- Wolle </ds-form> -->
|
||||
@ -109,7 +109,7 @@ export default {
|
||||
reasonCategory: null,
|
||||
// Wolle reasonCategory: reasonCategoryOptions[0],
|
||||
reasonCategoryOptions,
|
||||
reasonAddText: '',
|
||||
reasonDescription: '',
|
||||
},
|
||||
formSchema: {
|
||||
reasonCategory: {
|
||||
@ -124,12 +124,12 @@ export default {
|
||||
callback()
|
||||
},
|
||||
},
|
||||
reasonAddText: {
|
||||
reasonDescription: {
|
||||
type: 'string',
|
||||
min: 0,
|
||||
max: 200,
|
||||
validator: (rule, value, callback, source, options) => {
|
||||
this.form.reasonAddText = value
|
||||
this.form.reasonDescription = value
|
||||
callback()
|
||||
},
|
||||
},
|
||||
@ -151,9 +151,9 @@ export default {
|
||||
// console.log('this.form.reasonCategory: ', this.form.reasonCategory)
|
||||
// this.failsValidations = false
|
||||
// },
|
||||
// Wolle inputReasonAddText(reasonAddText) {
|
||||
// console.log('reasonAddText: ', reasonAddText)
|
||||
// this.form.reasonAddText = reasonAddText
|
||||
// Wolle inputReasonAddText(reasonDescription) {
|
||||
// console.log('reasonDescription: ', reasonDescription)
|
||||
// this.form.reasonDescription = reasonDescription
|
||||
// },
|
||||
async cancel() {
|
||||
// TODO: Use the "modalData" structure introduced in "ConfirmModal" and refactor this here. Be aware that all the Jest tests have to be refactored as well !!!
|
||||
@ -164,9 +164,9 @@ export default {
|
||||
}, 1000)
|
||||
},
|
||||
async confirm() {
|
||||
const { reasonCategory, reasonAddText } = this.form
|
||||
const { reasonCategory, reasonDescription } = this.form
|
||||
// Wolle console.log('reasonCategory: ', reasonCategory.value)
|
||||
// Wolle console.log('reasonAddText: ', reasonAddText)
|
||||
// Wolle console.log('reasonDescription: ', reasonDescription)
|
||||
|
||||
this.loading = true
|
||||
// TODO: Use the "modalData" structure introduced in "ConfirmModal" and refactor this here. Be aware that all the Jest tests have to be refactored as well !!!
|
||||
@ -175,9 +175,9 @@ export default {
|
||||
.mutate({
|
||||
mutation: reportMutation(),
|
||||
variables: {
|
||||
id: this.id,
|
||||
resourceId: this.id,
|
||||
reasonCategory: reasonCategory.value,
|
||||
description: reasonAddText,
|
||||
reasonDescription,
|
||||
},
|
||||
})
|
||||
.then(({ _data }) => {
|
||||
@ -214,7 +214,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.reasonAddText {
|
||||
.reasonDescription {
|
||||
margin-top: $space-x-small;
|
||||
margin-bottom: $space-xxx-small;
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ export const reportListQuery = () => {
|
||||
id
|
||||
createdAt
|
||||
reasonCategory
|
||||
description
|
||||
reasonDescription
|
||||
type
|
||||
submitter {
|
||||
id
|
||||
@ -83,8 +83,12 @@ export const reportListQuery = () => {
|
||||
|
||||
export const reportMutation = () => {
|
||||
return gql`
|
||||
mutation($id: ID!, $reasonCategory: String!, $description: String!) {
|
||||
report(id: $id, reasonCategory: $reasonCategory, description: $description) {
|
||||
mutation($resourceId: ID!, $reasonCategory: String!, $reasonDescription: String!) {
|
||||
report(
|
||||
resourceId: $resourceId
|
||||
reasonCategory: $reasonCategory
|
||||
reasonDescription: $reasonDescription
|
||||
) {
|
||||
id
|
||||
}
|
||||
}
|
||||
|
||||
@ -471,7 +471,7 @@
|
||||
"other": "Other"
|
||||
}
|
||||
},
|
||||
"addText": {
|
||||
"description": {
|
||||
"label": "Please explain why you like to report this?",
|
||||
"placeholder": "Additional information …"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user