mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-17 15:53:28 +00:00
optimize code
This commit is contained in:
@@ -42,9 +42,13 @@ class HeaderToolbar extends React.Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
const { repoID, filePath } = window.app.pageOptions;
|
||||||
|
const dirPath = filePath.substring(0, filePath.lastIndexOf('/') || 0) || '/';
|
||||||
this.state = {
|
this.state = {
|
||||||
|
repoID: repoID,
|
||||||
|
filePath: filePath,
|
||||||
|
dirPath: dirPath,
|
||||||
currentDirent: null,
|
currentDirent: null,
|
||||||
dirPath: '/',
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,8 +76,8 @@ class HeaderToolbar extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getDirentList = () => {
|
getDirentList = () => {
|
||||||
const { repoID, filePath } = window.app.pageOptions;
|
const { repoID, filePath, dirPath } = this.state;
|
||||||
return seafileAPI.listDir(repoID, this.dirPath, { 'with_thumbnail': true }).then(res => {
|
return seafileAPI.listDir(repoID, dirPath, { 'with_thumbnail': true }).then(res => {
|
||||||
res.data.dirent_list.forEach(item => {
|
res.data.dirent_list.forEach(item => {
|
||||||
const dirent = new Dirent(item);
|
const dirent = new Dirent(item);
|
||||||
if (Utils.joinPath(item.parent_dir, item.name) === filePath) {
|
if (Utils.joinPath(item.parent_dir, item.name) === filePath) {
|
||||||
@@ -86,8 +90,7 @@ class HeaderToolbar extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onArticleInfoDetailToggle = () => {
|
onArticleInfoDetailToggle = () => {
|
||||||
const { repoID, filePath } = window.app.pageOptions;
|
const { repoID, filePath, currentDirent } = this.state;
|
||||||
const { currentDirent } = this.state;
|
|
||||||
const repoInfo = { permission: 'rw' };
|
const repoInfo = { permission: 'rw' };
|
||||||
|
|
||||||
const eventBus = EventBus.getInstance();
|
const eventBus = EventBus.getInstance();
|
||||||
@@ -151,7 +154,7 @@ class HeaderToolbar extends React.Component {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<ButtonItem
|
<ButtonItem
|
||||||
id='info'
|
id='file-info'
|
||||||
text={gettext('Info')}
|
text={gettext('Info')}
|
||||||
icon='info'
|
icon='info'
|
||||||
onMouseDown={() => {
|
onMouseDown={() => {
|
||||||
|
Reference in New Issue
Block a user