mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 13:24:52 +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:
@@ -22,7 +22,7 @@ export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, chi
|
||||
const [detailsSettings, setDetailsSettings] = useState({});
|
||||
const [isBeingBuilt, setIsBeingBuilt] = useState(false);
|
||||
|
||||
const cancelMetadataURL = useCallback(() => {
|
||||
const cancelMetadataURL = useCallback((isSetRoot = false) => {
|
||||
// If attribute extension is turned off, unmark the URL
|
||||
const { origin, pathname, search } = window.location;
|
||||
const urlParams = new URLSearchParams(search);
|
||||
@@ -31,7 +31,8 @@ export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, chi
|
||||
const url = `${origin}${pathname}`;
|
||||
window.history.pushState({ url: url, path: '' }, '', url);
|
||||
}
|
||||
}, []);
|
||||
hideMetadataView && hideMetadataView(Boolean(param) || isSetRoot);
|
||||
}, [hideMetadataView]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!enableMetadataManagement) {
|
||||
@@ -68,7 +69,7 @@ export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, chi
|
||||
const updateEnableMetadata = useCallback((newValue) => {
|
||||
if (newValue === enableMetadata) return;
|
||||
if (!newValue) {
|
||||
cancelMetadataURL();
|
||||
cancelMetadataURL(true);
|
||||
setEnableTags(false);
|
||||
}
|
||||
setDetailsSettings({});
|
||||
@@ -79,12 +80,11 @@ export const MetadataStatusProvider = ({ repoID, repoInfo, hideMetadataView, chi
|
||||
const updateEnableTags = useCallback((newValue, lang = 'en') => {
|
||||
if (newValue === enableTags && lang === tagsLang) return;
|
||||
if (!newValue) {
|
||||
cancelMetadataURL();
|
||||
hideMetadataView && hideMetadataView();
|
||||
cancelMetadataURL(true);
|
||||
}
|
||||
setEnableTags(newValue);
|
||||
setTagsLang(lang);
|
||||
}, [enableTags, tagsLang, cancelMetadataURL, hideMetadataView]);
|
||||
}, [enableTags, tagsLang, cancelMetadataURL]);
|
||||
|
||||
const updateEnableOCR = useCallback((newValue) => {
|
||||
if (newValue === enableOCR) return;
|
||||
|
@@ -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.
|
||||
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 [enableFaceRecognition, setEnableFaceRecognition] = useState(false);
|
||||
const [navigation, setNavigation] = useState([]);
|
||||
@@ -70,7 +70,6 @@ export const MetadataProvider = ({ repoID, currentPath, repoInfo, hideMetadataVi
|
||||
});
|
||||
return;
|
||||
}
|
||||
hideMetadataView && hideMetadataView();
|
||||
setEnableFaceRecognition(false);
|
||||
setNavigation([]);
|
||||
setIdViewMap({});
|
||||
|
@@ -523,13 +523,16 @@ class LibContentView extends React.Component {
|
||||
window.history.pushState({ url: url, path: '' }, '', url);
|
||||
};
|
||||
|
||||
hideMetadataView = () => {
|
||||
hideMetadataView = (isSetRoot = false) => {
|
||||
const { repoID } = this.props;
|
||||
this.setState({
|
||||
currentMode: LIST_MODE,
|
||||
path: '',
|
||||
currentMode: cookie.load('seafile_view_mode') || LIST_MODE,
|
||||
path: isSetRoot ? '/' : this.getPathFromLocation(repoID),
|
||||
viewId: '',
|
||||
isDirentDetailShow: false
|
||||
tagId: '',
|
||||
currentDirent: isSetRoot ? null : this.state.currentDirent,
|
||||
}, () => {
|
||||
if (!isSetRoot) return;
|
||||
this.showDir('/');
|
||||
});
|
||||
};
|
||||
@@ -2216,7 +2219,7 @@ class LibContentView extends React.Component {
|
||||
return (
|
||||
<MetadataStatusProvider repoID={repoID} repoInfo={currentRepoInfo} hideMetadataView={this.hideMetadataView}>
|
||||
<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}>
|
||||
<div className="main-panel-center flex-row">
|
||||
<div className="cur-view-container">
|
||||
|
Reference in New Issue
Block a user