Skip to content

Commit 7be866c

Browse files
committed
Add link to admin page in navbar menu
1 parent dab4f7e commit 7be866c

File tree

2 files changed

+17
-31
lines changed

2 files changed

+17
-31
lines changed

crates/web-app-seed/src/main.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ enum Msg {
271271
ToggleNotifications,
272272
ToggleShowRPE,
273273
ToggleShowTUT,
274-
UpdateApp,
275274
GoUp,
276275
LogOut,
277276

@@ -385,16 +384,11 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
385384
.settings
386385
.show_tut))));
387386
}
388-
Msg::UpdateApp => {
389-
orders.skip().send_msg(Msg::Data(data::Msg::UpdateApp));
390-
}
391387
Msg::GoUp => match &model.page {
392388
Some(Page::Home(_) | Page::Login(_)) => {}
393-
Some(Page::Admin(_)) => {
394-
orders.request_url(crate::Urls::new(&model.data.base_url).login());
395-
}
396389
Some(
397-
Page::BodyWeight(_)
390+
Page::Admin(_)
391+
| Page::BodyWeight(_)
398392
| Page::BodyFat(_)
399393
| Page::MenstrualCycle(_)
400394
| Page::Training(_)
@@ -701,7 +695,20 @@ fn view_navbar(navbar: &Navbar, page: Option<&Page>, data_model: &data::Model) -
701695
]
702696
} else {
703697
empty![]
704-
}
698+
},
699+
a![
700+
C!["navbar-item"],
701+
ev(Ev::Click, {
702+
let url = data_model.base_url.clone();
703+
move |_| {
704+
crate::Urls::new(url.to_hash_base_url())
705+
.admin()
706+
.go_and_load();
707+
}
708+
}),
709+
span![C!["icon"], C!["px-5"], i![C!["fas fa-gears"]]],
710+
"Administration",
711+
],
705712
],
706713
]
707714
]
@@ -929,19 +936,6 @@ fn view_settings_dialog(data_model: &data::Model) -> Node<Msg> {
929936
}
930937
]
931938
},
932-
p![
933-
h1![C!["subtitle"], "Version"],
934-
common::view_versions(&data_model.version),
935-
IF![&data_model.version != env!("VALENS_VERSION") =>
936-
button![
937-
C!["button"],
938-
C!["is-link"],
939-
C!["mt-5"],
940-
ev(Ev::Click, |_| Msg::UpdateApp),
941-
"Update"
942-
]
943-
],
944-
],
945939
],
946940
&ev(Ev::Click, |_| Msg::CloseSettingsDialog),
947941
)

crates/web-app-seed/src/page/login.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,10 @@ use crate::{common, data};
88
// Init
99
// ------ ------
1010

11-
pub fn init(url: Url, orders: &mut impl Orders<Msg>, navbar: &mut crate::Navbar) -> Model {
11+
pub fn init(_url: Url, orders: &mut impl Orders<Msg>, navbar: &mut crate::Navbar) -> Model {
1212
orders.notify(data::Msg::ReadUsers);
1313

1414
navbar.title = String::from("Valens");
15-
navbar.items = vec![(
16-
ev(Ev::Click, move |_| {
17-
crate::Urls::new(url.to_hash_base_url())
18-
.admin()
19-
.go_and_load();
20-
}),
21-
String::from("gears"),
22-
)];
2315

2416
Model {}
2517
}

0 commit comments

Comments
 (0)