diff --git a/frontend/package-lock.json b/frontend/package-lock.json index ddd9deb935..dbe576b751 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -2693,41 +2693,139 @@ } } }, - "browser-sync": { - "version": "2.26.7", - "resolved": "https://registry.npmjs.org/browser-sync/-/browser-sync-2.26.7.tgz", - "integrity": "sha512-lY3emme0OyvA2ujEMpRmyRy9LY6gHLuTr2/ABxhIm3lADOiRXzP4dgekvnDrQqZ/Ec2Fz19lEjm6kglSG5766w==", + "browserify-aes": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.1.1.tgz", + "integrity": "sha512-UGnTYAnB2a3YuYKIRy1/4FB2HdM866E0qC46JXvVTYKlBlZlnvfpSfY6OKfXZAkv70eJ2a1SqzpAo5CRhZGDFg==", + "dev": true, "requires": { - "browser-sync-client": "^2.26.6", - "browser-sync-ui": "^2.26.4", - "bs-recipes": "1.3.4", - "bs-snippet-injector": "^2.0.1", - "chokidar": "^2.0.4", - "connect": "3.6.6", - "connect-history-api-fallback": "^1", - "dev-ip": "^1.0.1", - "easy-extender": "^2.3.4", - "eazy-logger": "^3", - "etag": "^1.8.1", - "fresh": "^0.5.2", - "fs-extra": "3.0.1", - "http-proxy": "1.15.2", - "immutable": "^3", - "localtunnel": "1.9.2", - "micromatch": "^3.1.10", - "opn": "5.3.0", - "portscanner": "2.1.1", - "qs": "6.2.3", - "raw-body": "^2.3.2", - "resp-modifier": "6.0.2", - "rx": "4.1.0", - "send": "0.16.2", - "serve-index": "1.9.1", - "serve-static": "1.13.2", - "server-destroy": "1.0.1", - "socket.io": "2.1.1", - "ua-parser-js": "0.7.17", - "yargs": "6.4.0" + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "browserify-cipher": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz", + "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", + "dev": true, + "requires": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "browserify-des": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz", + "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", + "dev": true, + "requires": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1" + } + }, + "browserify-rsa": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", + "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "dev": true, + "requires": { + "bn.js": "^4.1.0", + "randombytes": "^2.0.1" + } + }, + "browserify-sign": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", + "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "dev": true, + "requires": { + "bn.js": "^4.1.1", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.2", + "elliptic": "^6.0.0", + "inherits": "^2.0.1", + "parse-asn1": "^5.0.0" + } + }, + "browserify-zlib": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", + "dev": true, + "requires": { + "pako": "~1.0.5" + } + }, + "browserslist": { + "version": "2.11.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.11.3.tgz", + "integrity": "sha512-yWu5cXT7Av6mVwzWc8lMsJMHWn4xyjSuGYi4IozbVTLUOEYPSagUB8kiMDUHA1fS3zjr8nkxkn9jdvug4BBRmA==", + "requires": { + "caniuse-lite": "^1.0.30000792", + "electron-to-chromium": "^1.3.30" + } + }, + "bser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.0.0.tgz", + "integrity": "sha1-mseNPtXZFYBP2HrLFYvHlxR6Fxk=", + "requires": { + "node-int64": "^0.4.0" + } + }, + "buffer": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", + "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, + "buffer-indexof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-indexof/-/buffer-indexof-1.1.1.tgz", + "integrity": "sha512-4/rOEg86jivtPTeOUUT61jJO1Ya1TrR/OkqCSZDyq84WJh3LuuiphBYJN+fm5xufIk4XAFcEwte/8WzC8If/1g==", + "dev": true + }, + "buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", + "dev": true + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "builtin-status-codes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", + "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", + "dev": true + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", + "dev": true + }, + "caller-callsite": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", + "integrity": "sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ=", + "requires": { + "callsites": "^2.0.0" }, "dependencies": { "anymatch": { @@ -16101,9 +16199,9 @@ } }, "seafile-js": { - "version": "0.2.119", - "resolved": "https://registry.npmjs.org/seafile-js/-/seafile-js-0.2.119.tgz", - "integrity": "sha512-F1Js8luG+1jLTzgUqW3CjYPrDu/XwLkUiZ9ASJ3aE72lDjZnykjdFAn1KWq3QURVwJNSD4S7N2OEndre6j/vGw==", + "version": "0.2.120", + "resolved": "https://registry.npmjs.org/seafile-js/-/seafile-js-0.2.120.tgz", + "integrity": "sha512-3TrYkDTh4tC20S7StCetpu+RTXKQma0EUDrJ1iXjlhA8q0u8H8fiGmdl+nJv0D7fYQE9DydwDVyAZAj7aj0Lew==", "requires": { "axios": "^0.18.0", "form-data": "^2.3.2", diff --git a/frontend/package.json b/frontend/package.json index 325f04cb55..a39cb91a7d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -42,7 +42,7 @@ "react-responsive": "^6.1.2", "react-select": "^2.4.1", "reactstrap": "^6.4.0", - "seafile-js": "^0.2.119", + "seafile-js": "^0.2.120", "socket.io-client": "^2.2.0", "sw-precache-webpack-plugin": "0.11.4", "unified": "^7.0.0", diff --git a/frontend/src/components/dialog/rename-grid-item-dialog.js b/frontend/src/components/dialog/rename-dirent.js similarity index 96% rename from frontend/src/components/dialog/rename-grid-item-dialog.js rename to frontend/src/components/dialog/rename-dirent.js index 7173b497d6..fb4b11799e 100644 --- a/frontend/src/components/dialog/rename-grid-item-dialog.js +++ b/frontend/src/components/dialog/rename-dirent.js @@ -66,6 +66,7 @@ class Rename extends React.Component { this.setState({errMessage: errMessage}); } else { this.props.onRename(this.state.newName); + this.props.toggleCancel(); } } } @@ -116,7 +117,7 @@ class Rename extends React.Component { {type === 'file' ? gettext('Rename File') : gettext('Rename Folder') }

{type === 'file' ? gettext('New file name'): gettext('New folder name')}

- {this.newInput = input;}} placeholder="newName" value={this.state.newName} onChange={this.handleChange} /> + {this.newInput = input;}} value={this.state.newName} onChange={this.handleChange} /> {this.state.errMessage && {this.state.errMessage}}
diff --git a/frontend/src/components/dirent-grid-view/dirent-grid-view.js b/frontend/src/components/dirent-grid-view/dirent-grid-view.js index f676f81e02..a3bfba35aa 100644 --- a/frontend/src/components/dirent-grid-view/dirent-grid-view.js +++ b/frontend/src/components/dirent-grid-view/dirent-grid-view.js @@ -16,7 +16,7 @@ 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-grid-item-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'; @@ -150,7 +150,7 @@ class DirentGridView extends React.Component{ this.onLockItem(currentObject); break; case 'Comment': - this.onComnentItem(); + this.onCommentItem(); break; case 'History': this.onHistory(currentObject); @@ -261,7 +261,7 @@ class DirentGridView extends React.Component{ }); } - onComnentItem = () => { + onCommentItem = () => { this.props.showDirentDetail('comments'); } @@ -286,13 +286,9 @@ class DirentGridView extends React.Component{ } onItemRename = (newName) => { - this.setState({ - isRenameDialogShow: !this.state.isRenameDialogShow, - }); this.props.onItemRename(this.state.activeDirent, newName); } - prepareImageItem = (item) => { const useThumbnail = !this.repoEncrypted; const name = item.name; @@ -351,11 +347,7 @@ class DirentGridView extends React.Component{ } checkDuplicatedName = (newName) => { - let direntList = this.props.direntList; - let isDuplicated = direntList.some(object => { - return object.name === newName; - }); - return isDuplicated; + return Utils.checkDuplicatedNameInList(this.props.direntList, newName); } // common contextmenu handle @@ -434,93 +426,9 @@ class DirentGridView 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); } render() { diff --git a/frontend/src/components/dirent-list-view/dirent-list-view.js b/frontend/src/components/dirent-list-view/dirent-list-view.js index 7468e6df4b..aa89c23c25 100644 --- a/frontend/src/components/dirent-list-view/dirent-list-view.js +++ b/frontend/src/components/dirent-list-view/dirent-list-view.js @@ -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; diff --git a/frontend/src/components/toolbar/multiple-dir-operation-toolbar.js b/frontend/src/components/toolbar/multiple-dir-operation-toolbar.js index 8a593ca871..cb8b0e6e07 100644 --- a/frontend/src/components/toolbar/multiple-dir-operation-toolbar.js +++ b/frontend/src/components/toolbar/multiple-dir-operation-toolbar.js @@ -1,7 +1,7 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; 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 { seafileAPI } from '../../utils/seafile-api'; import URLDecorator from '../../utils/url-decorator'; @@ -12,6 +12,9 @@ import ShareDialog from '../dialog/share-dialog'; import RelatedFileDialogs from '../dialog/related-file-dialogs'; import EditFileTagDialog from '../dialog/edit-filetag-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 ItemDropdownMenu from '../dropdown-menu/item-dropdown-menu'; import toaster from '../toast'; @@ -51,6 +54,8 @@ class MultipleDirOperationToolbar extends React.Component { multiFileTagList: [], showRelatedFileDialog: false, 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) => { - 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') { - if (showShareBtn) { - menuList = [SHARE]; - } - return menuList; - } - - 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; + const isRepoOwner = this.props.isRepoOwner; + const currentRepoInfo = this.props.currentRepoInfo; + const isContextmenu = true; + let opList = Utils.getDirentOperationList(isRepoOwner, currentRepoInfo, dirent, isContextmenu); + const list = ['Move', 'Copy', 'Delete', 'Download']; + if (dirent.type == 'dir') { + opList = opList.filter((item, index) => { + return list.indexOf(item.key) == -1 && item != 'Divider'; + }); + } else { + opList = opList.filter((item, index) => { + return list.indexOf(item.key) == -1; + }); } + return opList; } onMenuItemClick = (operation) => { const dirents = this.props.selectedDirentList; const dirent = dirents[0]; - switch(operation) { + switch (operation) { case 'Share': this.setState({ showLibContentViewDialogs: true, showShareDialog: true, }); break; + case 'Rename': + this.setState({ + showLibContentViewDialogs: true, + isRenameDialogOpen: true + }); + break; + case 'Permission': + this.onPermissionItem(); + break; case 'Tags': this.listFileTags(dirent); break; @@ -147,6 +158,9 @@ class MultipleDirOperationToolbar extends React.Component { case 'Unlock': this.unlockFile(dirent); break; + case 'Comment': + this.onCommentItem(); + break; case 'Related Files': this.openRelatedFilesDialog(dirent); break; @@ -170,6 +184,7 @@ class MultipleDirOperationToolbar extends React.Component { if (res.data.is_locked) { this.props.updateDirent(dirent, 'is_locked', true); this.props.updateDirent(dirent, 'locked_by_me', true); + this.props.updateDirent(dirent, 'lock_owner_name', name); this.props.unSelectDirent(); } }).catch(error => { @@ -184,6 +199,7 @@ class MultipleDirOperationToolbar extends React.Component { if (!res.data.is_locked) { this.props.updateDirent(dirent, 'is_locked', false); this.props.updateDirent(dirent, 'locked_by_me', false); + this.props.updateDirent(dirent, 'lock_owner_name', ''); this.props.unSelectDirent(); } }).catch(error => { @@ -200,7 +216,6 @@ class MultipleDirOperationToolbar extends React.Component { filePath: filePath }); location.href = url; - this.props.unSelectDirent(); } onHistory = (dirent) => { @@ -250,6 +265,8 @@ class MultipleDirOperationToolbar extends React.Component { showShareDialog: false, showEditFileTagDialog: false, showRelatedFileDialog: false, + isRenameDialogOpen: false, + isPermissionDialogOpen: false, }); } @@ -304,7 +321,9 @@ class MultipleDirOperationToolbar extends React.Component { render() { 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') { return ''; @@ -366,18 +385,39 @@ class MultipleDirOperationToolbar extends React.Component { {this.state.showShareDialog && } + {this.state.isRenameDialogOpen && + + + + } + {this.state.isPermissionDialogOpen && + + + + } {this.state.showEditFileTagDialog && : { + return object.name === targetName; + }); + }, + encodePath: function(path) { // IE8 does not support 'map()' /* @@ -377,6 +384,111 @@ export const Utils = { 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) { var title; switch(permission) {