Add some feedback when performing some actions (#552)

* Add a way to display flash messages

* Make the flash messages look nice

* Add actual feedback messages

* cargo fmt

* Move flash messages to PlumeRocket

And add trait to convert PlumeRocket to BaseContext

* Remove useless lifetime
This commit is contained in:
Baptiste Gelez
2019-04-30 11:04:25 +01:00
committed by GitHub
parent 18ae6e26b3
commit 8f1ab3485e
40 changed files with 3255 additions and 445 deletions
+36 -2
View File
@@ -1,4 +1,4 @@
use plume_models::{notifications::*, users::User, Connection};
use plume_models::{notifications::*, users::User, Connection, PlumeRocket};
use rocket::http::hyper::header::{ETag, EntityTag};
use rocket::http::{Method, Status};
@@ -13,7 +13,41 @@ pub use askama_escape::escape;
pub static CACHE_NAME: &str = env!("CACHE_ID");
pub type BaseContext<'a> = &'a (&'a Connection, &'a Catalog, Option<User>);
pub type BaseContext<'a> = &'a (
&'a Connection,
&'a Catalog,
Option<User>,
Option<(String, String)>,
);
pub trait IntoContext {
fn to_context(
&self,
) -> (
&Connection,
&Catalog,
Option<User>,
Option<(String, String)>,
);
}
impl IntoContext for PlumeRocket {
fn to_context(
&self,
) -> (
&Connection,
&Catalog,
Option<User>,
Option<(String, String)>,
) {
(
&*self.conn,
&self.intl.catalog,
self.user.clone(),
self.flash_msg.clone(),
)
}
}
#[derive(Debug)]
pub struct Ructe(pub Vec<u8>);