2019-02-21 09:37:04 +00:00
|
|
|
import React, { Fragment } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { gettext } from '../../utils/constants';
|
|
|
|
import CurDirPath from '../../components/cur-dir-path';
|
|
|
|
import DirentDetail from '../../components/dirent-detail/dirent-details';
|
2019-04-12 12:21:54 +00:00
|
|
|
import LibDetail from '../../components/dirent-detail/lib-details';
|
2019-02-21 09:37:04 +00:00
|
|
|
import DirColumnView from '../../components/dir-view-mode/dir-column-view';
|
|
|
|
|
2019-04-17 06:18:12 +00:00
|
|
|
import '../../css/lib-content-view.css';
|
|
|
|
|
2019-02-21 09:37:04 +00:00
|
|
|
const propTypes = {
|
|
|
|
pathPrefix: PropTypes.array.isRequired,
|
2024-05-07 08:45:51 +00:00
|
|
|
isTreePanelShown: PropTypes.bool.isRequired,
|
2019-02-21 09:37:04 +00:00
|
|
|
currentMode: PropTypes.string.isRequired,
|
|
|
|
path: PropTypes.string.isRequired,
|
|
|
|
pathExist: PropTypes.bool.isRequired,
|
|
|
|
// repoinfo
|
|
|
|
currentRepoInfo: PropTypes.object.isRequired,
|
|
|
|
repoID: PropTypes.string.isRequired,
|
|
|
|
enableDirPrivateShare: PropTypes.bool.isRequired,
|
|
|
|
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
2019-06-24 03:28:25 +00:00
|
|
|
userPerm: PropTypes.string,
|
2019-02-21 09:37:04 +00:00
|
|
|
// path func
|
|
|
|
onTabNavClick: PropTypes.func.isRequired,
|
|
|
|
onMainNavBarClick: PropTypes.func.isRequired,
|
|
|
|
// file
|
|
|
|
isViewFile: PropTypes.bool.isRequired,
|
|
|
|
isFileLoadedErr: PropTypes.bool.isRequired,
|
|
|
|
hash: PropTypes.string,
|
2019-03-15 02:10:24 +00:00
|
|
|
fileTags: PropTypes.array.isRequired,
|
2019-02-21 09:37:04 +00:00
|
|
|
isFileLoading: PropTypes.bool.isRequired,
|
2019-04-19 07:50:27 +00:00
|
|
|
filePermission: PropTypes.string,
|
2019-02-21 09:37:04 +00:00
|
|
|
content: PropTypes.string,
|
|
|
|
lastModified: PropTypes.string,
|
|
|
|
latestContributor: PropTypes.string,
|
|
|
|
onLinkClick: PropTypes.func.isRequired,
|
|
|
|
// tree
|
|
|
|
isTreeDataLoading: PropTypes.bool.isRequired,
|
|
|
|
treeData: PropTypes.object.isRequired,
|
|
|
|
currentNode: PropTypes.object,
|
|
|
|
onNodeClick: PropTypes.func.isRequired,
|
|
|
|
onNodeCollapse: PropTypes.func.isRequired,
|
|
|
|
onNodeExpanded: PropTypes.func.isRequired,
|
|
|
|
onRenameNode: PropTypes.func.isRequired,
|
|
|
|
onDeleteNode: PropTypes.func.isRequired,
|
|
|
|
onAddFileNode: PropTypes.func.isRequired,
|
|
|
|
onAddFolderNode: PropTypes.func.isRequired,
|
|
|
|
// repo content
|
2024-02-02 12:52:58 +00:00
|
|
|
repoTags: PropTypes.array.isRequired,
|
2019-02-21 09:37:04 +00:00
|
|
|
usedRepoTags: PropTypes.array.isRequired,
|
|
|
|
updateUsedRepoTags: PropTypes.func.isRequired,
|
|
|
|
// list
|
|
|
|
isDirentListLoading: PropTypes.bool.isRequired,
|
|
|
|
direntList: PropTypes.array.isRequired,
|
|
|
|
sortBy: PropTypes.string.isRequired,
|
|
|
|
sortOrder: PropTypes.string.isRequired,
|
|
|
|
sortItems: PropTypes.func.isRequired,
|
|
|
|
updateDirent: PropTypes.func.isRequired,
|
|
|
|
onItemClick: PropTypes.func.isRequired,
|
|
|
|
onItemSelected: PropTypes.func.isRequired,
|
|
|
|
onItemDelete: PropTypes.func.isRequired,
|
|
|
|
onItemRename: PropTypes.func.isRequired,
|
|
|
|
onItemMove: PropTypes.func.isRequired,
|
|
|
|
onItemCopy: PropTypes.func.isRequired,
|
|
|
|
onAddFolder: PropTypes.func.isRequired,
|
|
|
|
onAddFile: PropTypes.func.isRequired,
|
2023-09-14 06:36:58 +00:00
|
|
|
onItemConvert: PropTypes.func.isRequired,
|
2019-02-21 09:37:04 +00:00
|
|
|
onFileTagChanged: PropTypes.func.isRequired,
|
|
|
|
isDirentSelected: PropTypes.bool.isRequired,
|
|
|
|
isAllDirentSelected: PropTypes.bool.isRequired,
|
|
|
|
onAllDirentSelected: PropTypes.func.isRequired,
|
2019-03-19 10:20:45 +00:00
|
|
|
isDirentDetailShow: PropTypes.bool.isRequired,
|
|
|
|
selectedDirent: PropTypes.object,
|
2019-04-11 13:04:47 +00:00
|
|
|
selectedDirentList: PropTypes.array.isRequired,
|
|
|
|
onItemsMove: PropTypes.func.isRequired,
|
|
|
|
onItemsCopy: PropTypes.func.isRequired,
|
|
|
|
onItemsDelete: PropTypes.func.isRequired,
|
2019-03-19 10:20:45 +00:00
|
|
|
closeDirentDetail: PropTypes.func.isRequired,
|
|
|
|
showDirentDetail: PropTypes.func.isRequired,
|
2019-03-25 07:23:37 +00:00
|
|
|
onDeleteRepoTag: PropTypes.func.isRequired,
|
2019-04-18 05:39:42 +00:00
|
|
|
updateDetail: PropTypes.bool.isRequired,
|
2019-04-24 07:16:26 +00:00
|
|
|
onListContainerScroll: PropTypes.func.isRequired,
|
2019-05-14 02:15:09 +00:00
|
|
|
onDirentClick: PropTypes.func.isRequired,
|
2019-05-29 04:02:07 +00:00
|
|
|
direntDetailPanelTab: PropTypes.string,
|
2023-10-09 13:27:44 +00:00
|
|
|
loadDirentList: PropTypes.func,
|
|
|
|
fullDirentList: PropTypes.array,
|
2019-02-21 09:37:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class LibContentContainer extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
2019-04-12 12:21:54 +00:00
|
|
|
currentDirent: null,
|
2019-02-21 09:37:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
this.errMessage = (<div className="message err-tip">{gettext('Folder does not exist.')}</div>);
|
|
|
|
}
|
|
|
|
|
2023-12-06 09:24:05 +00:00
|
|
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
2019-04-18 05:39:42 +00:00
|
|
|
if (nextProps.path !== this.props.path || nextProps.updateDetail !== this.props.updateDetail) {
|
2019-04-12 12:21:54 +00:00
|
|
|
this.setState({currentDirent: null});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-21 09:37:04 +00:00
|
|
|
onPathClick = (path) => {
|
|
|
|
this.props.onMainNavBarClick(path);
|
2019-03-19 10:20:45 +00:00
|
|
|
this.props.closeDirentDetail();
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-02-21 09:37:04 +00:00
|
|
|
|
|
|
|
onItemClick = (dirent) => {
|
|
|
|
this.props.onItemClick(dirent);
|
2019-03-19 10:20:45 +00:00
|
|
|
this.props.closeDirentDetail();
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-02-21 09:37:04 +00:00
|
|
|
|
|
|
|
onDirentClick = (dirent) => {
|
2019-04-12 12:21:54 +00:00
|
|
|
this.setState({currentDirent: dirent});
|
|
|
|
this.props.onDirentClick(dirent);
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-02-21 09:37:04 +00:00
|
|
|
|
2019-04-12 12:21:54 +00:00
|
|
|
onItemSelected = (dirent) => {
|
|
|
|
this.setState({currentDirent: dirent});
|
2019-04-13 08:56:06 +00:00
|
|
|
this.props.onItemSelected(dirent);
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-03-18 09:32:49 +00:00
|
|
|
|
2019-04-18 05:39:42 +00:00
|
|
|
onItemDelete = (dirent) => {
|
2019-07-16 08:21:20 +00:00
|
|
|
this.checkCurrentDirent(dirent);
|
|
|
|
this.props.onItemDelete(dirent);
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-07-16 08:21:20 +00:00
|
|
|
|
|
|
|
onItemMove = (destRepo, dirent, selectedPath, currentPath) => {
|
|
|
|
this.checkCurrentDirent(dirent);
|
|
|
|
this.props.onItemMove(destRepo, dirent, selectedPath, currentPath);
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-07-16 08:21:20 +00:00
|
|
|
|
|
|
|
checkCurrentDirent = (deletedDirent) => {
|
2019-07-17 06:54:12 +00:00
|
|
|
let { currentDirent } = this.state;
|
|
|
|
if (currentDirent && deletedDirent.name === currentDirent.name) {
|
2019-04-18 05:39:42 +00:00
|
|
|
this.setState({currentDirent: null});
|
|
|
|
}
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-04-18 05:39:42 +00:00
|
|
|
|
2019-04-24 05:37:48 +00:00
|
|
|
onItemsScroll = (e) => {
|
2019-04-24 02:10:28 +00:00
|
|
|
let target = e.target;
|
2019-05-05 09:20:37 +00:00
|
|
|
|
|
|
|
if (target.scrollTop === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-29 06:22:20 +00:00
|
|
|
if (target.scrollTop + target.clientHeight + 1 >= target.scrollHeight) {
|
2019-04-24 07:16:26 +00:00
|
|
|
this.props.onListContainerScroll();
|
2019-04-24 02:10:28 +00:00
|
|
|
}
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-04-24 02:10:28 +00:00
|
|
|
|
2019-02-21 09:37:04 +00:00
|
|
|
render() {
|
2024-03-25 09:22:01 +00:00
|
|
|
let { path, repoID, usedRepoTags } = this.props;
|
2019-02-21 09:37:04 +00:00
|
|
|
let isRepoInfoBarShow = false;
|
|
|
|
if (path === '/') {
|
2024-03-25 09:22:01 +00:00
|
|
|
if (usedRepoTags.length !== 0) {
|
2019-02-21 09:37:04 +00:00
|
|
|
isRepoInfoBarShow = true;
|
|
|
|
}
|
2019-06-24 03:28:25 +00:00
|
|
|
}
|
2019-02-21 09:37:04 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<div className="cur-view-container">
|
2019-05-17 08:30:56 +00:00
|
|
|
{this.props.currentRepoInfo.status === 'read-only' &&
|
2019-05-20 02:49:56 +00:00
|
|
|
<div className="readonly-tip-message">
|
|
|
|
{gettext('This library has been set to read-only by admin and cannot be updated.')}
|
2019-05-17 08:30:56 +00:00
|
|
|
</div>
|
|
|
|
}
|
2019-02-21 09:37:04 +00:00
|
|
|
<div className="cur-view-path">
|
2020-11-02 05:56:35 +00:00
|
|
|
<CurDirPath
|
2019-02-21 09:37:04 +00:00
|
|
|
repoID={repoID}
|
|
|
|
repoName={this.props.currentRepoInfo.repo_name}
|
2019-02-27 05:53:36 +00:00
|
|
|
pathPrefix={this.props.pathPrefix}
|
2020-11-02 05:56:35 +00:00
|
|
|
currentPath={this.props.path}
|
2021-09-13 02:37:07 +00:00
|
|
|
userPerm={this.props.userPerm}
|
2019-03-15 02:10:24 +00:00
|
|
|
isViewFile={this.props.isViewFile}
|
2019-02-21 09:37:04 +00:00
|
|
|
onTabNavClick={this.props.onTabNavClick}
|
|
|
|
onPathClick={this.onPathClick}
|
2019-02-27 06:14:28 +00:00
|
|
|
updateUsedRepoTags={this.props.updateUsedRepoTags}
|
2019-03-15 02:10:24 +00:00
|
|
|
fileTags={this.props.fileTags}
|
2019-03-25 07:23:37 +00:00
|
|
|
onDeleteRepoTag={this.props.onDeleteRepoTag}
|
2019-08-29 07:28:54 +00:00
|
|
|
direntList={this.props.direntList}
|
|
|
|
sortBy={this.props.sortBy}
|
|
|
|
sortOrder={this.props.sortOrder}
|
|
|
|
sortItems={this.props.sortItems}
|
2019-02-21 09:37:04 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2024-05-07 08:45:51 +00:00
|
|
|
<div className={`cur-view-content lib-content-container ${this.props.isTreePanelShown ? 'view-mode-container' : ''}`} onScroll={this.onItemsScroll}>
|
2019-02-21 09:37:04 +00:00
|
|
|
{!this.props.pathExist && this.errMessage}
|
|
|
|
{this.props.pathExist && (
|
2024-05-07 08:45:51 +00:00
|
|
|
<DirColumnView
|
|
|
|
currentMode={this.props.currentMode}
|
|
|
|
path={this.props.path}
|
|
|
|
repoID={repoID}
|
|
|
|
currentRepoInfo={this.props.currentRepoInfo}
|
|
|
|
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
|
|
|
userPerm={this.props.userPerm}
|
|
|
|
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
|
|
|
isTreeDataLoading={this.props.isTreeDataLoading}
|
|
|
|
treeData={this.props.treeData}
|
|
|
|
currentNode={this.props.currentNode}
|
|
|
|
onNodeClick={this.props.onNodeClick}
|
|
|
|
onNodeCollapse={this.props.onNodeCollapse}
|
|
|
|
onNodeExpanded={this.props.onNodeExpanded}
|
|
|
|
onAddFolderNode={this.props.onAddFolder}
|
|
|
|
onAddFileNode={this.props.onAddFile}
|
|
|
|
onRenameNode={this.props.onRenameNode}
|
|
|
|
onDeleteNode={this.props.onDeleteNode}
|
|
|
|
isViewFile={this.props.isViewFile}
|
|
|
|
isFileLoading={this.props.isFileLoading}
|
|
|
|
isFileLoadedErr={this.props.isFileLoadedErr}
|
|
|
|
hash={this.props.hash}
|
|
|
|
filePermission={this.props.filePermission}
|
|
|
|
content={this.props.content}
|
|
|
|
lastModified={this.props.lastModified}
|
|
|
|
latestContributor={this.props.latestContributor}
|
|
|
|
onLinkClick={this.props.onLinkClick}
|
|
|
|
isRepoInfoBarShow={isRepoInfoBarShow}
|
|
|
|
repoTags={this.props.repoTags}
|
|
|
|
usedRepoTags={this.props.usedRepoTags}
|
|
|
|
updateUsedRepoTags={this.props.updateUsedRepoTags}
|
|
|
|
isDirentListLoading={this.props.isDirentListLoading}
|
|
|
|
direntList={this.props.direntList}
|
|
|
|
fullDirentList={this.props.fullDirentList}
|
|
|
|
sortBy={this.props.sortBy}
|
|
|
|
sortOrder={this.props.sortOrder}
|
|
|
|
sortItems={this.props.sortItems}
|
|
|
|
onAddFolder={this.props.onAddFolder}
|
|
|
|
onAddFile={this.props.onAddFile}
|
|
|
|
onItemClick={this.onItemClick}
|
|
|
|
onItemSelected={this.onItemSelected}
|
|
|
|
onItemDelete={this.onItemDelete}
|
|
|
|
onItemRename={this.props.onItemRename}
|
|
|
|
onItemMove={this.onItemMove}
|
|
|
|
onItemCopy={this.props.onItemCopy}
|
|
|
|
onItemConvert={this.props.onItemConvert}
|
|
|
|
onDirentClick={this.onDirentClick}
|
|
|
|
updateDirent={this.props.updateDirent}
|
|
|
|
isAllItemSelected={this.props.isAllDirentSelected}
|
|
|
|
onAllItemSelected={this.props.onAllDirentSelected}
|
|
|
|
selectedDirentList={this.props.selectedDirentList}
|
|
|
|
onItemsMove={this.props.onItemsMove}
|
|
|
|
onItemsCopy={this.props.onItemsCopy}
|
|
|
|
onItemsDelete={this.props.onItemsDelete}
|
|
|
|
onFileTagChanged={this.props.onFileTagChanged}
|
|
|
|
showDirentDetail={this.props.showDirentDetail}
|
|
|
|
onItemsScroll={this.onItemsScroll}
|
|
|
|
isDirentDetailShow={this.props.isDirentDetailShow}
|
|
|
|
/>
|
2019-02-21 09:37:04 +00:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-02 05:56:35 +00:00
|
|
|
{this.props.isDirentDetailShow &&
|
2019-04-12 12:21:54 +00:00
|
|
|
<Fragment>
|
|
|
|
<div className="cur-view-detail">
|
2020-11-02 05:56:35 +00:00
|
|
|
{(this.props.path === '/' && !this.state.currentDirent) ?
|
|
|
|
<LibDetail
|
2019-04-12 12:34:19 +00:00
|
|
|
currentRepo={this.props.currentRepoInfo}
|
|
|
|
closeDetails={this.props.closeDirentDetail}
|
|
|
|
/> :
|
2019-04-12 12:21:54 +00:00
|
|
|
<DirentDetail
|
|
|
|
repoID={repoID}
|
|
|
|
path={this.props.path}
|
|
|
|
dirent={this.state.currentDirent}
|
|
|
|
currentRepoInfo={this.props.currentRepoInfo}
|
2024-02-23 08:23:35 +00:00
|
|
|
repoTags={this.props.repoTags}
|
2023-06-07 12:41:12 +00:00
|
|
|
fileTags={this.props.isViewFile ? this.props.fileTags : []}
|
2019-04-12 12:21:54 +00:00
|
|
|
onFileTagChanged={this.props.onFileTagChanged}
|
|
|
|
onItemDetailsClose={this.props.closeDirentDetail}
|
2019-05-29 04:02:07 +00:00
|
|
|
direntDetailPanelTab={this.props.direntDetailPanelTab}
|
2019-04-12 12:21:54 +00:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</Fragment>
|
|
|
|
}
|
2019-02-21 09:37:04 +00:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LibContentContainer.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default LibContentContainer;
|