BlueGit

ict rusty-teams

Files

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

profile_card.rs

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