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 · 6 hours ago

Hash
4f71a8266891d334da9d7f8e04ab947d806cd33b
Parent
d8b55f5e
Pipeline
Passed
4 files changed +70 −2
KVT-FORK.md +8 −0
@@ -473,6 +473,14 @@ De optionele Graph-beta-route `teamwork/messaging/customEmojis` is niet gebruikt
473 473 | Eigen bestanden | — |
474 474 | Upstream aangeraakt | `crates/chatsvc/src/custom_emojis.rs`, `crates/core/src/org_emojis.rs`, `crates/core/src/remote.rs`, `crates/core/src/spans.rs`, `crates/app-state/src/org_emojis.rs`, `crates/app-state/src/demo.rs`, `crates/app-state/src/stored_outgoing.rs`, `crates/app-base/src/remote_image.rs`, `crates/app/src/views/fun_picker.rs`, `crates/app/src/views/reaction_picker.rs`, `crates/app/src/views/attachment_tray.rs`, `crates/app/src/views/composer.rs`, `crates/app-base/locales/app.yml` |
475 475
476 ### Contactkaart: gegevens kopiëren — issue #6
477
478 Op de contactkaart kun je de tekst niet selecteren: de kaart blokkeert tekstselectie, zodat een klik
479 niet de chat erachter selecteert. Daarom is een contactregel (mail, telefoon, kantoor) nu klikbaar:
480 klikken kopieert de waarde naar het klembord en toont «Gekopieerd: …». Upstream aangeraakt:
481 `crates/app/src/views/profile_card.rs` (`contact_row`), `crates/app-state/src/profile_state.rs`
482 (`copy_profile_detail`). Teksten in `kvt.yml` (`kvt.profile.*`).
483
476 484 ## Eigen modules in het kort
477 485
478 486
@@ -473,6 +473,14 @@ De optionele Graph-beta-route `teamwork/messaging/customEmojis` is niet gebruikt
473| Eigen bestanden | — |
473| Eigen bestanden | — |
474| Upstream aangeraakt | `crates/chatsvc/src/custom_emojis.rs`, `crates/core/src/org_emojis.rs`, `crates/core/src/remote.rs`, `crates/core/src/spans.rs`, `crates/app-state/src/org_emojis.rs`, `crates/app-state/src/demo.rs`, `crates/app-state/src/stored_outgoing.rs`, `crates/app-base/src/remote_image.rs`, `crates/app/src/views/fun_picker.rs`, `crates/app/src/views/reaction_picker.rs`, `crates/app/src/views/attachment_tray.rs`, `crates/app/src/views/composer.rs`, `crates/app-base/locales/app.yml` |
474| Upstream aangeraakt | `crates/chatsvc/src/custom_emojis.rs`, `crates/core/src/org_emojis.rs`, `crates/core/src/remote.rs`, `crates/core/src/spans.rs`, `crates/app-state/src/org_emojis.rs`, `crates/app-state/src/demo.rs`, `crates/app-state/src/stored_outgoing.rs`, `crates/app-base/src/remote_image.rs`, `crates/app/src/views/fun_picker.rs`, `crates/app/src/views/reaction_picker.rs`, `crates/app/src/views/attachment_tray.rs`, `crates/app/src/views/composer.rs`, `crates/app-base/locales/app.yml` |
475
475
476### Contactkaart: gegevens kopiëren — issue #6
477
478Op de contactkaart kun je de tekst niet selecteren: de kaart blokkeert tekstselectie, zodat een klik
479niet de chat erachter selecteert. Daarom is een contactregel (mail, telefoon, kantoor) nu klikbaar:
480klikken kopieert de waarde naar het klembord en toont «Gekopieerd: …». Upstream aangeraakt:
481`crates/app/src/views/profile_card.rs` (`contact_row`), `crates/app-state/src/profile_state.rs`
482(`copy_profile_detail`). Teksten in `kvt.yml` (`kvt.profile.*`).
483
476## Eigen modules in het kort
484## Eigen modules in het kort
477
485
478
486
crates/app-base/locales/kvt.yml +9 −0
@@ -512,3 +512,12 @@ kvt:
512 512 en: Closed
513 513 de: Erledigt
514 514 nl: Afgehandeld
515 profile:
516 copy:
517 en: Click to copy
518 de: Zum Kopieren klicken
519 nl: Klik om te kopiëren
520 copied:
521 en: "Copied: %{value}"
522 de: "Kopiert: %{value}"
523 nl: "Gekopieerd: %{value}"
@@ -512,3 +512,12 @@ kvt:
512 en: Closed
512 en: Closed
513 de: Erledigt
513 de: Erledigt
514 nl: Afgehandeld
514 nl: Afgehandeld
515 profile:
516 copy:
517 en: Click to copy
518 de: Zum Kopieren klicken
519 nl: Klik om te kopiëren
520 copied:
521 en: "Copied: %{value}"
522 de: "Kopiert: %{value}"
523 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()