2024-08-06 17:30:11 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2024-08-02 22:31:46 +08:00
|
|
|
import LibDetail from './lib-details';
|
|
|
|
import DirentDetail from './dirent-details';
|
2024-08-06 17:30:11 +08:00
|
|
|
import ObjectUtils from '../../metadata/metadata-view/utils/object-utils';
|
2024-08-02 22:31:46 +08:00
|
|
|
|
2024-08-06 17:30:11 +08:00
|
|
|
const Index = React.memo(({ repoID, path, dirent, currentRepoInfo, repoTags, fileTags, onClose, onFileTagChanged }) => {
|
|
|
|
|
|
|
|
if (path === '/' && !dirent) {
|
|
|
|
return (
|
|
|
|
<LibDetail currentRepoInfo={currentRepoInfo} onClose={onClose} />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<DirentDetail
|
|
|
|
repoID={repoID}
|
|
|
|
path={path}
|
|
|
|
dirent={dirent}
|
|
|
|
currentRepoInfo={currentRepoInfo}
|
|
|
|
repoTags={repoTags}
|
|
|
|
fileTags={fileTags}
|
|
|
|
onFileTagChanged={onFileTagChanged}
|
|
|
|
onClose={onClose}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}, (props, nextProps) => {
|
|
|
|
const isChanged = props.repoID !== nextProps.repoID ||
|
|
|
|
props.path !== nextProps.path ||
|
|
|
|
!ObjectUtils.isSameObject(props.dirent, nextProps.dirent) ||
|
|
|
|
!ObjectUtils.isSameObject(props.currentRepoInfo, nextProps.currentRepoInfo) ||
|
|
|
|
JSON.stringify(props.repoTags || []) !== JSON.stringify(nextProps.repoTags || []) ||
|
|
|
|
JSON.stringify(props.fileTags || []) !== JSON.stringify(nextProps.fileTags || []);
|
|
|
|
return !isChanged;
|
|
|
|
});
|
|
|
|
|
|
|
|
Index.propTypes = {
|
|
|
|
repoID: PropTypes.string,
|
|
|
|
path: PropTypes.string,
|
|
|
|
dirent: PropTypes.object,
|
|
|
|
currentRepoInfo: PropTypes.object,
|
|
|
|
repoTags: PropTypes.array,
|
|
|
|
fileTags: PropTypes.array,
|
|
|
|
onClose: PropTypes.func,
|
|
|
|
onFileTagChanged: PropTypes.func,
|
2024-08-02 22:31:46 +08:00
|
|
|
};
|
2024-08-06 17:30:11 +08:00
|
|
|
|
|
|
|
export default Index;
|