balibabu commited on
Commit
a8facdf
·
1 Parent(s): 311da71

Feat: Add FileUploadDialog #3221 (#4327) (#4335)

Browse files

### What problem does this PR solve?

Feat: Add ConfirmDeleteDialog #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)

web/package-lock.json CHANGED
@@ -13,6 +13,7 @@
13
  "@hookform/resolvers": "^3.9.1",
14
  "@js-preview/excel": "^1.7.8",
15
  "@monaco-editor/react": "^4.6.0",
 
16
  "@radix-ui/react-aspect-ratio": "^1.1.0",
17
  "@radix-ui/react-avatar": "^1.1.1",
18
  "@radix-ui/react-checkbox": "^1.1.2",
@@ -4182,6 +4183,91 @@
4182
  "resolved": "https://registry.npmmirror.com/@radix-ui/primitive/-/primitive-1.1.0.tgz",
4183
  "integrity": "sha512-4Z8dn6Upk0qk4P74xBhZ6Hd/w0mPEzOOLxy4xiPXOXqjF7jZS0VAKk7/x/H6FyY2zCkYJqePf1G5KmkmNJ4RBA=="
4184
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4185
  "node_modules/@radix-ui/react-arrow": {
4186
  "version": "1.1.0",
4187
  "resolved": "https://registry.npmmirror.com/@radix-ui/react-arrow/-/react-arrow-1.1.0.tgz",
 
13
  "@hookform/resolvers": "^3.9.1",
14
  "@js-preview/excel": "^1.7.8",
15
  "@monaco-editor/react": "^4.6.0",
16
+ "@radix-ui/react-alert-dialog": "^1.1.4",
17
  "@radix-ui/react-aspect-ratio": "^1.1.0",
18
  "@radix-ui/react-avatar": "^1.1.1",
19
  "@radix-ui/react-checkbox": "^1.1.2",
 
4183
  "resolved": "https://registry.npmmirror.com/@radix-ui/primitive/-/primitive-1.1.0.tgz",
4184
  "integrity": "sha512-4Z8dn6Upk0qk4P74xBhZ6Hd/w0mPEzOOLxy4xiPXOXqjF7jZS0VAKk7/x/H6FyY2zCkYJqePf1G5KmkmNJ4RBA=="
4185
  },
