diff --git a/CHANGELOG.md b/CHANGELOG.md index 091b18fd..e515401c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [[0.8.7]](https://github.com/thoth-pub/thoth/releases/tag/v0.8.7) - 2022-07-22 +### Fixed + - [#379](https://github.com/thoth-pub/thoth/issues/379) - Limit to 6 the number of ISBNs offered in CrossRef metadata export + - [#388](https://github.com/thoth-pub/thoth/issues/388) - Upgrade packages flagged in Dependabot alerts + +### Changed + - [#370](https://github.com/thoth-pub/thoth/issues/370) - Upgrade Yew to v0.19 + + ## [[0.8.6]](https://github.com/thoth-pub/thoth/releases/tag/v0.8.6) - 2022-07-01 ### Added - [#390](https://github.com/thoth-pub/thoth/pull/390) - Implement OverDrive ONIX 3.0 specification diff --git a/Cargo.lock b/Cargo.lock index 2c52be8f..81ff2fe0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,7 +107,7 @@ dependencies = [ "firestorm", "http 0.2.6", "log", - "regex 1.5.4", + "regex", "serde", ] @@ -190,7 +190,7 @@ dependencies = [ "mime", "once_cell", "pin-project-lite", - "regex 1.5.4", + "regex", "serde", "serde_json", "serde_urlencoded 0.7.0", @@ -279,15 +279,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "aho-corasick" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5" -dependencies = [ - "memchr", -] - [[package]] name = "aho-corasick" version = "0.7.18" @@ -333,11 +324,17 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" +[[package]] +name = "anymap2" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" + [[package]] name = "arc-swap" -version = "0.4.4" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" +checksum = "dabe5a181f83789739c194cbe5a897dde195078fac08568d09221fd6137a7ba8" [[package]] name = "argon2rs" @@ -537,9 +534,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.2.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f359dc14ff8911330a51ef78022d376f25ed00248912803b58f00cb1c27f742" +checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" [[package]] name = "byteorder" @@ -738,7 +735,7 @@ dependencies = [ "lazy_static 1.4.0", "libc", "parking_lot 0.12.0", - "regex 1.5.4", + "regex", "termios", "unicode-width", "winapi 0.3.9", @@ -753,7 +750,7 @@ dependencies = [ "encode_unicode", "lazy_static 1.4.0", "libc", - "regex 1.5.4", + "regex", "terminal_size", "unicode-width", "winapi 0.3.9", @@ -864,9 +861,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed" dependencies = [ "crossbeam-epoch", "crossbeam-utils 0.7.2", @@ -1029,9 +1026,9 @@ dependencies = [ [[package]] name = "diesel" -version = "1.4.3" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d7cc03b910de9935007861dce440881f69102aaaedfd4bc5a6f40340ca5840c" +checksum = "b28135ecf6b7d446b43e27e225622a038cc4e2930a1022f51cdb97ada19b8e4d" dependencies = [ "bitflags", "byteorder", @@ -1118,12 +1115,9 @@ checksum = "923dea538cea0aa3025e8685b20d6ee21ef99c4f77e954a30febbaac5ec73a97" [[package]] name = "dotenv" -version = "0.9.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "400b347fe65ccfbd8f545c9d9a75d04b0caf23fec49aaa838a9a05398f94c019" -dependencies = [ - "regex 0.2.11", -] +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" [[package]] name = "dtoa" @@ -1173,7 +1167,7 @@ dependencies = [ "atty", "humantime", "log", - "regex 1.5.4", + "regex", "termcolor", ] @@ -1463,8 +1457,36 @@ checksum = "68ce6f2dfa9f57f15b848efa2aade5e1850dc72986b87a2b0752d44ca08f4967" dependencies = [ "gloo-console-timer", "gloo-events", - "gloo-file", + "gloo-file 0.1.0", + "gloo-timers", +] + +[[package]] +name = "gloo" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23947965eee55e3e97a5cd142dd4c10631cc349b48cecca0ed230fd296f568cd" +dependencies = [ + "gloo-console", + "gloo-dialogs", + "gloo-events", + "gloo-file 0.2.1", + "gloo-render", + "gloo-storage", "gloo-timers", + "gloo-utils", +] + +[[package]] +name = "gloo-console" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3907f786f65bbb4f419e918b0c5674175ef1c231ecda93b2dbd65fd1e8882637" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", + "web-sys", ] [[package]] @@ -1476,6 +1498,16 @@ dependencies = [ "web-sys", ] +[[package]] +name = "gloo-dialogs" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67062364ac72d27f08445a46cab428188e2e224ec9e37efdba48ae8c289002e6" +dependencies = [ + "wasm-bindgen", + "web-sys", +] + [[package]] name = "gloo-events" version = "0.1.1" @@ -1499,10 +1531,60 @@ dependencies = [ ] [[package]] -name = "gloo-timers" +name = "gloo-file" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47204a46aaff920a1ea58b11d03dec6f704287d27561724a4631e450654a891f" +checksum = "aa5d6084efa4a2b182ef3a8649cb6506cb4843f22cf907c6e0a799944248ae90" +dependencies = [ + "futures-channel", + "gloo-events", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-render" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd9306aef67cfd4449823aadcd14e3958e0800aa2183955a309112a84ec7764" +dependencies = [ + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-storage" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1caa4ba51c99de680dee3ad99c32ca45e9f13311be72079154d222c3f9a6b6f5" +dependencies = [ + "gloo-utils", + "js-sys", + "serde", + "serde_json", + "thiserror", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "gloo-timers" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fb7d06c1c8cc2a29bee7ec961009a0b2caa0793ee4900c2ffb348734ba1c8f9" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "gloo-utils" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c0bbef55e98d946adbd89f3c65a497cf9adb995a73b99573f30180e8813ab21" dependencies = [ "js-sys", "wasm-bindgen", @@ -1922,9 +2004,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.51" +version = "0.3.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" +checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" dependencies = [ "wasm-bindgen", ] @@ -1998,19 +2080,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "lexical-core" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" -dependencies = [ - "arrayvec 0.5.2", - "bitflags", - "cfg-if 1.0.0", - "ryu", - "static_assertions", -] - [[package]] name = "libc" version = "0.2.119" @@ -2031,9 +2100,9 @@ dependencies = [ [[package]] name = "linked-hash-map" -version = "0.5.2" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "local-channel" @@ -2187,7 +2256,7 @@ dependencies = [ "kernel32-sys", "libc", "log", - "miow 0.2.1", + "miow 0.2.2", "net2", "slab", "winapi 0.2.8", @@ -2208,9 +2277,9 @@ dependencies = [ [[package]] name = "miow" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" dependencies = [ "kernel32-sys", "net2", @@ -2247,9 +2316,9 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.33" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" dependencies = [ "cfg-if 0.1.10", "libc", @@ -2262,17 +2331,6 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" -[[package]] -name = "nom" -version = "5.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" -dependencies = [ - "lexical-core", - "memchr", - "version_check", -] - [[package]] name = "ntapi" version = "0.3.7" @@ -2388,7 +2446,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edc011af0ae98b7f88cf7e4a83b70a54a75d2b8cb013d6efd02e5956207e9eb" dependencies = [ - "regex 1.5.4", + "regex", ] [[package]] @@ -2419,7 +2477,7 @@ dependencies = [ "serde_json", "serde_yaml", "thiserror", - "url 1.7.2", + "url 2.2.2", ] [[package]] @@ -2450,7 +2508,7 @@ dependencies = [ "paperclip-macros", "parking_lot 0.12.0", "pin-project", - "regex 1.5.4", + "regex", "serde", "serde_json", "serde_yaml", @@ -2586,7 +2644,7 @@ checksum = "59698ea79df9bf77104aefd39cc3ec990cb9693fb59c3b0a70ddf2646fdffb4b" dependencies = [ "base64 0.12.3", "once_cell", - "regex 1.5.4", + "regex", ] [[package]] @@ -2782,7 +2840,7 @@ dependencies = [ "error-chain", "idna 0.2.0", "lazy_static 1.4.0", - "regex 1.5.4", + "regex", "url 2.2.2", ] @@ -3081,26 +3139,13 @@ dependencies = [ [[package]] name = "regex" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" -dependencies = [ - "aho-corasick 0.6.10", - "memchr", - "regex-syntax 0.5.6", - "thread_local", - "utf8-ranges", -] - -[[package]] -name = "regex" -version = "1.5.4" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ - "aho-corasick 0.7.18", + "aho-corasick", "memchr", - "regex-syntax 0.6.25", + "regex-syntax", ] [[package]] @@ -3114,18 +3159,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.5.6" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" -dependencies = [ - "ucd-util", -] - -[[package]] -name = "regex-syntax" -version = "0.6.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "remove_dir_all" @@ -3221,6 +3257,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "route-recognizer" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afab94fb28594581f62d981211a9a4d53cc8130bbcbbb89a0440d9b8e81a7746" + [[package]] name = "roxmltree" version = "0.13.1" @@ -3297,6 +3339,12 @@ dependencies = [ "parking_lot 0.10.0", ] +[[package]] +name = "scoped-tls-hkt" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2e9d7eaddb227e8fbaaa71136ae0e1e913ca159b86c7da82f3e8f0044ad3a63" + [[package]] name = "scoped_threadpool" version = "0.1.9" @@ -3381,6 +3429,18 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "618365e8e586c22123d692b72a7d791d5ee697817b65a218cdf12a98870af0f7" +dependencies = [ + "fnv", + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_derive" version = "1.0.136" @@ -3557,12 +3617,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "string" version = "0.2.1" @@ -3693,9 +3747,9 @@ dependencies = [ [[package]] name = "tar" -version = "0.4.33" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0bcfbd6a598361fda270d82469fff3d65089dc33e175c9a131f7b4cd395f228" +checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" dependencies = [ "filetime", "libc", @@ -3768,18 +3822,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.20" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.20" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2 1.0.36", "quote 1.0.15", @@ -3788,7 +3842,7 @@ dependencies = [ [[package]] name = "thoth" -version = "0.8.6" +version = "0.8.7" dependencies = [ "cargo-husky", "clap", @@ -3803,7 +3857,7 @@ dependencies = [ [[package]] name = "thoth-api" -version = "0.8.6" +version = "0.8.7" dependencies = [ "actix-web", "argon2rs", @@ -3821,7 +3875,7 @@ dependencies = [ "lazy_static 1.4.0", "phf", "rand 0.7.3", - "regex 1.5.4", + "regex", "serde", "serde_derive", "serde_json", @@ -3832,7 +3886,7 @@ dependencies = [ [[package]] name = "thoth-api-server" -version = "0.8.6" +version = "0.8.7" dependencies = [ "actix-cors", "actix-identity", @@ -3847,11 +3901,14 @@ dependencies = [ [[package]] name = "thoth-app" -version = "0.8.6" +version = "0.8.7" dependencies = [ "anyhow", "chrono", + "gloo-storage", + "gloo-timers", "log", + "reqwest 0.11.9", "semver 0.11.0", "serde", "serde_json", @@ -3863,14 +3920,16 @@ dependencies = [ "wasm-bindgen", "wasm-logger", "wasm-pack", - "yew", + "web-sys", + "yew 0.19.3", + "yew-agent", "yew-router", "yewtil", ] [[package]] name = "thoth-app-server" -version = "0.8.6" +version = "0.8.7" dependencies = [ "actix-cors", "actix-web", @@ -3879,7 +3938,7 @@ dependencies = [ [[package]] name = "thoth-client" -version = "0.8.6" +version = "0.8.7" dependencies = [ "chrono", "graphql_client", @@ -3893,7 +3952,7 @@ dependencies = [ [[package]] name = "thoth-errors" -version = "0.8.6" +version = "0.8.7" dependencies = [ "actix-web", "csv", @@ -3908,7 +3967,7 @@ dependencies = [ [[package]] name = "thoth-export-server" -version = "0.8.6" +version = "0.8.7" dependencies = [ "actix-cors", "actix-web", @@ -3927,15 +3986,6 @@ dependencies = [ "xml-rs", ] -[[package]] -name = "thread_local" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -dependencies = [ - "lazy_static 1.4.0", -] - [[package]] name = "time" version = "0.1.42" @@ -4225,12 +4275,6 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" -[[package]] -name = "ucd-util" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccdc2daea7cf8bc50cd8710d170a9d816678e54943829c5082bb1594312cf8e" - [[package]] name = "unicase" version = "2.6.0" @@ -4330,12 +4374,6 @@ dependencies = [ "percent-encoding 2.1.0", ] -[[package]] -name = "utf8-ranges" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" - [[package]] name = "uuid" version = "0.7.4" @@ -4425,9 +4463,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.74" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" +checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" dependencies = [ "cfg-if 1.0.0", "serde", @@ -4437,9 +4475,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.74" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" +checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" dependencies = [ "bumpalo", "lazy_static 1.4.0", @@ -4464,9 +4502,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.74" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" +checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" dependencies = [ "quote 1.0.15", "wasm-bindgen-macro-support", @@ -4474,9 +4512,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.74" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" +checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" dependencies = [ "proc-macro2 1.0.36", "quote 1.0.15", @@ -4487,9 +4525,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.74" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" +checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" [[package]] name = "wasm-logger" @@ -4538,9 +4576,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.44" +version = "0.3.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda38f4e5ca63eda02c059d243aa25b5f35ab98451e518c51612cd0f1bd19a47" +checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" dependencies = [ "js-sys", "wasm-bindgen", @@ -4712,7 +4750,7 @@ dependencies = [ "cfg-if 1.0.0", "cfg-match", "console_error_panic_hook", - "gloo", + "gloo 0.2.1", "http 0.2.6", "indexmap", "js-sys", @@ -4725,7 +4763,45 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "yew-macro", + "yew-macro 0.18.0", +] + +[[package]] +name = "yew" +version = "0.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a1ccb53e57d3f7d847338cf5758befa811cabe207df07f543c06f502f9998cd" +dependencies = [ + "console_error_panic_hook", + "gloo 0.4.2", + "gloo-utils", + "indexmap", + "js-sys", + "scoped-tls-hkt", + "slab", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "yew-macro 0.19.3", +] + +[[package]] +name = "yew-agent" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616700dc3851945658c44ba4477ede6b77c795462fbbb9b0ad9a8b6273a3ca77" +dependencies = [ + "anymap2", + "bincode", + "gloo-console", + "gloo-utils", + "js-sys", + "serde", + "slab", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "yew 0.19.3", ] [[package]] @@ -4741,46 +4817,49 @@ dependencies = [ "syn 1.0.72", ] +[[package]] +name = "yew-macro" +version = "0.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fab79082b556d768d6e21811869c761893f0450e1d550a67892b9bce303b7bb" +dependencies = [ + "boolinator", + "lazy_static 1.4.0", + "proc-macro-error", + "proc-macro2 1.0.36", + "quote 1.0.15", + "syn 1.0.72", +] + [[package]] name = "yew-router" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27666236d9597eac9be560e841e415e20ba67020bc8cd081076be178e159c8bc" +checksum = "155804f6f3aa309f596d5c3fa14486a94e7756f1edd7634569949e401d5099f2" dependencies = [ - "cfg-if 1.0.0", - "cfg-match", - "gloo", + "gloo 0.4.2", + "gloo-utils", "js-sys", - "log", - "nom", + "route-recognizer", "serde", - "serde_json", + "serde-wasm-bindgen", + "serde_urlencoded 0.7.0", + "thiserror", "wasm-bindgen", "web-sys", - "yew", + "yew 0.19.3", "yew-router-macro", - "yew-router-route-parser", ] [[package]] name = "yew-router-macro" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c0ace2924b7a175e2d1c0e62ee7022a5ad840040dcd52414ce5f410ab322dba" +checksum = "39049d193b52eaad4ffc80916bf08806d142c90b5edcebd527644de438a7e19a" dependencies = [ "proc-macro2 1.0.36", "quote 1.0.15", "syn 1.0.72", - "yew-router-route-parser", -] - -[[package]] -name = "yew-router-route-parser" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de4a67208fb46b900af18a7397938b01f379dfc18da34799cfa8347eec715697" -dependencies = [ - "nom", ] [[package]] @@ -4795,19 +4874,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "yew", - "yewtil-macro", -] - -[[package]] -name = "yewtil-macro" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1433d8554db0f0a87a38aeea190780c1d5f9570384d99a34ab4de1c51d8eb8f3" -dependencies = [ - "proc-macro2 1.0.36", - "quote 1.0.15", - "syn 1.0.72", + "yew 0.18.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 032fd747..fe041259 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth" -version = "0.8.6" +version = "0.8.7" authors = ["Javier Arias ", "Ross Higman "] edition = "2018" license = "Apache-2.0" @@ -16,14 +16,14 @@ maintenance = { status = "actively-developed" } members = ["thoth-api", "thoth-api-server", "thoth-app", "thoth-app-server", "thoth-client", "thoth-errors", "thoth-export-server"] [dependencies] -thoth-api = { version = "0.8.6", path = "thoth-api", features = ["backend"] } -thoth-api-server = { version = "0.8.6", path = "thoth-api-server" } -thoth-app-server = { version = "0.8.6", path = "thoth-app-server" } -thoth-errors = { version = "0.8.6", path = "thoth-errors" } -thoth-export-server = { version = "0.8.6", path = "thoth-export-server" } +thoth-api = { version = "0.8.7", path = "thoth-api", features = ["backend"] } +thoth-api-server = { version = "0.8.7", path = "thoth-api-server" } +thoth-app-server = { version = "0.8.7", path = "thoth-app-server" } +thoth-errors = { version = "0.8.7", path = "thoth-errors" } +thoth-export-server = { version = "0.8.7", path = "thoth-export-server" } clap = "2.33.3" dialoguer = "0.7.1" -dotenv = "0.9.0" +dotenv = "0.15.0" [dev-dependencies] cargo-husky = { version = "1.5.0", default-features = false, features = ["prepush-hook", "run-cargo-check", "run-cargo-test", "run-cargo-clippy", "run-cargo-fmt"] } diff --git a/thoth-api-server/Cargo.toml b/thoth-api-server/Cargo.toml index d889104e..83458569 100644 --- a/thoth-api-server/Cargo.toml +++ b/thoth-api-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-api-server" -version = "0.8.6" +version = "0.8.7" authors = ["Javier Arias ", "Ross Higman "] edition = "2018" license = "Apache-2.0" @@ -9,8 +9,8 @@ repository = "https://github.com/thoth-pub/thoth" readme = "README.md" [dependencies] -thoth-api = { version = "0.8.6", path = "../thoth-api", features = ["backend"] } -thoth-errors = { version = "0.8.6", path = "../thoth-errors" } +thoth-api = { version = "0.8.7", path = "../thoth-api", features = ["backend"] } +thoth-errors = { version = "0.8.7", path = "../thoth-errors" } actix-web = "4.0.1" actix-cors = "0.6.0" actix-identity = "0.4.0" diff --git a/thoth-api/Cargo.toml b/thoth-api/Cargo.toml index 08becb1c..eea665fc 100644 --- a/thoth-api/Cargo.toml +++ b/thoth-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-api" -version = "0.8.6" +version = "0.8.7" authors = ["Javier Arias ", "Ross Higman "] edition = "2018" license = "Apache-2.0" @@ -16,23 +16,23 @@ maintenance = { status = "actively-developed" } backend = ["diesel", "diesel-derive-enum", "diesel_migrations", "futures", "actix-web"] [dependencies] -thoth-errors = { version = "0.8.6", path = "../thoth-errors" } +thoth-errors = { version = "0.8.7", path = "../thoth-errors" } actix-web = { version = "4.0.1", optional = true } argon2rs = "0.2.5" isbn2 = "0.4.0" chrono = { version = "0.4", features = ["serde"] } -diesel = { version = "1.4.0", features = ["postgres", "uuidv07", "chrono", "r2d2", "64-column-tables", "serde_json"], optional = true } +diesel = { version = "1.4.8", features = ["postgres", "uuidv07", "chrono", "r2d2", "64-column-tables", "serde_json"], optional = true } diesel-derive-enum = { version = "1.1.0", features = ["postgres"], optional = true } diesel-derive-newtype = "0.1" diesel_migrations = { version = "1.4.0", features = ["postgres"], optional = true } -dotenv = "0.9.0" +dotenv = "0.15.0" futures = { version = "0.3.5", optional = true } jsonwebtoken = "7.2.0" juniper = "0.14.2" lazy_static = "1.4.0" phf = { version = "0.8", features = ["macros"] } rand = "0.7.3" -regex = "1.4.1" +regex = "1.6.0" serde = { version = "1.0.115", features = ["derive"] } serde_derive = "1.0" serde_json = "1.0" diff --git a/thoth-app-server/Cargo.toml b/thoth-app-server/Cargo.toml index 1eede4b9..eff0f608 100644 --- a/thoth-app-server/Cargo.toml +++ b/thoth-app-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-app-server" -version = "0.8.6" +version = "0.8.7" authors = ["Javier Arias ", "Ross Higman "] edition = "2018" license = "Apache-2.0" diff --git a/thoth-app/Cargo.toml b/thoth-app/Cargo.toml index d81594d8..31f886f6 100644 --- a/thoth-app/Cargo.toml +++ b/thoth-app/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-app" -version = "0.8.6" +version = "0.8.7" authors = ["Javier Arias ", "Ross Higman "] edition = "2018" license = "Apache-2.0" @@ -21,17 +21,22 @@ wasm-pack = "0.9.1" [dependencies] anyhow = "1.0.32" chrono = { version = "0.4", features = ["serde"] } +gloo-storage = "0.2.1" +gloo-timers = "0.2.4" log = "0.4.11" thiserror = "1.0.20" -yew = "0.18.0" -yew-router = "0.15.0" -yewtil = { version = "0.4.0", features = ["fetch", "pure"] } -wasm-bindgen = "0.2.74" +yew = "0.19.3" +yew-agent = "0.1.0" +yew-router = "0.16.0" +yewtil = { version = "0.4.0", features = ["fetch"] } +wasm-bindgen = "0.2.80" wasm-logger = "0.2.0" +web-sys = { version = "0.3.57", features = ["HtmlInputElement", "HtmlSelectElement", "HtmlTextAreaElement"] } +reqwest = { version = "0.11", features = ["json"] } semver = "0.11.0" serde = { version = "1.0.115", features = ["derive"] } serde_json = "1.0" url = "2.1.1" uuid = { version = "0.7", features = ["serde", "v4"] } -thoth-api = { version = "0.8.6", path = "../thoth-api" } -thoth-errors = { version = "0.8.6", path = "../thoth-errors" } +thoth-api = { version = "0.8.7", path = "../thoth-api" } +thoth-errors = { version = "0.8.7", path = "../thoth-errors" } diff --git a/thoth-app/manifest.json b/thoth-app/manifest.json index bd0ff0ef..19f2061d 100644 --- a/thoth-app/manifest.json +++ b/thoth-app/manifest.json @@ -9,7 +9,7 @@ "start_url": "/?homescreen=1", "background_color": "#ffffff", "theme_color": "#ffdd57", - "version": "0.8.6", + "version": "0.8.7", "icons": [ { "src": "\/android-icon-36x36.png", diff --git a/thoth-app/src/agent/contributor_activity_checker.rs b/thoth-app/src/agent/contributor_activity_checker.rs index 9126f220..6879f29f 100644 --- a/thoth-app/src/agent/contributor_activity_checker.rs +++ b/thoth-app/src/agent/contributor_activity_checker.rs @@ -1,11 +1,9 @@ use std::collections::HashSet; use uuid::Uuid; -use yew::prelude::worker::*; -use yew::Dispatched; +use yew_agent::{Agent, AgentLink, Context, Dispatched, HandlerId}; use yewtil::fetch::Fetch; use yewtil::fetch::FetchAction; use yewtil::fetch::FetchState; -use yewtil::future::LinkFuture; use crate::agent::notification_bus::NotificationBus; use crate::agent::notification_bus::NotificationDispatcher; diff --git a/thoth-app/src/agent/institution_activity_checker.rs b/thoth-app/src/agent/institution_activity_checker.rs index 6e6c99ad..2f60014e 100644 --- a/thoth-app/src/agent/institution_activity_checker.rs +++ b/thoth-app/src/agent/institution_activity_checker.rs @@ -1,11 +1,9 @@ use std::collections::HashSet; use uuid::Uuid; -use yew::prelude::worker::*; -use yew::Dispatched; +use yew_agent::{Agent, AgentLink, Context, Dispatched, HandlerId}; use yewtil::fetch::Fetch; use yewtil::fetch::FetchAction; use yewtil::fetch::FetchState; -use yewtil::future::LinkFuture; use crate::agent::notification_bus::NotificationBus; use crate::agent::notification_bus::NotificationDispatcher; diff --git a/thoth-app/src/agent/mod.rs b/thoth-app/src/agent/mod.rs index ba851ad6..792b2890 100644 --- a/thoth-app/src/agent/mod.rs +++ b/thoth-app/src/agent/mod.rs @@ -6,14 +6,11 @@ macro_rules! timer_agent { $agent_request:ident, $agent_response:ident, ) => { + use gloo_timers::callback::Interval; use serde::Deserialize; use serde::Serialize; - use std::time::Duration; - use yew::agent::Dispatcher; - use yew::prelude::worker::*; - use yew::services::IntervalService; - use yew::services::Task; use yew::Callback; + use yew_agent::{Agent, AgentLink, Context, Dispatcher, HandlerId}; pub type $agent_dispatcher = Dispatcher<$agent>; @@ -27,7 +24,7 @@ macro_rules! timer_agent { pub struct $agent { _link: AgentLink<$agent>, - timer_task: Option>, + timer_task: Option, } impl Agent for $agent { @@ -48,12 +45,12 @@ macro_rules! timer_agent { fn handle_input(&mut self, msg: Self::Input, _: HandlerId) { match msg { $agent_request::Start(callback) => { - let handle = IntervalService::spawn(Duration::from_secs(60), callback); - self.timer_task = Some(Box::new(handle)); + self.timer_task = Some(Interval::new(60_000, move || callback.emit(()))); } $agent_request::Stop => { - if self.timer_task.take().is_some() { - self.timer_task = None; + if let Some(timer_task) = self.timer_task.take() { + // .take() sets self.timer_task to None so no need to do it explicitly + timer_task.cancel(); } } } diff --git a/thoth-app/src/agent/notification_bus.rs b/thoth-app/src/agent/notification_bus.rs index 7acb5060..841a13a2 100644 --- a/thoth-app/src/agent/notification_bus.rs +++ b/thoth-app/src/agent/notification_bus.rs @@ -1,7 +1,6 @@ use std::collections::HashSet; use std::fmt; -use yew::agent::Dispatcher; -use yew::worker::*; +use yew_agent::{Agent, AgentLink, Context, Dispatcher, HandlerId}; pub type NotificationDispatcher = Dispatcher; diff --git a/thoth-app/src/component/admin.rs b/thoth-app/src/component/admin.rs index 2314f82a..70f82215 100644 --- a/thoth-app/src/component/admin.rs +++ b/thoth-app/src/component/admin.rs @@ -1,10 +1,9 @@ use thoth_api::account::model::AccountDetails; use yew::html; use yew::prelude::*; -use yew::ComponentLink; -use yew_router::agent::RouteAgentDispatcher; -use yew_router::agent::RouteRequest; -use yew_router::route::Route; +use yew_agent::Dispatched; +use yew_router::prelude::*; +use yew_router::scope_ext::HistoryHandle; use yewtil::NeqAssign; use crate::agent::notification_bus::NotificationBus; @@ -41,20 +40,19 @@ use crate::service::account::AccountService; use crate::string::PERMISSIONS_ERROR; pub struct AdminComponent { - props: Props, notification_bus: NotificationDispatcher, - router: RouteAgentDispatcher<()>, - link: ComponentLink, + current_route: AdminRoute, previous_route: AdminRoute, + _listener: Option, } pub enum Msg { RedirectToLogin, + RouteChanged, } #[derive(Clone, Properties, PartialEq)] pub struct Props { - pub route: AdminRoute, pub current_user: Option, } @@ -62,25 +60,30 @@ impl Component for AdminComponent { type Message = Msg; type Properties = Props; - fn create(props: Self::Properties, link: ComponentLink) -> Self { + fn create(ctx: &Context) -> Self { if !AccountService::new().is_loggedin() { - link.send_message(Msg::RedirectToLogin); + ctx.link().send_message(Msg::RedirectToLogin); } - let previous_route = props.route.clone(); + // Listen for when the route changes + let listener = ctx + .link() + .add_history_listener(ctx.link().callback(move |_| Msg::RouteChanged)); + // Start tracking current and previous route (previous is unknown at this point) + let current_route = ctx.link().route().unwrap(); + let previous_route = ctx.link().route().unwrap(); AdminComponent { - props, notification_bus: NotificationBus::dispatcher(), - router: RouteAgentDispatcher::new(), - link, + current_route, previous_route, + _listener: listener, } } - fn rendered(&mut self, _first_render: bool) { - if self.props.current_user.is_some() - && self - .props + fn rendered(&mut self, ctx: &Context, _first_render: bool) { + if ctx.props().current_user.is_some() + && ctx + .props() .current_user .as_ref() .unwrap() @@ -96,33 +99,39 @@ impl Component for AdminComponent { } } - fn update(&mut self, msg: Self::Message) -> ShouldRender { + fn update(&mut self, ctx: &Context, msg: Self::Message) -> bool { match msg { Msg::RedirectToLogin => { - self.router - .send(RouteRequest::ChangeRoute(Route::from(AppRoute::Login))); + ctx.link().history().unwrap().push(AppRoute::Login); false } + Msg::RouteChanged => { + if let Some(route) = ctx.link().route() { + // Route has changed - store it, and update the previous route value + self.previous_route.neq_assign(self.current_route.clone()); + self.current_route.neq_assign(route); + // Trigger a re-render to fire view() and update the copy of previous_route being + // passed to switch_admin() (without this, only switch_admin() fires on route change) + // This also ensures that menu.view() will be fired and update items' "is-active" classes + true + } else { + false + } + } } } - fn change(&mut self, props: Self::Properties) -> ShouldRender { - if self.props != props { - self.previous_route.neq_assign(self.props.route.clone()); - self.props = props; - if self.props.current_user.is_none() { - self.link.send_message(Msg::RedirectToLogin); - } - true - } else { - false + fn changed(&mut self, ctx: &Context) -> bool { + if ctx.props().current_user.is_none() { + ctx.link().send_message(Msg::RedirectToLogin); } + true } - fn view(&self) -> Html { - if self.props.current_user.is_some() - && self - .props + fn view(&self, ctx: &Context) -> Html { + if ctx.props().current_user.is_some() + && ctx + .props() .current_user .as_ref() .unwrap() @@ -130,67 +139,23 @@ impl Component for AdminComponent { .restricted_to() != Some(vec![]) { + let current_user = ctx.props().current_user.clone().unwrap(); + let route: AdminRoute = ctx.link().route().unwrap(); + let previous_route = self.previous_route.clone(); + let render = Switch::render(move |r| { + switch_admin(r, current_user.clone(), previous_route.clone()) + }); + html! {
- +
- { - match &self.props.route { - AdminRoute::Admin => html!{}, - AdminRoute::Dashboard => html!{}, - AdminRoute::Works => html!{}, - AdminRoute::Books => html!{}, - AdminRoute::Chapters => html!{}, - AdminRoute::Work(id) => html!{ - - }, - AdminRoute::NewWork => html!{ - - }, - AdminRoute::Publishers => html!{}, - AdminRoute::Publisher(id) => html!{}, - AdminRoute::NewPublisher => html!{}, - AdminRoute::Imprints => html!{}, - AdminRoute::Imprint(id) => html!{}, - AdminRoute::NewImprint => html!{}, - AdminRoute::Institutions => html!{}, - AdminRoute::Institution(id) => html!{}, - AdminRoute::NewInstitution => html!{}, - AdminRoute::Publications => html!{}, - AdminRoute::Publication(id) => html!{ - - }, - AdminRoute::NewPublication => { - html!{ -
-
- { "New publications can be added directly to the work." } -
-
- } - } - AdminRoute::Contributors => html!{}, - AdminRoute::Contributor(id) => html!{}, - AdminRoute::NewContributor => html!{}, - AdminRoute::Serieses => html!{}, - AdminRoute::NewSeries => html!{}, - AdminRoute::Series(id) => html!{}, - } - } + { render } />
@@ -200,3 +165,53 @@ impl Component for AdminComponent { } } } + +fn switch_admin( + route: &AdminRoute, + current_user: AccountDetails, + previous_route: AdminRoute, +) -> Html { + match route { + AdminRoute::Dashboard => html! {}, + AdminRoute::Works => html! {}, + AdminRoute::Books => html! {}, + AdminRoute::Chapters => html! {}, + AdminRoute::Work { id } => html! {}, + AdminRoute::NewWork => html! {}, + AdminRoute::Publishers => html! {}, + AdminRoute::Publisher { id } => { + html! {} + } + AdminRoute::NewPublisher => html! {}, + AdminRoute::Imprints => html! {}, + AdminRoute::Imprint { id } => { + html! {} + } + AdminRoute::NewImprint => html! {}, + AdminRoute::Institutions => html! {}, + AdminRoute::Institution { id } => html! {}, + AdminRoute::NewInstitution => html! {}, + AdminRoute::Publications => html! {}, + AdminRoute::Publication { id } => { + html! {} + } + AdminRoute::NewPublication => { + html! { +
+
+ { "New publications can be added directly to the work." } +
+
+ } + } + AdminRoute::Contributors => html! {}, + AdminRoute::Contributor { id } => html! {}, + AdminRoute::NewContributor => html! {}, + AdminRoute::Serieses => html! {}, + AdminRoute::NewSeries => html! {}, + AdminRoute::Series { id } => html! {}, + AdminRoute::Error => html! { + to={ AppRoute::Error }/> + }, + } +} diff --git a/thoth-app/src/component/affiliations_form.rs b/thoth-app/src/component/affiliations_form.rs index 0e11df07..ce47b8e9 100644 --- a/thoth-app/src/component/affiliations_form.rs +++ b/thoth-app/src/component/affiliations_form.rs @@ -3,11 +3,10 @@ use thoth_api::model::institution::Institution; use uuid::Uuid; use yew::html; use yew::prelude::*; -use yew::ComponentLink; +use yew_agent::Dispatched; use yewtil::fetch::Fetch; use yewtil::fetch::FetchAction; use yewtil::fetch::FetchState; -use yewtil::future::LinkFuture; use yewtil::NeqAssign; use crate::agent::notification_bus::NotificationBus; @@ -47,11 +46,11 @@ use crate::string::CANCEL_BUTTON; use crate::string::EDIT_BUTTON; use crate::string::REMOVE_BUTTON; +use super::ToElementValue; use super::ToOption; pub struct AffiliationsFormComponent { fetch_affiliations: FetchAffiliations, - props: Props, data: AffiliationsFormData, affiliation: AffiliationWithInstitution, show_modal_form: bool, @@ -61,7 +60,6 @@ pub struct AffiliationsFormComponent { create_affiliation: PushCreateAffiliation, delete_affiliation: PushDeleteAffiliation, update_affiliation: PushUpdateAffiliation, - link: ComponentLink, notification_bus: NotificationDispatcher, } @@ -100,7 +98,7 @@ impl Component for AffiliationsFormComponent { type Message = Msg; type Properties = Props; - fn create(props: Self::Properties, link: ComponentLink) -> Self { + fn create(ctx: &Context) -> Self { let fetch_affiliations = Default::default(); let data: AffiliationsFormData = Default::default(); let affiliation: AffiliationWithInstitution = Default::default(); @@ -113,12 +111,11 @@ impl Component for AffiliationsFormComponent { let update_affiliation = Default::default(); let notification_bus = NotificationBus::dispatcher(); - link.send_message(Msg::GetAffiliations); - link.send_message(Msg::GetInstitutions); + ctx.link().send_message(Msg::GetAffiliations); + ctx.link().send_message(Msg::GetInstitutions); AffiliationsFormComponent { fetch_affiliations, - props, data, affiliation, show_modal_form, @@ -128,12 +125,11 @@ impl Component for AffiliationsFormComponent { create_affiliation, delete_affiliation, update_affiliation, - link, notification_bus, } } - fn update(&mut self, msg: Self::Message) -> ShouldRender { + fn update(&mut self, ctx: &Context, msg: Self::Message) -> bool { match msg { Msg::ToggleModalFormDisplay(show_form, a) => { self.show_modal_form = show_form; @@ -148,7 +144,7 @@ impl Component for AffiliationsFormComponent { }; let request = InstitutionsRequest { body }; self.fetch_institutions = Fetch::new(request); - self.link.send_message(Msg::GetInstitutions); + ctx.link().send_message(Msg::GetInstitutions); if let Some(affiliation) = a { // Editing existing affiliation: load its current values. self.affiliation = affiliation; @@ -172,18 +168,18 @@ impl Component for AffiliationsFormComponent { Msg::GetAffiliations => { let body = AffiliationsRequestBody { variables: Variables { - contribution_id: self.props.contribution_id, + contribution_id: ctx.props().contribution_id, }, ..Default::default() }; let request = AffiliationsRequest { body }; self.fetch_affiliations = Fetch::new(request); - self.link.send_future( + ctx.link().send_future( self.fetch_affiliations .fetch(Msg::SetAffiliationsFetchState), ); - self.link + ctx.link() .send_message(Msg::SetAffiliationsFetchState(FetchAction::Fetching)); false } @@ -198,11 +194,11 @@ impl Component for AffiliationsFormComponent { true } Msg::GetInstitutions => { - self.link.send_future( + ctx.link().send_future( self.fetch_institutions .fetch(Msg::SetInstitutionsFetchState), ); - self.link + ctx.link() .send_message(Msg::SetInstitutionsFetchState(FetchAction::Fetching)); false } @@ -218,12 +214,12 @@ impl Component for AffiliationsFormComponent { self.data.affiliations.clone().unwrap_or_default(); affiliations.push(affiliation); self.data.affiliations = Some(affiliations); - self.link + ctx.link() .send_message(Msg::ToggleModalFormDisplay(false, None)); true } None => { - self.link + ctx.link() .send_message(Msg::ToggleModalFormDisplay(false, None)); self.notification_bus.send(Request::NotificationBusMsg(( "Failed to save".to_string(), @@ -233,7 +229,7 @@ impl Component for AffiliationsFormComponent { } }, FetchState::Failed(_, err) => { - self.link + ctx.link() .send_message(Msg::ToggleModalFormDisplay(false, None)); self.notification_bus.send(Request::NotificationBusMsg(( err.to_string(), @@ -246,7 +242,7 @@ impl Component for AffiliationsFormComponent { Msg::CreateAffiliation => { let body = CreateAffiliationRequestBody { variables: CreateVariables { - contribution_id: self.props.contribution_id, + contribution_id: ctx.props().contribution_id, institution_id: self.affiliation.institution_id, position: self.affiliation.position.clone(), affiliation_ordinal: self.affiliation.affiliation_ordinal, @@ -255,11 +251,11 @@ impl Component for AffiliationsFormComponent { }; let request = CreateAffiliationRequest { body }; self.create_affiliation = Fetch::new(request); - self.link.send_future( + ctx.link().send_future( self.create_affiliation .fetch(Msg::SetAffiliationCreateState), ); - self.link + ctx.link() .send_message(Msg::SetAffiliationCreateState(FetchAction::Fetching)); false } @@ -287,12 +283,12 @@ impl Component for AffiliationsFormComponent { NotificationStatus::Warning, ))); } - self.link + ctx.link() .send_message(Msg::ToggleModalFormDisplay(false, None)); true } None => { - self.link + ctx.link() .send_message(Msg::ToggleModalFormDisplay(false, None)); self.notification_bus.send(Request::NotificationBusMsg(( "Failed to save".to_string(), @@ -302,7 +298,7 @@ impl Component for AffiliationsFormComponent { } }, FetchState::Failed(_, err) => { - self.link + ctx.link() .send_message(Msg::ToggleModalFormDisplay(false, None)); self.notification_bus.send(Request::NotificationBusMsg(( err.to_string(), @@ -316,7 +312,7 @@ impl Component for AffiliationsFormComponent { let body = UpdateAffiliationRequestBody { variables: UpdateVariables { affiliation_id: self.affiliation.affiliation_id, - contribution_id: self.props.contribution_id, + contribution_id: ctx.props().contribution_id, institution_id: self.affiliation.institution_id, position: self.affiliation.position.clone(), affiliation_ordinal: self.affiliation.affiliation_ordinal, @@ -325,11 +321,11 @@ impl Component for AffiliationsFormComponent { }; let request = UpdateAffiliationRequest { body }; self.update_affiliation = Fetch::new(request); - self.link.send_future( + ctx.link().send_future( self.update_affiliation .fetch(Msg::SetAffiliationUpdateState), ); - self.link + ctx.link() .send_message(Msg::SetAffiliationUpdateState(FetchAction::Fetching)); false } @@ -375,18 +371,18 @@ impl Component for AffiliationsFormComponent { }; let request = DeleteAffiliationRequest { body }; self.delete_affiliation = Fetch::new(request); - self.link.send_future( + ctx.link().send_future( self.delete_affiliation .fetch(Msg::SetAffiliationDeleteState), ); - self.link + ctx.link() .send_message(Msg::SetAffiliationDeleteState(FetchAction::Fetching)); false } Msg::AddAffiliation(institution) => { self.affiliation.institution_id = institution.institution_id; self.affiliation.institution = institution; - self.link + ctx.link() .send_message(Msg::ToggleModalFormDisplay(true, None)); true } @@ -405,7 +401,7 @@ impl Component for AffiliationsFormComponent { }; let request = InstitutionsRequest { body }; self.fetch_institutions = Fetch::new(request); - self.link.send_message(Msg::GetInstitutions); + ctx.link().send_message(Msg::GetInstitutions); false } Msg::ChangeInstitution(institution_id) => { @@ -435,63 +431,55 @@ impl Component for AffiliationsFormComponent { } } - fn change(&mut self, props: Self::Properties) -> ShouldRender { - if self.props.neq_assign(props) { - self.link.send_message(Msg::GetAffiliations); - true - } else { - false - } + fn changed(&mut self, ctx: &Context) -> bool { + ctx.link().send_message(Msg::GetAffiliations); + false } - fn view(&self) -> Html { + fn view(&self, ctx: &Context) -> Html { // Ensure the form has a unique ID, as there may be multiple copies of // the form on the same parent page, and ID clashes can lead to bugs - let form_id = format!("affiliations-form-{}", self.props.contribution_id); + let form_id = format!("affiliations-form-{}", ctx.props().contribution_id); let affiliations = self.data.affiliations.clone().unwrap_or_default(); - let close_modal = self.link.callback(|e: MouseEvent| { + let close_modal = ctx.link().callback(|e: MouseEvent| { e.prevent_default(); Msg::ToggleModalFormDisplay(false, None) }); html! {
-
- +
+