mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-03 16:10:26 +00:00
freeze document
This commit is contained in:
@@ -271,6 +271,9 @@ class DirentListItem extends React.Component {
|
||||
case 'Lock':
|
||||
this.onLockItem();
|
||||
break;
|
||||
case 'Freeze Document':
|
||||
this.onFreezeDocument();
|
||||
break;
|
||||
case 'Convert to Markdown':
|
||||
this.onItemConvert(event, 'markdown');
|
||||
break;
|
||||
@@ -369,6 +372,20 @@ class DirentListItem extends React.Component {
|
||||
});
|
||||
};
|
||||
|
||||
onFreezeDocument = () => {
|
||||
let repoID = this.props.repoID;
|
||||
let filePath = this.getDirentPath(this.props.dirent);
|
||||
seafileAPI.lockfile(repoID, filePath, -1).then(() => {
|
||||
this.props.updateDirent(this.props.dirent, 'is_locked', true);
|
||||
this.props.updateDirent(this.props.dirent, 'locked_by_me', true);
|
||||
let lockName = username.split('@');
|
||||
this.props.updateDirent(this.props.dirent, 'lock_owner_name', lockName[0]);
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
};
|
||||
|
||||
onUnlockItem = () => {
|
||||
let repoID = this.props.repoID;
|
||||
let filePath = this.getDirentPath(this.props.dirent);
|
||||
|
@@ -21,6 +21,7 @@ const TextTranslation = {
|
||||
'DETAILS' : {key : 'Details', value : gettext('Details')},
|
||||
'OPEN_VIA_CLIENT' : {key : 'Open via Client', value : gettext('Open via Client')},
|
||||
'LOCK' : {key : 'Lock', value : gettext('Lock')},
|
||||
'FREEZE_DOCUMENT' : {key : 'Freeze Document', value : gettext('Freeze Document')},
|
||||
'UNLOCK' : {key : 'Unlock', value : gettext('Unlock')},
|
||||
'CONVERT_TO_MARKDOWN' : {key : 'Convert to Markdown', value : gettext('Convert to Markdown')},
|
||||
'CONVERT_TO_SDOC' : {key : 'Convert to sdoc', value : gettext('Convert to sdoc')},
|
||||
|
@@ -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,
|
||||
const { SHARE, DOWNLOAD, DELETE, RENAME, MOVE, COPY, TAGS, UNLOCK, LOCK, FREEZE_DOCUMENT,
|
||||
HISTORY, ACCESS_LOG, PROPERTIES, OPEN_VIA_CLIENT, ONLYOFFICE_CONVERT, CONVERT_TO_MARKDOWN, CONVERT_TO_SDOC } = TextTranslation;
|
||||
const permission = dirent.permission;
|
||||
const { isCustomPermission, customPermission } = Utils.getUserPermission(permission);
|
||||
@@ -589,10 +589,14 @@ export const Utils = {
|
||||
if (dirent.locked_by_me || dirent.lock_owner == 'OnlineOffice' || isRepoOwner || currentRepoInfo.is_admin) {
|
||||
list.push(UNLOCK);
|
||||
}
|
||||
} else {
|
||||
if (dirent.name.endsWith('.sdoc')) {
|
||||
list.push(FREEZE_DOCUMENT);
|
||||
} else {
|
||||
list.push(LOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list.push('Divider');
|
||||
}
|
||||
|
@@ -142,6 +142,7 @@ def get_dir_file_info_list(username, request_type, repo_obj, parent_dir,
|
||||
if is_pro_version():
|
||||
file_info["is_locked"] = dirent.is_locked
|
||||
file_info["lock_time"] = dirent.lock_time
|
||||
file_info["is_freezed"] = dirent.expire is not None and dirent.expire < 0
|
||||
|
||||
lock_owner_email = dirent.lock_owner or ''
|
||||
file_info["lock_owner"] = lock_owner_email
|
||||
|
@@ -662,6 +662,9 @@ class FileView(APIView):
|
||||
error_msg = _("File is locked")
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||
|
||||
# expire < 0, freeze document
|
||||
# expire = 0, use default lock duration
|
||||
# expire > 0, specify lock duration
|
||||
expire = request.data.get('expire', 0)
|
||||
try:
|
||||
expire = int(expire)
|
||||
@@ -669,17 +672,13 @@ class FileView(APIView):
|
||||
error_msg = 'expire invalid.'
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||
|
||||
if expire < 0:
|
||||
error_msg = 'expire invalid.'
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
|
||||
|
||||
# lock file
|
||||
try:
|
||||
if expire > 0:
|
||||
seafile_api.lock_file(repo_id, path, username,
|
||||
int(time.time()) + expire)
|
||||
else:
|
||||
seafile_api.lock_file(repo_id, path, username, 0)
|
||||
seafile_api.lock_file(repo_id, path, username, expire)
|
||||
except SearpcError as e:
|
||||
logger.error(e)
|
||||
error_msg = 'Internal Server Error'
|
||||
|
@@ -27,7 +27,8 @@ publisherNickname: '{{ publisher_nickname }}',
|
||||
isPublished: {% if is_published %}true{% else %}false{% endif %},
|
||||
revisionCreatedAt: '{{ revision_created_at }}',
|
||||
revisionUpdatedAt: '{{ revision_updated_at }}',
|
||||
isSdocDraft: {% if is_sdoc_draft %}true{% else %}false{% endif %}
|
||||
isSdocDraft: {% if is_sdoc_draft %}true{% else %}false{% endif %},
|
||||
isFreezed: {% if is_freezed %}true{% else %}false{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block render_bundle %}
|
||||
|
@@ -662,8 +662,12 @@ def view_lib_file(request, repo_id, path):
|
||||
can_edit_file = False
|
||||
elif is_locked and not locked_by_me:
|
||||
can_edit_file = False
|
||||
|
||||
return_dict['can_edit_file'] = can_edit_file
|
||||
|
||||
lock_info = seafile_api.get_lock_info(repo_id, path)
|
||||
return_dict['is_freezed'] = lock_info is not None and lock_info.expire < 0
|
||||
|
||||
if is_pro_version() and can_edit_file:
|
||||
try:
|
||||
if not is_locked:
|
||||
|
Reference in New Issue
Block a user