1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 02:48:51 +00:00

Merge branch 'master' into 13.0

This commit is contained in:
Michael An
2025-02-25 12:01:46 +08:00
12 changed files with 63 additions and 19 deletions

View File

@@ -203,11 +203,19 @@ class DirOperationToolbar extends React.Component {
render() {
let { path, repoName, userPerm } = this.props;
const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm);
const isShowDropdownMenu = (userPerm === 'rw' || userPerm === 'admin' || userPerm === 'cloud-edit' || isCustomPermission);
if (!isShowDropdownMenu) {
return (
<div className="dir-operation dir-operation-no-dropdown">
{this.props.children}
</div>
);
}
let itemType = path === '/' ? 'library' : 'dir';
let itemName = path == '/' ? repoName : Utils.getFolderName(path);
const { isCustomPermission, customPermission } = Utils.getUserPermission(userPerm);
let canUpload = true;
let canCreate = true;
if (isCustomPermission) {
@@ -293,7 +301,8 @@ class DirOperationToolbar extends React.Component {
data-toggle="dropdown"
>
{this.props.children}
<i className="sf3-font-down sf3-font ml-1 path-item-dropdown-toggle"></i>
<i className="sf3-font-new sf3-font ml-2"></i>
<i className="sf3-font-down sf3-font path-item-dropdown-toggle"></i>
</DropdownToggle>
<DropdownMenu onMouseMove={this.onDropDownMouseMove} className='position-fixed'>
{opList.map((item, index) => {
@@ -351,7 +360,8 @@ class DirOperationToolbar extends React.Component {
className="path-item"
>
{this.props.children}
<i className="sf3-font-down sf3-font ml-1 path-item-dropdown-toggle"></i>
<i className="sf3-font-new sf3-font ml-2"></i>
<i className="sf3-font-down sf3-font path-item-dropdown-toggle"></i>
</DropdownToggle>
<DropdownMenu className='position-fixed'>
{canUpload && (
@@ -370,7 +380,7 @@ class DirOperationToolbar extends React.Component {
return (
<Fragment>
{(userPerm === 'rw' || userPerm === 'admin' || userPerm === 'cloud-edit' || isCustomPermission) && (
{isShowDropdownMenu && (
<div className="dir-operation">
{content}
</div>

View File

@@ -280,6 +280,10 @@
align-items: center;
}
.dir-view-path .dir-operation.dir-operation-no-dropdown {
margin-left: 6px;
}
.dir-view-path .dir-operation .path-item {
display: inline-flex;
align-items: center;
@@ -316,9 +320,14 @@
display: inline-block;
}
.dir-view-path .sf3-font-new,
.dir-view-path .path-item-dropdown-toggle {
color: #666;
}
.dir-view-path .path-item-dropdown-toggle {
margin-top: 2px;
margin-left: 2px;
}
.dir-view-path .path-item-drop {

View File

@@ -109,7 +109,10 @@ export const enableTC = window.app.pageOptions.enableTC;
export const enableVideoThumbnail = window.app.pageOptions.enableVideoThumbnail;
export const enablePDFThumbnail = window.app.pageOptions.enablePDFThumbnail;
export const enableOfficeWebApp = window.app.pageOptions.enableOfficeWebApp || false;
export const officeWebAppEditFileExtension = window.app.pageOptions.officeWebAppEditFileExtension || [];
export const enableOnlyoffice = window.app.pageOptions.enableOnlyoffice || false;
export const onlyofficeEditFileExtension = window.app.pageOptions.onlyofficeEditFileExtension || [];
export const onlyofficeConverterExtensions = window.app.pageOptions.onlyofficeConverterExtensions || [];
export const enableFileTags = window.app.pageOptions.enableFileTags || false;

View File

@@ -1,5 +1,7 @@
import { mediaUrl, gettext, serviceURL, siteRoot, isPro, fileAuditEnabled, canGenerateShareLink, canGenerateUploadLink, shareLinkPasswordMinLength, username, folderPermEnabled, onlyofficeConverterExtensions, enableSeadoc, enableFileTags, enableRepoSnapshotLabel,
enableResetEncryptedRepoPassword, isEmailConfigured, isSystemStaff } from './constants';
enableResetEncryptedRepoPassword, isEmailConfigured, isSystemStaff,
enableOnlyoffice, onlyofficeEditFileExtension,
enableOfficeWebApp, officeWebAppEditFileExtension } from './constants';
import TextTranslation from './text-translation';
import React from 'react';
import toaster from '../components/toast';
@@ -209,7 +211,14 @@ export const Utils = {
return false;
}
const file_ext = filename.substr(filename.lastIndexOf('.') + 1).toLowerCase();
return ['docx', 'pptx', 'xlsx'].includes(file_ext);
if (enableOnlyoffice) {
return onlyofficeEditFileExtension.includes(file_ext);
} else if (enableOfficeWebApp) {
return officeWebAppEditFileExtension.includes(file_ext);
} else {
return false;
}
},
// check if a file is a video

View File

@@ -29,7 +29,10 @@ from seahub.settings import SEAFILE_VERSION, SITE_DESCRIPTION, \
from seahub.organizations.models import OrgAdminSettings
from seahub.organizations.settings import ORG_ENABLE_ADMIN_CUSTOM_LOGO
from seahub.onlyoffice.settings import ENABLE_ONLYOFFICE, ONLYOFFICE_CONVERTER_EXTENSIONS
from seahub.onlyoffice.settings import ENABLE_ONLYOFFICE, \
ONLYOFFICE_CONVERTER_EXTENSIONS, ONLYOFFICE_EDIT_FILE_EXTENSION
from seahub.wopi.settings import ENABLE_OFFICE_WEB_APP, \
OFFICE_WEB_APP_EDIT_FILE_EXTENSION
from seahub.constants import DEFAULT_ADMIN
from seahub.utils import get_site_name, get_service_url
from seahub.avatar.templatetags.avatar_tags import api_avatar_url
@@ -152,8 +155,11 @@ def base(request):
'FILE_SERVER_ROOT': file_server_root,
'USE_GO_FILESERVER': seaserv.USE_GO_FILESERVER if hasattr(seaserv, 'USE_GO_FILESERVER') else False,
'LOGIN_URL': dj_settings.LOGIN_URL,
'enableOnlyoffice': ENABLE_ONLYOFFICE,
'onlyofficeConverterExtensions': ONLYOFFICE_CONVERTER_EXTENSIONS,
'enable_onlyoffice': ENABLE_ONLYOFFICE,
'onlyoffice_edit_file_extension': list(ONLYOFFICE_EDIT_FILE_EXTENSION),
'enable_office_web_app': ENABLE_OFFICE_WEB_APP,
'office_web_app_edit_file_extension': list(OFFICE_WEB_APP_EDIT_FILE_EXTENSION),
'onlyoffice_converter_extensions': ONLYOFFICE_CONVERTER_EXTENSIONS,
'thumbnail_size_for_original': THUMBNAIL_SIZE_FOR_ORIGINAL,
'thumbnail_size_for_grid': THUMBNAIL_SIZE_FOR_GRID,
'thumbnail_default_size': THUMBNAIL_DEFAULT_SIZE,

View File

@@ -1,5 +1,6 @@
import logging
import requests
import time
from seahub.onlyoffice.converter_utils import get_file_name, get_file_ext
from seahub.onlyoffice.settings import ONLYOFFICE_CONVERTER_URL, \
@@ -21,6 +22,7 @@ def get_converter_uri(doc_uri, from_ext, to_ext, doc_key, is_async, file_passwor
'filetype': from_ext.replace('.', ''),
'title': title,
'key': doc_key,
'exp': int(time.time()) + 300
}
if file_password:

View File

@@ -63,5 +63,3 @@ if ENABLE_MULTIPLE_OFFICE_SUITE:
VERIFY_ONLYOFFICE_CERTIFICATE = office_info.get('VERIFY_ONLYOFFICE_CERTIFICATE', True)
ONLYOFFICE_FILE_EXTENSION = OFFICE_SUITE_ENABLED_FILE_TYPES
ONLYOFFICE_EDIT_FILE_EXTENSION = OFFICE_SUITE_ENABLED_EDIT_FILE_TYPES

View File

@@ -4,6 +4,7 @@ import logging
import urllib.parse
import posixpath
import json
import time
from django.urls import reverse
from django.utils.encoding import force_bytes
@@ -197,7 +198,8 @@ def get_onlyoffice_dict(request, username, repo_id, file_path, file_id='',
"customization": {
"forcesave": ONLYOFFICE_FORCE_SAVE,
},
}
},
'exp': int(time.time()) + 3 * 24 * 3600
}
if request.user.is_authenticated:

View File

@@ -5,6 +5,7 @@ import json
import logging
import requests
import posixpath
import time
import email.utils
import urllib.parse
@@ -433,6 +434,7 @@ class OnlyofficeGetHistoryFileAccessToken(APIView):
payload['key'] = obj_id
payload['url'] = full_url
payload['version'] = obj_id
payload['exp'] = int(time.time()) + 3 * 24 * 3600
jwt_token = jwt.encode(payload, ONLYOFFICE_JWT_SECRET)
payload['token'] = jwt_token

View File

@@ -152,8 +152,11 @@
showLogoutIcon: {% if show_logout_icon %} true {% else %} false {% endif %},
additionalShareDialogNote: {% if additional_share_dialog_note %} {{ additional_share_dialog_note|safe }} {% else %} null {% endif %},
additionalAboutDialogLinks: {% if additional_about_dialog_links %} {{ additional_about_dialog_links|safe }} {% else %} null {% endif %},
enableOnlyoffice: {% if enableOnlyoffice %} true {% else %} false {% endif %},
onlyofficeConverterExtensions: {% if onlyofficeConverterExtensions %} {{onlyofficeConverterExtensions|safe}} {% else %} null {% endif %},
enableOnlyoffice: {% if enable_onlyoffice %} true {% else %} false {% endif %},
onlyofficeEditFileExtension: {% if onlyoffice_edit_file_extension %} {{onlyoffice_edit_file_extension|safe}} {% else %} [] {% endif %},
onlyofficeConverterExtensions: {% if onlyoffice_converter_extensions %} {{onlyoffice_converter_extensions|safe}} {% else %} null {% endif %},
enableOfficeWebApp: {% if enable_office_web_app %} true {% else %} false {% endif %},
officeWebAppEditFileExtension: {% if office_web_app_edit_file_extension %} {{office_web_app_edit_file_extension|safe}} {% else %} [] {% endif %},
enableSeadoc: {% if enable_seadoc %} true {% else %} false {% endif %},
enableWhiteboard: {% if enable_whiteboard %} true {% else %} false {% endif %},
isOrgContext: {% if org is not None %} true {% else %} false {% endif %},

View File

@@ -398,7 +398,9 @@ def can_preview_file(file_name, file_size, repo):
filesizeformat(FILE_PREVIEW_MAX_SIZE)
return False, error_msg
elif filetype in (DOCUMENT, SPREADSHEET):
elif filetype in (DOCUMENT, SPREADSHEET) or \
fileext in OFFICE_WEB_APP_FILE_EXTENSION or \
fileext in ONLYOFFICE_FILE_EXTENSION:
if repo.encrypted:
error_msg = _('The library is encrypted, can not open file online.')

View File

@@ -13,7 +13,7 @@ OFFICE_WEB_APP_FILE_EXTENSION = getattr(settings, 'OFFICE_WEB_APP_FILE_EXTENSION
ENABLE_OFFICE_WEB_APP_EDIT = getattr(settings, 'ENABLE_OFFICE_WEB_APP_EDIT', False)
OFFICE_WEB_APP_EDIT_FILE_EXTENSION = getattr(settings, 'OFFICE_WEB_APP_EDIT_FILE_EXTENSION', ())
## Client certificates ##
# Client certificates ##
# path to client.cert when use client authentication
OFFICE_WEB_APP_CLIENT_CERT = getattr(settings, 'OFFICE_WEB_APP_CLIENT_CERT', '')
@@ -24,7 +24,7 @@ OFFICE_WEB_APP_CLIENT_KEY = getattr(settings, 'OFFICE_WEB_APP_CLIENT_KEY', '')
OFFICE_WEB_APP_CLIENT_PEM = getattr(settings, 'OFFICE_WEB_APP_CLIENT_PEM', '')
## Server certificates ##
# Server certificates ##
# Path to a CA_BUNDLE file or directory with certificates of trusted CAs
OFFICE_WEB_APP_SERVER_CA = getattr(settings, 'OFFICE_WEB_APP_SERVER_CA', True)
@@ -46,5 +46,3 @@ if settings.ENABLE_MULTIPLE_OFFICE_SUITE:
ENABLE_OFFICE_WEB_APP_EDIT = office_info.get('ENABLE_OFFICE_WEB_APP_EDIT', False)
OFFICE_WEB_APP_FILE_EXTENSION = settings.OFFICE_SUITE_ENABLED_FILE_TYPES
OFFICE_WEB_APP_EDIT_FILE_EXTENSION = settings.OFFICE_SUITE_ENABLED_EDIT_FILE_TYPES