11/** @jsxImportSource react */
2- import { useEffect , useRef } from "react" ;
3- import { X } from "lucide-react" ;
2+ import { useRef } from "react" ;
43
4+ import { Button } from "@/components/ui/button" ;
5+ import {
6+ Dialog ,
7+ DialogContent ,
8+ DialogDescription ,
9+ DialogFooter ,
10+ DialogHeader ,
11+ DialogTitle ,
12+ } from "@/components/ui/dialog" ;
13+ import { Field , FieldLabel } from "@/components/ui/field" ;
14+ import { Input } from "@/components/ui/input" ;
515import { t } from "../../../i18n" ;
6- import { inputClass , pillGhostClass , pillPrimaryClass , pillSecondaryClass } from "./modal-styles" ;
716
817export type RenameWorkspaceModalProps = {
918 open : boolean ;
@@ -18,83 +27,50 @@ export type RenameWorkspaceModalProps = {
1827export function RenameWorkspaceModal ( props : RenameWorkspaceModalProps ) {
1928 const inputRef = useRef < HTMLInputElement | null > ( null ) ;
2029
21- useEffect ( ( ) => {
22- if ( ! props . open ) return ;
23- const frame = requestAnimationFrame ( ( ) => {
24- inputRef . current ?. focus ( ) ;
25- inputRef . current ?. select ( ) ;
26- } ) ;
27- return ( ) => cancelAnimationFrame ( frame ) ;
28- } , [ props . open ] ) ;
29-
30- if ( ! props . open ) return null ;
31-
3230 return (
33- < div className = "fixed inset-0 z-50 bg-gray-1/60 backdrop-blur-sm flex items-center justify-center p-4" >
34- < div className = "bg-gray-2 border border-gray-6/70 w-full max-w-lg rounded-2xl shadow-2xl overflow-hidden" >
35- < div className = "p-6" >
36- < div className = "flex items-start justify-between gap-4" >
37- < div >
38- < h3 className = "text-lg font-semibold text-gray-12" >
39- { t ( "workspace.rename_title" ) }
40- </ h3 >
41- < p className = "text-sm text-gray-11 mt-1" >
42- { t ( "workspace.rename_description" ) }
43- </ p >
44- </ div >
45- < button
46- type = "button"
47- className = { `${ pillGhostClass } !p-2 rounded-full` }
48- onClick = { props . onClose }
49- >
50- < X size = { 16 } />
51- </ button >
52- </ div >
31+ < Dialog
32+ open = { props . open }
33+ onOpenChange = { ( open ) => {
34+ if ( ! open ) props . onClose ( ) ;
35+ } }
36+ >
37+ < DialogContent className = "sm:max-w-lg" initialFocus = { inputRef } >
38+ < DialogHeader >
39+ < DialogTitle > { t ( "workspace.rename_title" ) } </ DialogTitle >
40+ < DialogDescription > { t ( "workspace.rename_description" ) } </ DialogDescription >
41+ </ DialogHeader >
5342
54- < div className = "mt-6" >
55- < label className = "mb-1.5 block text-[13px] font-medium text-dls-text" >
56- { t ( "workspace.rename_label" ) }
57- </ label >
58- < input
59- ref = { inputRef }
60- type = "text"
61- value = { props . title }
62- onChange = { ( event ) => props . onTitleChange ( event . currentTarget . value ) }
63- onKeyDown = { ( event ) => {
64- if (
65- event . key !== "Enter" ||
66- event . nativeEvent . isComposing ||
67- event . keyCode === 229
68- )
69- return ;
70- event . preventDefault ( ) ;
71- if ( props . canSave ) props . onSave ( ) ;
72- } }
73- placeholder = { t ( "workspace.rename_placeholder" ) }
74- className = { `${ inputClass } bg-gray-3` }
75- />
76- </ div >
43+ < Field >
44+ < FieldLabel htmlFor = "rename-workspace-title" > { t ( "workspace.rename_label" ) } </ FieldLabel >
45+ < Input
46+ ref = { inputRef }
47+ id = "rename-workspace-title"
48+ type = "text"
49+ value = { props . title }
50+ onChange = { ( event ) => props . onTitleChange ( event . currentTarget . value ) }
51+ onKeyDown = { ( event ) => {
52+ if ( event . nativeEvent . isComposing || event . key === "Process" ) {
53+ return ;
54+ }
55+ if ( event . key !== "Enter" ) {
56+ return ;
57+ }
58+ event . preventDefault ( ) ;
59+ if ( props . canSave ) props . onSave ( ) ;
60+ } }
61+ placeholder = { t ( "workspace.rename_placeholder" ) }
62+ />
63+ </ Field >
7764
78- < div className = "mt-6 flex justify-end gap-2" >
79- < button
80- type = "button"
81- className = { pillSecondaryClass }
82- onClick = { props . onClose }
83- disabled = { props . busy }
84- >
85- { t ( "common.cancel" ) }
86- </ button >
87- < button
88- type = "button"
89- className = { pillPrimaryClass }
90- onClick = { props . onSave }
91- disabled = { ! props . canSave }
92- >
93- { t ( "common.save" ) }
94- </ button >
95- </ div >
96- </ div >
97- </ div >
98- </ div >
65+ < DialogFooter >
66+ < Button variant = "outline" type = "button" onClick = { props . onClose } disabled = { props . busy } >
67+ { t ( "common.cancel" ) }
68+ </ Button >
69+ < Button type = "button" onClick = { props . onSave } disabled = { ! props . canSave } >
70+ { t ( "common.save" ) }
71+ </ Button >
72+ </ DialogFooter >
73+ </ DialogContent >
74+ </ Dialog >
9975 ) ;
10076}
0 commit comments