From 3b50741f1941c0677e3d304bb8af2667b723b323 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Mon, 9 Dec 2024 15:17:55 +0800 Subject: [PATCH] chore(ui): clean code --- ui/package-lock.json | 136 ------------------ ui/package.json | 4 - ui/src/components/certimate/XPagination.tsx | 92 ------------ ui/src/components/ui/alert-dialog.tsx | 94 ------------ ui/src/components/ui/badge.tsx | 29 ---- ui/src/components/ui/breadcrumb.tsx | 57 -------- ui/src/components/ui/card.tsx | 35 ----- ui/src/components/ui/drawer.tsx | 62 -------- ui/src/components/ui/navigation-menu.tsx | 104 -------------- ui/src/components/ui/pagination.tsx | 79 ---------- ui/src/components/ui/progress.tsx | 15 -- ui/src/components/workflow/AddNode.tsx | 2 +- ui/src/components/workflow/ApplyForm.tsx | 2 +- ui/src/components/workflow/BranchNode.tsx | 2 +- ui/src/components/workflow/ConditionNode.tsx | 2 +- .../components/workflow/CustomAlertDialog.tsx | 46 ------ .../components/workflow/DeployToAliyunALB.tsx | 2 +- .../components/workflow/DeployToAliyunCDN.tsx | 2 +- .../components/workflow/DeployToAliyunCLB.tsx | 2 +- .../components/workflow/DeployToAliyunNLB.tsx | 2 +- .../components/workflow/DeployToAliyunOss.tsx | 2 +- .../workflow/DeployToBaiduCloudCDN.tsx | 2 +- .../workflow/DeployToByteplusCDN.tsx | 2 +- .../workflow/DeployToDogeCloudCDN.tsx | 2 +- .../workflow/DeployToHuaweiCloudCDN.tsx | 2 +- .../workflow/DeployToHuaweiCloudELB.tsx | 2 +- .../workflow/DeployToKubernetesSecret.tsx | 2 +- ui/src/components/workflow/DeployToLocal.tsx | 2 +- .../components/workflow/DeployToQiniuCDN.tsx | 2 +- ui/src/components/workflow/DeployToSSH.tsx | 2 +- .../workflow/DeployToTencentCDN.tsx | 2 +- .../workflow/DeployToTencentCLB.tsx | 2 +- .../workflow/DeployToTencentCOS.tsx | 2 +- .../workflow/DeployToTencentTEO.tsx | 2 +- .../workflow/DeployToVolcengineCDN.tsx | 2 +- .../workflow/DeployToVolcengineLive.tsx | 2 +- .../components/workflow/DeployToWebhook.tsx | 2 +- ui/src/components/workflow/Node.tsx | 2 +- ui/src/components/workflow/NotifyForm.tsx | 2 +- ui/src/components/workflow/StartForm.tsx | 2 +- .../workflow/WorkflowBaseInfoEditDialog.tsx | 2 +- ui/src/pages/workflows/WorkflowDetail.tsx | 2 +- .../{providers => stores}/workflow/index.ts | 23 +-- 43 files changed, 42 insertions(+), 794 deletions(-) delete mode 100644 ui/src/components/certimate/XPagination.tsx delete mode 100644 ui/src/components/ui/alert-dialog.tsx delete mode 100644 ui/src/components/ui/badge.tsx delete mode 100644 ui/src/components/ui/breadcrumb.tsx delete mode 100644 ui/src/components/ui/card.tsx delete mode 100644 ui/src/components/ui/drawer.tsx delete mode 100644 ui/src/components/ui/navigation-menu.tsx delete mode 100644 ui/src/components/ui/pagination.tsx delete mode 100644 ui/src/components/ui/progress.tsx delete mode 100644 ui/src/components/workflow/CustomAlertDialog.tsx rename ui/src/{providers => stores}/workflow/index.ts (92%) diff --git a/ui/package-lock.json b/ui/package-lock.json index 1377450b..f73e352f 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -11,14 +11,11 @@ "@ant-design/pro-components": "^2.8.2", "@hookform/resolvers": "^3.9.0", "@radix-ui/react-accordion": "^1.2.0", - "@radix-ui/react-alert-dialog": "^1.1.1", "@radix-ui/react-collapsible": "^1.1.1", "@radix-ui/react-dialog": "^1.1.2", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-label": "^2.1.0", - "@radix-ui/react-navigation-menu": "^1.2.0", "@radix-ui/react-popover": "^1.1.2", - "@radix-ui/react-progress": "^1.1.0", "@radix-ui/react-radio-group": "^1.2.0", "@radix-ui/react-scroll-area": "^1.1.0", "@radix-ui/react-select": "^2.1.1", @@ -52,7 +49,6 @@ "react-router-dom": "^6.25.1", "tailwind-merge": "^2.4.0", "tailwindcss-animate": "^1.0.7", - "vaul": "^0.9.1", "zod": "^3.23.8", "zustand": "^5.0.1" }, @@ -1688,68 +1684,6 @@ } } }, - "node_modules/@radix-ui/react-alert-dialog": { - "version": "1.1.1", - "resolved": "https://registry.npmmirror.com/@radix-ui/react-alert-dialog/-/react-alert-dialog-1.1.1.tgz", - "integrity": "sha512-wmCoJwj7byuVuiLKqDLlX7ClSUU0vd9sdCeM+2Ls+uf13+cpSJoMgwysHq1SGVVkJj5Xn0XWi1NoRCdkMpr6Mw==", - "dependencies": { - "@radix-ui/primitive": "1.1.0", - "@radix-ui/react-compose-refs": "1.1.0", - "@radix-ui/react-context": "1.1.0", - "@radix-ui/react-dialog": "1.1.1", - "@radix-ui/react-primitive": "2.0.0", - "@radix-ui/react-slot": "1.1.0" - }, - "peerDependencies": { - "@types/react": "*", - "@types/react-dom": "*", - "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", - "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - }, - "@types/react-dom": { - "optional": true - } - } - }, - "node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-dialog": { - "version": "1.1.1", - "resolved": "https://registry.npmmirror.com/@radix-ui/react-dialog/-/react-dialog-1.1.1.tgz", - "integrity": "sha512-zysS+iU4YP3STKNS6USvFVqI4qqx8EpiwmT5TuCApVEBca+eRCbONi4EgzfNSuVnOXvC5UPHHMjs8RXO6DH9Bg==", - "dependencies": { - "@radix-ui/primitive": "1.1.0", - "@radix-ui/react-compose-refs": "1.1.0", - "@radix-ui/react-context": "1.1.0", - "@radix-ui/react-dismissable-layer": "1.1.0", - "@radix-ui/react-focus-guards": "1.1.0", - "@radix-ui/react-focus-scope": "1.1.0", - "@radix-ui/react-id": "1.1.0", - "@radix-ui/react-portal": "1.1.1", - "@radix-ui/react-presence": "1.1.0", - "@radix-ui/react-primitive": "2.0.0", - "@radix-ui/react-slot": "1.1.0", - "@radix-ui/react-use-controllable-state": "1.1.0", - "aria-hidden": "^1.1.1", - "react-remove-scroll": "2.5.7" - }, - "peerDependencies": { - "@types/react": "*", - "@types/react-dom": "*", - "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", - "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - }, - "@types/react-dom": { - "optional": true - } - } - }, "node_modules/@radix-ui/react-arrow": { "version": "1.1.0", "resolved": "https://registry.npmmirror.com/@radix-ui/react-arrow/-/react-arrow-1.1.0.tgz", @@ -2234,41 +2168,6 @@ } } }, - "node_modules/@radix-ui/react-navigation-menu": { - "version": "1.2.0", - "resolved": "https://registry.npmmirror.com/@radix-ui/react-navigation-menu/-/react-navigation-menu-1.2.0.tgz", - "integrity": "sha512-OQ8tcwAOR0DhPlSY3e4VMXeHiol7la4PPdJWhhwJiJA+NLX0SaCaonOkRnI3gCDHoZ7Fo7bb/G6q25fRM2Y+3Q==", - "dependencies": { - "@radix-ui/primitive": "1.1.0", - "@radix-ui/react-collection": "1.1.0", - "@radix-ui/react-compose-refs": "1.1.0", - "@radix-ui/react-context": "1.1.0", - "@radix-ui/react-direction": "1.1.0", - "@radix-ui/react-dismissable-layer": "1.1.0", - "@radix-ui/react-id": "1.1.0", - "@radix-ui/react-presence": "1.1.0", - "@radix-ui/react-primitive": "2.0.0", - "@radix-ui/react-use-callback-ref": "1.1.0", - "@radix-ui/react-use-controllable-state": "1.1.0", - "@radix-ui/react-use-layout-effect": "1.1.0", - "@radix-ui/react-use-previous": "1.1.0", - "@radix-ui/react-visually-hidden": "1.1.0" - }, - "peerDependencies": { - "@types/react": "*", - "@types/react-dom": "*", - "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", - "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - }, - "@types/react-dom": { - "optional": true - } - } - }, "node_modules/@radix-ui/react-popover": { "version": "1.1.2", "resolved": "https://registry.npmmirror.com/@radix-ui/react-popover/-/react-popover-1.1.2.tgz", @@ -2528,29 +2427,6 @@ } } }, - "node_modules/@radix-ui/react-progress": { - "version": "1.1.0", - "resolved": "https://registry.npmmirror.com/@radix-ui/react-progress/-/react-progress-1.1.0.tgz", - "integrity": "sha512-aSzvnYpP725CROcxAOEBVZZSIQVQdHgBr2QQFKySsaD14u8dNT0batuXI+AAGDdAHfXH8rbnHmjYFqVJ21KkRg==", - "dependencies": { - "@radix-ui/react-context": "1.1.0", - "@radix-ui/react-primitive": "2.0.0" - }, - "peerDependencies": { - "@types/react": "*", - "@types/react-dom": "*", - "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", - "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - }, - "@types/react-dom": { - "optional": true - } - } - }, "node_modules/@radix-ui/react-radio-group": { "version": "1.2.0", "resolved": "https://registry.npmmirror.com/@radix-ui/react-radio-group/-/react-radio-group-1.2.0.tgz", @@ -7866,18 +7742,6 @@ "resolved": "https://registry.npmmirror.com/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, - "node_modules/vaul": { - "version": "0.9.1", - "resolved": "https://registry.npmmirror.com/vaul/-/vaul-0.9.1.tgz", - "integrity": "sha512-fAhd7i4RNMinx+WEm6pF3nOl78DFkAazcN04ElLPFF9BMCNGbY/kou8UMhIcicm0rJCNePJP0Yyza60gGOD0Jw==", - "dependencies": { - "@radix-ui/react-dialog": "^1.0.4" - }, - "peerDependencies": { - "react": "^16.8 || ^17.0 || ^18.0", - "react-dom": "^16.8 || ^17.0 || ^18.0" - } - }, "node_modules/vite": { "version": "5.4.8", "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.8.tgz", diff --git a/ui/package.json b/ui/package.json index 022aff59..8758ecbf 100644 --- a/ui/package.json +++ b/ui/package.json @@ -13,14 +13,11 @@ "@ant-design/pro-components": "^2.8.2", "@hookform/resolvers": "^3.9.0", "@radix-ui/react-accordion": "^1.2.0", - "@radix-ui/react-alert-dialog": "^1.1.1", "@radix-ui/react-collapsible": "^1.1.1", "@radix-ui/react-dialog": "^1.1.2", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-label": "^2.1.0", - "@radix-ui/react-navigation-menu": "^1.2.0", "@radix-ui/react-popover": "^1.1.2", - "@radix-ui/react-progress": "^1.1.0", "@radix-ui/react-radio-group": "^1.2.0", "@radix-ui/react-scroll-area": "^1.1.0", "@radix-ui/react-select": "^2.1.1", @@ -54,7 +51,6 @@ "react-router-dom": "^6.25.1", "tailwind-merge": "^2.4.0", "tailwindcss-animate": "^1.0.7", - "vaul": "^0.9.1", "zod": "^3.23.8", "zustand": "^5.0.1" }, diff --git a/ui/src/components/certimate/XPagination.tsx b/ui/src/components/certimate/XPagination.tsx deleted file mode 100644 index 53435387..00000000 --- a/ui/src/components/certimate/XPagination.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink } from "@/components/ui/pagination"; - -type PaginationProps = { - totalPages: number; - currentPage: number; - onPageChange: (page: number) => void; -}; - -type PageNumber = number | string; - -const XPagination = ({ totalPages, currentPage, onPageChange }: PaginationProps) => { - const pageNeighbours = 1; // Number of page numbers to show on either side of the current page - - const getPageNumbers = () => { - const totalNumbers = pageNeighbours * 2 + 3; // total pages to display (left + right neighbours + current + 2 for start and end) - const totalBlocks = totalNumbers + 2; // adding 2 for the start and end page numbers - - if (totalPages > totalBlocks) { - let pages: PageNumber[] = []; - - const leftBound = Math.max(2, currentPage - pageNeighbours); - const rightBound = Math.min(totalPages - 1, currentPage + pageNeighbours); - - const beforeLastPage = totalPages - 1; - - pages = range(leftBound, rightBound); - - if (currentPage > pageNeighbours + 2) { - pages.unshift("..."); - } - if (currentPage < beforeLastPage - pageNeighbours) { - pages.push("..."); - } - - pages.unshift(1); - pages.push(totalPages); - - return pages; - } - - return range(1, totalPages); - }; - - const range = (from: number, to: number, step = 1) => { - let i = from; - const range = []; - - while (i <= to) { - range.push(i); - i += step; - } - - return range; - }; - - const pages = getPageNumbers(); - - return ( - <> - - - {pages.map((page, index) => { - if (page === "...") { - return ( - - - - ); - } - - return ( - - { - e.preventDefault(); - onPageChange(page as number); - }} - > - {page} - - - ); - })} - - - - ); -}; - -export default XPagination; diff --git a/ui/src/components/ui/alert-dialog.tsx b/ui/src/components/ui/alert-dialog.tsx deleted file mode 100644 index 168887f1..00000000 --- a/ui/src/components/ui/alert-dialog.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import * as React from "react"; -import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"; - -import { cn } from "./utils"; -import { buttonVariants } from "@/components/ui/button"; - -const AlertDialog = AlertDialogPrimitive.Root; - -const AlertDialogTrigger = AlertDialogPrimitive.Trigger; - -const AlertDialogPortal = AlertDialogPrimitive.Portal; - -const AlertDialogOverlay = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); -AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName; - -const AlertDialogContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - - - - -)); -AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName; - -const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes) => ( -
-); -AlertDialogHeader.displayName = "AlertDialogHeader"; - -const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes) => ( -
-); -AlertDialogFooter.displayName = "AlertDialogFooter"; - -const AlertDialogTitle = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ); -AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName; - -const AlertDialogDescription = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ); -AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName; - -const AlertDialogAction = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ); -AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName; - -const AlertDialogCancel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); -AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName; - -export { - AlertDialog, - AlertDialogPortal, - AlertDialogOverlay, - AlertDialogTrigger, - AlertDialogContent, - AlertDialogHeader, - AlertDialogFooter, - AlertDialogTitle, - AlertDialogDescription, - AlertDialogAction, - AlertDialogCancel, -}; diff --git a/ui/src/components/ui/badge.tsx b/ui/src/components/ui/badge.tsx deleted file mode 100644 index aaa69973..00000000 --- a/ui/src/components/ui/badge.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import * as React from "react"; -import { cva, type VariantProps } from "class-variance-authority"; - -import { cn } from "./utils"; - -const badgeVariants = cva( - "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", - { - variants: { - variant: { - default: "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", - secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", - destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", - outline: "text-foreground", - }, - }, - defaultVariants: { - variant: "default", - }, - } -); - -export interface BadgeProps extends React.HTMLAttributes, VariantProps {} - -function Badge({ className, variant, ...props }: BadgeProps) { - return
; -} - -export { Badge, badgeVariants }; diff --git a/ui/src/components/ui/breadcrumb.tsx b/ui/src/components/ui/breadcrumb.tsx deleted file mode 100644 index 1b173dd1..00000000 --- a/ui/src/components/ui/breadcrumb.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import * as React from "react"; -import { Slot } from "@radix-ui/react-slot"; -import { ChevronRight, MoreHorizontal } from "lucide-react"; - -import { cn } from "./utils"; - -const Breadcrumb = React.forwardRef< - HTMLElement, - React.ComponentPropsWithoutRef<"nav"> & { - separator?: React.ReactNode; - } ->(({ ...props }, ref) =>