1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-06 17:33:18 +00:00

Dir view permission fixup (#7383)

* ['dir view' page] fixed permission for creating files when the library is empty

* ['dir view' page] fixed permission for rotating images in the image preview dialog
This commit is contained in:
llj
2025-01-17 17:35:28 +08:00
committed by GitHub
parent 41efd64872
commit 9760eca25c
4 changed files with 68 additions and 30 deletions

View File

@@ -362,8 +362,20 @@ class DirFiles extends React.Component {
}; };
render() { render() {
const { repoID, currentRepoInfo } = this.props; const { repoID, currentRepoInfo, userPerm } = this.props;
const repoEncrypted = currentRepoInfo.encrypted; const { encrypted: repoEncrypted } = currentRepoInfo;
let canModifyFile = false;
if (['rw', 'cloud-edit'].indexOf(userPerm) != -1) {
canModifyFile = true;
} else {
const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm);
if (isCustomPermission) {
const { modify } = customPermission.permission;
canModifyFile = modify;
}
}
return ( return (
<> <>
<TreeSection <TreeSection
@@ -456,7 +468,7 @@ class DirFiles extends React.Component {
moveToNextImage={this.moveToNextImage} moveToNextImage={this.moveToNextImage}
onDeleteImage={this.deleteImage} onDeleteImage={this.deleteImage}
onRotateImage={this.rotateImage} onRotateImage={this.rotateImage}
enableRotate={!repoEncrypted} enableRotate={canModifyFile}
/> />
</ModalPortal> </ModalPortal>
)} )}

View File

@@ -843,14 +843,25 @@ class DirentGridView extends React.Component {
}; };
render() { render() {
let { direntList, selectedDirentList, path } = this.props; const { direntList, selectedDirentList, path, currentRepoInfo, userPerm } = this.props;
const { encrypted: repoEncrypted } = currentRepoInfo;
let dirent = this.state.activeDirent ? this.state.activeDirent : ''; let dirent = this.state.activeDirent ? this.state.activeDirent : '';
let direntPath = Utils.joinPath(path, dirent.name); let direntPath = Utils.joinPath(path, dirent.name);
let canModifyFile = false;
if (['rw', 'cloud-edit'].indexOf(userPerm) != -1) {
canModifyFile = true;
} else {
const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm);
if (isCustomPermission) {
const { modify } = customPermission.permission;
canModifyFile = modify;
}
}
if (this.props.isDirentListLoading) { if (this.props.isDirentListLoading) {
return (<Loading />); return (<Loading />);
} }
const repoEncrypted = this.props.currentRepoInfo.encrypted;
return ( return (
<Fragment> <Fragment>
@@ -1025,7 +1036,7 @@ class DirentGridView extends React.Component {
moveToNextImage={this.moveToNextImage} moveToNextImage={this.moveToNextImage}
onDeleteImage={this.deleteImage} onDeleteImage={this.deleteImage}
onRotateImage={this.rotateImage} onRotateImage={this.rotateImage}
enableRotate={!repoEncrypted} enableRotate={canModifyFile}
/> />
</ModalPortal> </ModalPortal>
)} )}

View File

@@ -749,10 +749,20 @@ class DirentListView extends React.Component {
}; };
render() { render() {
const { direntList } = this.props; const { direntList, currentRepoInfo, userPerm } = this.props;
const { encrypted: repoEncrypted } = currentRepoInfo;
const isDesktop = Utils.isDesktop(); const isDesktop = Utils.isDesktop();
const repoEncrypted = this.props.currentRepoInfo.encrypted;
let canModifyFile = false;
if (['rw', 'cloud-edit'].indexOf(userPerm) != -1) {
canModifyFile = true;
} else {
const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm);
if (isCustomPermission) {
const { modify } = customPermission.permission;
canModifyFile = modify;
}
}
return ( return (
<div <div
@@ -856,7 +866,7 @@ class DirentListView extends React.Component {
moveToNextImage={this.moveToNextImage} moveToNextImage={this.moveToNextImage}
onDeleteImage={this.deleteImage} onDeleteImage={this.deleteImage}
onRotateImage={this.rotateImage} onRotateImage={this.rotateImage}
enableRotate={!repoEncrypted} enableRotate={canModifyFile}
/> />
</ModalPortal> </ModalPortal>
)} )}

View File

@@ -162,31 +162,36 @@ class DirentNoneView extends React.Component {
if (this.props.isDirentListLoading) { if (this.props.isDirentListLoading) {
return (<Loading />); return (<Loading />);
} }
const { currentRepoInfo } = this.props; const { currentRepoInfo, userPerm } = this.props;
let canCreateFile = false;
if (['rw', 'cloud-edit'].indexOf(userPerm) != -1) {
canCreateFile = true;
} else {
const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm);
if (isCustomPermission) {
const { create } = customPermission.permission;
canCreateFile = create;
}
}
return ( return (
<div className="tip-for-new-file-container" onContextMenu={this.onContainerContextMenu}> <div className="tip-for-new-file-container" onContextMenu={this.onContainerContextMenu}>
<div className="tip-for-new-file"> <div className="tip-for-new-file">
<p className="text-secondary text-center">{gettext('This folder has no content at this time.')}</p> <p className="text-secondary text-center">{gettext('This folder has no content at this time.')}</p>
<p className="text-secondary text-center">{gettext('You can create files quickly')}{' +'}</p> {canCreateFile && (
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.md')}> <>
{'+ Markdown'} <p className="text-secondary text-center">{gettext('You can create files quickly')}{' +'}</p>
</button> <button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.md')}>{'+ Markdown'}</button>
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.pptx')}> <button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.pptx')}>{'+ PPT'}</button>
{'+ PPT'} <br />
</button> <button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.docx')}>{'+ Word'}</button>
<br /> <button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.xlsx')}>{'+ Excel'}</button>
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.docx')}> <br />
{'+ Word'} {enableSeadoc && !currentRepoInfo.encrypted &&
</button> <button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.sdoc')}>{'+ SeaDoc'}</button>
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.xlsx')}> }
{'+ Excel'} </>
</button> )}
<br />
{enableSeadoc && !currentRepoInfo.encrypted &&
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.sdoc')}>
{'+ SeaDoc'}
</button>}
</div> </div>
{this.state.isCreateFileDialogShow && ( {this.state.isCreateFileDialogShow && (
<ModalPortal> <ModalPortal>