mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-07 09:51:26 +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:
@@ -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>
|
||||||
)}
|
)}
|
||||||
|
@@ -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>
|
||||||
)}
|
)}
|
||||||
|
@@ -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>
|
||||||
)}
|
)}
|
||||||
|
@@ -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>
|
||||||
|
{canCreateFile && (
|
||||||
|
<>
|
||||||
<p className="text-secondary text-center">{gettext('You can create files quickly')}{' +'}</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')}>
|
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.md')}>{'+ Markdown'}</button>
|
||||||
{'+ Markdown'}
|
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.pptx')}>{'+ PPT'}</button>
|
||||||
</button>
|
|
||||||
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.pptx')}>
|
|
||||||
{'+ PPT'}
|
|
||||||
</button>
|
|
||||||
<br />
|
<br />
|
||||||
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.docx')}>
|
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.docx')}>{'+ Word'}</button>
|
||||||
{'+ Word'}
|
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.xlsx')}>{'+ Excel'}</button>
|
||||||
</button>
|
|
||||||
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.xlsx')}>
|
|
||||||
{'+ Excel'}
|
|
||||||
</button>
|
|
||||||
<br />
|
<br />
|
||||||
{enableSeadoc && !currentRepoInfo.encrypted &&
|
{enableSeadoc && !currentRepoInfo.encrypted &&
|
||||||
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.sdoc')}>
|
<button className="big-new-file-button" onClick={this.onCreateNewFile.bind(this, '.sdoc')}>{'+ SeaDoc'}</button>
|
||||||
{'+ SeaDoc'}
|
}
|
||||||
</button>}
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{this.state.isCreateFileDialogShow && (
|
{this.state.isCreateFileDialogShow && (
|
||||||
<ModalPortal>
|
<ModalPortal>
|
||||||
|
Reference in New Issue
Block a user