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'; import LibDetail from '../../components/dirent-detail/lib-details'; import DirListView from '../../components/dir-view-mode/dir-list-view'; import DirGridView from '../../components/dir-view-mode/dir-grid-view'; import DirColumnView from '../../components/dir-view-mode/dir-column-view'; const propTypes = { pathPrefix: PropTypes.array.isRequired, currentMode: PropTypes.string.isRequired, path: PropTypes.string.isRequired, pathExist: PropTypes.bool.isRequired, // repoinfo currentRepoInfo: PropTypes.object.isRequired, repoID: PropTypes.string.isRequired, repoPermission: PropTypes.bool.isRequired, enableDirPrivateShare: PropTypes.bool.isRequired, userPrem: PropTypes.bool, isGroupOwnedRepo: PropTypes.bool.isRequired, // path func onTabNavClick: PropTypes.func.isRequired, onMainNavBarClick: PropTypes.func.isRequired, // file isViewFile: PropTypes.bool.isRequired, isFileLoadedErr: PropTypes.bool.isRequired, hash: PropTypes.string, isDraft: PropTypes.bool.isRequired, hasDraft: PropTypes.bool.isRequired, fileTags: PropTypes.array.isRequired, goDraftPage: PropTypes.func.isRequired, isFileLoading: PropTypes.bool.isRequired, filePermission: PropTypes.bool.isRequired, 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 draftCounts: PropTypes.number, usedRepoTags: PropTypes.array.isRequired, readmeMarkdown: PropTypes.object, updateUsedRepoTags: PropTypes.func.isRequired, // list isDirentListLoading: PropTypes.bool.isRequired, direntList: PropTypes.array.isRequired, showShareBtn: PropTypes.bool.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, onFileTagChanged: PropTypes.func.isRequired, isDirentSelected: PropTypes.bool.isRequired, isAllDirentSelected: PropTypes.bool.isRequired, onAllDirentSelected: PropTypes.func.isRequired, isDirentDetailShow: PropTypes.bool.isRequired, selectedDirent: PropTypes.object, selectedDirentList: PropTypes.array.isRequired, onItemsMove: PropTypes.func.isRequired, onItemsCopy: PropTypes.func.isRequired, onItemsDelete: PropTypes.func.isRequired, closeDirentDetail: PropTypes.func.isRequired, showDirentDetail: PropTypes.func.isRequired, onDeleteRepoTag: PropTypes.func.isRequired, }; class LibContentContainer extends React.Component { constructor(props) { super(props); this.state = { currentDirent: null, }; this.errMessage = (
{gettext('Folder does not exist.')}
); } componentWillReceiveProps(nextProps) { if (nextProps.path !== this.props.path) { this.setState({currentDirent: null}); } } onPathClick = (path) => { this.props.onMainNavBarClick(path); this.props.closeDirentDetail(); } onItemClick = (dirent) => { this.props.onItemClick(dirent); this.props.closeDirentDetail(); } // on '' onDirentClick = (dirent) => { this.setState({currentDirent: dirent}); this.props.onDirentClick(dirent); } onItemSelected = (dirent) => { this.setState({currentDirent: dirent}); } render() { let { path, repoID, usedRepoTags, readmeMarkdown, draftCounts } = this.props; let isRepoInfoBarShow = false; if (path === '/') { if (usedRepoTags.length !== 0 || readmeMarkdown !== null || draftCounts !== 0) { isRepoInfoBarShow = true; } } return (
{!this.props.pathExist && this.errMessage} {this.props.pathExist && ( {this.props.currentMode === 'list' && ( )} {this.props.currentMode === 'grid' && ( )} {this.props.currentMode === 'column' && ( )} )}
{this.props.isDirentDetailShow &&
{(this.props.path === '/' && !this.state.currentDirent) ? : }
}
); } } LibContentContainer.propTypes = propTypes; export default LibContentContainer;