2018-11-27 06:47:19 +00:00
|
|
|
import React, { Fragment } from 'react';
|
2018-10-13 09:07:54 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2018-12-18 01:02:16 +00:00
|
|
|
import MD5 from 'MD5';
|
|
|
|
import { UncontrolledTooltip } from 'reactstrap';
|
2018-11-29 09:55:14 +00:00
|
|
|
import { gettext, siteRoot } from '../../utils/constants';
|
2018-11-30 03:52:19 +00:00
|
|
|
import { Utils } from '../../utils/utils';
|
2018-12-06 03:28:16 +00:00
|
|
|
import { seafileAPI } from '../../utils/seafile-api';
|
2018-10-25 05:36:06 +00:00
|
|
|
import URLDecorator from '../../utils/url-decorator';
|
2018-12-07 06:58:37 +00:00
|
|
|
import toaster from '../toast';
|
2018-10-25 05:36:06 +00:00
|
|
|
import DirentMenu from './dirent-menu';
|
|
|
|
import DirentRename from './dirent-rename';
|
2018-11-27 06:47:19 +00:00
|
|
|
import ModalPortal from '../modal-portal';
|
|
|
|
import ZipDownloadDialog from '../dialog/zip-download-dialog';
|
|
|
|
import MoveDirentDialog from '../dialog/move-dirent-dialog';
|
|
|
|
import CopyDirentDialog from '../dialog/copy-dirent-dialog';
|
2018-12-06 03:28:16 +00:00
|
|
|
import ShareDialog from '../dialog/share-dialog';
|
2018-10-13 09:07:54 +00:00
|
|
|
|
|
|
|
const propTypes = {
|
2018-11-22 03:26:00 +00:00
|
|
|
path: PropTypes.string.isRequired,
|
2018-11-28 04:41:49 +00:00
|
|
|
repoID: PropTypes.string.isRequired,
|
2018-10-13 09:07:54 +00:00
|
|
|
isItemFreezed: PropTypes.bool.isRequired,
|
|
|
|
dirent: PropTypes.object.isRequired,
|
|
|
|
onItemClick: PropTypes.func.isRequired,
|
2018-10-25 05:36:06 +00:00
|
|
|
onFreezedItem: PropTypes.func.isRequired,
|
|
|
|
onUnfreezedItem: PropTypes.func.isRequired,
|
2018-11-23 12:19:42 +00:00
|
|
|
onItemRenameToggle: PropTypes.func.isRequired,
|
|
|
|
onItemSelected: PropTypes.func.isRequired,
|
2018-10-13 09:07:54 +00:00
|
|
|
onItemDelete: PropTypes.func.isRequired,
|
2018-10-25 05:36:06 +00:00
|
|
|
onItemRename: PropTypes.func.isRequired,
|
2018-11-27 06:47:19 +00:00
|
|
|
onItemMove: PropTypes.func.isRequired,
|
|
|
|
onItemCopy: PropTypes.func.isRequired,
|
2018-10-25 05:36:06 +00:00
|
|
|
onItemDetails: PropTypes.func.isRequired,
|
2018-11-22 03:26:00 +00:00
|
|
|
updateDirent: PropTypes.func.isRequired,
|
2018-12-18 09:21:01 +00:00
|
|
|
currentRepoInfo: PropTypes.object,
|
2018-11-01 10:40:18 +00:00
|
|
|
isRepoOwner: PropTypes.bool,
|
2018-10-13 09:07:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DirentListItem extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
isOperationShow: false,
|
2018-10-25 05:36:06 +00:00
|
|
|
highlight: false,
|
|
|
|
isItemMenuShow: false,
|
|
|
|
menuPosition: {top: 0, left: 0 },
|
2018-11-27 06:47:19 +00:00
|
|
|
progress: 0,
|
|
|
|
isProgressDialogShow: false,
|
|
|
|
isMoveDialogShow: false,
|
|
|
|
isCopyDialogShow: false,
|
2018-12-06 03:28:16 +00:00
|
|
|
isShareDialogShow: false,
|
2018-11-27 06:47:19 +00:00
|
|
|
isMutipleOperation: false,
|
2018-12-18 01:02:16 +00:00
|
|
|
isShowTagTooltip: false,
|
2018-10-13 09:07:54 +00:00
|
|
|
};
|
2018-11-27 06:47:19 +00:00
|
|
|
this.zipToken = null;
|
2018-10-13 09:07:54 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 05:36:06 +00:00
|
|
|
componentDidMount() {
|
|
|
|
document.addEventListener('click', this.onItemMenuHide);
|
|
|
|
}
|
2018-11-22 03:26:00 +00:00
|
|
|
|
2018-10-25 05:36:06 +00:00
|
|
|
componentWillUnmount() {
|
|
|
|
document.removeEventListener('click', this.onItemMenuHide);
|
|
|
|
}
|
|
|
|
|
2018-10-13 09:07:54 +00:00
|
|
|
//UI Interactive
|
|
|
|
onMouseEnter = () => {
|
|
|
|
if (!this.props.isItemFreezed) {
|
|
|
|
this.setState({
|
|
|
|
highlight: true,
|
|
|
|
isOperationShow: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onMouseOver = () => {
|
|
|
|
if (!this.props.isItemFreezed) {
|
|
|
|
this.setState({
|
|
|
|
highlight: true,
|
|
|
|
isOperationShow: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onMouseLeave = () => {
|
|
|
|
if (!this.props.isItemFreezed) {
|
|
|
|
this.setState({
|
|
|
|
highlight: false,
|
|
|
|
isOperationShow: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-25 05:36:06 +00:00
|
|
|
onItemMenuToggle = (e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.nativeEvent.stopImmediatePropagation();
|
|
|
|
|
|
|
|
if (!this.state.isItemMenuShow) {
|
|
|
|
this.onItemMenuShow(e);
|
|
|
|
} else {
|
|
|
|
this.onItemMenuHide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onItemMenuShow = (e) => {
|
2018-11-15 10:46:46 +00:00
|
|
|
let left = e.clientX;
|
|
|
|
let top = e.clientY;
|
2018-10-25 05:36:06 +00:00
|
|
|
let position = Object.assign({},this.state.menuPosition, {left: left, top: top});
|
|
|
|
this.setState({
|
|
|
|
menuPosition: position,
|
|
|
|
isItemMenuShow: true,
|
|
|
|
});
|
|
|
|
this.props.onFreezedItem();
|
2018-10-13 09:07:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onItemMenuHide = () => {
|
|
|
|
this.setState({
|
|
|
|
isOperationShow: false,
|
2018-10-25 05:36:06 +00:00
|
|
|
highlight: '',
|
|
|
|
isItemMenuShow: false,
|
|
|
|
isRenameing: false,
|
2018-10-13 09:07:54 +00:00
|
|
|
});
|
2018-10-25 05:36:06 +00:00
|
|
|
this.props.onUnfreezedItem();
|
2018-10-13 09:07:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//buiness handler
|
|
|
|
onItemSelected = () => {
|
2018-11-23 12:19:42 +00:00
|
|
|
this.props.onItemSelected(this.props.dirent);
|
2018-10-13 09:07:54 +00:00
|
|
|
}
|
2018-11-22 03:26:00 +00:00
|
|
|
|
2018-10-13 09:07:54 +00:00
|
|
|
onItemStarred = () => {
|
2018-10-25 05:36:06 +00:00
|
|
|
let dirent = this.props.dirent;
|
2018-11-28 04:41:49 +00:00
|
|
|
let repoID = this.props.repoID;
|
2018-10-25 05:36:06 +00:00
|
|
|
let filePath = this.getDirentPath(dirent);
|
|
|
|
if (dirent.starred) {
|
|
|
|
seafileAPI.unStarFile(repoID, filePath).then(() => {
|
2018-11-28 00:57:42 +00:00
|
|
|
this.props.updateDirent(this.props.dirent, 'starred', false);
|
2018-10-25 05:36:06 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
seafileAPI.starFile(repoID, filePath).then(() => {
|
2018-11-28 00:57:42 +00:00
|
|
|
this.props.updateDirent(this.props.dirent, 'starred', true);
|
2018-10-25 05:36:06 +00:00
|
|
|
});
|
|
|
|
}
|
2018-10-13 09:07:54 +00:00
|
|
|
}
|
2018-11-22 03:26:00 +00:00
|
|
|
|
2018-11-30 03:52:19 +00:00
|
|
|
onItemClick = (e) => {
|
|
|
|
e.preventDefault();
|
2018-11-29 09:55:14 +00:00
|
|
|
this.props.onItemClick(this.props.dirent);
|
2018-10-25 05:36:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onItemDelete = (e) => {
|
|
|
|
e.nativeEvent.stopImmediatePropagation(); //for document event
|
2018-11-22 03:26:00 +00:00
|
|
|
this.props.onItemDelete(this.props.dirent);
|
2018-10-25 05:36:06 +00:00
|
|
|
}
|
|
|
|
|
2018-12-06 03:28:16 +00:00
|
|
|
onItemShare = (e) => {
|
|
|
|
e.nativeEvent.stopImmediatePropagation(); //for document event
|
|
|
|
this.setState({isShareDialogShow: !this.state.isShareDialogShow});
|
|
|
|
}
|
|
|
|
|
2018-11-23 12:19:42 +00:00
|
|
|
onMenuItemClick = (operation) => {
|
2018-10-25 05:36:06 +00:00
|
|
|
switch(operation) {
|
2018-11-22 03:26:00 +00:00
|
|
|
case 'Rename':
|
2018-11-23 12:19:42 +00:00
|
|
|
this.onItemRenameToggle();
|
2018-10-25 05:36:06 +00:00
|
|
|
break;
|
|
|
|
case 'Move':
|
2018-11-23 12:19:42 +00:00
|
|
|
this.onItemMoveToggle();
|
2018-10-25 05:36:06 +00:00
|
|
|
break;
|
|
|
|
case 'Copy':
|
2018-11-23 12:19:42 +00:00
|
|
|
this.onItemCopyToggle();
|
2018-10-25 05:36:06 +00:00
|
|
|
break;
|
|
|
|
case 'Permission':
|
|
|
|
this.onPermissionItem();
|
|
|
|
break;
|
|
|
|
case 'Details':
|
|
|
|
this.onDetailsItem();
|
|
|
|
break;
|
|
|
|
case 'Unlock':
|
|
|
|
this.onUnlockItem();
|
|
|
|
break;
|
|
|
|
case 'Lock':
|
|
|
|
this.onLockItem();
|
|
|
|
break;
|
|
|
|
case 'New Draft':
|
|
|
|
this.onNewDraft();
|
|
|
|
break;
|
|
|
|
case 'Comment':
|
|
|
|
this.onComnentItem();
|
|
|
|
break;
|
|
|
|
case 'History':
|
|
|
|
this.onHistory();
|
|
|
|
break;
|
|
|
|
case 'Access Log':
|
|
|
|
this.onAccessLog();
|
|
|
|
break;
|
|
|
|
case 'Open via Client':
|
|
|
|
this.onOpenViaClient();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-23 12:19:42 +00:00
|
|
|
onItemRenameToggle = () => {
|
|
|
|
this.props.onItemRenameToggle(this.props.dirent);
|
2018-10-25 05:36:06 +00:00
|
|
|
this.setState({
|
|
|
|
isOperationShow: false,
|
|
|
|
isItemMenuShow: false,
|
|
|
|
isRenameing: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onRenameConfirm = (newName) => {
|
|
|
|
if (newName === this.props.dirent.name) {
|
|
|
|
this.onRenameCancel();
|
|
|
|
return false;
|
|
|
|
}
|
2018-11-22 03:26:00 +00:00
|
|
|
|
2018-10-25 05:36:06 +00:00
|
|
|
if (!newName) {
|
|
|
|
let errMessage = 'It is required.';
|
2018-12-07 06:58:37 +00:00
|
|
|
toaster.danger(gettext(errMessage));
|
2018-10-25 05:36:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
2018-11-22 03:26:00 +00:00
|
|
|
|
2018-10-25 05:36:06 +00:00
|
|
|
if (newName.indexOf('/') > -1) {
|
2018-11-28 00:57:42 +00:00
|
|
|
let errMessage = 'Name should not include ' + '\'/\'' + '.';
|
2018-12-07 06:58:37 +00:00
|
|
|
toaster.danger(gettext(errMessage));
|
2018-10-25 05:36:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-11-22 03:26:00 +00:00
|
|
|
this.props.onItemRename(this.props.dirent, newName);
|
2018-10-25 05:36:06 +00:00
|
|
|
this.onRenameCancel();
|
|
|
|
}
|
|
|
|
|
|
|
|
onRenameCancel = () => {
|
|
|
|
this.setState({
|
|
|
|
isRenameing: false,
|
|
|
|
});
|
|
|
|
this.props.onUnfreezedItem();
|
|
|
|
}
|
2018-11-22 03:26:00 +00:00
|
|
|
|
2018-11-23 12:19:42 +00:00
|
|
|
onItemMoveToggle = () => {
|
2018-11-27 06:47:19 +00:00
|
|
|
this.setState({isMoveDialogShow: !this.state.isMoveDialogShow});
|
2018-10-25 05:36:06 +00:00
|
|
|
this.onItemMenuHide();
|
|
|
|
}
|
|
|
|
|
2018-11-23 12:19:42 +00:00
|
|
|
onItemCopyToggle = () => {
|
2018-11-27 06:47:19 +00:00
|
|
|
this.setState({isCopyDialogShow: !this.state.isCopyDialogShow});
|
2018-10-25 05:36:06 +00:00
|
|
|
this.onItemMenuHide();
|
2018-10-13 09:07:54 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 05:36:06 +00:00
|
|
|
onPermissionItem = () => {
|
2018-10-13 09:07:54 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-10-25 05:36:06 +00:00
|
|
|
onDetailsItem = () => {
|
2018-11-29 09:55:14 +00:00
|
|
|
this.props.onItemDetails(this.props.dirent);
|
2018-10-25 05:36:06 +00:00
|
|
|
this.onItemMenuHide();
|
|
|
|
}
|
|
|
|
|
|
|
|
onLockItem = () => {
|
2018-11-28 04:41:49 +00:00
|
|
|
let repoID = this.props.repoID;
|
2018-10-25 05:36:06 +00:00
|
|
|
let filePath = this.getDirentPath(this.props.dirent);
|
|
|
|
seafileAPI.lockfile(repoID, filePath).then(() => {
|
2018-11-28 00:57:42 +00:00
|
|
|
this.props.updateDirent(this.props.dirent, 'is_locked', true);
|
|
|
|
this.props.updateDirent(this.props.dirent, 'locked_by_me', true);
|
2018-10-25 05:36:06 +00:00
|
|
|
});
|
|
|
|
this.onItemMenuHide();
|
|
|
|
}
|
|
|
|
|
|
|
|
onUnlockItem = () => {
|
2018-11-28 04:41:49 +00:00
|
|
|
let repoID = this.props.repoID;
|
2018-10-25 05:36:06 +00:00
|
|
|
let filePath = this.getDirentPath(this.props.dirent);
|
|
|
|
seafileAPI.unlockfile(repoID, filePath).then(() => {
|
2018-11-28 00:57:42 +00:00
|
|
|
this.props.updateDirent(this.props.dirent, 'is_locked', false);
|
|
|
|
this.props.updateDirent(this.props.dirent, 'locked_by_me', false);
|
2018-10-25 05:36:06 +00:00
|
|
|
});
|
|
|
|
this.onItemMenuHide();
|
|
|
|
}
|
|
|
|
|
|
|
|
onNewDraft = () => {
|
2018-11-28 04:41:49 +00:00
|
|
|
let repoID = this.props.repoID;
|
2018-10-25 05:36:06 +00:00
|
|
|
let filePath = this.getDirentPath(this.props.dirent);
|
2018-11-22 03:26:00 +00:00
|
|
|
seafileAPI.createDraft(repoID, filePath).then(res => {
|
2018-10-25 05:36:06 +00:00
|
|
|
let draft_file_Path = res.data.draft_file_path;
|
|
|
|
let draftId = res.data.id;
|
|
|
|
let url = URLDecorator.getUrl({type: 'draft_view', repoID: repoID, filePath: draft_file_Path, draftId: draftId});
|
|
|
|
let newWindow = window.open('draft');
|
|
|
|
newWindow.location.href = url;
|
|
|
|
}).catch(() => {
|
2018-12-07 06:58:37 +00:00
|
|
|
toaster.danger('Create draft failed.');
|
2018-10-25 05:36:06 +00:00
|
|
|
});
|
|
|
|
this.onItemMenuHide();
|
|
|
|
}
|
|
|
|
|
|
|
|
onComnentItem = () => {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onHistory = () => {
|
2018-11-28 04:41:49 +00:00
|
|
|
let repoID = this.props.repoID;
|
2018-10-25 05:36:06 +00:00
|
|
|
let filePath = this.getDirentPath(this.props.dirent);
|
|
|
|
let referer = location.href;
|
|
|
|
let url = URLDecorator.getUrl({type: 'file_revisions', repoID: repoID, filePath: filePath, referer: referer});
|
|
|
|
location.href = url;
|
|
|
|
this.onItemMenuHide();
|
|
|
|
}
|
|
|
|
|
|
|
|
onAccessLog = () => {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onOpenViaClient = () => {
|
2018-11-28 04:41:49 +00:00
|
|
|
let repoID = this.props.repoID;
|
2018-10-25 05:36:06 +00:00
|
|
|
let filePath = this.getDirentPath(this.props.dirent);
|
|
|
|
let url = URLDecorator.getUrl({type: 'open_via_client', repoID: repoID, filePath: filePath});
|
|
|
|
location.href = url;
|
|
|
|
this.onItemMenuHide();
|
|
|
|
}
|
|
|
|
|
2018-11-27 06:47:19 +00:00
|
|
|
onItemDownload = (e) => {
|
|
|
|
e.nativeEvent.stopImmediatePropagation();
|
|
|
|
let dirent = this.props.dirent;
|
2018-11-28 04:41:49 +00:00
|
|
|
let repoID = this.props.repoID;
|
2018-11-27 06:47:19 +00:00
|
|
|
let direntPath = this.getDirentPath(dirent);
|
|
|
|
if (dirent.type === 'dir') {
|
|
|
|
this.setState({isProgressDialogShow: true, progress: 0});
|
|
|
|
seafileAPI.zipDownload(repoID, this.props.path, dirent.name).then(res => {
|
|
|
|
this.zipToken = res.data['zip_token'];
|
|
|
|
this.addDownloadAnimation();
|
|
|
|
this.interval = setInterval(this.addDownloadAnimation, 1000);
|
|
|
|
}).catch(() => {
|
|
|
|
clearInterval(this.interval);
|
2018-12-07 06:58:37 +00:00
|
|
|
// toaster.danger(gettext(''));
|
2018-11-27 06:47:19 +00:00
|
|
|
//todo;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
let url = URLDecorator.getUrl({type: 'download_file_url', repoID: repoID, filePath: direntPath});
|
|
|
|
location.href = url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addDownloadAnimation = () => {
|
|
|
|
let _this = this;
|
|
|
|
let token = this.zipToken;
|
|
|
|
seafileAPI.queryZipProgress(token).then(res => {
|
|
|
|
let data = res.data;
|
|
|
|
let progress = data.total === 0 ? 100 : (data.zipped / data.total * 100).toFixed(0);
|
|
|
|
this.setState({progress: parseInt(progress)});
|
|
|
|
|
|
|
|
if (data['total'] === data['zipped']) {
|
|
|
|
this.setState({
|
|
|
|
progress: 100
|
|
|
|
});
|
|
|
|
clearInterval(this.interval);
|
|
|
|
location.href = URLDecorator.getUrl({type: 'download_dir_zip_url', token: token});
|
|
|
|
setTimeout(function() {
|
|
|
|
_this.setState({isProgressDialogShow: false});
|
|
|
|
}, 500);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onCancelDownload = () => {
|
|
|
|
let zipToken = this.zipToken;
|
|
|
|
seafileAPI.cancelZipTask(zipToken).then(res => {
|
|
|
|
this.setState({
|
|
|
|
isProgressDialogShow: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-10-25 05:36:06 +00:00
|
|
|
getDirentPath = (dirent) => {
|
2018-11-22 03:26:00 +00:00
|
|
|
let path = this.props.path;
|
2018-10-25 05:36:06 +00:00
|
|
|
return path === '/' ? path + dirent.name : path + '/' + dirent.name;
|
2018-10-13 09:07:54 +00:00
|
|
|
}
|
|
|
|
|
2018-12-18 01:02:16 +00:00
|
|
|
onTagTooltipToggle = (e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
this.setState({isShowTagTooltip: !this.state.isShowTagTooltip})
|
|
|
|
}
|
|
|
|
|
2018-10-13 09:07:54 +00:00
|
|
|
render() {
|
2018-11-30 03:52:19 +00:00
|
|
|
let { path, dirent } = this.props;
|
|
|
|
let direntPath = Utils.joinPath(path, dirent.name);
|
2018-12-13 03:05:47 +00:00
|
|
|
let href = siteRoot + 'wiki/lib/' + this.props.repoID + Utils.encodePath(direntPath);
|
2018-12-18 01:02:16 +00:00
|
|
|
let toolTipID = MD5(dirent.name).slice(0, 7);
|
2018-12-17 10:43:18 +00:00
|
|
|
let tagTitle = '';
|
2018-12-18 01:02:16 +00:00
|
|
|
if (dirent.file_tags && dirent.file_tags.length > 0) {
|
2018-12-17 10:43:18 +00:00
|
|
|
dirent.file_tags.forEach(item => {
|
|
|
|
tagTitle += item.name + ' ';
|
|
|
|
});
|
|
|
|
}
|
2018-10-13 09:07:54 +00:00
|
|
|
return (
|
2018-11-27 06:47:19 +00:00
|
|
|
<Fragment>
|
|
|
|
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}>
|
|
|
|
<td className="select">
|
|
|
|
<input type="checkbox" className="vam" onChange={this.onItemSelected} checked={dirent.isSelected}/>
|
|
|
|
</td>
|
|
|
|
<td className="star" onClick={this.onItemStarred}>
|
|
|
|
{dirent.starred !== undefined && !dirent.starred && <i className="far fa-star empty"></i>}
|
|
|
|
{dirent.starred !== undefined && dirent.starred && <i className="fas fa-star"></i>}
|
|
|
|
</td>
|
|
|
|
<td className="icon">
|
|
|
|
<div className="dir-icon">
|
2018-11-29 09:55:14 +00:00
|
|
|
<img src={dirent.type === 'dir' ? siteRoot + 'media/img/folder-192.png' : siteRoot + 'media/img/file/192/txt.png'} alt={gettext('file icon')}></img>
|
|
|
|
{dirent.is_locked && <img className="locked" src={siteRoot + 'media/img/file-locked-32.png'} alt={gettext('locked')}></img>}
|
2018-11-27 06:47:19 +00:00
|
|
|
</div>
|
|
|
|
</td>
|
2018-11-30 03:52:19 +00:00
|
|
|
<td className="name">
|
2018-11-27 06:47:19 +00:00
|
|
|
{this.state.isRenameing ?
|
|
|
|
<DirentRename dirent={dirent} onRenameConfirm={this.onRenameConfirm} onRenameCancel={this.onRenameCancel}/> :
|
2018-11-30 03:52:19 +00:00
|
|
|
<a href={href} onClick={this.onItemClick}>{dirent.name}</a>
|
2018-11-27 06:47:19 +00:00
|
|
|
}
|
|
|
|
</td>
|
|
|
|
<td>
|
2018-12-18 01:02:16 +00:00
|
|
|
{(dirent.type !== 'dir' && dirent.file_tags) && (
|
|
|
|
<Fragment>
|
|
|
|
<div id={`tag-list-title-${toolTipID}`} className="dirent-item tag-list tag-list-stacked">
|
|
|
|
{dirent.file_tags.map((fileTag, index) => {
|
|
|
|
let length = dirent.file_tags.length;
|
|
|
|
return (
|
|
|
|
<span className={`file-tag bg-${fileTag.color}`} key={fileTag.id} style={{zIndex: length - index }}></span>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
<UncontrolledTooltip target={`tag-list-title-${toolTipID}`} placement="bottom">
|
|
|
|
{tagTitle}
|
|
|
|
</UncontrolledTooltip>
|
|
|
|
</Fragment>
|
|
|
|
)}
|
2018-11-27 06:47:19 +00:00
|
|
|
</td>
|
|
|
|
<td className="operation">
|
|
|
|
{
|
|
|
|
this.state.isOperationShow &&
|
|
|
|
<div className="operations">
|
|
|
|
<ul className="operation-group">
|
|
|
|
<li className="operation-group-item">
|
|
|
|
<i className="sf2-icon-download" title={gettext('Download')} onClick={this.onItemDownload}></i>
|
|
|
|
</li>
|
|
|
|
<li className="operation-group-item">
|
|
|
|
<i className="sf2-icon-share" title={gettext('Share')} onClick={this.onItemShare}></i>
|
|
|
|
</li>
|
|
|
|
<li className="operation-group-item">
|
|
|
|
<i className="sf2-icon-delete" title={gettext('Delete')} onClick={this.onItemDelete}></i>
|
|
|
|
</li>
|
|
|
|
<li className="operation-group-item">
|
|
|
|
<i className="sf2-icon-caret-down sf-dropdown-toggle" title={gettext('More Operation')} onClick={this.onItemMenuToggle}></i>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
{
|
|
|
|
this.state.isItemMenuShow &&
|
|
|
|
<DirentMenu
|
|
|
|
dirent={this.props.dirent}
|
|
|
|
menuPosition={this.state.menuPosition}
|
|
|
|
onMenuItemClick={this.onMenuItemClick}
|
2018-12-18 09:21:01 +00:00
|
|
|
currentRepoInfo={this.props.currentRepoInfo}
|
2018-11-27 06:47:19 +00:00
|
|
|
isRepoOwner={this.props.isRepoOwner}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</td>
|
|
|
|
<td className="file-size">{dirent.size && dirent.size}</td>
|
|
|
|
<td className="last-update" dangerouslySetInnerHTML={{__html: dirent.mtime}}></td>
|
|
|
|
</tr>
|
|
|
|
{this.state.isMoveDialogShow &&
|
|
|
|
<ModalPortal>
|
|
|
|
<MoveDirentDialog
|
|
|
|
path={this.props.path}
|
2018-11-28 04:41:49 +00:00
|
|
|
repoID={this.props.repoID}
|
2018-11-27 06:47:19 +00:00
|
|
|
dirent={this.props.dirent}
|
|
|
|
isMutipleOperation={this.state.isMutipleOperation}
|
|
|
|
onItemMove={this.props.onItemMove}
|
|
|
|
onCancelMove={this.onItemMoveToggle}
|
|
|
|
/>
|
|
|
|
</ModalPortal>
|
|
|
|
}
|
|
|
|
{this.state.isCopyDialogShow &&
|
|
|
|
<ModalPortal>
|
|
|
|
<CopyDirentDialog
|
|
|
|
path={this.props.path}
|
2018-11-28 04:41:49 +00:00
|
|
|
repoID={this.props.repoID}
|
2018-11-27 06:47:19 +00:00
|
|
|
dirent={this.props.dirent}
|
|
|
|
isMutipleOperation={this.state.isMutipleOperation}
|
|
|
|
onItemCopy={this.props.onItemCopy}
|
|
|
|
onCancelCopy={this.onItemCopyToggle}
|
|
|
|
/>
|
|
|
|
</ModalPortal>
|
|
|
|
}
|
|
|
|
{this.state.isProgressDialogShow &&
|
|
|
|
<ModalPortal>
|
|
|
|
<ZipDownloadDialog
|
|
|
|
progress={this.state.progress}
|
|
|
|
onCancelDownload={this.onCancelDownload}
|
|
|
|
/>
|
|
|
|
</ModalPortal>
|
|
|
|
}
|
2018-12-06 03:28:16 +00:00
|
|
|
{this.state.isShareDialogShow &&
|
|
|
|
<ModalPortal>
|
|
|
|
<ShareDialog
|
2018-12-14 07:09:07 +00:00
|
|
|
itemType={dirent.type}
|
2018-12-06 03:28:16 +00:00
|
|
|
itemName={dirent.name}
|
2018-12-14 07:09:07 +00:00
|
|
|
itemPath={direntPath}
|
2018-12-06 03:28:16 +00:00
|
|
|
repoID={this.props.repoID}
|
|
|
|
toggleDialog={this.onItemShare}
|
|
|
|
/>
|
|
|
|
</ModalPortal>
|
|
|
|
}
|
2018-11-27 06:47:19 +00:00
|
|
|
</Fragment>
|
2018-10-13 09:07:54 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DirentListItem.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default DirentListItem;
|