mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 07:01:12 +00:00
[dir view] updated 'top operation list' for current active dirent (#4046)
* [dir view] updated 'top operation list' for current active dirent * added `getDirentOperationList` to utils.js * improved code * [dir view] added operations for current active dirent; bugfix & improvement * [utils] rewrote 'get dirent operation list' & bugfix
This commit is contained in:
@@ -474,95 +474,11 @@ 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;
|
||||
|
||||
if (showShareBtn) {
|
||||
contextmenuList = [SHARE];
|
||||
}
|
||||
|
||||
if (dirent.permission === 'rw' || dirent.permission === 'r') {
|
||||
contextmenuList = [...contextmenuList, DOWNLOAD];
|
||||
}
|
||||
|
||||
if (dirent.permission === 'rw') {
|
||||
contextmenuList = [...contextmenuList, DELETE];
|
||||
}
|
||||
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 = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', PERMISSION, 'Divider', OPEN_VIA_CLIENT];
|
||||
} else {
|
||||
menuList = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
if (type === 'dir' && permission === 'r') {
|
||||
menuList = [...contextmenuList];
|
||||
menuList = currentRepoInfo.encrypted ? [...menuList, COPY] : menuList.slice(0, menuList.length - 1);
|
||||
return menuList;
|
||||
}
|
||||
|
||||
if (type === 'file' && permission === 'rw') {
|
||||
menuList = [...contextmenuList];
|
||||
if (!dirent.is_locked || (dirent.is_locked && dirent.locked_by_me)) {
|
||||
menuList.push(RENAME);
|
||||
menuList.push(MOVE);
|
||||
}
|
||||
menuList.push(COPY);
|
||||
menuList.push(TAGS);
|
||||
if (isPro) {
|
||||
if (dirent.is_locked) {
|
||||
if (dirent.locked_by_me || (dirent.lock_owner === 'OnlineOffice' && permission === 'rw')) {
|
||||
menuList.push(UNLOCK);
|
||||
}
|
||||
} else {
|
||||
menuList.push(LOCK);
|
||||
}
|
||||
}
|
||||
menuList.push('Divider');
|
||||
if (enableFileComment) {
|
||||
menuList.push(COMMENT);
|
||||
}
|
||||
menuList.push(HISTORY);
|
||||
if (isPro && fileAuditEnabled) {
|
||||
menuList.push(ACCESS_LOG);
|
||||
}
|
||||
menuList.push('Divider');
|
||||
menuList.push(OPEN_VIA_CLIENT);
|
||||
return menuList;
|
||||
}
|
||||
|
||||
if (type === 'file' && permission === 'r') {
|
||||
menuList = [...contextmenuList];
|
||||
if (!currentRepoInfo.encrypted) {
|
||||
menuList.push(COPY);
|
||||
}
|
||||
if (enableFileComment) {
|
||||
menuList.push(COMMENT);
|
||||
}
|
||||
menuList.push(HISTORY);
|
||||
return menuList;
|
||||
}
|
||||
|
||||
return [];
|
||||
const isRepoOwner = this.isRepoOwner;
|
||||
const currentRepoInfo = this.props.currentRepoInfo;
|
||||
return Utils.getDirentOperationList(isRepoOwner, currentRepoInfo, dirent, isContextmenu);
|
||||
}
|
||||
|
||||
|
||||
onTableDragEnter = (e) => {
|
||||
if (Utils.isIEBrower()) {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user