4186
+ "node_modules/@radix-ui/react-alert-dialog": {
4187
+ "version": "1.1.4",
4188
+ "resolved": "https://registry.npmmirror.com/@radix-ui/react-alert-dialog/-/react-alert-dialog-1.1.4.tgz",
4189
+ "integrity": "sha512-A6Kh23qZDLy3PSU4bh2UJZznOrUdHImIXqF8YtUa6CN73f8EOO9XlXSCd9IHyPvIquTaa/kwaSWzZTtUvgXVGw==",
4190
+ "dependencies": {
4191
+ "@radix-ui/primitive": "1.1.1",
4192
+ "@radix-ui/react-compose-refs": "1.1.1",
4193
+ "@radix-ui/react-context": "1.1.1",
4194
+ "@radix-ui/react-dialog": "1.1.4",
4195
+ "@radix-ui/react-primitive": "2.0.1",
4196
+ "@radix-ui/react-slot": "1.1.1"
4197
+ },
4198
+ "peerDependencies": {
4199
+ "@types/react": "*",
4200
+ "@types/react-dom": "*",
4201
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
4202
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
4203
+ },
4204
+ "peerDependenciesMeta": {
4205
+ "@types/react": {
4206
+ "optional": true
4207
+ },
4208
+ "@types/react-dom": {
4209
+ "optional": true
4210
+ }
4211
+ }
4212
+ },
4213
+ "node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/primitive": {
4214
+ "version": "1.1.1",
4215
+ "resolved": "https://registry.npmmirror.com/@radix-ui/primitive/-/primitive-1.1.1.tgz",
4216
+ "integrity": "sha512-SJ31y+Q/zAyShtXJc8x83i9TYdbAfHZ++tUZnvjJJqFjzsdUnKsxPL6IEtBlxKkU7yzer//GQtZSV4GbldL3YA=="
4217
+ },
4218
+ "node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-compose-refs": {
4219
+ "version": "1.1.1",
4220
+ "resolved": "https://registry.npmmirror.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.1.tgz",
4221
+ "integrity": "sha512-Y9VzoRDSJtgFMUCoiZBDVo084VQ5hfpXxVE+NgkdNsjiDBByiImMZKKhxMwCbdHvhlENG6a833CbFkOQvTricw==",
4222
+ "peerDependencies": {
4223
+ "@types/react": "*",
4224
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
4225
+ },
4226
+ "peerDependenciesMeta": {
4227
+ "@types/react": {
4228
+ "optional": true
4229
+ }
4230
+ }
4231
+ },
4232
+ "node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-primitive": {
4233
+ "version": "2.0.1",
4234
+ "resolved": "https://registry.npmmirror.com/@radix-ui/react-primitive/-/react-primitive-2.0.1.tgz",
4235
+ "integrity": "sha512-sHCWTtxwNn3L3fH8qAfnF3WbUZycW93SM1j3NFDzXBiz8D6F5UTTy8G1+WFEaiCdvCVRJWj6N2R4Xq6HdiHmDg==",
4236
+ "dependencies": {
4237
+ "@radix-ui/react-slot": "1.1.1"
4238
+ },
4239
+ "peerDependencies": {
4240
+ "@types/react": "*",
4241
+ "@types/react-dom": "*",
4242
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
4243
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
4244
+ },
4245
+ "peerDependenciesMeta": {
4246
+ "@types/react": {
4247
+ "optional": true
4248
+ },
4249
+ "@types/react-dom": {
4250
+ "optional": true
4251
+ }
4252
+ }
4253
+ },
4254
+ "node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-slot": {
4255
+ "version": "1.1.1",
4256
+ "resolved": "https://registry.npmmirror.com/@radix-ui/react-slot/-/react-slot-1.1.1.tgz",
4257
+ "integrity": "sha512-RApLLOcINYJA+dMVbOju7MYv1Mb2EBp2nH4HdDzXTSyaR5optlm6Otrz1euW3HbdOR8UmmFK06TD+A9frYWv+g==",
4258
+ "dependencies": {
4259
+ "@radix-ui/react-compose-refs": "1.1.1"
4260
+ },
4261
+ "peerDependencies": {
4262
+ "@types/react": "*",
4263
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
4264
+ },
4265
+ "peerDependenciesMeta": {
4266
+ "@types/react": {
4267
+ "optional": true
4268
+ }
4269
+ }
4270
+ },
4271
  "node_modules/@radix-ui/react-arrow": {
4272
  "version": "1.1.0",
4273
  "resolved": "https://registry.npmmirror.com/@radix-ui/react-arrow/-/react-arrow-1.1.0.tgz",
web/package.json CHANGED
@@ -24,6 +24,7 @@
24
  "@hookform/resolvers": "^3.9.1",
25
  "@js-preview/excel": "^1.7.8",
26
  "@monaco-editor/react": "^4.6.0",
 
27
  "@radix-ui/react-aspect-ratio": "^1.1.0",
28
  "@radix-ui/react-avatar": "^1.1.1",
29
  "@radix-ui/react-checkbox": "^1.1.2",
 
24
  "@hookform/resolvers": "^3.9.1",
25
  "@js-preview/excel": "^1.7.8",
26
  "@monaco-editor/react": "^4.6.0",
27
+ "@radix-ui/react-alert-dialog": "^1.1.4",
28
  "@radix-ui/react-aspect-ratio": "^1.1.0",
29
  "@radix-ui/react-avatar": "^1.1.1",
30
  "@radix-ui/react-checkbox": "^1.1.2",
web/src/components/confirm-delete-dialog.tsx ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ AlertDialog,
3
+ AlertDialogAction,
4
+ AlertDialogCancel,
5
+ AlertDialogContent,
6
+ AlertDialogFooter,
7
+ AlertDialogHeader,
8
+ AlertDialogTitle,
9
+ AlertDialogTrigger,
10
+ } from '@/components/ui/alert-dialog';
11
+ import { Trash2 } from 'lucide-react';
12
+ import { PropsWithChildren } from 'react';
13
+ import { useTranslation } from 'react-i18next';
14
+
15
+ interface IProps {
16
+ title?: string;
17
+ onOk?: (...args: any[]) => any;
18
+ onCancel?: (...args: any[]) => any;
19
+ }
20
+
21
+ export function ConfirmDeleteDialog({
22
+ children,
23
+ title,
24
+ }: IProps & PropsWithChildren) {
25
+ const { t } = useTranslation();
26
+
27
+ return (
28
+ <AlertDialog>
29
+ <AlertDialogTrigger asChild>{children}</AlertDialogTrigger>
30
+ <AlertDialogContent>
31
+ <AlertDialogHeader>
32
+ <AlertDialogTitle>
33
+ {title ?? t('common.deleteModalTitle')}
34
+ </AlertDialogTitle>
35
+ {/* <AlertDialogDescription>
36
+ This action cannot be undone. This will permanently delete your
37
+ account and remove your data from our servers.
38
+ </AlertDialogDescription> */}
39
+ </AlertDialogHeader>
40
+ <AlertDialogFooter>
41
+ <AlertDialogCancel>{t('common.cancel')}</AlertDialogCancel>
42
+ <AlertDialogAction className="bg-colors-background-functional-solid-danger text--colors-text-neutral-strong">
43
+ <Trash2 />
44
+ {t('common.ok')}
45
+ </AlertDialogAction>
46
+ </AlertDialogFooter>
47
+ </AlertDialogContent>
48
+ </AlertDialog>
49
+ );
50
+ }
web/src/components/ui/alert-dialog.tsx ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use client';
2
+
3
+ import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
4
+ import * as React from 'react';
5
+
6
+ import { buttonVariants } from '@/components/ui/button';
7
+ import { cn } from '@/lib/utils';
8
+
9
+ const AlertDialog = AlertDialogPrimitive.Root;
10
+
11
+ const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
12
+
13
+ const AlertDialogPortal = AlertDialogPrimitive.Portal;
14
+
15
+ const AlertDialogOverlay = React.forwardRef<
16
+ React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
17
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
18
+ >(({ className, ...props }, ref) => (
19
+ <AlertDialogPrimitive.Overlay
20
+ className={cn(
21
+ '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',
22
+ className,
23
+ )}
24
+ {...props}
25
+ ref={ref}
26
+ />
27
+ ));
28
+ AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
29
+
30
+ const AlertDialogContent = React.forwardRef<
31
+ React.ElementRef<typeof AlertDialogPrimitive.Content>,
32
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
33
+ >(({ className, ...props }, ref) => (
34
+ <AlertDialogPortal>
35
+ <AlertDialogOverlay />
36
+ <AlertDialogPrimitive.Content
37
+ ref={ref}
38
+ className={cn(
39
+ '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',
40
+ className,
41
+ )}
42
+ {...props}
43
+ />
44
+ </AlertDialogPortal>
45
+ ));
46
+ AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
47
+
48
+ const AlertDialogHeader = ({
49
+ className,
50
+ ...props
51
+ }: React.HTMLAttributes<HTMLDivElement>) => (
52
+ <div
53
+ className={cn(
54
+ 'flex flex-col space-y-2 text-center sm:text-left',
55
+ className,
56
+ )}
57
+ {...props}
58
+ />
59
+ );
60
+ AlertDialogHeader.displayName = 'AlertDialogHeader';
61
+
62
+ const AlertDialogFooter = ({
63
+ className,
64
+ ...props
65
+ }: React.HTMLAttributes<HTMLDivElement>) => (
66
+ <div
67
+ className={cn(
68
+ 'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
69
+ className,
70
+ )}
71
+ {...props}
72
+ />
73
+ );
74
+ AlertDialogFooter.displayName = 'AlertDialogFooter';
75
+
76
+ const AlertDialogTitle = React.forwardRef<
77
+ React.ElementRef<typeof AlertDialogPrimitive.Title>,
78
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
79
+ >(({ className, ...props }, ref) => (
80
+ <AlertDialogPrimitive.Title
81
+ ref={ref}
82
+ className={cn('text-lg font-semibold', className)}
83
+ {...props}
84
+ />
85
+ ));
86
+ AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
87
+
88
+ const AlertDialogDescription = React.forwardRef<
89
+ React.ElementRef<typeof AlertDialogPrimitive.Description>,
90
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
91
+ >(({ className, ...props }, ref) => (
92
+ <AlertDialogPrimitive.Description
93
+ ref={ref}
94
+ className={cn('text-sm text-muted-foreground', className)}
95
+ {...props}
96
+ />
97
+ ));
98
+ AlertDialogDescription.displayName =
99
+ AlertDialogPrimitive.Description.displayName;
100
+
101
+ const AlertDialogAction = React.forwardRef<
102
+ React.ElementRef<typeof AlertDialogPrimitive.Action>,
103
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
104
+ >(({ className, ...props }, ref) => (
105
+ <AlertDialogPrimitive.Action
106
+ ref={ref}
107
+ className={cn(buttonVariants(), className)}
108
+ {...props}
109
+ />
110
+ ));
111
+ AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
112
+
113
+ const AlertDialogCancel = React.forwardRef<
114
+ React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
115
+ React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
116
+ >(({ className, ...props }, ref) => (
117
+ <AlertDialogPrimitive.Cancel
118
+ ref={ref}
119
+ className={cn(
120
+ buttonVariants({ variant: 'outline' }),
121
+ 'mt-2 sm:mt-0',
122
+ className,
123
+ )}
124
+ {...props}
125
+ />
126
+ ));
127
+ AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
128
+
129
+ export {
130
+ AlertDialog,
131
+ AlertDialogAction,
132
+ AlertDialogCancel,
133
+ AlertDialogContent,
134
+ AlertDialogDescription,
135
+ AlertDialogFooter,
136
+ AlertDialogHeader,
137
+ AlertDialogOverlay,
138
+ AlertDialogPortal,
139
+ AlertDialogTitle,
140
+ AlertDialogTrigger,
141
+ };
web/src/components/ui/slider.tsx CHANGED
@@ -17,7 +17,7 @@ const Slider = React.forwardRef<
17
  )}
