From 4b4edd48e3cf70c2f0b7dbcd248c003ffd9a2125 Mon Sep 17 00:00:00 2001 From: EUForest Date: Sun, 8 Mar 2026 23:42:39 +0800 Subject: [PATCH] refactor(group): remove deprecated user group components Remove unused user group management components as user groups have been deprecated in favor of node groups only. --- .../src/sections/group/user-group-form.tsx | 210 ----------------- apps/admin/src/sections/group/user-groups.tsx | 200 ---------------- .../sections/product/migrate-users-dialog.tsx | 215 ------------------ .../sections/user/edit-user-group-dialog.tsx | 199 ---------------- 4 files changed, 824 deletions(-) delete mode 100644 apps/admin/src/sections/group/user-group-form.tsx delete mode 100644 apps/admin/src/sections/group/user-groups.tsx delete mode 100644 apps/admin/src/sections/product/migrate-users-dialog.tsx delete mode 100644 apps/admin/src/sections/user/edit-user-group-dialog.tsx diff --git a/apps/admin/src/sections/group/user-group-form.tsx b/apps/admin/src/sections/group/user-group-form.tsx deleted file mode 100644 index 9cb805b..0000000 --- a/apps/admin/src/sections/group/user-group-form.tsx +++ /dev/null @@ -1,210 +0,0 @@ -"use client"; - -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@workspace/ui/components/dialog"; -import { Input } from "@workspace/ui/components/input"; -import { Label } from "@workspace/ui/components/label"; -import { Textarea } from "@workspace/ui/components/textarea"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@workspace/ui/components/select"; -import { Switch } from "@workspace/ui/components/switch"; -import { Loader2 } from "lucide-react"; -import { forwardRef, useEffect, useState } from "react"; -import { useTranslation } from "react-i18next"; - -interface UserGroupFormProps { - initialValues?: Partial; - loading?: boolean; - nodeGroups?: API.NodeGroup[]; - onSubmit: (values: Record) => Promise; - title: string; - trigger: React.ReactNode; -} - -const UserGroupForm = forwardRef< - HTMLButtonElement, - UserGroupFormProps ->(({ initialValues, loading, nodeGroups = [], onSubmit, title, trigger }, ref) => { - const { t } = useTranslation("group"); - const [open, setOpen] = useState(false); - const [submitting, setSubmitting] = useState(false); - - const [values, setValues] = useState({ - name: "", - description: "", - sort: 0, - node_group_id: null as number | null, - for_calculation: true, - }); - - useEffect(() => { - if (open) { - if (initialValues) { - setValues({ - name: initialValues.name || "", - description: initialValues.description || "", - sort: initialValues.sort ?? 0, - node_group_id: initialValues.node_group_id || null, - for_calculation: initialValues.for_calculation ?? true, - }); - } else { - setValues({ - name: "", - description: "", - sort: 0, - node_group_id: null, - for_calculation: true, - }); - } - } - }, [initialValues, open]); - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - setSubmitting(true); - const success = await onSubmit(values); - setSubmitting(false); - if (success) { - setOpen(false); - setValues({ - name: "", - description: "", - sort: 0, - node_group_id: null, - for_calculation: true, - }); - } - }; - - return ( - - - {trigger} - - - - {title} - - {t("userGroupFormDescription", "Configure user group settings")} - - -
-
- - - setValues({ ...values, name: e.target.value }) - } - placeholder={t("namePlaceholder", "Enter name")} - required - /> -
- -
- - - setValues({ ...values, for_calculation: checked }) - } - /> -
- -
- -