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

Commitcb664c2

Browse files
BrunoQuaresmapull[bot]
authored andcommitted
fix(site): fix template editor filetree navigation (#11260)
Close#11203
1 parent39bf010 commitcb664c2

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

‎site/src/pages/TemplateVersionEditorPage/FileTreeView.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { type CSSProperties, type FC, useState } from "react";
88
import{css}from"@emotion/react";
99
import{FileTree}from"utils/filetree";
1010
import{DockerIcon}from"components/Icons/DockerIcon";
11+
importFormatAlignLeftOutlinedfrom"@mui/icons-material/FormatAlignLeftOutlined";
1112

1213
constsortFileTree=(fileTree:FileTree)=>(a:string,b:string)=>{
1314
constcontentA=fileTree[a];
@@ -43,14 +44,17 @@ export const FileTreeView: FC<FileTreeViewProps> = ({
4344
onSelect,
4445
})=>{
4546
const[contextMenu,setContextMenu]=useState<ContextMenu|undefined>();
46-
4747
constbuildTreeItems=(
4848
filename:string,
4949
content?:FileTree|string,
5050
parentPath?:string,
5151
):JSX.Element=>{
5252
constcurrentPath=parentPath ?`${parentPath}/${filename}` :filename;
53-
leticon:JSX.Element|null=null;
53+
constisFolder=typeofcontent==="object";
54+
leticon:JSX.Element|null=isFolder ?null :(
55+
<FormatAlignLeftOutlined/>
56+
);
57+
5458
if(filename.endsWith(".tf")){
5559
icon=<FileTypeTerraform/>;
5660
}
@@ -69,39 +73,31 @@ export const FileTreeView: FC<FileTreeViewProps> = ({
6973
css={(theme)=>css`
7074
overflow: hidden;
7175
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-
}
8376
8477
&> .MuiTreeItem-content {
8578
padding:2px16px;
8679
color:${theme.palette.text.secondary};
80+
height:32px;
8781
8882
&svg {
89-
width:16px;
90-
height:16px;
83+
width:12px;
84+
height:12px;
85+
color:${theme.palette.text.secondary};
9186
}
9287
9388
&> .MuiTreeItem-label {
9489
margin-left:4px;
9590
font-size:13px;
9691
color: inherit;
9792
}
98-
}
9993
100-
&.active {
101-
&> .MuiTreeItem-content {
94+
&.Mui-selected {
10295
color:${theme.palette.text.primary};
10396
background:${theme.colors.gray[14]};
104-
pointer-events: none;
97+
}
98+
99+
&.Mui-focused {
100+
box-shadow: inset0001px${theme.palette.primary.main};
105101
}
106102
}
107103
@@ -114,7 +110,6 @@ export const FileTreeView: FC<FileTreeViewProps> = ({
114110
}
115111
}
116112
`}
117-
className={currentPath===activePath ?"active" :""}
118113
onClick={()=>{
119114
onSelect(currentPath);
120115
}}
@@ -138,7 +133,7 @@ export const FileTreeView: FC<FileTreeViewProps> = ({
138133
}asCSSProperties
139134
}
140135
>
141-
{typeofcontent==="object" ?(
136+
{isFolder ?(
142137
Object.keys(content)
143138
.sort(sortFileTree(content))
144139
.map((filename)=>{
@@ -157,6 +152,7 @@ export const FileTreeView: FC<FileTreeViewProps> = ({
157152
defaultCollapseIcon={<ExpandMoreIcon/>}
158153
defaultExpandIcon={<ChevronRightIcon/>}
159154
aria-label="Files"
155+
defaultSelected={activePath}
160156
>
161157
{Object.keys(fileTree)
162158
.sort(sortFileTree(fileTree))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp