From 57df516cf390d524b81d7055b7260a8b202a1a45 Mon Sep 17 00:00:00 2001 From: Montana Low Date: Wed, 11 Oct 2023 16:04:14 -0700 Subject: [PATCH 1/3] allow parent navlinks to be clickable --- pgml-dashboard/src/templates/docs.rs | 2 +- pgml-dashboard/src/utils/markdown.rs | 3 +- pgml-dashboard/templates/components/link.html | 28 +++++++++++-------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/pgml-dashboard/src/templates/docs.rs b/pgml-dashboard/src/templates/docs.rs index 458666548..311b02ca1 100644 --- a/pgml-dashboard/src/templates/docs.rs +++ b/pgml-dashboard/src/templates/docs.rs @@ -42,8 +42,8 @@ impl NavLink { /// Automatically expand the link and it's parents /// when one of the children is visible. pub fn should_open(&mut self, path: &str) -> bool { + self.open = self.href.contains(&path); let open = if self.children.is_empty() { - self.open = self.href.contains(&path); self.open } else { for child in self.children.iter_mut() { diff --git a/pgml-dashboard/src/utils/markdown.rs b/pgml-dashboard/src/utils/markdown.rs index 89b3144ea..8397b91f2 100644 --- a/pgml-dashboard/src/utils/markdown.rs +++ b/pgml-dashboard/src/utils/markdown.rs @@ -583,7 +583,8 @@ pub fn get_sub_links(list: &markdown::mdast::List) -> Result> { .unwrap(); let parent = NavLink::new(text.value.as_str()) .href(&url); - links.push(parent) + info!("link: {:?}", parent); + links.push(parent); } _ => error!("unhandled link child: {:?}", node), } diff --git a/pgml-dashboard/templates/components/link.html b/pgml-dashboard/templates/components/link.html index fa95024bf..88da126d2 100644 --- a/pgml-dashboard/templates/components/link.html +++ b/pgml-dashboard/templates/components/link.html @@ -1,5 +1,15 @@ From 1061647f364672663c936d259c343bf46d862148 Mon Sep 17 00:00:00 2001 From: Montana Low Date: Wed, 11 Oct 2023 18:09:31 -0700 Subject: [PATCH 2/3] make parent nav links clickable --- pgml-dashboard/src/components/nav/template.html | 8 ++++---- pgml-dashboard/static/css/scss/components/_navs.scss | 5 +---- pgml-dashboard/templates/components/link.html | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pgml-dashboard/src/components/nav/template.html b/pgml-dashboard/src/components/nav/template.html index 8e45cc818..f2488b703 100644 --- a/pgml-dashboard/src/components/nav/template.html +++ b/pgml-dashboard/src/components/nav/template.html @@ -26,14 +26,14 @@ <% if link.nav.is_some() { %> - + <% } %> <% } %> diff --git a/pgml-dashboard/static/css/scss/components/_navs.scss b/pgml-dashboard/static/css/scss/components/_navs.scss index ca7c78394..15f3acd10 100644 --- a/pgml-dashboard/static/css/scss/components/_navs.scss +++ b/pgml-dashboard/static/css/scss/components/_navs.scss @@ -198,12 +198,9 @@ &:focus:not(:hover) { color: #{$gray-100} } - } [aria-expanded=false] { - span.material-symbols-outlined { - transform: rotate(-90deg); - } + transform: rotate(-90deg); } @include media-breakpoint-down(xxl) { border-radius: 0px; diff --git a/pgml-dashboard/templates/components/link.html b/pgml-dashboard/templates/components/link.html index 88da126d2..7dbbc02ab 100644 --- a/pgml-dashboard/templates/components/link.html +++ b/pgml-dashboard/templates/components/link.html @@ -23,7 +23,7 @@ }; %> - + <%- title %> expand_more From 660718b3e55727503bea33a2b6288caa80dbb355 Mon Sep 17 00:00:00 2001 From: Montana Low Date: Wed, 11 Oct 2023 18:10:55 -0700 Subject: [PATCH 3/3] cargo fmt --- pgml-dashboard/src/api/docs.rs | 10 +++++++++- .../src/components/inputs/select/mod.rs | 2 +- pgml-dashboard/src/lib.rs | 2 +- pgml-dashboard/src/main.rs | 5 +---- pgml-dashboard/src/utils/markdown.rs | 16 ++++++---------- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/pgml-dashboard/src/api/docs.rs b/pgml-dashboard/src/api/docs.rs index 10fc5d948..34cfbc0f4 100644 --- a/pgml-dashboard/src/api/docs.rs +++ b/pgml-dashboard/src/api/docs.rs @@ -53,7 +53,15 @@ async fn doc_handler(path: PathBuf, cluster: &Cluster) -> Result", rank = 10)] diff --git a/pgml-dashboard/src/components/inputs/select/mod.rs b/pgml-dashboard/src/components/inputs/select/mod.rs index 30f2e5805..5bfbe3dc1 100644 --- a/pgml-dashboard/src/components/inputs/select/mod.rs +++ b/pgml-dashboard/src/components/inputs/select/mod.rs @@ -1,9 +1,9 @@ use crate::components::stimulus::stimulus_action::{StimulusAction, StimulusEvents}; use crate::components::stimulus::stimulus_target::StimulusTarget; +use crate::types::CustomOption; use pgml_components::component; use pgml_components::Component; use sailfish::TemplateOnce; -use crate::types::CustomOption; #[derive(TemplateOnce, Default)] #[template(path = "inputs/select/template.html")] diff --git a/pgml-dashboard/src/lib.rs b/pgml-dashboard/src/lib.rs index e28af9206..5e329501d 100644 --- a/pgml-dashboard/src/lib.rs +++ b/pgml-dashboard/src/lib.rs @@ -13,7 +13,6 @@ use sailfish::TemplateOnce; use sqlx::PgPool; use std::collections::HashMap; -pub mod types; pub mod api; pub mod components; pub mod fairings; @@ -22,6 +21,7 @@ pub mod guards; pub mod models; pub mod responses; pub mod templates; +pub mod types; pub mod utils; use guards::{Cluster, ConnectedCluster}; diff --git a/pgml-dashboard/src/main.rs b/pgml-dashboard/src/main.rs index 6e7e14df9..d958f3e76 100644 --- a/pgml-dashboard/src/main.rs +++ b/pgml-dashboard/src/main.rs @@ -285,10 +285,7 @@ mod test { #[rocket::async_test] async fn test_docs() { let client = Client::tracked(rocket().await).await.unwrap(); - let response = client - .get("/docs/guides/README") - .dispatch() - .await; + let response = client.get("/docs/guides/README").dispatch().await; assert_eq!(response.status().code, 200); } diff --git a/pgml-dashboard/src/utils/markdown.rs b/pgml-dashboard/src/utils/markdown.rs index 8397b91f2..7547d6d87 100644 --- a/pgml-dashboard/src/utils/markdown.rs +++ b/pgml-dashboard/src/utils/markdown.rs @@ -26,13 +26,11 @@ use url::Url; use crate::templates::docs::NavLink; use std::fmt; -pub struct MarkdownHeadings { -} +pub struct MarkdownHeadings {} impl MarkdownHeadings { pub fn new() -> Self { - Self { - } + Self {} } } @@ -583,7 +581,6 @@ pub fn get_sub_links(list: &markdown::mdast::List) -> Result> { .unwrap(); let parent = NavLink::new(text.value.as_str()) .href(&url); - info!("link: {:?}", parent); links.push(parent); } _ => error!("unhandled link child: {:?}", node), @@ -1075,8 +1072,8 @@ pub fn mkdocs<'a>(root: &'a AstNode<'a>, arena: &'a Arena>) -> anyho r#"