From 39c1cfd72de9f09255b5a2e3896de6f52edb54ce Mon Sep 17 00:00:00 2001 From: Reimar Stier Date: Thu, 9 Jan 2025 17:35:43 +0100 Subject: [PATCH] LEA -> WIP: Major upgrade to leptos 0.7 --- Cargo.lock | 630 ++++++++++++++++-- Cargo.toml | 6 +- opendut-carl/opendut-carl-api/src/carl/mod.rs | 4 +- opendut-lea/Cargo.toml | 2 +- opendut-lea/src/about/overview.rs | 4 +- opendut-lea/src/app.rs | 22 +- opendut-lea/src/clusters/card.rs | 4 +- .../components/create_cluster_button.rs | 2 +- .../components/cluster_name_input.rs | 2 +- .../configurator/components/controls.rs | 10 +- .../components/device_selector.rs | 141 ++-- .../components/leader_selector.rs | 2 +- .../clusters/configurator/components/mod.rs | 6 +- opendut-lea/src/clusters/configurator/mod.rs | 12 +- .../src/clusters/configurator/tabs/devices.rs | 2 +- .../src/clusters/configurator/tabs/general.rs | 2 +- .../src/clusters/configurator/tabs/leader.rs | 2 +- opendut-lea/src/clusters/overview.rs | 16 +- opendut-lea/src/components/auth.rs | 2 +- opendut-lea/src/components/authenticated.rs | 4 +- opendut-lea/src/components/breadcrumbs.rs | 2 +- opendut-lea/src/components/buttons/button.rs | 3 +- .../components/buttons/confirmation_button.rs | 6 +- .../components/buttons/doorhanger_button.rs | 11 +- .../src/components/buttons/icon_button.rs | 2 +- opendut-lea/src/components/doorhanger.rs | 6 +- opendut-lea/src/components/health.rs | 4 +- .../src/components/inputs/readonly_input.rs | 2 +- .../src/components/inputs/user_input.rs | 3 +- .../src/components/inputs/user_textarea.rs | 3 +- .../components/inputs/vector_user_input.rs | 10 +- opendut-lea/src/components/mod.rs | 22 +- opendut-lea/src/components/page.rs | 2 +- opendut-lea/src/components/toast/builder.rs | 6 +- opendut-lea/src/components/toast/container.rs | 4 +- opendut-lea/src/components/toast/mod.rs | 18 +- .../src/components/toast/notification.rs | 3 +- opendut-lea/src/components/tooltip.rs | 2 +- opendut-lea/src/components/util.rs | 27 +- opendut-lea/src/dashboard/mod.rs | 2 +- opendut-lea/src/downloads/cleo_card.rs | 127 ++-- opendut-lea/src/downloads/edgar_card.rs | 4 +- opendut-lea/src/downloads/view.rs | 4 +- opendut-lea/src/error/mod.rs | 4 +- opendut-lea/src/licenses/overview.rs | 4 +- opendut-lea/src/main.rs | 2 +- opendut-lea/src/nav.rs | 13 +- opendut-lea/src/peers/card.rs | 4 +- .../peers/components/create_peer_button.rs | 2 +- .../peers/configurator/components/controls.rs | 6 +- .../components/peer_location_input.rs | 2 +- .../components/peer_name_input.rs | 2 +- opendut-lea/src/peers/configurator/mod.rs | 26 +- .../configurator/tabs/devices/device_panel.rs | 6 +- .../peers/configurator/tabs/devices/mod.rs | 7 +- .../tabs/executor/executor_panel.rs | 12 +- .../peers/configurator/tabs/executor/mod.rs | 6 +- .../peers/configurator/tabs/general/mod.rs | 3 +- .../tabs/network/bridge_name_input.rs | 2 +- .../peers/configurator/tabs/network/mod.rs | 16 +- .../tabs/network/network_interface_input.rs | 16 +- .../src/peers/configurator/tabs/setup/mod.rs | 7 +- opendut-lea/src/peers/configurator/types.rs | 2 +- opendut-lea/src/peers/overview.rs | 18 +- opendut-lea/src/routing.rs | 37 +- opendut-lea/src/user/mod.rs | 3 +- opendut-lea/src/user/overview.rs | 5 +- opendut-lea/src/util/clipboard.rs | 12 +- opendut-lea/src/util/view.rs | 2 +- 69 files changed, 983 insertions(+), 384 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7bbfbea6a..78c917f3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -150,6 +150,17 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "any_spawner" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41058deaa38c9d9dd933d6d238d825227cffa668e2839b52879f6619c63eee3b" +dependencies = [ + "futures", + "thiserror 2.0.6", + "wasm-bindgen-futures", +] + [[package]] name = "anyhow" version = "1.0.94" @@ -192,6 +203,17 @@ dependencies = [ "tempfile", ] +[[package]] +name = "async-lock" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + [[package]] name = "async-recursion" version = "1.1.1" @@ -248,9 +270,23 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f1ee502851995027b06f99f5ffbeffa1406b38d0b318a1ebfa469332c6cbafd" dependencies = [ - "attribute-derive-macro", + "attribute-derive-macro 0.9.2", "derive-where", - "manyhow", + "manyhow 0.10.4", + "proc-macro2", + "quote", + "syn 2.0.90", +] + +[[package]] +name = "attribute-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0053e96dd3bec5b4879c23a138d6ef26f2cb936c9cdc96274ac2b9ed44b5bb54" +dependencies = [ + "attribute-derive-macro 0.10.3", + "derive-where", + "manyhow 0.11.4", "proc-macro2", "quote", "syn 2.0.90", @@ -264,7 +300,7 @@ checksum = "3601467f634cfe36c4780ca9c75dea9a5b34529c1f2810676a337e7e0997f954" dependencies = [ "collection_literals", "interpolator", - "manyhow", + "manyhow 0.10.4", "proc-macro-utils 0.8.0", "proc-macro2", "quote", @@ -272,6 +308,22 @@ dependencies = [ "syn 2.0.90", ] +[[package]] +name = "attribute-derive-macro" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "463b53ad0fd5b460af4b1915fe045ff4d946d025fb6c4dc3337752eaa980f71b" +dependencies = [ + "collection_literals", + "interpolator", + "manyhow 0.11.4", + "proc-macro-utils 0.10.0", + "proc-macro2", + "quote", + "quote-use", + "syn 2.0.90", +] + [[package]] name = "autocfg" version = "1.4.0" @@ -955,6 +1007,15 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "config" version = "0.14.0" @@ -1036,6 +1097,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "const_str_slice_concat" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f67855af358fcb20fac58f9d714c94e2b228fe5694c1c9b4ead4a366343eda1b" + [[package]] name = "constant_time_eq" version = "0.3.1" @@ -1395,6 +1462,20 @@ dependencies = [ "parking_lot_core 0.9.10", ] +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core 0.9.10", +] + [[package]] name = "debugid" version = "0.8.0" @@ -1720,6 +1801,15 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "either_of" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2dc0006c5cf511f802ddcffc0a6df9dcc1912f5f0e448f6641b3b035f14f43d" +dependencies = [ + "pin-project-lite", +] + [[package]] name = "elliptic-curve" version = "0.13.8" @@ -1816,6 +1906,27 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "event-listener" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3e4e0dd3673c1139bf041f3008816d9cf2946bbfac2945c09e523b8d7b05b2" +dependencies = [ + "event-listener", + "pin-project-lite", +] + [[package]] name = "fallible-iterator" version = "0.3.0" @@ -1985,6 +2096,7 @@ dependencies = [ "futures-core", "futures-task", "futures-util", + "num_cpus", ] [[package]] @@ -2219,6 +2331,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "guardian" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "493913a18c0d7bebb75127a26a432162c59edbe06f6cf712001e3e769345e8b5" + [[package]] name = "h2" version = "0.4.7" @@ -2295,6 +2413,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + [[package]] name = "hex" version = "0.4.3" @@ -2400,6 +2524,20 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "hydration_context" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d35485b3dcbf7e044b8f28c73f04f13e7b509c2466fd10cb2a8a447e38f8a93a" +dependencies = [ + "futures", + "once_cell", + "or_poisoned", + "pin-project-lite", + "serde", + "throw_error", +] + [[package]] name = "hyper" version = "1.5.1" @@ -2914,15 +3052,50 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cbb3237c274dadf00dcc27db96c52601b40375117178fb24a991cda073624f0" dependencies = [ "cfg-if", - "leptos_config", - "leptos_dom", - "leptos_macro", + "leptos_config 0.6.15", + "leptos_dom 0.6.15", + "leptos_macro 0.6.15", "leptos_reactive", - "leptos_server", - "server_fn", + "leptos_server 0.6.15", + "server_fn 0.6.15", "tracing", - "typed-builder", - "typed-builder-macro", + "typed-builder 0.18.2", + "typed-builder-macro 0.18.2", + "web-sys", +] + +[[package]] +name = "leptos" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8a90c679094979aa12927e8e925fe8eead1420d69420b2d8c6540863937ca75" +dependencies = [ + "any_spawner", + "cfg-if", + "either_of", + "futures", + "getrandom", + "hydration_context", + "leptos_config 0.7.3", + "leptos_dom 0.7.3", + "leptos_hot_reload 0.7.3", + "leptos_macro 0.7.3", + "leptos_server 0.7.3", + "oco_ref 0.2.0", + "or_poisoned", + "paste", + "reactive_graph", + "rustc-hash 2.1.0", + "send_wrapper", + "serde", + "serde_qs 0.13.0", + "server_fn 0.7.3", + "slotmap", + "tachys", + "thiserror 2.0.6", + "throw_error", + "typed-builder 0.20.0", + "typed-builder-macro 0.20.0", "wasm-bindgen", "web-sys", ] @@ -2935,15 +3108,36 @@ checksum = "5ad813007f413c960b33437371c0d0a3d6e6159da2357147429a2e79b0423932" dependencies = [ "cfg-if", "codee", + "default-struct-builder", + "js-sys", + "lazy_static", + "leptos 0.6.15", + "paste", + "thiserror 1.0.69", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "leptos-use" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1af542655ab0c5e93238774c5a60f4d5541ad2c61bb6552d520d29eebcb60351" +dependencies = [ + "cfg-if", + "chrono", + "codee", "cookie", "default-struct-builder", "futures-util", "gloo-timers", "js-sys", "lazy_static", - "leptos", + "leptos 0.7.3", "paste", - "thiserror 1.0.69", + "send_wrapper", + "thiserror 2.0.6", "unic-langid", "wasm-bindgen", "wasm-bindgen-futures", @@ -2960,7 +3154,20 @@ dependencies = [ "regex", "serde", "thiserror 1.0.69", - "typed-builder", + "typed-builder 0.18.2", +] + +[[package]] +name = "leptos_config" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c712e1ed3283d1acb842cef4cbcce7b2987a347cc1bf7141195e01f92bb8590d" +dependencies = [ + "config 0.14.1", + "regex", + "serde", + "thiserror 2.0.6", + "typed-builder 0.20.0", ] [[package]] @@ -2985,7 +3192,7 @@ dependencies = [ "rustc-hash 1.1.0", "serde", "serde_json", - "server_fn", + "server_fn 0.6.15", "smallvec", "tracing", "wasm-bindgen", @@ -2993,6 +3200,21 @@ dependencies = [ "web-sys", ] +[[package]] +name = "leptos_dom" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99803be421344a2184fd5796e1a7645c2090738b2ab5d1a856084816853ec322" +dependencies = [ + "js-sys", + "or_poisoned", + "reactive_graph", + "send_wrapper", + "tachys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "leptos_hot_reload" version = "0.6.15" @@ -3005,7 +3227,25 @@ dependencies = [ "parking_lot 0.12.3", "proc-macro2", "quote", - "rstml", + "rstml 0.11.2", + "serde", + "syn 2.0.90", + "walkdir", +] + +[[package]] +name = "leptos_hot_reload" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92413c6d93a22d8c4e75b2e7da3867af173e8d9ca49ce170b631e7c2766eef48" +dependencies = [ + "anyhow", + "camino", + "indexmap 2.7.0", + "parking_lot 0.12.3", + "proc-macro2", + "quote", + "rstml 0.12.0", "serde", "syn 2.0.90", "walkdir", @@ -3017,23 +3257,45 @@ version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b13bc3db70715cd8218c4535a5af3ae3c0e5fea6f018531fc339377b36bc0e0" dependencies = [ - "attribute-derive", + "attribute-derive 0.9.2", "cfg-if", "convert_case", "html-escape", "itertools 0.12.1", - "leptos_hot_reload", + "leptos_hot_reload 0.6.15", "prettyplease", "proc-macro-error2", "proc-macro2", "quote", - "rstml", - "server_fn_macro", + "rstml 0.11.2", + "server_fn_macro 0.6.15", "syn 2.0.90", "tracing", "uuid", ] +[[package]] +name = "leptos_macro" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20bcb2afa03e0614c64eec4a95ec2986fd3c59358daa0f50006e081bc1bd1067" +dependencies = [ + "attribute-derive 0.10.3", + "cfg-if", + "convert_case", + "html-escape", + "itertools 0.13.0", + "leptos_hot_reload 0.7.3", + "prettyplease", + "proc-macro-error2", + "proc-macro2", + "quote", + "rstml 0.12.0", + "server_fn_macro 0.7.3", + "syn 2.0.90", + "uuid", +] + [[package]] name = "leptos_oidc" version = "0.7.0" @@ -3042,9 +3304,9 @@ dependencies = [ "chrono", "codee", "jsonwebtoken", - "leptos", - "leptos-use", - "leptos_router", + "leptos 0.6.15", + "leptos-use 0.13.11", + "leptos_router 0.6.15", "oauth2 4.4.2", "reqwest", "serde", @@ -3064,8 +3326,7 @@ dependencies = [ "cfg-if", "futures", "indexmap 2.7.0", - "js-sys", - "oco_ref", + "oco_ref 0.1.1", "paste", "pin-project", "rustc-hash 1.1.0", @@ -3076,9 +3337,7 @@ dependencies = [ "slotmap", "thiserror 1.0.69", "tracing", - "wasm-bindgen", "wasm-bindgen-futures", - "web-sys", ] [[package]] @@ -3092,7 +3351,7 @@ dependencies = [ "itertools 0.12.1", "js-sys", "lazy_static", - "leptos", + "leptos 0.6.15", "linear-map", "once_cell", "percent-encoding", @@ -3107,6 +3366,41 @@ dependencies = [ "web-sys", ] +[[package]] +name = "leptos_router" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ff7d8c058b4bd7512fa58224b684d5da10d5f056171b8e27d516e0d36e1a5d" +dependencies = [ + "any_spawner", + "either_of", + "futures", + "gloo-net", + "js-sys", + "leptos 0.7.3", + "leptos_router_macro", + "once_cell", + "or_poisoned", + "reactive_graph", + "send_wrapper", + "tachys", + "thiserror 2.0.6", + "url", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "leptos_router_macro" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15a48035e8d796233a5b43322aeab9387f946f914dacdf17a1981c3910879b19" +dependencies = [ + "proc-macro-error2", + "proc-macro2", + "quote", +] + [[package]] name = "leptos_server" version = "0.6.15" @@ -3115,14 +3409,34 @@ checksum = "4a97eb90a13f71500b831c7119ddd3bdd0d7ae0a6b0487cade4fddeed3b8c03f" dependencies = [ "inventory", "lazy_static", - "leptos_macro", + "leptos_macro 0.6.15", "leptos_reactive", "serde", - "server_fn", + "server_fn 0.6.15", "thiserror 1.0.69", "tracing", ] +[[package]] +name = "leptos_server" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fb23bd110ac04c7276aae3d8ba523f94cf06989d00b4e76eaee89451b06b494" +dependencies = [ + "any_spawner", + "base64 0.22.1", + "codee", + "futures", + "hydration_context", + "or_poisoned", + "reactive_graph", + "send_wrapper", + "serde", + "serde_json", + "server_fn 0.7.3", + "tachys", +] + [[package]] name = "libc" version = "0.2.168" @@ -3249,7 +3563,19 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91ea592d76c0b6471965708ccff7e6a5d277f676b90ab31f4d3f3fc77fade64" dependencies = [ - "manyhow-macros", + "manyhow-macros 0.10.4", + "proc-macro2", + "quote", + "syn 2.0.90", +] + +[[package]] +name = "manyhow" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b33efb3ca6d3b07393750d4030418d594ab1139cee518f0dc88db70fec873587" +dependencies = [ + "manyhow-macros 0.11.4", "proc-macro2", "quote", "syn 2.0.90", @@ -3266,6 +3592,17 @@ dependencies = [ "quote", ] +[[package]] +name = "manyhow-macros" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46fce34d199b78b6e6073abf984c9cf5fd3e9330145a93ee0738a7443e371495" +dependencies = [ + "proc-macro-utils 0.10.0", + "proc-macro2", + "quote", +] + [[package]] name = "matchers" version = "0.1.0" @@ -3474,6 +3811,12 @@ dependencies = [ "tokio", ] +[[package]] +name = "next_tuple" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60993920e071b0c9b66f14e2b32740a4e27ffc82854dcd72035887f336a09a28" + [[package]] name = "nix" version = "0.27.1" @@ -3595,6 +3938,16 @@ dependencies = [ "libm", ] +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "num_threads" version = "0.1.7" @@ -3671,6 +4024,16 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "oco_ref" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64b94982fe39a861561cf67ff17a7849f2cedadbbad960a797634032b7abb998" +dependencies = [ + "serde", + "thiserror 1.0.69", +] + [[package]] name = "once_cell" version = "1.20.2" @@ -3801,7 +4164,7 @@ dependencies = [ "googletest", "http 1.2.0", "jsonwebtoken", - "leptos", + "leptos 0.7.3", "opendut-auth", "opendut-types", "opendut-util-core", @@ -3971,10 +4334,10 @@ dependencies = [ "console_error_panic_hook", "gloo-net", "jsonwebtoken", - "leptos", - "leptos-use", + "leptos 0.7.3", + "leptos-use 0.15.3", "leptos_oidc", - "leptos_router", + "leptos_router 0.7.3", "opendut-auth", "opendut-carl-api", "opendut-types", @@ -4272,6 +4635,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "or_poisoned" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c04f5d74368e4d0dfe06c45c8627c81bd7c317d52762d118fb9b3076f6420fd" + [[package]] name = "ordered-float" version = "2.10.1" @@ -4317,6 +4686,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56d80efc4b6721e8be2a10a5df21a30fa0b470f1539e53d8b4e6e75faf938b63" +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + [[package]] name = "parking_lot" version = "0.11.2" @@ -4975,6 +5350,55 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "reactive_graph" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bee22d7574c73fbfd47d828ee14dc67ca65606ade81de2f8d1691741072a93b" +dependencies = [ + "any_spawner", + "async-lock", + "futures", + "guardian", + "hydration_context", + "or_poisoned", + "pin-project-lite", + "rustc-hash 2.1.0", + "send_wrapper", + "serde", + "slotmap", + "thiserror 2.0.6", + "web-sys", +] + +[[package]] +name = "reactive_stores" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bb1913eeb71f74028213455ee971550c2b3cb91b6acd5efa8a0f8dc59f5039" +dependencies = [ + "guardian", + "itertools 0.13.0", + "or_poisoned", + "paste", + "reactive_graph", + "reactive_stores_macro", + "rustc-hash 2.1.0", +] + +[[package]] +name = "reactive_stores_macro" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d86e4f08f361b05d11422398cef4bc4cf356f2fdd2f06a96646b0e9cd902226" +dependencies = [ + "convert_case", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -5254,6 +5678,21 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "rstml" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51187e564f12336ef40cd04f6f4d805d6919188001dcf1e0a021898ea0fe28ce" +dependencies = [ + "derive-where", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.90", + "syn_derive", + "thiserror 1.0.69", +] + [[package]] name = "rtnetlink" version = "0.14.1" @@ -5727,7 +6166,7 @@ dependencies = [ "bytes", "ciborium", "const_format", - "dashmap", + "dashmap 5.5.3", "futures", "gloo-net", "http 1.2.0", @@ -5737,7 +6176,7 @@ dependencies = [ "serde", "serde_json", "serde_qs 0.12.0", - "server_fn_macro_default", + "server_fn_macro_default 0.6.15", "thiserror 1.0.69", "url", "wasm-bindgen", @@ -5747,6 +6186,36 @@ dependencies = [ "xxhash-rust", ] +[[package]] +name = "server_fn" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0b9f0d2eecb2bf4f909661acc731009e3657574dec93a0ec9f114e250f74bc4" +dependencies = [ + "bytes", + "const_format", + "dashmap 6.1.0", + "futures", + "gloo-net", + "http 1.2.0", + "js-sys", + "once_cell", + "pin-project-lite", + "send_wrapper", + "serde", + "serde_json", + "serde_qs 0.13.0", + "server_fn_macro_default 0.7.3", + "thiserror 2.0.6", + "throw_error", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "xxhash-rust", +] + [[package]] name = "server_fn_macro" version = "0.6.15" @@ -5761,13 +6230,37 @@ dependencies = [ "xxhash-rust", ] +[[package]] +name = "server_fn_macro" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee7723bef57b4353cd9939e280d3b5b2ebe45b4a4630c9e9e97a6fa4b84e8b1c" +dependencies = [ + "const_format", + "convert_case", + "proc-macro2", + "quote", + "syn 2.0.90", + "xxhash-rust", +] + [[package]] name = "server_fn_macro_default" version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f2aa8119b558a17992e0ac1fd07f080099564f24532858811ce04f742542440" dependencies = [ - "server_fn_macro", + "server_fn_macro 0.6.15", + "syn 2.0.90", +] + +[[package]] +name = "server_fn_macro_default" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87663ec10f17fbe8f6c53adc2d038df3304bfd17aaaab22f777810a9e6e05fff" +dependencies = [ + "server_fn_macro 0.7.3", "syn 2.0.90", ] @@ -6166,6 +6659,38 @@ dependencies = [ "winx", ] +[[package]] +name = "tachys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "761f12c13d74f1b723e3c53ff70fe291d15fe51cc4b6586aafea974f0b647043" +dependencies = [ + "any_spawner", + "const_str_slice_concat", + "drain_filter_polyfill", + "either_of", + "futures", + "html-escape", + "indexmap 2.7.0", + "itertools 0.13.0", + "js-sys", + "linear-map", + "next_tuple", + "oco_ref 0.2.0", + "once_cell", + "or_poisoned", + "parking_lot 0.12.3", + "paste", + "reactive_graph", + "reactive_stores", + "rustc-hash 2.1.0", + "send_wrapper", + "slotmap", + "throw_error", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "tar" version = "0.4.43" @@ -6344,6 +6869,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "throw_error" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ef8bf264c6ae02a065a4a16553283f0656bd6266fc1fcb09fd2e6b5e91427b" +dependencies = [ + "pin-project-lite", +] + [[package]] name = "time" version = "0.3.37" @@ -6816,7 +7350,16 @@ version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77739c880e00693faef3d65ea3aad725f196da38b22fdc7ea6ded6e1ce4d3add" dependencies = [ - "typed-builder-macro", + "typed-builder-macro 0.18.2", +] + +[[package]] +name = "typed-builder" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e14ed59dc8b7b26cacb2a92bad2e8b1f098806063898ab42a3bd121d7d45e75" +dependencies = [ + "typed-builder-macro 0.20.0", ] [[package]] @@ -6830,6 +7373,17 @@ dependencies = [ "syn 2.0.90", ] +[[package]] +name = "typed-builder-macro" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "560b82d656506509d43abe30e0ba64c56b1953ab3d4fe7ba5902747a7a3cedd5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "typenum" version = "1.17.0" diff --git a/Cargo.toml b/Cargo.toml index 128593e6b..084254fb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,11 +89,11 @@ hyper-util = "0.1.6" indicatif = "0.17.7" indoc = "2.0.4" jsonwebtoken = "9.2.0" -leptos = { version = "0.6.15" } +leptos = { version = "0.7.3" } # https://gitlab.com/GoodLucky777/leptos_oidc, version 0.7.0 leptos_oidc = { git = "https://gitlab.com/GoodLucky777/leptos_oidc", rev = "ed55987efec1004de93455591ef702bf1ffd2e43" } -leptos_router = { version = "0.6.15" } -leptos-use = { version = "0.13.10" } +leptos_router = { version = "0.7.3" } +leptos-use = { version = "0.15.3" } mime = "0.3.17" mockall = "0.13.0" netlink-packet-route = "0.19.0" diff --git a/opendut-carl/opendut-carl-api/src/carl/mod.rs b/opendut-carl/opendut-carl-api/src/carl/mod.rs index 4ff44f309..48d64f244 100644 --- a/opendut-carl/opendut-carl-api/src/carl/mod.rs +++ b/opendut-carl/opendut-carl-api/src/carl/mod.rs @@ -209,7 +209,7 @@ cfg_if! { #[cfg(feature = "wasm-client")] pub mod wasm { - use leptos::{create_signal, provide_context}; + use leptos::prelude::{signal, provide_context}; use tonic::codegen::InterceptedService; use opendut_auth::public::{Auth, AuthInterceptor, OptionalAuthData}; @@ -228,7 +228,7 @@ pub mod wasm { impl CarlClient { pub async fn create(url: url::Url, auth: Option) -> Result { - let auth_data_signal = create_signal( + let auth_data_signal = signal( OptionalAuthData { auth_data: None } ); provide_context(auth_data_signal); diff --git a/opendut-lea/Cargo.toml b/opendut-lea/Cargo.toml index 1a20ce289..048974f24 100644 --- a/opendut-lea/Cargo.toml +++ b/opendut-lea/Cargo.toml @@ -16,7 +16,7 @@ gloo-net = { workspace = true, features = ["json"]} jsonwebtoken = { workspace = true } leptos = { workspace = true, features = ["csr"] } leptos_oidc = { workspace = true } -leptos_router = { workspace = true, features = ["csr"] } +leptos_router = { workspace = true } leptos-use = { workspace = true } serde = { workspace = true, features = ["derive"] } shadow-rs = { workspace = true, default-features = false, features = ["tzdb"] } diff --git a/opendut-lea/src/about/overview.rs b/opendut-lea/src/about/overview.rs index 8ed119301..1f436d62a 100644 --- a/opendut-lea/src/about/overview.rs +++ b/opendut-lea/src/about/overview.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use crate::app::{ExpectGlobals, use_app_globals}; use crate::components::{BasePageContainer, Initialized}; @@ -15,7 +15,7 @@ pub fn AboutOverview() -> impl IntoView { let globals = use_app_globals(); - let metadata: Resource<(), VersionInfo> = create_local_resource(|| {}, move |_| { + let metadata: LocalResource = LocalResource::new(move || { let mut carl = globals.expect_client(); async move { carl.metadata.version().await diff --git a/opendut-lea/src/app.rs b/opendut-lea/src/app.rs index 06a6ac606..252d39e41 100644 --- a/opendut-lea/src/app.rs +++ b/opendut-lea/src/app.rs @@ -1,7 +1,7 @@ -use std::rc::Rc; +use std::sync::Arc; use gloo_net::http; -use leptos::*; +use leptos::prelude::*; use leptos_oidc::{Auth, AuthParameters}; use serde::{Deserialize, Deserializer}; use tracing::info; @@ -20,8 +20,8 @@ pub struct AppGlobals { pub auth: Option, } -pub fn use_app_globals() -> Resource<(), Result> { - use_context::>>() +pub fn use_app_globals() -> LocalResource> { + use_context::>>() .expect("The AppGlobals should be provided in the context.") } @@ -87,7 +87,7 @@ pub struct AppGlobalsError { #[component] pub fn App() -> impl IntoView { - let globals: Resource<(), Result> = create_local_resource(|| {}, |_| async move { + let globals: LocalResource> = LocalResource::new(move || async { let config = http::Request::get("/api/lea/config") .send() .await @@ -123,7 +123,7 @@ pub fn App() -> impl IntoView { }); provide_context(globals); - provide_context(Rc::new(Toaster::new())); + provide_context(Arc::new(Toaster::new())); view! { @@ -134,14 +134,14 @@ pub fn App() -> impl IntoView { } pub trait ExpectGlobals { - fn expect_config(&self) -> AppConfig; - fn expect_client(&self) -> CarlClient; - fn expect_auth(&self) -> Option; + async fn expect_config(&self) -> AppConfig; + async fn expect_client(&self) -> CarlClient; + async fn expect_auth(&self) -> Option; } -impl ExpectGlobals for Resource<(), Result> { +impl ExpectGlobals for LocalResource> { - fn expect_config(&self) -> AppConfig { + async fn expect_config(&self) -> AppConfig { self.get() .expect("AppGlobals should be loaded to get the config") .expect("AppGlobals should be loaded successfully to get the config") diff --git a/opendut-lea/src/clusters/card.rs b/opendut-lea/src/clusters/card.rs index 1edc01b82..eec0de490 100644 --- a/opendut-lea/src/clusters/card.rs +++ b/opendut-lea/src/clusters/card.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use crate::app::{ExpectGlobals, use_app_globals}; use crate::clusters::components::CreateClusterButton; @@ -15,7 +15,7 @@ pub fn ClustersCard() -> impl IntoView { let globals = use_app_globals(); - let clusters: Resource<(), Clusters> = create_local_resource(|| {}, move |_| { + let clusters: LocalResource = LocalResource::new(move || { let mut carl = globals.expect_client(); async move { let configured = carl.cluster.list_cluster_configurations().await diff --git a/opendut-lea/src/clusters/components/create_cluster_button.rs b/opendut-lea/src/clusters/components/create_cluster_button.rs index c37220bc2..b5cea3d91 100644 --- a/opendut-lea/src/clusters/components/create_cluster_button.rs +++ b/opendut-lea/src/clusters/components/create_cluster_button.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use opendut_types::cluster::ClusterId; diff --git a/opendut-lea/src/clusters/configurator/components/cluster_name_input.rs b/opendut-lea/src/clusters/configurator/components/cluster_name_input.rs index ca3931a1d..cb2829236 100644 --- a/opendut-lea/src/clusters/configurator/components/cluster_name_input.rs +++ b/opendut-lea/src/clusters/configurator/components/cluster_name_input.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use opendut_types::cluster::{IllegalClusterName, ClusterName}; diff --git a/opendut-lea/src/clusters/configurator/components/controls.rs b/opendut-lea/src/clusters/configurator/components/controls.rs index 516bd7d11..aa7e77f99 100644 --- a/opendut-lea/src/clusters/configurator/components/controls.rs +++ b/opendut-lea/src/clusters/configurator/components/controls.rs @@ -1,6 +1,6 @@ -use std::rc::Rc; +use std::sync::Arc; -use leptos::*; +use leptos::prelude::*; use tracing::{debug, error}; use opendut_types::cluster::{ClusterConfiguration, ClusterId}; @@ -15,7 +15,7 @@ use crate::routing::{navigate_to, WellKnownRoutes}; pub fn Controls(cluster_configuration: ReadSignal, deployed_signal: RwSignal) -> impl IntoView { let (info_text, _) = - create_signal({ + signal({ if deployed_signal.get().0 { String::from("Cluster can not be updated or deleted while it is deployed.") } else { @@ -41,7 +41,7 @@ fn SaveClusterButton(cluster_configuration: ReadSignal let toaster = use_toaster(); let store_action = create_action(move |_: &()| { - let toaster = Rc::clone(&toaster); + let toaster = Arc::clone(&toaster); let configuration = ClusterConfiguration::try_from(cluster_configuration.get_untracked()); async move { match configuration { @@ -124,7 +124,7 @@ fn DeleteClusterButton(cluster_configuration: ReadSignal) }) }; - let rows = move || { - let mut all_devices_by_peer: Vec<_> = Vec::new(); + fn render_peer_descriptors(peer_descriptors: Vec, selected_devices: HashSet, getter: Signal, setter: SignalSetter) -> impl IntoView { + let mut all_devices_by_peer: Vec<_> = Vec::new(); - for peer in peer_descriptors.get().unwrap_or_default() { - let mut devices = peer.topology.devices; - let selected_devices = selected_devices(); + for peer in peer_descriptors { + let mut devices = peer.topology.devices; - devices.sort_by(|a, b| + devices.sort_by(|a, b| a.name.value().to_lowercase().cmp(&b.name.value().to_lowercase())); - let interfaces_and_devices = peer.network.interfaces_zipped_with_devices(&devices); - - let devices_per_peer = interfaces_and_devices.into_iter() - .map(|(network_interface, device)| { - let collapsed_signal = create_rw_signal(true); - let collapse_button_icon = MaybeSignal::derive(move || if collapsed_signal.get() { FontAwesomeIcon::ChevronDown } else {FontAwesomeIcon::ChevronUp} ); - let selected_signal = create_rw_signal(selected_devices.contains(&device.id)); - view! { - - - + + + + + {device.name.to_string()} + + {peer.location.clone().unwrap_or_default().to_string()} + + ButtonColor::Light, + true => ButtonColor::Success, + }) + size=ButtonSize::Small + state=ButtonState::Enabled + label="More infos" + on_action=move || icon_button_on_action( + selected_signal, + getter, + setter, + device.id, + ) + /> + + + + - - - {&device.name.to_string()} - - {peer.location.clone().unwrap_or_default().to_string()} - - ButtonColor::Light, - true => ButtonColor::Success, - }) - size=ButtonSize::Small - state=ButtonState::Enabled - label="More infos" - on_action=move || icon_button_on_action( - selected_signal, - getter, - setter, - device.id, - ) - /> - - - - - - } - }) - .collect::>(); - - for device in devices_per_peer { - all_devices_by_peer.push(device); + + } + }).collect_view(); + + for device in devices_per_peer { + all_devices_by_peer.push(device); + } } - } - all_devices_by_peer - }; + all_devices_by_peer + } view! {

{ help_text }

@@ -120,7 +119,17 @@ pub fn DeviceSelector(cluster_configuration: RwSignal) - { rows } + "Loading..."

} + > + {move || Suspend::new(async move { + let peer_descriptors = peer_descriptors.await; + let selected_devices = selected_devices(); + view! { + { render_peer_descriptors(peer_descriptors, selected_devices, getter, setter) } + } + })} +
diff --git a/opendut-lea/src/clusters/configurator/components/leader_selector.rs b/opendut-lea/src/clusters/configurator/components/leader_selector.rs index 426908e84..bb4f18842 100644 --- a/opendut-lea/src/clusters/configurator/components/leader_selector.rs +++ b/opendut-lea/src/clusters/configurator/components/leader_selector.rs @@ -1,6 +1,6 @@ use std::collections::HashSet; -use leptos::{component, create_read_slice, create_slice, view, IntoView, RwSignal, SignalGet, SignalWith}; +use leptos::prelude::*; use opendut_types::peer::PeerId; use opendut_types::topology::DeviceId; diff --git a/opendut-lea/src/clusters/configurator/components/mod.rs b/opendut-lea/src/clusters/configurator/components/mod.rs index 05b5e03d9..0d9d2246e 100644 --- a/opendut-lea/src/clusters/configurator/components/mod.rs +++ b/opendut-lea/src/clusters/configurator/components/mod.rs @@ -4,7 +4,7 @@ mod cluster_name_input; mod leader_selector; use std::collections::HashSet; -use leptos::{create_local_resource, Resource, Signal, SignalWith}; +use leptos::prelude::*; pub use controls::Controls; pub use device_selector::{DeviceSelector, DeviceSelection}; pub use cluster_name_input::ClusterNameInput; @@ -14,10 +14,10 @@ use opendut_types::topology::DeviceId; use crate::app::{ExpectGlobals, use_app_globals}; -fn get_all_peers() -> Resource<(), Vec> { +fn get_all_peers() -> LocalResource> { let globals = use_app_globals(); - create_local_resource(|| {}, move |_| { + LocalResource::new(move || { async move { let mut carl = globals.expect_client(); carl.peers.list_peer_descriptors().await diff --git a/opendut-lea/src/clusters/configurator/mod.rs b/opendut-lea/src/clusters/configurator/mod.rs index fe26c4b92..b26d8ea00 100644 --- a/opendut-lea/src/clusters/configurator/mod.rs +++ b/opendut-lea/src/clusters/configurator/mod.rs @@ -1,5 +1,5 @@ -use leptos::*; -use leptos_router::use_params_map; +use leptos::prelude::*; +use leptos_router::hooks::use_params_map; use opendut_types::cluster::{ClusterId}; use crate::app::{ExpectGlobals, use_app_globals}; @@ -48,14 +48,14 @@ pub fn ClusterConfigurator() -> impl IntoView { } }; - let user_configuration = create_rw_signal(UserClusterConfiguration { + let user_configuration = RwSignal::new(UserClusterConfiguration { id: cluster_id, name: UserInputValue::Left(UserInputError::from("Enter a valid cluster name.")), devices: DeviceSelection::Left(String::from("Select at least two devices.")), leader: LeaderSelection::Left(String::from("Select a leader.")), }); - create_local_resource(|| {}, move |_| { // TODO: maybe a action suits better here + LocalResource::new(move || { // TODO: maybe a action suits better here let mut carl = globals.expect_client(); async move { if let Ok(configuration) = carl.cluster.get_cluster_configuration(cluster_id).await { @@ -82,7 +82,7 @@ pub fn ClusterConfigurator() -> impl IntoView { ] }); - let cluster_deployments = create_local_resource(|| {}, move |_| { + let cluster_deployments = LocalResource::new(move || { let mut carl = globals.expect_client(); async move { carl.cluster.list_cluster_deployments().await @@ -101,7 +101,7 @@ pub fn ClusterConfigurator() -> impl IntoView { }; let deployed_rw_signal = move || { - create_rw_signal(IsDeployed(deployed_clusters().contains(&cluster_id.get()))) + RwSignal::new(IsDeployed(deployed_clusters().contains(&cluster_id.get()))) }; let is_deployed = move || { diff --git a/opendut-lea/src/clusters/configurator/tabs/devices.rs b/opendut-lea/src/clusters/configurator/tabs/devices.rs index ffe768fc8..d56113e1b 100644 --- a/opendut-lea/src/clusters/configurator/tabs/devices.rs +++ b/opendut-lea/src/clusters/configurator/tabs/devices.rs @@ -1,4 +1,4 @@ -use leptos::{component, IntoView, RwSignal, view}; +use leptos::prelude::*; use crate::clusters::configurator::DeviceSelector; use crate::clusters::configurator::types::UserClusterConfiguration; diff --git a/opendut-lea/src/clusters/configurator/tabs/general.rs b/opendut-lea/src/clusters/configurator/tabs/general.rs index bae5424a3..8251f6f88 100644 --- a/opendut-lea/src/clusters/configurator/tabs/general.rs +++ b/opendut-lea/src/clusters/configurator/tabs/general.rs @@ -1,4 +1,4 @@ -use leptos::{component, IntoView, MaybeSignal, RwSignal, SignalGet, view}; +use leptos::prelude::*; use crate::clusters::configurator::components::ClusterNameInput; use crate::clusters::configurator::types::UserClusterConfiguration; diff --git a/opendut-lea/src/clusters/configurator/tabs/leader.rs b/opendut-lea/src/clusters/configurator/tabs/leader.rs index 35549caa8..9d49b1beb 100644 --- a/opendut-lea/src/clusters/configurator/tabs/leader.rs +++ b/opendut-lea/src/clusters/configurator/tabs/leader.rs @@ -1,4 +1,4 @@ -use leptos::{component, IntoView, RwSignal, view}; +use leptos::prelude::*; use crate::clusters::configurator::components::LeaderSelector; use crate::clusters::configurator::types::UserClusterConfiguration; diff --git a/opendut-lea/src/clusters/overview.rs b/opendut-lea/src/clusters/overview.rs index 40162c551..efb716ebf 100644 --- a/opendut-lea/src/clusters/overview.rs +++ b/opendut-lea/src/clusters/overview.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use leptos::html::Div; use leptos_use::on_click_outside; use serde::{Deserialize, Serialize}; @@ -20,7 +20,7 @@ pub fn ClustersOverview() -> impl IntoView { let globals = use_app_globals(); - let clusters = create_local_resource(|| {}, move |_| { + let clusters = LocalResource::new(move || { let mut carl = globals.expect_client(); async move { carl.cluster.list_cluster_configurations().await @@ -28,7 +28,7 @@ pub fn ClustersOverview() -> impl IntoView { } }); - let cluster_deployments = create_local_resource(|| {}, move |_| { + let cluster_deployments = LocalResource::new(move || { let mut carl = globals.expect_client(); async move { carl.cluster.list_cluster_deployments().await @@ -112,10 +112,10 @@ pub fn ClustersOverview() -> impl IntoView { let cluster_id = cluster_configuration.id; view! { } }).collect::>() @@ -190,12 +190,12 @@ where let configurator_href = move || format!("/clusters/{}/configure/general", cluster_id.get()); - let dropdown_active = create_rw_signal(false); - let dropdown = create_node_ref::
(); + let dropdown_active = RwSignal::new(false); + let dropdown = NodeRef::
::new(); let _ = on_click_outside(dropdown, move |_| dropdown_active.set(false) ); - let (health_state, _) = create_signal({ + let (health_state, _) = signal({ if is_deployed.get().0 { health::State { kind: health::StateKind::Yellow, diff --git a/opendut-lea/src/components/auth.rs b/opendut-lea/src/components/auth.rs index 750abbe22..ae8486fab 100644 --- a/opendut-lea/src/components/auth.rs +++ b/opendut-lea/src/components/auth.rs @@ -1,5 +1,5 @@ use jsonwebtoken::DecodingKey; -use leptos::{ChildrenFn, component, create_effect, IntoView, ReadSignal, Show, SignalSet, Transition, use_context, view, ViewFn, WriteSignal}; +use leptos::prelude::*; use leptos_oidc::{Algorithm, TokenData, Validation}; use serde::{Deserialize, Serialize}; use opendut_auth::public::{AuthData, OptionalAuthData}; diff --git a/opendut-lea/src/components/authenticated.rs b/opendut-lea/src/components/authenticated.rs index a3bae1667..fcc392c28 100644 --- a/opendut-lea/src/components/authenticated.rs +++ b/opendut-lea/src/components/authenticated.rs @@ -1,6 +1,6 @@ use std::ops::Not; -use leptos::{ChildrenFn, component, HtmlElement, IntoView, Show, SignalGet, view}; -use leptos::html::P; +use leptos::prelude::*; +use leptos::html::{HtmlElement, P}; use crate::app::{ExpectGlobals, use_app_globals}; use crate::routing::{navigate_to, WellKnownRoutes}; diff --git a/opendut-lea/src/components/breadcrumbs.rs b/opendut-lea/src/components/breadcrumbs.rs index 20169a7b4..76c2d7579 100644 --- a/opendut-lea/src/components/breadcrumbs.rs +++ b/opendut-lea/src/components/breadcrumbs.rs @@ -1,6 +1,6 @@ use std::ops::Not; -use leptos::*; +use leptos::prelude::*; #[derive(Debug, Clone)] pub struct Breadcrumb { diff --git a/opendut-lea/src/components/buttons/button.rs b/opendut-lea/src/components/buttons/button.rs index e2efa9dc8..12e43ad62 100644 --- a/opendut-lea/src/components/buttons/button.rs +++ b/opendut-lea/src/components/buttons/button.rs @@ -1,5 +1,4 @@ -use leptos::*; - +use leptos::prelude::*; use crate::components::{ButtonColor, ButtonState, FontAwesomeIcon}; #[component] diff --git a/opendut-lea/src/components/buttons/confirmation_button.rs b/opendut-lea/src/components/buttons/confirmation_button.rs index 9e29ce14e..94c3a32e9 100644 --- a/opendut-lea/src/components/buttons/confirmation_button.rs +++ b/opendut-lea/src/components/buttons/confirmation_button.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use leptos::html::Div; use leptos_use::on_click_outside; use crate::components::{ButtonSize, IconButton}; @@ -19,9 +19,9 @@ where A: Fn() + 'static { let text = Clone::clone(&label); let aria_label = Clone::clone(&label); - let doorhanger_visible = create_rw_signal(false); + let doorhanger_visible = RwSignal::new(false); - let delete_button_area = create_node_ref::
(); + let delete_button_area = NodeRef::
::new(); let _ = on_click_outside(delete_button_area, move |_| { doorhanger_visible.set(false) diff --git a/opendut-lea/src/components/buttons/doorhanger_button.rs b/opendut-lea/src/components/buttons/doorhanger_button.rs index 03e5e40c8..09a6b3300 100644 --- a/opendut-lea/src/components/buttons/doorhanger_button.rs +++ b/opendut-lea/src/components/buttons/doorhanger_button.rs @@ -1,5 +1,6 @@ -use leptos::*; -use leptos::html::Div; +use leptos::prelude::*; +use leptos::prelude::IntoAny; +use leptos::html::{Div, HtmlElement}; use leptos_use::on_click_outside; use crate::components::{ButtonSize, IconButton}; use crate::components::{ButtonColor, ButtonState, FontAwesomeIcon}; @@ -18,9 +19,9 @@ pub fn DoorhangerButton( let text = Clone::clone(&text); let aria_label = Clone::clone(&label); - let doorhanger_visible = create_rw_signal(false); + let doorhanger_visible = RwSignal::new(false); - let delete_button_area = create_node_ref::
(); + let delete_button_area = NodeRef::
::new(); let _ = on_click_outside(delete_button_area, move |_| { doorhanger_visible.set(false) @@ -41,7 +42,7 @@ pub fn DoorhangerButton( label=aria_label on_action=move || doorhanger_visible.set(true) /> - } + }.into_any() }) >

{ text }

diff --git a/opendut-lea/src/components/buttons/icon_button.rs b/opendut-lea/src/components/buttons/icon_button.rs index b73a6ca8c..b5a008680 100644 --- a/opendut-lea/src/components/buttons/icon_button.rs +++ b/opendut-lea/src/components/buttons/icon_button.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use crate::components::{ButtonColor, ButtonSize, ButtonState, FontAwesomeIcon}; diff --git a/opendut-lea/src/components/doorhanger.rs b/opendut-lea/src/components/doorhanger.rs index 4b9e704d3..4603bbf9e 100644 --- a/opendut-lea/src/components/doorhanger.rs +++ b/opendut-lea/src/components/doorhanger.rs @@ -1,8 +1,8 @@ -use leptos::*; +use leptos::prelude::*; use leptos::html::Div; use leptos_use::{use_element_size, UseElementSizeReturn}; -pub type Trigger = Box View>; +pub type Trigger = Box AnyView + Send>; #[allow(dead_code)] pub enum DoorhangerAlignment { @@ -33,7 +33,7 @@ pub fn Doorhanger( }) }; - let trigger_div = create_node_ref::
(); + let trigger_div = NodeRef::
::new(); let UseElementSizeReturn { height, .. } = use_element_size(trigger_div); let dog_ear_style = move || { let top = (height.get() as i32) + 4; diff --git a/opendut-lea/src/components/health.rs b/opendut-lea/src/components/health.rs index 7485fc168..7676b06af 100644 --- a/opendut-lea/src/components/health.rs +++ b/opendut-lea/src/components/health.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use leptos::ev::MouseEvent; use crate::components::tooltip::Tooltip; @@ -19,7 +19,7 @@ pub enum StateKind { #[component] pub fn Health(state: ReadSignal) -> impl IntoView { - let (tooltip_visible, set_tooltip_visible) = create_signal(false); + let (tooltip_visible, set_tooltip_visible) = signal(false); let classes = move || state.with(|state| { match state.kind { diff --git a/opendut-lea/src/components/inputs/readonly_input.rs b/opendut-lea/src/components/inputs/readonly_input.rs index eec4b1484..00540194d 100644 --- a/opendut-lea/src/components/inputs/readonly_input.rs +++ b/opendut-lea/src/components/inputs/readonly_input.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; #[component] pub fn ReadOnlyInput( diff --git a/opendut-lea/src/components/inputs/user_input.rs b/opendut-lea/src/components/inputs/user_input.rs index a9906b9b5..fed91d4cb 100644 --- a/opendut-lea/src/components/inputs/user_input.rs +++ b/opendut-lea/src/components/inputs/user_input.rs @@ -1,4 +1,5 @@ -use leptos::*; +use leptos::prelude::*; +use leptos::reactive::wrappers::write::SignalSetter; use crate::components::inputs::{UserInputValidator, UserInputValue}; use crate::util::NON_BREAKING_SPACE; diff --git a/opendut-lea/src/components/inputs/user_textarea.rs b/opendut-lea/src/components/inputs/user_textarea.rs index 1bd0804d2..885d6daa7 100644 --- a/opendut-lea/src/components/inputs/user_textarea.rs +++ b/opendut-lea/src/components/inputs/user_textarea.rs @@ -1,4 +1,5 @@ -use leptos::*; +use leptos::prelude::*; +use leptos::reactive::wrappers::write::SignalSetter; use crate::components::inputs::{UserInputValidator, UserInputValue}; use crate::util::NON_BREAKING_SPACE; diff --git a/opendut-lea/src/components/inputs/vector_user_input.rs b/opendut-lea/src/components/inputs/vector_user_input.rs index 15ddf8898..3ed7e0de7 100644 --- a/opendut-lea/src/components/inputs/vector_user_input.rs +++ b/opendut-lea/src/components/inputs/vector_user_input.rs @@ -1,4 +1,5 @@ -use leptos::*; +use leptos::prelude::*; +use leptos::reactive::wrappers::write::SignalSetter; use crate::components::{ButtonColor, ButtonSize, ButtonState, ConfirmationButton, FontAwesomeIcon, UserInputError}; use crate::components::inputs::{UserInputValidator, UserInputValue}; use crate::util::{Ior, NON_BREAKING_SPACE}; @@ -35,7 +36,8 @@ where let aria_label = Clone::clone(&label); - let panels = create_memo(move |_| { + // TODO: refactor, do not collect views in signals, use new leptos store type, see also create_slice in executor_panel.rs + let panels = move || { getter.with(|inputs| { inputs.iter() .cloned() @@ -61,9 +63,9 @@ where /> } }) - .collect::>() + .collect_view() }) - }); + }; view! {
diff --git a/opendut-lea/src/components/mod.rs b/opendut-lea/src/components/mod.rs index 5ccf99a55..54707fa64 100644 --- a/opendut-lea/src/components/mod.rs +++ b/opendut-lea/src/components/mod.rs @@ -1,3 +1,6 @@ +use leptos::prelude::*; + +pub use auth::LeaAuthenticated; pub use authenticated::Initialized; pub use breadcrumbs::{Breadcrumb, Breadcrumbs}; pub use buttons::button::SimpleButton; @@ -7,14 +10,13 @@ pub use buttons::icon_button::IconButton; pub use inputs::{UserInputError, UserInputValue}; pub use inputs::readonly_input::ReadOnlyInput; pub use inputs::user_input::UserInput; -pub use inputs::vector_user_input::VectorUserInput; pub use inputs::user_textarea::UserTextarea; +pub use inputs::vector_user_input::VectorUserInput; pub use page::BasePageContainer; -pub use toast::{use_toaster, Toaster, Toast, ToastKind, ToastContent}; +pub use toast::{Toast, ToastContent, Toaster, ToastKind, use_toaster}; pub use util::ButtonStateSignalProvider; pub use util::Toggled; pub use util::use_active_tab; -pub use auth::LeaAuthenticated; pub mod health; pub mod tooltip; @@ -66,26 +68,16 @@ impl FontAwesomeIcon { } } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Default)] #[allow(dead_code)] pub enum ButtonState { + #[default] Enabled, Loading, Disabled, Hidden, } -impl ButtonState { - #[allow(non_upper_case_globals)] - pub const Default: ButtonState = ButtonState::Enabled; -} - -impl Default for ButtonState { - fn default() -> Self { - Self::Default - } -} - #[derive(Clone, Copy, Debug)] #[allow(dead_code)] pub enum ButtonColor { diff --git a/opendut-lea/src/components/page.rs b/opendut-lea/src/components/page.rs index 4df0125eb..ff2e638d2 100644 --- a/opendut-lea/src/components/page.rs +++ b/opendut-lea/src/components/page.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use crate::components::{Breadcrumbs, Breadcrumb}; diff --git a/opendut-lea/src/components/toast/builder.rs b/opendut-lea/src/components/toast/builder.rs index 7878e5339..139e86fd4 100644 --- a/opendut-lea/src/components/toast/builder.rs +++ b/opendut-lea/src/components/toast/builder.rs @@ -1,5 +1,5 @@ use chrono::Local; -use leptos::create_rw_signal; +use leptos::prelude::*; use crate::components::{Toast, ToastContent, Toaster, ToastKind}; use crate::components::toast::duration_as_ticks; @@ -62,8 +62,8 @@ impl From for Toast { content: value.content.unwrap_or_else(|| ToastContent::Simple { text: String::new() }), timestamp: Local::now(), max_ticks: ticks, - remaining_ticks: create_rw_signal(ticks), - keep: create_rw_signal(false), + remaining_ticks: RwSignal::new(ticks), + keep: RwSignal::new(false), } } } diff --git a/opendut-lea/src/components/toast/container.rs b/opendut-lea/src/components/toast/container.rs index 3b19dff3b..86e50ad52 100644 --- a/opendut-lea/src/components/toast/container.rs +++ b/opendut-lea/src/components/toast/container.rs @@ -1,4 +1,4 @@ -use leptos::{component, create_memo, For, IntoView, RwSignal, SignalGet, SignalUpdate, SignalWith, SignalWithUntracked, view}; +use leptos::prelude::*; use tracing::debug; use crate::components::toast::notification::Notification; @@ -17,7 +17,7 @@ pub fn Container( }); }; - let toasts_list = create_memo(move |_| { + let toasts_list = Memo::new(move |_| { let mut result = toasts.with(|toasts| { toasts.iter() .map(|(key, toast)| (key, Clone::clone(toast))) diff --git a/opendut-lea/src/components/toast/mod.rs b/opendut-lea/src/components/toast/mod.rs index 4618a7eb5..cf74100a1 100644 --- a/opendut-lea/src/components/toast/mod.rs +++ b/opendut-lea/src/components/toast/mod.rs @@ -1,9 +1,9 @@ use std::ops::Not; -use std::rc::Rc; +use std::sync::Arc; use std::time::Duration; use chrono::{DateTime, Local}; -use leptos::{create_effect, create_rw_signal, mount_to_body, RwSignal, SignalGet, SignalGetUntracked, SignalSet, SignalUpdate, SignalWith, use_context, view}; +use leptos::prelude::*; use leptos_use::use_interval_fn; use leptos_use::utils::Pausable; use slotmap::{DefaultKey, SlotMap}; @@ -54,8 +54,8 @@ pub enum ToastContent { } } -pub fn use_toaster() -> Rc { - use_context::>() +pub fn use_toaster() -> Arc { + use_context::>() .expect("The Toaster should be provided in the context.") } @@ -70,7 +70,7 @@ impl Toaster { debug!("Creating toaster."); - let toasts: RwSignal = create_rw_signal(Default::default()); + let toasts: RwSignal = RwSignal::new(Default::default()); let Pausable { pause: pause_toast_janitor, resume: resume_toast_janitor, is_active: is_toast_janitor_active } = use_interval_fn(move || { toasts.update(|toasts: &mut ToastMap| { @@ -94,7 +94,7 @@ impl Toaster { }); }, Self::UPDATE_INTERVAL_IN_MILLIS); - create_effect(move |_| { + Effect::new(move |_| { toasts.with(|toasts| { let is_active = is_toast_janitor_active.get(); if toasts.is_empty() { @@ -121,7 +121,7 @@ impl Toaster { let toast = toast.into(); debug!("{toast:?}"); self.toasts.update(|toasts| { - toasts.insert(create_rw_signal(toast)); + toasts.insert(RwSignal::new(toast)); }); } } @@ -138,8 +138,8 @@ impl From for Toast { content: ToastContent::Simple { text: value }, timestamp: Local::now(), max_ticks: ticks, - remaining_ticks: create_rw_signal(ticks), - keep: create_rw_signal(false), + remaining_ticks: RwSignal::new(ticks), + keep: RwSignal::new(false), } } } diff --git a/opendut-lea/src/components/toast/notification.rs b/opendut-lea/src/components/toast/notification.rs index f082e3818..a0a119cf9 100644 --- a/opendut-lea/src/components/toast/notification.rs +++ b/opendut-lea/src/components/toast/notification.rs @@ -1,7 +1,6 @@ use std::ops::Not; -use leptos::{component, create_read_slice, IntoView, RwSignal, SignalGet, SignalGetUntracked, SignalSet, SignalWith, SignalWithUntracked, view}; - +use leptos::prelude::*; use crate::components::toast::{Toast, ToastContent, ToastKind}; #[component] diff --git a/opendut-lea/src/components/tooltip.rs b/opendut-lea/src/components/tooltip.rs index fd1e73808..4cd5e68e1 100644 --- a/opendut-lea/src/components/tooltip.rs +++ b/opendut-lea/src/components/tooltip.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; #[component] diff --git a/opendut-lea/src/components/util.rs b/opendut-lea/src/components/util.rs index 50c4c7a2f..b3d60ecc0 100644 --- a/opendut-lea/src/components/util.rs +++ b/opendut-lea/src/components/util.rs @@ -1,33 +1,38 @@ -use leptos::{MaybeSignal, ReadSignal, RwSignal, Signal, SignalGet, SignalUpdate, SignalWith}; -use leptos_router::use_params_map; - +use leptos::prelude::*; +use leptos_router::hooks::use_params_map; use crate::components::ButtonState; use crate::routing::{navigate_to, WellKnownRoutes}; pub trait ButtonStateSignalProvider { - fn derive_loading(&self) -> MaybeSignal; + fn derive_loading(self) -> MaybeSignal; } impl ButtonStateSignalProvider for ReadSignal { - fn derive_loading(&self) -> MaybeSignal { - derive_loading(self) + fn derive_loading(self) -> MaybeSignal { + let signal = Signal::from(self); + derive_loading(signal) } } impl ButtonStateSignalProvider for Signal { - fn derive_loading(&self) -> MaybeSignal { + fn derive_loading(self) -> MaybeSignal { derive_loading(self) } } -fn derive_loading(signal: &(impl SignalGet + Clone + 'static)) -> MaybeSignal { - let signal = Clone::clone(signal); +impl ButtonStateSignalProvider for LocalResource { + fn derive_loading(self) -> MaybeSignal { + derive_loading(self) + } +} + +fn derive_loading(signal: Signal) -> MaybeSignal { MaybeSignal::derive(move || { if signal.get() { ButtonState::Loading } else { - ButtonState::Default + ButtonState::Enabled } }) } @@ -97,7 +102,7 @@ impl Toggled for RwSignal { } } -fn derive_toggled(signal: &(impl SignalGet + Clone + 'static), on: T, off: T) -> MaybeSignal +fn derive_toggled(signal: Signal, on: T, off: T) -> MaybeSignal where T: Clone { diff --git a/opendut-lea/src/dashboard/mod.rs b/opendut-lea/src/dashboard/mod.rs index e183ef28b..9879ac0fb 100644 --- a/opendut-lea/src/dashboard/mod.rs +++ b/opendut-lea/src/dashboard/mod.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use crate::clusters::ClustersCard; use crate::components::Initialized; diff --git a/opendut-lea/src/downloads/cleo_card.rs b/opendut-lea/src/downloads/cleo_card.rs index b99b28bcf..1fc619c6c 100644 --- a/opendut-lea/src/downloads/cleo_card.rs +++ b/opendut-lea/src/downloads/cleo_card.rs @@ -1,13 +1,15 @@ -use leptos::*; +use leptos::either::Either; +use leptos::prelude::*; use crate::app::{use_app_globals, ExpectGlobals}; use opendut_auth::public::OptionalAuthData; use opendut_types::proto::util::VersionInfo; -use crate::components::{ButtonColor, ButtonStateSignalProvider, SimpleButton}; +use crate::components::{ButtonColor, ButtonState, SimpleButton}; +use crate::user::UNAUTHENTICATED_USER; use crate::util::clipboard::copy_with_feedback; #[component] pub fn CleoCard( - version_info: Resource<(), VersionInfo> + version_info: LocalResource ) -> impl IntoView { let globals = use_app_globals(); @@ -35,13 +37,17 @@ pub fn CleoCard( let (auth_data_signal, _) = use_context::<(ReadSignal, WriteSignal)>().expect("AuthData should be provided in the context."); - let setup_string = create_local_resource(move || trigger_cleo_setup_generation.get(), move |action| { + let setup_string = LocalResource::new(move || { async move { + let trigger = trigger_cleo_setup_generation.get(); + let user_id = match auth_data_signal.get().auth_data { - None => { String::from("UNKNOWN USER") } + None => { + String::from(UNAUTHENTICATED_USER) // + } Some(auth_data) => { auth_data.subject } }; - if action { + if trigger { let mut carl = globals.expect_client(); let setup = carl.peers.create_cleo_setup(user_id.clone()).await .expect("Failed to request the setup string."); @@ -54,8 +60,6 @@ pub fn CleoCard( } }); - let button_state = setup_string.loading().derive_loading(); - view! {
@@ -83,51 +87,21 @@ pub fn CleoCard(
- { - move || match setup_string.get() { - Some(Some(setup_string)) => { - let clipboard_text = setup_string.clone(); - view! { -
-
-
-
- -
-
-
- -
-
+ } > + {move || Suspend::new(async move { + let setup_string = setup_string.await; + + match setup_string { + Some(setup_string) => { + Either::Right(view! { }) } - } - _ => { - view! { -
- -
-
- -
-
-
+ None => { + Either::Left(view! { }) } } - } - } + })} +
+
@@ -145,3 +119,56 @@ pub fn CleoCard(
} } + +#[component] +pub fn CleoGenerateSetupStringTextForm( + setup_string: String, +) -> impl IntoView { + let setup_string_for_clipboard_fn = setup_string.clone(); + + view! { +
+
+
+
+ +
+
+
+ +
+
+ } +} + +#[component] +pub fn CleoGenerateSetupStringButtonForm( + trigger_cleo_setup_generation: RwSignal, + button_state: ButtonState, +) -> impl IntoView { + view! { +
+ +
+
+ +
+
+
+ } +} diff --git a/opendut-lea/src/downloads/edgar_card.rs b/opendut-lea/src/downloads/edgar_card.rs index fa986faed..1c75a330e 100644 --- a/opendut-lea/src/downloads/edgar_card.rs +++ b/opendut-lea/src/downloads/edgar_card.rs @@ -1,10 +1,10 @@ -use leptos::*; +use leptos::prelude::*; use opendut_types::proto::util::VersionInfo; use crate::routing; #[component] pub fn EdgarCard( - version_info: Resource<(), VersionInfo> + version_info: LocalResource ) -> impl IntoView { let version_name = move || { diff --git a/opendut-lea/src/downloads/view.rs b/opendut-lea/src/downloads/view.rs index 10d19259d..d45165aa0 100644 --- a/opendut-lea/src/downloads/view.rs +++ b/opendut-lea/src/downloads/view.rs @@ -1,4 +1,4 @@ -use leptos::{component, IntoView, MaybeSignal, view, create_local_resource}; +use leptos::prelude::*; use crate::app::{use_app_globals, ExpectGlobals}; use crate::components::{BasePageContainer, Breadcrumb, Initialized}; use crate::downloads::{CleoCard, EdgarCard}; @@ -19,7 +19,7 @@ pub fn Downloads() -> impl IntoView { }) }; - let version_info = create_local_resource(|| {}, move |_| { + let version_info = LocalResource::new(move || { let mut carl = globals.expect_client(); async move { carl.metadata.version().await diff --git a/opendut-lea/src/error/mod.rs b/opendut-lea/src/error/mod.rs index 070c0b1d6..120f243b9 100644 --- a/opendut-lea/src/error/mod.rs +++ b/opendut-lea/src/error/mod.rs @@ -1,5 +1,5 @@ -use leptos::*; -use leptos_router::use_location; +use leptos::prelude::*; +use leptos_router::hooks::use_location; use crate::routing; #[component] diff --git a/opendut-lea/src/licenses/overview.rs b/opendut-lea/src/licenses/overview.rs index d2ab0fa49..42ff36f06 100644 --- a/opendut-lea/src/licenses/overview.rs +++ b/opendut-lea/src/licenses/overview.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use crate::api::ApiError; use crate::api::ComponentLicenses; @@ -7,7 +7,7 @@ use crate::components::BasePageContainer; #[component] pub fn LicensesOverview() -> impl IntoView { - let licenses: Resource<(), Result, ApiError>> = create_local_resource(|| {}, move |_| { + let licenses: LocalResource, ApiError>> = LocalResource::new(move || { async move { crate::api::get_licenses().await } diff --git a/opendut-lea/src/main.rs b/opendut-lea/src/main.rs index dc238d68e..b96ccf1d9 100644 --- a/opendut-lea/src/main.rs +++ b/opendut-lea/src/main.rs @@ -1,6 +1,6 @@ #![allow(clippy::empty_docs)] //Temporarily ignore these, as they are currently buggy: https://github.com/rust-lang/rust-clippy/issues/12377 (as of 2024-05-14) -use leptos::*; +use leptos::prelude::*; use tracing::info; use tracing_subscriber::fmt::format::Pretty; use tracing_subscriber::layer::SubscriberExt; diff --git a/opendut-lea/src/nav.rs b/opendut-lea/src/nav.rs index 2e066ac8f..ac6821f04 100644 --- a/opendut-lea/src/nav.rs +++ b/opendut-lea/src/nav.rs @@ -1,4 +1,4 @@ -use leptos::{component, create_node_ref, create_rw_signal, IntoView, MaybeSignal, SignalGet, SignalSet, SignalUpdate, view}; +use leptos::prelude::*; use leptos::html::Div; use leptos_oidc::components::{LoginLink, LogoutLink}; use leptos_use::on_click_outside; @@ -7,13 +7,14 @@ use opendut_auth::public::OptionalAuthData; use crate::components::{LeaAuthenticated, ButtonColor, ButtonSize, ButtonState, FontAwesomeIcon, IconButton, Initialized}; use crate::{routing, use_context}; use crate::{WriteSignal, ReadSignal}; +use crate::user::UNAUTHENTICATED_USER; #[component(transparent)] pub fn Navbar() -> impl IntoView { #[component] fn inner() -> impl IntoView { - let menu_visible = create_rw_signal(false); - let profile_visible = create_rw_signal(false); + let menu_visible = RwSignal::new(false); + let profile_visible = RwSignal::new(false); let menu_button_icon = MaybeSignal::derive(move || { if menu_visible.get() { @@ -31,12 +32,12 @@ pub fn Navbar() -> impl IntoView { } }); - let menu_button_area = create_node_ref::
(); + let menu_button_area = NodeRef::
::new(); let _ = on_click_outside(menu_button_area, move |_| { menu_visible.set(false) }); - let profile_button_area = create_node_ref::
(); + let profile_button_area = NodeRef::
::new(); let _ = on_click_outside(profile_button_area, move |_| { profile_visible.set(false) }); @@ -151,7 +152,7 @@ pub fn LoggedInUser() -> impl IntoView { let (auth_data, _) = use_context::<(ReadSignal, WriteSignal)>().expect("AuthData should be provided in the context."); let user_name = move || { match auth_data.get().auth_data { - None => { "Unknown User".to_string() } + None => { UNAUTHENTICATED_USER.to_string() } Some(auth_data) => { auth_data.preferred_username } } }; diff --git a/opendut-lea/src/peers/card.rs b/opendut-lea/src/peers/card.rs index dbf94b18b..22ce40715 100644 --- a/opendut-lea/src/peers/card.rs +++ b/opendut-lea/src/peers/card.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use opendut_types::peer::state::PeerState; use crate::app::{ExpectGlobals, use_app_globals}; use crate::peers::components::CreatePeerButton; @@ -15,7 +15,7 @@ pub fn PeersCard() -> impl IntoView { let globals = use_app_globals(); - let peers: Resource<(), Peers> = create_local_resource(|| {}, move |_| { + let peers: LocalResource = LocalResource::new(move || { let mut carl = globals.expect_client(); async move { let registered = carl.peers.list_peer_descriptors().await diff --git a/opendut-lea/src/peers/components/create_peer_button.rs b/opendut-lea/src/peers/components/create_peer_button.rs index 5dae144ee..e64a931d8 100644 --- a/opendut-lea/src/peers/components/create_peer_button.rs +++ b/opendut-lea/src/peers/components/create_peer_button.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use opendut_types::peer::PeerId; diff --git a/opendut-lea/src/peers/configurator/components/controls.rs b/opendut-lea/src/peers/configurator/components/controls.rs index ba25fc9c8..252db5b31 100644 --- a/opendut-lea/src/peers/configurator/components/controls.rs +++ b/opendut-lea/src/peers/configurator/components/controls.rs @@ -1,8 +1,8 @@ use std::collections::{HashSet}; use std::ops::Not; -use std::rc::Rc; +use std::sync::Arc; -use leptos::*; +use leptos::prelude::*; use tracing::{debug, error, info}; use opendut_types::cluster::ClusterId; use opendut_types::peer::{PeerDescriptor, PeerId}; @@ -41,7 +41,7 @@ fn SavePeerButton( ); let store_action = create_action(move |_: &()| { - let toaster = Rc::clone(&toaster); + let toaster = Arc::clone(&toaster); async move { let mut carl = globals.expect_client(); let peer_descriptor = PeerDescriptor::try_from(configuration.get_untracked()); diff --git a/opendut-lea/src/peers/configurator/components/peer_location_input.rs b/opendut-lea/src/peers/configurator/components/peer_location_input.rs index 2ee1f0010..36d1eea6a 100644 --- a/opendut-lea/src/peers/configurator/components/peer_location_input.rs +++ b/opendut-lea/src/peers/configurator/components/peer_location_input.rs @@ -1,6 +1,6 @@ use crate::components::{UserInput, UserInputValue}; use crate::peers::configurator::types::UserPeerConfiguration; -use leptos::{component, create_slice, view, IntoView, RwSignal}; +use leptos::prelude::*; use opendut_types::peer::{IllegalLocation, PeerLocation}; #[component] diff --git a/opendut-lea/src/peers/configurator/components/peer_name_input.rs b/opendut-lea/src/peers/configurator/components/peer_name_input.rs index ac7dd49cb..3f57e86ab 100644 --- a/opendut-lea/src/peers/configurator/components/peer_name_input.rs +++ b/opendut-lea/src/peers/configurator/components/peer_name_input.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use opendut_types::peer::{IllegalPeerName, PeerName}; diff --git a/opendut-lea/src/peers/configurator/mod.rs b/opendut-lea/src/peers/configurator/mod.rs index a3175c902..d5336b8ff 100644 --- a/opendut-lea/src/peers/configurator/mod.rs +++ b/opendut-lea/src/peers/configurator/mod.rs @@ -6,11 +6,11 @@ use crate::peers::configurator::tabs::{DevicesTab, ExecutorTab, GeneralTab, Netw use crate::peers::configurator::types::{UserContainerEnv, UserDeviceConfiguration, UserNetworkInterface, UserPeerConfiguration, UserPeerExecutor, UserPeerExecutorKind, UserPeerNetwork}; use crate::routing::{navigate_to, WellKnownRoutes}; use crate::util; -use leptos::*; -use leptos_router::use_params_map; +use leptos::prelude::*; use opendut_types::peer::executor::{ExecutorDescriptor, ExecutorKind}; use opendut_types::peer::PeerId; use std::collections::HashMap; +use leptos_router::hooks::use_params_map; mod components; mod tabs; @@ -47,7 +47,7 @@ pub fn PeerConfigurator() -> impl IntoView { } }; - let peer_configuration = create_rw_signal(UserPeerConfiguration { + let peer_configuration = RwSignal::new(UserPeerConfiguration { id: peer_id, name: UserInputValue::Left(UserInputError::from("Enter a valid peer name.")), location: UserInputValue::Right(String::from("")), @@ -60,7 +60,7 @@ pub fn PeerConfigurator() -> impl IntoView { executors: Vec::new(), }); - let peer_configuration_resource = create_local_resource(|| {}, move |_| { + let peer_configuration_resource = LocalResource::new(move || { let mut carl = globals.expect_client(); async move { if let Ok(configuration) = carl.peers.get_peer_descriptor(peer_id).await { @@ -81,7 +81,7 @@ pub fn PeerConfigurator() -> impl IntoView { } } } - create_rw_signal(UserDeviceConfiguration { + RwSignal::new(UserDeviceConfiguration { id: device.id, name: UserInputValue::Right(device.name.to_string()), interface: Some(device.interface), @@ -95,7 +95,7 @@ pub fn PeerConfigurator() -> impl IntoView { } user_configuration.network.network_interfaces = configuration.network.interfaces.into_iter() .map(|interface| { - create_rw_signal(UserNetworkInterface::from(interface)) + RwSignal::new(UserNetworkInterface::from(interface)) }) .collect(); for executor in configuration.executors.executors { @@ -116,18 +116,18 @@ pub fn PeerConfigurator() -> impl IntoView { } => { let volumes = volumes.into_iter() .map(|volume| { - create_rw_signal(UserInputValue::Right(volume.to_string())) + RwSignal::new(UserInputValue::Right(volume.to_string())) }) .collect::>(); let devices = devices.into_iter() .map(|device| { - create_rw_signal(UserInputValue::Right(device.to_string())) + RwSignal::new(UserInputValue::Right(device.to_string())) }) .collect::>(); let envs = envs.into_iter() .map(|env| { let (name, value) = env.into(); - create_rw_signal(UserContainerEnv { + RwSignal::new(UserContainerEnv { name: UserInputValue::Right(name), value: UserInputValue::Right(value) }) @@ -135,12 +135,12 @@ pub fn PeerConfigurator() -> impl IntoView { .collect::>(); let ports = ports.into_iter() .map(|port| { - create_rw_signal(UserInputValue::Right(port.to_string())) + RwSignal::new(UserInputValue::Right(port.to_string())) }) .collect::>(); let args = args.into_iter() .map(|arg| { - create_rw_signal(UserInputValue::Right(arg.to_string())) + RwSignal::new(UserInputValue::Right(arg.to_string())) }) .collect::>(); UserPeerExecutorKind::Container { @@ -158,7 +158,7 @@ pub fn PeerConfigurator() -> impl IntoView { }; user_configuration.executors.push( - create_rw_signal(UserPeerExecutor { + RwSignal::new(UserPeerExecutor { id, kind, results_url: UserInputValue::Right(results_url.map(|s| s.to_string()).unwrap_or(String::new())), @@ -171,7 +171,7 @@ pub fn PeerConfigurator() -> impl IntoView { } }); - let is_valid_peer_configuration = create_memo(move |_| { + let is_valid_peer_configuration = Memo::new(move |_| { peer_configuration.with(|peer_configuration| { peer_configuration.name.is_right() && peer_configuration.location.is_right() diff --git a/opendut-lea/src/peers/configurator/tabs/devices/device_panel.rs b/opendut-lea/src/peers/configurator/tabs/devices/device_panel.rs index 8b8e46219..dea8fe35e 100644 --- a/opendut-lea/src/peers/configurator/tabs/devices/device_panel.rs +++ b/opendut-lea/src/peers/configurator/tabs/devices/device_panel.rs @@ -1,4 +1,4 @@ -use leptos::{component, create_read_slice, create_slice, event_target_value, IntoView, MaybeSignal, RwSignal, SignalGet, SignalGetUntracked, SignalWith, view}; +use leptos::prelude::*; use opendut_types::topology::{DeviceDescription, DeviceId, DeviceName, IllegalDeviceName}; use opendut_types::util::net::NetworkInterfaceId; use uuid::Uuid; @@ -76,6 +76,7 @@ where
}; view! { +
+
} } else { view! { +
+
} } }); diff --git a/opendut-lea/src/peers/configurator/tabs/devices/mod.rs b/opendut-lea/src/peers/configurator/tabs/devices/mod.rs index c6f0a04fc..c8f7115e6 100644 --- a/opendut-lea/src/peers/configurator/tabs/devices/mod.rs +++ b/opendut-lea/src/peers/configurator/tabs/devices/mod.rs @@ -1,5 +1,4 @@ -use leptos::{component, create_memo, create_rw_signal, create_slice, IntoView, RwSignal, SignalUpdate, SignalWith, SignalWithUntracked, view}; - +use leptos::prelude::*; use opendut_types::topology::DeviceId; use crate::components::UserInputValue; @@ -39,7 +38,7 @@ fn DevicesTable(peer_configuration: RwSignal) -> impl Int devices_setter.set(remaining_devices) }; - let panels = create_memo(move |_| { + let panels = Memo::new(move |_| { devices.with(|devices| { devices.iter() .cloned() @@ -63,7 +62,7 @@ fn DevicesTable(peer_configuration: RwSignal) -> impl Int on:click=move |_| { peer_configuration.update(|peer_configuration| { let device_id = DeviceId::random(); - let user_device_configuration = create_rw_signal( + let user_device_configuration = RwSignal::new( UserDeviceConfiguration { id: device_id, name: UserInputValue::Left(String::from(EMPTY_DEVICE_NAME_ERROR_MESSAGE)), diff --git a/opendut-lea/src/peers/configurator/tabs/executor/executor_panel.rs b/opendut-lea/src/peers/configurator/tabs/executor/executor_panel.rs index fdf48a856..6caca8b32 100644 --- a/opendut-lea/src/peers/configurator/tabs/executor/executor_panel.rs +++ b/opendut-lea/src/peers/configurator/tabs/executor/executor_panel.rs @@ -1,4 +1,4 @@ -use leptos::{component, create_read_slice, create_rw_signal, create_slice, event_target_value, IntoView, RwSignal, SignalGet, SignalGetUntracked, SignalUpdate, SignalWith, SignalWithUntracked, view}; +use leptos::prelude::*; use opendut_types::peer::executor::{container::{ContainerCommand, ContainerCommandArgument, ContainerDevice, ContainerImage, ContainerName, ContainerPortSpec, ContainerVolume, Engine, IllegalContainerImage}, ExecutorId, ResultsUrl}; use strum::IntoEnumIterator; @@ -293,7 +293,7 @@ fn ExecutorContainerVolumesInput( let on_add_volume = move || { executor.update(|executor| { - let volume = create_rw_signal( + let volume = RwSignal::new( UserInputValue::Left(String::from("Container volume must not be empty.")) ); match &mut executor.kind { @@ -348,7 +348,7 @@ fn ExecutorContainerDevicesInput( let on_add_device = move || { executor.update(|executor| { - let device = create_rw_signal( + let device = RwSignal::new( UserInputValue::Left(String::from("Container device must not be empty.")) ); match &mut executor.kind { @@ -403,7 +403,7 @@ fn ExecutorContainerPortsInput( let on_add_port = move || { executor.update(|executor| { - let port = create_rw_signal( + let port = RwSignal::new( UserInputValue::Left(String::from("Container port specification must not be empty.")) ); match &mut executor.kind { @@ -498,7 +498,7 @@ fn ExecutorContainerArgsInput( let on_add_arg = move || { executor.update(|executor| { - let arg = create_rw_signal( + let arg = RwSignal::new( UserInputValue::Left(String::from("Container command argument must not be empty.")) ); match &mut executor.kind { @@ -542,7 +542,7 @@ fn ExecutorContainerEnvsInput( let on_add_env = move || { executor.update(|executor| { - let env = create_rw_signal( + let env = RwSignal::new( UserContainerEnv { name: UserInputValue::Left(String::from("Container environment variable name must not be empty.")), value: UserInputValue::Right(String::from("")) diff --git a/opendut-lea/src/peers/configurator/tabs/executor/mod.rs b/opendut-lea/src/peers/configurator/tabs/executor/mod.rs index bd283e561..4469ea5d5 100644 --- a/opendut-lea/src/peers/configurator/tabs/executor/mod.rs +++ b/opendut-lea/src/peers/configurator/tabs/executor/mod.rs @@ -1,4 +1,4 @@ -use leptos::{component, create_memo, create_rw_signal, create_slice, IntoView, RwSignal, SignalUpdate, SignalWith, SignalWithUntracked, view}; +use leptos::prelude::*; use opendut_types::peer::executor::container::Engine; use opendut_types::peer::executor::ExecutorId; use crate::components::UserInputValue; @@ -41,7 +41,7 @@ fn ExecutorTable(peer_configuration: RwSignal) -> impl In }; - let panels = create_memo(move |_| { + let panels = Memo::new(move |_| { executors.with(|executors| { executors.iter() .cloned() @@ -64,7 +64,7 @@ fn ExecutorTable(peer_configuration: RwSignal) -> impl In class="dut-panel-ghost has-text-success px-4 py-3 is-clickable is-flex is-justify-content-center" on:click=move |_| { peer_configuration.update(|peer_configuration| { - let user_peer_executor = create_rw_signal( + let user_peer_executor = RwSignal::new( UserPeerExecutor { id: ExecutorId::random(), kind: UserPeerExecutorKind::Container { diff --git a/opendut-lea/src/peers/configurator/tabs/general/mod.rs b/opendut-lea/src/peers/configurator/tabs/general/mod.rs index fd064191b..fb50420e3 100644 --- a/opendut-lea/src/peers/configurator/tabs/general/mod.rs +++ b/opendut-lea/src/peers/configurator/tabs/general/mod.rs @@ -1,5 +1,4 @@ -use leptos::{component, IntoView, MaybeSignal, RwSignal, SignalGet, view}; - +use leptos::prelude::*; use crate::components::ReadOnlyInput; use crate::peers::configurator::components::{PeerLocationInput, PeerNameInput}; use crate::peers::configurator::types::UserPeerConfiguration; diff --git a/opendut-lea/src/peers/configurator/tabs/network/bridge_name_input.rs b/opendut-lea/src/peers/configurator/tabs/network/bridge_name_input.rs index 4fd8059a6..85ededbf4 100644 --- a/opendut-lea/src/peers/configurator/tabs/network/bridge_name_input.rs +++ b/opendut-lea/src/peers/configurator/tabs/network/bridge_name_input.rs @@ -1,6 +1,6 @@ use crate::components::{UserInput, UserInputValue}; use crate::peers::configurator::types::UserPeerConfiguration; -use leptos::{component, create_slice, view, IntoView, RwSignal}; +use leptos::prelude::*; use opendut_types::util::net::{NetworkInterfaceName, NetworkInterfaceNameError}; #[component] diff --git a/opendut-lea/src/peers/configurator/tabs/network/mod.rs b/opendut-lea/src/peers/configurator/tabs/network/mod.rs index 0bf872eed..0c82a7fa0 100644 --- a/opendut-lea/src/peers/configurator/tabs/network/mod.rs +++ b/opendut-lea/src/peers/configurator/tabs/network/mod.rs @@ -1,11 +1,13 @@ -use std::rc::Rc; +use std::sync::Arc; + +use leptos::prelude::*; -use leptos::{component, create_action, create_read_slice, create_rw_signal, create_slice, IntoView, RwSignal, SignalGetUntracked, SignalWith, SignalWithUntracked, view, SignalGet, MaybeSignal}; use opendut_types::util::net::{NetworkInterfaceConfiguration, NetworkInterfaceId}; + use crate::components::{Toast, use_toaster, UserInputValue}; -use crate::peers::configurator::tabs::network::network_interface_input::NetworkInterfaceInput; use crate::peers::configurator::tabs::network::bridge_name_input::BridgeNameInput; -use crate::peers::configurator::types::{UserPeerConfiguration, UserNetworkInterface}; +use crate::peers::configurator::tabs::network::network_interface_input::NetworkInterfaceInput; +use crate::peers::configurator::types::{UserNetworkInterface, UserPeerConfiguration}; mod network_interface_input; mod bridge_name_input; @@ -48,7 +50,7 @@ pub fn NetworkTab(peer_configuration: RwSignal) -> impl I interfaces = interfaces_getter on_action = move |name, configuration| { let mut interfaces = interfaces_getter.get_untracked(); - let user_peer_network = create_rw_signal( + let user_peer_network = RwSignal::new( UserNetworkInterface { id: NetworkInterfaceId::random(), name, @@ -95,7 +97,7 @@ fn Row( ) -> impl IntoView { let toaster = use_toaster(); - let toaster = Rc::clone(&toaster); + let toaster = Arc::clone(&toaster); let (interfaces_getter, interfaces_setter) = create_slice(peer_configuration, |peer_configuration| { @@ -130,7 +132,7 @@ fn Row( }; let deletion_failed_action = create_action(move |interface_to_delete: &NetworkInterfaceId| { - let toaster = Rc::clone(&toaster); + let toaster = Arc::clone(&toaster); let devices_with_interface = devices.get_untracked().into_iter() .filter(|device| { device.get_untracked().interface == Some(*interface_to_delete) diff --git a/opendut-lea/src/peers/configurator/tabs/network/network_interface_input.rs b/opendut-lea/src/peers/configurator/tabs/network/network_interface_input.rs index 17f28f51e..ab473d80d 100644 --- a/opendut-lea/src/peers/configurator/tabs/network/network_interface_input.rs +++ b/opendut-lea/src/peers/configurator/tabs/network/network_interface_input.rs @@ -1,5 +1,5 @@ use std::ops::Not; -use leptos::*; +use leptos::prelude::*; use opendut_types::util::net::{CanSamplePoint, NetworkInterfaceConfiguration, NetworkInterfaceName, NetworkInterfaceNameError}; use crate::components::{ButtonColor, ButtonSize, ButtonState, FontAwesomeIcon, IconButton, UserInput, UserInputValue}; @@ -14,14 +14,14 @@ pub fn NetworkInterfaceInput( ) -> impl IntoView where A: Fn(NetworkInterfaceName, UserNetworkInterfaceConfiguration) + 'static { - let (interface_name_getter, interface_name_setter) = create_signal(UserInputValue::Left(String::from(NON_BREAKING_SPACE))); - let (bitrate_getter, bitrate_setter) = create_signal(UserInputValue::Right(String::from("500000"))); - let (sample_point_getter, sample_point_setter) = create_signal(UserInputValue::Right(String::from("0.7"))); - let (data_bitrate_getter, data_bitrate_setter) = create_signal(UserInputValue::Right(String::from("2000000"))); - let (data_sample_point_getter, data_sample_point_setter) = create_signal(UserInputValue::Right(String::from("0.7"))); + let (interface_name_getter, interface_name_setter) = signal(UserInputValue::Left(String::from(NON_BREAKING_SPACE))); + let (bitrate_getter, bitrate_setter) = signal(UserInputValue::Right(String::from("500000"))); + let (sample_point_getter, sample_point_setter) = signal(UserInputValue::Right(String::from("0.7"))); + let (data_bitrate_getter, data_bitrate_setter) = signal(UserInputValue::Right(String::from("2000000"))); + let (data_sample_point_getter, data_sample_point_setter) = signal(UserInputValue::Right(String::from("0.7"))); - let (getter_type, setter_type) = create_signal(InterfaceKind::Ethernet); - let (can_fd_getter_type, can_fd_setter_type) = create_signal(false); + let (getter_type, setter_type) = signal(InterfaceKind::Ethernet); + let (can_fd_getter_type, can_fd_setter_type) = signal(false); let name_filter = move |name: NetworkInterfaceName| { interfaces.with(|interfaces| { diff --git a/opendut-lea/src/peers/configurator/tabs/setup/mod.rs b/opendut-lea/src/peers/configurator/tabs/setup/mod.rs index fc3ad1c4c..3898927c8 100644 --- a/opendut-lea/src/peers/configurator/tabs/setup/mod.rs +++ b/opendut-lea/src/peers/configurator/tabs/setup/mod.rs @@ -1,4 +1,4 @@ -use leptos::{component, create_local_resource, IntoView, ReadSignal, RwSignal, SignalGet, SignalSet, use_context, view, WriteSignal}; +use leptos::prelude::*; use opendut_auth::public::OptionalAuthData; use opendut_types::peer::PeerId; @@ -7,6 +7,7 @@ use crate::app::{ExpectGlobals, use_app_globals}; use crate::components::{ButtonColor, SimpleButton}; use crate::components::ButtonStateSignalProvider; use crate::peers::configurator::types::UserPeerConfiguration; +use crate::user::UNAUTHENTICATED_USER; use crate::util::clipboard::{copy_with_feedback}; #[component] @@ -18,10 +19,10 @@ pub fn SetupTab(peer_configuration: ReadSignal) -> impl I let (auth_data_signal, _) = use_context::<(ReadSignal, WriteSignal)>().expect("AuthData should be provided in the context."); - let setup_string = create_local_resource(move || trigger_generation.get(), move |peer_id| { + let setup_string = LocalResource::new(move || trigger_generation.get(), move |peer_id| { async move { let user_id = match auth_data_signal.get().auth_data { - None => { String::from("UNKNOWN USER") } + None => { String::from(UNAUTHENTICATED_USER) } Some(auth_data) => { auth_data.subject } }; if let Some(peer_id) = peer_id { diff --git a/opendut-lea/src/peers/configurator/types.rs b/opendut-lea/src/peers/configurator/types.rs index 91ca3bd3b..fe62f073a 100644 --- a/opendut-lea/src/peers/configurator/types.rs +++ b/opendut-lea/src/peers/configurator/types.rs @@ -1,4 +1,4 @@ -use leptos::{RwSignal, SignalGetUntracked}; +use leptos::prelude::*; use opendut_types::cluster::ClusterConfiguration; use opendut_types::peer::executor::{ExecutorDescriptor, ExecutorId}; use opendut_types::peer::{PeerDescriptor, PeerId, PeerLocation, PeerName, PeerNetworkDescriptor}; diff --git a/opendut-lea/src/peers/overview.rs b/opendut-lea/src/peers/overview.rs index 3021cf8e8..0f0b1fb52 100644 --- a/opendut-lea/src/peers/overview.rs +++ b/opendut-lea/src/peers/overview.rs @@ -5,7 +5,7 @@ use crate::components::{BasePageContainer, Breadcrumb, ButtonColor, ButtonSize, use crate::peers::components::CreatePeerButton; use crate::util; use leptos::html::Div; -use leptos::*; +use leptos::prelude::*; use leptos_use::on_click_outside; use opendut_types::cluster::ClusterConfiguration; use opendut_types::peer::state::PeerState; @@ -19,7 +19,7 @@ pub fn PeersOverview() -> impl IntoView { let globals = use_app_globals(); - let registered_peers: Resource<(), Vec<(PeerDescriptor, PeerState)>> = create_local_resource(|| {}, move |_| { + let registered_peers: LocalResource> = LocalResource::new(move || { let mut carl = globals.expect_client(); async move { let peers = carl.peers.list_peer_descriptors().await @@ -35,7 +35,7 @@ pub fn PeersOverview() -> impl IntoView { } }); - let configured_clusters: Resource<(), Vec> = create_local_resource(|| {}, move |_| { + let configured_clusters: LocalResource> = LocalResource::new(move || { let mut carl = globals.expect_client(); async move { carl.cluster.list_cluster_configurations().await @@ -48,9 +48,9 @@ pub fn PeersOverview() -> impl IntoView { registered_peers.into_iter().map(|(peer_descriptor, peer_state)| { view! { } }).collect::>() @@ -152,11 +152,11 @@ fn Row( } } }; - create_signal(state) + signal(state) }; - let dropdown_active = create_rw_signal(false); - let dropdown = create_node_ref::
(); + let dropdown_active = RwSignal::new(false); + let dropdown = NodeRef::
::new(); let _ = on_click_outside(dropdown, move |_| dropdown_active.set(false) ); diff --git a/opendut-lea/src/routing.rs b/opendut-lea/src/routing.rs index 53489cb15..d57c675cb 100644 --- a/opendut-lea/src/routing.rs +++ b/opendut-lea/src/routing.rs @@ -1,5 +1,5 @@ -use leptos::*; -use leptos_router::use_navigate; +use leptos::prelude::*; +use leptos_router::hooks::use_navigate; use tracing::info; use url::Url; @@ -69,15 +69,16 @@ impl WellKnownRoutes { } mod routes { - use leptos::*; - use leptos_router::{Route, Router, Routes}; + use leptos::prelude::*; + use leptos_router::components::{Route, Router, Routes}; + use leptos_router::path; use crate::clusters::{ClusterConfigurator, ClustersOverview}; use crate::dashboard::Dashboard; use crate::error::ErrorPage; use crate::licenses::LicensesOverview; use crate::peers::{PeerConfigurator, PeersOverview}; - use crate::routing::{self, NotFound}; + use crate::routing::NotFound; use crate::user::UserOverview; use crate::about::AboutOverview; use crate::downloads::Downloads; @@ -87,18 +88,18 @@ mod routes { view! {
- - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> + + + + + + + + + + + +
@@ -109,7 +110,7 @@ mod routes { pub fn navigate_to(route: WellKnownRoutes) { let base = { - let location = leptos_dom::helpers::location(); + let location = location(); Url::parse(location.origin() .expect("Origin of the current location should be valid.").as_str()) .expect("Base url should be valid.") diff --git a/opendut-lea/src/user/mod.rs b/opendut-lea/src/user/mod.rs index 926de342e..698f7dd7a 100644 --- a/opendut-lea/src/user/mod.rs +++ b/opendut-lea/src/user/mod.rs @@ -1,3 +1,4 @@ pub use overview::UserOverview; - +/// In case authentication is disabled the user identity is not known +pub const UNAUTHENTICATED_USER: &str = "unknown-user"; mod overview; diff --git a/opendut-lea/src/user/overview.rs b/opendut-lea/src/user/overview.rs index 435e00ebd..139fb4cb5 100644 --- a/opendut-lea/src/user/overview.rs +++ b/opendut-lea/src/user/overview.rs @@ -1,7 +1,8 @@ use std::ops::Not; -use leptos::*; +use leptos::prelude::*; use opendut_auth::public::OptionalAuthData; use crate::components::{BasePageContainer, Breadcrumb, Initialized}; +use crate::user::UNAUTHENTICATED_USER; #[component] pub fn UserOverview() -> impl IntoView { @@ -21,7 +22,7 @@ pub fn UserOverview() -> impl IntoView { None => { view! { Action { - create_action(move |clipboard_text: &String| { - let toaster = use_toaster(); +pub fn copy_with_feedback() -> Action { + Action::new_local(move |clipboard_text: &String| { let test = clipboard_text.clone(); async move { let clipboard = window().navigator().clipboard(); let clipboard_promise = clipboard.write_text(&test); match wasm_bindgen_futures::JsFuture::from(clipboard_promise).await { Ok(_) => { - toaster.toast( + + use_toaster().toast( Toast::builder() .simple("Successfully copied Setup-String.") .success(), ); } Err(_) => { - toaster.toast( + use_toaster().toast( Toast::builder() .simple("Error while copying Setup-String.") .error(), diff --git a/opendut-lea/src/util/view.rs b/opendut-lea/src/util/view.rs index ed851c27d..20a98f134 100644 --- a/opendut-lea/src/util/view.rs +++ b/opendut-lea/src/util/view.rs @@ -1,4 +1,4 @@ -use leptos::{view, IntoView, View}; +use leptos::prelude::*; pub fn join_with_comma_spans(elements: Vec) -> Vec { let elements_length = elements.len();