diff --git a/frontend/src/components/dialog/share-dialog.js b/frontend/src/components/dialog/share-dialog.js index cd81785fa8..990abf4481 100644 --- a/frontend/src/components/dialog/share-dialog.js +++ b/frontend/src/components/dialog/share-dialog.js @@ -51,14 +51,22 @@ class ShareDialog extends React.Component { } getInitialActiveTab = () => { - const { repoEncrypted, userPerm, enableDirPrivateShare } = this.props; + let { repoEncrypted, userPerm, enableDirPrivateShare, itemType } = this.props; const enableShareLink = !repoEncrypted && canGenerateShareLink; const enableUploadLink = !repoEncrypted && canGenerateUploadLink && userPerm == 'rw'; + // for encrypted repo, 'dir private share' is only enabled for the repo itself, + // not for the folders in it. + if (repoEncrypted) { + enableDirPrivateShare = itemType == 'library'; + } + if (enableShareLink) { return 'shareLink'; } else if (enableUploadLink) { return 'uploadLink'; + } else if (itemType == 'file' || itemType == 'dir') { + return 'internalLink'; } else if (enableDirPrivateShare) { return 'shareToUser'; } @@ -77,10 +85,16 @@ class ShareDialog extends React.Component { } let activeTab = this.state.activeTab; - const { repoEncrypted, userPerm, enableDirPrivateShare, itemType } = this.props; + let { repoEncrypted, userPerm, enableDirPrivateShare, itemType } = this.props; const enableShareLink = !repoEncrypted && canGenerateShareLink; const enableUploadLink = !repoEncrypted && canGenerateUploadLink && userPerm == 'rw'; + // for encrypted repo, 'dir private share' is only enabled for the repo itself, + // not for the folders in it. + if (repoEncrypted) { + enableDirPrivateShare = itemType == 'library'; + } + return (
@@ -184,17 +198,20 @@ class ShareDialog extends React.Component { renderFileContent = () => { let activeTab = this.state.activeTab; - const { itemType } = this.props; + const { itemType, itemName, repoEncrypted } = this.props; + const enableShareLink = !repoEncrypted && canGenerateShareLink; return (
- {activeTab === 'shareLink' && + {enableShareLink && activeTab === 'shareLink' && @@ -250,7 +266,7 @@ class ShareDialog extends React.Component { {(itemType === 'library' || itemType === 'dir') && this.renderDirContent()} - {(itemType === 'file' && enableShareLink) && this.renderFileContent()} + {itemType === 'file' && this.renderFileContent()}
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 49048de1b6..3a8cc4f40f 100644 --- a/frontend/src/components/dirent-list-view/dirent-list-item.js +++ b/frontend/src/components/dirent-list-view/dirent-list-item.js @@ -766,7 +766,7 @@ class DirentListItem extends React.Component { itemPath={direntPath} userPerm={dirent.permission} repoID={this.props.repoID} - repoEncrypted={false} + repoEncrypted={this.props.repoEncrypted} enableDirPrivateShare={this.props.enableDirPrivateShare} isGroupOwnedRepo={this.props.isGroupOwnedRepo} toggleDialog={this.closeSharedDialog} diff --git a/frontend/src/components/file-view/file-toolbar.js b/frontend/src/components/file-view/file-toolbar.js index d035b1e76d..b116f452cb 100644 --- a/frontend/src/components/file-view/file-toolbar.js +++ b/frontend/src/components/file-view/file-toolbar.js @@ -63,8 +63,9 @@ class FileToolbar extends React.Component { } let showShareBtn = false; - if (!repoEncrypted && - (filePerm == 'rw' || filePerm == 'r') && canGenerateShareLink) { + if (repoEncrypted) { + showShareBtn = true; // for internal link + } else if ((filePerm == 'rw' || filePerm == 'r') && canGenerateShareLink) { showShareBtn = true; } @@ -212,7 +213,7 @@ class FileToolbar extends React.Component { itemPath={filePath} userPerm={filePerm} repoID={repoID} - repoEncrypted={false} + repoEncrypted={repoEncrypted} toggleDialog={this.toggleShareDialog} /> diff --git a/frontend/src/components/toolbar/multiple-dir-operation-toolbar.js b/frontend/src/components/toolbar/multiple-dir-operation-toolbar.js index 42a33917da..f147de1e7b 100644 --- a/frontend/src/components/toolbar/multiple-dir-operation-toolbar.js +++ b/frontend/src/components/toolbar/multiple-dir-operation-toolbar.js @@ -398,7 +398,7 @@ class MultipleDirOperationToolbar extends React.Component { itemPath={direntPath} userPerm={dirent.permission} repoID={repoID} - repoEncrypted={false} + repoEncrypted={this.props.repoEncrypted} enableDirPrivateShare={this.props.enableDirPrivateShare} isGroupOwnedRepo={this.props.isGroupOwnedRepo} toggleDialog={this.toggleCancel} diff --git a/frontend/src/components/toolbar/view-file-toolbar.js b/frontend/src/components/toolbar/view-file-toolbar.js index 96cb5bad51..079f87ff6f 100644 --- a/frontend/src/components/toolbar/view-file-toolbar.js +++ b/frontend/src/components/toolbar/view-file-toolbar.js @@ -118,7 +118,7 @@ class ViewFileToolbar extends React.Component { {gettext('More')} - {this.props.showShareBtn && canGenerateShareLink && + {this.props.showShareBtn && {gettext('Share')} } {gettext('Tags')} @@ -174,4 +174,4 @@ class ViewFileToolbar extends React.Component { ViewFileToolbar.propTypes = propTypes; -export default ViewFileToolbar; \ No newline at end of file +export default ViewFileToolbar; diff --git a/frontend/src/utils/utils.js b/frontend/src/utils/utils.js index 90828d4e14..5158c47425 100644 --- a/frontend/src/utils/utils.js +++ b/frontend/src/utils/utils.js @@ -1286,7 +1286,7 @@ export const Utils = { let isRepoOwner = ownerEmail === username; if (repoEncrypted) { - return false; + return true; } if (dirent && dirent.type === 'file') {