BlueGit

ict rusty-teams

feat(channel): announcement posts with headline banner like Teams

- show the Teams announcement banner (color theme or uploaded image) above the subject
- keep the banner attachment content from Graph so edits send it back
- megaphone in the post format bar: headline on a color banner, four Teams themes, "Add a subheading"
- send the banner as an announcement-card attachment with teamsAppId

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-06 · 3 weeks ago

Hash
3fd6abd647cf7c815ee376252847b33db8b5ce25
Parent
9c1cde1a
23 files changed +584 −15
crates/app-base/src/assets.rs +2 −1
@@ -8,7 +8,8 @@ macro_rules! symbols {
8 8 };
9 9 }
10 10
11 const SYMBOLS: [(&str, &[u8]); 77] = symbols![
11 const SYMBOLS: [(&str, &[u8]); 78] = symbols![
12 "campaign",
12 13 "bot",
13 14 "copilot_color",
14 15 "done",
@@ -8,7 +8,8 @@ macro_rules! symbols {
8 };
8 };
9}
9}
10
10
11const SYMBOLS: [(&str, &[u8]); 77] = symbols![
11const SYMBOLS: [(&str, &[u8]); 78] = symbols![
12 "campaign",
12 "bot",
13 "bot",
13 "copilot_color",
14 "copilot_color",
14 "done",
15 "done",
crates/app-state/src/demo.rs +22 −0
@@ -11,6 +11,7 @@ use store::{
11 11 Store, TeamLayoutRecord, TeamRecord,
12 12 };
13 13 use teams_core::{
14 ANNOUNCEMENT_BANNER_TYPE,
14 15 Activity, ActivityHorizons, ActivityItem, ActivitySnapshot, CallEvent, CallPhase, CallType, CardActionOutcome, ChatApp, Gif, Language,
15 16 LanguageSettings, LinkPreview, MentionCandidate, NOTES_CHAT_ID, PersonCandidate, PersonSource,
16 17 PinnedMessage, SavedMessage, TaskDialog, TaskDialogKind, Translation, TranslationBehavior,
@@ -2216,6 +2217,27 @@ fn code_post(channel: &str, tobias: (&str, &str)) -> Vec<MessageRecord> {
2216 2217 "[]",
2217 2218 false,
2218 2219 ),
2220 with_attachments(
2221 with_subject(
2222 message(
2223 channel,
2224 "t9",
2225 None,
2226 tobias,
2227 at(0, 12, 10),
2228 "<attachment id=\"announcement-card-demo\"></attachment><p>Please merge your last changes by Thursday 18:00. Anything later goes into release 44.</p>",
2229 "[]",
2230 false,
2231 ),
2232 "Code freeze starts Thursday",
2233 ),
2234 &format!(
2235 r#"[{{"content_type":"{ANNOUNCEMENT_BANNER_TYPE}","id":"announcement-card-demo","name":null,"url":null,"text":null,"content":{}}}]"#,
2236 serde_json::Value::String(
2237 r#"{"title":"Release 43 ships Friday","cardImageType":"colorTheme","cardImageDetails":{"colorTheme":"periwinkleBlue"}}"#.to_owned()
2238 )
2239 ),
2240 ),
2219 2241 ]
2220 2242 }
2221 2243
@@ -11,6 +11,7 @@ use store::{
11 Store, TeamLayoutRecord, TeamRecord,
11 Store, TeamLayoutRecord, TeamRecord,
12};
12};
13use teams_core::{
13use teams_core::{
14 ANNOUNCEMENT_BANNER_TYPE,
14 Activity, ActivityHorizons, ActivityItem, ActivitySnapshot, CallEvent, CallPhase, CallType, CardActionOutcome, ChatApp, Gif, Language,
15 Activity, ActivityHorizons, ActivityItem, ActivitySnapshot, CallEvent, CallPhase, CallType, CardActionOutcome, ChatApp, Gif, Language,
15 LanguageSettings, LinkPreview, MentionCandidate, NOTES_CHAT_ID, PersonCandidate, PersonSource,
16 LanguageSettings, LinkPreview, MentionCandidate, NOTES_CHAT_ID, PersonCandidate, PersonSource,
16 PinnedMessage, SavedMessage, TaskDialog, TaskDialogKind, Translation, TranslationBehavior,
17 PinnedMessage, SavedMessage, TaskDialog, TaskDialogKind, Translation, TranslationBehavior,
@@ -2216,6 +2217,27 @@ fn code_post(channel: &str, tobias: (&str, &str)) -> Vec<MessageRecord> {
2216 "[]",
2217 "[]",
2217 false,
2218 false,
2218 ),
2219 ),
2220 with_attachments(
2221 with_subject(
2222 message(
2223 channel,
2224 "t9",
2225 None,
2226 tobias,
2227 at(0, 12, 10),
2228 "<attachment id=\"announcement-card-demo\"></attachment><p>Please merge your last changes by Thursday 18:00. Anything later goes into release 44.</p>",
2229 "[]",
2230 false,
2231 ),
2232 "Code freeze starts Thursday",
2233 ),
2234 &format!(
2235 r#"[{{"content_type":"{ANNOUNCEMENT_BANNER_TYPE}","id":"announcement-card-demo","name":null,"url":null,"text":null,"content":{}}}]"#,
2236 serde_json::Value::String(
2237 r#"{"title":"Release 43 ships Friday","cardImageType":"colorTheme","cardImageDetails":{"colorTheme":"periwinkleBlue"}}"#.to_owned()
2238 )
2239 ),
2240 ),
2219 ]
2241 ]
2220}
2242}
2221
2243
crates/app-state/src/outgoing.rs +8 −1
@@ -4,11 +4,13 @@ use chrono::{DateTime, Utc};
4 4 use gpui_kit::Image;
5 5 use serde::{Deserialize, Serialize};
6 6 use teams_core::{
7 AnnouncementBanner,
7 8 Draft, FileKind, FileReference, HostedImage, LinkPreview, MentionInput, MessageExtras,
8 9 OBJECT_MARK, UploadedFile,
9 10 };
10 11
11 12 use store::MessageImportance;
13 use uuid::Uuid;
12 14
13 15 use crate::remote_image::RemoteImage;
14 16
@@ -60,6 +62,7 @@ pub struct Outgoing {
60 62 pub files: Vec<OutgoingFile>,
61 63 pub link_preview: Option<LinkPreview>,
62 64 pub importance: MessageImportance,
65 pub banner: Option<AnnouncementBanner>,
63 66 }
64 67
65 68 impl Outgoing {
@@ -99,7 +102,11 @@ impl Outgoing {
99 102 pub fn extras(&self) -> MessageExtras {
100 103 MessageExtras {
101 104 importance: self.importance.stored(),
102 kept: Vec::new(),
105 kept: self
106 .banner
107 .iter()
108 .map(|banner| banner.attachment(format!("announcement-card-{}", Uuid::new_v4().simple())))
109 .collect(),
103 110 images: self
104 111 .images
105 112 .iter()
@@ -4,11 +4,13 @@ use chrono::{DateTime, Utc};
4use gpui_kit::Image;
4use gpui_kit::Image;
5use serde::{Deserialize, Serialize};
5use serde::{Deserialize, Serialize};
6use teams_core::{
6use teams_core::{
7 AnnouncementBanner,
7 Draft, FileKind, FileReference, HostedImage, LinkPreview, MentionInput, MessageExtras,
8 Draft, FileKind, FileReference, HostedImage, LinkPreview, MentionInput, MessageExtras,
8 OBJECT_MARK, UploadedFile,
9 OBJECT_MARK, UploadedFile,
9};
10};
10
11
11use store::MessageImportance;
12use store::MessageImportance;
13use uuid::Uuid;
12
14
13use crate::remote_image::RemoteImage;
15use crate::remote_image::RemoteImage;
14
16
@@ -60,6 +62,7 @@ pub struct Outgoing {
60 pub files: Vec<OutgoingFile>,
62 pub files: Vec<OutgoingFile>,
61 pub link_preview: Option<LinkPreview>,
63 pub link_preview: Option<LinkPreview>,
62 pub importance: MessageImportance,
64 pub importance: MessageImportance,
65 pub banner: Option<AnnouncementBanner>,
63}
66}
64
67
65impl Outgoing {
68impl Outgoing {
@@ -99,7 +102,11 @@ impl Outgoing {
99 pub fn extras(&self) -> MessageExtras {
102 pub fn extras(&self) -> MessageExtras {
100 MessageExtras {
103 MessageExtras {
101 importance: self.importance.stored(),
104 importance: self.importance.stored(),
102 kept: Vec::new(),
105 kept: self
106 .banner
107 .iter()
108 .map(|banner| banner.attachment(format!("announcement-card-{}", Uuid::new_v4().simple())))
109 .collect(),
103 images: self
110 images: self
104 .images
111 .images
105 .iter()
112 .iter()
crates/app-state/src/pending_rows.rs +2 −0
@@ -79,6 +79,7 @@ pub fn pending_row(
79 79 })
80 80 .collect(),
81 81 subject: outgoing.subject.clone(),
82 banner: outgoing.banner.clone(),
82 83 importance: outgoing.importance,
83 84 new_marker: false,
84 85 reply_root: None,
@@ -102,6 +103,7 @@ mod tests {
102 103 #[test]
103 104 fn a_pending_reply_shows_its_quote_before_the_server_echo() {
104 105 let outgoing = Outgoing {
106 banner: None,
105 107 draft: Draft::plain("agreed"),
106 108 subject: None,
107 109 mentions: Vec::new(),
@@ -79,6 +79,7 @@ pub fn pending_row(
79 })
79 })
80 .collect(),
80 .collect(),
81 subject: outgoing.subject.clone(),
81 subject: outgoing.subject.clone(),
82 banner: outgoing.banner.clone(),
82 importance: outgoing.importance,
83 importance: outgoing.importance,
83 new_marker: false,
84 new_marker: false,
84 reply_root: None,
85 reply_root: None,
@@ -102,6 +103,7 @@ mod tests {
102 #[test]
103 #[test]
103 fn a_pending_reply_shows_its_quote_before_the_server_echo() {
104 fn a_pending_reply_shows_its_quote_before_the_server_echo() {
104 let outgoing = Outgoing {
105 let outgoing = Outgoing {
106 banner: None,
105 draft: Draft::plain("agreed"),
107 draft: Draft::plain("agreed"),
106 subject: None,
108 subject: None,
107 mentions: Vec::new(),
109 mentions: Vec::new(),
crates/app-state/src/rows.rs +4 −0
@@ -7,6 +7,7 @@ use gpui_kit::Image;
7 7 use store::{MessageImportance, MessageRecord};
8 8 use teams_core::roster_event::{RosterEvent, roster_event};
9 9 use teams_core::{
10 AnnouncementBanner, attachments,
10 11 JumboEmoji, jumbo_emoji,
11 12 AdaptiveCard, CallEvent, CallPhase, Draft, FileCard, ForwardHeader, ForwardInfo,
12 13 ImageRef, LinkPreview, forwards,
@@ -179,6 +180,7 @@ pub struct MessageRow {
179 180 pub meeting_link: Option<String>,
180 181 pub adaptive_cards: Vec<AdaptiveCard>,
181 182 pub subject: Option<String>,
183 pub banner: Option<AnnouncementBanner>,
182 184 pub importance: MessageImportance,
183 185 pub new_marker: bool,
184 186 pub reply_root: Option<String>,
@@ -761,6 +763,7 @@ fn event_row(
761 763 meeting_link: None,
762 764 adaptive_cards: Vec::new(),
763 765 subject: None,
766 banner: None,
764 767 importance: MessageImportance::Normal,
765 768 new_marker: false,
766 769 reply_root: None,
@@ -897,6 +900,7 @@ fn message_row_with(
897 900 _ => adaptive_cards(record),
898 901 },
899 902 subject: record.subject.clone(),
903 banner: AnnouncementBanner::from_attachments(&attachments(record)),
900 904 importance: if record.deleted {
901 905 MessageImportance::Normal
902 906 } else {
@@ -7,6 +7,7 @@ use gpui_kit::Image;
7use store::{MessageImportance, MessageRecord};
7use store::{MessageImportance, MessageRecord};
8use teams_core::roster_event::{RosterEvent, roster_event};
8use teams_core::roster_event::{RosterEvent, roster_event};
9use teams_core::{
9use teams_core::{
10 AnnouncementBanner, attachments,
10 JumboEmoji, jumbo_emoji,
11 JumboEmoji, jumbo_emoji,
11 AdaptiveCard, CallEvent, CallPhase, Draft, FileCard, ForwardHeader, ForwardInfo,
12 AdaptiveCard, CallEvent, CallPhase, Draft, FileCard, ForwardHeader, ForwardInfo,
12 ImageRef, LinkPreview, forwards,
13 ImageRef, LinkPreview, forwards,
@@ -179,6 +180,7 @@ pub struct MessageRow {
179 pub meeting_link: Option<String>,
180 pub meeting_link: Option<String>,
180 pub adaptive_cards: Vec<AdaptiveCard>,
181 pub adaptive_cards: Vec<AdaptiveCard>,
181 pub subject: Option<String>,
182 pub subject: Option<String>,
183 pub banner: Option<AnnouncementBanner>,
182 pub importance: MessageImportance,
184 pub importance: MessageImportance,
183 pub new_marker: bool,
185 pub new_marker: bool,
184 pub reply_root: Option<String>,
186 pub reply_root: Option<String>,
@@ -761,6 +763,7 @@ fn event_row(
761 meeting_link: None,
763 meeting_link: None,
762 adaptive_cards: Vec::new(),
764 adaptive_cards: Vec::new(),
763 subject: None,
765 subject: None,
766 banner: None,
764 importance: MessageImportance::Normal,
767 importance: MessageImportance::Normal,
765 new_marker: false,
768 new_marker: false,
766 reply_root: None,
769 reply_root: None,
@@ -897,6 +900,7 @@ fn message_row_with(
897 _ => adaptive_cards(record),
900 _ => adaptive_cards(record),
898 },
901 },
899 subject: record.subject.clone(),
902 subject: record.subject.clone(),
903 banner: AnnouncementBanner::from_attachments(&attachments(record)),
900 importance: if record.deleted {
904 importance: if record.deleted {
901 MessageImportance::Normal
905 MessageImportance::Normal
902 } else {
906 } else {
crates/app-state/src/scheduled_rows.rs +1 −0
@@ -27,6 +27,7 @@ pub fn draft_id_of(key: &str) -> Option<&str> {
27 27
28 28 pub fn scheduled_outgoing(html: &str) -> Outgoing {
29 29 Outgoing {
30 banner: None,
30 31 draft: Draft::from_spans(&html_to_spans(html)).trimmed(),
31 32 subject: None,
32 33 mentions: Vec::new(),
@@ -27,6 +27,7 @@ pub fn draft_id_of(key: &str) -> Option<&str> {
27
27
28pub fn scheduled_outgoing(html: &str) -> Outgoing {
28pub fn scheduled_outgoing(html: &str) -> Outgoing {
29 Outgoing {
29 Outgoing {
30 banner: None,
30 draft: Draft::from_spans(&html_to_spans(html)).trimmed(),
31 draft: Draft::from_spans(&html_to_spans(html)).trimmed(),
31 subject: None,
32 subject: None,
32 mentions: Vec::new(),
33 mentions: Vec::new(),
crates/app-state/src/stored_outgoing.rs +20 −1
@@ -3,7 +3,7 @@ use std::sync::Arc;
3 3 use gpui_kit::{Image, ImageFormat};
4 4 use serde::{Deserialize, Serialize};
5 5 use store::{AttachmentImage, MessageImportance};
6 use teams_core::{Draft, DraftLine, LinkPreview, MentionInput};
6 use teams_core::{AnnouncementBanner, Draft, DraftLine, LinkPreview, MentionInput};
7 7
8 8 use crate::remote_image::{RemoteImage, RemoteKind};
9 9 use crate::outgoing::{InlineImage, Outgoing, OutgoingFile, OutgoingImage, ReplyPreview};
@@ -57,6 +57,8 @@ struct Payload {
57 57 preview: Option<StoredPreview>,
58 58 #[serde(default)]
59 59 importance: Option<String>,
60 #[serde(default)]
61 banner: Option<String>,
60 62 }
61 63
62 64 pub struct StoredOutgoing {
@@ -109,6 +111,7 @@ pub fn encode(outgoing: &Outgoing) -> Option<StoredOutgoing> {
109 111 image_height: preview.image_height,
110 112 }),
111 113 importance: outgoing.importance.stored().map(str::to_owned),
114 banner: outgoing.banner.as_ref().map(AnnouncementBanner::content),
112 115 })
113 116 .ok()?;
114 117 Some(StoredOutgoing { payload, images })
@@ -145,6 +148,7 @@ pub fn decode(payload: &str, images: &[AttachmentImage]) -> Option<Outgoing> {
145 148 objects,
146 149 preview,
147 150 importance,
151 banner,
148 152 } = serde_json::from_str(payload).ok()?;
149 153 let mut inline = images.iter();
150 154 let images = objects
@@ -172,6 +176,7 @@ pub fn decode(payload: &str, images: &[AttachmentImage]) -> Option<Outgoing> {
172 176 image_height: preview.image_height,
173 177 }),
174 178 importance: MessageImportance::from_stored(importance.as_deref()),
179 banner: banner.as_deref().and_then(AnnouncementBanner::parse),
175 180 })
176 181 }
177 182
@@ -229,9 +234,23 @@ mod tests {
229 234 image_height: None,
230 235 }),
231 236 importance: Default::default(),
237 banner: Some(AnnouncementBanner {
238 title: "Ship it".to_owned(),
239 background: teams_core::BannerBackground::Color("rose".to_owned()),
240 }),
232 241 }
233 242 }
234 243
244 #[test]
245 fn an_announcement_is_sent_as_a_banner_attachment_first() {
246 let extras = outgoing().extras();
247 let banner = &extras.kept[0];
248 assert!(banner.id.starts_with("announcement-card-"));
249 assert_eq!(banner.content_type.as_deref(), Some(teams_core::ANNOUNCEMENT_BANNER_TYPE));
250 assert_eq!(banner.teams_app_id.as_deref(), Some(teams_core::ANNOUNCEMENT_APP_ID));
251 assert!(extras.kept_html().starts_with("<attachment id=\"announcement-card-"));
252 }
253
235 254 #[test]
236 255 fn an_outgoing_message_round_trips_with_formatting_mention_and_image() {
237 256 let original = outgoing();
@@ -3,7 +3,7 @@ use std::sync::Arc;
3use gpui_kit::{Image, ImageFormat};
3use gpui_kit::{Image, ImageFormat};
4use serde::{Deserialize, Serialize};
4use serde::{Deserialize, Serialize};
5use store::{AttachmentImage, MessageImportance};
5use store::{AttachmentImage, MessageImportance};
6use teams_core::{Draft, DraftLine, LinkPreview, MentionInput};
6use teams_core::{AnnouncementBanner, Draft, DraftLine, LinkPreview, MentionInput};
7
7
8use crate::remote_image::{RemoteImage, RemoteKind};
8use crate::remote_image::{RemoteImage, RemoteKind};
9use crate::outgoing::{InlineImage, Outgoing, OutgoingFile, OutgoingImage, ReplyPreview};
9use crate::outgoing::{InlineImage, Outgoing, OutgoingFile, OutgoingImage, ReplyPreview};
@@ -57,6 +57,8 @@ struct Payload {
57 preview: Option<StoredPreview>,
57 preview: Option<StoredPreview>,
58 #[serde(default)]
58 #[serde(default)]
59 importance: Option<String>,
59 importance: Option<String>,
60 #[serde(default)]
61 banner: Option<String>,
60}
62}
61
63
62pub struct StoredOutgoing {
64pub struct StoredOutgoing {
@@ -109,6 +111,7 @@ pub fn encode(outgoing: &Outgoing) -> Option<StoredOutgoing> {
109 image_height: preview.image_height,
111 image_height: preview.image_height,
110 }),
112 }),
111 importance: outgoing.importance.stored().map(str::to_owned),
113 importance: outgoing.importance.stored().map(str::to_owned),
114 banner: outgoing.banner.as_ref().map(AnnouncementBanner::content),
112 })
115 })
113 .ok()?;
116 .ok()?;
114 Some(StoredOutgoing { payload, images })
117 Some(StoredOutgoing { payload, images })
@@ -145,6 +148,7 @@ pub fn decode(payload: &str, images: &[AttachmentImage]) -> Option<Outgoing> {
145 objects,
148 objects,
146 preview,
149 preview,
147 importance,
150 importance,
151 banner,
148 } = serde_json::from_str(payload).ok()?;
152 } = serde_json::from_str(payload).ok()?;
149 let mut inline = images.iter();
153 let mut inline = images.iter();
150 let images = objects
154 let images = objects
@@ -172,6 +176,7 @@ pub fn decode(payload: &str, images: &[AttachmentImage]) -> Option<Outgoing> {
172 image_height: preview.image_height,
176 image_height: preview.image_height,
173 }),
177 }),
174 importance: MessageImportance::from_stored(importance.as_deref()),
178 importance: MessageImportance::from_stored(importance.as_deref()),
179 banner: banner.as_deref().and_then(AnnouncementBanner::parse),
175 })
180 })
176}
181}
177
182
@@ -229,9 +234,23 @@ mod tests {
229 image_height: None,
234 image_height: None,
230 }),
235 }),
231 importance: Default::default(),
236 importance: Default::default(),
237 banner: Some(AnnouncementBanner {
238 title: "Ship it".to_owned(),
239 background: teams_core::BannerBackground::Color("rose".to_owned()),
240 }),
232 }
241 }
233 }
242 }
234
243
244 #[test]
245 fn an_announcement_is_sent_as_a_banner_attachment_first() {
246 let extras = outgoing().extras();
247 let banner = &extras.kept[0];
248 assert!(banner.id.starts_with("announcement-card-"));
249 assert_eq!(banner.content_type.as_deref(), Some(teams_core::ANNOUNCEMENT_BANNER_TYPE));
250 assert_eq!(banner.teams_app_id.as_deref(), Some(teams_core::ANNOUNCEMENT_APP_ID));
251 assert!(extras.kept_html().starts_with("<attachment id=\"announcement-card-"));
252 }
253
235 #[test]
254 #[test]
236 fn an_outgoing_message_round_trips_with_formatting_mention_and_image() {
255 fn an_outgoing_message_round_trips_with_formatting_mention_and_image() {
237 let original = outgoing();
256 let original = outgoing();
crates/app/assets/symbols/campaign.svg added +1 −0
@@ -0,0 +1 @@
1 <svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M716.92-460v-40h129.23v40H716.92Zm43.39 258.46-103.39-77.54 24.93-31.69 103.38 77.54-24.92 31.69Zm-81.54-450.77L653.85-684l103.38-77.54 24.92 31.69-103.38 77.54ZM220-241.54v-152.31h-41.54q-26.84 0-45.73-18.88-18.88-18.89-18.88-45.73v-43.08q0-26.84 18.88-45.73 18.89-18.88 45.73-18.88h149.23L486.15-660v360l-158.46-93.85H260v152.31h-40Zm226.15-129.69v-217.54l-107.23 62.62H178.46q-9.23 0-16.92 7.69-7.69 7.69-7.69 16.92v43.08q0 9.23 7.69 16.92 7.69 7.69 16.92 7.69h160.46l107.23 62.62Zm110.77 6.77v-231.08q20.08 18.62 32.35 48.89 12.27 30.27 12.27 66.65 0 36.38-12.27 66.65-12.27 30.27-32.35 48.89ZM300-480Z"/></svg>
@@ -0,0 +1 @@
1<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M716.92-460v-40h129.23v40H716.92Zm43.39 258.46-103.39-77.54 24.93-31.69 103.38 77.54-24.92 31.69Zm-81.54-450.77L653.85-684l103.38-77.54 24.92 31.69-103.38 77.54ZM220-241.54v-152.31h-41.54q-26.84 0-45.73-18.88-18.88-18.89-18.88-45.73v-43.08q0-26.84 18.88-45.73 18.89-18.88 45.73-18.88h149.23L486.15-660v360l-158.46-93.85H260v152.31h-40Zm226.15-129.69v-217.54l-107.23 62.62H178.46q-9.23 0-16.92 7.69-7.69 7.69-7.69 16.92v43.08q0 9.23 7.69 16.92 7.69 7.69 16.92 7.69h160.46l107.23 62.62Zm110.77 6.77v-231.08q20.08 18.62 32.35 48.89 12.27 30.27 12.27 66.65 0 36.38-12.27 66.65-12.27 30.27-32.35 48.89ZM300-480Z"/></svg>
crates/app/src/layout_guard.rs +31 −1
@@ -185,7 +185,7 @@ mod frames {
185 185 use crate::views::composer::{
186 186 COMPOSER_BOX_TAG, COMPOSER_FORMAT_BAR_TAG, COMPOSER_FORMAT_DIVIDER_TAG,
187 187 COMPOSER_ACTIONS_TAG, COMPOSER_FORMAT_TAG, COMPOSER_INPUT_TAG, COMPOSER_SEND_TAG,
188 POST_CARD_DIVIDER_TAG, POST_CARD_FOOTER_TAG, POST_CARD_HEADER_TAG, POST_CARD_SEND_TAG,
188 POST_ANNOUNCEMENT_TAG, POST_ANNOUNCEMENT_TOGGLE_TAG, POST_CARD_DIVIDER_TAG, POST_CARD_FOOTER_TAG, POST_CARD_HEADER_TAG, POST_CARD_SEND_TAG,
189 189 POST_CARD_SUBJECT_TAG,
190 190 };
191 191 use crate::views::conversation::{
@@ -2128,6 +2128,36 @@ mod frames {
2128 2128 );
2129 2129 }
2130 2130
2131 #[gpui_kit::test]
2132 fn announcement_mode_puts_the_banner_between_author_and_subheading(cx: &mut TestAppContext) {
2133 let mut visual = open_channel(cx, crate::views::post_card::POST_IN_CHANNEL_TAG);
2134 let open = visual
2135 .debug_bounds(crate::views::post_card::POST_IN_CHANNEL_TAG)
2136 .expect("post in channel card");
2137 visual.simulate_click(open.center(), Default::default());
2138 collect(&mut visual, Some(POST_ANNOUNCEMENT_TOGGLE_TAG));
2139 let toggle = visual
2140 .debug_bounds(POST_ANNOUNCEMENT_TOGGLE_TAG)
2141 .expect("announcement toggle in the format bar");
2142 let format_bar = visual.debug_bounds(COMPOSER_FORMAT_BAR_TAG).expect("format bar");
2143 assert!(format_bar.contains(&toggle.center()), "toggle outside the format bar");
2144 visual.simulate_click(toggle.center(), Default::default());
2145 collect(&mut visual, Some(POST_ANNOUNCEMENT_TAG));
2146 let mut bounds_of = |path: &'static str| {
2147 visual
2148 .debug_bounds(path)
2149 .unwrap_or_else(|| panic!("{path} missing"))
2150 };
2151 let card = bounds_of(COMPOSER_BOX_TAG);
2152 let header = bounds_of(POST_CARD_HEADER_TAG);
2153 let banner = bounds_of(POST_ANNOUNCEMENT_TAG);
2154 let subject = bounds_of(POST_CARD_SUBJECT_TAG);
2155 assert!(header.bottom() <= banner.top() && banner.bottom() <= subject.top());
2156 let left = f32::from(banner.left() - card.left());
2157 let right = f32::from(card.right() - banner.right());
2158 assert!((left - right).abs() < TOLERANCE, "banner insets: left {left}, right {right}");
2159 }
2160
2131 2161 #[gpui_kit::test]
2132 2162 fn channel_posts_start_the_body_at_the_avatar_edge_like_teams(cx: &mut TestAppContext) {
2133 2163 let mut visual = open_channel(cx, POST_FOOTER_AVATAR_TAG);
@@ -185,7 +185,7 @@ mod frames {
185 use crate::views::composer::{
185 use crate::views::composer::{
186 COMPOSER_BOX_TAG, COMPOSER_FORMAT_BAR_TAG, COMPOSER_FORMAT_DIVIDER_TAG,
186 COMPOSER_BOX_TAG, COMPOSER_FORMAT_BAR_TAG, COMPOSER_FORMAT_DIVIDER_TAG,
187 COMPOSER_ACTIONS_TAG, COMPOSER_FORMAT_TAG, COMPOSER_INPUT_TAG, COMPOSER_SEND_TAG,
187 COMPOSER_ACTIONS_TAG, COMPOSER_FORMAT_TAG, COMPOSER_INPUT_TAG, COMPOSER_SEND_TAG,
188 POST_CARD_DIVIDER_TAG, POST_CARD_FOOTER_TAG, POST_CARD_HEADER_TAG, POST_CARD_SEND_TAG,
188 POST_ANNOUNCEMENT_TAG, POST_ANNOUNCEMENT_TOGGLE_TAG, POST_CARD_DIVIDER_TAG, POST_CARD_FOOTER_TAG, POST_CARD_HEADER_TAG, POST_CARD_SEND_TAG,
189 POST_CARD_SUBJECT_TAG,
189 POST_CARD_SUBJECT_TAG,
190 };
190 };
191 use crate::views::conversation::{
191 use crate::views::conversation::{
@@ -2128,6 +2128,36 @@ mod frames {
2128 );
2128 );
2129 }
2129 }
2130
2130
2131 #[gpui_kit::test]
2132 fn announcement_mode_puts_the_banner_between_author_and_subheading(cx: &mut TestAppContext) {
2133 let mut visual = open_channel(cx, crate::views::post_card::POST_IN_CHANNEL_TAG);
2134 let open = visual
2135 .debug_bounds(crate::views::post_card::POST_IN_CHANNEL_TAG)
2136 .expect("post in channel card");
2137 visual.simulate_click(open.center(), Default::default());
2138 collect(&mut visual, Some(POST_ANNOUNCEMENT_TOGGLE_TAG));
2139 let toggle = visual
2140 .debug_bounds(POST_ANNOUNCEMENT_TOGGLE_TAG)
2141 .expect("announcement toggle in the format bar");
2142 let format_bar = visual.debug_bounds(COMPOSER_FORMAT_BAR_TAG).expect("format bar");
2143 assert!(format_bar.contains(&toggle.center()), "toggle outside the format bar");
2144 visual.simulate_click(toggle.center(), Default::default());
2145 collect(&mut visual, Some(POST_ANNOUNCEMENT_TAG));
2146 let mut bounds_of = |path: &'static str| {
2147 visual
2148 .debug_bounds(path)
2149 .unwrap_or_else(|| panic!("{path} missing"))
2150 };
2151 let card = bounds_of(COMPOSER_BOX_TAG);
2152 let header = bounds_of(POST_CARD_HEADER_TAG);
2153 let banner = bounds_of(POST_ANNOUNCEMENT_TAG);
2154 let subject = bounds_of(POST_CARD_SUBJECT_TAG);
2155 assert!(header.bottom() <= banner.top() && banner.bottom() <= subject.top());
2156 let left = f32::from(banner.left() - card.left());
2157 let right = f32::from(card.right() - banner.right());
2158 assert!((left - right).abs() < TOLERANCE, "banner insets: left {left}, right {right}");
2159 }
2160
2131 #[gpui_kit::test]
2161 #[gpui_kit::test]
2132 fn channel_posts_start_the_body_at_the_avatar_edge_like_teams(cx: &mut TestAppContext) {
2162 fn channel_posts_start_the_body_at_the_avatar_edge_like_teams(cx: &mut TestAppContext) {
2133 let mut visual = open_channel(cx, POST_FOOTER_AVATAR_TAG);
2163 let mut visual = open_channel(cx, POST_FOOTER_AVATAR_TAG);
crates/app/src/views/announcement_banner.rs added +83 −0
@@ -0,0 +1,83 @@
1 use gpui_kit::*;
2 use teams_core::{AnnouncementBanner, BannerBackground};
3
4 use crate::data::Directory;
5
6 pub const ANNOUNCEMENT_BANNER_TAG: &str = "post/announcement-banner";
7 pub const BANNER_COLORS: [&str; 4] = ["periwinkleBlue", "indigo", "rose", "orangeSherbet"];
8 pub const BANNER_HEIGHT: f32 = 112.;
9 pub const BANNER_RADIUS: f32 = 8.;
10 const HEADLINE_SIZE: f32 = 24.;
11 const HEADLINE_INSET: f32 = 24.;
12 const IMAGE_SHADE: f32 = 0.3;
13 const GRADIENT_ANGLE: f32 = 120.;
14
15 pub fn color_label(color: &str) -> &'static str {
16 match color {
17 "indigo" => "Indigo",
18 "rose" => "Rose",
19 "orangeSherbet" => "Orange sherbet",
20 _ => "Periwinkle",
21 }
22 }
23
24 pub fn banner_fill(color: &str) -> Background {
25 let (from, to) = match color {
26 "indigo" => (0x2F3185, 0x5B5FC7),
27 "rose" => (0xA4264F, 0xE26D8B),
28 "orangeSherbet" => (0xD8590F, 0xF5A55A),
29 _ => (0x4F52B2, 0x8B8EF0),
30 };
31 linear_gradient(
32 GRADIENT_ANGLE,
33 linear_color_stop(rgb(from), 0.),
34 linear_color_stop(rgb(to), 1.),
35 )
36 }
37
38 /// The banner frame without its headline, shared with the composer.
39 pub fn banner_frame(background: &BannerBackground, directory: &Directory) -> Div {
40 let frame = div()
41 .relative()
42 .w_full()
43 .h(px(BANNER_HEIGHT))
44 .flex()
45 .items_center()
46 .justify_center()
47 .px(px(HEADLINE_INSET))
48 .rounded(px(BANNER_RADIUS))
49 .overflow_hidden();
50 match background {
51 BannerBackground::Color(color) => frame.bg(banner_fill(color)),
52 BannerBackground::Image(url) => {
53 let frame = frame.bg(banner_fill(""));
54 match directory.image(url) {
55 Some(entry) => frame
56 .child(
57 img(entry.path.clone())
58 .absolute()
59 .inset_0()
60 .size_full()
61 .object_fit(ObjectFit::Cover),
62 )
63 .child(div().absolute().inset_0().bg(black().opacity(IMAGE_SHADE))),
64 None => frame,
65 }
66 }
67 }
68 }
69
70 pub fn headline_style(text: Div) -> Div {
71 text.relative()
72 .text_size(px(HEADLINE_SIZE))
73 .line_height(relative(1.25))
74 .font_weight(FontWeight::BOLD)
75 .text_color(white())
76 .text_center()
77 }
78
79 pub fn announcement_banner(banner: &AnnouncementBanner, directory: &Directory) -> Div {
80 banner_frame(&banner.background, directory)
81 .debug_selector(|| ANNOUNCEMENT_BANNER_TAG.into())
82 .child(headline_style(div().line_clamp(2)).child(banner.title.clone()))
83 }
@@ -0,0 +1,83 @@
1use gpui_kit::*;
2use teams_core::{AnnouncementBanner, BannerBackground};
3
4use crate::data::Directory;
5
6pub const ANNOUNCEMENT_BANNER_TAG: &str = "post/announcement-banner";
7pub const BANNER_COLORS: [&str; 4] = ["periwinkleBlue", "indigo", "rose", "orangeSherbet"];
8pub const BANNER_HEIGHT: f32 = 112.;
9pub const BANNER_RADIUS: f32 = 8.;
10const HEADLINE_SIZE: f32 = 24.;
11const HEADLINE_INSET: f32 = 24.;
12const IMAGE_SHADE: f32 = 0.3;
13const GRADIENT_ANGLE: f32 = 120.;
14
15pub fn color_label(color: &str) -> &'static str {
16 match color {
17 "indigo" => "Indigo",
18 "rose" => "Rose",
19 "orangeSherbet" => "Orange sherbet",
20 _ => "Periwinkle",
21 }
22}
23
24pub fn banner_fill(color: &str) -> Background {
25 let (from, to) = match color {
26 "indigo" => (0x2F3185, 0x5B5FC7),
27 "rose" => (0xA4264F, 0xE26D8B),
28 "orangeSherbet" => (0xD8590F, 0xF5A55A),
29 _ => (0x4F52B2, 0x8B8EF0),
30 };
31 linear_gradient(
32 GRADIENT_ANGLE,
33 linear_color_stop(rgb(from), 0.),
34 linear_color_stop(rgb(to), 1.),
35 )
36}
37
38/// The banner frame without its headline, shared with the composer.
39pub fn banner_frame(background: &BannerBackground, directory: &Directory) -> Div {
40 let frame = div()
41 .relative()
42 .w_full()
43 .h(px(BANNER_HEIGHT))
44 .flex()
45 .items_center()
46 .justify_center()
47 .px(px(HEADLINE_INSET))
48 .rounded(px(BANNER_RADIUS))
49 .overflow_hidden();
50 match background {
51 BannerBackground::Color(color) => frame.bg(banner_fill(color)),
52 BannerBackground::Image(url) => {
53 let frame = frame.bg(banner_fill(""));
54 match directory.image(url) {
55 Some(entry) => frame
56 .child(
57 img(entry.path.clone())
58 .absolute()
59 .inset_0()
60 .size_full()
61 .object_fit(ObjectFit::Cover),
62 )
63 .child(div().absolute().inset_0().bg(black().opacity(IMAGE_SHADE))),
64 None => frame,
65 }
66 }
67 }
68}
69
70pub fn headline_style(text: Div) -> Div {
71 text.relative()
72 .text_size(px(HEADLINE_SIZE))
73 .line_height(relative(1.25))
74 .font_weight(FontWeight::BOLD)
75 .text_color(white())
76 .text_center()
77}
78
79pub fn announcement_banner(banner: &AnnouncementBanner, directory: &Directory) -> Div {
80 banner_frame(&banner.background, directory)
81 .debug_selector(|| ANNOUNCEMENT_BANNER_TAG.into())
82 .child(headline_style(div().line_clamp(2)).child(banner.title.clone()))
83}
crates/app/src/views/composer.rs +21 −3
@@ -35,8 +35,9 @@ mod drafts;
35 35 mod format_menus;
36 36 mod post;
37 37 pub use post::{
38 POST_ANNOUNCEMENT_TAG, POST_ANNOUNCEMENT_TOGGLE_TAG,
38 39 POST_CARD_DIVIDER_TAG, POST_CARD_FOOTER_TAG, POST_CARD_HEADER_TAG, POST_CARD_SEND_TAG,
39 POST_CARD_SUBJECT_TAG,
40 POST_CARD_SUBJECT_TAG, SUBJECT_PLACEHOLDER,
40 41 };
41 42 mod rule;
42 43 mod schedule;
@@ -247,6 +248,7 @@ pub struct Composer {
247 248 format_overflow: bool,
248 249 format_bar: HashSet<String>,
249 250 post_subject: Option<Entity<InputState>>,
251 announcement: Option<post::AnnouncementDraft>,
250 252 active_cell: Option<(String, teams_core::Cell)>,
251 253 caret_before_table: usize,
252 254 caret_text: String,
@@ -516,6 +518,7 @@ impl Composer {
516 518 format_overflow: false,
517 519 format_bar: HashSet::new(),
518 520 post_subject: None,
521 announcement: None,
519 522 active_cell: None,
520 523 caret_before_table: 0,
521 524 caret_text: String::new(),
@@ -1886,6 +1889,7 @@ impl Composer {
1886 1889 Vec::new()
1887 1890 },
1888 1891 importance: self.sendable_importance(cx),
1892 banner: self.announcement_banner(cx),
1889 1893 }
1890 1894 }
1891 1895
@@ -2363,6 +2367,7 @@ impl Composer {
2363 2367 self.link.reset();
2364 2368 self.close_popup();
2365 2369 self.reset_importance();
2370 self.close_announcement(window, cx);
2366 2371 cx.emit(ComposerEvent::Submit(Box::new(outgoing)));
2367 2372 cx.notify();
2368 2373 }
@@ -2415,6 +2420,9 @@ impl Composer {
2415 2420 self.reply = outgoing.reply.clone();
2416 2421 self.editing = outgoing.edit.clone();
2417 2422 self.link.restore(outgoing.link_preview.clone());
2423 if outgoing.edit.is_none() {
2424 self.restore_announcement(outgoing.banner.as_ref(), window, cx);
2425 }
2418 2426 self.close_popup();
2419 2427 self.schedule_draft_save(cx);
2420 2428 cx.notify();
@@ -2656,8 +2664,9 @@ impl Composer {
2656 2664 }
2657 2665
2658 2666 fn format_bar_fit(&self) -> format_toolbar::BarFit {
2667 let toggle_width = if self.post_layout() { COMPOSER_BUTTON_SIZE } else { 0. };
2659 2668 let available = self.composer_bounds.get().map_or(f32::INFINITY, |bounds| {
2660 f32::from(bounds.size.width) - 2. * (COMPOSER_BUTTON_INSET + 1.)
2669 f32::from(bounds.size.width) - 2. * (COMPOSER_BUTTON_INSET + 1.) - toggle_width
2661 2670 });
2662 2671 format_toolbar::fit_groups(available, &format_toolbar::BAR_GROUPS)
2663 2672 }
@@ -2708,7 +2717,13 @@ impl Composer {
2708 2717 v_flex()
2709 2718 .debug_selector(|| COMPOSER_FORMAT_BAR_TAG.into())
2710 2719 .w_full()
2711 .child(row.w_full().p(px(COMPOSER_BUTTON_INSET)))
2720 .child(
2721 h_flex()
2722 .w_full()
2723 .p(px(COMPOSER_BUTTON_INSET))
2724 .child(row.flex_1().min_w_0())
2725 .children(self.render_announcement_toggle(cx)),
2726 )
2712 2727 .child(
2713 2728 div()
2714 2729 .debug_selector(|| COMPOSER_FORMAT_DIVIDER_TAG.into())
@@ -3593,6 +3608,7 @@ mod tests {
3593 3608 use crate::outgoing::{Outgoing, OutgoingFile, OutgoingImage};
3594 3609
3595 3610 let outgoing = Outgoing {
3611 banner: None,
3596 3612 draft: teams_core::Draft::default(),
3597 3613 subject: None,
3598 3614 mentions: Vec::new(),
@@ -3651,6 +3667,7 @@ mod tests {
3651 3667 images: Vec<crate::outgoing::OutgoingImage>,
3652 3668 ) -> crate::outgoing::Outgoing {
3653 3669 crate::outgoing::Outgoing {
3670 banner: None,
3654 3671 draft: teams_core::Draft::plain(text),
3655 3672 subject: None,
3656 3673 mentions: Vec::new(),
@@ -5147,6 +5164,7 @@ mod tests {
5147 5164 cx.update_window(handle, |_, window, cx| {
5148 5165 composer.update(cx, |composer, cx| {
5149 5166 let draft = Outgoing {
5167 banner: None,
5150 5168 draft: teams_core::Draft::plain("old"),
5151 5169 subject: None,
5152 5170 mentions: Vec::new(),
@@ -35,8 +35,9 @@ mod drafts;
35mod format_menus;
35mod format_menus;
36mod post;
36mod post;
37pub use post::{
37pub use post::{
38 POST_ANNOUNCEMENT_TAG, POST_ANNOUNCEMENT_TOGGLE_TAG,
38 POST_CARD_DIVIDER_TAG, POST_CARD_FOOTER_TAG, POST_CARD_HEADER_TAG, POST_CARD_SEND_TAG,
39 POST_CARD_DIVIDER_TAG, POST_CARD_FOOTER_TAG, POST_CARD_HEADER_TAG, POST_CARD_SEND_TAG,
39 POST_CARD_SUBJECT_TAG,
40 POST_CARD_SUBJECT_TAG, SUBJECT_PLACEHOLDER,
40};
41};
41mod rule;
42mod rule;
42mod schedule;
43mod schedule;
@@ -247,6 +248,7 @@ pub struct Composer {
247 format_overflow: bool,
248 format_overflow: bool,
248 format_bar: HashSet<String>,
249 format_bar: HashSet<String>,
249 post_subject: Option<Entity<InputState>>,
250 post_subject: Option<Entity<InputState>>,
251 announcement: Option<post::AnnouncementDraft>,
250 active_cell: Option<(String, teams_core::Cell)>,
252 active_cell: Option<(String, teams_core::Cell)>,
251 caret_before_table: usize,
253 caret_before_table: usize,
252 caret_text: String,
254 caret_text: String,
@@ -516,6 +518,7 @@ impl Composer {
516 format_overflow: false,
518 format_overflow: false,
517 format_bar: HashSet::new(),
519 format_bar: HashSet::new(),
518 post_subject: None,
520 post_subject: None,
521 announcement: None,
519 active_cell: None,
522 active_cell: None,
520 caret_before_table: 0,
523 caret_before_table: 0,
521 caret_text: String::new(),
524 caret_text: String::new(),
@@ -1886,6 +1889,7 @@ impl Composer {
1886 Vec::new()
1889 Vec::new()
1887 },
1890 },
1888 importance: self.sendable_importance(cx),
1891 importance: self.sendable_importance(cx),
1892 banner: self.announcement_banner(cx),
1889 }
1893 }
1890 }
1894 }
1891
1895
@@ -2363,6 +2367,7 @@ impl Composer {
2363 self.link.reset();
2367 self.link.reset();
2364 self.close_popup();
2368 self.close_popup();
2365 self.reset_importance();
2369 self.reset_importance();
2370 self.close_announcement(window, cx);
2366 cx.emit(ComposerEvent::Submit(Box::new(outgoing)));
2371 cx.emit(ComposerEvent::Submit(Box::new(outgoing)));
2367 cx.notify();
2372 cx.notify();
2368 }
2373 }
@@ -2415,6 +2420,9 @@ impl Composer {
2415 self.reply = outgoing.reply.clone();
2420 self.reply = outgoing.reply.clone();
2416 self.editing = outgoing.edit.clone();
2421 self.editing = outgoing.edit.clone();
2417 self.link.restore(outgoing.link_preview.clone());
2422 self.link.restore(outgoing.link_preview.clone());
2423 if outgoing.edit.is_none() {
2424 self.restore_announcement(outgoing.banner.as_ref(), window, cx);
2425 }
2418 self.close_popup();
2426 self.close_popup();
2419 self.schedule_draft_save(cx);
2427 self.schedule_draft_save(cx);
2420 cx.notify();
2428 cx.notify();
@@ -2656,8 +2664,9 @@ impl Composer {
2656 }
2664 }
2657
2665
2658 fn format_bar_fit(&self) -> format_toolbar::BarFit {
2666 fn format_bar_fit(&self) -> format_toolbar::BarFit {
2667 let toggle_width = if self.post_layout() { COMPOSER_BUTTON_SIZE } else { 0. };
2659 let available = self.composer_bounds.get().map_or(f32::INFINITY, |bounds| {
2668 let available = self.composer_bounds.get().map_or(f32::INFINITY, |bounds| {
2660 f32::from(bounds.size.width) - 2. * (COMPOSER_BUTTON_INSET + 1.)
2669 f32::from(bounds.size.width) - 2. * (COMPOSER_BUTTON_INSET + 1.) - toggle_width
2661 });
2670 });
2662 format_toolbar::fit_groups(available, &format_toolbar::BAR_GROUPS)
2671 format_toolbar::fit_groups(available, &format_toolbar::BAR_GROUPS)
2663 }
2672 }
@@ -2708,7 +2717,13 @@ impl Composer {
2708 v_flex()
2717 v_flex()
2709 .debug_selector(|| COMPOSER_FORMAT_BAR_TAG.into())
2718 .debug_selector(|| COMPOSER_FORMAT_BAR_TAG.into())
2710 .w_full()
2719 .w_full()
2711 .child(row.w_full().p(px(COMPOSER_BUTTON_INSET)))
2720 .child(
2721 h_flex()
2722 .w_full()
2723 .p(px(COMPOSER_BUTTON_INSET))
2724 .child(row.flex_1().min_w_0())
2725 .children(self.render_announcement_toggle(cx)),
2726 )
2712 .child(
2727 .child(
2713 div()
2728 div()
2714 .debug_selector(|| COMPOSER_FORMAT_DIVIDER_TAG.into())
2729 .debug_selector(|| COMPOSER_FORMAT_DIVIDER_TAG.into())
@@ -3593,6 +3608,7 @@ mod tests {
3593 use crate::outgoing::{Outgoing, OutgoingFile, OutgoingImage};
3608 use crate::outgoing::{Outgoing, OutgoingFile, OutgoingImage};
3594
3609
3595 let outgoing = Outgoing {
3610 let outgoing = Outgoing {
3611 banner: None,
3596 draft: teams_core::Draft::default(),
3612 draft: teams_core::Draft::default(),
3597 subject: None,
3613 subject: None,
3598 mentions: Vec::new(),
3614 mentions: Vec::new(),
@@ -3651,6 +3667,7 @@ mod tests {
3651 images: Vec<crate::outgoing::OutgoingImage>,
3667 images: Vec<crate::outgoing::OutgoingImage>,
3652 ) -> crate::outgoing::Outgoing {
3668 ) -> crate::outgoing::Outgoing {
3653 crate::outgoing::Outgoing {
3669 crate::outgoing::Outgoing {
3670 banner: None,
3654 draft: teams_core::Draft::plain(text),
3671 draft: teams_core::Draft::plain(text),
3655 subject: None,
3672 subject: None,
3656 mentions: Vec::new(),
3673 mentions: Vec::new(),
@@ -5147,6 +5164,7 @@ mod tests {
5147 cx.update_window(handle, |_, window, cx| {
5164 cx.update_window(handle, |_, window, cx| {
5148 composer.update(cx, |composer, cx| {
5165 composer.update(cx, |composer, cx| {
5149 let draft = Outgoing {
5166 let draft = Outgoing {
5167 banner: None,
5150 draft: teams_core::Draft::plain("old"),
5168 draft: teams_core::Draft::plain("old"),
5151 subject: None,
5169 subject: None,
5152 mentions: Vec::new(),
5170 mentions: Vec::new(),
crates/app/src/views/composer/post.rs +202 −2
@@ -4,8 +4,13 @@ use gpui_kit::component::{Sizable as _, Size, h_flex, v_flex};
4 4 use gpui_kit::prelude::FluentBuilder as _;
5 5 use gpui_kit::*;
6 6
7 use super::{COMPOSER_BUTTON_SIZE, Composer, ComposerEvent};
7 use teams_core::{AnnouncementBanner, BannerBackground};
8
9 use super::{COMPOSER_BUTTON_SIZE, COMPOSER_ICON_SIZE, Composer, ComposerEvent};
8 10 use crate::theme;
11 use crate::views::announcement_banner::{
12 BANNER_COLORS, banner_fill, banner_frame, color_label, headline_style,
13 };
9 14 use crate::views::avatar::person_avatar;
10 15 use crate::views::widgets::symbol;
11 16
@@ -14,6 +19,17 @@ pub const POST_CARD_SUBJECT_TAG: &str = "composer/post/subject";
14 19 pub const POST_CARD_DIVIDER_TAG: &str = "composer/post/divider";
15 20 pub const POST_CARD_FOOTER_TAG: &str = "composer/post/footer";
16 21 pub const POST_CARD_SEND_TAG: &str = "composer/post/send";
22 pub const POST_ANNOUNCEMENT_TAG: &str = "composer/post/announcement";
23 pub const POST_ANNOUNCEMENT_TOGGLE_TAG: &str = "composer/post/announcement-toggle";
24 const ANNOUNCEMENT_TOOLTIP: &str = "Announcement";
25 const HEADLINE_PLACEHOLDER: &str = "Add a headline";
26 pub const SUBJECT_PLACEHOLDER: &str = "Add a subject";
27 const SUBHEADING_PLACEHOLDER: &str = "Add a subheading";
28 const HEADLINE_SIZE: f32 = 24.;
29 const SWATCH_SIZE: f32 = 18.;
30 const SWATCH_RING: f32 = 2.;
31 const SWATCH_GAP: f32 = 6.;
32 const SWATCH_INSET: f32 = 8.;
17 33 const POST_LABEL: &str = "Post";
18 34 const CLOSE_TOOLTIP: &str = "Close";
19 35 const AUTHOR_AVATAR: f32 = 24.;
@@ -23,12 +39,20 @@ const INPUT_TEXT_SCALE: f32 = 0.875;
23 39 const SUBJECT_INSET: f32 = 8.;
24 40 const TEXT_INSET: f32 = 16.;
25 41
42 pub(super) struct AnnouncementDraft {
43 headline: Entity<InputState>,
44 color: &'static str,
45 }
46
26 47 impl Composer {
27 48 /// Shows the channel post layout with `subject` above the body, or the chat layout when `None`.
28 49 pub fn set_post_layout(&mut self, subject: Option<Entity<InputState>>, cx: &mut Context<Self>) {
29 50 let changed = self.post_subject.as_ref().map(Entity::entity_id)
30 51 != subject.as_ref().map(Entity::entity_id);
31 52 self.post_subject = subject;
53 if self.post_subject.is_none() {
54 self.announcement = None;
55 }
32 56 if changed {
33 57 cx.notify();
34 58 }
@@ -38,8 +62,183 @@ impl Composer {
38 62 self.post_subject.is_some() && self.editing.is_none()
39 63 }
40 64
65 pub(super) fn announcement_banner(&self, cx: &App) -> Option<AnnouncementBanner> {
66 let draft = self.announcement.as_ref().filter(|_| self.post_layout())?;
67 let title = draft.headline.read(cx).value().trim().to_owned();
68 (!title.is_empty()).then(|| AnnouncementBanner {
69 title,
70 background: BannerBackground::Color(draft.color.to_owned()),
71 })
72 }
73
74 pub(super) fn restore_announcement(
75 &mut self,
76 banner: Option<&AnnouncementBanner>,
77 window: &mut Window,
78 cx: &mut Context<Self>,
79 ) {
80 match banner {
81 Some(banner) => {
82 let color = match &banner.background {
83 BannerBackground::Color(color) => BANNER_COLORS
84 .into_iter()
85 .find(|known| known == color)
86 .unwrap_or(BANNER_COLORS[0]),
87 BannerBackground::Image(_) => BANNER_COLORS[0],
88 };
89 self.open_announcement(color, window, cx);
90 if let Some(draft) = &self.announcement {
91 let title = banner.title.clone();
92 draft
93 .headline
94 .update(cx, |input, cx| input.set_value(title, window, cx));
95 }
96 }
97 None => self.close_announcement(window, cx),
98 }
99 }
100
101 fn toggle_announcement(&mut self, window: &mut Window, cx: &mut Context<Self>) {
102 if self.announcement.is_some() {
103 self.close_announcement(window, cx);
104 self.focus(window, cx);
105 } else {
106 self.open_announcement(BANNER_COLORS[0], window, cx);
107 if let Some(draft) = &self.announcement {
108 draft
109 .headline
110 .update(cx, |input, cx| input.focus(window, cx));
111 }
112 }
113 }
114
115 fn open_announcement(
116 &mut self,
117 color: &'static str,
118 window: &mut Window,
119 cx: &mut Context<Self>,
120 ) {
121 let headline = cx.new(|cx| InputState::new(window, cx).placeholder(HEADLINE_PLACEHOLDER));
122 self.announcement = Some(AnnouncementDraft { headline, color });
123 self.set_subject_placeholder(SUBHEADING_PLACEHOLDER, window, cx);
124 cx.notify();
125 }
126
127 pub(super) fn close_announcement(&mut self, window: &mut Window, cx: &mut Context<Self>) {
128 if self.announcement.take().is_some() {
129 self.set_subject_placeholder(SUBJECT_PLACEHOLDER, window, cx);
130 cx.notify();
131 }
132 }
133
134 fn set_subject_placeholder(
135 &self,
136 placeholder: &'static str,
137 window: &mut Window,
138 cx: &mut Context<Self>,
139 ) {
140 if let Some(subject) = &self.post_subject {
141 subject.update(cx, |input, cx| {
142 input.set_placeholder(placeholder, window, cx)
143 });
144 }
145 }
146
147 pub(super) fn render_announcement_toggle(
148 &self,
149 cx: &mut Context<Self>,
150 ) -> Option<Stateful<Div>> {
151 if !self.post_layout() {
152 return None;
153 }
154 let active = self.announcement.is_some();
155 Some(
156 div()
157 .id("composer-post-announcement")
158 .debug_selector(|| POST_ANNOUNCEMENT_TOGGLE_TAG.into())
159 .size(px(COMPOSER_BUTTON_SIZE))
160 .flex_none()
161 .flex()
162 .items_center()
163 .justify_center()
164 .rounded(px(6.))
165 .cursor_pointer()
166 .when(active, |button| button.bg(theme::popup_hover()))
167 .hover(|button| button.bg(theme::popup_hover()))
168 .tooltip(|window, cx| Tooltip::new(ANNOUNCEMENT_TOOLTIP).build(window, cx))
169 .child(symbol(
170 "campaign",
171 COMPOSER_ICON_SIZE,
172 if active {
173 theme::accent_soft()
174 } else {
175 theme::text_muted()
176 },
177 ))
178 .on_mouse_down(MouseButton::Left, |_, window, cx| {
179 window.prevent_default();
180 cx.stop_propagation();
181 })
182 .on_click(cx.listener(|this, _, window, cx| this.toggle_announcement(window, cx))),
183 )
184 }
185
186 fn render_announcement(&self, cx: &mut Context<Self>) -> Option<Div> {
187 let draft = self.announcement.as_ref()?;
188 let directory = &self.app.read(cx).directory;
189 let swatches = h_flex()
190 .absolute()
191 .right(px(SWATCH_INSET))
192 .bottom(px(SWATCH_INSET))
193 .gap(px(SWATCH_GAP))
194 .children(BANNER_COLORS.into_iter().map(|color| {
195 let selected = color == draft.color;
196 div()
197 .id(ElementId::Name(format!("composer-banner-{color}").into()))
198 .size(px(SWATCH_SIZE))
199 .rounded_full()
200 .border(px(SWATCH_RING))
201 .border_color(if selected {
202 white()
203 } else {
204 white().opacity(0.4)
205 })
206 .bg(banner_fill(color))
207 .cursor_pointer()
208 .tooltip(move |window, cx| Tooltip::new(color_label(color)).build(window, cx))
209 .on_click(cx.listener(move |this, _, _, cx| {
210 if let Some(draft) = this.announcement.as_mut() {
211 draft.color = color;
212 cx.notify();
213 }
214 }))
215 }));
216 Some(
217 div()
218 .debug_selector(|| POST_ANNOUNCEMENT_TAG.into())
219 .w_full()
220 .px(px(CARD_INSET))
221 .pt(px(CARD_INSET))
222 .child(
223 banner_frame(&BannerBackground::Color(draft.color.to_owned()), directory)
224 .child(
225 headline_style(div().w_full()).child(
226 Input::new(&draft.headline)
227 .appearance(false)
228 .bordered(false)
229 .with_size(Size::Size(px(HEADLINE_SIZE / INPUT_TEXT_SCALE))),
230 ),
231 )
232 .child(swatches),
233 ),
234 )
235 }
236
41 237 pub(super) fn render_post_header(&self, cx: &mut Context<Self>) -> Option<Div> {
42 let subject = self.post_subject.clone().filter(|_| self.editing.is_none())?;
238 let subject = self
239 .post_subject
240 .clone()
241 .filter(|_| self.editing.is_none())?;
43 242 let directory = &self.app.read(cx).directory;
44 243 let author = directory.me.as_ref().map(|me| {
45 244 h_flex()
@@ -87,6 +286,7 @@ impl Composer {
87 286 .child(div().flex_1())
88 287 .child(close),
89 288 )
289 .children(self.render_announcement(cx))
90 290 .child(
91 291 div()
92 292 .debug_selector(|| POST_CARD_SUBJECT_TAG.into())
@@ -4,8 +4,13 @@ use gpui_kit::component::{Sizable as _, Size, h_flex, v_flex};
4use gpui_kit::prelude::FluentBuilder as _;
4use gpui_kit::prelude::FluentBuilder as _;
5use gpui_kit::*;
5use gpui_kit::*;
6
6
7use super::{COMPOSER_BUTTON_SIZE, Composer, ComposerEvent};
7use teams_core::{AnnouncementBanner, BannerBackground};
8
9use super::{COMPOSER_BUTTON_SIZE, COMPOSER_ICON_SIZE, Composer, ComposerEvent};
8use crate::theme;
10use crate::theme;
11use crate::views::announcement_banner::{
12 BANNER_COLORS, banner_fill, banner_frame, color_label, headline_style,
13};
9use crate::views::avatar::person_avatar;
14use crate::views::avatar::person_avatar;
10use crate::views::widgets::symbol;
15use crate::views::widgets::symbol;
11
16
@@ -14,6 +19,17 @@ pub const POST_CARD_SUBJECT_TAG: &str = "composer/post/subject";
14pub const POST_CARD_DIVIDER_TAG: &str = "composer/post/divider";
19pub const POST_CARD_DIVIDER_TAG: &str = "composer/post/divider";
15pub const POST_CARD_FOOTER_TAG: &str = "composer/post/footer";
20pub const POST_CARD_FOOTER_TAG: &str = "composer/post/footer";
16pub const POST_CARD_SEND_TAG: &str = "composer/post/send";
21pub const POST_CARD_SEND_TAG: &str = "composer/post/send";
22pub const POST_ANNOUNCEMENT_TAG: &str = "composer/post/announcement";
23pub const POST_ANNOUNCEMENT_TOGGLE_TAG: &str = "composer/post/announcement-toggle";
24const ANNOUNCEMENT_TOOLTIP: &str = "Announcement";
25const HEADLINE_PLACEHOLDER: &str = "Add a headline";
26pub const SUBJECT_PLACEHOLDER: &str = "Add a subject";
27const SUBHEADING_PLACEHOLDER: &str = "Add a subheading";
28const HEADLINE_SIZE: f32 = 24.;
29const SWATCH_SIZE: f32 = 18.;
30const SWATCH_RING: f32 = 2.;
31const SWATCH_GAP: f32 = 6.;
32const SWATCH_INSET: f32 = 8.;
17const POST_LABEL: &str = "Post";
33const POST_LABEL: &str = "Post";
18const CLOSE_TOOLTIP: &str = "Close";
34const CLOSE_TOOLTIP: &str = "Close";
19const AUTHOR_AVATAR: f32 = 24.;
35const AUTHOR_AVATAR: f32 = 24.;
@@ -23,12 +39,20 @@ const INPUT_TEXT_SCALE: f32 = 0.875;
23const SUBJECT_INSET: f32 = 8.;
39const SUBJECT_INSET: f32 = 8.;
24const TEXT_INSET: f32 = 16.;
40const TEXT_INSET: f32 = 16.;
25
41
42pub(super) struct AnnouncementDraft {
43 headline: Entity<InputState>,
44 color: &'static str,
45}
46
26impl Composer {
47impl Composer {
27 /// Shows the channel post layout with `subject` above the body, or the chat layout when `None`.
48 /// Shows the channel post layout with `subject` above the body, or the chat layout when `None`.
28 pub fn set_post_layout(&mut self, subject: Option<Entity<InputState>>, cx: &mut Context<Self>) {
49 pub fn set_post_layout(&mut self, subject: Option<Entity<InputState>>, cx: &mut Context<Self>) {
29 let changed = self.post_subject.as_ref().map(Entity::entity_id)
50 let changed = self.post_subject.as_ref().map(Entity::entity_id)
30 != subject.as_ref().map(Entity::entity_id);
51 != subject.as_ref().map(Entity::entity_id);
31 self.post_subject = subject;
52 self.post_subject = subject;
53 if self.post_subject.is_none() {
54 self.announcement = None;
55 }
32 if changed {
56 if changed {
33 cx.notify();
57 cx.notify();
34 }
58 }
@@ -38,8 +62,183 @@ impl Composer {
38 self.post_subject.is_some() && self.editing.is_none()
62 self.post_subject.is_some() && self.editing.is_none()
39 }
63 }
40
64
65 pub(super) fn announcement_banner(&self, cx: &App) -> Option<AnnouncementBanner> {
66 let draft = self.announcement.as_ref().filter(|_| self.post_layout())?;
67 let title = draft.headline.read(cx).value().trim().to_owned();
68 (!title.is_empty()).then(|| AnnouncementBanner {
69 title,
70 background: BannerBackground::Color(draft.color.to_owned()),
71 })
72 }
73
74 pub(super) fn restore_announcement(
75 &mut self,
76 banner: Option<&AnnouncementBanner>,
77 window: &mut Window,
78 cx: &mut Context<Self>,
79 ) {
80 match banner {
81 Some(banner) => {
82 let color = match &banner.background {
83 BannerBackground::Color(color) => BANNER_COLORS
84 .into_iter()
85 .find(|known| known == color)
86 .unwrap_or(BANNER_COLORS[0]),
87 BannerBackground::Image(_) => BANNER_COLORS[0],
88 };
89 self.open_announcement(color, window, cx);
90 if let Some(draft) = &self.announcement {
91 let title = banner.title.clone();
92 draft
93 .headline
94 .update(cx, |input, cx| input.set_value(title, window, cx));
95 }
96 }
97 None => self.close_announcement(window, cx),
98 }
99 }
100
101 fn toggle_announcement(&mut self, window: &mut Window, cx: &mut Context<Self>) {
102 if self.announcement.is_some() {
103 self.close_announcement(window, cx);
104 self.focus(window, cx);
105 } else {
106 self.open_announcement(BANNER_COLORS[0], window, cx);
107 if let Some(draft) = &self.announcement {
108 draft
109 .headline
110 .update(cx, |input, cx| input.focus(window, cx));
111 }
112 }
113 }
114
115 fn open_announcement(
116 &mut self,
117 color: &'static str,
118 window: &mut Window,
119 cx: &mut Context<Self>,
120 ) {
121 let headline = cx.new(|cx| InputState::new(window, cx).placeholder(HEADLINE_PLACEHOLDER));
122 self.announcement = Some(AnnouncementDraft { headline, color });
123 self.set_subject_placeholder(SUBHEADING_PLACEHOLDER, window, cx);
124 cx.notify();
125 }
126
127 pub(super) fn close_announcement(&mut self, window: &mut Window, cx: &mut Context<Self>) {
128 if self.announcement.take().is_some() {
129 self.set_subject_placeholder(SUBJECT_PLACEHOLDER, window, cx);
130 cx.notify();
131 }
132 }
133
134 fn set_subject_placeholder(
135 &self,
136 placeholder: &'static str,
137 window: &mut Window,
138 cx: &mut Context<Self>,
139 ) {
140 if let Some(subject) = &self.post_subject {
141 subject.update(cx, |input, cx| {
142 input.set_placeholder(placeholder, window, cx)
143 });
144 }
145 }
146
147 pub(super) fn render_announcement_toggle(
148 &self,
149 cx: &mut Context<Self>,
150 ) -> Option<Stateful<Div>> {
151 if !self.post_layout() {
152 return None;
153 }
154 let active = self.announcement.is_some();
155 Some(
156 div()
157 .id("composer-post-announcement")
158 .debug_selector(|| POST_ANNOUNCEMENT_TOGGLE_TAG.into())
159 .size(px(COMPOSER_BUTTON_SIZE))
160 .flex_none()
161 .flex()
162 .items_center()
163 .justify_center()
164 .rounded(px(6.))
165 .cursor_pointer()
166 .when(active, |button| button.bg(theme::popup_hover()))
167 .hover(|button| button.bg(theme::popup_hover()))
168 .tooltip(|window, cx| Tooltip::new(ANNOUNCEMENT_TOOLTIP).build(window, cx))
169 .child(symbol(
170 "campaign",
171 COMPOSER_ICON_SIZE,
172 if active {
173 theme::accent_soft()
174 } else {
175 theme::text_muted()
176 },
177 ))
178 .on_mouse_down(MouseButton::Left, |_, window, cx| {
179 window.prevent_default();
180 cx.stop_propagation();
181 })
182 .on_click(cx.listener(|this, _, window, cx| this.toggle_announcement(window, cx))),
183 )
184 }
185
186 fn render_announcement(&self, cx: &mut Context<Self>) -> Option<Div> {
187 let draft = self.announcement.as_ref()?;
188 let directory = &self.app.read(cx).directory;
189 let swatches = h_flex()
190 .absolute()
191 .right(px(SWATCH_INSET))
192 .bottom(px(SWATCH_INSET))
193 .gap(px(SWATCH_GAP))
194 .children(BANNER_COLORS.into_iter().map(|color| {
195 let selected = color == draft.color;
196 div()
197 .id(ElementId::Name(format!("composer-banner-{color}").into()))
198 .size(px(SWATCH_SIZE))
199 .rounded_full()
200 .border(px(SWATCH_RING))
201 .border_color(if selected {
202 white()
203 } else {
204 white().opacity(0.4)
205 })
206 .bg(banner_fill(color))
207 .cursor_pointer()
208 .tooltip(move |window, cx| Tooltip::new(color_label(color)).build(window, cx))
209 .on_click(cx.listener(move |this, _, _, cx| {
210 if let Some(draft) = this.announcement.as_mut() {
211 draft.color = color;
212 cx.notify();
213 }
214 }))
215 }));
216 Some(
217 div()
218 .debug_selector(|| POST_ANNOUNCEMENT_TAG.into())
219 .w_full()
220 .px(px(CARD_INSET))
221 .pt(px(CARD_INSET))
222 .child(
223 banner_frame(&BannerBackground::Color(draft.color.to_owned()), directory)
224 .child(
225 headline_style(div().w_full()).child(
226 Input::new(&draft.headline)
227 .appearance(false)
228 .bordered(false)
229 .with_size(Size::Size(px(HEADLINE_SIZE / INPUT_TEXT_SCALE))),
230 ),
231 )
232 .child(swatches),
233 ),
234 )
235 }
236
41 pub(super) fn render_post_header(&self, cx: &mut Context<Self>) -> Option<Div> {
237 pub(super) fn render_post_header(&self, cx: &mut Context<Self>) -> Option<Div> {
42 let subject = self.post_subject.clone().filter(|_| self.editing.is_none())?;
238 let subject = self
239 .post_subject
240 .clone()
241 .filter(|_| self.editing.is_none())?;
43 let directory = &self.app.read(cx).directory;
242 let directory = &self.app.read(cx).directory;
44 let author = directory.me.as_ref().map(|me| {
243 let author = directory.me.as_ref().map(|me| {
45 h_flex()
244 h_flex()
@@ -87,6 +286,7 @@ impl Composer {
87 .child(div().flex_1())
286 .child(div().flex_1())
88 .child(close),
287 .child(close),
89 )
288 )
289 .children(self.render_announcement(cx))
90 .child(
290 .child(
91 div()
291 div()
92 .debug_selector(|| POST_CARD_SUBJECT_TAG.into())
292 .debug_selector(|| POST_CARD_SUBJECT_TAG.into())
crates/app/src/views/conversation.rs +1 −0
@@ -2975,6 +2975,7 @@ impl ConversationView {
2975 2975 Vec::new()
2976 2976 };
2977 2977 let draft = Outgoing {
2978 banner: None,
2978 2979 draft: message_draft(&record),
2979 2980 subject: None,
2980 2981 mentions,
@@ -2975,6 +2975,7 @@ impl ConversationView {
2975 Vec::new()
2975 Vec::new()
2976 };
2976 };
2977 let draft = Outgoing {
2977 let draft = Outgoing {
2978 banner: None,
2978 draft: message_draft(&record),
2979 draft: message_draft(&record),
2979 subject: None,
2980 subject: None,
2980 mentions,
2981 mentions,
crates/app/src/views/conversation/feed.rs +1 −2
@@ -19,7 +19,6 @@ use crate::views::composer::{Composer, ComposerEvent, ReplyPreview};
19 19 use crate::views::post_card::{PostAction, post_in_channel_card};
20 20
21 21 const REPLY_PLACEHOLDER: &str = "Reply in thread";
22 const SUBJECT_PLACEHOLDER: &str = "Add a subject";
23 22
24 23 pub(super) struct FeedStash {
25 24 scroller: Entity<MessageScrollerState>,
@@ -31,7 +30,7 @@ pub(super) fn subject_input(
31 30 window: &mut Window,
32 31 cx: &mut Context<ConversationView>,
33 32 ) -> Entity<InputState> {
34 cx.new(|cx| InputState::new(window, cx).placeholder(SUBJECT_PLACEHOLDER))
33 cx.new(|cx| InputState::new(window, cx).placeholder(crate::views::composer::SUBJECT_PLACEHOLDER))
35 34 }
36 35
37 36 impl ConversationView {
@@ -19,7 +19,6 @@ use crate::views::composer::{Composer, ComposerEvent, ReplyPreview};
19use crate::views::post_card::{PostAction, post_in_channel_card};
19use crate::views::post_card::{PostAction, post_in_channel_card};
20
20
21const REPLY_PLACEHOLDER: &str = "Reply in thread";
21const REPLY_PLACEHOLDER: &str = "Reply in thread";
22const SUBJECT_PLACEHOLDER: &str = "Add a subject";
23
22
24pub(super) struct FeedStash {
23pub(super) struct FeedStash {
25 scroller: Entity<MessageScrollerState>,
24 scroller: Entity<MessageScrollerState>,
@@ -31,7 +30,7 @@ pub(super) fn subject_input(
31 window: &mut Window,
30 window: &mut Window,
32 cx: &mut Context<ConversationView>,
31 cx: &mut Context<ConversationView>,
33) -> Entity<InputState> {
32) -> Entity<InputState> {
34 cx.new(|cx| InputState::new(window, cx).placeholder(SUBJECT_PLACEHOLDER))
33 cx.new(|cx| InputState::new(window, cx).placeholder(crate::views::composer::SUBJECT_PLACEHOLDER))
35}
34}
36
35
37impl ConversationView {
36impl ConversationView {
crates/app/src/views/conversation/render_env.rs +2 −1
@@ -8,7 +8,7 @@ use gpui_kit::component::{
8 8 };
9 9 use gpui_kit::*;
10 10 use mcp::ReactionProposal;
11 use teams_core::{FileCard, ImageRef, LinkPreview};
11 use teams_core::{AnnouncementBanner, FileCard, ImageRef, LinkPreview};
12 12
13 13 use super::forward_select::SelectionSnapshot;
14 14 use super::{ConversationView, HoverSlot, PENDING_KEY_PREFIX};
@@ -79,6 +79,7 @@ impl RenderEnv {
79 79 .and_then(|call| call.recap.as_ref()?.recording.thumbnail.clone()),
80 80 )
81 81 .chain(message.files.iter().filter_map(FileCard::preview))
82 .chain(message.banner.as_ref().and_then(AnnouncementBanner::image))
82 83 .chain(
83 84 message
84 85 .reactions
@@ -8,7 +8,7 @@ use gpui_kit::component::{
8};
8};
9use gpui_kit::*;
9use gpui_kit::*;
10use mcp::ReactionProposal;
10use mcp::ReactionProposal;
11use teams_core::{FileCard, ImageRef, LinkPreview};
11use teams_core::{AnnouncementBanner, FileCard, ImageRef, LinkPreview};
12
12
13use super::forward_select::SelectionSnapshot;
13use super::forward_select::SelectionSnapshot;
14use super::{ConversationView, HoverSlot, PENDING_KEY_PREFIX};
14use super::{ConversationView, HoverSlot, PENDING_KEY_PREFIX};
@@ -79,6 +79,7 @@ impl RenderEnv {
79 .and_then(|call| call.recap.as_ref()?.recording.thumbnail.clone()),
79 .and_then(|call| call.recap.as_ref()?.recording.thumbnail.clone()),
80 )
80 )
81 .chain(message.files.iter().filter_map(FileCard::preview))
81 .chain(message.files.iter().filter_map(FileCard::preview))
82 .chain(message.banner.as_ref().and_then(AnnouncementBanner::image))
82 .chain(
83 .chain(
83 message
84 message
84 .reactions
85 .reactions
crates/app/src/views/mod.rs +1 −0
@@ -1,6 +1,7 @@
1 1 pub mod actions;
2 2 pub mod activity_panel;
3 3 pub mod adaptive_card;
4 pub mod announcement_banner;
4 5 pub mod add_people_dialog;
5 6 pub mod attachment_tray;
6 7 pub mod attachments;
@@ -1,6 +1,7 @@
1pub mod actions;
1pub mod actions;
2pub mod activity_panel;
2pub mod activity_panel;
3pub mod adaptive_card;
3pub mod adaptive_card;
4pub mod announcement_banner;
4pub mod add_people_dialog;
5pub mod add_people_dialog;
5pub mod attachment_tray;
6pub mod attachment_tray;
6pub mod attachments;
7pub mod attachments;
crates/app/src/views/post_card.rs +7 −0
@@ -4,6 +4,7 @@ use gpui_kit::prelude::FluentBuilder as _;
4 4 use gpui_kit::*;
5 5
6 6 use super::adaptive_card::cards_view;
7 use super::announcement_banner::announcement_banner;
7 8 use super::attachments::{attachments_view, message_body};
8 9 use super::avatar::{bot_avatar, person_avatar, with_presence};
9 10 use super::call_card::{CallActions, post_call_card};
@@ -294,10 +295,16 @@ fn message_block(
294 295 .text_color(theme::text())
295 296 .child(subject)
296 297 });
298 let banner = row
299 .banner
300 .as_ref()
301 .filter(|_| role == Role::Root && !row.deleted)
302 .map(|banner| announcement_banner(banner, directory));
297 303 let details = v_flex()
298 304 .w_full()
299 305 .min_w_0()
300 306 .gap(px(6.))
307 .children(banner)
301 308 .children(subject)
302 309 .child(content)
303 310 .children(translation)
@@ -4,6 +4,7 @@ use gpui_kit::prelude::FluentBuilder as _;
4use gpui_kit::*;
4use gpui_kit::*;
5
5
6use super::adaptive_card::cards_view;
6use super::adaptive_card::cards_view;
7use super::announcement_banner::announcement_banner;
7use super::attachments::{attachments_view, message_body};
8use super::attachments::{attachments_view, message_body};
8use super::avatar::{bot_avatar, person_avatar, with_presence};
9use super::avatar::{bot_avatar, person_avatar, with_presence};
9use super::call_card::{CallActions, post_call_card};
10use super::call_card::{CallActions, post_call_card};
@@ -294,10 +295,16 @@ fn message_block(
294 .text_color(theme::text())
295 .text_color(theme::text())
295 .child(subject)
296 .child(subject)
296 });
297 });
298 let banner = row
299 .banner
300 .as_ref()
301 .filter(|_| role == Role::Root && !row.deleted)
302 .map(|banner| announcement_banner(banner, directory));
297 let details = v_flex()
303 let details = v_flex()
298 .w_full()
304 .w_full()
299 .min_w_0()
305 .min_w_0()
300 .gap(px(6.))
306 .gap(px(6.))
307 .children(banner)
301 .children(subject)
308 .children(subject)
302 .child(content)
309 .child(content)
303 .children(translation)
310 .children(translation)
crates/app/src/views/proposal_card.rs +1 −0
@@ -98,6 +98,7 @@ pub fn outgoing_for(entry: &ProposalEntry, reply: Option<ReplyPreview>) -> Outgo
98 98 markdown.push(OBJECT_MARK);
99 99 }
100 100 Outgoing {
101 banner: None,
101 102 draft: Draft::from_markdown(&markdown),
102 103 subject: None,
103 104 mentions: entry
@@ -98,6 +98,7 @@ pub fn outgoing_for(entry: &ProposalEntry, reply: Option<ReplyPreview>) -> Outgo
98 markdown.push(OBJECT_MARK);
98 markdown.push(OBJECT_MARK);
99 }
99 }
100 Outgoing {
100 Outgoing {
101 banner: None,
101 draft: Draft::from_markdown(&markdown),
102 draft: Draft::from_markdown(&markdown),
102 subject: None,
103 subject: None,
103 mentions: entry
104 mentions: entry
crates/core/src/announcement.rs added +159 −0
@@ -0,0 +1,159 @@
1 use serde_json::{Value, json};
2
3 use crate::stored::{AttachmentInfo, ImageRef};
4
5 pub const ANNOUNCEMENT_BANNER_TYPE: &str =
6 "application/vnd.microsoft.teams.messaging-announcementBanner";
7 pub const ANNOUNCEMENT_APP_ID: &str = "announcement-card";
8 const DEFAULT_BANNER_COLOR: &str = "periwinkleBlue";
9 const COLOR_THEME: &str = "colorTheme";
10
11 #[derive(Debug, Clone, PartialEq, Eq)]
12 pub enum BannerBackground {
13 Color(String),
14 Image(String),
15 }
16
17 #[derive(Debug, Clone, PartialEq, Eq)]
18 pub struct AnnouncementBanner {
19 pub title: String,
20 pub background: BannerBackground,
21 }
22
23 impl AnnouncementBanner {
24 pub fn from_attachments(attachments: &[AttachmentInfo]) -> Option<AnnouncementBanner> {
25 attachments
26 .iter()
27 .filter(|attachment| {
28 attachment.content_type.as_deref() == Some(ANNOUNCEMENT_BANNER_TYPE)
29 })
30 .find_map(|attachment| AnnouncementBanner::parse(attachment.content.as_deref()?))
31 }
32
33 pub fn parse(content: &str) -> Option<AnnouncementBanner> {
34 let content: Value = serde_json::from_str(content).ok()?;
35 let title = content.get("title")?.as_str()?.trim().to_owned();
36 let details = content.get("cardImageDetails");
37 let image = details
38 .filter(|_| content.get("cardImageType").and_then(Value::as_str) != Some(COLOR_THEME))
39 .and_then(|details| {
40 image_source(details, "croppedImage")
41 .or_else(|| image_source(details, "originalImage"))
42 });
43 let background = match image {
44 Some(url) => BannerBackground::Image(url),
45 None => BannerBackground::Color(
46 details
47 .and_then(|details| details.get(COLOR_THEME))
48 .and_then(Value::as_str)
49 .unwrap_or(DEFAULT_BANNER_COLOR)
50 .to_owned(),
51 ),
52 };
53 Some(AnnouncementBanner { title, background })
54 }
55
56 pub fn image(&self) -> Option<ImageRef> {
57 let BannerBackground::Image(url) = &self.background else {
58 return None;
59 };
60 Some(ImageRef {
61 id: url.clone(),
62 url: url.clone(),
63 width: None,
64 height: None,
65 alt: Some(self.title.clone()),
66 })
67 }
68
69 /// `id` must be unique per message; Teams uses `announcement-card-<guid>`.
70 pub fn attachment(&self, id: String) -> graph::KeptAttachment {
71 graph::KeptAttachment {
72 id,
73 content_type: Some(ANNOUNCEMENT_BANNER_TYPE.to_owned()),
74 content: Some(self.content()),
75 content_url: None,
76 name: None,
77 teams_app_id: Some(ANNOUNCEMENT_APP_ID.to_owned()),
78 }
79 }
80
81 /// Only color banners can be sent; uploaded images need the Teams image service.
82 pub fn content(&self) -> String {
83 let color = match &self.background {
84 BannerBackground::Color(color) => color.as_str(),
85 BannerBackground::Image(_) => DEFAULT_BANNER_COLOR,
86 };
87 json!({
88 "title": self.title,
89 "cardImageType": COLOR_THEME,
90 "cardImageDetails": { COLOR_THEME: color },
91 })
92 .to_string()
93 }
94 }
95
96 fn image_source(details: &Value, key: &str) -> Option<String> {
97 let found = details
98 .get(key)
99 .or_else(|| details.get("uploadedImageDetail")?.get(key))?;
100 found
101 .get("source")
102 .or_else(|| found.get("url"))
103 .and_then(Value::as_str)
104 .filter(|url| url.starts_with("https://"))
105 .map(str::to_owned)
106 }
107
108 #[cfg(test)]
109 mod tests {
110 use super::*;
111
112 fn banner_attachment(content: &str) -> AttachmentInfo {
113 serde_json::from_value(json!({
114 "content_type": ANNOUNCEMENT_BANNER_TYPE,
115 "name": null,
116 "url": null,
117 "text": null,
118 "content": content,
119 }))
120 .unwrap()
121 }
122
123 #[test]
124 fn color_banner_from_graph_content() {
125 let content = r#"{"title":"Release day","cardImageType":"colorTheme","cardImageDetails":{"colorTheme":"periwinkleBlue"}}"#;
126 let banner = AnnouncementBanner::from_attachments(&[banner_attachment(content)]).unwrap();
127 assert_eq!(banner.title, "Release day");
128 assert_eq!(
129 banner.background,
130 BannerBackground::Color("periwinkleBlue".into())
131 );
132 }
133
134 #[test]
135 fn uploaded_image_banner_uses_the_cropped_image() {
136 let content = r#"{"title":"Hi","cardImageType":"uploadedImage","cardImageDetails":{"uploadedImageDetail":{"originalImage":{"source":"https://example.test/o"},"croppedImage":{"source":"https://example.test/c"}}}}"#;
137 let banner = AnnouncementBanner::parse(content).unwrap();
138 assert_eq!(
139 banner.background,
140 BannerBackground::Image("https://example.test/c".into())
141 );
142 }
143
144 #[test]
145 fn content_round_trips() {
146 let banner = AnnouncementBanner {
147 title: "Ship it".into(),
148 background: BannerBackground::Color("teal".into()),
149 };
150 assert_eq!(AnnouncementBanner::parse(&banner.content()), Some(banner));
151 }
152
153 #[test]
154 fn banner_without_content_is_none() {
155 let mut attachment = banner_attachment("");
156 attachment.content = None;
157 assert_eq!(AnnouncementBanner::from_attachments(&[attachment]), None);
158 }
159 }
@@ -0,0 +1,159 @@
1use serde_json::{Value, json};
2
3use crate::stored::{AttachmentInfo, ImageRef};
4
5pub const ANNOUNCEMENT_BANNER_TYPE: &str =
6 "application/vnd.microsoft.teams.messaging-announcementBanner";
7pub const ANNOUNCEMENT_APP_ID: &str = "announcement-card";
8const DEFAULT_BANNER_COLOR: &str = "periwinkleBlue";
9const COLOR_THEME: &str = "colorTheme";
10
11#[derive(Debug, Clone, PartialEq, Eq)]
12pub enum BannerBackground {
13 Color(String),
14 Image(String),
15}
16
17#[derive(Debug, Clone, PartialEq, Eq)]
18pub struct AnnouncementBanner {
19 pub title: String,
20 pub background: BannerBackground,
21}
22
23impl AnnouncementBanner {
24 pub fn from_attachments(attachments: &[AttachmentInfo]) -> Option<AnnouncementBanner> {
25 attachments
26 .iter()
27 .filter(|attachment| {
28 attachment.content_type.as_deref() == Some(ANNOUNCEMENT_BANNER_TYPE)
29 })
30 .find_map(|attachment| AnnouncementBanner::parse(attachment.content.as_deref()?))
31 }
32
33 pub fn parse(content: &str) -> Option<AnnouncementBanner> {
34 let content: Value = serde_json::from_str(content).ok()?;
35 let title = content.get("title")?.as_str()?.trim().to_owned();
36 let details = content.get("cardImageDetails");
37 let image = details
38 .filter(|_| content.get("cardImageType").and_then(Value::as_str) != Some(COLOR_THEME))
39 .and_then(|details| {
40 image_source(details, "croppedImage")
41 .or_else(|| image_source(details, "originalImage"))
42 });
43 let background = match image {
44 Some(url) => BannerBackground::Image(url),
45 None => BannerBackground::Color(
46 details
47 .and_then(|details| details.get(COLOR_THEME))
48 .and_then(Value::as_str)
49 .unwrap_or(DEFAULT_BANNER_COLOR)
50 .to_owned(),
51 ),
52 };
53 Some(AnnouncementBanner { title, background })
54 }
55
56 pub fn image(&self) -> Option<ImageRef> {
57 let BannerBackground::Image(url) = &self.background else {
58 return None;
59 };
60 Some(ImageRef {
61 id: url.clone(),
62 url: url.clone(),
63 width: None,
64 height: None,
65 alt: Some(self.title.clone()),
66 })
67 }
68
69 /// `id` must be unique per message; Teams uses `announcement-card-<guid>`.
70 pub fn attachment(&self, id: String) -> graph::KeptAttachment {
71 graph::KeptAttachment {
72 id,
73 content_type: Some(ANNOUNCEMENT_BANNER_TYPE.to_owned()),
74 content: Some(self.content()),
75 content_url: None,
76 name: None,
77 teams_app_id: Some(ANNOUNCEMENT_APP_ID.to_owned()),
78 }
79 }
80
81 /// Only color banners can be sent; uploaded images need the Teams image service.
82 pub fn content(&self) -> String {
83 let color = match &self.background {
84 BannerBackground::Color(color) => color.as_str(),
85 BannerBackground::Image(_) => DEFAULT_BANNER_COLOR,
86 };
87 json!({
88 "title": self.title,
89 "cardImageType": COLOR_THEME,
90 "cardImageDetails": { COLOR_THEME: color },
91 })
92 .to_string()
93 }
94}
95
96fn image_source(details: &Value, key: &str) -> Option<String> {
97 let found = details
98 .get(key)
99 .or_else(|| details.get("uploadedImageDetail")?.get(key))?;
100 found
101 .get("source")
102 .or_else(|| found.get("url"))
103 .and_then(Value::as_str)
104 .filter(|url| url.starts_with("https://"))
105 .map(str::to_owned)
106}
107
108#[cfg(test)]
109mod tests {
110 use super::*;
111
112 fn banner_attachment(content: &str) -> AttachmentInfo {
113 serde_json::from_value(json!({
114 "content_type": ANNOUNCEMENT_BANNER_TYPE,
115 "name": null,
116 "url": null,
117 "text": null,
118 "content": content,
119 }))
120 .unwrap()
121 }
122
123 #[test]
124 fn color_banner_from_graph_content() {
125 let content = r#"{"title":"Release day","cardImageType":"colorTheme","cardImageDetails":{"colorTheme":"periwinkleBlue"}}"#;
126 let banner = AnnouncementBanner::from_attachments(&[banner_attachment(content)]).unwrap();
127 assert_eq!(banner.title, "Release day");
128 assert_eq!(
129 banner.background,
130 BannerBackground::Color("periwinkleBlue".into())
131 );
132 }
133
134 #[test]
135 fn uploaded_image_banner_uses_the_cropped_image() {
136 let content = r#"{"title":"Hi","cardImageType":"uploadedImage","cardImageDetails":{"uploadedImageDetail":{"originalImage":{"source":"https://example.test/o"},"croppedImage":{"source":"https://example.test/c"}}}}"#;
137 let banner = AnnouncementBanner::parse(content).unwrap();
138 assert_eq!(
139 banner.background,
140 BannerBackground::Image("https://example.test/c".into())
141 );
142 }
143
144 #[test]
145 fn content_round_trips() {
146 let banner = AnnouncementBanner {
147 title: "Ship it".into(),
148 background: BannerBackground::Color("teal".into()),
149 };
150 assert_eq!(AnnouncementBanner::parse(&banner.content()), Some(banner));
151 }
152
153 #[test]
154 fn banner_without_content_is_none() {
155 let mut attachment = banner_attachment("");
156 attachment.content = None;
157 assert_eq!(AnnouncementBanner::from_attachments(&[attachment]), None);
158 }
159}
crates/core/src/lib.rs +4 −0
@@ -1,4 +1,5 @@
1 1 mod actions;
2 mod announcement;
2 3 mod activity_sync;
3 4 mod adaptive_card;
4 5 mod avatars;
@@ -70,6 +71,9 @@ mod translation;
70 71 mod youtube;
71 72
72 73 pub use activity_sync::stored_activity_feed;
74 pub use announcement::{
75 ANNOUNCEMENT_APP_ID, ANNOUNCEMENT_BANNER_TYPE, AnnouncementBanner, BannerBackground,
76 };
73 77 pub use chatsvc::{ActivityHorizons, ActivityItem, ActivitySnapshot};
74 78 pub use adaptive_card::{
75 79 ActionSplit, AdaptiveCard, CARD_THEME, CardAction, CardActionIcon, CardActionKind, CardColumn,
@@ -1,4 +1,5 @@
1mod actions;
1mod actions;
2mod announcement;
2mod activity_sync;
3mod activity_sync;
3mod adaptive_card;
4mod adaptive_card;
4mod avatars;
5mod avatars;
@@ -70,6 +71,9 @@ mod translation;
70mod youtube;
71mod youtube;
71
72
72pub use activity_sync::stored_activity_feed;
73pub use activity_sync::stored_activity_feed;
74pub use announcement::{
75 ANNOUNCEMENT_APP_ID, ANNOUNCEMENT_BANNER_TYPE, AnnouncementBanner, BannerBackground,
76};
73pub use chatsvc::{ActivityHorizons, ActivityItem, ActivitySnapshot};
77pub use chatsvc::{ActivityHorizons, ActivityItem, ActivitySnapshot};
74pub use adaptive_card::{
78pub use adaptive_card::{
75 ActionSplit, AdaptiveCard, CARD_THEME, CardAction, CardActionIcon, CardActionKind, CardColumn,
79 ActionSplit, AdaptiveCard, CARD_THEME, CardAction, CardActionIcon, CardActionKind, CardColumn,
crates/core/src/mapping.rs +2 −1
@@ -4,6 +4,7 @@ use store::{
4 4 ChannelRecord, ChatRecord, MemberRecord, MessageImportance, MessageRecord, TeamRecord,
5 5 };
6 6
7 use crate::announcement::ANNOUNCEMENT_BANNER_TYPE;
7 8 use crate::adaptive_card::card_content_text;
8 9 use crate::call_event::CallEvent;
9 10 use crate::forwarded::FORWARDED_CONTENT_TYPE;
@@ -244,7 +245,7 @@ pub(crate) fn attachment_info(attachment: &Attachment) -> AttachmentInfo {
244 245 is_card
245 246 || matches!(
246 247 attachment.content_type.as_deref(),
247 Some("messageReference" | FORWARDED_CONTENT_TYPE)
248 Some("messageReference" | FORWARDED_CONTENT_TYPE | ANNOUNCEMENT_BANNER_TYPE)
248 249 )
249 250 }),
250 251 unavailable: false,
@@ -4,6 +4,7 @@ use store::{
4 ChannelRecord, ChatRecord, MemberRecord, MessageImportance, MessageRecord, TeamRecord,
4 ChannelRecord, ChatRecord, MemberRecord, MessageImportance, MessageRecord, TeamRecord,
5};
5};
6
6
7use crate::announcement::ANNOUNCEMENT_BANNER_TYPE;
7use crate::adaptive_card::card_content_text;
8use crate::adaptive_card::card_content_text;
8use crate::call_event::CallEvent;
9use crate::call_event::CallEvent;
9use crate::forwarded::FORWARDED_CONTENT_TYPE;
10use crate::forwarded::FORWARDED_CONTENT_TYPE;
@@ -244,7 +245,7 @@ pub(crate) fn attachment_info(attachment: &Attachment) -> AttachmentInfo {
244 is_card
245 is_card
245 || matches!(
246 || matches!(
246 attachment.content_type.as_deref(),
247 attachment.content_type.as_deref(),
247 Some("messageReference" | FORWARDED_CONTENT_TYPE)
248 Some("messageReference" | FORWARDED_CONTENT_TYPE | ANNOUNCEMENT_BANNER_TYPE)
248 )
249 )
249 }),
250 }),
250 unavailable: false,
251 unavailable: false,
crates/core/src/stored.rs +1 −0
@@ -403,6 +403,7 @@ pub fn edit_preserved(record: &MessageRecord) -> EditPreserved {
403 403 content: attachment.content,
404 404 content_url: attachment.url,
405 405 name: attachment.name,
406 teams_app_id: attachment.teams_app_id,
406 407 });
407 408 }
408 409 }
@@ -403,6 +403,7 @@ pub fn edit_preserved(record: &MessageRecord) -> EditPreserved {
403 content: attachment.content,
403 content: attachment.content,
404 content_url: attachment.url,
404 content_url: attachment.url,
405 name: attachment.name,
405 name: attachment.name,
406 teams_app_id: attachment.teams_app_id,
406 });
407 });
407 }
408 }
408 }
409 }
crates/graph/src/outgoing.rs +8 −2
@@ -67,6 +67,7 @@ pub struct KeptAttachment {
67 67 pub content: Option<String>,
68 68 pub content_url: Option<String>,
69 69 pub name: Option<String>,
70 pub teams_app_id: Option<String>,
70 71 }
71 72
72 73 #[derive(Debug, Clone, Default, PartialEq, Eq)]
@@ -159,13 +160,17 @@ pub(crate) fn message_body(
159 160 }
160 161 if !extras.files.is_empty() || !extras.kept.is_empty() {
161 162 let kept = extras.kept.iter().map(|kept| {
162 json!({
163 let mut attachment = json!({
163 164 "id": kept.id,
164 165 "contentType": kept.content_type,
165 166 "content": kept.content,
166 167 "contentUrl": kept.content_url,
167 168 "name": kept.name,
168 })
169 });
170 if let Some(app_id) = &kept.teams_app_id {
171 attachment["teamsAppId"] = json!(app_id);
172 }
173 attachment
169 174 });
170 175 let files = extras.files.iter().map(|file| {
171 176 json!({
@@ -412,6 +417,7 @@ mod tests {
412 417 content: Some("{\"messageId\":\"Q1\"}".into()),
413 418 content_url: None,
414 419 name: None,
420 teams_app_id: None,
415 421 }],
416 422 importance: None,
417 423 };
@@ -67,6 +67,7 @@ pub struct KeptAttachment {
67 pub content: Option<String>,
67 pub content: Option<String>,
68 pub content_url: Option<String>,
68 pub content_url: Option<String>,
69 pub name: Option<String>,
69 pub name: Option<String>,
70 pub teams_app_id: Option<String>,
70}
71}
71
72
72#[derive(Debug, Clone, Default, PartialEq, Eq)]
73#[derive(Debug, Clone, Default, PartialEq, Eq)]
@@ -159,13 +160,17 @@ pub(crate) fn message_body(
159 }
160 }
160 if !extras.files.is_empty() || !extras.kept.is_empty() {
161 if !extras.files.is_empty() || !extras.kept.is_empty() {
161 let kept = extras.kept.iter().map(|kept| {
162 let kept = extras.kept.iter().map(|kept| {
162 json!({
163 let mut attachment = json!({
163 "id": kept.id,
164 "id": kept.id,
164 "contentType": kept.content_type,
165 "contentType": kept.content_type,
165 "content": kept.content,
166 "content": kept.content,
166 "contentUrl": kept.content_url,
167 "contentUrl": kept.content_url,
167 "name": kept.name,
168 "name": kept.name,
168 })
169 });
170 if let Some(app_id) = &kept.teams_app_id {
171 attachment["teamsAppId"] = json!(app_id);
172 }
173 attachment
169 });
174 });
170 let files = extras.files.iter().map(|file| {
175 let files = extras.files.iter().map(|file| {
171 json!({
176 json!({
@@ -412,6 +417,7 @@ mod tests {
412 content: Some("{\"messageId\":\"Q1\"}".into()),
417 content: Some("{\"messageId\":\"Q1\"}".into()),
413 content_url: None,
418 content_url: None,
414 name: None,
419 name: None,
420 teams_app_id: None,
415 }],
421 }],
416 importance: None,
422 importance: None,
417 };
423 };