BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / profile_card.rs

profile_card.rs

profile_card.rs 26.5 KiB Download Raw
1use std::sync::Arc;
2
3use chrono::Utc;
4use gpui_kit::component::scroll::ScrollableElement as _;
5use gpui_kit::assets::IconName;
6use gpui_kit::base::GlobalState;
7use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};
8use gpui_kit::prelude::FluentBuilder as _;
9use gpui_kit::*;
10use teams_core::{OrgPerson, PROFILE_LINK_PREFIX, PersonProfile, WorkLocationKind};
11
12use super::avatar::{person_avatar, with_presence};
13use super::new_chat::Pick;
14use super::new_meeting_dialog::open_new_meeting_with;
15use super::widgets::icon;
16use crate::app_state::{AppHandle, AppState};
17use crate::data::{Presence, PresenceKind, presence_kind_of};
18use crate::people::resolve_names;
19use crate::profile_model::{
20 ContactKind, ContactRow, StatusBox, contact_rows, has_organization, local_time_label,
21 mailto_url, status_box, status_line, work_location_label,
22};
23use crate::theme::{self, ElevatedSurface as _};
24use crate::presence_follow::{NOTIFY_WHEN_AVAILABLE, TURN_OFF_NOTIFICATIONS};
25
26const CARD_WIDTH: f32 = 340.;
27const CARD_RADIUS: f32 = 10.;
28const CARD_PADDING: f32 = 16.;
29const CARD_GAP: f32 = 12.;
30const CARD_MARGIN: f32 = 8.;
31const CLICK_OFFSET: f32 = 4.;
32const PHOTO_SIZE: f32 = 56.;
33const PERSON_ROW_AVATAR: f32 = 22.;
34const STATUS_LINES: usize = 3;
35const REPORTS_MAX_HEIGHT: f32 = 168.;
36const ACTION_HEIGHT: f32 = 30.;
37const SKELETON_HEIGHT: f32 = 10.;
38const SCHEDULE_MEETING: &str = "Schedule meeting";
39const EMAIL: &str = "Email";
40const COPY_EMAIL: &str = "Copy email";
41
42pub enum ProfileCardEvent {
43 Close,
44}
45
46pub struct ProfileCard {
47 app: Entity<AppState>,
48 user_id: String,
49 history: Vec<String>,
50 anchor: Point<Pixels>,
51 contact_open: bool,
52 organization_open: bool,
53 reports_open: bool,
54 focus_handle: FocusHandle,
55 _observation: Subscription,
56}
57
58impl EventEmitter<ProfileCardEvent> for ProfileCard {}
59
60pub fn open_profile(user_id: &str, position: Point<Pixels>, cx: &mut App) {
61 let Some(handle) = cx.try_global::<AppHandle>() else {
62 return;
63 };
64 let (app, user_id) = (handle.0.clone(), user_id.to_owned());
65 app.update(cx, |state, cx| {
66 state.open_profile_card(&user_id, position, cx)
67 });
68}
69
70/// `true` when the link was a profile link and has been handled.
71pub fn open_profile_link(url: &str, position: Point<Pixels>, cx: &mut App) -> bool {
72 match url.strip_prefix(PROFILE_LINK_PREFIX) {
73 Some(user_id) => {
74 open_profile(user_id, position, cx);
75 true
76 }
77 None => false,
78 }
79}
80
81pub fn opens_profile(element: Stateful<Div>, user_id: Option<&str>) -> Stateful<Div> {
82 match user_id {
83 Some(user_id) => {
84 let user_id = user_id.to_owned();
85 element.cursor_pointer().on_click(move |event, _, cx| {
86 cx.stop_propagation();
87 open_profile(&user_id, event.position(), cx)
88 })
89 }
90 None => element,
91 }
92}
93
94impl ProfileCard {
95 pub fn new(
96 app: Entity<AppState>,
97 user_id: String,
98 anchor: Point<Pixels>,
99 window: &mut Window,
100 cx: &mut Context<Self>,
101 ) -> Self {
102 let focus_handle = cx.focus_handle();
103 window.focus(&focus_handle, cx);
104 let observation = cx.observe(&app, |_, _, cx| cx.notify());
105 ProfileCard {
106 app,
107 user_id,
108 history: Vec::new(),
109 anchor,
110 contact_open: true,
111 organization_open: true,
112 reports_open: false,
113 focus_handle,
114 _observation: observation,
115 }
116 }
117
118 pub fn move_to(&mut self, user_id: String, anchor: Point<Pixels>, cx: &mut Context<Self>) {
119 self.history.clear();
120 self.anchor = anchor;
121 self.show(user_id, false, cx);
122 }
123
124 fn show(&mut self, user_id: String, remember: bool, cx: &mut Context<Self>) {
125 if remember {
126 self.history
127 .push(std::mem::replace(&mut self.user_id, user_id));
128 } else {
129 self.user_id = user_id;
130 }
131 self.reports_open = false;
132 let id = self.user_id.clone();
133 self.app.update(cx, |state, cx| {
134 state.request_profile(&id, false, cx);
135 state.request_avatars(vec![id.clone()], cx);
136 });
137 cx.notify();
138 }
139
140 fn go_back(&mut self, cx: &mut Context<Self>) {
141 if let Some(previous) = self.history.pop() {
142 self.show(previous, false, cx);
143 }
144 }
145
146 fn on_key_down(&mut self, event: &KeyDownEvent, _: &mut Window, cx: &mut Context<Self>) {
147 if event.keystroke.key == "escape" {
148 cx.emit(ProfileCardEvent::Close);
149 }
150 }
151
152 fn display_name(&self, profile: Option<&PersonProfile>, cx: &App) -> String {
153 profile
154 .and_then(|profile| profile.display_name.clone())
155 .or_else(|| {
156 resolve_names(self.app.read(cx), std::slice::from_ref(&self.user_id))
157 .remove(&self.user_id)
158 })
159 .unwrap_or_else(|| "Unknown person".to_owned())
160 }
161
162 fn presence(&self, profile: Option<&PersonProfile>, cx: &App) -> Presence {
163 let directory = self.app.read(cx).directory.presence_of(&self.user_id);
164 match (directory, profile.and_then(|profile| profile.availability)) {
165 (Presence::Live(kind), _) if kind != PresenceKind::Unknown => directory,
166 (_, Some(availability)) => Presence::Live(presence_kind_of(availability)),
167 _ => directory,
168 }
169 }
170
171 fn header(&self, profile: Option<&PersonProfile>, failed: bool, cx: &App) -> Div {
172 let name = self.display_name(profile, cx);
173 let presence = self.presence(profile, cx);
174 let directory = &self.app.read(cx).directory;
175 let photo = with_presence(
176 person_avatar(directory, Some(&self.user_id), &name, PHOTO_SIZE),
177 presence,
178 PHOTO_SIZE,
179 theme::surface_raised(),
180 );
181 let availability = directory.status_label(&self.user_id, presence);
182 let local_time = profile.and_then(|profile| local_time_label(profile, Utc::now()));
183 let subline = status_line(availability, local_time.as_deref());
184 let details = v_flex()
185 .gap(px(1.))
186 .children(profile.into_iter().flat_map(|profile| {
187 [&profile.job_title, &profile.department]
188 .into_iter()
189 .flatten()
190 .filter(|text| !text.trim().is_empty())
191 .map(|text| muted_line(text.clone()))
192 .collect::<Vec<_>>()
193 }));
194 let work_location = profile
195 .and_then(|profile| profile.work_location)
196 .map(|location| {
197 let glyph = match location.kind {
198 WorkLocationKind::Office => IconName::Building2,
199 WorkLocationKind::Remote => IconName::House,
200 };
201 h_flex()
202 .gap(px(5.))
203 .items_center()
204 .child(icon(glyph, 13., theme::text_muted()))
205 .child(muted_line(work_location_label(location).to_owned()))
206 });
207 let loading = profile.is_none() && !failed;
208 h_flex().gap(px(12.)).items_center().child(photo).child(
209 v_flex()
210 .flex_1()
211 .min_w_0()
212 .gap(px(2.))
213 .child(
214 div()
215 .truncate()
216 .text_size(px(15.))
217 .font_weight(FontWeight::SEMIBOLD)
218 .text_color(theme::text())
219 .child(name),
220 )
221 .when(!subline.is_empty(), |column| {
222 column.child(muted_line(subline))
223 })
224 .children(work_location)
225 .child(details)
226 .when(loading, |column| column.child(skeleton(0.6))),
227 )
228 }
229
230 fn status_box(&self, status: &StatusBox) -> AnyElement {
231 let (background, foreground) = if status.out_of_office {
232 (theme::amber().opacity(0.12), theme::amber())
233 } else {
234 (theme::surface(), theme::text_soft())
235 };
236 let full_text = status.text.clone();
237 div()
238 .id("profile-status")
239 .w_full()
240 .px(px(10.))
241 .py(px(8.))
242 .rounded(px(6.))
243 .bg(background)
244 .text_color(foreground)
245 .text_size(px(12.))
246 .line_height(relative(1.4))
247 .child(
248 div()
249 .line_clamp(STATUS_LINES)
250 .text_ellipsis()
251 .child(status.text.clone()),
252 )
253 .tooltip(move |window, cx| Tooltip::new(full_text.clone()).build(window, cx))
254 .into_any_element()
255 }
256
257 fn actions(&self, email: Option<String>, cx: &mut Context<Self>) -> Div {
258 let is_me = self
259 .app
260 .read(cx)
261 .directory
262 .me
263 .as_ref()
264 .is_some_and(|me| me.user_id == self.user_id);
265 let profile = self
266 .app
267 .read(cx)
268 .profiles
269 .get(&self.user_id)
270 .and_then(|entry| entry.profile.clone());
271 let name = self.display_name(profile.as_deref(), cx);
272 let user_id = self.user_id.clone();
273 let (mail_email, copy_email) = (email.clone(), email.clone());
274 let invitee = Pick {
275 user_id: user_id.clone(),
276 name: name.clone(),
277 mail: email,
278 };
279 let chat_id = user_id.clone();
280 let (video_id, audio_id) = (user_id.clone(), user_id.clone());
281 let followed = self.app.read(cx).is_presence_followed(&user_id);
282 let (follow_id, follow_name) = (user_id.clone(), name.clone());
283 h_flex()
284 .gap(px(8.))
285 .when(!is_me, |row| {
286 row.child(
287 action_button("profile-chat", "Chat", IconName::MessageSquare, true).on_click(
288 cx.listener(move |this, _, _, cx| {
289 let user_id = chat_id.clone();
290 this.app
291 .update(cx, |state, cx| state.open_chat_with(&user_id, cx));
292 cx.emit(ProfileCardEvent::Close);
293 }),
294 ),
295 )
296 .child(
297 icon_action(
298 "profile-video-call",
299 IconName::Video,
300 video_call_tooltip(&name),
301 )
302 .on_click(cx.listener(move |this, _, _, cx| {
303 let user_id = video_id.clone();
304 this.app
305 .update(cx, |state, cx| state.call_person(&user_id, true, cx));
306 cx.emit(ProfileCardEvent::Close);
307 })),
308 )
309 .child(
310 icon_action(
311 "profile-audio-call",
312 IconName::Phone,
313 audio_call_tooltip(&name),
314 )
315 .on_click(cx.listener(move |this, _, _, cx| {
316 let user_id = audio_id.clone();
317 this.app
318 .update(cx, |state, cx| state.call_person(&user_id, false, cx));
319 cx.emit(ProfileCardEvent::Close);
320 })),
321 )
322 .child(
323 icon_action(
324 "profile-schedule-meeting",
325 IconName::Calendar,
326 SCHEDULE_MEETING.to_owned(),
327 )
328 .on_click(cx.listener(move |this, _, window, cx| {
329 open_new_meeting_with(this.app.clone(), vec![invitee.clone()], window, cx);
330 cx.emit(ProfileCardEvent::Close);
331 })),
332 )
333 .child(
334 icon_action(
335 "profile-follow-presence",
336 if followed {
337 IconName::BellOff
338 } else {
339 IconName::BellRing
340 },
341 if followed {
342 TURN_OFF_NOTIFICATIONS
343 } else {
344 NOTIFY_WHEN_AVAILABLE
345 }
346 .to_owned(),
347 )
348 .on_click(cx.listener(move |this, _, _, cx| {
349 let (user_id, name) = (follow_id.clone(), follow_name.clone());
350 this.app.update(cx, |state, cx| {
351 state.set_presence_followed(&user_id, &name, !followed, cx)
352 });
353 })),
354 )
355 })
356 .when_some(mail_email, |row, address| {
357 row.child(
358 icon_action("profile-email", IconName::Mail, EMAIL.to_owned()).on_click(
359 cx.listener(move |_, _, _, cx| {
360 cx.open_url(&mailto_url(&address));
361 cx.emit(ProfileCardEvent::Close);
362 }),
363 ),
364 )
365 })
366 .when_some(copy_email, |row, address| {
367 row.child(
368 icon_action("profile-copy-email", IconName::Copy, COPY_EMAIL.to_owned())
369 .on_click(cx.listener(move |this, _, _, cx| {
370 this.app
371 .update(cx, |state, cx| state.copy_profile_email(&address, cx));
372 cx.emit(ProfileCardEvent::Close);
373 })),
374 )
375 })
376 }
377
378 fn section_header(
379 &self,
380 id: &'static str,
381 label: &'static str,
382 open: bool,
383 cx: &mut Context<Self>,
384 ) -> Stateful<Div> {
385 h_flex()
386 .id(id)
387 .gap(px(4.))
388 .items_center()
389 .cursor_pointer()
390 .text_size(px(12.))
391 .font_weight(FontWeight::SEMIBOLD)
392 .text_color(theme::text_muted())
393 .child(icon(
394 if open {
395 IconName::ChevronDown
396 } else {
397 IconName::ChevronRight
398 },
399 14.,
400 theme::text_muted(),
401 ))
402 .child(label)
403 .on_click(cx.listener(move |this, _, _, cx| {
404 match id {
405 "profile-contact-header" => this.contact_open = !this.contact_open,
406 _ => this.organization_open = !this.organization_open,
407 }
408 cx.notify();
409 }))
410 }
411
412 fn contact_section(&self, rows: Vec<ContactRow>, cx: &mut Context<Self>) -> Div {
413 let open = self.contact_open;
414 v_flex()
415 .gap(px(6.))
416 .child(self.section_header("profile-contact-header", "Contact", open, cx))
417 .when(open, |section| {
418 section.children(rows.into_iter().map(contact_row))
419 })
420 }
421
422 fn person_row(
423 &self,
424 id: String,
425 person: &OrgPerson,
426 caption: Option<&'static str>,
427 cx: &mut Context<Self>,
428 ) -> Stateful<Div> {
429 let name = person.display_name.clone().unwrap_or_default();
430 let subtitle = caption
431 .map(str::to_owned)
432 .or_else(|| person.job_title.clone())
433 .filter(|text| !text.is_empty());
434 let target = person.id.clone();
435 let directory = &self.app.read(cx).directory;
436 h_flex()
437 .id(ElementId::Name(id.into()))
438 .gap(px(8.))
439 .px(px(4.))
440 .py(px(3.))
441 .items_center()
442 .rounded(px(6.))
443 .cursor_pointer()
444 .hover(|row| row.bg(theme::row_hover()))
445 .child(person_avatar(
446 directory,
447 Some(&person.id),
448 &name,
449 PERSON_ROW_AVATAR,
450 ))
451 .child(
452 div()
453 .truncate()
454 .text_size(px(12.5))
455 .text_color(theme::text())
456 .child(name),
457 )
458 .children(
459 subtitle.map(|text| div().flex_1().min_w_0().truncate().child(muted_text(text))),
460 )
461 .on_click(cx.listener(move |this, _, _, cx| this.show(target.clone(), true, cx)))
462 }
463
464 fn organization_section(&self, profile: &PersonProfile, cx: &mut Context<Self>) -> Div {
465 let open = self.organization_open;
466 let mut section = v_flex().gap(px(4.)).child(self.section_header(
467 "profile-organization-header",
468 "Organization",
469 open,
470 cx,
471 ));
472 if !open {
473 return section;
474 }
475 if let Some(manager) = &profile.manager {
476 section = section.child(self.person_row(
477 "profile-manager".to_owned(),
478 manager,
479 Some("Manager"),
480 cx,
481 ));
482 }
483 let count = profile.direct_reports.len();
484 if count > 0 {
485 let label = match count {
486 1 => "1 direct report".to_owned(),
487 count => format!("{count} direct reports"),
488 };
489 let reports_open = self.reports_open;
490 section = section.child(
491 h_flex()
492 .id("profile-reports-toggle")
493 .gap(px(4.))
494 .px(px(4.))
495 .py(px(3.))
496 .items_center()
497 .cursor_pointer()
498 .text_size(px(12.5))
499 .text_color(theme::text_soft())
500 .child(label)
501 .child(icon(
502 if reports_open {
503 IconName::ChevronDown
504 } else {
505 IconName::ChevronRight
506 },
507 14.,
508 theme::text_muted(),
509 ))
510 .on_click(cx.listener(|this, _, _, cx| {
511 this.reports_open = !this.reports_open;
512 cx.notify();
513 })),
514 );
515 if reports_open {
516 let rows: Vec<Stateful<Div>> = profile
517 .direct_reports
518 .iter()
519 .enumerate()
520 .map(|(index, person)| {
521 self.person_row(format!("profile-report-{index}"), person, None, cx)
522 })
523 .collect();
524 section = section.child(
525 v_flex()
526 .id("profile-reports")
527 .max_h(px(REPORTS_MAX_HEIGHT))
528 .overflow_y_scrollbar()
529 .children(rows),
530 );
531 }
532 }
533 section
534 }
535
536 fn loading_sections(&self) -> Div {
537 v_flex()
538 .gap(px(8.))
539 .child(skeleton(1.))
540 .child(skeleton(0.8))
541 .child(skeleton(0.5))
542 }
543
544 fn failure(&self, cx: &mut Context<Self>) -> Div {
545 h_flex()
546 .gap(px(6.))
547 .text_size(px(12.))
548 .text_color(theme::red_soft())
549 .child("Profile details could not be loaded.")
550 .child(
551 div()
552 .id("profile-retry")
553 .cursor_pointer()
554 .underline()
555 .text_color(theme::red_tint())
556 .child("Retry")
557 .on_click(cx.listener(|this, _, _, cx| {
558 let id = this.user_id.clone();
559 this.app
560 .update(cx, |state, cx| state.request_profile(&id, true, cx));
561 })),
562 )
563 }
564
565 fn body(&self, entry_state: EntryState, cx: &mut Context<Self>) -> Vec<AnyElement> {
566 let EntryState { profile, failed } = entry_state;
567 let mut parts: Vec<AnyElement> = Vec::new();
568 let Some(profile) = profile else {
569 parts.push(self.actions(None, cx).into_any_element());
570 parts.push(if failed {
571 self.failure(cx).into_any_element()
572 } else {
573 self.loading_sections().into_any_element()
574 });
575 return parts;
576 };
577 if let Some(status) = status_box(&profile) {
578 parts.push(self.status_box(&status));
579 }
580 parts.push(self.actions(profile.email.clone(), cx).into_any_element());
581 let rows = contact_rows(&profile);
582 if !rows.is_empty() {
583 parts.push(self.contact_section(rows, cx).into_any_element());
584 }
585 if has_organization(&profile) {
586 parts.push(self.organization_section(&profile, cx).into_any_element());
587 }
588 if failed {
589 parts.push(self.failure(cx).into_any_element());
590 }
591 parts
592 }
593}
594
595struct EntryState {
596 profile: Option<Arc<PersonProfile>>,
597 failed: bool,
598}
599
600fn muted_text(text: String) -> Div {
601 div()
602 .text_size(px(12.))
603 .text_color(theme::text_muted())
604 .child(text)
605}
606
607fn muted_line(text: String) -> Div {
608 muted_text(text).truncate()
609}
610
611fn skeleton(width_ratio: f32) -> Div {
612 div()
613 .h(px(SKELETON_HEIGHT))
614 .w(relative(width_ratio))
615 .rounded(px(4.))
616 .bg(theme::popup_hover())
617}
618
619fn contact_row(row: ContactRow) -> Div {
620 let glyph = match row.kind {
621 ContactKind::Email => IconName::Mail,
622 ContactKind::WorkPhone => IconName::Phone,
623 ContactKind::MobilePhone => IconName::Smartphone,
624 ContactKind::Office => IconName::MapPin,
625 };
626 h_flex()
627 .gap(px(8.))
628 .px(px(4.))
629 .items_center()
630 .child(icon(glyph, 14., theme::text_muted()))
631 .child(
632 div()
633 .flex_1()
634 .min_w_0()
635 .truncate()
636 .text_size(px(12.5))
637 .text_color(theme::text())
638 .child(row.value),
639 )
640}
641
642pub fn video_call_tooltip(name: &str) -> String {
643 format!("Start a video call with {name}")
644}
645
646pub fn audio_call_tooltip(name: &str) -> String {
647 format!("Start an audio call with {name}")
648}
649
650fn icon_action(id: &'static str, glyph: IconName, tooltip: String) -> Stateful<Div> {
651 div()
652 .id(id)
653 .size(px(ACTION_HEIGHT))
654 .flex()
655 .flex_none()
656 .items_center()
657 .justify_center()
658 .rounded(px(6.))
659 .cursor_pointer()
660 .bg(theme::popup_hover())
661 .hover(|button| button.opacity(0.9))
662 .child(icon(glyph, 14., theme::text_soft()))
663 .tooltip(move |window, cx| Tooltip::new(tooltip.clone()).build(window, cx))
664}
665
666fn action_button(
667 id: &'static str,
668 label: &'static str,
669 glyph: IconName,
670 filled: bool,
671) -> Stateful<Div> {
672 let (foreground, background) = if filled {
673 (theme::on_accent(), theme::accent())
674 } else {
675 (theme::text_soft(), theme::popup_hover())
676 };
677 h_flex()
678 .id(id)
679 .h(px(ACTION_HEIGHT))
680 .px(px(10.))
681 .gap(px(6.))
682 .items_center()
683 .justify_center()
684 .rounded(px(6.))
685 .cursor_pointer()
686 .bg(background)
687 .text_color(foreground)
688 .text_size(px(12.5))
689 .font_weight(FontWeight::SEMIBOLD)
690 .hover(|button| button.opacity(0.9))
691 .child(icon(glyph, 14., foreground))
692 .child(label)
693}
694
695impl Render for ProfileCard {
696 fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
697 let entry_state = self
698 .app
699 .read(cx)
700 .profiles
701 .get(&self.user_id)
702 .map(|entry| EntryState {
703 profile: entry.profile.clone(),
704 failed: entry.failed,
705 })
706 .unwrap_or(EntryState {
707 profile: None,
708 failed: false,
709 });
710 let profile = entry_state.profile.clone();
711 let header = self.header(profile.as_deref(), entry_state.failed, cx);
712 let body = self.body(entry_state, cx);
713 let back = (!self.history.is_empty()).then(|| {
714 h_flex()
715 .id("profile-back")
716 .gap(px(4.))
717 .items_center()
718 .cursor_pointer()
719 .text_size(px(12.))
720 .text_color(theme::text_muted())
721 .hover(|button| button.text_color(theme::text()))
722 .child(icon(IconName::ArrowLeft, 14., theme::text_muted()))
723 .child("Back")
724 .on_click(cx.listener(|this, _, _, cx| this.go_back(cx)))
725 });
726 let card = v_flex()
727 .id("profile-card")
728 .track_focus(&self.focus_handle)
729 .w(px(CARD_WIDTH))
730 .p(px(CARD_PADDING))
731 .gap(px(CARD_GAP))
732 .rounded(px(CARD_RADIUS))
733 .flyout_surface()
734 .text_color(theme::text())
735 .occlude()
736 .on_key_down(cx.listener(Self::on_key_down))
737 .on_mouse_down(MouseButton::Left, |_, _, cx| {
738 GlobalState::suppress_text_selection(cx);
739 cx.stop_propagation();
740 })
741 .on_mouse_down(MouseButton::Right, |_, _, cx| cx.stop_propagation())
742 .children(back)
743 .child(header)
744 .children(body);
745 let offset = point(px(CLICK_OFFSET), px(CLICK_OFFSET));
746 div()
747 .id("profile-layer")
748 .absolute()
749 .top_0()
750 .left_0()
751 .size_full()
752 .occlude()
753 .on_mouse_down(
754 MouseButton::Left,
755 cx.listener(|_, _, _, cx| cx.emit(ProfileCardEvent::Close)),
756 )
757 .on_mouse_down(
758 MouseButton::Right,
759 cx.listener(|_, _, _, cx| cx.emit(ProfileCardEvent::Close)),
760 )
761 .child(
762 deferred(
763 anchored()
764 .position(self.anchor + offset)
765 .anchor(Anchor::TopLeft)
766 .snap_to_window_with_margin(px(CARD_MARGIN))
767 .child(card),
768 )
769 .with_priority(2),
770 )
771 }
772}
773
774#[cfg(test)]
775mod tests {
776 use super::{audio_call_tooltip, video_call_tooltip};
777
778 #[test]
779 fn call_tooltips_use_the_teams_wording() {
780 assert_eq!(video_call_tooltip("Ann"), "Start a video call with Ann");
781 assert_eq!(audio_call_tooltip("Ann"), "Start an audio call with Ann");
782 }
783}