BlueGit

ict rusty-teams

profiel: contactgegevens op de kaart kopiëren met een klik

Tekst selecteren kan niet in de contactkaart. Een klik op een
contactregel (mail, telefoon, kantoor) zet de waarde nu op het klembord
en meldt «Gekopieerd: …».

Fixes #6

hephaestus

Authored 2026-12-01 · 9 hours ago

Hash
ebb3c0e138e37b0655f5250bf8527613be5244a8
Parent
c46b33da
4 files changed +70 −2
KVT-FORK.md +8 −0
@@ -502,6 +502,14 @@ de app de Teams-link (`customTapAction`) in de browser. `teams_core::teams_link_
502 502 of `threadId` in `context`). Kent de app dat gesprek, dan opent het daar; anders nog steeds de browser.
503 503 Upstream aangeraakt: `crates/app/src/views/shell.rs` (`ActivityPanelEvent::Open`), `crates/core/src/lib.rs`.
504 504
505 ### Contactkaart: gegevens kopiëren — issue #6
506
507 Op de contactkaart kun je de tekst niet selecteren: de kaart blokkeert tekstselectie, zodat een klik
508 niet de chat erachter selecteert. Daarom is een contactregel (mail, telefoon, kantoor) nu klikbaar:
509 klikken kopieert de waarde naar het klembord en toont «Gekopieerd: …». Upstream aangeraakt:
510 `crates/app/src/views/profile_card.rs` (`contact_row`), `crates/app-state/src/profile_state.rs`
511 (`copy_profile_detail`). Teksten in `kvt.yml` (`kvt.profile.*`).
512
505 513 ## Eigen modules in het kort
506 514
507 515
@@ -502,6 +502,14 @@ de app de Teams-link (`customTapAction`) in de browser. `teams_core::teams_link_
502of `threadId` in `context`). Kent de app dat gesprek, dan opent het daar; anders nog steeds de browser.
502of `threadId` in `context`). Kent de app dat gesprek, dan opent het daar; anders nog steeds de browser.
503Upstream aangeraakt: `crates/app/src/views/shell.rs` (`ActivityPanelEvent::Open`), `crates/core/src/lib.rs`.
503Upstream aangeraakt: `crates/app/src/views/shell.rs` (`ActivityPanelEvent::Open`), `crates/core/src/lib.rs`.
504
504
505### Contactkaart: gegevens kopiëren — issue #6
506
507Op de contactkaart kun je de tekst niet selecteren: de kaart blokkeert tekstselectie, zodat een klik
508niet de chat erachter selecteert. Daarom is een contactregel (mail, telefoon, kantoor) nu klikbaar:
509klikken kopieert de waarde naar het klembord en toont «Gekopieerd: …». Upstream aangeraakt:
510`crates/app/src/views/profile_card.rs` (`contact_row`), `crates/app-state/src/profile_state.rs`
511(`copy_profile_detail`). Teksten in `kvt.yml` (`kvt.profile.*`).
512
505## Eigen modules in het kort
513## Eigen modules in het kort
506
514
507
515
crates/app-base/locales/kvt.yml +9 −0
@@ -516,3 +516,12 @@ kvt:
516 516 en: Closed
517 517 de: Erledigt
518 518 nl: Afgehandeld
519 profile:
520 copy:
521 en: Click to copy
522 de: Zum Kopieren klicken
523 nl: Klik om te kopiëren
524 copied:
525 en: "Copied: %{value}"
526 de: "Kopiert: %{value}"
527 nl: "Gekopieerd: %{value}"
@@ -516,3 +516,12 @@ kvt:
516 en: Closed
516 en: Closed
517 de: Erledigt
517 de: Erledigt
518 nl: Afgehandeld
518 nl: Afgehandeld
519 profile:
520 copy:
521 en: Click to copy
522 de: Zum Kopieren klicken
523 nl: Klik om te kopiëren
524 copied:
525 en: "Copied: %{value}"
526 de: "Kopiert: %{value}"
527 nl: "Gekopieerd: %{value}"
crates/app-state/src/profile_state.rs +39 −0
@@ -119,6 +119,13 @@ impl AppState {
119 119 self.raise_notice("Email copied".to_owned(), None, cx);
120 120 }
121 121
122 /// KVT issue #6: een regel van de contactkaart (mail, telefoon, kantoor) naar het klembord.
123 pub fn copy_profile_detail(&mut self, value: &str, cx: &mut Context<Self>) {
124 cx.write_to_clipboard(ClipboardItem::new_string(value.to_owned()));
125 let notice = app_base::ui_locale::tr("kvt.profile.copied").replace("%{value}", value);
126 self.raise_notice(notice, None, cx);
127 }
128
122 129 pub fn open_chat_with(&mut self, user_id: &str, cx: &mut Context<Self>) {
123 130 self.with_one_on_one(user_id, cx, |state, chat_id, cx| {
124 131 state.select(Selection::Chat(chat_id.to_owned()), cx)
@@ -182,3 +189,35 @@ impl AppState {
182 189 .detach();
183 190 }
184 191 }
192
193 #[cfg(test)]
194 mod tests {
195 use std::sync::Arc;
196
197 use gpui_kit::{AppContext as _, TestAppContext};
198 use store::Store;
199
200 use crate::app_state::{AppState, Mode};
201
202 #[gpui_kit::test]
203 fn a_contact_detail_lands_on_the_clipboard(cx: &mut TestAppContext) {
204 cx.update(gpui_kit::init);
205 let store = Arc::new(Store::open_in_memory().unwrap());
206 let app = cx.update(|cx| cx.new(|_| AppState::new(store, Mode::default())));
207 cx.update(|cx| {
208 app.update(cx, |state, cx| {
209 state.copy_profile_detail("ada@example.com", cx);
210 assert!(
211 state
212 .notice
213 .as_ref()
214 .unwrap()
215 .text
216 .contains("ada@example.com")
217 );
218 })
219 });
220 let copied = cx.read_from_clipboard().and_then(|item| item.text());
221 assert_eq!(copied.as_deref(), Some("ada@example.com"));
222 }
223 }
@@ -119,6 +119,13 @@ impl AppState {
119 self.raise_notice("Email copied".to_owned(), None, cx);
119 self.raise_notice("Email copied".to_owned(), None, cx);
120 }
120 }
121
121
122 /// KVT issue #6: een regel van de contactkaart (mail, telefoon, kantoor) naar het klembord.
123 pub fn copy_profile_detail(&mut self, value: &str, cx: &mut Context<Self>) {
124 cx.write_to_clipboard(ClipboardItem::new_string(value.to_owned()));
125 let notice = app_base::ui_locale::tr("kvt.profile.copied").replace("%{value}", value);
126 self.raise_notice(notice, None, cx);
127 }
128
122 pub fn open_chat_with(&mut self, user_id: &str, cx: &mut Context<Self>) {
129 pub fn open_chat_with(&mut self, user_id: &str, cx: &mut Context<Self>) {
123 self.with_one_on_one(user_id, cx, |state, chat_id, cx| {
130 self.with_one_on_one(user_id, cx, |state, chat_id, cx| {
124 state.select(Selection::Chat(chat_id.to_owned()), cx)
131 state.select(Selection::Chat(chat_id.to_owned()), cx)
@@ -182,3 +189,35 @@ impl AppState {
182 .detach();
189 .detach();
183 }
190 }
184}
191}
192
193#[cfg(test)]
194mod tests {
195 use std::sync::Arc;
196
197 use gpui_kit::{AppContext as _, TestAppContext};
198 use store::Store;
199
200 use crate::app_state::{AppState, Mode};
201
202 #[gpui_kit::test]
203 fn a_contact_detail_lands_on_the_clipboard(cx: &mut TestAppContext) {
204 cx.update(gpui_kit::init);
205 let store = Arc::new(Store::open_in_memory().unwrap());
206 let app = cx.update(|cx| cx.new(|_| AppState::new(store, Mode::default())));
207 cx.update(|cx| {
208 app.update(cx, |state, cx| {
209 state.copy_profile_detail("ada@example.com", cx);
210 assert!(
211 state
212 .notice
213 .as_ref()
214 .unwrap()
215 .text
216 .contains("ada@example.com")
217 );
218 })
219 });
220 let copied = cx.read_from_clipboard().and_then(|item| item.text());
221 assert_eq!(copied.as_deref(), Some("ada@example.com"));
222 }
223}
crates/app/src/views/profile_card.rs +14 −2
@@ -416,7 +416,13 @@ impl ProfileCard {
416 416 .gap(px(6.))
417 417 .child(self.section_header("profile-contact-header", "Contact", open, cx))
418 418 .when(open, |section| {
419 section.children(rows.into_iter().map(contact_row))
419 section.children(rows.into_iter().enumerate().map(|(index, row)| {
420 let value = row.value.clone();
421 let app = self.app.clone();
422 contact_row(index, row).on_click(move |_, _, cx| {
423 app.update(cx, |state, cx| state.copy_profile_detail(&value, cx));
424 })
425 }))
420 426 })
421 427 }
422 428
@@ -617,7 +623,8 @@ fn skeleton(width_ratio: f32) -> Div {
617 623 .bg(theme::popup_hover())
618 624 }
619 625
620 fn contact_row(row: ContactRow) -> Div {
626 /// Klikbaar: kopieert de waarde (KVT issue #6; tekst selecteren kan niet in de kaart).
627 fn contact_row(index: usize, row: ContactRow) -> Stateful<Div> {
621 628 let glyph = match row.kind {
622 629 ContactKind::Email => IconName::Mail,
623 630 ContactKind::WorkPhone => IconName::Phone,
@@ -625,9 +632,14 @@ fn contact_row(row: ContactRow) -> Div {
625 632 ContactKind::Office => IconName::MapPin,
626 633 };
627 634 h_flex()
635 .id(ElementId::Name(format!("profile-contact-{index}").into()))
628 636 .gap(px(8.))
629 637 .px(px(4.))
630 638 .items_center()
639 .rounded(px(6.))
640 .cursor_pointer()
641 .hover(|row| row.bg(theme::row_hover()))
642 .tooltip(|window, cx| Tooltip::new(crate::i18n::tr("kvt.profile.copy")).build(window, cx))
631 643 .child(icon(glyph, 14., theme::text_muted()))
632 644 .child(
633 645 div()
@@ -416,7 +416,13 @@ impl ProfileCard {
416 .gap(px(6.))
416 .gap(px(6.))
417 .child(self.section_header("profile-contact-header", "Contact", open, cx))
417 .child(self.section_header("profile-contact-header", "Contact", open, cx))
418 .when(open, |section| {
418 .when(open, |section| {
419 section.children(rows.into_iter().map(contact_row))
419 section.children(rows.into_iter().enumerate().map(|(index, row)| {
420 let value = row.value.clone();
421 let app = self.app.clone();
422 contact_row(index, row).on_click(move |_, _, cx| {
423 app.update(cx, |state, cx| state.copy_profile_detail(&value, cx));
424 })
425 }))
420 })
426 })
421 }
427 }
422
428
@@ -617,7 +623,8 @@ fn skeleton(width_ratio: f32) -> Div {
617 .bg(theme::popup_hover())
623 .bg(theme::popup_hover())
618}
624}
619
625
620fn contact_row(row: ContactRow) -> Div {
626/// Klikbaar: kopieert de waarde (KVT issue #6; tekst selecteren kan niet in de kaart).
627fn contact_row(index: usize, row: ContactRow) -> Stateful<Div> {
621 let glyph = match row.kind {
628 let glyph = match row.kind {
622 ContactKind::Email => IconName::Mail,
629 ContactKind::Email => IconName::Mail,
623 ContactKind::WorkPhone => IconName::Phone,
630 ContactKind::WorkPhone => IconName::Phone,
@@ -625,9 +632,14 @@ fn contact_row(row: ContactRow) -> Div {
625 ContactKind::Office => IconName::MapPin,
632 ContactKind::Office => IconName::MapPin,
626 };
633 };
627 h_flex()
634 h_flex()
635 .id(ElementId::Name(format!("profile-contact-{index}").into()))
628 .gap(px(8.))
636 .gap(px(8.))
629 .px(px(4.))
637 .px(px(4.))
630 .items_center()
638 .items_center()
639 .rounded(px(6.))
640 .cursor_pointer()
641 .hover(|row| row.bg(theme::row_hover()))
642 .tooltip(|window, cx| Tooltip::new(crate::i18n::tr("kvt.profile.copy")).build(window, cx))
631 .child(icon(glyph, 14., theme::text_muted()))
643 .child(icon(glyph, 14., theme::text_muted()))
632 .child(
644 .child(
633 div()
645 div()