Skip to content

Commit 4463be6

Browse files
Enforcing React 18 in Dash and allowing data: in CSP connect-src (#687)
* Enforcing React 18 in Dash and allowing `data:` in CSP `connect-src` * Removed `navigate-to` from CSP * Ignoring shaky test `test_example_wlf_plugin.py` --------- Co-authored-by: Hans Kallekleiv <16436291+HansKallekleiv@users.noreply.github.com>
1 parent 83dac74 commit 4463be6

File tree

7 files changed

+11
-6
lines changed

7 files changed

+11
-6
lines changed

.github/workflows/webviz-config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
- name: 🤖 Run tests
7474
run: |
7575
webviz preferences --theme default
76-
pytest ./tests --headless --forked
76+
pytest ./tests --headless --forked --ignore ./tests/test_example_wlf_plugin.py
7777
webviz docs --portable ./docs_build --skip-open
7878
webviz schema
7979

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- [#655](https://github.com/equinor/webviz-config/pull/655) - Regression fix: Show filters in `TablePlotter` when using `lock` argument.
1010

1111
### Changed
12+
- [#687](https://github.com/equinor/webviz-config/pull/687) - Enforce React 18 in Dash.
13+
- [#687](https://github.com/equinor/webviz-config/pull/687) - Allow `data:` in `connect-src` CSP in order to enable loading of images from data strings. Removed `navigate-to` in CSP as it got deprecated.
1214
- [#648](https://github.com/equinor/webviz-config/pull/648) - Allow `blob:` in `script-src` CSP in order to enable web worker usage in Dash components.
1315
- [#652](https://github.com/equinor/webviz-config/pull/652) - Enabled support for LaTeX math/equations in markdown.
1416
- [#653](https://github.com/equinor/webviz-config/pull/653) - Reduce time for running `webviz --help` by lazy importing top level entrypoints.

webviz_config/_theme_class.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ def __init__(self, theme_name: str):
1212

1313
self._csp = {
1414
"default-src": "'none'",
15-
"connect-src": "'self'",
15+
"connect-src": ["'self'", "data:"],
1616
"style-src": ["'self'", "'unsafe-inline'"], # [1]
1717
"script-src": ["'self'", "blob:", "'unsafe-eval'"], # [blob: 2] [eval: 3]
1818
"img-src": ["'self'", "data:", "blob:"], # [4]
19-
"navigate-to": "'self'",
2019
"base-uri": "'self'",
2120
"form-action": "'self'",
2221
"frame-ancestors": "'self'", # [5]

webviz_config/templates/copy_data_template.py.jinja2

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ theme = webviz_config.WebvizConfigTheme("{{ theme_name }}")
2424
theme.from_json((Path(__file__).resolve().parent / "theme_settings.json").read_text())
2525
theme.plotly_theme_layout_update({{ options.plotly_theme }})
2626

27+
dash._dash_renderer._set_react_version("18.3.1")
28+
2729
app = dash.Dash()
2830
app.config.suppress_callback_exceptions = True
2931

webviz_config/templates/webviz_template.py.jinja2

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ from pathlib import Path
1414

1515
from uuid import uuid4
1616

17-
from dash import html, dcc, Dash, Input, Output, callback, callback_context
17+
from dash import html, dcc, Dash, Input, Output, callback, callback_context, _dash_renderer
1818
import webviz_core_components as wcc
1919
from flask_talisman import Talisman
2020
import webviz_config
@@ -40,6 +40,8 @@ theme = webviz_config.WebvizConfigTheme("{{ theme_name }}")
4040
theme.from_json((Path(__file__).resolve().parent / "theme_settings.json").read_text())
4141
theme.plotly_theme_layout_update({{ options.plotly_theme }})
4242

43+
_dash_renderer._set_react_version("18.3.1")
44+
4345
app = Dash(
4446
name=__name__,
4547
external_stylesheets=theme.external_stylesheets,

webviz_config/testing/_composite.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def start_server(self, plugin: WebvizPluginABC, **kwargs: Any) -> None:
7070

7171
def toggle_webviz_settings_drawer(self) -> None:
7272
"""Open the plugin settings drawer"""
73-
self.wait_for_element(WebvizIds.SETTINGS_DRAWER_TOGGLE_OPEN).click()
73+
self.wait_for_element(WebvizIds.SETTINGS_DRAWER_TOGGLE).click()
7474

7575
def toggle_webviz_settings_group(self, settings_group_id: str) -> None:
7676
"""Open the respective settings group in the settings drawer"""

webviz_config/testing/_webviz_ids.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ class WebvizIds(str, Enum):
66
CONTENT_MANAGER = "webviz-content-manager"
77
SETTINGS_DRAWER = "settings-drawer"
88
PLUGINS_WRAPPER = "plugins-wrapper"
9-
SETTINGS_DRAWER_TOGGLE_OPEN = ".WebvizSettingsDrawer__ToggleOpen"
9+
SETTINGS_DRAWER_TOGGLE = ".WebvizSettingsDrawer__Toggle"

0 commit comments

Comments
 (0)