@@ -12,6 +12,7 @@ use sqlx::postgres::types::PgMoney;
1212use sqlx:: types:: time:: PrimitiveDateTime ;
1313use sqlx:: { Column , Executor , PgPool , Row , Statement , TypeInfo , ValueRef } ;
1414
15+ use crate :: components:: breadcrumbs:: Breadcrumbs ;
1516use crate :: models;
1617use crate :: utils:: tabs;
1718
@@ -116,10 +117,10 @@ impl From<Layout> for String {
116117#[ template( path ="layout/web_app_base.html" ) ]
117118pub struct WebAppBase < ' a > {
118119pub content : Option < String > ,
119- pub breadcrumbs : Vec < NavLink < ' a > > ,
120+ pub breadcrumbs : Breadcrumbs < ' a > ,
120121pub head : Head ,
121122pub dropdown_nav : StaticNav ,
122- pub product_left_nav : StaticNav ,
123+ pub product_left_nav : crate :: components :: navigation :: left_nav :: web_app :: Menu ,
123124pub body_components : Vec < Component > ,
124125pub cluster : Cluster ,
125126pub product_banners_high : Vec < ProductBanner > ,
@@ -145,7 +146,7 @@ impl<'a> WebAppBase<'a> {
145146WebAppBase {
146147 head,
147148 cluster,
148- dropdown_nav : context. context . dropdown_nav . clone ( ) ,
149+ dropdown_nav : context. context . deployment_dropdown . clone ( ) ,
149150product_left_nav : context. context . product_left_nav . clone ( ) ,
150151product_banners_high : all_product_high_level,
151152product_banner_medium : ProductBanner :: from_notification ( Notification :: next_product_of_level (
@@ -161,18 +162,22 @@ impl<'a> WebAppBase<'a> {
161162}
162163
163164pub fn breadcrumbs ( & mut self , breadcrumbs : Vec < NavLink < ' a > > ) ->& mut Self {
164- self . breadcrumbs = breadcrumbs. to_owned ( ) ;
165+ self . breadcrumbs . path = breadcrumbs. clone ( ) ;
165166self
166167}
167168
168169pub fn disable_upper_nav ( & mut self ) ->& mut Self {
169170let links: Vec < StaticNavLink > =self
170171. product_left_nav
172+ . items
171173. links
172174. iter ( )
173175. map ( |item| item. to_owned ( ) . disabled ( true ) )
174176. collect ( ) ;
175- self . product_left_nav =StaticNav { links} ;
177+ self . product_left_nav =crate :: components:: navigation:: left_nav:: web_app:: Menu {
178+ back : self . product_left_nav . back . clone ( ) ,
179+ items : StaticNav { links} ,
180+ } ;
176181self
177182}
178183
@@ -186,6 +191,56 @@ impl<'a> WebAppBase<'a> {
186191self
187192}
188193
194+ pub fn breadcrumbs_from_uri (
195+ & mut self ,
196+ org_dropdown : Vec < StaticNavLink > ,
197+ database_dropdown : Vec < StaticNavLink > ,
198+ uri : & str ,
199+ ) ->& mut Self {
200+ let uri =if uri. starts_with ( "/" ) {
201+ uri. chars ( ) . skip ( 1 ) . collect :: < String > ( )
202+ } else {
203+ uri. to_string ( )
204+ } ;
205+
206+ let start_index =match ( org_dropdown. is_empty ( ) , database_dropdown. is_empty ( ) ) {
207+ ( true , true ) =>0 ,
208+ ( false , true ) =>1 ,
209+ _ =>2 ,
210+ } ;
211+
212+ let mut uris = uri
213+ . split ( "/" )
214+ . skip ( start_index)
215+ . enumerate ( )
216+ . map ( |( i, part) |{
217+ let path = uri
218+ . split ( "/" )
219+ . into_iter ( )
220+ . take ( 1 + i + start_index)
221+ . collect :: < Vec < & str > > ( )
222+ . join ( "/" ) ;
223+ let mut out ="/" . to_owned ( ) ;
224+ out. push_str ( & path) ;
225+
226+ NavLink :: new ( part, & out)
227+ } )
228+ . collect :: < Vec < NavLink > > ( ) ;
229+
230+ if let Some ( last) = uris. clone ( ) . into_iter ( ) . next_back ( ) {
231+ uris. pop ( ) ;
232+ uris. push ( last. active ( ) ) ;
233+ }
234+
235+ self . breadcrumbs =Breadcrumbs {
236+ organizations : org_dropdown,
237+ databases : database_dropdown,
238+ path : uris,
239+ } ;
240+
241+ self
242+ }
243+
189244pub fn render < T > ( & mut self , template : T ) ->String
190245where
191246T : sailfish:: TemplateOnce ,