From 6f79c4cf7ed8b0b4cd048817aa90ab12997caabc Mon Sep 17 00:00:00 2001
From: Mark Bakhit
Date: Sun, 24 Sep 2023 23:39:37 -0700
Subject: [PATCH] `view_to_iframe` component (#188)
- The `compatibility` argument on `reactpy_django.components.view_to_component` is deprecated.
- Using `reactpy_django.components.view_to_component` as a decorator is deprecated.
- `reactpy_django.utils.register_iframe` function has been added.
- `reactpy_django.components.view_to_iframe` component has been added
- It is now recommended to call `as_view()` when using `view_to_component` or `view_to_iframe` with Class Based Views.
- Thread sensitivity has been enabled in all locations where ORM queries are possible.
---
CHANGELOG.md | 9 +
docs/python/hello_world_app_config_cbv.py | 11 +
docs/python/hello_world_app_config_fbv.py | 11 +
docs/python/hello_world_args_kwargs.py | 5 +
docs/python/hello_world_cbv.py | 7 +
docs/python/hello_world_fbv.py | 5 +
docs/python/hello_world_fbv_with_id.py | 5 +
docs/python/register-component.py | 5 +-
docs/python/use-mutation-thread-sensitive.py | 2 +-
docs/python/views.py | 7 +
docs/python/vtc-args-kwargs.py | 21 --
docs/python/vtc-args.py | 23 ++
docs/python/vtc-cbv-compatibility.py | 10 -
docs/python/vtc-cbv.py | 12 +-
docs/python/vtc-compatibility.py | 15 -
docs/python/vtc-fbv-compat.py | 8 -
docs/python/vtc-func.py | 12 -
docs/python/vtc-request.py | 20 --
docs/python/vtc-strict-parsing.py | 8 +-
docs/python/vtc-transforms.py | 13 +-
docs/python/vtc.py | 8 +-
docs/python/vti-args.py | 20 ++
docs/python/vti-cbv.py | 13 +
docs/python/vti-extra-props.py | 15 +
docs/python/vti.py | 13 +
docs/src/reference/components.md | 230 +++++++++++----
docs/src/reference/decorators.md | 2 +-
docs/src/reference/hooks.md | 14 +-
docs/src/reference/settings.md | 8 +-
docs/src/reference/utils.md | 80 ++++--
mkdocs.yml | 2 +-
src/reactpy_django/checks.py | 2 +-
src/reactpy_django/components.py | 262 +++++++++++-------
src/reactpy_django/config.py | 5 +-
src/reactpy_django/exceptions.py | 8 +
src/reactpy_django/http/urls.py | 6 +-
src/reactpy_django/http/views.py | 23 +-
.../templates/reactpy/component.html | 2 +-
src/reactpy_django/types.py | 9 -
src/reactpy_django/utils.py | 102 ++++---
src/reactpy_django/websocket/consumer.py | 4 +-
tests/test_app/apps.py | 16 ++
tests/test_app/components.py | 36 ++-
tests/test_app/templates/base.html | 17 +-
tests/test_app/templates/errors.html | 31 +++
tests/test_app/tests/test_components.py | 66 +++--
tests/test_app/urls.py | 1 +
tests/test_app/views.py | 26 +-
48 files changed, 814 insertions(+), 416 deletions(-)
create mode 100644 docs/python/hello_world_app_config_cbv.py
create mode 100644 docs/python/hello_world_app_config_fbv.py
create mode 100644 docs/python/hello_world_args_kwargs.py
create mode 100644 docs/python/hello_world_cbv.py
create mode 100644 docs/python/hello_world_fbv.py
create mode 100644 docs/python/hello_world_fbv_with_id.py
create mode 100644 docs/python/views.py
delete mode 100644 docs/python/vtc-args-kwargs.py
create mode 100644 docs/python/vtc-args.py
delete mode 100644 docs/python/vtc-cbv-compatibility.py
delete mode 100644 docs/python/vtc-compatibility.py
delete mode 100644 docs/python/vtc-fbv-compat.py
delete mode 100644 docs/python/vtc-func.py
delete mode 100644 docs/python/vtc-request.py
create mode 100644 docs/python/vti-args.py
create mode 100644 docs/python/vti-cbv.py
create mode 100644 docs/python/vti-extra-props.py
create mode 100644 docs/python/vti.py
create mode 100644 tests/test_app/apps.py
create mode 100644 tests/test_app/templates/errors.html
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f8f0ec63..cf739c05 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -39,10 +39,19 @@ Using the following categories, list your changes in this order:
- ReactPy components can now use SEO compatible rendering!
- `settings.py:REACTPY_PRERENDER` can be set to `True` to enable this behavior by default
- Or, you can enable it on individual components via the template tag: `{% component "..." prerender="True" %}`
+- `reactpy_django.components.view_to_iframe` component has been added, which uses an `
+ ReactPy Errors Test Page
+
+ {% component "test_app.components.does_not_exist" %}
+
+ {% component "test_app.components.hello_world" invalid_param="random_value" %}
+
+ {% component "test_app.components.hello_world" host="https://example.com/" %}
+
+
+ {% component "test_app.components.broken_postprocessor_query" %}
+
+
+
+ {% component "test_app.components.view_to_iframe_not_registered" %}
+
+
diff --git a/tests/test_app/templates/errors.html b/tests/test_app/templates/errors.html
new file mode 100644
index 00000000..0f6db8db
--- /dev/null
+++ b/tests/test_app/templates/errors.html
@@ -0,0 +1,31 @@
+{% load static %} {% load reactpy %}
+
+
+
+