1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 15:53:28 +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': case 'Unmask as draft':
this.onUnmaskAsDraft(currentObject); this.onUnmaskAsDraft(currentObject);
break; break;
case 'Start revise':
this.onStartRevise(currentObject);
break;
case 'List revisions': case 'List revisions':
this.openRevisionsPage(currentObject); this.openRevisionsPage(currentObject);
break; 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) => { openRevisionsPage = (currentObject) => {
const repoID = this.props.repoID; const repoID = this.props.repoID;
const filePath = this.getDirentPath(currentObject); const filePath = this.getDirentPath(currentObject);

View File

@@ -270,9 +270,6 @@ class DirentListItem extends React.Component {
case 'Unmask as draft': case 'Unmask as draft':
this.onUnmaskAsDraft(); this.onUnmaskAsDraft();
break; break;
case 'Start revise':
this.onStartRevise();
break;
case 'List revisions': case 'List revisions':
this.openRevisionsPage(); this.openRevisionsPage();
break; 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 = () => { openRevisionsPage = () => {
const repoID = this.props.repoID; const repoID = this.props.repoID;
const filePath = this.getDirentPath(this.props.dirent); const filePath = this.getDirentPath(this.props.dirent);

View File

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

View File

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

View File

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

View File

@@ -194,6 +194,11 @@ class SdocJWTTokenAuthentication(BaseAuthentication):
""" """
from seahub.seadoc.utils import is_valid_seadoc_access_token from seahub.seadoc.utils import is_valid_seadoc_access_token
file_uuid = request.parser_context['kwargs'].get('file_uuid') 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() auth = request.headers.get('authorization', '').split()
is_valid, payload = is_valid_seadoc_access_token(auth, file_uuid, return_payload=True) is_valid, payload = is_valid_seadoc_access_token(auth, file_uuid, return_payload=True)
if not is_valid: if not is_valid:

View File

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

View File

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

View File

@@ -53,7 +53,7 @@ def sdoc_revision(request, repo_id):
'is_owner': is_owner, 'is_owner': is_owner,
'can_compare': True, 'can_compare': True,
'assets_url': '/api/v2.1/seadoc/download-image/' + file_uuid, '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) 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) is_published = return_dict.get('is_published', False)
if (origin_doc_uuid and not is_published): if (origin_doc_uuid and not is_published):
uuid_map = FileUUIDMap.objects.get_fileuuidmap_by_uuid(origin_doc_uuid) 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) return render(request, 'sdoc_revision.html', return_dict)