add comp() and default failure components
This commit is contained in:
3 files changed
+81
-4
No files matched your search
@@ -0,0 +1,59 @@
|
|||||||
|
use crate::components::Link;
|
||||||
|
use dioxus::prelude::*;
|
||||||
|
use dioxus_router_core::prelude::{named, RootIndex};
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn FailureExternalNavigation(cx: Scope) -> Element {
|
||||||
|
todo!("add href to FailureExternalNavigation link");
|
||||||
|
|
||||||
|
render! {
|
||||||
|
h1 { "External Navigation Failure!" }
|
||||||
|
p {
|
||||||
|
"The application tried to programmatically navigate to an external page. This "
|
||||||
|
"operation has failed. Click the link below to complete the navigation manually."
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
"Click here to fix the failure."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn FailureNamedNavigation(cx: Scope) -> Element {
|
||||||
|
render! {
|
||||||
|
h1 { "Named Navigation Failure!" }
|
||||||
|
p {
|
||||||
|
"The application has tried to navigate to an unknown name. This is a bug. Please "
|
||||||
|
"inform the developer, so they can fix it."
|
||||||
|
b { "Thank you!" }
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
"We are sorry for the inconvenience. The link below may help to fix the problem, but "
|
||||||
|
"there is no guarantee."
|
||||||
|
}
|
||||||
|
Link {
|
||||||
|
target: named::<RootIndex>(),
|
||||||
|
"Click here to try to fix the failure."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn FailureRedirectionLimit(cx: Scope) -> Element {
|
||||||
|
render! {
|
||||||
|
h1 { "Redirection Limit Failure!" }
|
||||||
|
p {
|
||||||
|
"The application seems to have entered into an endless redirection loop. This is a "
|
||||||
|
"bug. Please inform the developer, so they can fix it."
|
||||||
|
b { "Thank you!" }
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
"We are sorry for the inconvenience. The link below may help to fix the problem, but "
|
||||||
|
"there is no guarantee."
|
||||||
|
}
|
||||||
|
Link {
|
||||||
|
target: named::<RootIndex>(),
|
||||||
|
"Click here to try to fix the failure."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,15 @@ use dioxus_router_core::{
|
|||||||
RouterService, RouterState, RoutingCallback,
|
RouterService, RouterState, RoutingCallback,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::contexts::router::RouterContext;
|
use crate::{
|
||||||
|
contexts::router::RouterContext,
|
||||||
|
prelude::{
|
||||||
|
comp,
|
||||||
|
default_errors::{
|
||||||
|
FailureExternalNavigation, FailureNamedNavigation, FailureRedirectionLimit,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
pub fn use_router<'a>(
|
pub fn use_router<'a>(
|
||||||
cx: &'a ScopeState,
|
cx: &'a ScopeState,
|
||||||
@@ -70,9 +78,9 @@ pub struct RouterConfiguration {
|
|||||||
impl Default for RouterConfiguration {
|
impl Default for RouterConfiguration {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
failure_external_navigation: todo!("provide default component for external navigation"),
|
failure_external_navigation: comp(FailureExternalNavigation),
|
||||||
failure_named_navigation: todo!("provide default component for named navigation"),
|
failure_named_navigation: comp(FailureNamedNavigation),
|
||||||
failure_redirection_limit: todo!("provide default component for redirection limit"),
|
failure_redirection_limit: comp(FailureRedirectionLimit),
|
||||||
history: Box::new(MemoryHistory::default()),
|
history: Box::new(MemoryHistory::default()),
|
||||||
on_update: None,
|
on_update: None,
|
||||||
synchronous: false,
|
synchronous: false,
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
pub mod components {
|
pub mod components {
|
||||||
|
pub(crate) mod default_errors;
|
||||||
|
|
||||||
mod link;
|
mod link;
|
||||||
pub use link::*;
|
pub use link::*;
|
||||||
|
|
||||||
@@ -17,6 +19,14 @@ pub mod hooks {
|
|||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use dioxus_router_core::prelude::*;
|
pub use dioxus_router_core::prelude::*;
|
||||||
|
|
||||||
|
pub use crate::components::*;
|
||||||
|
pub use crate::hooks::*;
|
||||||
|
|
||||||
|
use dioxus::core::Component;
|
||||||
|
pub fn comp(component: Component) -> ContentAtom<Component> {
|
||||||
|
ContentAtom(component)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod utils {
|
mod utils {
|
||||||
|
|||||||
Reference in new issue
Block a user