1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-12 13:24:52 +00:00

Revert "feat: sdoc metadata (#6682)" (#6684)

This reverts commit 9bda201094.
This commit is contained in:
杨顺强
2024-09-02 12:55:10 +08:00
committed by GitHub
parent 4715ce67d2
commit eea1a04585
20 changed files with 274 additions and 477 deletions

View File

@@ -1,72 +0,0 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { seafileAPI } from '../../../utils/seafile-api';
import { Utils } from '../../../utils/utils';
import toaster from '../../toast';
import { Header, Body } from '../detail';
import FileDetails from './file-details';
import { MetadataContext } from '../../../metadata';
import './index.css';
const EmbeddedFileDetails = ({ repoID, repoInfo, dirent, path, onClose, width, className }) => {
const [direntDetail, setDirentDetail] = useState('');
useEffect(() => {
// init context
const context = new MetadataContext();
window.sfMetadataContext = context;
window.sfMetadataContext.init({ repoID, repoInfo });
seafileAPI.getFileInfo(repoID, path).then(res => {
setDirentDetail(res.data);
}).catch(error => {
const errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
return () => {
window.sfMetadataContext.destroy();
delete window['sfMetadataContext'];
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const direntName = dirent?.name || '';
const smallIconUrl = Utils.getDirentIcon(dirent);
return (
<div
className={classnames('cur-view-detail', className, {
'cur-view-detail-small': width < 400,
'cur-view-detail-large': width > 400
})}
style={{ width }}
>
<Header title={direntName} icon={smallIconUrl} onClose={onClose} />
<Body>
{dirent && direntDetail && (
<div className="detail-content">
<FileDetails
repoID={repoID}
repoInfo={repoInfo}
path={path}
direntDetail={direntDetail}
/>
</div>
)}
</Body>
</div>
);
};
EmbeddedFileDetails.propTypes = {
repoID: PropTypes.string.isRequired,
dirent: PropTypes.object,
path: PropTypes.string.isRequired,
repoInfo: PropTypes.object.isRequired,
onClose: PropTypes.func.isRequired,
};
export default EmbeddedFileDetails;