1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-08 18:30:53 +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

@@ -536,46 +536,48 @@ class MarkdownEditor extends React.Component {
});
}
componentDidMount() {
async componentDidMount() {
seafileAPI.getFileInfo(repoID, filePath).then((res) => {
let { mtime, size, starred, permission, last_modifier_name, id } = res.data;
let lastModifier = last_modifier_name;
// get file info
const fileInfoRes = await seafileAPI.getFileInfo(repoID, filePath);
const { mtime, size, starred, permission, last_modifier_name, id } = fileInfoRes.data;
const lastModifier = last_modifier_name;
this.setState((prevState, props) => ({
fileInfo: {
...prevState.fileInfo,
mtime,
size,
starred,
permission,
lastModifier,
id
}
}));
// get file download url
const fileDownloadUrlRes = await seafileAPI.getFileDownloadLink(repoID, filePath);
const downloadUrl = fileDownloadUrlRes.data;
seafileAPI.getFileDownloadLink(repoID, filePath).then((res) => {
const downLoadUrl = res.data;
seafileAPI.getFileContent(downLoadUrl).then((res) => {
const contentLength = res.data.length;
let isBlankFile = (contentLength === 0 || contentLength === 1);
let permission = this.state.fileInfo.permission;
let hasPermission = (permission === 'rw' || permission === 'cloud-edit');
let value = deserialize(res.data);
this.setState({
markdownContent: res.data,
loading: false,
// Goto rich edit page
// First, the user has the relevant permissions, otherwise he can only enter the viewer interface or cannot access
// case1: If file is draft file
// case2: If mode == 'edit' and the file has no draft
// case3: The length of markDownContent is 1 when clear all content in editor and the file has no draft
readOnly: !hasPermission || hasDraft,
value: value,
});
});
});
// get file content
const fileContentRes = await seafileAPI.getFileContent(downloadUrl);
const markdownContent = fileContentRes.data;
const value = deserialize(markdownContent);
// init permission
let hasPermission = permission === 'rw' || permission === 'cloud-edit';
// get custom permission
if (permission.startsWith('custom-')) {
const permissionID = permission.split('-')[1];
const customPermissionRes = await seafileAPI.getCustomPermission(repoID, permissionID);
const customPermission = customPermissionRes.data.permission;
const { modify: canModify } = customPermission.permission;
hasPermission = canModify ? true : hasPermission;
}
// Goto rich edit page
// First, the user has the relevant permissions, otherwise he can only enter the viewer interface or cannot access
// case1: If file is draft file
// case2: If mode == 'edit' and the file has no draft
// case3: The length of markDownContent is 1 when clear all content in editor and the file has no draft
const { fileInfo } = this.state;
this.setState({
loading: false,
fileInfo: {...fileInfo, mtime, size, starred, permission, lastModifier, id},
markdownContent,
value,
readOnly: !hasPermission || hasDraft,
});
if (userInfo && this.socket) {
const { repoID, path } = this.state.fileInfo;
this.socket.emit('presence', {