mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 08:53:14 +00:00
forbid new folder & new file in container for someone who not has permission
This commit is contained in:
@@ -11,7 +11,7 @@ const propTypes = {
|
|||||||
currentRepoInfo: PropTypes.object.isRequired,
|
currentRepoInfo: PropTypes.object.isRequired,
|
||||||
repoPermission: PropTypes.bool.isRequired,
|
repoPermission: PropTypes.bool.isRequired,
|
||||||
enableDirPrivateShare: PropTypes.bool.isRequired,
|
enableDirPrivateShare: PropTypes.bool.isRequired,
|
||||||
userPrem: PropTypes.bool,
|
userPerm: PropTypes.string,
|
||||||
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
||||||
// tree
|
// tree
|
||||||
isTreeDataLoading: PropTypes.bool.isRequired,
|
isTreeDataLoading: PropTypes.bool.isRequired,
|
||||||
@@ -196,6 +196,7 @@ class DirColumnView extends React.Component {
|
|||||||
repoID={this.props.repoID}
|
repoID={this.props.repoID}
|
||||||
currentRepoInfo={this.props.currentRepoInfo}
|
currentRepoInfo={this.props.currentRepoInfo}
|
||||||
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
||||||
|
userPerm={this.props.userPerm}
|
||||||
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
||||||
isRepoInfoBarShow={this.props.isRepoInfoBarShow}
|
isRepoInfoBarShow={this.props.isRepoInfoBarShow}
|
||||||
usedRepoTags={this.props.usedRepoTags}
|
usedRepoTags={this.props.usedRepoTags}
|
||||||
|
@@ -21,6 +21,7 @@ const propTypes = {
|
|||||||
onItemCopy: PropTypes.func.isRequired,
|
onItemCopy: PropTypes.func.isRequired,
|
||||||
onRenameNode: PropTypes.func.isRequired,
|
onRenameNode: PropTypes.func.isRequired,
|
||||||
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
||||||
|
userPerm: PropTypes.string,
|
||||||
isRepoInfoBarShow: PropTypes.bool.isRequired,
|
isRepoInfoBarShow: PropTypes.bool.isRequired,
|
||||||
isDirentListLoading: PropTypes.bool.isRequired,
|
isDirentListLoading: PropTypes.bool.isRequired,
|
||||||
isDirentDetailShow: PropTypes.bool.isRequired,
|
isDirentDetailShow: PropTypes.bool.isRequired,
|
||||||
@@ -62,6 +63,7 @@ class DirGridView extends React.Component {
|
|||||||
repoID={this.props.repoID}
|
repoID={this.props.repoID}
|
||||||
currentRepoInfo={this.props.currentRepoInfo}
|
currentRepoInfo={this.props.currentRepoInfo}
|
||||||
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
||||||
|
userPerm={this.props.userPerm}
|
||||||
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
||||||
direntList={this.props.direntList}
|
direntList={this.props.direntList}
|
||||||
onAddFile={this.props.onAddFile}
|
onAddFile={this.props.onAddFile}
|
||||||
|
@@ -9,6 +9,7 @@ const propTypes = {
|
|||||||
repoID: PropTypes.string.isRequired,
|
repoID: PropTypes.string.isRequired,
|
||||||
currentRepoInfo: PropTypes.object.isRequired,
|
currentRepoInfo: PropTypes.object.isRequired,
|
||||||
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
||||||
|
userPerm: PropTypes.string,
|
||||||
enableDirPrivateShare: PropTypes.bool.isRequired,
|
enableDirPrivateShare: PropTypes.bool.isRequired,
|
||||||
isRepoInfoBarShow: PropTypes.bool.isRequired,
|
isRepoInfoBarShow: PropTypes.bool.isRequired,
|
||||||
usedRepoTags: PropTypes.array.isRequired,
|
usedRepoTags: PropTypes.array.isRequired,
|
||||||
@@ -72,6 +73,7 @@ class DirListView extends React.Component {
|
|||||||
currentRepoInfo={this.props.currentRepoInfo}
|
currentRepoInfo={this.props.currentRepoInfo}
|
||||||
repoID={this.props.repoID}
|
repoID={this.props.repoID}
|
||||||
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
||||||
|
userPerm={this.props.userPerm}
|
||||||
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
||||||
direntList={this.props.direntList}
|
direntList={this.props.direntList}
|
||||||
sortBy={this.props.sortBy}
|
sortBy={this.props.sortBy}
|
||||||
|
@@ -34,6 +34,7 @@ const propTypes = {
|
|||||||
onItemClick: PropTypes.func.isRequired,
|
onItemClick: PropTypes.func.isRequired,
|
||||||
isDirentListLoading: PropTypes.bool.isRequired,
|
isDirentListLoading: PropTypes.bool.isRequired,
|
||||||
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
||||||
|
userPerm: PropTypes.string, // current path's user permission
|
||||||
enableDirPrivateShare: PropTypes.bool.isRequired,
|
enableDirPrivateShare: PropTypes.bool.isRequired,
|
||||||
updateDirent: PropTypes.func.isRequired,
|
updateDirent: PropTypes.func.isRequired,
|
||||||
isDirentDetailShow: PropTypes.bool.isRequired,
|
isDirentDetailShow: PropTypes.bool.isRequired,
|
||||||
@@ -353,12 +354,19 @@ class DirentGridView extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
onGridContainerContextMenu = (event) => {
|
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 id = 'dirent-grid-container-menu';
|
||||||
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
|
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
|
||||||
this.handleContextClick(event, id, menuList);
|
this.handleContextClick(event, id, menuList);
|
||||||
}
|
}
|
||||||
|
|
||||||
onGridItemContextMenu = (event, dirent) => {
|
onGridItemContextMenu = (event, dirent) => {
|
||||||
|
// Display menu items according to the current dirent permission
|
||||||
let id = 'grid-item-contextmenu';
|
let id = 'grid-item-contextmenu';
|
||||||
let menuList = this.getDirentItemMenuList(dirent, true);
|
let menuList = this.getDirentItemMenuList(dirent, true);
|
||||||
this.handleContextClick(event, id, menuList, dirent);
|
this.handleContextClick(event, id, menuList, dirent);
|
||||||
@@ -423,27 +431,27 @@ class DirentGridView extends React.Component{
|
|||||||
if (dirent.permission === 'rw') {
|
if (dirent.permission === 'rw') {
|
||||||
contextmenuList = [...contextmenuList, DELETE];
|
contextmenuList = [...contextmenuList, DELETE];
|
||||||
}
|
}
|
||||||
|
|
||||||
contextmenuList = [...contextmenuList, 'Divider'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG } = TextTranslation;
|
let { RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG } = TextTranslation;
|
||||||
if (type === 'dir' && permission === 'rw') {
|
if (type === 'dir' && permission === 'rw') {
|
||||||
|
menuList = [...contextmenuList, 'Divider'];
|
||||||
if (can_set_folder_perm) {
|
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 {
|
} else {
|
||||||
menuList = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
|
menuList = [...menuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
|
||||||
}
|
}
|
||||||
return menuList;
|
return menuList;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'dir' && permission === 'r') {
|
if (type === 'dir' && permission === 'r') {
|
||||||
menuList = currentRepoInfo.encrypted ? [...contextmenuList, COPY] : [];
|
menuList = [...contextmenuList];
|
||||||
|
menuList = currentRepoInfo.encrypted ? [...menuList, COPY] : [...menuList];
|
||||||
return menuList;
|
return menuList;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'file' && permission === 'rw') {
|
if (type === 'file' && permission === 'rw') {
|
||||||
menuList = [...contextmenuList];
|
menuList = [...contextmenuList, 'Divider'];
|
||||||
if (!dirent.is_locked || (dirent.is_locked && dirent.locked_by_me)) {
|
if (!dirent.is_locked || (dirent.is_locked && dirent.locked_by_me)) {
|
||||||
menuList.push(RENAME);
|
menuList.push(RENAME);
|
||||||
menuList.push(MOVE);
|
menuList.push(MOVE);
|
||||||
@@ -472,7 +480,7 @@ class DirentGridView extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'file' && permission === 'r') {
|
if (type === 'file' && permission === 'r') {
|
||||||
menuList = [...contextmenuList];
|
menuList = [...contextmenuList, 'Divider'];
|
||||||
if (!currentRepoInfo.encrypted) {
|
if (!currentRepoInfo.encrypted) {
|
||||||
menuList.push(COPY);
|
menuList.push(COPY);
|
||||||
}
|
}
|
||||||
|
@@ -46,6 +46,7 @@ const propTypes = {
|
|||||||
onFileTagChanged: PropTypes.func,
|
onFileTagChanged: PropTypes.func,
|
||||||
enableDirPrivateShare: PropTypes.bool.isRequired,
|
enableDirPrivateShare: PropTypes.bool.isRequired,
|
||||||
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
||||||
|
userPerm: PropTypes.string,
|
||||||
showDirentDetail: PropTypes.func.isRequired,
|
showDirentDetail: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -294,12 +295,6 @@ class DirentListView extends React.Component {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
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 x = event.clientX || (event.touches && event.touches[0].pageX);
|
||||||
let y = event.clientY || (event.touches && event.touches[0].pageY);
|
let y = event.clientY || (event.touches && event.touches[0].pageY);
|
||||||
|
|
||||||
@@ -339,6 +334,13 @@ class DirentListView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onContainerContextMenu = (event) => {
|
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) {
|
if (this.props.selectedDirentList.length === 0) {
|
||||||
let id = 'dirent-container-menu';
|
let id = 'dirent-container-menu';
|
||||||
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
|
let menuList = [TextTranslation.NEW_FOLDER, TextTranslation.NEW_FILE];
|
||||||
@@ -419,6 +421,7 @@ class DirentListView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onItemContextMenu = (event, dirent) => {
|
onItemContextMenu = (event, dirent) => {
|
||||||
|
// Display menu items according to the current dirent permission
|
||||||
if (this.props.selectedDirentList.length > 1) {
|
if (this.props.selectedDirentList.length > 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -488,27 +491,27 @@ class DirentListView extends React.Component {
|
|||||||
contextmenuList = [...contextmenuList, DELETE];
|
contextmenuList = [...contextmenuList, DELETE];
|
||||||
}
|
}
|
||||||
|
|
||||||
contextmenuList = [...contextmenuList, 'Divider'];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG, TAGS } = TextTranslation;
|
let { RENAME, MOVE, COPY, PERMISSION, OPEN_VIA_CLIENT, LOCK, UNLOCK, COMMENT, HISTORY, ACCESS_LOG, TAGS } = TextTranslation;
|
||||||
if (type === 'dir' && permission === 'rw') {
|
if (type === 'dir' && permission === 'rw') {
|
||||||
|
menuList = [...contextmenuList, 'Divider'];
|
||||||
if (can_set_folder_perm) {
|
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 {
|
} else {
|
||||||
menuList = [...contextmenuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
|
menuList = [...menuList, RENAME, MOVE, COPY, 'Divider', OPEN_VIA_CLIENT];
|
||||||
}
|
}
|
||||||
return menuList;
|
return menuList;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'dir' && permission === 'r') {
|
if (type === 'dir' && permission === 'r') {
|
||||||
menuList = currentRepoInfo.encrypted ? [...contextmenuList, COPY] : [];
|
menuList = [...contextmenuList];
|
||||||
|
menuList = currentRepoInfo.encrypted ? [...menuList, COPY] : [...menuList];
|
||||||
return menuList;
|
return menuList;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'file' && permission === 'rw') {
|
if (type === 'file' && permission === 'rw') {
|
||||||
menuList = [...contextmenuList];
|
menuList = [...contextmenuList, 'Divider'];
|
||||||
if (!dirent.is_locked || (dirent.is_locked && dirent.locked_by_me)) {
|
if (!dirent.is_locked || (dirent.is_locked && dirent.locked_by_me)) {
|
||||||
menuList.push(RENAME);
|
menuList.push(RENAME);
|
||||||
menuList.push(MOVE);
|
menuList.push(MOVE);
|
||||||
@@ -538,7 +541,7 @@ class DirentListView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'file' && permission === 'r') {
|
if (type === 'file' && permission === 'r') {
|
||||||
menuList = [...contextmenuList];
|
menuList = [...contextmenuList, 'Divider'];
|
||||||
if (!currentRepoInfo.encrypted) {
|
if (!currentRepoInfo.encrypted) {
|
||||||
menuList.push(COPY);
|
menuList.push(COPY);
|
||||||
}
|
}
|
||||||
|
@@ -198,6 +198,12 @@ class TreeView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onContextMenu = (event) => {
|
onContextMenu = (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
let currentRepoInfo = this.props.currentRepoInfo;
|
||||||
|
if (currentRepoInfo.permission !== 'admin' && currentRepoInfo.permission !== 'rw') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
this.handleContextClick(event);
|
this.handleContextClick(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,12 +215,6 @@ class TreeView extends React.Component {
|
|||||||
return;
|
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 x = event.clientX || (event.touches && event.touches[0].pageX);
|
||||||
let y = event.clientY || (event.touches && event.touches[0].pageY);
|
let y = event.clientY || (event.touches && event.touches[0].pageY);
|
||||||
|
|
||||||
|
@@ -20,8 +20,8 @@ const propTypes = {
|
|||||||
repoID: PropTypes.string.isRequired,
|
repoID: PropTypes.string.isRequired,
|
||||||
repoPermission: PropTypes.bool.isRequired,
|
repoPermission: PropTypes.bool.isRequired,
|
||||||
enableDirPrivateShare: PropTypes.bool.isRequired,
|
enableDirPrivateShare: PropTypes.bool.isRequired,
|
||||||
userPrem: PropTypes.bool,
|
|
||||||
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
isGroupOwnedRepo: PropTypes.bool.isRequired,
|
||||||
|
userPerm: PropTypes.string,
|
||||||
// path func
|
// path func
|
||||||
onTabNavClick: PropTypes.func.isRequired,
|
onTabNavClick: PropTypes.func.isRequired,
|
||||||
onMainNavBarClick: PropTypes.func.isRequired,
|
onMainNavBarClick: PropTypes.func.isRequired,
|
||||||
@@ -194,6 +194,7 @@ class LibContentContainer extends React.Component {
|
|||||||
repoID={repoID}
|
repoID={repoID}
|
||||||
currentRepoInfo={this.props.currentRepoInfo}
|
currentRepoInfo={this.props.currentRepoInfo}
|
||||||
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
||||||
|
userPerm={this.props.userPerm}
|
||||||
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
||||||
isRepoInfoBarShow={isRepoInfoBarShow}
|
isRepoInfoBarShow={isRepoInfoBarShow}
|
||||||
usedRepoTags={this.props.usedRepoTags}
|
usedRepoTags={this.props.usedRepoTags}
|
||||||
@@ -232,6 +233,7 @@ class LibContentContainer extends React.Component {
|
|||||||
currentRepoInfo={this.props.currentRepoInfo}
|
currentRepoInfo={this.props.currentRepoInfo}
|
||||||
repoPermission={this.props.repoPermission}
|
repoPermission={this.props.repoPermission}
|
||||||
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
||||||
|
userPerm={this.props.userPerm}
|
||||||
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
||||||
onRenameNode={this.props.onRenameNode}
|
onRenameNode={this.props.onRenameNode}
|
||||||
isRepoInfoBarShow={isRepoInfoBarShow}
|
isRepoInfoBarShow={isRepoInfoBarShow}
|
||||||
@@ -262,6 +264,7 @@ class LibContentContainer extends React.Component {
|
|||||||
currentRepoInfo={this.props.currentRepoInfo}
|
currentRepoInfo={this.props.currentRepoInfo}
|
||||||
repoPermission={this.props.repoPermission}
|
repoPermission={this.props.repoPermission}
|
||||||
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
isGroupOwnedRepo={this.props.isGroupOwnedRepo}
|
||||||
|
userPerm={this.props.userPerm}
|
||||||
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
enableDirPrivateShare={this.props.enableDirPrivateShare}
|
||||||
isTreeDataLoading={this.props.isTreeDataLoading}
|
isTreeDataLoading={this.props.isTreeDataLoading}
|
||||||
treeData={this.props.treeData}
|
treeData={this.props.treeData}
|
||||||
|
Reference in New Issue
Block a user