1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 15:19:06 +00:00

feat: start revise style (#5540)

* feat: start revise style

* restore code

* restore code
This commit is contained in:
杨国璇
2023-07-09 16:27:02 +08:00
committed by GitHub
parent 7b7d4ca53a
commit 5165998326
9 changed files with 16 additions and 41 deletions

View File

@@ -156,9 +156,6 @@ class DirentGridView extends React.Component{
case 'Unmask as draft':
this.onUnmaskAsDraft(currentObject);
break;
case 'Start revise':
this.onStartRevise(currentObject);
break;
case 'List revisions':
this.openRevisionsPage(currentObject);
break;
@@ -296,18 +293,6 @@ class DirentGridView extends React.Component{
});
}
onStartRevise = (currentObject) => {
let repoID = this.props.repoID;
let filePath = this.getDirentPath(currentObject);
seafileAPI.sdocStartRevise(repoID, filePath).then((res) => {
const url = siteRoot + 'lib/' + repoID + '/file' + Utils.encodePath(res.data.file_path);
window.open(url);
}).catch(error => {
const errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
}
openRevisionsPage = (currentObject) => {
const repoID = this.props.repoID;
const filePath = this.getDirentPath(currentObject);

View File

@@ -270,9 +270,6 @@ class DirentListItem extends React.Component {
case 'Unmask as draft':
this.onUnmaskAsDraft();
break;
case 'Start revise':
this.onStartRevise();
break;
case 'List revisions':
this.openRevisionsPage();
break;
@@ -387,18 +384,6 @@ class DirentListItem extends React.Component {
});
}
onStartRevise = () => {
const repoID = this.props.repoID;
const filePath = this.getDirentPath(this.props.dirent);
seafileAPI.sdocStartRevise(repoID, filePath).then((res) => {
const url = siteRoot + 'lib/' + repoID + '/file' + Utils.encodePath(res.data.file_path);
window.open(url);
}).catch(error => {
const errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
}
openRevisionsPage = () => {
const repoID = this.props.repoID;
const filePath = this.getDirentPath(this.props.dirent);

View File

@@ -211,9 +211,6 @@ class MultipleDirOperationToolbar extends React.Component {
case 'Unmask as draft':
this.onUnmaskAsDraft(dirent);
break;
case 'Start revise':
this.onStartRevise(dirent);
break;
case 'Comment':
this.onCommentItem();
break;

View File

@@ -18,7 +18,6 @@ const TextTranslation = {
'UNLOCK' : {key : 'Unlock', value : gettext('Unlock')},
'MASK_AS_DRAFT' : {key : 'Mask as draft', value : gettext('Mark as draft')},
'UNMASK_AS_DRAFT' : {key : 'Unmask as draft', value : gettext('Unmark as draft')},
'START_REVISE' : {key : 'Start revise', value : gettext('Start revise')},
'LIST_REVISIONS': { key: 'List revisions', value: gettext('List revisions') },
'COMMENT' : {key : 'Comment', value : gettext('Comment')},
'HISTORY' : {key : 'History', value : gettext('History')},

View File

@@ -527,7 +527,7 @@ export const Utils = {
getFileOperationList: function(isRepoOwner, currentRepoInfo, dirent, isContextmenu) {
let list = [];
const { SHARE, DOWNLOAD, DELETE, RENAME, MOVE, COPY, TAGS, UNLOCK, LOCK, MASK_AS_DRAFT, UNMASK_AS_DRAFT,
START_REVISE, LIST_REVISIONS, COMMENT, HISTORY, ACCESS_LOG, OPEN_VIA_CLIENT, ONLYOFFICE_CONVERT } = TextTranslation;
LIST_REVISIONS, COMMENT, HISTORY, ACCESS_LOG, OPEN_VIA_CLIENT, ONLYOFFICE_CONVERT } = TextTranslation;
const permission = dirent.permission;
const { isCustomPermission, customPermission } = Utils.getUserPermission(permission);
@@ -600,7 +600,6 @@ export const Utils = {
} else {
list.push(MASK_AS_DRAFT);
}
list.push(START_REVISE);
list.push(LIST_REVISIONS);
}
if (enableFileComment) {

View File

@@ -194,6 +194,11 @@ class SdocJWTTokenAuthentication(BaseAuthentication):
"""
from seahub.seadoc.utils import is_valid_seadoc_access_token
file_uuid = request.parser_context['kwargs'].get('file_uuid')
if not file_uuid:
if request._request.method == 'POST':
file_uuid = request._request.POST.get('file_uuid')
elif request._request.method == 'GET':
file_uuid = request._request.GET.get('file_uuid')
auth = request.headers.get('authorization', '').split()
is_valid, payload = is_valid_seadoc_access_token(auth, file_uuid, return_payload=True)
if not is_valid:

View File

@@ -825,7 +825,8 @@ class SeadocCommentView(APIView):
class SeadocRevisions(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
# sdoc editor use jwt token
authentication_classes = (SdocJWTTokenAuthentication, TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )

View File

@@ -114,7 +114,7 @@ def get_seadoc_upload_link(uuid_map, last_modify_user=''):
return upload_link
def get_seadoc_download_link(uuid_map):
def get_seadoc_download_link(uuid_map, is_inner=True):
repo_id = uuid_map.repo_id
parent_path = uuid_map.parent_path
filename = uuid_map.filename
@@ -127,9 +127,13 @@ def get_seadoc_download_link(uuid_map):
repo_id, obj_id, 'view', '', use_onetime=False)
if not token:
return None
if is_inner:
download_link = gen_inner_file_get_url(token, filename)
return download_link
download_link = gen_file_get_url(token, filename)
return download_link
def gen_seadoc_image_parent_path(file_uuid, repo_id, username):
parent_path = '/images/sdoc/' + file_uuid + '/'

View File

@@ -53,7 +53,7 @@ def sdoc_revision(request, repo_id):
'is_owner': is_owner,
'can_compare': True,
'assets_url': '/api/v2.1/seadoc/download-image/' + file_uuid,
'file_download_link': get_seadoc_download_link(uuid_map)
'file_download_link': get_seadoc_download_link(uuid_map, False)
}
revision_info = is_seadoc_revision(file_uuid)
@@ -63,7 +63,7 @@ def sdoc_revision(request, repo_id):
is_published = return_dict.get('is_published', False)
if (origin_doc_uuid and not is_published):
uuid_map = FileUUIDMap.objects.get_fileuuidmap_by_uuid(origin_doc_uuid)
return_dict['origin_file_download_link'] = get_seadoc_download_link(uuid_map)
return_dict['origin_file_download_link'] = get_seadoc_download_link(uuid_map, False)
return render(request, 'sdoc_revision.html', return_dict)