### What problem does this PR solve? Feat: Add ConfirmDeleteDialog #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)tags/v0.16.0
| @@ -13,6 +13,7 @@ | |||
| "@hookform/resolvers": "^3.9.1", | |||
| "@js-preview/excel": "^1.7.8", | |||
| "@monaco-editor/react": "^4.6.0", | |||
| "@radix-ui/react-alert-dialog": "^1.1.4", | |||
| "@radix-ui/react-aspect-ratio": "^1.1.0", | |||
| "@radix-ui/react-avatar": "^1.1.1", | |||
| "@radix-ui/react-checkbox": "^1.1.2", | |||
| @@ -4182,6 +4183,91 @@ | |||
| "resolved": "https://registry.npmmirror.com/@radix-ui/primitive/-/primitive-1.1.0.tgz", | |||
| "integrity": "sha512-4Z8dn6Upk0qk4P74xBhZ6Hd/w0mPEzOOLxy4xiPXOXqjF7jZS0VAKk7/x/H6FyY2zCkYJqePf1G5KmkmNJ4RBA==" | |||
| }, | |||
| "node_modules/@radix-ui/react-alert-dialog": { | |||
| "version": "1.1.4", | |||
| "resolved": "https://registry.npmmirror.com/@radix-ui/react-alert-dialog/-/react-alert-dialog-1.1.4.tgz", | |||
| "integrity": "sha512-A6Kh23qZDLy3PSU4bh2UJZznOrUdHImIXqF8YtUa6CN73f8EOO9XlXSCd9IHyPvIquTaa/kwaSWzZTtUvgXVGw==", | |||
| "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-dialog": "1.1.4", | |||
| "@radix-ui/react-primitive": "2.0.1", | |||
| "@radix-ui/react-slot": "1.1.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-alert-dialog/node_modules/@radix-ui/primitive": { | |||
| "version": "1.1.1", | |||
| "resolved": "https://registry.npmmirror.com/@radix-ui/primitive/-/primitive-1.1.1.tgz", | |||
| "integrity": "sha512-SJ31y+Q/zAyShtXJc8x83i9TYdbAfHZ++tUZnvjJJqFjzsdUnKsxPL6IEtBlxKkU7yzer//GQtZSV4GbldL3YA==" | |||
| }, | |||
| "node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-compose-refs": { | |||
| "version": "1.1.1", | |||
| "resolved": "https://registry.npmmirror.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.1.tgz", | |||
| "integrity": "sha512-Y9VzoRDSJtgFMUCoiZBDVo084VQ5hfpXxVE+NgkdNsjiDBByiImMZKKhxMwCbdHvhlENG6a833CbFkOQvTricw==", | |||
| "peerDependencies": { | |||
| "@types/react": "*", | |||
| "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" | |||
| }, | |||
| "peerDependenciesMeta": { | |||
| "@types/react": { | |||
| "optional": true | |||
| } | |||
| } | |||
| }, | |||
| "node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-primitive": { | |||
| "version": "2.0.1", | |||
| "resolved": "https://registry.npmmirror.com/@radix-ui/react-primitive/-/react-primitive-2.0.1.tgz", | |||
| "integrity": "sha512-sHCWTtxwNn3L3fH8qAfnF3WbUZycW93SM1j3NFDzXBiz8D6F5UTTy8G1+WFEaiCdvCVRJWj6N2R4Xq6HdiHmDg==", | |||
| "dependencies": { | |||
| "@radix-ui/react-slot": "1.1.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-alert-dialog/node_modules/@radix-ui/react-slot": { | |||
| "version": "1.1.1", | |||
| "resolved": "https://registry.npmmirror.com/@radix-ui/react-slot/-/react-slot-1.1.1.tgz", | |||
| "integrity": "sha512-RApLLOcINYJA+dMVbOju7MYv1Mb2EBp2nH4HdDzXTSyaR5optlm6Otrz1euW3HbdOR8UmmFK06TD+A9frYWv+g==", | |||
| "dependencies": { | |||
| "@radix-ui/react-compose-refs": "1.1.1" | |||
| }, | |||
| "peerDependencies": { | |||
| "@types/react": "*", | |||
| "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" | |||
| }, | |||
| "peerDependenciesMeta": { | |||
| "@types/react": { | |||
| "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", | |||
| @@ -24,6 +24,7 @@ | |||
| "@hookform/resolvers": "^3.9.1", | |||
| "@js-preview/excel": "^1.7.8", | |||
| "@monaco-editor/react": "^4.6.0", | |||
| "@radix-ui/react-alert-dialog": "^1.1.4", | |||
| "@radix-ui/react-aspect-ratio": "^1.1.0", | |||
| "@radix-ui/react-avatar": "^1.1.1", | |||
| "@radix-ui/react-checkbox": "^1.1.2", | |||
| @@ -0,0 +1,50 @@ | |||
| import { | |||
| AlertDialog, | |||
| AlertDialogAction, | |||
| AlertDialogCancel, | |||
| AlertDialogContent, | |||
| AlertDialogFooter, | |||
| AlertDialogHeader, | |||
| AlertDialogTitle, | |||
| AlertDialogTrigger, | |||
| } from '@/components/ui/alert-dialog'; | |||
| import { Trash2 } from 'lucide-react'; | |||
| import { PropsWithChildren } from 'react'; | |||
| import { useTranslation } from 'react-i18next'; | |||
| interface IProps { | |||
| title?: string; | |||
| onOk?: (...args: any[]) => any; | |||
| onCancel?: (...args: any[]) => any; | |||
| } | |||
| export function ConfirmDeleteDialog({ | |||
| children, | |||
| title, | |||
| }: IProps & PropsWithChildren) { | |||
| const { t } = useTranslation(); | |||
| return ( | |||
| <AlertDialog> | |||
| <AlertDialogTrigger asChild>{children}</AlertDialogTrigger> | |||
| <AlertDialogContent> | |||
| <AlertDialogHeader> | |||
| <AlertDialogTitle> | |||
| {title ?? t('common.deleteModalTitle')} | |||
| </AlertDialogTitle> | |||
| {/* <AlertDialogDescription> | |||
| This action cannot be undone. This will permanently delete your | |||
| account and remove your data from our servers. | |||
| </AlertDialogDescription> */} | |||
| </AlertDialogHeader> | |||
| <AlertDialogFooter> | |||
| <AlertDialogCancel>{t('common.cancel')}</AlertDialogCancel> | |||
| <AlertDialogAction className="bg-colors-background-functional-solid-danger text--colors-text-neutral-strong"> | |||
| <Trash2 /> | |||
| {t('common.ok')} | |||
| </AlertDialogAction> | |||
| </AlertDialogFooter> | |||
| </AlertDialogContent> | |||
| </AlertDialog> | |||
| ); | |||
| } | |||
| @@ -0,0 +1,141 @@ | |||
| 'use client'; | |||
| import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'; | |||
| import * as React from 'react'; | |||
| import { buttonVariants } from '@/components/ui/button'; | |||
| import { cn } from '@/lib/utils'; | |||
| const AlertDialog = AlertDialogPrimitive.Root; | |||
| const AlertDialogTrigger = AlertDialogPrimitive.Trigger; | |||
| const AlertDialogPortal = AlertDialogPrimitive.Portal; | |||
| const AlertDialogOverlay = React.forwardRef< | |||
| React.ElementRef<typeof AlertDialogPrimitive.Overlay>, | |||
| React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay> | |||
| >(({ className, ...props }, ref) => ( | |||
| <AlertDialogPrimitive.Overlay | |||
| className={cn( | |||
| 'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0', | |||
| className, | |||
| )} | |||
| {...props} | |||
| ref={ref} | |||
| /> | |||
| )); | |||
| AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName; | |||
| const AlertDialogContent = React.forwardRef< | |||
| React.ElementRef<typeof AlertDialogPrimitive.Content>, | |||
| React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content> | |||
| >(({ className, ...props }, ref) => ( | |||
| <AlertDialogPortal> | |||
| <AlertDialogOverlay /> | |||
| <AlertDialogPrimitive.Content | |||
| ref={ref} | |||
| className={cn( | |||
| 'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-colors-background-neutral-standard p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg', | |||
| className, | |||
| )} | |||
| {...props} | |||
| /> | |||
| </AlertDialogPortal> | |||
| )); | |||
| AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName; | |||
| const AlertDialogHeader = ({ | |||
| className, | |||
| ...props | |||
| }: React.HTMLAttributes<HTMLDivElement>) => ( | |||
| <div | |||
| className={cn( | |||
| 'flex flex-col space-y-2 text-center sm:text-left', | |||
| className, | |||
| )} | |||
| {...props} | |||
| /> | |||
| ); | |||
| AlertDialogHeader.displayName = 'AlertDialogHeader'; | |||
| const AlertDialogFooter = ({ | |||
| className, | |||
| ...props | |||
| }: React.HTMLAttributes<HTMLDivElement>) => ( | |||
| <div | |||
| className={cn( | |||
| 'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', | |||
| className, | |||
| )} | |||
| {...props} | |||
| /> | |||
| ); | |||
| AlertDialogFooter.displayName = 'AlertDialogFooter'; | |||
| const AlertDialogTitle = React.forwardRef< | |||
| React.ElementRef<typeof AlertDialogPrimitive.Title>, | |||
| React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title> | |||
| >(({ className, ...props }, ref) => ( | |||
| <AlertDialogPrimitive.Title | |||
| ref={ref} | |||
| className={cn('text-lg font-semibold', className)} | |||
| {...props} | |||
| /> | |||
| )); | |||
| AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName; | |||
| const AlertDialogDescription = React.forwardRef< | |||
| React.ElementRef<typeof AlertDialogPrimitive.Description>, | |||
| React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description> | |||
| >(({ className, ...props }, ref) => ( | |||
| <AlertDialogPrimitive.Description | |||
| ref={ref} | |||
| className={cn('text-sm text-muted-foreground', className)} | |||
| {...props} | |||
| /> | |||
| )); | |||
| AlertDialogDescription.displayName = | |||
| AlertDialogPrimitive.Description.displayName; | |||
| const AlertDialogAction = React.forwardRef< | |||
| React.ElementRef<typeof AlertDialogPrimitive.Action>, | |||
| React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action> | |||
| >(({ className, ...props }, ref) => ( | |||
| <AlertDialogPrimitive.Action | |||
| ref={ref} | |||
| className={cn(buttonVariants(), className)} | |||
| {...props} | |||
| /> | |||
| )); | |||
| AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName; | |||
| const AlertDialogCancel = React.forwardRef< | |||
| React.ElementRef<typeof AlertDialogPrimitive.Cancel>, | |||
| React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel> | |||
| >(({ className, ...props }, ref) => ( | |||
| <AlertDialogPrimitive.Cancel | |||
| ref={ref} | |||
| className={cn( | |||
| buttonVariants({ variant: 'outline' }), | |||
| 'mt-2 sm:mt-0', | |||
| className, | |||
| )} | |||
| {...props} | |||
| /> | |||
| )); | |||
| AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName; | |||
| export { | |||
| AlertDialog, | |||
| AlertDialogAction, | |||
| AlertDialogCancel, | |||
| AlertDialogContent, | |||
| AlertDialogDescription, | |||
| AlertDialogFooter, | |||
| AlertDialogHeader, | |||
| AlertDialogOverlay, | |||
| AlertDialogPortal, | |||
| AlertDialogTitle, | |||
| AlertDialogTrigger, | |||
| }; | |||
| @@ -17,7 +17,7 @@ const Slider = React.forwardRef< | |||
| )} | |||
| {...props} | |||
| > | |||
| <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary"> | |||
| <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-colors-background-inverse-strong"> | |||
| <SliderPrimitive.Range className="absolute h-full bg-primary" /> | |||
| </SliderPrimitive.Track> | |||
| <SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-colors-text-core-standard ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" /> | |||
| @@ -1,8 +1,9 @@ | |||
| import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog'; | |||
| import ListFilterBar from '@/components/list-filter-bar'; | |||
| import { Button } from '@/components/ui/button'; | |||
| import { Card, CardContent } from '@/components/ui/card'; | |||
| import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks'; | |||
| import { ChevronRight, MoreHorizontal, Plus } from 'lucide-react'; | |||
| import { ChevronRight, Plus, Trash2 } from 'lucide-react'; | |||
| import { DatasetCreatingDialog } from './dataset-creating-dialog'; | |||
| import { useSaveKnowledge } from './hooks'; | |||
| @@ -109,9 +110,11 @@ export default function Datasets() { | |||
| className="w-[70px] h-[70px] rounded-xl bg-cover" | |||
| style={{ backgroundImage: `url(${dataset.image})` }} | |||
| /> | |||
| <Button variant="ghost" size="icon"> | |||
| <MoreHorizontal className="h-6 w-6" /> | |||
| </Button> | |||
| <ConfirmDeleteDialog> | |||
| <Button variant="ghost" size="icon"> | |||
| <Trash2 /> | |||
| </Button> | |||
| </ConfirmDeleteDialog> | |||
| </div> | |||
| <div className="flex justify-between items-end"> | |||
| <div> | |||
| @@ -110,7 +110,7 @@ module.exports = { | |||
| }, | |||
| 'colors-background-functional-solid-danger': { | |||
| DEFAULT: 'var(--colors-background-functional-solid-danger)', | |||
| foreground: 'var(--background-inverse-standard-foreground)', | |||
| foreground: 'var(--colors-text-inverse-strong)', | |||
| }, | |||
| 'colors-background-functional-solid-notice': { | |||
| DEFAULT: 'var(--colors-background-functional-solid-notice)', | |||
| @@ -41,6 +41,7 @@ | |||
| --colors-background-inverse-strong: rgba(11, 10, 18, 0.8); | |||
| --colors-background-inverse-weak: rgba(17, 16, 23, 0.1); | |||
| --colors-background-neutral-standard: white; | |||
| --colors-background-functional-solid-danger: rgba(222, 17, 53, 1); | |||
| --button-blue-text: rgb(22, 119, 255); | |||