File tree Expand file tree Collapse file tree 2 files changed +57
-1
lines changed
Expand file tree Collapse file tree 2 files changed +57
-1
lines changed Original file line number Diff line number Diff line change 1+ import { Button , Dialog , TextField } from "@vaadin/react-components" ;
2+ import { Signal , useSignal } from "@vaadin/hilla-react-signals" ;
3+ import FileItem from "Frontend/generated/pro/homedns/filebrowser/model/FileItem" ;
4+
5+ export let renameFileDialogOpenSignal : Signal < boolean > ;
6+ export let itemToRename : Signal < FileItem | null > ;
7+
8+ export default function RenameFileDialog ( ) {
9+ renameFileDialogOpenSignal = useSignal < boolean > ( false ) ;
10+ itemToRename = useSignal < FileItem | null > ( null ) ;
11+
12+ return < Dialog
13+ header = { (
14+ < div className = "flex flex-col gap-xs" >
15+ < span className = "text-secondary text-s" > { itemToRename . value ?. displayName } </ span >
16+ < span className = "text-body text-m" > Rename</ span >
17+ </ div >
18+ ) }
19+ opened = { renameFileDialogOpenSignal . value }
20+ onClosed = { ( ) => {
21+ renameFileDialogOpenSignal . value = false ;
22+ } }
23+ footer = {
24+ < >
25+ < div className = "flex flex-row w-full justify-between" >
26+ < Button
27+ onClick = { ( ) => {
28+ renameFileDialogOpenSignal . value = false ;
29+ } }
30+ >
31+ Cancel
32+ </ Button >
33+ < Button
34+ theme = "primary"
35+ onClick = { ( ) => {
36+ renameFileDialogOpenSignal . value = false ;
37+ } }
38+ >
39+ Rename
40+ </ Button >
41+ </ div >
42+ </ >
43+ }
44+ >
45+ < div className = "flex flex-col items-stretch max-w-full" style = { { width : '18rem' } } >
46+ < TextField label = "New name" value = { itemToRename . value ?. displayName } />
47+ </ div >
48+ </ Dialog >
49+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import renameImage from "@images/icons8-rename-50.png?url";
1313import { useNavigate , useParams } from "react-router" ;
1414import BreadCrumbs from "Frontend/components/BreadCrumbs" ;
1515import { formatDate } from "Frontend/util/dateFormat" ;
16+ import RenameFileDialog , { itemToRename , renameFileDialogOpenSignal } from "Frontend/components/RenameFileDialog" ;
1617
1718
1819export const config : ViewConfig = {
@@ -36,8 +37,14 @@ export default function FileBrowserView() {
3637 navigate ( "/browser/" + item . path ) ;
3738 } ;
3839
40+ const onRenameFileClick = ( item : FileItem ) => {
41+ renameFileDialogOpenSignal . value = true ;
42+ itemToRename . value = item ;
43+ } ;
44+
3945 return < >
4046 < BreadCrumbs path = { wildcardPath } />
47+ < RenameFileDialog />
4148
4249 < Grid items = { fileItems . value } >
4350 < GridSortColumn resizable path = "displayName" header = "Name" renderer = {
@@ -72,7 +79,7 @@ export default function FileBrowserView() {
7279 < img src = { downloadImage } width = "32" />
7380 </ Button >
7481 </ a >
75- < Button theme = "icon tertiary" >
82+ < Button theme = "icon tertiary" onClick = { ( ) => onRenameFileClick ( item ) } >
7683 < img src = { renameImage } width = "32" />
7784 </ Button >
7885 </ >
You can’t perform that action at this time.
0 commit comments