1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +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:
llj
2019-09-04 14:21:57 +08:00
committed by Daniel Pan
parent 169ee131c9
commit 5c7c13c478
7 changed files with 216 additions and 234 deletions

View File

@@ -66,6 +66,7 @@ class Rename extends React.Component {
this.setState({errMessage: errMessage}); this.setState({errMessage: errMessage});
} else { } else {
this.props.onRename(this.state.newName); this.props.onRename(this.state.newName);
this.props.toggleCancel();
} }
} }
} }
@@ -116,7 +117,7 @@ class Rename extends React.Component {
<ModalHeader toggle={this.toggle}>{type === 'file' ? gettext('Rename File') : gettext('Rename Folder') }</ModalHeader> <ModalHeader toggle={this.toggle}>{type === 'file' ? gettext('Rename File') : gettext('Rename Folder') }</ModalHeader>
<ModalBody> <ModalBody>
<p>{type === 'file' ? gettext('New file name'): gettext('New folder name')}</p> <p>{type === 'file' ? gettext('New file name'): gettext('New folder name')}</p>
<Input onKeyPress={this.handleKeyPress} innerRef={input => {this.newInput = input;}} placeholder="newName" value={this.state.newName} onChange={this.handleChange} /> <Input onKeyPress={this.handleKeyPress} innerRef={input => {this.newInput = input;}} value={this.state.newName} onChange={this.handleChange} />
{this.state.errMessage && <Alert color="danger" className="mt-2">{this.state.errMessage}</Alert>} {this.state.errMessage && <Alert color="danger" className="mt-2">{this.state.errMessage}</Alert>}
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>

View File

@@ -16,7 +16,7 @@ import CopyDirentDialog from '../dialog/copy-dirent-dialog';
import ShareDialog from '../dialog/share-dialog'; import ShareDialog from '../dialog/share-dialog';
import ZipDownloadDialog from '../dialog/zip-download-dialog'; import ZipDownloadDialog from '../dialog/zip-download-dialog';
import EditFileTagDialog from '../dialog/edit-filetag-dialog'; import EditFileTagDialog from '../dialog/edit-filetag-dialog';
import Rename from '../../components/dialog/rename-grid-item-dialog'; import Rename from '../../components/dialog/rename-dirent';
import CreateFile from '../dialog/create-file-dialog'; import CreateFile from '../dialog/create-file-dialog';
import CreateFolder from '../dialog/create-folder-dialog'; import CreateFolder from '../dialog/create-folder-dialog';
import LibSubFolderPermissionDialog from '../dialog/lib-sub-folder-permission-dialog'; import LibSubFolderPermissionDialog from '../dialog/lib-sub-folder-permission-dialog';
@@ -150,7 +150,7 @@ class DirentGridView extends React.Component{
this.onLockItem(currentObject); this.onLockItem(currentObject);
break; break;
case 'Comment': case 'Comment':
this.onComnentItem(); this.onCommentItem();
break; break;
case 'History': case 'History':
this.onHistory(currentObject); this.onHistory(currentObject);
@@ -261,7 +261,7 @@ class DirentGridView extends React.Component{
}); });
} }
onComnentItem = () => { onCommentItem = () => {
this.props.showDirentDetail('comments'); this.props.showDirentDetail('comments');
} }
@@ -286,13 +286,9 @@ class DirentGridView extends React.Component{
} }
onItemRename = (newName) => { onItemRename = (newName) => {
this.setState({
isRenameDialogShow: !this.state.isRenameDialogShow,
});
this.props.onItemRename(this.state.activeDirent, newName); this.props.onItemRename(this.state.activeDirent, newName);
} }
prepareImageItem = (item) => { prepareImageItem = (item) => {
const useThumbnail = !this.repoEncrypted; const useThumbnail = !this.repoEncrypted;
const name = item.name; const name = item.name;
@@ -351,11 +347,7 @@ class DirentGridView extends React.Component{
} }
checkDuplicatedName = (newName) => { checkDuplicatedName = (newName) => {
let direntList = this.props.direntList; return Utils.checkDuplicatedNameInList(this.props.direntList, newName);
let isDuplicated = direntList.some(object => {
return object.name === newName;
});
return isDuplicated;
} }
// common contextmenu handle // common contextmenu handle
@@ -434,93 +426,9 @@ class DirentGridView extends React.Component{
} }
getDirentItemMenuList = (dirent, isContextmenu) => { getDirentItemMenuList = (dirent, isContextmenu) => {
const isRepoOwner = this.isRepoOwner;
let isRepoOwner = this.isRepoOwner; const currentRepoInfo = this.props.currentRepoInfo;
let currentRepoInfo = this.props.currentRepoInfo; return Utils.getDirentOperationList(isRepoOwner, currentRepoInfo, dirent, isContextmenu);
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 [];
} }
render() { render() {

View File

@@ -474,95 +474,11 @@ class DirentListView extends React.Component {
} }
getDirentItemMenuList = (dirent, isContextmenu) => { getDirentItemMenuList = (dirent, isContextmenu) => {
let isRepoOwner = this.isRepoOwner; const isRepoOwner = this.isRepoOwner;
let currentRepoInfo = this.props.currentRepoInfo; const currentRepoInfo = this.props.currentRepoInfo;
let can_set_folder_perm = folderPermEnabled && ((isRepoOwner && currentRepoInfo.has_been_shared_out) || currentRepoInfo.is_admin); return Utils.getDirentOperationList(isRepoOwner, currentRepoInfo, dirent, isContextmenu);
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 [];
} }
onTableDragEnter = (e) => { onTableDragEnter = (e) => {
if (Utils.isIEBrower()) { if (Utils.isIEBrower()) {
return false; return false;

View File

@@ -1,7 +1,7 @@
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Button, ButtonGroup } from 'reactstrap'; import { Button, ButtonGroup } from 'reactstrap';
import { gettext, siteRoot, canGenerateShareLink, isPro, fileAuditEnabled } from '../../utils/constants'; import { gettext, siteRoot, canGenerateShareLink, isPro, fileAuditEnabled, name } from '../../utils/constants';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
import { seafileAPI } from '../../utils/seafile-api'; import { seafileAPI } from '../../utils/seafile-api';
import URLDecorator from '../../utils/url-decorator'; import URLDecorator from '../../utils/url-decorator';
@@ -12,6 +12,9 @@ import ShareDialog from '../dialog/share-dialog';
import RelatedFileDialogs from '../dialog/related-file-dialogs'; import RelatedFileDialogs from '../dialog/related-file-dialogs';
import EditFileTagDialog from '../dialog/edit-filetag-dialog'; import EditFileTagDialog from '../dialog/edit-filetag-dialog';
import ZipDownloadDialog from '../dialog/zip-download-dialog'; import ZipDownloadDialog from '../dialog/zip-download-dialog';
import Rename from '../dialog/rename-dirent';
import LibSubFolderPermissionDialog from '../dialog/lib-sub-folder-permission-dialog';
import ModalPortal from '../modal-portal'; import ModalPortal from '../modal-portal';
import ItemDropdownMenu from '../dropdown-menu/item-dropdown-menu'; import ItemDropdownMenu from '../dropdown-menu/item-dropdown-menu';
import toaster from '../toast'; import toaster from '../toast';
@@ -51,6 +54,8 @@ class MultipleDirOperationToolbar extends React.Component {
multiFileTagList: [], multiFileTagList: [],
showRelatedFileDialog: false, showRelatedFileDialog: false,
viewMode: 'list_related_file', viewMode: 'list_related_file',
isRenameDialogOpen: false,
isPermissionDialogOpen: false
}; };
} }
@@ -87,57 +92,63 @@ class MultipleDirOperationToolbar extends React.Component {
}); });
} }
checkDuplicatedName = (newName) => {
return Utils.checkDuplicatedNameInList(this.props.direntList, newName);
}
onItemRename = (newName) => {
const dirent = this.props.selectedDirentList[0];
this.props.onItemRename(dirent, newName);
}
onPermissionItem = () => {
this.setState({
showLibContentViewDialogs: !this.state.showLibContentViewDialogs,
isPermissionDialogOpen: !this.state.isPermissionDialogOpen
});
}
onCommentItem = () => {
this.props.showDirentDetail('comments');
}
getDirentMenuList = (dirent) => { getDirentMenuList = (dirent) => {
let menuList = []; const isRepoOwner = this.props.isRepoOwner;
let currentRepoInfo = this.props.currentRepoInfo; const currentRepoInfo = this.props.currentRepoInfo;
let showShareBtn = Utils.isHasPermissionToShare(currentRepoInfo, dirent.permission, dirent); const isContextmenu = true;
let opList = Utils.getDirentOperationList(isRepoOwner, currentRepoInfo, dirent, isContextmenu);
const { SHARE, TAGS, RELATED_FILES, HISTORY, ACCESS_LOG, OPEN_VIA_CLIENT, LOCK, UNLOCK } = TextTranslation; const list = ['Move', 'Copy', 'Delete', 'Download'];
if (dirent.type == 'dir') {
if (dirent.type === 'dir') { opList = opList.filter((item, index) => {
if (showShareBtn) { return list.indexOf(item.key) == -1 && item != 'Divider';
menuList = [SHARE]; });
} } else {
return menuList; opList = opList.filter((item, index) => {
} return list.indexOf(item.key) == -1;
});
if (dirent.type === 'file') {
let shareBtn = showShareBtn ? [SHARE] : [];
menuList = [...shareBtn, TAGS, RELATED_FILES, 'Divider', HISTORY, ACCESS_LOG, 'Divider', OPEN_VIA_CLIENT];
if (!Utils.isMarkdownFile(dirent.name)) {
menuList = menuList.filter(menu => {
return menu !== RELATED_FILES;
});
}
if (!isPro || !fileAuditEnabled) {
menuList = menuList.filter(menu => {
return menu !== ACCESS_LOG;
});
}
if (isPro) {
if (dirent.is_locked) {
if (dirent.locked_by_me || (dirent.lock_owner === 'OnlineOffice' && currentRepoInfo.permission === 'rw')) {
menuList.splice(1, 0, UNLOCK);
}
} else {
menuList.splice(1, 0, LOCK);
}
}
return menuList;
} }
return opList;
} }
onMenuItemClick = (operation) => { onMenuItemClick = (operation) => {
const dirents = this.props.selectedDirentList; const dirents = this.props.selectedDirentList;
const dirent = dirents[0]; const dirent = dirents[0];
switch(operation) { switch (operation) {
case 'Share': case 'Share':
this.setState({ this.setState({
showLibContentViewDialogs: true, showLibContentViewDialogs: true,
showShareDialog: true, showShareDialog: true,
}); });
break; break;
case 'Rename':
this.setState({
showLibContentViewDialogs: true,
isRenameDialogOpen: true
});
break;
case 'Permission':
this.onPermissionItem();
break;
case 'Tags': case 'Tags':
this.listFileTags(dirent); this.listFileTags(dirent);
break; break;
@@ -147,6 +158,9 @@ class MultipleDirOperationToolbar extends React.Component {
case 'Unlock': case 'Unlock':
this.unlockFile(dirent); this.unlockFile(dirent);
break; break;
case 'Comment':
this.onCommentItem();
break;
case 'Related Files': case 'Related Files':
this.openRelatedFilesDialog(dirent); this.openRelatedFilesDialog(dirent);
break; break;
@@ -170,6 +184,7 @@ class MultipleDirOperationToolbar extends React.Component {
if (res.data.is_locked) { if (res.data.is_locked) {
this.props.updateDirent(dirent, 'is_locked', true); this.props.updateDirent(dirent, 'is_locked', true);
this.props.updateDirent(dirent, 'locked_by_me', true); this.props.updateDirent(dirent, 'locked_by_me', true);
this.props.updateDirent(dirent, 'lock_owner_name', name);
this.props.unSelectDirent(); this.props.unSelectDirent();
} }
}).catch(error => { }).catch(error => {
@@ -184,6 +199,7 @@ class MultipleDirOperationToolbar extends React.Component {
if (!res.data.is_locked) { if (!res.data.is_locked) {
this.props.updateDirent(dirent, 'is_locked', false); this.props.updateDirent(dirent, 'is_locked', false);
this.props.updateDirent(dirent, 'locked_by_me', false); this.props.updateDirent(dirent, 'locked_by_me', false);
this.props.updateDirent(dirent, 'lock_owner_name', '');
this.props.unSelectDirent(); this.props.unSelectDirent();
} }
}).catch(error => { }).catch(error => {
@@ -200,7 +216,6 @@ class MultipleDirOperationToolbar extends React.Component {
filePath: filePath filePath: filePath
}); });
location.href = url; location.href = url;
this.props.unSelectDirent();
} }
onHistory = (dirent) => { onHistory = (dirent) => {
@@ -250,6 +265,8 @@ class MultipleDirOperationToolbar extends React.Component {
showShareDialog: false, showShareDialog: false,
showEditFileTagDialog: false, showEditFileTagDialog: false,
showRelatedFileDialog: false, showRelatedFileDialog: false,
isRenameDialogOpen: false,
isPermissionDialogOpen: false,
}); });
} }
@@ -304,7 +321,9 @@ class MultipleDirOperationToolbar extends React.Component {
render() { render() {
const { repoID, userPerm } = this.props; const { repoID, userPerm } = this.props;
let direntPath = this.getDirentPath(this.props.selectedDirentList[0]); const dirent = this.props.selectedDirentList[0];
let direntPath = this.getDirentPath(dirent);
if (userPerm !== 'rw' && userPerm !== 'admin') { if (userPerm !== 'rw' && userPerm !== 'admin') {
return ''; return '';
@@ -366,18 +385,39 @@ class MultipleDirOperationToolbar extends React.Component {
{this.state.showShareDialog && {this.state.showShareDialog &&
<ModalPortal> <ModalPortal>
<ShareDialog <ShareDialog
itemType={this.props.selectedDirentList[0].type} itemType={dirent.type}
itemName={this.props.selectedDirentList[0].name} itemName={dirent.name}
itemPath={direntPath} itemPath={direntPath}
userPerm={this.props.selectedDirentList[0].permission} userPerm={dirent.permission}
repoID={repoID} repoID={repoID}
repoEncrypted={false} repoEncrypted={false}
enableDirPrivateShare={this.props.enableDirPrivateShare} enableDirPrivateShare={this.props.enableDirPrivateShare}
isGroupOwnedRepo={this.state.isGroupOwnedRepo} isGroupOwnedRepo={this.props.isGroupOwnedRepo}
toggleDialog={this.toggleCancel} toggleDialog={this.toggleCancel}
/> />
</ModalPortal> </ModalPortal>
} }
{this.state.isRenameDialogOpen &&
<ModalPortal>
<Rename
dirent={dirent}
onRename={this.onItemRename}
checkDuplicatedName={this.checkDuplicatedName}
toggleCancel={this.toggleCancel}
/>
</ModalPortal>
}
{this.state.isPermissionDialogOpen &&
<ModalPortal>
<LibSubFolderPermissionDialog
toggleDialog={this.toggleCancel}
repoID={repoID}
folderPath={direntPath}
folderName={dirent.name}
isDepartmentRepo={this.props.isGroupOwnedRepo}
/>
</ModalPortal>
}
{this.state.showEditFileTagDialog && {this.state.showEditFileTagDialog &&
<ModalPortal> <ModalPortal>
<EditFileTagDialog <EditFileTagDialog

View File

@@ -95,9 +95,11 @@ class LibContentToolbar extends React.Component {
userPerm={this.props.userPerm} userPerm={this.props.userPerm}
repoEncrypted={this.props.repoEncrypted} repoEncrypted={this.props.repoEncrypted}
selectedDirentList={this.props.selectedDirentList} selectedDirentList={this.props.selectedDirentList}
direntList={this.props.direntList}
onItemsMove={this.props.onItemsMove} onItemsMove={this.props.onItemsMove}
onItemsCopy={this.props.onItemsCopy} onItemsCopy={this.props.onItemsCopy}
onItemsDelete={this.props.onItemsDelete} onItemsDelete={this.props.onItemsDelete}
onItemRename={this.props.onItemRename}
isRepoOwner={this.props.isRepoOwner} isRepoOwner={this.props.isRepoOwner}
currentRepoInfo={this.props.currentRepoInfo} currentRepoInfo={this.props.currentRepoInfo}
enableDirPrivateShare={this.props.enableDirPrivateShare} enableDirPrivateShare={this.props.enableDirPrivateShare}
@@ -106,6 +108,8 @@ class LibContentToolbar extends React.Component {
unSelectDirent={this.props.unSelectDirent} unSelectDirent={this.props.unSelectDirent}
onFilesTagChanged={this.props.onFilesTagChanged} onFilesTagChanged={this.props.onFilesTagChanged}
showShareBtn={this.props.showShareBtn} showShareBtn={this.props.showShareBtn}
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
showDirentDetail={this.props.showDirentDetail}
/> : /> :
<DirOperationToolBar <DirOperationToolBar
path={this.props.path} path={this.props.path}

View File

@@ -1653,6 +1653,7 @@ class LibContentView extends React.Component {
onItemsMove={this.onMoveItems} onItemsMove={this.onMoveItems}
onItemsCopy={this.onCopyItems} onItemsCopy={this.onCopyItems}
onItemsDelete={this.onDeleteItems} onItemsDelete={this.onDeleteItems}
onItemRename={this.onMainPanelItemRename}
direntList={this.state.direntList} direntList={this.state.direntList}
repoName={this.state.repoName} repoName={this.state.repoName}
repoEncrypted={this.state.repoEncrypted} repoEncrypted={this.state.repoEncrypted}

View File

@@ -1,5 +1,6 @@
import { mediaUrl, gettext, serviceURL, siteRoot, canGenerateShareLink, canGenerateUploadLink, username } from './constants'; import { mediaUrl, gettext, serviceURL, siteRoot, isPro, enableFileComment, fileAuditEnabled, canGenerateShareLink, canGenerateUploadLink, username, folderPermEnabled } from './constants';
import { strChineseFirstPY } from './pinyin-by-unicode'; import { strChineseFirstPY } from './pinyin-by-unicode';
import TextTranslation from './text-translation';
export const Utils = { export const Utils = {
@@ -137,6 +138,12 @@ export const Utils = {
} }
}, },
checkDuplicatedNameInList: function(list, targetName) {
return list.some(object => {
return object.name === targetName;
});
},
encodePath: function(path) { encodePath: function(path) {
// IE8 does not support 'map()' // IE8 does not support 'map()'
/* /*
@@ -377,6 +384,111 @@ export const Utils = {
return title; return title;
}, },
getFolderOperationList: function(isRepoOwner, currentRepoInfo, dirent, isContextmenu) {
let list = [];
const { SHARE, DOWNLOAD, DELETE, RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT } = TextTranslation;
const permission = dirent.permission;
if (isContextmenu) {
if (permission == 'rw' || permission == 'r') {
list.push(DOWNLOAD);
}
if (Utils.isHasPermissionToShare(currentRepoInfo, permission, dirent)) {
list.push(SHARE);
}
if (permission == 'rw') {
list.push(DELETE, 'Divider');
}
}
if (permission == 'rw') {
list.push(RENAME, MOVE, COPY);
if (folderPermEnabled && ((isRepoOwner && currentRepoInfo.has_been_shared_out) || currentRepoInfo.is_admin)) {
list.push('Divider', PERMISSION);
}
list.push('Divider', OPEN_VIA_CLIENT);
}
if (permission == 'r' && !currentRepoInfo.encrypted) {
list.push(COPY);
}
return list;
},
getFileOperationList: function(currentRepoInfo, dirent, isContextmenu) {
let list = [];
const { SHARE, DOWNLOAD, DELETE, RENAME, MOVE, COPY, TAGS, UNLOCK, LOCK,
COMMENT, HISTORY, ACCESS_LOG, OPEN_VIA_CLIENT } = TextTranslation;
const permission = dirent.permission;
if (isContextmenu) {
if (permission == 'rw' || permission == 'r') {
list.push(DOWNLOAD);
}
if (Utils.isHasPermissionToShare(currentRepoInfo, permission, dirent)) {
list.push(SHARE);
}
if (permission == 'rw') {
if (!dirent.is_locked || (dirent.is_locked && dirent.locked_by_me)) {
list.push(DELETE);
}
}
list.push('Divider');
}
if (permission == 'rw') {
if (!dirent.is_locked || (dirent.is_locked && dirent.locked_by_me)) {
list.push(RENAME, MOVE);
}
list.push(COPY, TAGS);
if (isPro) {
if (dirent.is_locked) {
if (dirent.locked_by_me || dirent.lock_owner == 'OnlineOffice') {
list.push(UNLOCK);
}
} else {
list.push(LOCK);
}
}
list.push('Divider');
if (enableFileComment) {
list.push(COMMENT);
}
list.push(HISTORY);
if (isPro && fileAuditEnabled) {
list.push(ACCESS_LOG);
}
list.push('Divider', OPEN_VIA_CLIENT);
}
if (permission == 'r') {
if (!currentRepoInfo.encrypted) {
list.push(COPY);
}
if (enableFileComment) {
list.push(COMMENT);
}
list.push(HISTORY);
}
return list;
},
getDirentOperationList: function(isRepoOwner, currentRepoInfo, dirent, isContextmenu) {
return dirent.type == 'dir' ?
Utils.getFolderOperationList(isRepoOwner, currentRepoInfo, dirent, isContextmenu) :
Utils.getFileOperationList(currentRepoInfo, dirent, isContextmenu);
},
sharePerms: function(permission) { sharePerms: function(permission) {
var title; var title;
switch(permission) { switch(permission) {