🌐 AI搜索 & 代理 主页
Skip to content

Commit 88ce70b

Browse files
committed
move product engines dropdown to topnav, set dropdown default formatting, add dashbaord styling, fmt, lint
1 parent b044163 commit 88ce70b

File tree

10 files changed

+43
-38
lines changed

10 files changed

+43
-38
lines changed

pgml-dashboard/src/components/cms/index_link/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl IndexLink {
7373
self
7474
}
7575

76-
// Adds a suffix to this and all children ids.
76+
// Adds a suffix to this and all children ids.
7777
// this prevents id collision with multiple naves on one screen
7878
// like d-none for mobile nav
7979
pub fn id_suffix(mut self, id_suffix: &str) -> IndexLink {

pgml-dashboard/src/components/dropdown/dropdown.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
.dropdown-item {
3030
overflow: hidden;
3131
text-overflow: ellipsis;
32+
--bs-dropdown-link-hover-bg: #{$gray-700};
33+
--bs-dropdown-link-active-bg: #{$neon-tint-100};
3234
}
3335
}
3436

@@ -67,10 +69,6 @@
6769
}
6870
}
6971

70-
.collapase {
71-
width: 100%;
72-
}
73-
7472
.btn-dropdown-text {
7573
overflow: hidden;
7674
text-overflow: ellipsis;

pgml-dashboard/src/components/left_nav_menu/left-nav-menu.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
import { Controller } from "@hotwired/stimulus";
22

33
export default class extends Controller {
4-
static targets = [
5-
"link",
6-
];
7-
8-
// When page reloads we need to set the left nav to the current window
9-
// location since left nave is turbo permanent. Trigger this on event
10-
// rather than on connect since on connect() will fire prior to backend
11-
// redirects.
4+
static targets = ["link"];
5+
6+
// When page reloads we need to set the left nav to the current window
7+
// location since left nave is turbo permanent. Trigger this on event
8+
// rather than on connect since on connect() will fire prior to backend
9+
// redirects.
1210
connect() {
1311
this.callback = () => {
1412
this.setLeftNavToLocation();
15-
}
13+
};
1614

1715
document.addEventListener("turbo:load", this.callback);
1816
}
1917

20-
// Find link element in the left nav that matches the current window
18+
// Find link element in the left nav that matches the current window
2119
// location and set to active
2220
setLeftNavToLocation() {
2321
this.removeAllActive();
2422

25-
let tag = "a[href='" + window.location.pathname + window.location.search + "']";
23+
let tag =
24+
"a[href='" + window.location.pathname + window.location.search + "']";
2625
let element = this.element.querySelector(tag);
27-
26+
2827
if (element) {
2928
element.classList.add("active");
3029
}

pgml-dashboard/src/components/navigation/left_nav/web_app/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ use sailfish::TemplateOnce;
77
pub struct WebApp {
88
pub upper_nav: StaticNav,
99
pub lower_nav: StaticNav,
10-
pub dropdown_nav: StaticNav,
1110
pub id: Option<String>,
1211
}
1312

1413
impl WebApp {
15-
pub fn new(upper_nav: StaticNav, lower_nav: StaticNav, dropdown_nav: StaticNav) -> WebApp {
14+
pub fn new(upper_nav: StaticNav, lower_nav: StaticNav) -> WebApp {
1615
WebApp {
1716
upper_nav,
1817
lower_nav,
19-
dropdown_nav,
20-
id: None
18+
id: None,
2119
}
2220
}
2321

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
import { Controller } from "@hotwired/stimulus";
22

33
export default class extends Controller {
4-
static targets = ['stateReference']
4+
static targets = ["stateReference"];
55
expand() {
6-
if( !this.stateReferenceTarget.classList.contains("show")) {
7-
const elements = this.element.getElementsByClassName('leftnav-collapse')
8-
for( const element of elements) {
9-
bootstrap.Collapse.getOrCreateInstance(element).show()
6+
if (!this.stateReferenceTarget.classList.contains("show")) {
7+
const elements = this.element.getElementsByClassName("leftnav-collapse");
8+
for (const element of elements) {
9+
bootstrap.Collapse.getOrCreateInstance(element).show();
1010
}
1111
}
1212
}
1313

1414
collapse() {
15-
if( this.stateReferenceTarget.classList.contains("show")) {
16-
const elements = this.element.getElementsByClassName('leftnav-collapse')
17-
for( const element of elements) {
18-
bootstrap.Collapse.getOrCreateInstance(element, {toggle: false}).hide()
15+
if (this.stateReferenceTarget.classList.contains("show")) {
16+
const elements = this.element.getElementsByClassName("leftnav-collapse");
17+
for (const element of elements) {
18+
bootstrap.Collapse.getOrCreateInstance(element, {
19+
toggle: false,
20+
}).hide();
1921
}
2022
}
2123
}
2224

2325
checkIfHover() {
24-
this.element.matches(':hover') ? this.expand() : this.collapse()
26+
this.element.matches(":hover") ? this.expand() : this.collapse();
2527
}
2628
}

pgml-dashboard/src/components/navigation/navbar/web_app/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
use crate::components::{StaticNav, StaticNavLink};
2-
use crate::utils::config;
32
use pgml_components::component;
43
use sailfish::TemplateOnce;
54

65
#[derive(TemplateOnce, Default)]
76
#[template(path = "navigation/navbar/web_app/template.html")]
87
pub struct WebApp {
9-
pub standalone_dashboard: bool,
108
pub links: Vec<StaticNavLink>,
119
pub account_management_nav: StaticNav,
1210
pub deployment_controls: StaticNav,
@@ -15,7 +13,6 @@ pub struct WebApp {
1513
impl WebApp {
1614
pub fn new(links: Vec<StaticNavLink>, deployment_controls: StaticNav) -> WebApp {
1715
WebApp {
18-
standalone_dashboard: config::standalone_dashboard(),
1916
links,
2017
account_management_nav: StaticNav::default(),
2118
deployment_controls,

pgml-dashboard/src/components/navigation/navbar/web_app/template.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<%
2+
use crate::utils::config;
23
use crate::templates::components::GithubIcon;
34
use crate::templates::components::PostgresLogo;
4-
use crate::components::{Dropdown, ProfileIcon};
5+
use crate::components::{Dropdown, ProfileIcon};
6+
7+
let standalone_dashboard = config::standalone_dashboard();
58
%>
69

710
<div class="fixed-top-nav font-family-primary" data-controller="navigation-navbar-web-app">
@@ -136,6 +139,11 @@
136139
<div class="collapse navbar-collapse" id="leftNavItems">
137140
<div class="nav-item w-100 d-flex flex-column flex-lg-row collapse show drawer-submenu">
138141
<ul class="sub-menu-dropdown mb-2 d-lg-none">
142+
<li class="mobile-dashboard-button mx-2 rounded-1 d-flex menu-item">
143+
<a href="/deployments" class="py-2 text-white w-100 text-center">
144+
Dashboard
145+
</a>
146+
</li>
139147
<% for link in links { %>
140148
<li class="menu-item rounded-0 d-flex align-items-center">
141149
<a

pgml-dashboard/src/components/navigation/navbar/web_app/web_app.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,8 @@
6666
background-color: #{$gray-700};
6767
}
6868
}
69+
70+
.mobile-dashboard-button:not(:active) {
71+
background-color: #{$gray-700};
72+
}
6973
}

pgml-dashboard/static/css/scss/components/_navs.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@
142142

143143
.drawer-submenu {
144144
white-space: nowrap;
145-
background-color: #{gray-800};
146145
@include media-breakpoint-down(lg) {
147146
background-color: #{$gray-900};
148147
}

pgml-dashboard/templates/layout/web_app_base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
<main>
2525
<div class="container-fluid p-0 min-vh-lg-100">
2626
<div class="row gx-0 min-vh-lg-100 gy-0">
27-
<%+ WebAppNavbar::new(left_nav_links, dropdown_nav.clone()) %>
27+
<%+ WebAppNavbar::new(left_nav_links, dropdown_nav) %>
2828

2929
<div class="d-flex">
30-
<%+ WebAppLeftNav::new( upper_left_nav.clone(), lower_left_nav, dropdown_nav ).id(&upper_left_nav.unique_id()) %>
30+
<%+ WebAppLeftNav::new( upper_left_nav.clone(), lower_left_nav).id(&upper_left_nav.unique_id()) %>
3131

3232
<div class="clear-from-under-navbar flex-grow-1 min-vw-0 web-app-content-area">
3333
<div class="px-4 px-sm-5 py-3" style="position: absolute">

0 commit comments

Comments
 (0)