Skip to content

Commit

Permalink
path selector添加当前目录选项,修复上层目录 (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
WeidiDeng authored Jan 9, 2023
1 parent a205cb4 commit 95ff68b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
1 change: 1 addition & 0 deletions public/locales/en-US/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"name": "Name",
"size": "Size",
"lastModified": "Last modified",
"currentFolder": "Current Folder",
"backToParentFolder": "Back to the parent",
"folders": "Folders",
"files": "Files",
Expand Down
1 change: 1 addition & 0 deletions public/locales/zh-CN/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"name": "名称",
"size": "大小",
"lastModified": "修改日期",
"currentFolder": "当前目录",
"backToParentFolder": "上级目录",
"folders": "文件夹",
"files": "文件",
Expand Down
48 changes: 34 additions & 14 deletions src/component/FileManager/PathSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,20 @@ class PathSelectorCompoment extends Component {
} else {
let path = toBeLoad;
let name = toBeLoad;
const paths = path.split("/");
name = paths.pop();
name = name === "" ? "/" : name;
path = paths.join("/");
dirList.unshift({
name: name,
path: path,
displayName: this.props.t(
"fileManager.backToParentFolder"
),
});
const displayNames = ["fileManager.currentFolder", "fileManager.backToParentFolder"];
for (let i = 0; i < 2; i++) {
const paths = path.split("/");
name = paths.pop();
name = name === "" ? "/" : name;
path = paths.join("/");
dirList.unshift({
name: name,
path: path,
displayName: this.props.t(
displayNames[i]
),
});
}
}
this.setState({
presentPath: toBeLoad,
Expand All @@ -134,6 +137,24 @@ class PathSelectorCompoment extends Component {
render() {
const { classes, t } = this.props;

const showActionIcon = (index) => {
if (this.state.presentPath === "/") {
return index !== 0;
}
return index !== 1;
};

const actionIcon = (index) => {
if (this.state.presentPath === "/") {
return <RightIcon />;
}

if (index === 0) {
return <UpIcon />;
}
return <RightIcon />;
};

return (
<div className={classes.container}>
<MenuList className={classes.selector}>
Expand All @@ -156,7 +177,7 @@ class PathSelectorCompoment extends Component {
style: { whiteSpace: "normal" },
}}
/>
{(index !== 0 || value.name !== "/") && (
{showActionIcon(index) && (
<ListItemSecondaryAction
className={classes.buttonIcon}
>
Expand All @@ -179,8 +200,7 @@ class PathSelectorCompoment extends Component {
)
}
>
{index === 0 && <UpIcon />}
{index !== 0 && <RightIcon />}
{actionIcon(index)}
</IconButton>
</ListItemSecondaryAction>
)}
Expand Down

0 comments on commit 95ff68b

Please sign in to comment.