- Notifications
You must be signed in to change notification settings - Fork328
Dan product notifications#1524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
13 commits Select commitHold shift + click to select a range
a2a4ce2
checkpoint product notifications
chillenbergera555f4e
Merge branch 'master' into dan-product-notifications
chillenbergerc9fefe0
checkpoint
chillenbergerc432f03
Merge branch 'master' into dan-product-notifications
chillenberger495de99
backend working, front end design working
chillenbergerc5b9932
add top level notices to layout
chillenberger4f5fdb2
add ability to show/hide modal with events and use this feature
chillenberger11c455b
all for many high level notifications
chillenbergeraa26bc3
clean up code, prevent modal collision
chillenbergerd6c598c
fmt
chillenbergerff02bb7
Merge branch 'master' into dan-product-notifications
chillenberger270032a
add product marketing banner to layout
chillenberger2a67b62
adn new line
chillenbergerFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
13 changes: 7 additions & 6 deletionspgml-dashboard/src/api/deployment/deployment_models.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletionspgml-dashboard/src/api/deployment/notebooks.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 7 additions & 6 deletionspgml-dashboard/src/api/deployment/projects.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 7 additions & 6 deletionspgml-dashboard/src/api/deployment/snapshots.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletionspgml-dashboard/src/api/deployment/uploader.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletionspgml-dashboard/src/components/modal/mod.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletionpgml-dashboard/src/components/modal/template.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionpgml-dashboard/src/components/notifications/marketing/alert_banner/template.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletionspgml-dashboard/src/components/notifications/marketing/feature_banner/feature_banner.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionpgml-dashboard/src/components/notifications/marketing/feature_banner/template.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletionspgml-dashboard/src/components/notifications/mod.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3,3 +3,6 @@ | ||
// src/components/notifications/marketing | ||
pub mod marketing; | ||
// src/components/notifications/product | ||
pub mod product; |
6 changes: 6 additions & 0 deletionspgml-dashboard/src/components/notifications/product/mod.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// This file is automatically generated. | ||
// You shouldn't modify it manually. | ||
// src/components/notifications/product/product_banner | ||
pub mod product_banner; | ||
pub use product_banner::ProductBanner; |
96 changes: 96 additions & 0 deletionspgml-dashboard/src/components/notifications/product/product_banner/mod.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
use crate::utils::random_string; | ||
use crate::{Notification, NotificationLevel}; | ||
use pgml_components::component; | ||
use sailfish::TemplateOnce; | ||
#[derive(TemplateOnce, Default, Clone)] | ||
#[template(path = "notifications/product/product_banner/template.html")] | ||
pub struct ProductBanner { | ||
notification: Option<Notification>, | ||
location_id: String, | ||
url: String, | ||
show_modal_on_load: bool, | ||
} | ||
impl ProductBanner { | ||
pub fn from_notification(notification: Option<&Notification>) -> ProductBanner { | ||
let mut unique_target = random_string(10); | ||
unique_target.insert(0, 'a'); | ||
let location_id = ProductBanner::make_location_id(notification.clone(), unique_target.clone()); | ||
let url = ProductBanner::make_url(notification.clone(), unique_target.clone()); | ||
ProductBanner { | ||
notification: notification.cloned(), | ||
location_id, | ||
url, | ||
show_modal_on_load: true, | ||
} | ||
} | ||
pub fn get_location_id(&self) -> String { | ||
self.location_id.clone() | ||
} | ||
pub fn get_url(&self) -> String { | ||
self.url.clone() | ||
} | ||
pub fn set_show_modal_on_load(mut self, show_modal_on_load: bool) -> ProductBanner { | ||
self.show_modal_on_load = show_modal_on_load; | ||
self | ||
} | ||
fn make_location_id(notification: Option<&Notification>, random_target: String) -> String { | ||
match notification { | ||
Some(notification) => match notification.level { | ||
NotificationLevel::ProductHigh => random_target, | ||
_ => { | ||
format!( | ||
"product-banner{}{}", | ||
notification.level.to_string(), | ||
notification | ||
.deployment | ||
.as_ref() | ||
.and_then(|id| Some(format!("-{}", id))) | ||
.unwrap_or(String::new()) | ||
) | ||
} | ||
}, | ||
_ => random_target, | ||
} | ||
} | ||
fn make_url(notification: Option<&Notification>, random_target: String) -> String { | ||
let mut url = format!("/dashboard/notifications/product"); | ||
url.push_str(match notification { | ||
Some(notification) => match notification.level { | ||
NotificationLevel::ProductHigh => "/remove_banner", | ||
_ => "/replace_banner", | ||
}, | ||
None => "/remove_banner", | ||
}); | ||
let query_params: Vec<Option<String>> = vec![ | ||
notification.and_then(|n| Some(format!("id={}", n.id))), | ||
notification.and_then(|n| { | ||
n.deployment | ||
.as_ref() | ||
.and_then(|id| Some(format!("deployment_id={}", id))) | ||
}), | ||
Some(format!("target={}", random_target)), | ||
]; | ||
let all_params = query_params | ||
.iter() | ||
.filter_map(|x| x.clone()) | ||
.collect::<Vec<String>>() | ||
.join("&"); | ||
url.push_str(&("?".to_owned() + &all_params)); | ||
url | ||
} | ||
} | ||
component!(ProductBanner); |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.