File tree 2 files changed +14
-3
lines changed
site/src/components/TemplateVersionEditor
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { Stack } from "components/Stack/Stack"
4
4
import { ChangeEvent , FC , useState } from "react"
5
5
import Typography from "@material-ui/core/Typography"
6
6
import { allowedExtensions , isAllowedFile } from "util/templateVersion"
7
- import { FileTree , validatePath } from "util/filetree"
7
+ import { FileTree , isFolder , validatePath } from "util/filetree"
8
8
9
9
export const CreateFileDialog : FC < {
10
10
onClose : ( ) => void
@@ -142,6 +142,12 @@ export const RenameFileDialog: FC<{
142
142
)
143
143
return
144
144
}
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
+ }
145
151
const pathError = validatePath ( pathValue , fileTree )
146
152
if ( pathError ) {
147
153
setError ( pathError )
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import TreeView from "@material-ui/lab/TreeView"
5
5
import TreeItem from "@material-ui/lab/TreeItem"
6
6
import Menu from "@material-ui/core/Menu"
7
7
import MenuItem from "@material-ui/core/MenuItem"
8
- import { FC , useState } from "react"
8
+ import { CSSProperties , FC , useState } from "react"
9
9
import { FileTree } from "util/filetree"
10
10
import { DockerIcon } from "components/Icons/DockerIcon"
11
11
import { colors } from "theme/colors"
@@ -80,6 +80,11 @@ export const FileTreeView: FC<{
80
80
)
81
81
} }
82
82
icon = { icon }
83
+ style = {
84
+ {
85
+ "--level" : parentPath ? parentPath . split ( "/" ) . length : 0 ,
86
+ } as CSSProperties
87
+ }
83
88
>
84
89
{ typeof content === "object" ? (
85
90
Object . keys ( content )
@@ -200,7 +205,7 @@ const useStyles = makeStyles((theme) => ({
200
205
201
206
// We need to find a better way to recursive padding here
202
207
"& .MuiTreeItem-content" : {
203
- paddingLeft : theme . spacing ( 5 ) ,
208
+ paddingLeft : `calc(var(--level) * ${ theme . spacing ( 5 ) } px)` ,
204
209
} ,
205
210
} ,
206
211
} ,
You can’t perform that action at this time.
0 commit comments