diff --git a/frontend/src/utils/constants.js b/frontend/src/utils/constants.js index 91eb515d60..c5f5b00831 100644 --- a/frontend/src/utils/constants.js +++ b/frontend/src/utils/constants.js @@ -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; diff --git a/frontend/src/utils/utils.js b/frontend/src/utils/utils.js index 3319cb0f2d..51a15f1b13 100644 --- a/frontend/src/utils/utils.js +++ b/frontend/src/utils/utils.js @@ -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 diff --git a/seahub/base/context_processors.py b/seahub/base/context_processors.py index 721db067f0..8bfbaa00a4 100644 --- a/seahub/base/context_processors.py +++ b/seahub/base/context_processors.py @@ -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, diff --git a/seahub/onlyoffice/settings.py b/seahub/onlyoffice/settings.py index 56a2842469..1cb69ab524 100644 --- a/seahub/onlyoffice/settings.py +++ b/seahub/onlyoffice/settings.py @@ -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 - - \ No newline at end of file diff --git a/seahub/templates/base_for_react.html b/seahub/templates/base_for_react.html index 400c06a4b2..1f246a43c0 100644 --- a/seahub/templates/base_for_react.html +++ b/seahub/templates/base_for_react.html @@ -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 %}, diff --git a/seahub/views/file.py b/seahub/views/file.py index 1a2d5f9b5c..2dc9e20fef 100644 --- a/seahub/views/file.py +++ b/seahub/views/file.py @@ -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.') diff --git a/seahub/wopi/settings.py b/seahub/wopi/settings.py index 6d933222da..15b5771429 100644 --- a/seahub/wopi/settings.py +++ b/seahub/wopi/settings.py @@ -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 - -