add managed state for conditional template element rendering
This commit is contained in:
parent
de9b8f5d73
commit
6f03063f8d
|
@ -1,17 +1,25 @@
|
|||
use rocket::{get, request::FlashMessage};
|
||||
use rocket::{get, request::FlashMessage, State};
|
||||
use rocket_dyn_templates::{tera::Context, Template};
|
||||
|
||||
use crate::routes::authentication::Authenticated;
|
||||
use crate::RocketConfig;
|
||||
|
||||
// HELPERS AND ROUTES FOR /settings
|
||||
|
||||
/// View and delete currently configured admin.
|
||||
#[get("/settings")]
|
||||
pub fn settings_menu(flash: Option<FlashMessage>, _auth: Authenticated) -> Template {
|
||||
pub fn settings_menu(
|
||||
_auth: Authenticated,
|
||||
flash: Option<FlashMessage>,
|
||||
config: &State<RocketConfig>,
|
||||
) -> Template {
|
||||
let mut context = Context::new();
|
||||
context.insert("back", &Some("/".to_string()));
|
||||
context.insert("title", &Some("Settings".to_string()));
|
||||
|
||||
// pass in mode from managed state so we can conditionally render html elements
|
||||
context.insert("standalone_mode", &config.standalone_mode);
|
||||
|
||||
// check to see if there is a flash message to display
|
||||
if let Some(flash) = flash {
|
||||
context.insert("flash_name", &Some(flash.kind().to_string()));
|
||||
|
|
Loading…
Reference in New Issue