mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 23:48:47 +00:00
@@ -11,7 +11,7 @@ const propTypes = {
|
||||
currentRepoInfo: PropTypes.object.isRequired,
|
||||
repoPermission: PropTypes.bool.isRequired,
|
||||
enableDirPrivateShare: PropTypes.bool.isRequired,
|
||||
userPrem: PropTypes.bool,
|
||||
userPerm: PropTypes.string,
|
||||
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
||||
// tree
|
||||
isTreeDataLoading: PropTypes.bool.isRequired,
|
||||
@@ -46,7 +46,6 @@ const propTypes = {
|
||||
// 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,
|
||||
@@ -197,6 +196,7 @@ class DirColumnView extends React.Component {
|
||||
repoID={this.props.repoID}
|
||||
currentRepoInfo={this.props.currentRepoInfo}
|
||||
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
||||
userPerm={this.props.userPerm}
|
||||
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
||||
isRepoInfoBarShow={this.props.isRepoInfoBarShow}
|
||||
usedRepoTags={this.props.usedRepoTags}
|
||||
@@ -205,7 +205,6 @@ class DirColumnView extends React.Component {
|
||||
updateUsedRepoTags={this.props.updateUsedRepoTags}
|
||||
isDirentListLoading={this.props.isDirentListLoading}
|
||||
direntList={this.props.direntList}
|
||||
showShareBtn={this.props.showShareBtn}
|
||||
sortBy={this.props.sortBy}
|
||||
sortOrder={this.props.sortOrder}
|
||||
sortItems={this.props.sortItems}
|
||||
|
@@ -21,12 +21,12 @@ const propTypes = {
|
||||
onItemCopy: PropTypes.func.isRequired,
|
||||
onRenameNode: PropTypes.func.isRequired,
|
||||
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
||||
userPerm: PropTypes.string,
|
||||
isRepoInfoBarShow: PropTypes.bool.isRequired,
|
||||
isDirentListLoading: PropTypes.bool.isRequired,
|
||||
isDirentDetailShow: PropTypes.bool.isRequired,
|
||||
enableDirPrivateShare: PropTypes.bool.isRequired,
|
||||
updateDirent: PropTypes.func.isRequired,
|
||||
showShareBtn: PropTypes.bool.isRequired,
|
||||
showDirentDetail: PropTypes.func.isRequired,
|
||||
onAddFolder: PropTypes.func.isRequired,
|
||||
onFileTagChanged: PropTypes.func,
|
||||
@@ -63,6 +63,7 @@ class DirGridView extends React.Component {
|
||||
repoID={this.props.repoID}
|
||||
currentRepoInfo={this.props.currentRepoInfo}
|
||||
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
||||
userPerm={this.props.userPerm}
|
||||
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
||||
direntList={this.props.direntList}
|
||||
onAddFile={this.props.onAddFile}
|
||||
@@ -72,7 +73,6 @@ class DirGridView extends React.Component {
|
||||
onItemCopy={this.props.onItemCopy}
|
||||
isDirentListLoading={this.props.isDirentListLoading}
|
||||
updateDirent={this.props.updateDirent}
|
||||
showShareBtn={this.props.showShareBtn}
|
||||
onRenameNode={this.props.onRenameNode}
|
||||
showDirentDetail={this.props.showDirentDetail}
|
||||
onGridItemClick={this.props.onGridItemClick}
|
||||
|
@@ -9,6 +9,7 @@ const propTypes = {
|
||||
repoID: PropTypes.string.isRequired,
|
||||
currentRepoInfo: PropTypes.object.isRequired,
|
||||
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
||||
userPerm: PropTypes.string,
|
||||
enableDirPrivateShare: PropTypes.bool.isRequired,
|
||||
isRepoInfoBarShow: PropTypes.bool.isRequired,
|
||||
usedRepoTags: PropTypes.array.isRequired,
|
||||
@@ -17,7 +18,6 @@ const propTypes = {
|
||||
updateUsedRepoTags: PropTypes.func.isRequired,
|
||||
isDirentListLoading: PropTypes.bool.isRequired,
|
||||
direntList: PropTypes.array.isRequired,
|
||||
showShareBtn: PropTypes.bool.isRequired,
|
||||
sortBy: PropTypes.string.isRequired,
|
||||
sortOrder: PropTypes.string.isRequired,
|
||||
sortItems: PropTypes.func.isRequired,
|
||||
@@ -73,9 +73,9 @@ class DirListView extends React.Component {
|
||||
currentRepoInfo={this.props.currentRepoInfo}
|
||||
repoID={this.props.repoID}
|
||||
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
||||
userPerm={this.props.userPerm}
|
||||
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
||||
direntList={this.props.direntList}
|
||||
showShareBtn={this.props.showShareBtn}
|
||||
sortBy={this.props.sortBy}
|
||||
sortOrder={this.props.sortOrder}
|
||||
sortItems={this.props.sortItems}
|
||||
|
@@ -34,7 +34,7 @@ const propTypes = {
|
||||
onItemClick: PropTypes.func.isRequired,
|
||||
isDirentListLoading: PropTypes.bool.isRequired,
|
||||
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
||||
showShareBtn: PropTypes.bool.isRequired,
|
||||
userPerm: PropTypes.string, // current path's user permission
|
||||
enableDirPrivateShare: PropTypes.bool.isRequired,
|
||||
updateDirent: PropTypes.func.isRequired,
|
||||
isDirentDetailShow: PropTypes.bool.isRequired,
|
||||
@@ -354,12 +354,19 @@ class DirentGridView extends React.Component{
|
||||
}
|
||||
|
||||
onGridContainerContextMenu = (event) => {
|
||||
event.preventDefault();
|
||||
// Display menu items based on the permissions of the current path
|
||||
let permission = this.props.userPerm;
|
||||
if (permission !== 'admin' && permission !== 'rw') {
|
||||
return;
|
||||
}
|
||||
let id = 'dirent-grid-container-menu';
|
||||
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
|
||||
this.handleContextClick(event, id, menuList);
|
||||
}
|
||||
|
||||
onGridItemContextMenu = (event, dirent) => {
|
||||
// Display menu items according to the current dirent permission
|
||||
let id = 'grid-item-contextmenu';
|
||||
let menuList = this.getDirentItemMenuList(dirent, true);
|
||||
this.handleContextClick(event, id, menuList, dirent);
|
||||
@@ -407,12 +414,15 @@ class DirentGridView extends React.Component{
|
||||
|
||||
let type = dirent.type;
|
||||
let permission = dirent.permission;
|
||||
|
||||
let showShareBtn = Utils.isHasPermissionToShare(currentRepoInfo, permission, dirent);
|
||||
let menuList = [];
|
||||
let contextmenuList = [];
|
||||
if (isContextmenu) {
|
||||
let { SHARE, DOWNLOAD, DELETE } = TextTranslation;
|
||||
contextmenuList = this.props.showShareBtn ? [SHARE] : [];
|
||||
|
||||
if (showShareBtn) {
|
||||
contextmenuList = [SHARE];
|
||||
}
|
||||
|
||||
if (dirent.permission === 'rw' || dirent.permission === 'r') {
|
||||
contextmenuList = [...contextmenuList, DOWNLOAD];
|
||||
@@ -422,7 +432,7 @@ class DirentGridView extends React.Component{
|
||||
contextmenuList = [...contextmenuList, DELETE];
|
||||
}
|
||||
|
||||
contextmenuList = [...contextmenuList, 'Divider'];
|
||||
contextmenuList = contextmenuList.length > 0 ? [...contextmenuList, 'Divider'] : [];
|
||||
}
|
||||
|
||||
let { RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG } = TextTranslation;
|
||||
@@ -436,7 +446,8 @@ class DirentGridView extends React.Component{
|
||||
}
|
||||
|
||||
if (type === 'dir' && permission === 'r') {
|
||||
menuList = currentRepoInfo.encrypted ? [...contextmenuList, COPY] : [];
|
||||
menuList = [...contextmenuList];
|
||||
menuList = currentRepoInfo.encrypted ? [...menuList, COPY] : menuList.slice(0, menuList.length - 1);
|
||||
return menuList;
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,6 @@ const propTypes = {
|
||||
path: PropTypes.string.isRequired,
|
||||
repoID: PropTypes.string.isRequired,
|
||||
isItemFreezed: PropTypes.bool.isRequired,
|
||||
showShareBtn: PropTypes.bool.isRequired,
|
||||
dirent: PropTypes.object.isRequired,
|
||||
onItemClick: PropTypes.func.isRequired,
|
||||
freezeItem: PropTypes.func.isRequired,
|
||||
@@ -375,11 +374,12 @@ class DirentListItem extends React.Component {
|
||||
e.dataTransfer.setData('applicaiton/drag-item-info', dragStartItemData);
|
||||
}
|
||||
|
||||
onItemDragEnter = () => {
|
||||
onItemDragEnter = (e) => {
|
||||
if (Utils.isIEBrower()) {
|
||||
return false;
|
||||
}
|
||||
if (this.props.dirent.type === 'dir') {
|
||||
e.stopPropagation();
|
||||
this.setState({isDropTipshow: true});
|
||||
}
|
||||
}
|
||||
@@ -392,10 +392,14 @@ class DirentListItem extends React.Component {
|
||||
e.dataTransfer.dropEffect = 'move';
|
||||
}
|
||||
|
||||
onItemDragLeave = () => {
|
||||
onItemDragLeave = (e) => {
|
||||
if (Utils.isIEBrower()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.props.dirent.type === 'dir') {
|
||||
e.stopPropagation();
|
||||
}
|
||||
this.setState({isDropTipshow: false});
|
||||
}
|
||||
|
||||
@@ -407,6 +411,9 @@ class DirentListItem extends React.Component {
|
||||
if (e.dataTransfer.files.length) { // uploaded files
|
||||
return;
|
||||
}
|
||||
if (this.props.dirent.type === 'dir') {
|
||||
e.stopPropagation();
|
||||
}
|
||||
let dragStartItemData = e.dataTransfer.getData('applicaiton/drag-item-info');
|
||||
dragStartItemData = JSON.parse(dragStartItemData);
|
||||
if (Array.isArray(dragStartItemData)) { //move items
|
||||
@@ -458,10 +465,11 @@ class DirentListItem extends React.Component {
|
||||
}
|
||||
|
||||
renderItemOperation = () => {
|
||||
let { dirent, selectedDirentList, currentRepoInfo, showShareBtn } = this.props;
|
||||
let { dirent, selectedDirentList, currentRepoInfo } = this.props;
|
||||
if (currentRepoInfo.permission === 'cloud-edit' || currentRepoInfo.permission === 'preview') {
|
||||
return '';
|
||||
}
|
||||
let showShareBtn = Utils.isHasPermissionToShare(currentRepoInfo, dirent.permission, dirent);
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
|
@@ -25,7 +25,6 @@ const propTypes = {
|
||||
isAllItemSelected: PropTypes.bool.isRequired,
|
||||
isDirentListLoading: PropTypes.bool.isRequired,
|
||||
direntList: PropTypes.array.isRequired,
|
||||
showShareBtn: PropTypes.bool.isRequired,
|
||||
sortBy: PropTypes.string.isRequired,
|
||||
sortOrder: PropTypes.string.isRequired,
|
||||
sortItems: PropTypes.func.isRequired,
|
||||
@@ -47,6 +46,7 @@ const propTypes = {
|
||||
onFileTagChanged: PropTypes.func,
|
||||
enableDirPrivateShare: PropTypes.bool.isRequired,
|
||||
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
||||
userPerm: PropTypes.string,
|
||||
showDirentDetail: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
@@ -71,6 +71,7 @@ class DirentListView extends React.Component {
|
||||
isListDropTipShow: false,
|
||||
};
|
||||
|
||||
this.enteredCounter = 0; // Determine whether to enter the child element to avoid dragging bubbling bugs。
|
||||
this.isRepoOwner = props.currentRepoInfo.owner_email === username;
|
||||
this.isAdmin = props.currentRepoInfo.is_admin;
|
||||
this.repoEncrypted = props.currentRepoInfo.encrypted;
|
||||
@@ -294,12 +295,6 @@ class DirentListView extends React.Component {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
let currentRepoInfo = this.props.currentRepoInfo;
|
||||
|
||||
if (currentRepoInfo.permission === 'cloud-edit' || currentRepoInfo.permission === 'preview') {
|
||||
return '';
|
||||
}
|
||||
|
||||
let x = event.clientX || (event.touches && event.touches[0].pageX);
|
||||
let y = event.clientY || (event.touches && event.touches[0].pageY);
|
||||
|
||||
@@ -339,6 +334,13 @@ class DirentListView extends React.Component {
|
||||
}
|
||||
|
||||
onContainerContextMenu = (event) => {
|
||||
event.preventDefault();
|
||||
// Display menu items based on the permissions of the current path
|
||||
let permission = this.props.userPerm;
|
||||
if (permission !== 'admin' && permission !== 'rw') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.props.selectedDirentList.length === 0) {
|
||||
let id = 'dirent-container-menu';
|
||||
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
|
||||
@@ -419,6 +421,7 @@ class DirentListView extends React.Component {
|
||||
}
|
||||
|
||||
onItemContextMenu = (event, dirent) => {
|
||||
// Display menu items according to the current dirent permission
|
||||
if (this.props.selectedDirentList.length > 1) {
|
||||
return;
|
||||
}
|
||||
@@ -461,20 +464,23 @@ class DirentListView extends React.Component {
|
||||
}
|
||||
|
||||
getDirentItemMenuList = (dirent, isContextmenu) => {
|
||||
|
||||
let isRepoOwner = this.isRepoOwner;
|
||||
let currentRepoInfo = this.props.currentRepoInfo;
|
||||
let can_set_folder_perm = folderPermEnabled && ((isRepoOwner && currentRepoInfo.has_been_shared_out) || currentRepoInfo.is_admin);
|
||||
|
||||
let type = dirent.type;
|
||||
let permission = dirent.permission;
|
||||
let showShareBtn = Utils.isHasPermissionToShare(currentRepoInfo, permission, dirent);
|
||||
|
||||
let menuList = [];
|
||||
let contextmenuList = [];
|
||||
|
||||
if (isContextmenu) {
|
||||
let { SHARE, DOWNLOAD, DELETE } = TextTranslation;
|
||||
contextmenuList = this.props.showShareBtn ? [SHARE] : [];
|
||||
|
||||
if (showShareBtn) {
|
||||
contextmenuList = [SHARE];
|
||||
}
|
||||
|
||||
if (dirent.permission === 'rw' || dirent.permission === 'r') {
|
||||
contextmenuList = [...contextmenuList, DOWNLOAD];
|
||||
@@ -483,22 +489,22 @@ class DirentListView extends React.Component {
|
||||
if (dirent.permission === 'rw') {
|
||||
contextmenuList = [...contextmenuList, DELETE];
|
||||
}
|
||||
|
||||
contextmenuList = [...contextmenuList, 'Divider'];
|
||||
contextmenuList = contextmenuList.length > 0 ? [...contextmenuList, 'Divider'] : [];
|
||||
}
|
||||
|
||||
let { RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG, TAGS } = TextTranslation;
|
||||
if (type === 'dir' && permission === 'rw') {
|
||||
if (can_set_folder_perm) {
|
||||
menuList = [...menuList, RENAME, MOVE, COPY, 'Divider', PERMISSION, 'Divider', OPEN_VIA_CLIENT];
|
||||
menuList = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', PERMISSION, 'Divider', OPEN_VIA_CLIENT];
|
||||
} else {
|
||||
menuList = [...menuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
|
||||
menuList = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
if (type === 'dir' && permission === 'r') {
|
||||
menuList = currentRepoInfo.encrypted ? [...contextmenuList, COPY] : [];
|
||||
menuList = [...contextmenuList];
|
||||
menuList = currentRepoInfo.encrypted ? [...menuList, COPY] : menuList.slice(0, menuList.length - 1);
|
||||
return menuList;
|
||||
}
|
||||
|
||||
@@ -551,7 +557,8 @@ class DirentListView extends React.Component {
|
||||
if (Utils.isIEBrower()) {
|
||||
return false;
|
||||
}
|
||||
if (e.target.className === 'table-container ') {
|
||||
this.enteredCounter++;
|
||||
if (this.enteredCounter !== 0) {
|
||||
this.setState({isListDropTipShow: true});
|
||||
}
|
||||
}
|
||||
@@ -568,7 +575,8 @@ class DirentListView extends React.Component {
|
||||
if (Utils.isIEBrower()) {
|
||||
return false;
|
||||
}
|
||||
if (e.target.className === 'table-container table-drop-active') {
|
||||
this.enteredCounter--;
|
||||
if (this.enteredCounter === 0) {
|
||||
this.setState({isListDropTipShow: false});
|
||||
}
|
||||
}
|
||||
@@ -578,6 +586,7 @@ class DirentListView extends React.Component {
|
||||
return false;
|
||||
}
|
||||
e.persist();
|
||||
this.enteredCounter = 0;
|
||||
this.setState({isListDropTipShow: false});
|
||||
if (e.dataTransfer.files.length) { // uploaded files
|
||||
return;
|
||||
@@ -587,22 +596,19 @@ class DirentListView extends React.Component {
|
||||
|
||||
let {nodeDirent, nodeParentPath, nodeRootPath} = dragStartItemData;
|
||||
|
||||
if (e.target.className === 'table-container table-drop-active') {
|
||||
|
||||
if (Array.isArray(dragStartItemData)) { //selected items
|
||||
return;
|
||||
}
|
||||
|
||||
if (nodeRootPath === this.props.path || nodeParentPath === this.props.path) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.props.path.indexOf(nodeRootPath) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.onItemMove(this.props.currentRepoInfo, nodeDirent, this.props.path, nodeParentPath);
|
||||
if (Array.isArray(dragStartItemData)) { //selected items
|
||||
return;
|
||||
}
|
||||
|
||||
if (nodeRootPath === this.props.path || nodeParentPath === this.props.path) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.props.path.indexOf(nodeRootPath) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.onItemMove(this.props.currentRepoInfo, nodeDirent, this.props.path, nodeParentPath);
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -659,7 +665,6 @@ class DirentListView extends React.Component {
|
||||
repoEncrypted={this.repoEncrypted}
|
||||
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
||||
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
||||
showShareBtn={this.props.showShareBtn}
|
||||
onItemClick={this.props.onItemClick}
|
||||
onItemRenameToggle={this.onItemRenameToggle}
|
||||
onItemSelected={this.onItemSelected}
|
||||
|
@@ -32,7 +32,6 @@ const propTypes = {
|
||||
onFilesTagChanged: PropTypes.func.isRequired,
|
||||
unSelectDirent: PropTypes.func.isRequired,
|
||||
updateDirent: PropTypes.func.isRequired,
|
||||
showShareBtn: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
class MutipleDirOperationToolbar extends React.Component {
|
||||
@@ -90,18 +89,19 @@ class MutipleDirOperationToolbar extends React.Component {
|
||||
getDirentMenuList = (dirent) => {
|
||||
let menuList = [];
|
||||
let currentRepoInfo = this.props.currentRepoInfo;
|
||||
let showShareBtn = Utils.isHasPermissionToShare(currentRepoInfo, dirent.permission, dirent);
|
||||
|
||||
const { SHARE, TAGS, RELATED_FILES, HISTORY, ACCESS_LOG, OPEN_VIA_CLIENT, LOCK, UNLOCK } = TextTranslation;
|
||||
|
||||
|
||||
if (dirent.type === 'dir') {
|
||||
let shareBtn = this.props.showShareBtn ? [SHARE] : [];
|
||||
menuList = [...shareBtn];
|
||||
if (showShareBtn) {
|
||||
menuList = [SHARE];
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
if (dirent.type === 'file') {
|
||||
let shareBtn = (this.props.showShareBtn && canGenerateShareLink) ? [SHARE] : [];
|
||||
let shareBtn = showShareBtn ? [SHARE] : [];
|
||||
|
||||
menuList = [...shareBtn, TAGS, RELATED_FILES, 'Divider', HISTORY, ACCESS_LOG, 'Divider', OPEN_VIA_CLIENT];
|
||||
if (!Utils.isMarkdownFile(dirent.name)) {
|
||||
|
@@ -198,6 +198,12 @@ class TreeView extends React.Component {
|
||||
}
|
||||
|
||||
onContextMenu = (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
let currentRepoInfo = this.props.currentRepoInfo;
|
||||
if (currentRepoInfo.permission !== 'admin' && currentRepoInfo.permission !== 'rw') {
|
||||
return '';
|
||||
}
|
||||
this.handleContextClick(event);
|
||||
}
|
||||
|
||||
@@ -208,12 +214,6 @@ class TreeView extends React.Component {
|
||||
if (!this.props.isNodeMenuShow) {
|
||||
return;
|
||||
}
|
||||
|
||||
let currentRepoInfo = this.props.currentRepoInfo;
|
||||
|
||||
if (currentRepoInfo.permission === 'cloud-edit' || currentRepoInfo.permission === 'preview') {
|
||||
return '';
|
||||
}
|
||||
|
||||
let x = event.clientX || (event.touches && event.touches[0].pageX);
|
||||
let y = event.clientY || (event.touches && event.touches[0].pageY);
|
||||
|
Reference in New Issue
Block a user