general cleanup
This commit is contained in:
1 parent
09cabe4e8b
commit
ece8f0fb22
15 files changed
+155
-767
No files matched your search
@@ -1,15 +1,10 @@
|
||||
use crate::{
|
||||
components::GenericLink, hooks::use_generic_route, navigation::NavigationTarget,
|
||||
routable::Routable,
|
||||
};
|
||||
use crate::{hooks::use_generic_router, routable::Routable};
|
||||
use dioxus::prelude::*;
|
||||
|
||||
/// The default component to render when an external navigation fails.
|
||||
#[allow(non_snake_case)]
|
||||
pub fn FailureExternalNavigation<R: Routable + Clone>(cx: Scope) -> Element {
|
||||
let href = use_generic_route::<R>(cx).expect(
|
||||
"`FailureExternalNavigation` can only be mounted by the router itself, \
|
||||
since it is not exposed",
|
||||
);
|
||||
let router = use_generic_router::<R>(cx);
|
||||
|
||||
render! {
|
||||
h1 { "External Navigation Failure!" }
|
||||
@@ -18,53 +13,10 @@ pub fn FailureExternalNavigation<R: Routable + Clone>(cx: Scope) -> Element {
|
||||
"operation has failed. Click the link below to complete the navigation manually."
|
||||
}
|
||||
a {
|
||||
href: "{href}",
|
||||
rel: "noopener noreferrer",
|
||||
"Click here to fix the failure."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn FailureNamedNavigation<R: Routable + Clone>(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."
|
||||
}
|
||||
GenericLink::<R> {
|
||||
target: NavigationTarget::Internal(R::from_str("/").unwrap_or_else(|_| {
|
||||
panic!("Failed to parse `/` as a Route")
|
||||
})),
|
||||
"Click here to try to fix the failure."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn FailureRedirectionLimit<R: Routable + Clone>(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."
|
||||
}
|
||||
GenericLink::<R> {
|
||||
target: NavigationTarget::Internal(R::from_str("/").unwrap_or_else(|_| {
|
||||
panic!("Failed to parse `/` as a Route")
|
||||
})),
|
||||
"Click here to try to fix the failure."
|
||||
onclick: move |_| {
|
||||
router.clear_error()
|
||||
},
|
||||
"Click here to go back"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
use crate::{contexts::outlet::OutletContext, routable::Routable};
|
||||
use crate::prelude::{outlet::OutletContext, *};
|
||||
use dioxus::prelude::*;
|
||||
|
||||
/// An outlet for the current content.
|
||||
///
|
||||
/// Only works as descendant of a [`GenericRouter`] component, otherwise it will be inactive.
|
||||
///
|
||||
/// The [`Outlet`] is aware of how many [`Outlet`]s it is nested within. It will render the content
|
||||
/// The [`GenericOutlet`] is aware of how many [`Outlet`]s it is nested within. It will render the content
|
||||
/// of the active route that is __exactly as deep__.
|
||||
///
|
||||
/// # Panic
|
||||
/// - When the [`Outlet`] is not nested within another component calling the [`use_router`] hook,
|
||||
/// - When the [`GenericOutlet`] is not nested a [`GenericRouter`] component,
|
||||
/// but only in debug builds.
|
||||
///
|
||||
/// # Example
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::{
|
||||
router_cfg::RouterConfiguration,
|
||||
};
|
||||
|
||||
/// The config for [`Router`].
|
||||
/// The config for [`GenericRouter`].
|
||||
pub struct RouterCfg<R: Routable> {
|
||||
config: RefCell<Option<RouterConfiguration<R>>>,
|
||||
}
|
||||
@@ -33,7 +33,7 @@ impl<R: Routable> From<RouterConfiguration<R>> for RouterCfg<R> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The props for [`Router`].
|
||||
/// The props for [`GenericRouter`].
|
||||
#[derive(Props)]
|
||||
pub struct GenericRouterProps<R: Routable + Serialize + DeserializeOwned>
|
||||
where
|
||||
|
||||
Reference in new issue
Block a user