Skip to content

Commit 5190a17

Browse files
authored
Adds a flag to disable RTC (#177)
* Adds a flag to disable RTC * Temporarily fix for tests
1 parent 8267706 commit 5190a17

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

jupyter_collaboration/app.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import asyncio
66

77
from jupyter_server.extension.application import ExtensionApp
8-
from traitlets import Float, Type
8+
from traitlets import Bool, Float, Type
99
from ypy_websocket.ystore import BaseYStore
1010

1111
from .handlers import DocSessionHandler, YDocWebSocketHandler
@@ -17,6 +17,12 @@
1717

1818
class YDocExtension(ExtensionApp):
1919
name = "jupyter_collaboration"
20+
app_name = "Collaboration"
21+
description = """
22+
Enables Real Time Collaboration in JupyterLab
23+
"""
24+
25+
disable_rtc = Bool(False, config=True, help="Whether to disable real time collaboration.")
2026

2127
file_poll_interval = Float(
2228
1,
@@ -66,6 +72,10 @@ def initialize_settings(self):
6672
)
6773

6874
def initialize_handlers(self):
75+
self.serverapp.web_app.settings.setdefault(
76+
"page_config_data", {"disableRTC": self.disable_rtc}
77+
)
78+
6979
# Set configurable parameters to YStore class
7080
for k, v in self.config.get(self.ystore_class.__name__, {}).items():
7181
setattr(self.ystore_class, k, v)

packages/docprovider/src/ydrive.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Jupyter Development Team.
22
// Distributed under the terms of the Modified BSD License.
33

4-
import { URLExt } from '@jupyterlab/coreutils';
4+
import { PageConfig, URLExt } from '@jupyterlab/coreutils';
55
import { TranslationBundle } from '@jupyterlab/translation';
66
import { Contents, Drive, User } from '@jupyterlab/services';
77

@@ -14,6 +14,9 @@ import {
1414
SharedDocumentFactory
1515
} from './tokens';
1616

17+
const DISABLE_RTC =
18+
PageConfig.getOption('disableRTC') === 'true' ? true : false;
19+
1720
/**
1821
* The url for the default drive service.
1922
*/
@@ -177,7 +180,7 @@ class SharedModelFactory implements ISharedModelFactory {
177180
/**
178181
* Whether the IDrive supports real-time collaboration or not.
179182
*/
180-
readonly collaborative = true;
183+
readonly collaborative = !DISABLE_RTC;
181184

182185
/**
183186
* Register a SharedDocumentFactory.
@@ -208,7 +211,7 @@ class SharedModelFactory implements ISharedModelFactory {
208211
return;
209212
}
210213

211-
if (!options.collaborative) {
214+
if (!this.collaborative || !options.collaborative) {
212215
// Bail if the document model does not support collaboration
213216
// the `sharedModel` will be the default one.
214217
return;

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ dependencies = [
3131
"jupyter_ydoc>=1.1.0a0,<2.0.0",
3232
"ypy-websocket>=0.12.1,<0.13.0",
3333
"jupyter_events",
34-
"jupyter_server_fileid>=0.6.0,<1"
34+
"jupyter_server_fileid>=0.6.0,<1",
35+
"jsonschema[format-nongpl,format_nongpl]<4.18.0" # https://github.com/jupyter/jupyter_events/pull/80
3536
]
3637
dynamic = ["version", "description", "authors", "urls", "keywords"]
3738

0 commit comments

Comments
 (0)