From 815cf4464760c499b89f3b999a14fe72f11dff37 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 28 Sep 2022 09:10:01 -0600 Subject: [PATCH] Rename AddParticipantPopover to ContactsPopover Co-Authored-By: Antonio Scandurra --- .../src/collab_titlebar_item.rs | 42 +++++++++---------- ...icipant_popover.rs => contacts_popover.rs} | 26 ++++++------ crates/theme/src/theme.rs | 4 +- styles/src/styleTree/workspace.ts | 4 +- 4 files changed, 36 insertions(+), 40 deletions(-) rename crates/collab_titlebar_item/src/{add_participant_popover.rs => contacts_popover.rs} (97%) diff --git a/crates/collab_titlebar_item/src/collab_titlebar_item.rs b/crates/collab_titlebar_item/src/collab_titlebar_item.rs index e0ad25325190ed00c19393c371a26a4fe07b7385..c27a2b3452e08fe9828dd63235882ab73df43028 100644 --- a/crates/collab_titlebar_item/src/collab_titlebar_item.rs +++ b/crates/collab_titlebar_item/src/collab_titlebar_item.rs @@ -1,8 +1,8 @@ -mod add_participant_popover; +mod contacts_popover; -use add_participant_popover::AddParticipantPopover; use client::{Authenticate, PeerId}; use clock::ReplicaId; +use contacts_popover::ContactsPopover; use gpui::{ actions, color::Color, @@ -17,16 +17,16 @@ use std::{ops::Range, sync::Arc}; use theme::Theme; use workspace::{FollowNextCollaborator, ToggleFollow, Workspace}; -actions!(contacts_titlebar_item, [ToggleAddParticipantPopover]); +actions!(contacts_titlebar_item, [ToggleContactsPopover]); pub fn init(cx: &mut MutableAppContext) { - add_participant_popover::init(cx); - cx.add_action(CollabTitlebarItem::toggle_add_participant_popover); + contacts_popover::init(cx); + cx.add_action(CollabTitlebarItem::toggle_contacts_popover); } pub struct CollabTitlebarItem { workspace: WeakViewHandle, - add_participant_popover: Option>, + contacts_popover: Option>, _subscriptions: Vec, } @@ -61,34 +61,30 @@ impl CollabTitlebarItem { let observe_workspace = cx.observe(workspace, |_, _, cx| cx.notify()); Self { workspace: workspace.downgrade(), - add_participant_popover: None, + contacts_popover: None, _subscriptions: vec![observe_workspace], } } - fn toggle_add_participant_popover( - &mut self, - _: &ToggleAddParticipantPopover, - cx: &mut ViewContext, - ) { - match self.add_participant_popover.take() { + fn toggle_contacts_popover(&mut self, _: &ToggleContactsPopover, cx: &mut ViewContext) { + match self.contacts_popover.take() { Some(_) => {} None => { if let Some(workspace) = self.workspace.upgrade(cx) { let user_store = workspace.read(cx).user_store().clone(); - let view = cx.add_view(|cx| AddParticipantPopover::new(user_store, cx)); + let view = cx.add_view(|cx| ContactsPopover::new(user_store, cx)); cx.focus(&view); cx.subscribe(&view, |this, _, event, cx| { match event { - add_participant_popover::Event::Dismissed => { - this.add_participant_popover = None; + contacts_popover::Event::Dismissed => { + this.contacts_popover = None; } } cx.notify(); }) .detach(); - self.add_participant_popover = Some(view); + self.contacts_popover = Some(view); } } } @@ -110,10 +106,10 @@ impl CollabTitlebarItem { Some( Stack::new() .with_child( - MouseEventHandler::::new(0, cx, |state, _| { + MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar - .add_participant_button - .style_for(state, self.add_participant_popover.is_some()); + .toggle_contacts_button + .style_for(state, self.contacts_popover.is_some()); Svg::new("icons/plus_8.svg") .with_color(style.color) .constrained() @@ -128,18 +124,18 @@ impl CollabTitlebarItem { }) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, |_, cx| { - cx.dispatch_action(ToggleAddParticipantPopover); + cx.dispatch_action(ToggleContactsPopover); }) .aligned() .boxed(), ) - .with_children(self.add_participant_popover.as_ref().map(|popover| { + .with_children(self.contacts_popover.as_ref().map(|popover| { Overlay::new( ChildView::new(popover) .contained() .with_margin_top(titlebar.height) .with_margin_right( - -titlebar.add_participant_button.default.button_width, + -titlebar.toggle_contacts_button.default.button_width, ) .boxed(), ) diff --git a/crates/collab_titlebar_item/src/add_participant_popover.rs b/crates/collab_titlebar_item/src/contacts_popover.rs similarity index 97% rename from crates/collab_titlebar_item/src/add_participant_popover.rs rename to crates/collab_titlebar_item/src/contacts_popover.rs index b6fa8125f7566d5889c4f8651879d8b0891a1194..e44f6a23312577e80a2365abbddccf1ed31cf724 100644 --- a/crates/collab_titlebar_item/src/add_participant_popover.rs +++ b/crates/collab_titlebar_item/src/contacts_popover.rs @@ -15,11 +15,11 @@ use theme::IconButton; impl_internal_actions!(contacts_panel, [ToggleExpanded]); pub fn init(cx: &mut MutableAppContext) { - cx.add_action(AddParticipantPopover::clear_filter); - cx.add_action(AddParticipantPopover::select_next); - cx.add_action(AddParticipantPopover::select_prev); - cx.add_action(AddParticipantPopover::confirm); - cx.add_action(AddParticipantPopover::toggle_expanded); + cx.add_action(ContactsPopover::clear_filter); + cx.add_action(ContactsPopover::select_next); + cx.add_action(ContactsPopover::select_prev); + cx.add_action(ContactsPopover::confirm); + cx.add_action(ContactsPopover::toggle_expanded); } #[derive(Clone, PartialEq)] @@ -72,7 +72,7 @@ pub enum Event { Dismissed, } -pub struct AddParticipantPopover { +pub struct ContactsPopover { entries: Vec, match_candidates: Vec, list_state: ListState, @@ -83,7 +83,7 @@ pub struct AddParticipantPopover { _maintain_contacts: Subscription, } -impl AddParticipantPopover { +impl ContactsPopover { pub fn new(user_store: ModelHandle, cx: &mut ViewContext) -> Self { let filter_editor = cx.add_view(|cx| { let mut editor = Editor::single_line( @@ -555,13 +555,13 @@ impl AddParticipantPopover { } } -impl Entity for AddParticipantPopover { +impl Entity for ContactsPopover { type Event = Event; } -impl View for AddParticipantPopover { +impl View for ContactsPopover { fn ui_name() -> &'static str { - "AddParticipantPopover" + "ContactsPopover" } fn keymap_context(&self, _: &AppContext) -> keymap::Context { @@ -657,10 +657,10 @@ impl View for AddParticipantPopover { }), ) .contained() - .with_style(theme.workspace.titlebar.add_participant_popover.container) + .with_style(theme.workspace.titlebar.contacts_popover.container) .constrained() - .with_width(theme.workspace.titlebar.add_participant_popover.width) - .with_height(theme.workspace.titlebar.add_participant_popover.height) + .with_width(theme.workspace.titlebar.contacts_popover.width) + .with_height(theme.workspace.titlebar.contacts_popover.height) .boxed() } diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 4192bc0752c51ea3835b3a98631cb564a20b1672..28c8eb30917ac581b5d6e2b82c4f723959d29a63 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -73,8 +73,8 @@ pub struct Titlebar { pub avatar: ImageStyle, pub sign_in_prompt: Interactive, pub outdated_warning: ContainedText, - pub add_participant_button: Interactive, - pub add_participant_popover: AddParticipantPopover, + pub toggle_contacts_button: Interactive, + pub contacts_popover: AddParticipantPopover, } #[derive(Clone, Deserialize, Default)] diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 156ed62fbaef7c465eb6fdef6a2f9adcdd498ed9..8bd1e3800fe5ff50c02b46c65c437242ef412fcd 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -119,7 +119,7 @@ export default function workspace(theme: Theme) { }, cornerRadius: 6, }, - addParticipantButton: { + toggleContactsButton: { cornerRadius: 6, color: iconColor(theme, "secondary"), iconWidth: 8, @@ -133,7 +133,7 @@ export default function workspace(theme: Theme) { color: iconColor(theme, "active"), }, }, - addParticipantPopover: { + contactsPopover: { background: backgroundColor(theme, 300, "base"), cornerRadius: 6, padding: { top: 6 },