diff --git a/frontend/src/components/dir-view/dir-panel.js b/frontend/src/components/dir-view/dir-panel.js index 3d74c81cb9..cbbdb52c03 100644 --- a/frontend/src/components/dir-view/dir-panel.js +++ b/frontend/src/components/dir-view/dir-panel.js @@ -18,7 +18,6 @@ const propTypes = { pathPrefix: PropTypes.array.isRequired, path: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired, - dirID: PropTypes.string.isRequired, repoName: PropTypes.string.isRequired, pathExist: PropTypes.bool.isRequired, permission: PropTypes.bool.isRequired, @@ -166,7 +165,6 @@ class DirPanel extends React.Component { ErrMessage : { this.setState({pathExist: false}); }); @@ -462,7 +464,6 @@ class DirView extends React.Component { render() { return ( { - console.log(data); - this.checkFileUpdate(); - }); - } - - checkFileUpdate = () => { - let repoID = this.props.repoID; - let path = this.props.path; - - seafileAPI.dirMetaData(repoID, path).then((res) => { - if (res.data.id !== this.props.dirID) { - toaster.notify({gettext('This folder has been updated. ')}{gettext('Refresh')}, {duration: 3600}); - } - }); - } - - onRefresh = () => { - location.reload(); } onFreezedItem = () => { diff --git a/frontend/src/pages/repo-wiki-mode/main-panel.js b/frontend/src/pages/repo-wiki-mode/main-panel.js index 3fe298a2e6..0050557155 100644 --- a/frontend/src/pages/repo-wiki-mode/main-panel.js +++ b/frontend/src/pages/repo-wiki-mode/main-panel.js @@ -30,7 +30,6 @@ const propTypes = { isDirentSelected: PropTypes.bool.isRequired, isAllDirentSelected: PropTypes.bool.isRequired, direntList: PropTypes.array.isRequired, - dirID: PropTypes.string.isRequired, selectedDirentList: PropTypes.array.isRequired, updateDirent: PropTypes.func.isRequired, onSideNavMenuClick: PropTypes.func.isRequired, @@ -245,7 +244,6 @@ class MainPanel extends Component { /> : { + seafileAPI.dirMetaData(repoID, path).then((res) => { + if (res.data.id !== dirID) { + toaster.notify( + + {gettext('This folder has been updated. ')} + {gettext('Refresh')} + , + {duration: 3600} + ); + } + }) + }) + } + + unwatchRepo() { + socket.off() + } +} + +const collabServer = new CollabServer(); + +export default collabServer; diff --git a/frontend/src/utils/constants.js b/frontend/src/utils/constants.js index 593edd042a..8fb88d4ed3 100644 --- a/frontend/src/utils/constants.js +++ b/frontend/src/utils/constants.js @@ -14,6 +14,9 @@ export const lang = window.app.config.lang; export const fileServerRoot = window.app.config.fileServerRoot; //pageOptions +export const seafileCollabServer = window.app.pageOptions.seafileCollabServer; +export const name = window.app.pageOptions.name; +export const contactEmail = window.app.pageOptions.contactEmail; export const username = window.app.pageOptions.username; export const canGenerateShareLink = window.app.pageOptions.canGenerateShareLink === 'True'; export const canGenerateUploadLink = window.app.pageOptions.canGenerateUploadLink === 'True'; diff --git a/seahub/templates/base_for_react.html b/seahub/templates/base_for_react.html index 7101813528..47fa5e8429 100644 --- a/seahub/templates/base_for_react.html +++ b/seahub/templates/base_for_react.html @@ -37,6 +37,9 @@ fileServerRoot: '{{ FILE_SERVER_ROOT }}' }, pageOptions: { + seafileCollabServer: '{{seafile_collab_server}}', + name: "{{request.user.username|email2nickname|escapejs}}", + contactEmail: "{{request.user.username|email2contact_email|escapejs}}", username: "{{request.user.username|escapejs}}", canGenerateShareLink: '{{ user.permissions.can_generate_share_link }}', canGenerateUploadLink: '{{ user.permissions.can_generate_upload_link }}', diff --git a/seahub/views/__init__.py b/seahub/views/__init__.py index 7204a56df4..3f99b12f74 100644 --- a/seahub/views/__init__.py +++ b/seahub/views/__init__.py @@ -55,7 +55,7 @@ import seahub.settings as settings from seahub.settings import AVATAR_FILE_STORAGE, \ ENABLE_SUB_LIBRARY, ENABLE_FOLDER_PERM, ENABLE_REPO_SNAPSHOT_LABEL, \ UNREAD_NOTIFICATIONS_REQUEST_INTERVAL, SHARE_LINK_EXPIRE_DAYS_MIN, \ - SHARE_LINK_EXPIRE_DAYS_MAX, SHARE_LINK_EXPIRE_DAYS_DEFAULT + SHARE_LINK_EXPIRE_DAYS_MAX, SHARE_LINK_EXPIRE_DAYS_DEFAULT, SEAFILE_COLLAB_SERVER from seahub.wopi.settings import ENABLE_OFFICE_WEB_APP from seahub.onlyoffice.settings import ENABLE_ONLYOFFICE @@ -713,6 +713,7 @@ def libraries(request): if use_new_page: return render(request, "react_app.html", { + 'seafile_collab_server': SEAFILE_COLLAB_SERVER, 'storages': get_library_storages(request), 'enable_wiki': settings.ENABLE_WIKI, 'enable_repo_snapshot_label': settings.ENABLE_REPO_SNAPSHOT_LABEL, @@ -1220,6 +1221,7 @@ def choose_register(request): def react_fake_view(request): return render(request, "react_app.html", { + 'seafile_collab_server': SEAFILE_COLLAB_SERVER, 'storages': get_library_storages(request), 'enable_wiki': settings.ENABLE_WIKI, 'enable_repo_snapshot_label': settings.ENABLE_REPO_SNAPSHOT_LABEL, diff --git a/seahub/views/repo.py b/seahub/views/repo.py index f42cee0d16..c1c34bf1bb 100644 --- a/seahub/views/repo.py +++ b/seahub/views/repo.py @@ -29,6 +29,7 @@ from seahub.settings import ENABLE_UPLOAD_FOLDER, \ THUMBNAIL_ROOT, THUMBNAIL_DEFAULT_SIZE, THUMBNAIL_SIZE_FOR_GRID, \ MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD, SHARE_LINK_EXPIRE_DAYS_MIN, \ SHARE_LINK_EXPIRE_DAYS_MAX + MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD, SEAFILE_COLLAB_SERVER from seahub.utils.file_types import IMAGE, VIDEO from seahub.thumbnail.utils import get_share_link_thumbnail_src from seahub.constants import HASH_URLS @@ -179,6 +180,7 @@ def view_lib_as_wiki(request, repo_id, path): user_can_write = False return render(request, 'view_lib_as_wiki.html', { + 'seafile_collab_server': SEAFILE_COLLAB_SERVER, 'repo_id': repo_id, 'service_url': get_service_url().rstrip('/'), 'initial_path': path,