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 a56e1b49c3..7d0ac33394 100644 --- a/frontend/src/components/dirent-grid-view/dirent-grid-view.js +++ b/frontend/src/components/dirent-grid-view/dirent-grid-view.js @@ -1,6 +1,6 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; -import { siteRoot, thumbnailSizeForOriginal, username, isPro, enableFileComment, fileAuditEnabled, folderPermEnabled } from '../../utils/constants'; +import { siteRoot, thumbnailSizeForOriginal, username, isPro, enableFileComment, fileAuditEnabled, folderPermEnabled, canGenerateShareLink } from '../../utils/constants'; import { Utils } from '../../utils/utils'; import { seafileAPI } from '../../utils/seafile-api'; import URLDecorator from '../../utils/url-decorator'; @@ -412,6 +412,10 @@ class DirentGridView extends React.Component{ if (isContextmenu) { let { SHARE, DOWNLOAD, DELETE } = TextTranslation; contextmenuList = this.props.showShareBtn ? [SHARE, DOWNLOAD, DELETE, 'Divider'] : [DOWNLOAD, DELETE, 'Divider']; + + if (dirent.type === 'file') { + contextmenuList = canGenerateShareLink ? [SHARE, DOWNLOAD, DELETE, 'Divider'] : [DOWNLOAD, DELETE, 'Divider'] + } } let { RENAME, MOVE, COPY, PERMISSION, DETAILS, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG } = TextTranslation; diff --git a/frontend/src/components/dirent-list-view/dirent-list-item.js b/frontend/src/components/dirent-list-view/dirent-list-item.js index 9fe750caef..f41be55efe 100644 --- a/frontend/src/components/dirent-list-view/dirent-list-item.js +++ b/frontend/src/components/dirent-list-view/dirent-list-item.js @@ -2,7 +2,7 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import MD5 from 'MD5'; import { UncontrolledTooltip } from 'reactstrap'; -import { gettext, siteRoot, mediaUrl, username } from '../../utils/constants'; +import { gettext, siteRoot, mediaUrl, username, canGenerateShareLink } from '../../utils/constants'; import { Utils } from '../../utils/utils'; import { seafileAPI } from '../../utils/seafile-api'; import URLDecorator from '../../utils/url-decorator'; @@ -412,6 +412,8 @@ class DirentListItem extends React.Component { if (currentRepoInfo.permission === 'cloud-edit' || currentRepoInfo.permission === 'preview') { return ''; } + + let isShowShareBtn = (dirent.type === 'dir' && this.props.showShareBtn) || canGenerateShareLink; return ( @@ -423,7 +425,7 @@ class DirentListItem extends React.Component {
  • - {this.props.showShareBtn && + {isShowShareBtn &&
  • @@ -453,7 +455,7 @@ class DirentListItem extends React.Component {
  • - {this.props.showShareBtn && + {isShowShareBtn &&
  • 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 5b28016eb6..5d824fb659 100644 --- a/frontend/src/components/dirent-list-view/dirent-list-view.js +++ b/frontend/src/components/dirent-list-view/dirent-list-view.js @@ -1,6 +1,6 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; -import { siteRoot, gettext, thumbnailSizeForOriginal, username, isPro, enableFileComment, fileAuditEnabled, folderPermEnabled } from '../../utils/constants'; +import { siteRoot, gettext, thumbnailSizeForOriginal, username, isPro, enableFileComment, fileAuditEnabled, folderPermEnabled, canGenerateShareLink } from '../../utils/constants'; import { Utils } from '../../utils/utils'; import TextTranslation from '../../utils/text-translation'; import { seafileAPI } from '../../utils/seafile-api'; @@ -459,6 +459,10 @@ class DirentListView extends React.Component { if (isContextmenu) { let { SHARE, DOWNLOAD, DELETE } = TextTranslation; contextmenuList = this.props.showShareBtn ? [SHARE, DOWNLOAD, DELETE, 'Divider'] : [DOWNLOAD, DELETE, 'Divider']; + + if (dirent.type === 'file') { + contextmenuList = canGenerateShareLink ? [SHARE, DOWNLOAD, DELETE, 'Divider'] : [DOWNLOAD, DELETE, 'Divider']; + } } let { RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG, TAGS } = TextTranslation; diff --git a/frontend/src/components/toolbar/cdoc-editor-topbar.js b/frontend/src/components/toolbar/cdoc-editor-topbar.js index 99603d44c5..44614be8c6 100644 --- a/frontend/src/components/toolbar/cdoc-editor-topbar.js +++ b/frontend/src/components/toolbar/cdoc-editor-topbar.js @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { gettext } from '../../utils/constants'; +import { gettext, canGenerateShareLink } from '../../utils/constants'; import { IconButton, ButtonGroup, CollabUsersButton } from '@seafile/seafile-editor/dist/components/topbarcomponent/editorToolBar'; import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Tooltip } from 'reactstrap'; import FileInfo from '@seafile/seafile-editor/dist/components/topbarcomponent/file-info'; @@ -62,8 +62,10 @@ class CDOCTopbar extends React.Component { {this.props.collabUsers.length > 0 && } - + } { diff --git a/frontend/src/components/toolbar/markdown-viewer-toolbar.js b/frontend/src/components/toolbar/markdown-viewer-toolbar.js index 2966c16c2e..221e864c0c 100644 --- a/frontend/src/components/toolbar/markdown-viewer-toolbar.js +++ b/frontend/src/components/toolbar/markdown-viewer-toolbar.js @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { gettext } from '../../utils/constants'; +import { gettext, canGenerateShareLink } from '../../utils/constants'; import { IconButton, ButtonGroup, CollabUsersButton } from '@seafile/seafile-editor/dist/components/topbarcomponent/editorToolBar'; import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Tooltip } from 'reactstrap'; import FileInfo from '@seafile/seafile-editor/dist/components/topbarcomponent/file-info'; @@ -77,7 +77,7 @@ class MoreMenu extends React.PureComponent { {(this.props.openDialogs && editorMode === 'rich') && {gettext('Help')} } - {isSmall && {gettext('Share')}} + {isSmall && canGenerateShareLink && {gettext('Share')}} {isSmall && {gettext('Back to parent directory')}} {(isSmall && this.props.showFileHistory) && {gettext('File History')} @@ -141,8 +141,10 @@ class MarkdownViewerToolbar extends React.Component { /> } - + } { diff --git a/frontend/src/components/toolbar/mutilple-dir-operation-toolbar.js b/frontend/src/components/toolbar/mutilple-dir-operation-toolbar.js index b75373da27..9856178cb2 100644 --- a/frontend/src/components/toolbar/mutilple-dir-operation-toolbar.js +++ b/frontend/src/components/toolbar/mutilple-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 } from '../../utils/constants'; +import { gettext, canGenerateShareLink } from '../../utils/constants'; import { Utils, isPro } from '../../utils/utils'; import { seafileAPI } from '../../utils/seafile-api'; import URLDecorator from '../../utils/url-decorator'; @@ -32,6 +32,7 @@ const propTypes = { onFilesTagChanged: PropTypes.func.isRequired, unSelectDirent: PropTypes.func.isRequired, updateDirent: PropTypes.func.isRequired, + showShareBtn: PropTypes.bool.isRequired, }; class MutipleDirOperationToolbar extends React.Component { @@ -92,13 +93,17 @@ class MutipleDirOperationToolbar extends React.Component { const { SHARE, TAGS, RELATED_FILES, HISTORY, OPEN_VIA_CLIENT, LOCK, UNLOCK } = TextTranslation; + if (dirent.type === 'dir') { - menuList = [SHARE]; + let shareBtn = this.props.showShareBtn ? [SHARE] : [] + menuList = [...shareBtn]; return menuList; } if (dirent.type === 'file') { - menuList = [SHARE, TAGS, RELATED_FILES, 'Divider', HISTORY, 'Divider', OPEN_VIA_CLIENT]; + let shareBtn = (this.props.showShareBtn && canGenerateShareLink) ? [SHARE] : []; + + menuList = [...shareBtn, TAGS, RELATED_FILES, 'Divider', HISTORY, 'Divider', OPEN_VIA_CLIENT]; if (!Utils.isMarkdownFile(dirent.name)) { menuList.splice(2, 1); } diff --git a/frontend/src/components/toolbar/view-file-toolbar.js b/frontend/src/components/toolbar/view-file-toolbar.js index f5834c5ba6..b289e330f2 100644 --- a/frontend/src/components/toolbar/view-file-toolbar.js +++ b/frontend/src/components/toolbar/view-file-toolbar.js @@ -2,7 +2,7 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { DropdownToggle, Dropdown, DropdownMenu, DropdownItem, Tooltip} from 'reactstrap'; import { Utils } from '../../utils/utils'; -import { gettext, siteRoot } from '../../utils/constants'; +import { gettext, siteRoot, canGenerateShareLink } from '../../utils/constants'; import { seafileAPI } from '../../utils/seafile-api'; import ModalPotal from '../modal-portal'; import ShareDialog from '../dialog/share-dialog'; @@ -23,6 +23,7 @@ const propTypes = { relatedFiles: PropTypes.array.isRequired, onFileTagChanged: PropTypes.func.isRequired, onRelatedFileChange: PropTypes.func.isRequired, + showShareBtn: PropTypes.bool.isRequired, }; class ViewFileToolbar extends React.Component { @@ -88,7 +89,6 @@ class ViewFileToolbar extends React.Component { let { filePermission } = this.props; let name = Utils.getFileName(this.props.path); let dirent = { name: name }; - return (
    @@ -109,7 +109,9 @@ class ViewFileToolbar extends React.Component { {gettext('More')} - {gettext('Share')} + {this.props.showShareBtn && canGenerateShareLink && + {gettext('Share')} + } {gettext('Tags')} {gettext('Related Files')} diff --git a/frontend/src/pages/lib-content-view/lib-content-toolbar.js b/frontend/src/pages/lib-content-view/lib-content-toolbar.js index 1bda24b038..1aa3ea3e64 100644 --- a/frontend/src/pages/lib-content-view/lib-content-toolbar.js +++ b/frontend/src/pages/lib-content-view/lib-content-toolbar.js @@ -71,6 +71,7 @@ class LibContentToolbar extends React.Component { relatedFiles={this.props.relatedFiles} onFileTagChanged={this.props.onFileTagChanged} onRelatedFileChange={this.props.onRelatedFileChange} + showShareBtn={this.props.showShareBtn} />
    @@ -101,6 +102,7 @@ class LibContentToolbar extends React.Component { relatedFiles={this.props.relatedFiles} unSelectDirent={this.props.unSelectDirent} onFilesTagChanged={this.props.onFilesTagChanged} + showShareBtn={this.props.showShareBtn} /> :