Skip to content

Commit d928f56

Browse files
fix toggle file tree close metadata
1 parent 9d4c9b8 commit d928f56

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

frontend/src/pages/lib-content-view/lib-content-view.js

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ class LibContentView extends React.Component {
547547
window.history.pushState({ url: url, path: '' }, '', url);
548548
};
549549

550-
hideFileMetadata = () => {
550+
hideMetadataView = () => {
551551
this.setState({
552552
currentMode: LIST_MODE,
553553
path: '',
@@ -1084,7 +1084,7 @@ class LibContentView extends React.Component {
10841084

10851085
onMainNavBarClick = (nodePath) => {
10861086
// just for dir
1087-
this.resetSelected();
1087+
this.resetSelected(nodePath);
10881088
if (this.state.isTreePanelShown) {
10891089
let tree = this.state.treeData.clone();
10901090
let node = tree.getNodeByPath(nodePath);
@@ -1485,7 +1485,7 @@ class LibContentView extends React.Component {
14851485
};
14861486

14871487
onItemClick = (dirent) => {
1488-
this.resetSelected();
1488+
this.resetSelected(dirent);
14891489
let repoID = this.props.repoID;
14901490
let direntPath = Utils.joinPath(this.state.path, dirent.name);
14911491
if (dirent.isDir()) { // is dir
@@ -1829,7 +1829,7 @@ class LibContentView extends React.Component {
18291829
};
18301830

18311831
onTreeNodeClick = (node) => {
1832-
this.resetSelected();
1832+
this.resetSelected(node);
18331833
let repoID = this.props.repoID;
18341834

18351835
if (!this.state.pathExist) {
@@ -2013,14 +2013,16 @@ class LibContentView extends React.Component {
20132013
return this.state.selectedDirentList.map(selectedDirent => selectedDirent.name);
20142014
};
20152015

2016-
resetSelected = () => {
2016+
resetSelected = (node) => {
20172017
this.setState({
20182018
isDirentSelected: false,
20192019
isAllDirentSelected: false,
20202020
});
20212021
if (this.state.currentMode === METADATA_MODE) {
2022+
const path = node.path || '';
2023+
const isMetadataView = path.startsWith('/' + PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES);
20222024
this.setState({
2023-
currentMode: cookie.load('seafile_view_mode') || LIST_MODE,
2025+
currentMode: cookie.load('seafile_view_mode') || (isMetadataView ? METADATA_MODE : LIST_MODE),
20242026
});
20252027
this.markdownFileName = '';
20262028
this.markdownFileParentDir = '';
@@ -2179,12 +2181,17 @@ class LibContentView extends React.Component {
21792181
};
21802182

21812183
render() {
2182-
let { currentRepoInfo, userPerm, isCopyMoveProgressDialogShow, isDeleteFolderDialogOpen,
2183-
path, usedRepoTags } = this.state;
2184+
const { repoID } = this.props;
2185+
let { currentRepoInfo, userPerm, isCopyMoveProgressDialogShow, isDeleteFolderDialogOpen, errorMsg,
2186+
path, usedRepoTags, isDirentSelected } = this.state;
2187+
21842188
if (this.state.libNeedDecrypt) {
21852189
return (
21862190
<ModalPortal>
2187-
<LibDecryptDialog repoID={this.props.repoID} onLibDecryptDialog={this.onLibDecryptDialog} />
2191+
<LibDecryptDialog
2192+
repoID={repoID}
2193+
onLibDecryptDialog={this.onLibDecryptDialog}
2194+
/>
21882195
</ModalPortal>
21892196
);
21902197
}
@@ -2198,15 +2205,15 @@ class LibContentView extends React.Component {
21982205
</ModalPortal>
21992206
);
22002207
}
2201-
if (this.state.errorMsg) {
2208+
if (errorMsg) {
22022209
return (
22032210
<>
2204-
<p className="error mt-6 text-center">{this.state.errorMsg}</p>
2211+
<p className="error mt-6 text-center">{errorMsg}</p>
22052212
<button type="submit" className="btn btn-primary submit" onClick={this.handleSubmit}>{gettext('Leave Share')}</button>
22062213
</>
22072214
);
22082215
}
2209-
if (!this.state.currentRepoInfo) {
2216+
if (!currentRepoInfo) {
22102217
return '';
22112218
}
22122219

@@ -2239,12 +2246,12 @@ class LibContentView extends React.Component {
22392246

22402247
return (
22412248
<MetadataProvider
2242-
repoID={this.props.repoID}
2249+
repoID={repoID}
22432250
currentRepoInfo={currentRepoInfo}
22442251
selectMetadataView={this.onTreeNodeClick}
2245-
hideMetadataView={this.hideFileMetadata}
2252+
hideMetadataView={this.hideMetadataView}
22462253
>
2247-
<CollaboratorsProvider repoID={this.props.repoID}>
2254+
<CollaboratorsProvider repoID={repoID}>
22482255
<div className="main-panel-center flex-row">
22492256
<div className="cur-view-container">
22502257
{this.state.currentRepoInfo.status === 'read-only' &&
@@ -2256,9 +2263,9 @@ class LibContentView extends React.Component {
22562263
<div className={classnames(
22572264
'cur-view-path-left', {
22582265
'w-100': !isDesktop,
2259-
'animation-children': this.state.isDirentSelected
2266+
'animation-children': isDirentSelected
22602267
})}>
2261-
{this.state.isDirentSelected ?
2268+
{isDirentSelected ?
22622269
<SelectedDirentsToolbar
22632270
repoID={this.props.repoID}
22642271
path={this.state.path}

0 commit comments

Comments
 (0)