From 70f19f230d9deac7724bd0b335e9bd814e48f010 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Fri, 10 Jan 2025 10:30:19 +0800 Subject: [PATCH] 1 --- frontend/package-lock.json | 56 +++ frontend/package.json | 2 + frontend/src/components/ui/command.tsx | 152 ++++++ frontend/src/components/ui/popover.tsx | 29 ++ .../List/components/ApplicationModal.tsx | 450 ++++++++++-------- 5 files changed, 485 insertions(+), 204 deletions(-) create mode 100644 frontend/src/components/ui/command.tsx create mode 100644 frontend/src/components/ui/popover.tsx diff --git a/frontend/package-lock.json b/frontend/package-lock.json index d4738a1a..68382483 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -31,6 +31,7 @@ "@radix-ui/react-dropdown-menu": "^2.1.4", "@radix-ui/react-label": "^2.1.1", "@radix-ui/react-navigation-menu": "^1.2.3", + "@radix-ui/react-popover": "^1.1.4", "@radix-ui/react-progress": "^1.1.1", "@radix-ui/react-scroll-area": "^1.2.2", "@radix-ui/react-select": "^2.1.4", @@ -45,6 +46,7 @@ "ajv-formats": "^3.0.1", "antd": "^5.22.2", "axios": "^1.6.2", + "cmdk": "^1.0.4", "dagre": "^0.8.5", "form-render": "^2.5.1", "less": "^4.2.1", @@ -2096,6 +2098,7 @@ "version": "1.1.4", "resolved": "https://registry.npmmirror.com/@radix-ui/react-dialog/-/react-dialog-1.1.4.tgz", "integrity": "sha512-Ur7EV1IwQGCyaAuyDRiOLA5JIUZxELJljF+MbM/2NC0BYwfuRrbpS30BiQBJrVruscgUkieKkqXYDOoByaxIoA==", + "license": "MIT", "dependencies": { "@radix-ui/primitive": "1.1.1", "@radix-ui/react-compose-refs": "1.1.1", @@ -2352,6 +2355,43 @@ } } }, + "node_modules/@radix-ui/react-popover": { + "version": "1.1.4", + "resolved": "https://registry.npmmirror.com/@radix-ui/react-popover/-/react-popover-1.1.4.tgz", + "integrity": "sha512-aUACAkXx8LaFymDma+HQVji7WhvEhpFJ7+qPz17Nf4lLZqtreGOFRiNQWQmhzp7kEWg9cOyyQJpdIMUMPc/CPw==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.1", + "@radix-ui/react-compose-refs": "1.1.1", + "@radix-ui/react-context": "1.1.1", + "@radix-ui/react-dismissable-layer": "1.1.3", + "@radix-ui/react-focus-guards": "1.1.1", + "@radix-ui/react-focus-scope": "1.1.1", + "@radix-ui/react-id": "1.1.0", + "@radix-ui/react-popper": "1.2.1", + "@radix-ui/react-portal": "1.1.3", + "@radix-ui/react-presence": "1.1.2", + "@radix-ui/react-primitive": "2.0.1", + "@radix-ui/react-slot": "1.1.1", + "@radix-ui/react-use-controllable-state": "1.1.0", + "aria-hidden": "^1.1.1", + "react-remove-scroll": "^2.6.1" + }, + "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-popper": { "version": "1.2.1", "resolved": "https://registry.npmmirror.com/@radix-ui/react-popper/-/react-popper-1.2.1.tgz", @@ -4397,6 +4437,22 @@ "node": ">=6" } }, + "node_modules/cmdk": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/cmdk/-/cmdk-1.0.4.tgz", + "integrity": "sha512-AnsjfHyHpQ/EFeAnG216WY7A5LiYCoZzCSygiLvfXC3H3LFGCprErteUcszaVluGOhuOTbJS3jWHrSDYPBBygg==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-dialog": "^1.1.2", + "@radix-ui/react-id": "^1.1.0", + "@radix-ui/react-primitive": "^2.0.0", + "use-sync-external-store": "^1.2.2" + }, + "peerDependencies": { + "react": "^18 || ^19 || ^19.0.0-rc", + "react-dom": "^18 || ^19 || ^19.0.0-rc" + } + }, "node_modules/color": { "version": "3.2.1", "resolved": "https://registry.npmmirror.com/color/-/color-3.2.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index 752266fa..5ae7dffe 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -33,6 +33,7 @@ "@radix-ui/react-dropdown-menu": "^2.1.4", "@radix-ui/react-label": "^2.1.1", "@radix-ui/react-navigation-menu": "^1.2.3", + "@radix-ui/react-popover": "^1.1.4", "@radix-ui/react-progress": "^1.1.1", "@radix-ui/react-scroll-area": "^1.2.2", "@radix-ui/react-select": "^2.1.4", @@ -47,6 +48,7 @@ "ajv-formats": "^3.0.1", "antd": "^5.22.2", "axios": "^1.6.2", + "cmdk": "^1.0.4", "dagre": "^0.8.5", "form-render": "^2.5.1", "less": "^4.2.1", diff --git a/frontend/src/components/ui/command.tsx b/frontend/src/components/ui/command.tsx new file mode 100644 index 00000000..49a2921a --- /dev/null +++ b/frontend/src/components/ui/command.tsx @@ -0,0 +1,152 @@ +import * as React from "react" +import { Command as CommandPrimitive } from "cmdk" +import { Search } from "lucide-react" +import { cn } from "@/lib/utils" +import { Dialog, DialogContent } from "@/components/ui/dialog" +import { type DialogProps } from "@radix-ui/react-dialog" + +const Command = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +Command.displayName = CommandPrimitive.displayName + +interface CommandDialogProps extends DialogProps {} + +const CommandDialog = ({ children, ...props }: CommandDialogProps) => { + return ( + + + + {children} + + + + ) +} + +const CommandInput = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( +
+ + +
+)) + +CommandInput.displayName = CommandPrimitive.Input.displayName + +const CommandList = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) + +CommandList.displayName = CommandPrimitive.List.displayName + +const CommandEmpty = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>((props, ref) => ( + +)) + +CommandEmpty.displayName = CommandPrimitive.Empty.displayName + +const CommandGroup = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) + +CommandGroup.displayName = CommandPrimitive.Group.displayName + +const CommandSeparator = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +CommandSeparator.displayName = CommandPrimitive.Separator.displayName + +const CommandItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) + +CommandItem.displayName = CommandPrimitive.Item.displayName + +const CommandShortcut = ({ + className, + ...props +}: React.HTMLAttributes) => { + return ( + + ) +} +CommandShortcut.displayName = "CommandShortcut" + +export { + Command, + CommandDialog, + CommandInput, + CommandList, + CommandEmpty, + CommandGroup, + CommandItem, + CommandShortcut, + CommandSeparator, +} diff --git a/frontend/src/components/ui/popover.tsx b/frontend/src/components/ui/popover.tsx new file mode 100644 index 00000000..bbba7e0e --- /dev/null +++ b/frontend/src/components/ui/popover.tsx @@ -0,0 +1,29 @@ +import * as React from "react" +import * as PopoverPrimitive from "@radix-ui/react-popover" + +import { cn } from "@/lib/utils" + +const Popover = PopoverPrimitive.Root + +const PopoverTrigger = PopoverPrimitive.Trigger + +const PopoverContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, align = "center", sideOffset = 4, ...props }, ref) => ( + + + +)) +PopoverContent.displayName = PopoverPrimitive.Content.displayName + +export { Popover, PopoverTrigger, PopoverContent } diff --git a/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx b/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx index de24a45b..e10aee43 100644 --- a/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx +++ b/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx @@ -35,6 +35,11 @@ import {useForm} from "react-hook-form"; import {zodResolver} from "@hookform/resolvers/zod"; import {applicationFormSchema, type ApplicationFormValues} from "../schema"; import {Textarea} from "@/components/ui/textarea"; +import {Command, CommandEmpty, CommandGroup, CommandInput, CommandItem} from "@/components/ui/command"; +import {ScrollArea} from "@/components/ui/scroll-area"; +import {Check} from "lucide-react"; +import {cn} from "@/lib/utils"; +import {Popover, PopoverContent, PopoverTrigger} from "@/components/ui/popover"; interface ApplicationModalProps { open: boolean; @@ -165,221 +170,258 @@ const ApplicationModal: React.FC = ({ return ( !open && onCancel()}> - - + + {isEdit ? '编辑' : '新建'}应用 -
- - ( - - 应用编码 - - - - - - )} - /> + +
+ + + ( + + 应用编码 + + + + + + )} + /> - ( - - 应用名称 - - - - - - )} - /> + ( + + 应用名称 + + + + + + )} + /> - ( - - 开发语言 - - - - )} - /> + ( + + 开发语言 + + + + )} + /> - ( - - Git实例 - - - - )} - /> + ( + + Git实例 + + + + )} + /> - ( - - 代码仓库组 - - - - )} - /> + ( + + 代码仓库组 + + + + + + + + + + 未找到代码仓库组 + + + {repositoryGroups.map((group) => ( + { + form.setValue("repositoryGroupId", group.id); + }} + > + + {group.name} + + ))} + + + + + + + + )} + /> - ( - - 仓库地址 - -
- -
-
- -
- )} - /> + ( + + 仓库地址 + +
+ +
+
+ +
+ )} + /> - ( - - 应用描述 - -