1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-09 02:42:47 +00:00

fix: metadata set root (#7293)

* fix: metadata set root

* feat: update code

* feat: optimize code

* feat: optimize code

---------

Co-authored-by: 杨国璇 <ygx@Hello-word.local>
This commit is contained in:
杨国璇
2025-01-02 16:04:46 +08:00
committed by GitHub
parent e34b0768ba
commit d263e1018f
3 changed files with 15 additions and 13 deletions

View File

@@ -22,7 +22,7 @@ export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, chi
const [detailsSettings, setDetailsSettings] = useState({}); const [detailsSettings, setDetailsSettings] = useState({});
const [isBeingBuilt, setIsBeingBuilt] = useState(false); const [isBeingBuilt, setIsBeingBuilt] = useState(false);
const cancelMetadataURL = useCallback(() => { const cancelMetadataURL = useCallback((isSetRoot = false) => {
// If attribute extension is turned off, unmark the URL // If attribute extension is turned off, unmark the URL
const { origin, pathname, search } = window.location; const { origin, pathname, search } = window.location;
const urlParams = new URLSearchParams(search); const urlParams = new URLSearchParams(search);
@@ -31,7 +31,8 @@ export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, chi
const url = `${origin}${pathname}`; const url = `${origin}${pathname}`;
window.history.pushState({ url: url, path: '' }, '', url); window.history.pushState({ url: url, path: '' }, '', url);
} }
}, []); hideMetadataView && hideMetadataView(Boolean(param) || isSetRoot);
}, [hideMetadataView]);
useEffect(() => { useEffect(() => {
if (!enableMetadataManagement) { if (!enableMetadataManagement) {
@@ -68,7 +69,7 @@ export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, chi
const updateEnableMetadata = useCallback((newValue) => { const updateEnableMetadata = useCallback((newValue) => {
if (newValue === enableMetadata) return; if (newValue === enableMetadata) return;
if (!newValue) { if (!newValue) {
cancelMetadataURL(); cancelMetadataURL(true);
setEnableTags(false); setEnableTags(false);
} }
setDetailsSettings({}); setDetailsSettings({});
@@ -79,12 +80,11 @@ export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, chi
const updateEnableTags = useCallback((newValue, lang = 'en') => { const updateEnableTags = useCallback((newValue, lang = 'en') => {
if (newValue === enableTags && lang === tagsLang) return; if (newValue === enableTags && lang === tagsLang) return;
if (!newValue) { if (!newValue) {
cancelMetadataURL(); cancelMetadataURL(true);
hideMetadataView && hideMetadataView();
} }
setEnableTags(newValue); setEnableTags(newValue);
setTagsLang(lang); setTagsLang(lang);
}, [enableTags, tagsLang, cancelMetadataURL, hideMetadataView]); }, [enableTags, tagsLang, cancelMetadataURL]);
const updateEnableOCR = useCallback((newValue) => { const updateEnableOCR = useCallback((newValue) => {
if (newValue === enableOCR) return; if (newValue === enableOCR) return;

View File

@@ -15,7 +15,7 @@ const CACHED_COLLAPSED_FOLDERS_PREFIX = 'sf-metadata-collapsed-folders';
// This hook provides content related to seahub interaction, such as whether to enable extended attributes, views data, etc. // This hook provides content related to seahub interaction, such as whether to enable extended attributes, views data, etc.
const MetadataContext = React.createContext(null); const MetadataContext = React.createContext(null);
export const MetadataProvider = ({ repoID, currentPath, repoInfo, hideMetadataView, selectMetadataView, children }) => { export const MetadataProvider = ({ repoID, currentPath, repoInfo, selectMetadataView, children }) => {
const [isLoading, setLoading] = useState(true); const [isLoading, setLoading] = useState(true);
const [enableFaceRecognition, setEnableFaceRecognition] = useState(false); const [enableFaceRecognition, setEnableFaceRecognition] = useState(false);
const [navigation, setNavigation] = useState([]); const [navigation, setNavigation] = useState([]);
@@ -70,7 +70,6 @@ export const MetadataProvider = ({ repoID, currentPath, repoInfo, hideMetadataVi
}); });
return; return;
} }
hideMetadataView && hideMetadataView();
setEnableFaceRecognition(false); setEnableFaceRecognition(false);
setNavigation([]); setNavigation([]);
setIdViewMap({}); setIdViewMap({});

View File

@@ -523,13 +523,16 @@ class LibContentView extends React.Component {
window.history.pushState({ url: url, path: '' }, '', url); window.history.pushState({ url: url, path: '' }, '', url);
}; };
hideMetadataView = () => { hideMetadataView = (isSetRoot = false) => {
const { repoID } = this.props;
this.setState({ this.setState({
currentMode: LIST_MODE, currentMode: cookie.load('seafile_view_mode') || LIST_MODE,
path: '', path: isSetRoot ? '/' : this.getPathFromLocation(repoID),
viewId: '', viewId: '',
isDirentDetailShow: false tagId: '',
currentDirent: isSetRoot ? null : this.state.currentDirent,
}, () => { }, () => {
if (!isSetRoot) return;
this.showDir('/'); this.showDir('/');
}); });
}; };
@@ -2216,7 +2219,7 @@ class LibContentView extends React.Component {
return ( return (
<MetadataStatusProvider repoID={repoID} repoInfo={currentRepoInfo} hideMetadataView={this.hideMetadataView}> <MetadataStatusProvider repoID={repoID} repoInfo={currentRepoInfo} hideMetadataView={this.hideMetadataView}>
<TagsProvider repoID={repoID} currentPath={path} repoInfo={currentRepoInfo} selectTagsView={this.onTreeNodeClick}> <TagsProvider repoID={repoID} currentPath={path} repoInfo={currentRepoInfo} selectTagsView={this.onTreeNodeClick}>
<MetadataProvider repoID={repoID} currentPath={path} repoInfo={currentRepoInfo} selectMetadataView={this.onTreeNodeClick} hideMetadataView={this.hideMetadataView} > <MetadataProvider repoID={repoID} currentPath={path} repoInfo={currentRepoInfo} selectMetadataView={this.onTreeNodeClick} >
<CollaboratorsProvider repoID={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">