diff --git a/jupyterlab_server/config.py b/jupyterlab_server/config.py index c978288f..342eb2b9 100644 --- a/jupyterlab_server/config.py +++ b/jupyterlab_server/config.py @@ -97,7 +97,7 @@ def get_page_config(labextensions_path, app_settings_dir=None, logger=None): # Convert lists to dicts for key in [disabled_key, "deferredExtensions"]: if key in data: - data[key] = dict((k, True) for k in data[key]) + data[key] = dict((key, True) for key in data[key]) recursive_update(page_config, data) @@ -167,6 +167,12 @@ def get_page_config(labextensions_path, app_settings_dir=None, logger=None): rollup_disabled.update(page_config.get(disabled_key, [])) page_config[disabled_key] = rollup_disabled + # Convert dictionaries to lists to give to the front end + for (key, value) in page_config.items(): + + if isinstance(value, dict): + page_config[key] = [subkey for subkey in value if value[subkey]] + return page_config diff --git a/jupyterlab_server/handlers.py b/jupyterlab_server/handlers.py index 4d1cb9c8..1b500c84 100755 --- a/jupyterlab_server/handlers.py +++ b/jupyterlab_server/handlers.py @@ -25,7 +25,7 @@ # Module globals # ----------------------------------------------------------------------------- -MASTER_URL_PATTERN = r'/(?P{}|doc)(?P/workspaces/[a-zA-Z0-9\-\_]+)?(?P/tree/.*)?' +MASTER_URL_PATTERN = '/(?P{}|doc)(?P/workspaces/[a-zA-Z0-9\-\_]+)?(?P/tree/.*)?' DEFAULT_TEMPLATE = template.Template(""" @@ -127,13 +127,6 @@ def get_page_config(self): if page_config_hook: page_config = page_config_hook(self, page_config) - # Convert dictionaries to lists to give to the front end - # copy first, so that we don't have converted values in page_copy that we have a ref to - page_config = page_config.copy() - for (key, value) in page_config.items(): - if isinstance(value, dict): - page_config[key] = [subkey for subkey in value if value[subkey]] - return page_config @web.authenticated diff --git a/jupyterlab_server/pytest_plugin.py b/jupyterlab_server/pytest_plugin.py index 2c71c2f5..b941de4b 100644 --- a/jupyterlab_server/pytest_plugin.py +++ b/jupyterlab_server/pytest_plugin.py @@ -112,15 +112,6 @@ def _make_labserver_extension_app(**kwargs): data = dict(name=target_name, jupyterlab=dict(extension=True)) json.dump(data, fid) - # Disable an extension in page config - app_page_config = pjoin(app_settings_dir, 'page_config.json') - with open(app_page_config, mode="w", encoding='utf-8') as fid: - json.dump({ - "disabledExtensions": { - "@foo/bar:plugin": True - } - }, fid) - # Copy the overrides file. src = pjoin( os.path.abspath(os.path.dirname(__file__)), diff --git a/jupyterlab_server/tests/test_labapp.py b/jupyterlab_server/tests/test_labapp.py index 5eb51c30..6aa6f9ec 100644 --- a/jupyterlab_server/tests/test_labapp.py +++ b/jupyterlab_server/tests/test_labapp.py @@ -1,9 +1,7 @@ """Basic tests for the lab handlers. """ -import json import pytest -import re import tornado from .utils import expected_http_error @@ -30,24 +28,6 @@ async def test_lab_handler(notebooks, jp_fetch): assert "JupyterLab Server Application" in html -async def test_page_config(labserverapp, jp_fetch): - settings = labserverapp.serverapp.web_app.settings - page_config = settings.setdefault('page_config_data', {}) - # In labserverapp fixture, we dump a page_config file that also disables "@foo/bar:plugin" - # Here we check that we correctly merge those settings with page_config_data in settings - page_config.setdefault("disabledExtensions", {"@acme/paint:plugin": True}) - r = await jp_fetch('lab', 'jlab_test_notebooks') - assert r.code == 200 - # Check that the lab template is loaded - html = r.body.decode() - m = re.search( - r'', - html, - re.MULTILINE | re.DOTALL - ) - page_config = json.loads(m.group("page_config")) - assert sorted(page_config['disabledExtensions']) == ["@acme/paint:plugin", "@foo/bar:plugin"] - async def test_notebook_handler(notebooks, jp_fetch): for nbpath in notebooks: r = await jp_fetch('lab', nbpath)