diff --git a/jupyter_collaboration/app.py b/jupyter_collaboration/app.py index 23f96132..ff337460 100644 --- a/jupyter_collaboration/app.py +++ b/jupyter_collaboration/app.py @@ -5,7 +5,7 @@ import asyncio from jupyter_server.extension.application import ExtensionApp -from traitlets import Float, Type +from traitlets import Bool, Float, Type from ypy_websocket.ystore import BaseYStore from .handlers import DocSessionHandler, YDocWebSocketHandler @@ -17,6 +17,12 @@ class YDocExtension(ExtensionApp): name = "jupyter_collaboration" + app_name = "Collaboration" + description = """ + Enables Real Time Collaboration in JupyterLab + """ + + disable_rtc = Bool(False, config=True, help="Whether to disable real time collaboration.") file_poll_interval = Float( 1, @@ -66,6 +72,10 @@ def initialize_settings(self): ) def initialize_handlers(self): + self.serverapp.web_app.settings.setdefault( + "page_config_data", {"disableRTC": self.disable_rtc} + ) + # Set configurable parameters to YStore class for k, v in self.config.get(self.ystore_class.__name__, {}).items(): setattr(self.ystore_class, k, v) diff --git a/packages/docprovider/src/ydrive.ts b/packages/docprovider/src/ydrive.ts index 0c93cf59..ba622b02 100644 --- a/packages/docprovider/src/ydrive.ts +++ b/packages/docprovider/src/ydrive.ts @@ -1,7 +1,7 @@ // Copyright (c) Jupyter Development Team. // Distributed under the terms of the Modified BSD License. -import { URLExt } from '@jupyterlab/coreutils'; +import { PageConfig, URLExt } from '@jupyterlab/coreutils'; import { TranslationBundle } from '@jupyterlab/translation'; import { Contents, Drive, User } from '@jupyterlab/services'; @@ -14,6 +14,9 @@ import { SharedDocumentFactory } from './tokens'; +const DISABLE_RTC = + PageConfig.getOption('disableRTC') === 'true' ? true : false; + /** * The url for the default drive service. */ @@ -177,7 +180,7 @@ class SharedModelFactory implements ISharedModelFactory { /** * Whether the IDrive supports real-time collaboration or not. */ - readonly collaborative = true; + readonly collaborative = !DISABLE_RTC; /** * Register a SharedDocumentFactory. @@ -208,7 +211,7 @@ class SharedModelFactory implements ISharedModelFactory { return; } - if (!options.collaborative) { + if (!this.collaborative || !options.collaborative) { // Bail if the document model does not support collaboration // the `sharedModel` will be the default one. return; diff --git a/pyproject.toml b/pyproject.toml index b5a4fb34..35964091 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,8 @@ dependencies = [ "jupyter_ydoc>=1.1.0a0,<2.0.0", "ypy-websocket>=0.12.1,<0.13.0", "jupyter_events", - "jupyter_server_fileid>=0.6.0,<1" + "jupyter_server_fileid>=0.6.0,<1", + "jsonschema[format-nongpl,format_nongpl]<4.18.0" # https://github.com/jupyter/jupyter_events/pull/80 ] dynamic = ["version", "description", "authors", "urls", "keywords"]