1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 23:48:47 +00:00

forbid new folder & new file in container for someone who not has permission

This commit is contained in:
shanshuirenjia
2019-06-24 11:28:25 +08:00
parent ba39bfe176
commit 01df690b19
7 changed files with 48 additions and 29 deletions

View File

@@ -11,7 +11,7 @@ const propTypes = {
currentRepoInfo: PropTypes.object.isRequired,
repoPermission: PropTypes.bool.isRequired,
enableDirPrivateShare: PropTypes.bool.isRequired,
userPrem: PropTypes.bool,
userPerm: PropTypes.string,
isGroupOwnedRepo: PropTypes.bool.isRequired,
// tree
isTreeDataLoading: PropTypes.bool.isRequired,
@@ -196,6 +196,7 @@ class DirColumnView extends React.Component {
repoID={this.props.repoID}
currentRepoInfo={this.props.currentRepoInfo}
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
userPerm={this.props.userPerm}
enableDirPrivateShare={this.props.enableDirPrivateShare}
isRepoInfoBarShow={this.props.isRepoInfoBarShow}
usedRepoTags={this.props.usedRepoTags}

View File

@@ -21,6 +21,7 @@ const propTypes = {
onItemCopy: PropTypes.func.isRequired,
onRenameNode: PropTypes.func.isRequired,
isGroupOwnedRepo: PropTypes.bool.isRequired,
userPerm: PropTypes.string,
isRepoInfoBarShow: PropTypes.bool.isRequired,
isDirentListLoading: PropTypes.bool.isRequired,
isDirentDetailShow: PropTypes.bool.isRequired,
@@ -62,6 +63,7 @@ class DirGridView extends React.Component {
repoID={this.props.repoID}
currentRepoInfo={this.props.currentRepoInfo}
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
userPerm={this.props.userPerm}
enableDirPrivateShare={this.props.enableDirPrivateShare}
direntList={this.props.direntList}
onAddFile={this.props.onAddFile}

View File

@@ -9,6 +9,7 @@ const propTypes = {
repoID: PropTypes.string.isRequired,
currentRepoInfo: PropTypes.object.isRequired,
isGroupOwnedRepo: PropTypes.bool.isRequired,
userPerm: PropTypes.string,
enableDirPrivateShare: PropTypes.bool.isRequired,
isRepoInfoBarShow: PropTypes.bool.isRequired,
usedRepoTags: PropTypes.array.isRequired,
@@ -72,6 +73,7 @@ class DirListView extends React.Component {
currentRepoInfo={this.props.currentRepoInfo}
repoID={this.props.repoID}
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
userPerm={this.props.userPerm}
enableDirPrivateShare={this.props.enableDirPrivateShare}
direntList={this.props.direntList}
sortBy={this.props.sortBy}

View File

@@ -34,6 +34,7 @@ const propTypes = {
onItemClick: PropTypes.func.isRequired,
isDirentListLoading: PropTypes.bool.isRequired,
isGroupOwnedRepo: PropTypes.bool.isRequired,
userPerm: PropTypes.string, // current path's user permission
enableDirPrivateShare: PropTypes.bool.isRequired,
updateDirent: PropTypes.func.isRequired,
isDirentDetailShow: PropTypes.bool.isRequired,
@@ -353,12 +354,19 @@ class DirentGridView extends React.Component{
}
onGridContainerContextMenu = (event) => {
event.preventDefault();
// Display menu items based on the permissions of the current path
let permission = this.props.userPerm;
if (permission !== 'admin' && permission !== 'rw') {
return;
}
let id = 'dirent-grid-container-menu';
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
this.handleContextClick(event, id, menuList);
}
onGridItemContextMenu = (event, dirent) => {
// Display menu items according to the current dirent permission
let id = 'grid-item-contextmenu';
let menuList = this.getDirentItemMenuList(dirent, true);
this.handleContextClick(event, id, menuList, dirent);
@@ -423,27 +431,27 @@ class DirentGridView extends React.Component{
if (dirent.permission === 'rw') {
contextmenuList = [...contextmenuList, DELETE];
}
contextmenuList = [...contextmenuList, 'Divider'];
}
let { RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG } = TextTranslation;
if (type === 'dir' && permission === 'rw') {
menuList = [...contextmenuList, 'Divider'];
if (can_set_folder_perm) {
menuList = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', PERMISSION, 'Divider', OPEN_VIA_CLIENT];
menuList = [...menuList, RENAME, MOVE, COPY, 'Divider', PERMISSION, 'Divider', OPEN_VIA_CLIENT];
} else {
menuList = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
menuList = [...menuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
}
return menuList;
}
if (type === 'dir' && permission === 'r') {
menuList = currentRepoInfo.encrypted ? [...contextmenuList, COPY] : [];
menuList = [...contextmenuList];
menuList = currentRepoInfo.encrypted ? [...menuList, COPY] : [...menuList];
return menuList;
}
if (type === 'file' && permission === 'rw') {
menuList = [...contextmenuList];
menuList = [...contextmenuList, 'Divider'];
if (!dirent.is_locked || (dirent.is_locked && dirent.locked_by_me)) {
menuList.push(RENAME);
menuList.push(MOVE);
@@ -472,7 +480,7 @@ class DirentGridView extends React.Component{
}
if (type === 'file' && permission === 'r') {
menuList = [...contextmenuList];
menuList = [...contextmenuList, 'Divider'];
if (!currentRepoInfo.encrypted) {
menuList.push(COPY);
}

View File

@@ -46,6 +46,7 @@ const propTypes = {
onFileTagChanged: PropTypes.func,
enableDirPrivateShare: PropTypes.bool.isRequired,
isGroupOwnedRepo: PropTypes.bool.isRequired,
userPerm: PropTypes.string,
showDirentDetail: PropTypes.func.isRequired,
};
@@ -294,12 +295,6 @@ class DirentListView extends React.Component {
event.preventDefault();
event.stopPropagation();
let currentRepoInfo = this.props.currentRepoInfo;
if (currentRepoInfo.permission === 'cloud-edit' || currentRepoInfo.permission === 'preview') {
return '';
}
let x = event.clientX || (event.touches && event.touches[0].pageX);
let y = event.clientY || (event.touches && event.touches[0].pageY);
@@ -339,6 +334,13 @@ class DirentListView extends React.Component {
}
onContainerContextMenu = (event) => {
event.preventDefault();
// Display menu items based on the permissions of the current path
let permission = this.props.userPerm;
if (permission !== 'admin' && permission !== 'rw') {
return;
}
if (this.props.selectedDirentList.length === 0) {
let id = 'dirent-container-menu';
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
@@ -419,6 +421,7 @@ class DirentListView extends React.Component {
}
onItemContextMenu = (event, dirent) => {
// Display menu items according to the current dirent permission
if (this.props.selectedDirentList.length > 1) {
return;
}
@@ -488,27 +491,27 @@ class DirentListView extends React.Component {
contextmenuList = [...contextmenuList, DELETE];
}
contextmenuList = [...contextmenuList, 'Divider'];
}
let { RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG, TAGS } = TextTranslation;
if (type === 'dir' && permission === 'rw') {
menuList = [...contextmenuList, 'Divider'];
if (can_set_folder_perm) {
menuList = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', PERMISSION, 'Divider', OPEN_VIA_CLIENT];
menuList = [...menuList, RENAME, MOVE, COPY, 'Divider', PERMISSION, 'Divider', OPEN_VIA_CLIENT];
} else {
menuList = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
menuList = [...menuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
}
return menuList;
}
if (type === 'dir' && permission === 'r') {
menuList = currentRepoInfo.encrypted ? [...contextmenuList, COPY] : [];
menuList = [...contextmenuList];
menuList = currentRepoInfo.encrypted ? [...menuList, COPY] : [...menuList];
return menuList;
}
if (type === 'file' && permission === 'rw') {
menuList = [...contextmenuList];
menuList = [...contextmenuList, 'Divider'];
if (!dirent.is_locked || (dirent.is_locked && dirent.locked_by_me)) {
menuList.push(RENAME);
menuList.push(MOVE);
@@ -538,7 +541,7 @@ class DirentListView extends React.Component {
}
if (type === 'file' && permission === 'r') {
menuList = [...contextmenuList];
menuList = [...contextmenuList, 'Divider'];
if (!currentRepoInfo.encrypted) {
menuList.push(COPY);
}

View File

@@ -198,6 +198,12 @@ class TreeView extends React.Component {
}
onContextMenu = (event) => {
event.preventDefault();
let currentRepoInfo = this.props.currentRepoInfo;
if (currentRepoInfo.permission !== 'admin' && currentRepoInfo.permission !== 'rw') {
return '';
}
this.handleContextClick(event);
}
@@ -208,12 +214,6 @@ class TreeView extends React.Component {
if (!this.props.isNodeMenuShow) {
return;
}
let currentRepoInfo = this.props.currentRepoInfo;
if (currentRepoInfo.permission === 'cloud-edit' || currentRepoInfo.permission === 'preview') {
return '';
}
let x = event.clientX || (event.touches && event.touches[0].pageX);
let y = event.clientY || (event.touches && event.touches[0].pageY);