@@ -8,6 +8,7 @@ import { type CSSProperties, type FC, useState } from "react";
8
8
import { css } from "@emotion/react" ;
9
9
import { FileTree } from "utils/filetree" ;
10
10
import { DockerIcon } from "components/Icons/DockerIcon" ;
11
+ import FormatAlignLeftOutlined from "@mui/icons-material/FormatAlignLeftOutlined" ;
11
12
12
13
const sortFileTree = ( fileTree : FileTree ) => ( a : string , b : string ) => {
13
14
const contentA = fileTree [ a ] ;
@@ -43,14 +44,17 @@ export const FileTreeView: FC<FileTreeViewProps> = ({
43
44
onSelect,
44
45
} ) => {
45
46
const [ contextMenu , setContextMenu ] = useState < ContextMenu | undefined > ( ) ;
46
-
47
47
const buildTreeItems = (
48
48
filename : string ,
49
49
content ?: FileTree | string ,
50
50
parentPath ?: string ,
51
51
) : JSX . Element => {
52
52
const currentPath = parentPath ? `${ parentPath } /${ filename } ` : filename ;
53
- let icon : JSX . Element | null = null ;
53
+ const isFolder = typeof content === "object" ;
54
+ let icon : JSX . Element | null = isFolder ? null : (
55
+ < FormatAlignLeftOutlined />
56
+ ) ;
57
+
54
58
if ( filename . endsWith ( ".tf" ) ) {
55
59
icon = < FileTypeTerraform /> ;
56
60
}
@@ -69,39 +73,31 @@ export const FileTreeView: FC<FileTreeViewProps> = ({
69
73
css = { ( theme ) => css `
70
74
overflow : hidden;
71
75
user-select : none;
72
- height : 32px ;
73
-
74
- & : focus : not (.active ) > .MuiTreeItem-content {
75
- background : ${ theme . palette . action . hover } ;
76
- color : ${ theme . palette . text . primary } ;
77
- }
78
-
79
- & : not (: focus ): not (.active ) > .MuiTreeItem-content : hover {
80
- background : ${ theme . palette . action . hover } ;
81
- color : ${ theme . palette . text . primary } ;
82
- }
83
76
84
77
& > .MuiTreeItem-content {
85
78
padding : 2px 16px ;
86
79
color : ${ theme . palette . text . secondary } ;
80
+ height : 32px ;
87
81
88
82
& svg {
89
- width : 16px ;
90
- height : 16px ;
83
+ width : 12px ;
84
+ height : 12px ;
85
+ color : ${ theme . palette . text . secondary } ;
91
86
}
92
87
93
88
& > .MuiTreeItem-label {
94
89
margin-left : 4px ;
95
90
font-size : 13px ;
96
91
color : inherit;
97
92
}
98
- }
99
93
100
- & .active {
101
- & > .MuiTreeItem-content {
94
+ & .Mui-selected {
102
95
color : ${ theme . palette . text . primary } ;
103
96
background : ${ theme . colors . gray [ 14 ] } ;
104
- pointer-events : none;
97
+ }
98
+
99
+ & .Mui-focused {
100
+ box-shadow : inset 0 0 0 1px ${ theme . palette . primary . main } ;
105
101
}
106
102
}
107
103
@@ -114,7 +110,6 @@ export const FileTreeView: FC<FileTreeViewProps> = ({
114
110
}
115
111
}
116
112
` }
117
- className = { currentPath === activePath ? "active" : "" }
118
113
onClick = { ( ) => {
119
114
onSelect ( currentPath ) ;
120
115
} }
@@ -138,7 +133,7 @@ export const FileTreeView: FC<FileTreeViewProps> = ({
138
133
} as CSSProperties
139
134
}
140
135
>
141
- { typeof content === "object" ? (
136
+ { isFolder ? (
142
137
Object . keys ( content )
143
138
. sort ( sortFileTree ( content ) )
144
139
. map ( ( filename ) => {
@@ -157,6 +152,7 @@ export const FileTreeView: FC<FileTreeViewProps> = ({
157
152
defaultCollapseIcon = { < ExpandMoreIcon /> }
158
153
defaultExpandIcon = { < ChevronRightIcon /> }
159
154
aria-label = "Files"
155
+ defaultSelected = { activePath }
160
156
>
161
157
{ Object . keys ( fileTree )
162
158
. sort ( sortFileTree ( fileTree ) )
0 commit comments