Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Delay list -> dict conversation to end (#192)" #234

Merged
merged 1 commit into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion jupyterlab_server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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


Expand Down
9 changes: 1 addition & 8 deletions jupyterlab_server/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Module globals
# -----------------------------------------------------------------------------

MASTER_URL_PATTERN = r'/(?P<mode>{}|doc)(?P<workspace>/workspaces/[a-zA-Z0-9\-\_]+)?(?P<tree>/tree/.*)?'
MASTER_URL_PATTERN = '/(?P<mode>{}|doc)(?P<workspace>/workspaces/[a-zA-Z0-9\-\_]+)?(?P<tree>/tree/.*)?'

DEFAULT_TEMPLATE = template.Template("""
<!DOCTYPE html>
Expand Down Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions jupyterlab_server/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)),
Expand Down
20 changes: 0 additions & 20 deletions jupyterlab_server/tests/test_labapp.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""Basic tests for the lab handlers.
"""

import json
import pytest
import re
import tornado

from .utils import expected_http_error
Expand All @@ -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'<script id="jupyter-config-data" type="application/json">(?P<page_config>.*?)</script>',
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)
Expand Down