Rename variables, parameters and properties

This commit is contained in:
Wolfgang Huß 2019-10-04 15:21:07 +02:00
parent b4f47997b3
commit 935252a16e
8 changed files with 58 additions and 54 deletions

View File

@ -2,14 +2,14 @@ import uuid from 'uuid/v4'
export default { export default {
Mutation: { 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 reportId = uuid()
const session = driver.session() const session = driver.session()
const reportProperties = { const reportProperties = {
id: reportId, id: reportId,
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
reasonCategory, reasonCategory,
description, reasonDescription,
} }
const reportQueryRes = await session.run( const reportQueryRes = await session.run(
@ -18,7 +18,7 @@ export default {
RETURN labels(resource)[0] as label RETURN labels(resource)[0] as label
`, `,
{ {
resourceId: id, resourceId,
submitterId: user.id, submitterId: user.id,
}, },
) )
@ -43,7 +43,7 @@ export default {
RETURN report, submitter, resource, labels(resource)[0] as type RETURN report, submitter, resource, labels(resource)[0] as type
`, `,
{ {
resourceId: id, resourceId,
userId: user.id, userId: user.id,
reportProperties, reportProperties,
}, },

View File

@ -18,9 +18,9 @@ describe('report', () => {
beforeEach(async () => { beforeEach(async () => {
returnedObject = '{ id }' returnedObject = '{ id }'
variables = { variables = {
id: 'whatever', resourceId: 'whatever',
reasonCategory: 'reason-category-dummy', reasonCategory: 'reason-category-dummy',
description: 'Violates code of conduct !!!', reasonDescription: 'Violates code of conduct !!!',
} }
headers = {} headers = {}
user = await factory.create('User', { user = await factory.create('User', {
@ -49,8 +49,8 @@ describe('report', () => {
const action = () => { const action = () => {
// because of the template `${returnedObject}` the 'gql' tag from 'jest/helpers' is not working here // because of the template `${returnedObject}` the 'gql' tag from 'jest/helpers' is not working here
reportMutation = ` reportMutation = `
mutation($id: ID!, $reasonCategory: String!, $description: String!) { mutation($resourceId: ID!, $reasonCategory: String!, $reasonDescription: String!) {
report( id: $id, reasonCategory: $reasonCategory, description: $description) ${returnedObject} report( resourceId: $resourceId, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription) ${returnedObject}
} }
` `
client = new GraphQLClient(host, { client = new GraphQLClient(host, {
@ -86,7 +86,7 @@ describe('report', () => {
beforeEach(async () => { beforeEach(async () => {
variables = { variables = {
...variables, ...variables,
id: 'u2', resourceId: 'u2',
} }
}) })
@ -146,12 +146,12 @@ describe('report', () => {
it('returns the reason description', async () => { it('returns the reason description', async () => {
variables = { variables = {
...variables, ...variables,
description: 'My reason!', reasonDescription: 'My reason!',
} }
returnedObject = '{ description }' returnedObject = '{ reasonDescription }'
await expect(action()).resolves.toEqual({ await expect(action()).resolves.toEqual({
report: { report: {
description: 'My reason!', reasonDescription: 'My reason!',
}, },
}) })
}) })
@ -167,7 +167,7 @@ describe('report', () => {
}) })
variables = { variables = {
...variables, ...variables,
id: 'p23', resourceId: 'p23',
} }
}) })
@ -221,7 +221,7 @@ describe('report', () => {
}) })
variables = { variables = {
...variables, ...variables,
id: 'c34', resourceId: 'c34',
} }
}) })
@ -256,7 +256,7 @@ describe('report', () => {
}) })
variables = { variables = {
...variables, ...variables,
id: 't23', resourceId: 't23',
} }
}) })

View File

@ -24,7 +24,7 @@ type Mutation {
changePassword(oldPassword: String!, newPassword: String!): String! changePassword(oldPassword: String!, newPassword: String!): String!
requestPasswordReset(email: String!): Boolean! requestPasswordReset(email: String!): Boolean!
resetPassword(email: String!, nonce: String!, newPassword: 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 disable(id: ID!): ID
enable(id: ID!): ID enable(id: ID!): ID
# Shout the given Type and ID # Shout the given Type and ID
@ -39,7 +39,7 @@ type Report {
id: ID! id: ID!
createdAt: String! createdAt: String!
reasonCategory: String! reasonCategory: String!
description: String! reasonDescription: String!
submitter: User @relation(name: "REPORTED", direction: "IN") submitter: User @relation(name: "REPORTED", direction: "IN")
type: String! type: String!
@cypher(statement: "MATCH (resource)<-[:REPORTED]-(this) RETURN labels(resource)[0]") @cypher(statement: "MATCH (resource)<-[:REPORTED]-(this) RETURN labels(resource)[0]")

View File

@ -650,8 +650,8 @@ import { gql } from '../jest/helpers'
authenticatedUser = null authenticatedUser = null
const reportMutation = gql` const reportMutation = gql`
mutation($id: ID!, $description: String!) { mutation($resourceId: ID!, $reasonDescription: String!) {
report(description: $description, id: $id) { report(reasonDescription: $reasonDescription, resourceId: $resourceId) {
id id
} }
} }
@ -661,22 +661,22 @@ import { gql } from '../jest/helpers'
mutate({ mutate({
mutation: reportMutation, mutation: reportMutation,
variables: { variables: {
description: 'This comment is bigoted', reasonDescription: 'This comment is bigoted',
id: 'c1', resourceId: 'c1',
}, },
}), }),
mutate({ mutate({
mutation: reportMutation, mutation: reportMutation,
variables: { variables: {
description: 'This post is bigoted', reasonDescription: 'This post is bigoted',
id: 'p1', resourceId: 'p1',
}, },
}), }),
mutate({ mutate({
mutation: reportMutation, mutation: reportMutation,
variables: { variables: {
description: 'This user is harassing me with bigoted remarks', reasonDescription: 'This user is harassing me with bigoted remarks',
id: 'u1', resourceId: 'u1',
}, },
}), }),
]) ])

View File

@ -122,13 +122,13 @@ Given('somebody reported the following posts:', table => {
cy.factory() cy.factory()
.create('User', submitter) .create('User', submitter)
.authenticateAs(submitter) .authenticateAs(submitter)
.mutate(`mutation($id: ID!, $description: String!) { .mutate(`mutation($resourceId: ID!, $reasonDescription: String!) {
report(description: $description, id: $id) { report(reasonDescription: $reasonDescription, resourceId: $resourceId) {
id id
} }
}`, { }`, {
id, resourceId,
description: 'Offensive content' reasonDescription: 'Offensive content'
}) })
}) })
}) })

