1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

custom share permission (#4967)

* custom share permission

* remove path field

* add permission manager ui

* optimize custom permission manager style

* add permission setting

* add normalize_custom_permission_name

* optimize repo custom permission

* delete useless code

* optimize code

* optimize code

* optimize markdown file page

* fix a few bugs

* add permission control

* repair modify permission

* optimize style

* optimize copyright

* add try-except

* optimize code

* move file&folder

* batch operation item

* repair batch move item

* update copyright

* optimize move permission control

* optimize code

* optimize code

* optimize code & fix code wranning

* optimize code

* delete unsupport permission

* optimize code

* repair code bug

* add pro limit

* optimize code

* add permission handle for permission editor

* repair new file&folder bug

* optimize file uploader code

* custom permission user can not visit custom permission module

* optimize code

* forbid comment&detail module

* optimize code

* optimize modify/preview permission

* optimize custom permission share perm

* optimize view file module: file-toolbar

* optimize custom drag move operation

* repair column view bug

* optimize drag operation code

* repair code bug

* optimize code

Co-authored-by: shanshuirenjia <978987373@qq.com>
This commit is contained in:
王健辉
2021-09-13 10:37:07 +08:00
committed by GitHub
parent 1f68680257
commit 07df610e43
60 changed files with 1965 additions and 287 deletions

View File

@@ -83,6 +83,14 @@ class DirentListView extends React.Component {
this.currentItemRef = null;
this.zipToken = null;
const { userPerm } = props;
this.canDrop = userPerm === 'rw';
const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm);
if (isCustomPermission) {
const { modify } = customPermission.permission;
this.canDrop = modify;
}
}
freezeItem = () => {
@@ -315,12 +323,21 @@ class DirentListView extends React.Component {
event.preventDefault();
// Display menu items based on the permissions of the current path
let permission = this.props.userPerm;
if (permission !== 'admin' && permission !== 'rw') {
const { isCustomPermission, customPermission } = Utils.getUserPermission(this.props.userPerm);
if (permission !== 'admin' && permission !== 'rw' && !isCustomPermission) {
return;
}
if (this.props.selectedDirentList.length === 0) {
let id = 'dirent-container-menu';
// custom permission judgement
if (isCustomPermission) {
const { modify } = customPermission.permission;
if (!modify) return;
}
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
this.handleContextClick(event, id, menuList);
} else {
@@ -334,6 +351,13 @@ class DirentListView extends React.Component {
this.onDirentClick(null);
event.preventDefault();
event.persist();
// custom permission judgement
if (isCustomPermission) {
const { modify } = customPermission.permission;
if (!modify) return;
}
setTimeout(() => {
let id = 'dirent-container-menu';
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
@@ -342,7 +366,17 @@ class DirentListView extends React.Component {
}
} else {
let id = 'dirents-menu';
let menuList = [TextTranslation.MOVE, TextTranslation.COPY, TextTranslation.DOWNLOAD, TextTranslation.DELETE];
let menuList = [];
if (isCustomPermission) {
const { modify: canModify, copy: canCopy, download: canDownload, delete: canDelete } = customPermission.permission;
canModify && menuList.push(TextTranslation.MOVE);
canCopy && menuList.push(TextTranslation.COPY);
canDownload && menuList.push(TextTranslation.DOWNLOAD);
canDelete && menuList.push(TextTranslation.DELETE);
} else {
menuList = [TextTranslation.MOVE, TextTranslation.COPY, TextTranslation.DOWNLOAD, TextTranslation.DELETE];
}
this.handleContextClick(event, id, menuList);
}
}
@@ -448,7 +482,7 @@ class DirentListView extends React.Component {
}
onTableDragEnter = (e) => {
if (Utils.isIEBrower()) {
if (Utils.isIEBrower() || !this.canDrop) {
return false;
}
this.enteredCounter++;
@@ -461,7 +495,7 @@ class DirentListView extends React.Component {
}
onTableDragOver = (e) => {
if (Utils.isIEBrower()) {
if (Utils.isIEBrower() || !this.canDrop) {
return false;
}
if (e.dataTransfer.dropEffect === 'copy') {
@@ -472,7 +506,7 @@ class DirentListView extends React.Component {
}
onTableDragLeave = (e) => {
if (Utils.isIEBrower()) {
if (Utils.isIEBrower() || !this.canDrop) {
return false;
}
this.enteredCounter--;
@@ -482,7 +516,7 @@ class DirentListView extends React.Component {
}
tableDrop = (e) => {
if (Utils.isIEBrower()) {
if (Utils.isIEBrower() || !this.canDrop) {
return false;
}
e.persist();
@@ -540,7 +574,7 @@ class DirentListView extends React.Component {
return (
<div
className={`table-container ${this.state.isListDropTipShow ? 'table-drop-active' : ''}`}
className={`table-container ${(this.state.isListDropTipShow && this.canDrop) ? 'table-drop-active' : ''}`}
onMouseDown={this.onContainerMouseDown}
onContextMenu={this.onContainerContextMenu}
onClick={this.onContainerClick}