diff --git a/admin/src/graphql/adminDeleteContribution.js b/admin/src/graphql/adminDeleteContribution.js new file mode 100644 index 000000000..0aed494e1 --- /dev/null +++ b/admin/src/graphql/adminDeleteContribution.js @@ -0,0 +1,7 @@ +import gql from 'graphql-tag' + +export const adminDeleteContribution = gql` + mutation ($id: Int!) { + adminDeleteContribution(id: $id) + } +` diff --git a/admin/src/graphql/deletePendingCreation.js b/admin/src/graphql/deletePendingCreation.js deleted file mode 100644 index edf45fe74..000000000 --- a/admin/src/graphql/deletePendingCreation.js +++ /dev/null @@ -1,7 +0,0 @@ -import gql from 'graphql-tag' - -export const deletePendingCreation = gql` - mutation ($id: Int!) { - deletePendingCreation(id: $id) - } -` diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index 76a943a24..c35a48dbc 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -1,6 +1,6 @@ import { mount } from '@vue/test-utils' import CreationConfirm from './CreationConfirm.vue' -import { deletePendingCreation } from '../graphql/deletePendingCreation' +import { adminDeleteContribution } from '../graphql/adminDeleteContribution' import { confirmPendingCreation } from '../graphql/confirmPendingCreation' import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' @@ -84,9 +84,9 @@ describe('CreationConfirm', () => { await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click') }) - it('calls the deletePendingCreation mutation', () => { + it('calls the adminDeleteContribution mutation', () => { expect(apolloMutateMock).toBeCalledWith({ - mutation: deletePendingCreation, + mutation: adminDeleteContribution, variables: { id: 1 }, }) }) diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 7598bf0a2..e8016ddf9 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -16,7 +16,7 @@ import Overlay from '../components/Overlay.vue' import OpenCreationsTable from '../components/Tables/OpenCreationsTable.vue' import { listUnconfirmedContributions } from '../graphql/listUnconfirmedContributions' -import { deletePendingCreation } from '../graphql/deletePendingCreation' +import { adminDeleteContribution } from '../graphql/adminDeleteContribution' import { confirmPendingCreation } from '../graphql/confirmPendingCreation' export default { @@ -36,7 +36,7 @@ export default { removeCreation(item) { this.$apollo .mutate({ - mutation: deletePendingCreation, + mutation: adminDeleteContribution, variables: { id: item.id, }, diff --git a/backend/src/auth/RIGHTS.ts b/backend/src/auth/RIGHTS.ts index 4211adb32..7ea32a61b 100644 --- a/backend/src/auth/RIGHTS.ts +++ b/backend/src/auth/RIGHTS.ts @@ -30,8 +30,8 @@ export enum RIGHTS { ADMIN_CREATE_CONTRIBUTION = 'ADMIN_CREATE_CONTRIBUTION', ADMIN_CREATE_CONTRIBUTIONS = 'ADMIN_CREATE_CONTRIBUTIONS', ADMIN_UPDATE_CONTRIBUTION = 'ADMIN_UPDATE_CONTRIBUTION', + ADMIN_DELETE_CONTRIBUTION = 'ADMIN_DELETE_CONTRIBUTION', LIST_UNCONFIRMED_CONTRIBUTIONS = 'LIST_UNCONFIRMED_CONTRIBUTIONS', - DELETE_PENDING_CREATION = 'DELETE_PENDING_CREATION', CONFIRM_PENDING_CREATION = 'CONFIRM_PENDING_CREATION', SEND_ACTIVATION_EMAIL = 'SEND_ACTIVATION_EMAIL', DELETE_USER = 'DELETE_USER', diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index c2a04007f..897ca40d7 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -18,7 +18,7 @@ import { adminCreateContribution, adminCreateContributions, updatePendingCreation, - deletePendingCreation, + adminDeleteContribution, confirmPendingCreation, createContributionLink, deleteContributionLink, @@ -562,11 +562,11 @@ describe('AdminResolver', () => { }) }) - describe('deletePendingCreation', () => { + describe('adminDeleteContribution', () => { it('returns an error', async () => { await expect( mutate({ - mutation: deletePendingCreation, + mutation: adminDeleteContribution, variables: { id: 1, }, @@ -672,11 +672,11 @@ describe('AdminResolver', () => { }) }) - describe('deletePendingCreation', () => { + describe('adminDeleteContribution', () => { it('returns an error', async () => { await expect( mutate({ - mutation: deletePendingCreation, + mutation: adminDeleteContribution, variables: { id: 1, }, @@ -1177,19 +1177,19 @@ describe('AdminResolver', () => { }) }) - describe('deletePendingCreation', () => { + describe('adminDeleteContribution', () => { describe('creation id does not exist', () => { it('throws an error', async () => { await expect( mutate({ - mutation: deletePendingCreation, + mutation: adminDeleteContribution, variables: { id: -1, }, }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('Creation not found for given id.')], + errors: [new GraphQLError('Contribution not found for given id.')], }), ) }) @@ -1199,14 +1199,14 @@ describe('AdminResolver', () => { it('returns true', async () => { await expect( mutate({ - mutation: deletePendingCreation, + mutation: adminDeleteContribution, variables: { id: creation ? creation.id : -1, }, }), ).resolves.toEqual( expect.objectContaining({ - data: { deletePendingCreation: true }, + data: { adminDeleteContribution: true }, }), ) }) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 2be7d75b9..1740d9d64 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -314,12 +314,12 @@ export class AdminResolver { }) } - @Authorized([RIGHTS.DELETE_PENDING_CREATION]) + @Authorized([RIGHTS.ADMIN_DELETE_CONTRIBUTION]) @Mutation(() => Boolean) - async deletePendingCreation(@Arg('id', () => Int) id: number): Promise { + async adminDeleteContribution(@Arg('id', () => Int) id: number): Promise { const contribution = await Contribution.findOne(id) if (!contribution) { - throw new Error('Creation not found for given id.') + throw new Error('Contribution not found for given id.') } const res = await contribution.softRemove() return !!res diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 036a9bdb6..7989fb97d 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -137,9 +137,9 @@ export const updatePendingCreation = gql` } ` -export const deletePendingCreation = gql` +export const adminDeleteContribution = gql` mutation ($id: Int!) { - deletePendingCreation(id: $id) + adminDeleteContribution(id: $id) } `