View File

@ -28,24 +28,24 @@
:options="form.reasonCategoryOptions" :options="form.reasonCategoryOptions"
/> />
<!-- Wolle <ds-input <!-- Wolle <ds-input
model="reasonAddText" model="reasonDescription"
:label="$t('report.reason.addText.label')" :label="$t('report.reason.description.label')"
:placeholder="$t('report.reason.addText.placeholder')" :placeholder="$t('report.reason.description.placeholder')"
type="textarea" type="textarea"
rows="5" rows="5"
class="reasonAddText" class="reasonDescription"
/> --> /> -->
<ds-input <ds-input
:value="form.reasonAddText" :value="form.reasonDescription"
:schema="formSchema.reasonAddText" :schema="formSchema.reasonDescription"
:label="$t('report.reason.addText.label')" :label="$t('report.reason.description.label')"
:placeholder="$t('report.reason.addText.placeholder')" :placeholder="$t('report.reason.description.placeholder')"
type="textarea" type="textarea"
rows="5" rows="5"
class="reasonAddText" class="reasonDescription"
/> />
<small class="smallTag"> <small class="smallTag">
{{ form.reasonAddText.length }}/{{ formSchema.reasonAddText.max }} {{ form.reasonDescription.length }}/{{ formSchema.reasonDescription.max }}
</small> </small>
<ds-space /> <ds-space />
<!-- Wolle </ds-form> --> <!-- Wolle </ds-form> -->
@ -109,7 +109,7 @@ export default {
reasonCategory: null, reasonCategory: null,
// Wolle reasonCategory: reasonCategoryOptions[0], // Wolle reasonCategory: reasonCategoryOptions[0],
reasonCategoryOptions, reasonCategoryOptions,
reasonAddText: '', reasonDescription: '',
}, },
formSchema: { formSchema: {
reasonCategory: { reasonCategory: {
@ -124,12 +124,12 @@ export default {
callback() callback()
}, },
}, },
reasonAddText: { reasonDescription: {
type: 'string', type: 'string',
min: 0, min: 0,
max: 200, max: 200,
validator: (rule, value, callback, source, options) => { validator: (rule, value, callback, source, options) => {
this.form.reasonAddText = value this.form.reasonDescription = value
callback() callback()
}, },
}, },
@ -151,9 +151,9 @@ export default {
// console.log('this.form.reasonCategory: ', this.form.reasonCategory) // console.log('this.form.reasonCategory: ', this.form.reasonCategory)
// this.failsValidations = false // this.failsValidations = false
// }, // },
// Wolle inputReasonAddText(reasonAddText) { // Wolle inputReasonAddText(reasonDescription) {
// console.log('reasonAddText: ', reasonAddText) // console.log('reasonDescription: ', reasonDescription)
// this.form.reasonAddText = reasonAddText // this.form.reasonDescription = reasonDescription
// }, // },
async cancel() { 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 !!! // 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) }, 1000)
}, },
async confirm() { async confirm() {
const { reasonCategory, reasonAddText } = this.form const { reasonCategory, reasonDescription } = this.form
// Wolle console.log('reasonCategory: ', reasonCategory.value) // Wolle console.log('reasonCategory: ', reasonCategory.value)
// Wolle console.log('reasonAddText: ', reasonAddText) // Wolle console.log('reasonDescription: ', reasonDescription)
this.loading = true 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 !!! // 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({ .mutate({
mutation: reportMutation(), mutation: reportMutation(),
variables: { variables: {
id: this.id, resourceId: this.id,
reasonCategory: reasonCategory.value, reasonCategory: reasonCategory.value,
description: reasonAddText, reasonDescription,
}, },
}) })
.then(({ _data }) => { .then(({ _data }) => {
@ -214,7 +214,7 @@ export default {
</script> </script>
<style lang="scss"> <style lang="scss">
.reasonAddText { .reasonDescription {
margin-top: $space-x-small; margin-top: $space-x-small;
margin-bottom: $space-xxx-small; margin-bottom: $space-xxx-small;
} }

View File

@ -7,7 +7,7 @@ export const reportListQuery = () => {
id id
createdAt createdAt
reasonCategory reasonCategory
description reasonDescription
type type
submitter { submitter {
id id
@ -83,8 +83,12 @@ export const reportListQuery = () => {
export const reportMutation = () => { export const reportMutation = () => {
return gql` return gql`
mutation($id: ID!, $reasonCategory: String!, $description: String!) { mutation($resourceId: ID!, $reasonCategory: String!, $reasonDescription: String!) {
report(id: $id, reasonCategory: $reasonCategory, description: $description) { report(
resourceId: $resourceId
reasonCategory: $reasonCategory
reasonDescription: $reasonDescription
) {
id id
} }
} }

View File

@ -471,7 +471,7 @@
"other": "Other" "other": "Other"
} }
}, },
"addText": { "description": {
"label": "Please explain why you like to report this?", "label": "Please explain why you like to report this?",
"placeholder": "Additional information …" "placeholder": "Additional information …"
} }