diff --git a/backend/src/admin/forum/forums/delete/delete.service.ts b/backend/src/admin/forum/forums/delete/delete.service.ts index a7e9b4531..68eae7138 100644 --- a/backend/src/admin/forum/forums/delete/delete.service.ts +++ b/backend/src/admin/forum/forums/delete/delete.service.ts @@ -13,11 +13,7 @@ import { forum_topics } from "../../database/schema/topics"; export class DeleteForumForumsService { constructor(private databaseService: DatabaseService) {} - async delete({ - id, - move_forums_to, - move_topics_to - }: DeleteForumForumsArgs): Promise { + async delete({ id, move_topics_to }: DeleteForumForumsArgs): Promise { const forum = await this.databaseService.db.query.forum_forums.findFirst({ where: (table, { eq }) => eq(table.id, id) }); @@ -31,28 +27,11 @@ export class DeleteForumForumsService { }); if (children.length > 0) { - if (!move_forums_to) { - throw new CustomError({ - code: "FORUM_HAS_CHILDREN", - message: "Forum has children and no move_forums_to provided" - }); - } - - const moveForumsToForum = - await this.databaseService.db.query.forum_forums.findFirst({ - where: (table, { eq }) => eq(table.id, move_forums_to) - }); - - if (!moveForumsToForum) { - throw new NotFoundError("Forum"); - } - - await this.databaseService.db - .update(forum_forums) - .set({ - parent_id: move_forums_to - }) - .where(eq(forum_forums.parent_id, id)); + throw new CustomError({ + code: "FORUM_HAS_CHILDREN", + message: + "Forum has children and cannot be deleted. Please delete children first." + }); } const topics = await this.databaseService.db.query.forum_topics.findMany({ diff --git a/backend/src/admin/forum/forums/delete/dto/delete.args.ts b/backend/src/admin/forum/forums/delete/dto/delete.args.ts index a55f1eaa6..5035a9c3a 100644 --- a/backend/src/admin/forum/forums/delete/dto/delete.args.ts +++ b/backend/src/admin/forum/forums/delete/dto/delete.args.ts @@ -5,9 +5,6 @@ export class DeleteForumForumsArgs { @Field(() => Int) id: number; - @Field(() => Int, { nullable: true }) - move_forums_to: number | null; - @Field(() => Int, { nullable: true }) move_topics_to: number | null; } diff --git a/backend/src/schema.gql b/backend/src/schema.gql index 0ce7ec637..19d5a9985 100644 --- a/backend/src/schema.gql +++ b/backend/src/schema.gql @@ -126,7 +126,7 @@ type Mutation { admin__core_themes__upload(file: Upload!): String! admin__forum_forums__change_position(id: Int!, index_to_move: Int!, parent_id: Int): String! admin__forum_forums__create(description: [TextLanguageInput!]!, name: [TextLanguageInput!]!, parent_id: Int, permissions: PermissionsCreateForumForums!): CreateForumForumsObj! - admin__forum_forums__delete(id: Int!, move_forums_to: Int, move_topics_to: Int): String! + admin__forum_forums__delete(id: Int!, move_topics_to: Int): String! admin__forum_forums__edit(description: [TextLanguageInput!]!, id: Int!, name: [TextLanguageInput!]!, parent_id: Int, permissions: PermissionsCreateForumForums!): CreateForumForumsObj! admin__install__create_database: String! admin_sessions__sign_out: String! diff --git a/frontend/admin/forum/views/forums/table/item/actions/delete/content.tsx b/frontend/admin/forum/views/forums/table/item/actions/delete/content.tsx index f046857aa..3f5321c3b 100644 --- a/frontend/admin/forum/views/forums/table/item/actions/delete/content.tsx +++ b/frontend/admin/forum/views/forums/table/item/actions/delete/content.tsx @@ -47,22 +47,6 @@ export const ContentDeleteActionForumAdmin = ({ - {_count.children > 0 && ( - ( - - {t("move_forums_to")} - - - - - - )} - /> - )} - {_count.topics > 0 && ( 0 && !form.watch("move_forums_to")) || (_count.topics > 0 && !form.watch("move_topics_to")) } loading={form.formState.isSubmitting} diff --git a/frontend/admin/forum/views/forums/table/item/actions/delete/delete.tsx b/frontend/admin/forum/views/forums/table/item/actions/delete/delete.tsx index e9d0ef4b7..02e06556e 100644 --- a/frontend/admin/forum/views/forums/table/item/actions/delete/delete.tsx +++ b/frontend/admin/forum/views/forums/table/item/actions/delete/delete.tsx @@ -25,7 +25,12 @@ export const DeleteActionForumAdmin = ( return ( - diff --git a/frontend/admin/forum/views/forums/table/item/actions/delete/hooks/use-delete-forum-admin.ts b/frontend/admin/forum/views/forums/table/item/actions/delete/hooks/use-delete-forum-admin.ts index b6f3dd8e0..26b593b63 100644 --- a/frontend/admin/forum/views/forums/table/item/actions/delete/hooks/use-delete-forum-admin.ts +++ b/frontend/admin/forum/views/forums/table/item/actions/delete/hooks/use-delete-forum-admin.ts @@ -19,12 +19,6 @@ export const useDeleteForumAdmin = ({ const { convertText } = useTextLang(); const { setOpen } = useAlertDialog(); const formSchema = z.object({ - move_forums_to: z - .object({ - id: z.number().min(1), - name: zodInput.languageInput - }) - .optional(), move_topics_to: z .object({ id: z.number().min(1), @@ -40,7 +34,6 @@ export const useDeleteForumAdmin = ({ const onSubmit = async (values: z.infer) => { const mutation = await mutationApi({ id, - moveForumsTo: values.move_forums_to?.id, moveTopicsTo: values.move_topics_to?.id }); if (mutation.error) { diff --git a/frontend/graphql/hooks.ts b/frontend/graphql/hooks.ts index ca77fd590..3c48a0fa0 100644 --- a/frontend/graphql/hooks.ts +++ b/frontend/graphql/hooks.ts @@ -336,7 +336,6 @@ export type MutationAdmin__Forum_Forums__CreateArgs = { export type MutationAdmin__Forum_Forums__DeleteArgs = { id: Scalars['Int']['input']; - move_forums_to?: InputMaybe; move_topics_to?: InputMaybe; }; @@ -1310,7 +1309,6 @@ export type Admin__Forum_Forums__CreateMutation = { __typename?: 'Mutation', adm export type Admin__Forum_Forums__DeleteMutationVariables = Exact<{ id: Scalars['Int']['input']; - moveForumsTo?: InputMaybe; moveTopicsTo?: InputMaybe; }>; @@ -1868,12 +1866,8 @@ export const Admin__Forum_Forums__Create = gql` } `; export const Admin__Forum_Forums__Delete = gql` - mutation Admin__forum_forums__delete($id: Int!, $moveForumsTo: Int, $moveTopicsTo: Int) { - admin__forum_forums__delete( - id: $id - move_forums_to: $moveForumsTo - move_topics_to: $moveTopicsTo - ) + mutation Admin__forum_forums__delete($id: Int!, $moveTopicsTo: Int) { + admin__forum_forums__delete(id: $id, move_topics_to: $moveTopicsTo) } `; export const Admin__Forum_Forums__Edit = gql` diff --git a/frontend/graphql/mutations/forum/admin/forums/admin__forum_forums__delete.gql b/frontend/graphql/mutations/forum/admin/forums/admin__forum_forums__delete.gql index 13fa2766f..c5170583c 100644 --- a/frontend/graphql/mutations/forum/admin/forums/admin__forum_forums__delete.gql +++ b/frontend/graphql/mutations/forum/admin/forums/admin__forum_forums__delete.gql @@ -1,11 +1,3 @@ -mutation Admin__forum_forums__delete( - $id: Int! - $moveForumsTo: Int - $moveTopicsTo: Int -) { - admin__forum_forums__delete( - id: $id - move_forums_to: $moveForumsTo - move_topics_to: $moveTopicsTo - ) +mutation Admin__forum_forums__delete($id: Int!, $moveTopicsTo: Int) { + admin__forum_forums__delete(id: $id, move_topics_to: $moveTopicsTo) } diff --git a/frontend/langs/en/forum.json b/frontend/langs/en/forum.json index 87c6613ab..989a9395d 100644 --- a/frontend/langs/en/forum.json +++ b/frontend/langs/en/forum.json @@ -56,7 +56,6 @@ }, "delete": { "desc": "Are you sure you want to delete forum? This action cannot be undone.", - "move_forums_to": "Move children forums to", "move_topics_to": "Move topics to", "success": "Forum has been deleted.", "submit": "Delete Forum" diff --git a/frontend/langs/pl/forum.json b/frontend/langs/pl/forum.json index fe947b36c..c3236049c 100644 --- a/frontend/langs/pl/forum.json +++ b/frontend/langs/pl/forum.json @@ -56,7 +56,6 @@ }, "delete": { "desc": "Czy na pewno chcesz usunąć forum ? Ta akcja nie może być cofnięta.", - "move_forums_to": "Przenieś sub-fora do", "move_topics_to": "Przenieś posty do", "success": "Forum zostało usunięte.", "submit": "Usuń forum"