Commit Graph

2156 Commits

Author SHA1 Message Date
benedikt-bartscher
682bca7f9a
improve StateManagerRedis error message (#4444) 2024-12-13 12:40:38 -08:00
Thomas Brandého
ff510cacc5
enable C4 rule (#4536) 2024-12-13 12:37:34 -08:00
Joodith
ec89702137
Include step attribute in input (#4073)
* Include step attribute in input

* Remove `step` prop from TextField

it is inherited from Input, and does not need to be redefined

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-12-13 11:35:35 -08:00
Elijah Ahianyo
206de4df7a
Unify is_external prop in rx.redirect and rx.link (#4389)
* Unify `is_external` prop in `rx.redirect` and `rx.link`

* default external to `None`

* address PR comment

* use a one-liner

* reorder args for api stability

Co-authored-by: Masen Furer <m_github@0x26.net>

* reorder doc args

* external arg as deprecated in the docs

* Update reflex/event.py

Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>

* Fixup typing_extensions import and ruff

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
2024-12-13 11:27:51 -08:00
Masen Furer
f4aea1b3ab
[ENG-3583] Respect cors_allowed_origins for backend HTTP requests (#4533) 2024-12-13 09:31:27 -08:00
Vy Nguyen
7208540855
Wrap Checkbox component in Context Menu (partial fix for #4262) (#4479)
* Add ContextMenuCheckBoxItem component

* Remove toggle_state method

* Import Checkbox and implement ContextMenuCheckbox class

* Change parameter for create function

* Reformat code and import block

* Removed unused vars

* Format file

* Remove create method

* Reformat code

* Update reflex/components/radix/themes/components/context_menu.py

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Update reflex/components/radix/themes/components/context_menu.py

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Update reflex/components/radix/themes/components/context_menu.py

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Update reflex/components/radix/themes/components/context_menu.py

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>

* Reformat code

* Add automatically modified pyi file

* Update context_menu.pyi file

---------

Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
2024-12-13 01:50:01 +01:00
Elijah Ahianyo
7ca50c62e2
[ENG-4153]Use empty string for None values in rx.input and rx.el.input (#4521)
* Use empty string for None values in `rx.input` and `rx.el.input`

* fix tests

* fix pyi scripts

* use nullish coalescing operator

* fix unit tests

* use ternary operator so old browsers and dynamic components tests pass

* address comment on doing this only for optionals

* Fix tests

* pyright!

* fix comments
2024-12-12 15:24:15 -08:00
Masen Furer
d5d41a0d9e
raise_console_error during integration tests (#4535) 2024-12-12 14:28:30 -08:00
Masen Furer
60a5b7bc7a
[ENG-4194] TypeError: Cannot create property 'token' on string (#4534) 2024-12-12 14:28:17 -08:00
Elijah Ahianyo
c387f517b6
[ENG-4100]Throw warnings when Redis lock is held for more than the allowed threshold (#4522)
* Throw warnings when Redis lock is held for more than the allowed threshold

* initial tests

* fix tests and address comments

* fix tests fr, and use pydantic validators

* darglint fix

* increase lock expiration in tests to 2500

* remove print statement

---------

Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
2024-12-12 11:36:31 -08:00
Masen Furer
2d9849e00a
Fix upload cancellation (#4527)
* Improve assertions in test_cancel_upload

* Fix upload cancellation by using `refs` instead of `upload_controllers`
2024-12-12 10:15:19 -08:00
Masen Furer
adfda8adfd
[ENG-4165] Consider default and default_factory for state vars (#4510)
* [ENG-4165] Consider default and default_factory for state vars

When determining whether a state var should be marked as optional, check that
it is missing both default and default_factory and is not required.

Fix #4471

* add test for default factory with rx.foreach (#4515)

---------

Co-authored-by: benedikt-bartscher <31854409+benedikt-bartscher@users.noreply.github.com>
2024-12-12 10:10:44 -08:00
benedikt-bartscher
1b6f539657
simplify redis code, less redis calls (#4456)
* simplify redis code, less redis calls

* cleanup

* properly ignore non-lock events from redis pubsub, keep timeout
2024-12-12 05:56:42 -08:00
Masen Furer
a2f14e7713
Avoid double JSON encode/decode for socket.io (#4449)
* Avoid double JSON encode/decode for socket.io

socket.io (python and js) already has a built in mechanism for JSON encoding
and decoding messages over the websocket. To use it, we pass a custom `json`
namespace which uses `format.json_dumps` (leveraging reflex serializers) to encode the
messages. This avoids sending a JSON-encoded string of JSON over the wire, and
reduces the number of serialization/deserialization passes over the message
data.

The side benefit is that debugging websocket messages in browser tools displays
the parsed JSON hierarchy and is much easier to work with.

* JSON5.parse in on_upload_progress handler responses
2024-12-12 05:47:23 -08:00
Masen Furer
053cbe7558
bump CI runners to macos-latest (#4526)
* use `macos-latest` runner

macos-12 is deprecated and the jobs don't start anymore, so see if we can run
fine on latest.

* unit_tests.yml: use python versions with arm64 builds
2024-12-12 04:17:28 -08:00
benedikt-bartscher
ea90a3ebfa
minor pickle improvement (#4499) 2024-12-12 02:07:59 -08:00
Thomas Brandého
5e026e4b27
Support python 3.13 (#4206)
* bump playwright and run tests with 3.13

* test with psycopg3

* typo

* update everything for psycopg 3.
2024-12-12 00:10:51 -08:00
Thomas Brandého
a86d2c612a
deprecate add_custom_404_page (#4505)
* deprecate add_custom_404_page

* show raw value in deprecate message

* fix typo

* Update reflex/app.py

Co-authored-by: Masen Furer <m_github@0x26.net>

* change removal version to 0.8.0

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
2024-12-11 18:29:39 -08:00
benedikt-bartscher
a7151cd6c8
disable polling (#4441) 2024-12-11 18:29:01 -08:00
Thomas Brandého
fb444ad112
add ERA rules to detect commented out code (#4472)
* add eradicate rules for commented out code

* remove output change

* fix pyi messed up indent

* fix pyi again

* fix layout docstring

* fix pyi_generator to remove commented out props from docs

* fix pyi_generator and regenerate some pyi

* fix double strip

* update all pyi

* try to fix stuff in pyi_gen

* whatever

* remove that maybe? i don't know

* fix that shit?

* fix more shit, idk

* better not see you ever again, extra line
2024-12-11 18:26:44 -08:00
benedikt-bartscher
e4b5755568
fix: handle default_factory in get_attribute_access_type (#4517)
* fix: handle default_factory in get_attribute_access_type, add tests for sqla dataclasses

* only test classes which have default_factory + add test for no default
2024-12-11 18:22:31 -08:00
Masen Furer
95eb663347
client_state: create Var from value when pushing from backend (#4474)
This ensures that the value is properly escaped/formatted for direct use in
javascript code.
2024-12-11 17:15:17 -08:00
Masen Furer
d75a708e6b
Fix REFLEX_COMPILE_PROCESSES=0 (#4523)
when zero is passed, that is short for "use the default", which is actually
None in the code.

fix for both processes and threads being set to zero
2024-12-11 21:29:33 +01:00
benedikt-bartscher
2ee201b520
raise StateSerializationError if the state cannot be serialized (#4453)
* raise StateSerializationError if the state cannot be serialized

* fix test
2024-12-11 20:08:18 +01:00
Thomas Brandého
862d7ec807
add test for color mode (initial and toggle) (#4467)
* add test for color mode (initial and toggle)

* add css check

* add page reload in the tests

* update test to catch the appearance regression

* don't render the appearance prop of rx.theme
2024-12-11 19:57:51 +01:00
benedikt-bartscher
06d743cda9
fix: migrate is_backend_only (deprecated) to EnvironmentVariables (#4495) 2024-12-11 19:22:44 +01:00
Masen Furer
4922f7ba05
Reuse the sqlalchemy engine once it's created (#4493)
* Reuse the sqlalchemy engine once it's created

* Implement `rx.asession` for async database support

Requires setting `async_db_url` to the same database as `db_url`, except using
an async driver; this will vary by database.

* resolve the url first, so the key into _ENGINE is correct

* Ping db connections before returning them from pool

Move connect engine kwargs to a separate function

* the param is `echo`

* sanity check that config db_url and async_db_url are the same

throw a warning if the part following the `://` differs between these two

* create_async_engine: use sqlalchemy async API

update types

* redact ASYNC_DB_URL similarly to DB_URL when overridden in config

* update rx.asession docstring

* use async_sessionmaker

* Redact sensitive env vars instead of hiding them
2024-12-10 12:37:09 -08:00
benedikt-bartscher
3ef7106e0e
style: prefer type() over __class__ (#4512) 2024-12-10 12:35:46 -08:00
Masen Furer
37af2ee1ec
Revert "reduce lock expiration time to 1s (#4507)" (#4514)
This reverts commit 6e3e632bbd.
2024-12-10 11:12:26 -08:00
Thomas Brandého
fd0fd2c6d4
enable REFURB rules in ruff (#4466)
Co-authored-by: Masen Furer <m_github@0x26.net>
2024-12-10 09:52:03 -08:00
benedikt-bartscher
2520c51aaf
fix: multiple mismatched-type-assignment fixes (#4482)
* fix: only make type optional if it's not already, add helper to unwrap rx.Field

* migrate unwrap_field_type to private function
2024-12-10 09:49:56 -08:00
Thomas Brandého
49a8f813fe
bump ruff to 0.8 and relock poetry (#4451)
* bump ruff to 0.8 and relock poetry

* bump to 0.8.1

* relock poetry.lock

* update again
2024-12-10 09:17:57 -08:00
Elijah Ahianyo
6e42efd2b1
Fix deploy help text (#4508) 2024-12-10 09:15:53 -08:00
Elijah Ahianyo
6e3e632bbd
reduce lock expiration time to 1s (#4507) 2024-12-10 09:15:22 -08:00
Elijah Ahianyo
05b791653e
Default rx.link href to # so underline prop works (#4509) 2024-12-10 09:14:29 -08:00
Thomas Brandého
4ecb0b81ce
enable RUF rules for linting (#4465) 2024-12-10 09:11:50 -08:00
Thomas Brandého
a68eef23aa
add issues templates (#4455)
* add issues templates

* fix typo
2024-12-10 15:37:58 +01:00
Masen Furer
0a34949019
Add production-one-port example (#4489)
* Add production-one-port example

A more complex version of simple-one-port that facilitates better layer caching
to shorten build times and multi-stage build to reduce final image size.

Harder to understand, but ultimately nicer to use.

* fix Caddyfile format to avoid complaints

* docker-examples: bump all base images to python:3.13
2024-12-09 15:26:48 -08:00
benedikt-bartscher
9ff386bf48
add __repr__ method to MutableProxy (#4506) 2024-12-10 00:17:51 +01:00
benedikt-bartscher
3d89d74bdc
only mark backend vars as dirty if they have changed (#4494) 2024-12-09 01:00:01 -08:00
Thomas Brandého
a895eaaede
fix non-interactive flag in deploy command (#4498) 2024-12-06 22:16:21 +01:00
benedikt-bartscher
3a225c2180
test dynamic route flakiness (can't reproduce locally) (#4496)
* test dynamic route flakiness (can't reproduce locally)

* fix typo
2024-12-06 17:41:53 +01:00
Masen Furer
3f4dca21a8
rename loginv2 to login (#4486)
* rename loginv2 to login

* reflex-hosting-cli bump to 0.1.29

* relock deps
2024-12-05 01:17:26 -08:00
Simon Young
12771004cb
remove v2 commands (#4478)
* remove v2 commands

* format

* remove v2

* remove v2

* little fixes friend

* add cloud

* relock poetry deps

* bump reflex-hosting-cli dep

* test_dynamic_routes: wait for token

attempt to avoid test flakiness

* relock deps

* test_dynamic_routes: increase polling timeout

---------

Co-authored-by: simon <simon@reflex.dev>
Co-authored-by: Masen Furer <m_github@0x26.net>
2024-12-04 23:21:18 -08:00
Elijah Ahianyo
e23d939781
[HOS-373][HOS-372]Logout should not open the browser (#4475)
* Logout should not open the browser

* check user login first before deploy
2024-12-04 18:17:22 -08:00
Masen Furer
a894f21ce5
[ENG-4149] require login to deploy named templates (#4450)
* integration_tests.yml: init masenf/rx_shout as a template

fix test

* [ENG-4149] require login to deploy template

* Send loginv2 telemetry event
2024-12-04 18:15:31 -08:00
Thomas Brandého
c721227a06
add default value for text area (#4462)
* add default_value prop in text_area

* also support it for el.textarea
2024-12-03 01:31:32 +01:00
Masen Furer
99d1b5fbdf
rx.upload must include _var_data from props (#4463)
* rx.upload must include _var_data from props

str-casting the dropzone arguments removed any VarData they depended on, like
the state context.

update test_upload to include passing a prop from a state var

* Handle large payload delta from upload event handler

Fix update chunk chaining logic; try/catch wasn't catching errors from the
async inner function.
2024-12-02 16:29:06 -08:00
Thomas Brandého
a320d062fb
enable css props via wrapperStyle for recharts components (#4447) 2024-12-02 09:20:33 -08:00
Masen Furer
39cdce6960
[HOS-333] Send a "reload" message to the frontend after state expiry (#4442)
* Unit test updates

* test_client_storage: simulate backend state expiry

* [HOS-333] Send a "reload" message to the frontend after state expiry

1. a state instance expires on the backing store
2. frontend attempts to process an event against the expired token and gets a
   fresh instance of the state without router_data set
3. backend sends a "reload" message on the websocket containing the event and
   immediately stops processing
4. in response to the "reload" message, frontend sends
   [hydrate, update client storage, on_load, <previous_event>]

This allows the frontend and backend to re-syncronize on the state of the app
before continuing to process regular events.

If the event in (2) is a special hydrate event, then it is processed normally
by the middleware and the "reload" logic is skipped since this indicates an
initial load or a browser refresh.

* unit tests working with redis
2024-11-28 13:56:41 +01:00