1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 08:53:14 +00:00

fix toggle file tree close metadata (#7012)

This commit is contained in:
Michael An
2024-11-09 10:36:08 +08:00
committed by GitHub
parent e23860c651
commit dce23db5ca

View File

@@ -547,7 +547,7 @@ class LibContentView extends React.Component {
window.history.pushState({ url: url, path: '' }, '', url); window.history.pushState({ url: url, path: '' }, '', url);
}; };
hideFileMetadata = () => { hideMetadataView = () => {
this.setState({ this.setState({
currentMode: LIST_MODE, currentMode: LIST_MODE,
path: '', path: '',
@@ -1084,7 +1084,7 @@ class LibContentView extends React.Component {
onMainNavBarClick = (nodePath) => { onMainNavBarClick = (nodePath) => {
// just for dir // just for dir
this.resetSelected(); this.resetSelected(nodePath);
if (this.state.isTreePanelShown) { if (this.state.isTreePanelShown) {
let tree = this.state.treeData.clone(); let tree = this.state.treeData.clone();
let node = tree.getNodeByPath(nodePath); let node = tree.getNodeByPath(nodePath);
@@ -1485,7 +1485,7 @@ class LibContentView extends React.Component {
}; };
onItemClick = (dirent) => { onItemClick = (dirent) => {
this.resetSelected(); this.resetSelected(dirent);
let repoID = this.props.repoID; let repoID = this.props.repoID;
let direntPath = Utils.joinPath(this.state.path, dirent.name); let direntPath = Utils.joinPath(this.state.path, dirent.name);
if (dirent.isDir()) { // is dir if (dirent.isDir()) { // is dir
@@ -1829,7 +1829,7 @@ class LibContentView extends React.Component {
}; };
onTreeNodeClick = (node) => { onTreeNodeClick = (node) => {
this.resetSelected(); this.resetSelected(node);
let repoID = this.props.repoID; let repoID = this.props.repoID;
if (!this.state.pathExist) { if (!this.state.pathExist) {
@@ -2013,14 +2013,16 @@ class LibContentView extends React.Component {
return this.state.selectedDirentList.map(selectedDirent => selectedDirent.name); return this.state.selectedDirentList.map(selectedDirent => selectedDirent.name);
}; };
resetSelected = () => { resetSelected = (node) => {
this.setState({ this.setState({
isDirentSelected: false, isDirentSelected: false,
isAllDirentSelected: false, isAllDirentSelected: false,
}); });
if (this.state.currentMode === METADATA_MODE) { if (this.state.currentMode === METADATA_MODE) {
const path = node.path || '';
const isMetadataView = path.startsWith('/' + PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES);
this.setState({ this.setState({
currentMode: cookie.load('seafile_view_mode') || LIST_MODE, currentMode: cookie.load('seafile_view_mode') || (isMetadataView ? METADATA_MODE : LIST_MODE),
}); });
this.markdownFileName = ''; this.markdownFileName = '';
this.markdownFileParentDir = ''; this.markdownFileParentDir = '';
@@ -2179,12 +2181,17 @@ class LibContentView extends React.Component {
}; };
render() { render() {
let { currentRepoInfo, userPerm, isCopyMoveProgressDialogShow, isDeleteFolderDialogOpen, const { repoID } = this.props;
path, usedRepoTags } = this.state; let { currentRepoInfo, userPerm, isCopyMoveProgressDialogShow, isDeleteFolderDialogOpen, errorMsg,
path, usedRepoTags, isDirentSelected } = this.state;
if (this.state.libNeedDecrypt) { if (this.state.libNeedDecrypt) {
return ( return (
<ModalPortal> <ModalPortal>
<LibDecryptDialog repoID={this.props.repoID} onLibDecryptDialog={this.onLibDecryptDialog} /> <LibDecryptDialog
repoID={repoID}
onLibDecryptDialog={this.onLibDecryptDialog}
/>
</ModalPortal> </ModalPortal>
); );
} }
@@ -2198,15 +2205,15 @@ class LibContentView extends React.Component {
</ModalPortal> </ModalPortal>
); );
} }
if (this.state.errorMsg) { if (errorMsg) {
return ( return (
<> <>
<p className="error mt-6 text-center">{this.state.errorMsg}</p> <p className="error mt-6 text-center">{errorMsg}</p>
<button type="submit" className="btn btn-primary submit" onClick={this.handleSubmit}>{gettext('Leave Share')}</button> <button type="submit" className="btn btn-primary submit" onClick={this.handleSubmit}>{gettext('Leave Share')}</button>
</> </>
); );
} }
if (!this.state.currentRepoInfo) { if (!currentRepoInfo) {
return ''; return '';
} }
@@ -2239,12 +2246,12 @@ class LibContentView extends React.Component {
return ( return (
<MetadataProvider <MetadataProvider
repoID={this.props.repoID} repoID={repoID}
currentRepoInfo={currentRepoInfo} currentRepoInfo={currentRepoInfo}
selectMetadataView={this.onTreeNodeClick} selectMetadataView={this.onTreeNodeClick}
hideMetadataView={this.hideFileMetadata} hideMetadataView={this.hideMetadataView}
> >
<CollaboratorsProvider repoID={this.props.repoID}> <CollaboratorsProvider repoID={repoID}>
<div className="main-panel-center flex-row"> <div className="main-panel-center flex-row">
<div className="cur-view-container"> <div className="cur-view-container">
{this.state.currentRepoInfo.status === 'read-only' && {this.state.currentRepoInfo.status === 'read-only' &&
@@ -2256,9 +2263,9 @@ class LibContentView extends React.Component {
<div className={classnames( <div className={classnames(
'cur-view-path-left', { 'cur-view-path-left', {
'w-100': !isDesktop, 'w-100': !isDesktop,
'animation-children': this.state.isDirentSelected 'animation-children': isDirentSelected
})}> })}>
{this.state.isDirentSelected ? {isDirentSelected ?
<SelectedDirentsToolbar <SelectedDirentsToolbar
repoID={this.props.repoID} repoID={this.props.repoID}
path={this.state.path} path={this.state.path}