1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-14 14:21:23 +00:00
Files
seahub/frontend/src/components/dirent-grid-view/dirent-grid-view.js

745 lines
23 KiB
JavaScript
Raw Normal View History

2019-04-18 22:36:07 +08:00
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { siteRoot, username, enableSeadoc } from '../../utils/constants';
2019-04-18 22:36:07 +08:00
import { Utils } from '../../utils/utils';
import { seafileAPI } from '../../utils/seafile-api';
import URLDecorator from '../../utils/url-decorator';
import Loading from '../loading';
import ModalPortal from '../modal-portal';
import ImageDialog from '../../components/dialog/image-dialog';
import DirentGridItem from '../../components/dirent-grid-view/dirent-grid-item';
import ContextMenu from '../context-menu/context-menu';
import { hideMenu, showMenu } from '../context-menu/actions';
import TextTranslation from '../../utils/text-translation';
import MoveDirentDialog from '../dialog/move-dirent-dialog';
import CopyDirentDialog from '../dialog/copy-dirent-dialog';
import ShareDialog from '../dialog/share-dialog';
import ZipDownloadDialog from '../dialog/zip-download-dialog';
import EditFileTagDialog from '../dialog/edit-filetag-dialog';
import Rename from '../../components/dialog/rename-dirent';
import CreateFile from '../dialog/create-file-dialog';
import CreateFolder from '../dialog/create-folder-dialog';
import LibSubFolderPermissionDialog from '../dialog/lib-sub-folder-permission-dialog';
import toaster from '../toast';
2019-04-18 22:36:07 +08:00
import '../../css/grid-view.css';
const propTypes = {
path: PropTypes.string.isRequired,
repoID: PropTypes.string.isRequired,
currentRepoInfo: PropTypes.object,
direntList: PropTypes.array.isRequired,
fullDirentList: PropTypes.array,
selectedDirentList: PropTypes.array.isRequired,
2019-04-18 22:36:07 +08:00
onAddFile: PropTypes.func,
onItemDelete: PropTypes.func,
onItemCopy: PropTypes.func.isRequired,
2023-09-14 14:36:58 +08:00
onItemConvert: PropTypes.func.isRequired,
2019-04-18 22:36:07 +08:00
onItemMove: PropTypes.func.isRequired,
onItemsMove: PropTypes.func.isRequired,
onItemsCopy: PropTypes.func.isRequired,
onItemsDelete: PropTypes.func.isRequired,
2019-04-18 22:36:07 +08:00
onRenameNode: PropTypes.func.isRequired,
onItemClick: PropTypes.func.isRequired,
isDirentListLoading: PropTypes.bool.isRequired,
isGroupOwnedRepo: PropTypes.bool.isRequired,
userPerm: PropTypes.string, // current path's user permission
2019-04-18 22:36:07 +08:00
enableDirPrivateShare: PropTypes.bool.isRequired,
updateDirent: PropTypes.func.isRequired,
isDirentDetailShow: PropTypes.bool.isRequired,
onGridItemClick: PropTypes.func,
repoTags: PropTypes.array.isRequired,
onFileTagChanged: PropTypes.func,
onAddFolder: PropTypes.func.isRequired,
showDirentDetail: PropTypes.func.isRequired,
onItemRename: PropTypes.func.isRequired,
posX: PropTypes.number,
posY: PropTypes.number,
dirent: PropTypes.object,
getMenuContainerSize: PropTypes.func,
2019-04-18 22:36:07 +08:00
};
const DIRENT_GRID_CONTAINER_MENU_ID = 'dirent-grid-container-menu';
const GRID_ITEM_CONTEXTMENU_ID = 'grid-item-contextmenu';
const DIRENTS_MENU_ID = 'dirents-menu';
class DirentGridView extends React.Component {
2019-04-18 22:36:07 +08:00
constructor(props) {
super(props);
this.state = {
2019-04-18 22:36:07 +08:00
isImagePopupOpen: false,
imageItems: [],
imageIndex: 0,
// onmenuClick
2019-04-18 22:36:07 +08:00
isShareDialogShow: false,
isMoveDialogShow: false,
isCopyDialogShow: false,
isEditFileTagShow: false,
2019-04-18 22:36:07 +08:00
isZipDialogOpen: false,
isRenameDialogShow: false,
isCreateFolderDialogShow: false,
isCreateFileDialogShow: false,
fileType: '',
isPermissionDialogOpen: false,
2019-04-18 22:36:07 +08:00
isMutipleOperation: true,
isGridItemFreezed: false,
activeDirent: null,
downloadItems: [],
2019-05-13 11:55:49 +08:00
};
2019-04-18 22:36:07 +08:00
this.isRepoOwner = props.currentRepoInfo.owner_email === username;
}
onCreateFileToggle = (fileType) => {
this.setState({
isCreateFileDialogShow: !this.state.isCreateFileDialogShow,
fileType: fileType || ''
});
};
onGridItemClick = (dirent, event) => {
2023-05-18 17:46:59 +08:00
hideMenu();
if (this.state.activeDirent !== dirent) {
this.setState({ activeDirent: dirent });
}
this.props.onGridItemClick(dirent, event);
};
2019-04-24 14:42:29 +08:00
2019-04-18 22:36:07 +08:00
onMoveToggle = () => {
2024-07-18 11:58:42 +08:00
this.setState({ isMoveDialogShow: !this.state.isMoveDialogShow });
};
2019-04-18 22:36:07 +08:00
onCopyToggle = () => {
2024-07-18 11:58:42 +08:00
this.setState({ isCopyDialogShow: !this.state.isCopyDialogShow });
};
2019-04-18 22:36:07 +08:00
onAddFolder = (dirPath) => {
2024-07-18 11:58:42 +08:00
this.setState({ isCreateFolderDialogShow: false });
this.props.onAddFolder(dirPath);
};
2019-04-18 22:36:07 +08:00
onItemShare = (e) => {
2024-07-18 11:58:42 +08:00
e.nativeEvent.stopImmediatePropagation(); // for document event
this.setState({ isShareDialogShow: !this.state.isShareDialogShow });
};
2019-04-18 22:36:07 +08:00
closeSharedDialog = () => {
2024-07-18 11:58:42 +08:00
this.setState({ isShareDialogShow: !this.state.isShareDialogShow });
};
2019-04-18 22:36:07 +08:00
onItemDelete = (currentObject, e) => {
2024-07-18 11:58:42 +08:00
e.nativeEvent.stopImmediatePropagation(); // for document event
if (this.props.selectedDirentList.length === 1) {
this.props.onItemDelete(currentObject);
return;
} else {
this.props.onItemsDelete();
}
};
2019-04-18 22:36:07 +08:00
2023-09-14 14:36:58 +08:00
onItemConvert = (currentObject, e, dstType) => {
2024-07-18 11:58:42 +08:00
e.nativeEvent.stopImmediatePropagation(); // for document event
2023-09-14 14:36:58 +08:00
this.props.onItemConvert(currentObject, dstType);
2023-09-18 10:20:47 +08:00
};
2023-09-14 14:36:58 +08:00
exportDocx = () => {
const serviceUrl = window.app.config.serviceURL;
let repoID = this.props.repoID;
let filePath = this.getDirentPath(this.props.dirent);
let exportToDocxUrl = serviceUrl + '/repo/sdoc_export_to_docx/' + repoID + '/?file_path=' + filePath;
window.location.href = exportToDocxUrl;
};
2019-04-18 22:36:07 +08:00
onMenuItemClick = (operation, currentObject, event) => {
hideMenu();
2024-07-18 11:58:42 +08:00
switch (operation) {
case 'Download':
this.onItemsDownload();
2019-04-18 22:36:07 +08:00
break;
case 'Share':
this.onItemShare(event);
break;
case 'Delete':
2019-04-18 22:36:07 +08:00
this.onItemDelete(currentObject, event);
break;
case 'Rename':
this.onItemRenameToggle();
break;
case 'Move':
this.onItemMoveToggle();
break;
case 'Copy':
this.onItemCopyToggle();
break;
2024-04-11 18:26:48 +08:00
case 'Unfreeze Document':
this.onUnlockItem(currentObject);
break;
2023-11-29 16:23:01 +08:00
case 'Freeze Document':
this.onFreezeDocument(currentObject);
break;
2023-09-14 14:36:58 +08:00
case 'Convert to Markdown':
this.onItemConvert(currentObject, event, 'markdown');
break;
case 'Convert to docx':
this.onItemConvert(currentObject, event, 'docx');
break;
case 'Export docx':
this.exportDocx();
break;
2023-09-14 14:36:58 +08:00
case 'Convert to sdoc':
this.onItemConvert(currentObject, event, 'sdoc');
break;
case 'Tags':
this.onEditFileTagToggle();
break;
2019-04-18 22:36:07 +08:00
case 'Permission':
this.onPermissionItem();
break;
case 'Unlock':
this.onUnlockItem(currentObject);
break;
case 'Lock':
this.onLockItem(currentObject);
break;
case 'History':
this.onHistory(currentObject);
break;
case 'New Folder':
this.onCreateFolderToggle(currentObject);
break;
case 'New File':
this.onCreateFileToggle('');
break;
case 'New Markdown File':
this.onCreateFileToggle('.md');
break;
case 'New Excel File':
this.onCreateFileToggle('.xlsx');
break;
case 'New PowerPoint File':
this.onCreateFileToggle('.pptx');
break;
case 'New Word File':
this.onCreateFileToggle('.docx');
break;
case 'New SeaDoc File':
this.onCreateFileToggle('.sdoc');
break;
2019-04-18 22:36:07 +08:00
case 'Access Log':
2019-05-30 16:12:33 +08:00
this.onAccessLog(currentObject);
2019-04-18 22:36:07 +08:00
break;
case 'Properties':
this.props.showDirentDetail('info');
break;
2019-04-18 22:36:07 +08:00
case 'Open via Client':
this.onOpenViaClient(currentObject);
break;
default:
break;
}
};
2019-04-18 22:36:07 +08:00
onDirentsMenuItemClick = (operation) => {
switch (operation) {
case 'Move':
this.onMoveToggle();
break;
case 'Copy':
this.onCopyToggle();
break;
case 'Download':
this.onItemsDownload();
break;
case 'Delete':
this.props.onItemsDelete();
break;
default:
break;
}
hideMenu();
};
onEditFileTagToggle = () => {
this.setState({
isEditFileTagShow: !this.state.isEditFileTagShow
});
};
onFileTagChanged = () => {
let dirent = this.state.activeDirent ? this.state.activeDirent : '';
let direntPath = Utils.joinPath(this.props.path, dirent.name);
this.props.onFileTagChanged(dirent, direntPath);
};
2019-04-18 22:36:07 +08:00
getDirentPath = (dirent) => {
let path = this.props.path;
return path === '/' ? path + dirent.name : path + '/' + dirent.name;
};
2019-04-18 22:36:07 +08:00
closeZipDialog = () => {
this.setState({
isZipDialogOpen: false
});
};
2019-04-18 22:36:07 +08:00
onItemsDownload = () => {
let { path, repoID, selectedDirentList } = this.props;
if (selectedDirentList.length === 1 && !selectedDirentList[0].isDir()) {
let direntPath = Utils.joinPath(path, selectedDirentList[0].name);
2024-07-18 11:58:42 +08:00
let url = URLDecorator.getUrl({ type: 'download_file_url', repoID: repoID, filePath: direntPath });
2019-04-18 22:36:07 +08:00
location.href = url;
return;
2019-04-18 22:36:07 +08:00
}
let selectedDirentNames = selectedDirentList.map(dirent => {
return dirent.name;
});
this.setState({
isZipDialogOpen: true,
downloadItems: selectedDirentNames
});
};
2019-04-18 22:36:07 +08:00
onCreateFolderToggle = () => {
this.setState({
isCreateFolderDialogShow: !this.state.isCreateFolderDialogShow,
});
};
2019-04-18 22:36:07 +08:00
onItemRenameToggle = () => {
this.setState({
isRenameDialogShow: !this.state.isRenameDialogShow,
});
};
2019-04-18 22:36:07 +08:00
onItemMoveToggle = () => {
2024-07-18 11:58:42 +08:00
this.setState({ isMoveDialogShow: !this.state.isMoveDialogShow });
};
2019-04-18 22:36:07 +08:00
onItemCopyToggle = () => {
2024-07-18 11:58:42 +08:00
this.setState({ isCopyDialogShow: !this.state.isCopyDialogShow });
};
2019-04-18 22:36:07 +08:00
onPermissionItem = () => {
2024-07-18 11:58:42 +08:00
this.setState({ isPermissionDialogOpen: !this.state.isPermissionDialogOpen });
};
2019-04-18 22:36:07 +08:00
onLockItem = (currentObject) => {
let repoID = this.props.repoID;
let filePath = this.getDirentPath(currentObject);
seafileAPI.lockfile(repoID, filePath).then(() => {
this.props.updateDirent(currentObject, 'is_locked', true);
this.props.updateDirent(currentObject, 'locked_by_me', true);
2019-04-23 10:49:07 +08:00
let lockName = username.split('@');
this.props.updateDirent(currentObject, 'lock_owner_name', lockName[0]);
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
};
2019-04-18 22:36:07 +08:00
2023-11-29 16:23:01 +08:00
onFreezeDocument = (currentObject) => {
let repoID = this.props.repoID;
let filePath = this.getDirentPath(currentObject);
seafileAPI.lockfile(repoID, filePath, -1).then(() => {
this.props.updateDirent(currentObject, 'is_freezed', true);
this.props.updateDirent(currentObject, 'is_locked', true);
this.props.updateDirent(currentObject, 'locked_by_me', true);
let lockName = username.split('@');
this.props.updateDirent(currentObject, 'lock_owner_name', lockName[0]);
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
};
2019-04-18 22:36:07 +08:00
onUnlockItem = (currentObject) => {
let repoID = this.props.repoID;
let filePath = this.getDirentPath(currentObject);
seafileAPI.unlockfile(repoID, filePath).then(() => {
this.props.updateDirent(currentObject, 'is_locked', false);
this.props.updateDirent(currentObject, 'locked_by_me', false);
2019-04-23 10:49:07 +08:00
this.props.updateDirent(currentObject, 'lock_owner_name', '');
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
2019-04-18 22:36:07 +08:00
});
};
2019-04-18 22:36:07 +08:00
onHistory = (currentObject) => {
let repoID = this.props.repoID;
let filePath = this.getDirentPath(currentObject);
2024-07-18 11:58:42 +08:00
let url = URLDecorator.getUrl({ type: 'file_revisions', repoID: repoID, filePath: filePath });
2019-04-18 22:36:07 +08:00
location.href = url;
};
2019-05-30 16:12:33 +08:00
onAccessLog = (currentObject) => {
let filePath = this.getDirentPath(currentObject);
let path = siteRoot + 'repo/file-access/' + this.props.repoID + '/?p=' + encodeURIComponent(filePath) ;
window.open(path);
};
2019-04-18 22:36:07 +08:00
onOpenViaClient = (currentObject) => {
let repoID = this.props.repoID;
let filePath = this.getDirentPath(currentObject);
2024-07-18 11:58:42 +08:00
let url = URLDecorator.getUrl({ type: 'open_via_client', repoID: repoID, filePath: filePath });
2019-04-18 22:36:07 +08:00
location.href = url;
};
2019-04-18 22:36:07 +08:00
onItemRename = (newName) => {
2019-05-13 11:55:49 +08:00
this.props.onItemRename(this.state.activeDirent, newName);
};
2019-04-18 22:36:07 +08:00
prepareImageItem = (item) => {
const name = item.name;
const repoID = this.props.repoID;
const path = Utils.encodePath(Utils.joinPath(this.props.path, name));
const src = `${siteRoot}repo/${repoID}/raw${path}`;
2019-04-18 22:36:07 +08:00
return {
'name': name,
'url': `${siteRoot}lib/${repoID}/file${path}`,
'src': src
};
};
2019-04-18 22:36:07 +08:00
showImagePopup = (curItem) => {
let items = this.props.fullDirentList.filter((item) => {
2019-04-18 22:36:07 +08:00
return Utils.imageCheck(item.name);
});
const imageItems = items.map((item) => {
return this.prepareImageItem(item);
});
this.setState({
isImagePopupOpen: true,
imageItems: imageItems,
imageIndex: items.indexOf(curItem)
});
};
2019-04-18 22:36:07 +08:00
closeImagePopup = () => {
2024-07-18 11:58:42 +08:00
this.setState({ isImagePopupOpen: false });
};
2019-04-18 22:36:07 +08:00
moveToPrevImage = () => {
const imageItemsLength = this.state.imageItems.length;
this.setState((prevState) => ({
imageIndex: (prevState.imageIndex + imageItemsLength - 1) % imageItemsLength
}));
};
2019-04-18 22:36:07 +08:00
moveToNextImage = () => {
const imageItemsLength = this.state.imageItems.length;
this.setState((prevState) => ({
imageIndex: (prevState.imageIndex + 1) % imageItemsLength
}));
};
2019-04-18 22:36:07 +08:00
checkDuplicatedName = (newName) => {
return Utils.checkDuplicatedNameInList(this.props.direntList, newName);
};
2019-04-18 22:36:07 +08:00
// common contextmenu handle
onMouseDown = (event) => {
event.stopPropagation();
if (event.button === 2) {
return;
}
};
onGridContainerMouseDown = (event) => {
2019-05-13 11:55:49 +08:00
this.onMouseDown(event);
};
onGridItemMouseDown = (event) => {
this.onMouseDown(event);
};
2019-04-18 22:36:07 +08:00
gridContainerClick = () => {
2023-05-18 17:46:59 +08:00
hideMenu();
2019-04-18 22:36:07 +08:00
if (!this.props.isDirentDetailShow) {
2019-04-22 09:57:33 +08:00
this.onGridItemClick(null);
2019-04-18 22:36:07 +08:00
}
};
2019-04-22 11:34:51 +08:00
onGridContainerContextMenu = (event) => {
event.preventDefault();
const hasCustomPermission = (action) => {
const { isCustomPermission, customPermission } = Utils.getUserPermission(this.props.userPerm);
if (isCustomPermission) {
return customPermission.permission[action];
}
return true;
};
if (!['admin', 'rw'].includes(this.props.userPerm)) return;
const {
NEW_FOLDER, NEW_FILE,
NEW_MARKDOWN_FILE,
NEW_EXCEL_FILE,
NEW_POWERPOINT_FILE,
NEW_WORD_FILE,
NEW_SEADOC_FILE
} = TextTranslation;
let direntsContainerMenuList = [
NEW_FOLDER, NEW_FILE, 'Divider',
NEW_MARKDOWN_FILE,
NEW_EXCEL_FILE,
NEW_POWERPOINT_FILE,
NEW_WORD_FILE
];
const { currentRepoInfo, selectedDirentList } = this.props;
if (enableSeadoc && !currentRepoInfo.encrypted) {
direntsContainerMenuList.push(NEW_SEADOC_FILE);
}
if (selectedDirentList.length === 0) {
if (!hasCustomPermission('create')) return;
this.handleContextClick(event, DIRENT_GRID_CONTAINER_MENU_ID, direntsContainerMenuList);
} else if (selectedDirentList.length === 1) {
if (!this.state.activeDirent) {
let menuList = Utils.getDirentOperationList(this.isRepoOwner, currentRepoInfo, selectedDirentList[0], true);
this.handleContextClick(event, GRID_ITEM_CONTEXTMENU_ID, menuList, selectedDirentList[0]);
} else {
this.onDirentClick(null);
event.persist();
if (!hasCustomPermission('modify')) return;
setTimeout(() => {
this.handleContextClick(event, DIRENT_GRID_CONTAINER_MENU_ID, direntsContainerMenuList);
}, 0);
}
} else {
let menuList = [];
if (!hasCustomPermission('modify') && !hasCustomPermission('copy') && !hasCustomPermission('download') && !hasCustomPermission('delete')) return;
['move', 'copy', 'download', 'delete'].forEach(action => {
if (hasCustomPermission(action)) {
menuList.push(TextTranslation[action.toUpperCase()]);
}
});
this.handleContextClick(event, DIRENTS_MENU_ID, menuList);
}
};
2019-04-18 22:36:07 +08:00
2019-04-22 11:34:51 +08:00
onGridItemContextMenu = (event, dirent) => {
if (this.props.selectedDirentList.length > 1) return;
// Display menu items according to the current dirent permission
const menuList = this.getDirentItemMenuList(dirent, true);
this.handleContextClick(event, GRID_ITEM_CONTEXTMENU_ID, menuList, dirent);
this.props.onGridItemClick && this.props.onGridItemClick(dirent);
};
handleContextClick = (event, id, menuList, currentObject = null) => {
2019-04-18 22:36:07 +08:00
event.preventDefault();
event.stopPropagation();
let x = event.clientX || (event.touches && event.touches[0].pageX);
let y = event.clientY || (event.touches && event.touches[0].pageY);
if (this.props.posX) {
2019-05-13 11:55:49 +08:00
x -= this.props.posX;
2019-04-18 22:36:07 +08:00
}
if (this.props.posY) {
2019-05-13 11:55:49 +08:00
y -= this.props.posY;
2019-04-18 22:36:07 +08:00
}
hideMenu();
2024-07-18 11:58:42 +08:00
this.setState({ activeDirent: currentObject });
2019-04-18 22:36:07 +08:00
let showMenuConfig = {
id: id,
2019-04-18 22:36:07 +08:00
position: { x, y },
target: event.target,
currentObject: currentObject,
menuList: menuList,
};
2019-06-21 14:22:45 +08:00
if (menuList.length === 0) {
return;
}
2019-04-18 22:36:07 +08:00
showMenu(showMenuConfig);
};
2019-04-18 22:36:07 +08:00
getDirentItemMenuList = (dirent, isContextmenu) => {
const isRepoOwner = this.isRepoOwner;
const currentRepoInfo = this.props.currentRepoInfo;
return Utils.getDirentOperationList(isRepoOwner, currentRepoInfo, dirent, isContextmenu);
};
2019-04-18 22:36:07 +08:00
render() {
let { direntList, selectedDirentList, path } = this.props;
2019-04-22 09:57:33 +08:00
let dirent = this.state.activeDirent ? this.state.activeDirent : '';
2019-04-18 22:36:07 +08:00
let direntPath = Utils.joinPath(path, dirent.name);
if (this.props.isDirentListLoading) {
return (<Loading />);
}
2019-04-18 22:36:07 +08:00
return (
<Fragment>
2019-04-22 11:34:51 +08:00
<ul className="grid-view" onClick={this.gridContainerClick} onContextMenu={this.onGridContainerContextMenu} onMouseDown={this.onGridContainerMouseDown}>
2019-04-18 22:36:07 +08:00
{
direntList.length !== 0 && direntList.map((dirent, index) => {
return (
<DirentGridItem
key={index}
dirent={dirent}
repoID={this.props.repoID}
path={this.props.path}
onItemClick={this.props.onItemClick}
currentRepoInfo={this.props.currentRepoInfo}
showImagePopup={this.showImagePopup}
2019-04-22 11:34:51 +08:00
onGridItemContextMenu={this.onGridItemContextMenu}
2019-04-18 22:36:07 +08:00
onItemMove={this.props.onItemMove}
onGridItemMouseDown={this.onGridItemMouseDown}
2019-04-21 20:41:14 +08:00
onGridItemClick={this.onGridItemClick}
activeDirent={this.state.activeDirent}
2019-04-18 22:36:07 +08:00
/>
2019-05-13 11:55:49 +08:00
);
2019-04-18 22:36:07 +08:00
})
}
</ul>
<ContextMenu
id={GRID_ITEM_CONTEXTMENU_ID}
2019-04-18 22:36:07 +08:00
onMenuItemClick={this.onMenuItemClick}
getMenuContainerSize={this.props.getMenuContainerSize}
2019-04-18 22:36:07 +08:00
/>
<ContextMenu
id={DIRENT_GRID_CONTAINER_MENU_ID}
onMenuItemClick={this.onMenuItemClick}
getMenuContainerSize={this.props.getMenuContainerSize}
/>
<ContextMenu
id={DIRENTS_MENU_ID}
onMenuItemClick={this.onDirentsMenuItemClick}
getMenuContainerSize={this.props.getMenuContainerSize}
/>
{this.state.isCreateFolderDialogShow && (
<ModalPortal>
<CreateFolder
parentPath={this.props.path}
onAddFolder={this.onAddFolder}
checkDuplicatedName={this.checkDuplicatedName}
addFolderCancel={this.onCreateFolderToggle}
/>
</ModalPortal>
)}
{this.state.isCreateFileDialogShow && (
<ModalPortal>
<CreateFile
parentPath={this.props.path}
fileType={this.state.fileType}
onAddFile={this.props.onAddFile}
checkDuplicatedName={this.checkDuplicatedName}
toggleDialog={this.onCreateFileToggle}
/>
</ModalPortal>
)}
{this.state.isMoveDialogShow &&
<MoveDirentDialog
2019-04-18 22:36:07 +08:00
path={this.props.path}
repoID={this.props.repoID}
repoEncrypted={this.props.currentRepoInfo.encrypted}
isMutipleOperation={this.state.isMutipleOperation}
selectedDirentList={selectedDirentList}
onItemsMove={this.props.onItemsMove}
2019-04-18 22:36:07 +08:00
onCancelMove={this.onMoveToggle}
2019-04-22 09:57:33 +08:00
dirent={this.state.activeDirent}
2019-04-18 22:36:07 +08:00
/>
}
{this.state.isZipDialogOpen &&
<ModalPortal>
<ZipDownloadDialog
repoID={this.props.repoID}
path={this.props.path}
target={this.state.downloadItems}
2019-04-18 22:36:07 +08:00
toggleDialog={this.closeZipDialog}
/>
</ModalPortal>
}
{this.state.isCopyDialogShow &&
<CopyDirentDialog
path={this.props.path}
repoID={this.props.repoID}
repoEncrypted={this.props.currentRepoInfo.encrypted}
isMutipleOperation={this.state.isMutipleOperation}
selectedDirentList={selectedDirentList}
onItemsCopy={this.props.onItemsCopy}
2019-04-18 22:36:07 +08:00
onCancelCopy={this.onCopyToggle}
/>
}
{this.state.isEditFileTagShow &&
<EditFileTagDialog
repoID={this.props.repoID}
fileTagList={dirent.file_tags}
filePath={direntPath}
toggleCancel={this.onEditFileTagToggle}
repoTags={this.props.repoTags}
onFileTagChanged={this.onFileTagChanged}
/>
}
2019-04-18 22:36:07 +08:00
{this.state.isShareDialogShow &&
<ModalPortal>
<ShareDialog
2019-04-18 22:36:07 +08:00
itemType={dirent.type}
itemName={dirent.name}
itemPath={direntPath}
userPerm={dirent.permission}
repoID={this.props.repoID}
repoEncrypted={false}
enableDirPrivateShare={this.props.enableDirPrivateShare}
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
toggleDialog={this.closeSharedDialog}
/>
</ModalPortal>
}
{this.state.isRenameDialogShow && (
<ModalPortal>
<Rename
dirent={selectedDirentList.length > 1 ? selectedDirentList[selectedDirentList.length - 1] : this.state.activeDirent}
2019-04-18 22:36:07 +08:00
onRename={this.onItemRename}
checkDuplicatedName={this.checkDuplicatedName}
toggleCancel={this.onItemRenameToggle}
/>
</ModalPortal>
)}
{this.state.isPermissionDialogOpen &&
<ModalPortal>
<LibSubFolderPermissionDialog
toggleDialog={this.onPermissionItem}
repoID={this.props.repoID}
folderPath={direntPath}
folderName={dirent.name}
isDepartmentRepo={this.props.isGroupOwnedRepo}
/>
</ModalPortal>
}
2019-04-18 22:36:07 +08:00
{this.state.isImagePopupOpen && (
<ModalPortal>
<ImageDialog
imageItems={this.state.imageItems}
imageIndex={this.state.imageIndex}
closeImagePopup={this.closeImagePopup}
moveToPrevImage={this.moveToPrevImage}
moveToNextImage={this.moveToNextImage}
/>
</ModalPortal>
)}
</Fragment>
2019-05-13 11:55:49 +08:00
);
2019-04-18 22:36:07 +08:00
}
}
DirentGridView.propTypes = propTypes;
2019-05-13 11:55:49 +08:00
export default DirentGridView;