1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 23:48:47 +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() {
const { repoID, currentRepoInfo } = this.props;
const repoEncrypted = currentRepoInfo.encrypted;
const { repoID, currentRepoInfo, userPerm } = this.props;
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 (
<>
<TreeSection
@@ -456,7 +468,7 @@ class DirFiles extends React.Component {
moveToNextImage={this.moveToNextImage}
onDeleteImage={this.deleteImage}
onRotateImage={this.rotateImage}
enableRotate={!repoEncrypted}
enableRotate={canModifyFile}
/>
</ModalPortal>
)}

View File

@@ -843,14 +843,25 @@ class DirentGridView extends React.Component {
};
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 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) {
return (<Loading />);
}
const repoEncrypted = this.props.currentRepoInfo.encrypted;
return (
<Fragment>
@@ -1025,7 +1036,7 @@ class DirentGridView extends React.Component {
moveToNextImage={this.moveToNextImage}
onDeleteImage={this.deleteImage}
onRotateImage={this.rotateImage}
enableRotate={!repoEncrypted}
enableRotate={canModifyFile}
/>
</ModalPortal>
)}

View File

@@ -749,10 +749,20 @@ class DirentListView extends React.Component {
};
render() {
const { direntList } = this.props;
const { direntList, currentRepoInfo, userPerm } = this.props;
const { encrypted: repoEncrypted } = currentRepoInfo;
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 (
<div
@@ -856,7 +866,7 @@ class DirentListView extends React.Component {
moveToNextImage={this.moveToNextImage}
onDeleteImage={this.deleteImage}
onRotateImage={this.rotateImage}
enableRotate={!repoEncrypted}
enableRotate={canModifyFile}
/>
</ModalPortal>
)}

View File

@@ -162,31 +162,36 @@ class DirentNoneView extends React.Component {
if (this.props.isDirentListLoading) {
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 (
<div className="tip-for-new-file-container" onContextMenu={this.onContainerContextMenu}>
<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('You can create files quickly')}{' +'}</p>
<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')}>
{'+ PPT'}
</button>
<br />
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.docx')}>
{'+ Word'}
</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>}
{canCreateFile && (
<>
<p className="text-secondary text-center">{gettext('You can create files quickly')}{' +'}</p>
<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')}>{'+ PPT'}</button>
<br />
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.docx')}>{'+ Word'}</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>
{this.state.isCreateFileDialogShow && (
<ModalPortal>