18
  {...props}
19
  >
20
- <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
21
  <SliderPrimitive.Range className="absolute h-full bg-primary" />
22
  </SliderPrimitive.Track>
23
  <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" />
 
17
  )}
18
  {...props}
19
  >
20
+ <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-colors-background-inverse-strong">
21
  <SliderPrimitive.Range className="absolute h-full bg-primary" />
22
  </SliderPrimitive.Track>
23
  <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" />
web/src/pages/datasets/index.tsx CHANGED
@@ -1,8 +1,9 @@
 
1
  import ListFilterBar from '@/components/list-filter-bar';
2
  import { Button } from '@/components/ui/button';
3
  import { Card, CardContent } from '@/components/ui/card';
4
  import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
5
- import { ChevronRight, MoreHorizontal, Plus } from 'lucide-react';
6
  import { DatasetCreatingDialog } from './dataset-creating-dialog';
7
  import { useSaveKnowledge } from './hooks';
8
 
@@ -109,9 +110,11 @@ export default function Datasets() {
109
  className="w-[70px] h-[70px] rounded-xl bg-cover"
110
  style={{ backgroundImage: `url(${dataset.image})` }}
111
  />
112
- <Button variant="ghost" size="icon">
113
- <MoreHorizontal className="h-6 w-6" />
114
- </Button>
 
 
115
  </div>
116
  <div className="flex justify-between items-end">
117
  <div>
 
1
+ import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
2
  import ListFilterBar from '@/components/list-filter-bar';
3
  import { Button } from '@/components/ui/button';
4
  import { Card, CardContent } from '@/components/ui/card';
5
  import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
6
+ import { ChevronRight, Plus, Trash2 } from 'lucide-react';
7
  import { DatasetCreatingDialog } from './dataset-creating-dialog';
8
  import { useSaveKnowledge } from './hooks';
9
 
 
110
  className="w-[70px] h-[70px] rounded-xl bg-cover"
111
  style={{ backgroundImage: `url(${dataset.image})` }}
112
  />
113
+ <ConfirmDeleteDialog>
114
+ <Button variant="ghost" size="icon">
115
+ <Trash2 />
116
+ </Button>
117
+ </ConfirmDeleteDialog>
118
  </div>
119
  <div className="flex justify-between items-end">
120
  <div>
web/tailwind.config.js CHANGED
@@ -110,7 +110,7 @@ module.exports = {
110
  },
111
  'colors-background-functional-solid-danger': {
112
  DEFAULT: 'var(--colors-background-functional-solid-danger)',
113
- foreground: 'var(--background-inverse-standard-foreground)',
114
  },
115
  'colors-background-functional-solid-notice': {
116
  DEFAULT: 'var(--colors-background-functional-solid-notice)',
 
110
  },
111
  'colors-background-functional-solid-danger': {
112
  DEFAULT: 'var(--colors-background-functional-solid-danger)',
113
+ foreground: 'var(--colors-text-inverse-strong)',
114
  },
115
  'colors-background-functional-solid-notice': {
116
  DEFAULT: 'var(--colors-background-functional-solid-notice)',
web/tailwind.css CHANGED
@@ -41,6 +41,7 @@
41
  --colors-background-inverse-strong: rgba(11, 10, 18, 0.8);
42
  --colors-background-inverse-weak: rgba(17, 16, 23, 0.1);
43
  --colors-background-neutral-standard: white;
 
44
 
45
  --button-blue-text: rgb(22, 119, 255);
46
 
 
41
  --colors-background-inverse-strong: rgba(11, 10, 18, 0.8);
42
  --colors-background-inverse-weak: rgba(17, 16, 23, 0.1);
43
  --colors-background-neutral-standard: white;
44
+ --colors-background-functional-solid-danger: rgba(222, 17, 53, 1);
45
 
46
  --button-blue-text: rgb(22, 119, 255);
47