Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa2468b

Browse files
fix(site): Handle rename a folder to a file (#7063)
1 parente5c6ebd commitaa2468b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

‎site/src/components/TemplateVersionEditor/FileDialog.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Stack } from "components/Stack/Stack"
44
import{ChangeEvent,FC,useState}from"react"
55
importTypographyfrom"@material-ui/core/Typography"
66
import{allowedExtensions,isAllowedFile}from"util/templateVersion"
7-
import{FileTree,validatePath}from"util/filetree"
7+
import{FileTree,isFolder,validatePath}from"util/filetree"
88

99
exportconstCreateFileDialog:FC<{
1010
onClose:()=>void
@@ -142,6 +142,12 @@ export const RenameFileDialog: FC<{
142142
)
143143
return
144144
}
145+
//Check if a folder is renamed to a file
146+
const[_,extension]=pathValue.split(".")
147+
if(isFolder(filename,fileTree)&&extension){
148+
setError(`A folder can't be renamed to a file.`)
149+
return
150+
}
145151
constpathError=validatePath(pathValue,fileTree)
146152
if(pathError){
147153
setError(pathError)

‎site/src/components/TemplateVersionEditor/FileTreeView.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import TreeView from "@material-ui/lab/TreeView"
55
importTreeItemfrom"@material-ui/lab/TreeItem"
66
importMenufrom"@material-ui/core/Menu"
77
importMenuItemfrom"@material-ui/core/MenuItem"
8-
import{FC,useState}from"react"
8+
import{CSSProperties,FC,useState}from"react"
99
import{FileTree}from"util/filetree"
1010
import{DockerIcon}from"components/Icons/DockerIcon"
1111
import{colors}from"theme/colors"
@@ -80,6 +80,11 @@ export const FileTreeView: FC<{
8080
)
8181
}}
8282
icon={icon}
83+
style={
84+
{
85+
"--level":parentPath ?parentPath.split("/").length :0,
86+
}asCSSProperties
87+
}
8388
>
8489
{typeofcontent==="object" ?(
8590
Object.keys(content)
@@ -200,7 +205,7 @@ const useStyles = makeStyles((theme) => ({
200205

201206
// We need to find a better way to recursive padding here
202207
"& .MuiTreeItem-content":{
203-
paddingLeft:theme.spacing(5),
208+
paddingLeft:`calc(var(--level) *${theme.spacing(5)}px)`,
204209
},
205210
},
206211
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp