From 935252a16e2133d9256c7a38e6bc5d63641c86a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Fri, 4 Oct 2019 15:21:07 +0200 Subject: [PATCH] Rename variables, parameters and properties --- backend/src/schema/resolvers/reports.js | 8 ++-- backend/src/schema/resolvers/reports.spec.js | 22 +++++----- backend/src/schema/types/schema.gql | 4 +- backend/src/seed/seed-db.js | 16 ++++---- cypress/integration/common/report.js | 8 ++-- webapp/components/Modal/ReportModal.vue | 42 ++++++++++---------- webapp/graphql/Moderation.js | 10 +++-- webapp/locales/en.json | 2 +- 8 files changed, 58 insertions(+), 54 deletions(-) diff --git a/backend/src/schema/resolvers/reports.js b/backend/src/schema/resolvers/reports.js index d8698844f..42f9a416f 100644 --- a/backend/src/schema/resolvers/reports.js +++ b/backend/src/schema/resolvers/reports.js @@ -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, }, diff --git a/backend/src/schema/resolvers/reports.spec.js b/backend/src/schema/resolvers/reports.spec.js index 228234ba1..d96b894c5 100644 --- a/backend/src/schema/resolvers/reports.spec.js +++ b/backend/src/schema/resolvers/reports.spec.js @@ -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', } }) diff --git a/backend/src/schema/types/schema.gql b/backend/src/schema/types/schema.gql index 2bb3fdace..cdf0d7f87 100644 --- a/backend/src/schema/types/schema.gql +++ b/backend/src/schema/types/schema.gql @@ -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]") diff --git a/backend/src/seed/seed-db.js b/backend/src/seed/seed-db.js index 8c87a3214..bc85e2a7d 100644 --- a/backend/src/seed/seed-db.js +++ b/backend/src/seed/seed-db.js @@ -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', }, }), ]) diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index c51c6b42e..83c96e6af 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -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' }) }) }) diff --git a/webapp/components/Modal/ReportModal.vue b/webapp/components/Modal/ReportModal.vue index ff31d5e0e..415ec9db4 100644 --- a/webapp/components/Modal/ReportModal.vue +++ b/webapp/components/Modal/ReportModal.vue @@ -28,24 +28,24 @@ :options="form.reasonCategoryOptions" /> - {{ form.reasonAddText.length }}/{{ formSchema.reasonAddText.max }} + {{ form.reasonDescription.length }}/{{ formSchema.reasonDescription.max }} @@ -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 {