BlueGit

ict rusty-teams

feat(teams): native Manage team page with the member list

- team menu > Manage team opens a page in the main island: Owners and Members and guests, collapsible, with search by name or email
- members come from the General channel's member list (Graph roles mark owners)
- read-only; deviation from Teams: an "Open in browser" button in the header for changes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-12 · 2 weeks ago

Hash
a87753e4829a28bdcd0a6e679f8972b647f9db56
Parent
af3b0c0e
14 files changed +541 −3
crates/app-state/src/app_state.rs +4 −1
@@ -152,6 +152,7 @@ pub struct AppState {
152 152 pub(crate) warm_chats: crate::warm_chats::WarmChats,
153 153 pub local_previews: HashMap<String, LocalPreview>,
154 154 pub quick_view: Option<QuickView>,
155 pub manage_team: Option<crate::manage_team::ManageTeam>,
155 156 pub scheduled: Vec<ScheduledDraft>,
156 157 pub scheduled_polling: bool,
157 158 pub saved: SavedSet,
@@ -311,6 +312,7 @@ impl AppState {
311 312 warm_chats: Default::default(),
312 313 local_previews: HashMap::new(),
313 314 quick_view: None,
315 manage_team: None,
314 316 scheduled: Vec::new(),
315 317 scheduled_polling: false,
316 318 saved: SavedSet::default(),
@@ -982,8 +984,9 @@ impl AppState {
982 984 self.call_end = None;
983 985 let was_drafting = std::mem::take(&mut self.new_chat);
984 986 let left_quick_view = self.quick_view.take().is_some();
987 let left_manage_team = self.manage_team.take().is_some();
985 988 if !was_drafting && self.selection.as_ref() == Some(&selection) {
986 if left_quick_view {
989 if left_quick_view || left_manage_team {
987 990 cx.emit(AppEvent::Sidebar);
988 991 cx.notify();
989 992 }
@@ -152,6 +152,7 @@ pub struct AppState {
152 pub(crate) warm_chats: crate::warm_chats::WarmChats,
152 pub(crate) warm_chats: crate::warm_chats::WarmChats,
153 pub local_previews: HashMap<String, LocalPreview>,
153 pub local_previews: HashMap<String, LocalPreview>,
154 pub quick_view: Option<QuickView>,
154 pub quick_view: Option<QuickView>,
155 pub manage_team: Option<crate::manage_team::ManageTeam>,
155 pub scheduled: Vec<ScheduledDraft>,
156 pub scheduled: Vec<ScheduledDraft>,
156 pub scheduled_polling: bool,
157 pub scheduled_polling: bool,
157 pub saved: SavedSet,
158 pub saved: SavedSet,
@@ -311,6 +312,7 @@ impl AppState {
311 warm_chats: Default::default(),
312 warm_chats: Default::default(),
312 local_previews: HashMap::new(),
313 local_previews: HashMap::new(),
313 quick_view: None,
314 quick_view: None,
315 manage_team: None,
314 scheduled: Vec::new(),
316 scheduled: Vec::new(),
315 scheduled_polling: false,
317 scheduled_polling: false,
316 saved: SavedSet::default(),
318 saved: SavedSet::default(),
@@ -982,8 +984,9 @@ impl AppState {
982 self.call_end = None;
984 self.call_end = None;
983 let was_drafting = std::mem::take(&mut self.new_chat);
985 let was_drafting = std::mem::take(&mut self.new_chat);
984 let left_quick_view = self.quick_view.take().is_some();
986 let left_quick_view = self.quick_view.take().is_some();
987 let left_manage_team = self.manage_team.take().is_some();
985 if !was_drafting && self.selection.as_ref() == Some(&selection) {
988 if !was_drafting && self.selection.as_ref() == Some(&selection) {
986 if left_quick_view {
989 if left_quick_view || left_manage_team {
987 cx.emit(AppEvent::Sidebar);
990 cx.emit(AppEvent::Sidebar);
988 cx.notify();
991 cx.notify();
989 }
992 }
crates/app-state/src/demo.rs +13 −0
@@ -2431,6 +2431,19 @@ fn encode_rgb(width: usize, height: usize, pixel: impl Fn(usize, usize) -> [u8;
2431 2431 png
2432 2432 }
2433 2433
2434 pub fn team_members() -> Vec<crate::manage_team::TeamMember> {
2435 std::iter::once((DEMO_USER_ID, DEMO_USER_NAME, DEMO_USER_EMAIL))
2436 .chain(PEOPLE_DIRECTORY.iter().map(|(user_id, name, _, email)| (*user_id, *name, *email)))
2437 .enumerate()
2438 .map(|(index, (user_id, name, email))| crate::manage_team::TeamMember {
2439 user_id: Some(user_id.to_owned()),
2440 name: name.to_owned(),
2441 email: Some(email.to_owned()),
2442 owner: index == 1 || index == 3,
2443 })
2444 .collect()
2445 }
2446
2434 2447 #[cfg(test)]
2435 2448 mod tests {
2436 2449 use super::*;
@@ -2431,6 +2431,19 @@ fn encode_rgb(width: usize, height: usize, pixel: impl Fn(usize, usize) -> [u8;
2431 png
2431 png
2432}
2432}
2433
2433
2434pub fn team_members() -> Vec<crate::manage_team::TeamMember> {
2435 std::iter::once((DEMO_USER_ID, DEMO_USER_NAME, DEMO_USER_EMAIL))
2436 .chain(PEOPLE_DIRECTORY.iter().map(|(user_id, name, _, email)| (*user_id, *name, *email)))
2437 .enumerate()
2438 .map(|(index, (user_id, name, email))| crate::manage_team::TeamMember {
2439 user_id: Some(user_id.to_owned()),
2440 name: name.to_owned(),
2441 email: Some(email.to_owned()),
2442 owner: index == 1 || index == 3,
2443 })
2444 .collect()
2445}
2446
2434#[cfg(test)]
2447#[cfg(test)]
2435mod tests {
2448mod tests {
2436 use super::*;
2449 use super::*;
crates/app-state/src/lib.rs +1 −0
@@ -31,6 +31,7 @@ pub mod gifs;
31 31 pub mod image_view_gallery;
32 32 pub mod importance;
33 33 pub mod local_previews;
34 pub mod manage_team;
34 35 pub mod message_actions;
35 36 pub mod notice;
36 37 pub mod notify;
@@ -31,6 +31,7 @@ pub mod gifs;
31pub mod image_view_gallery;
31pub mod image_view_gallery;
32pub mod importance;
32pub mod importance;
33pub mod local_previews;
33pub mod local_previews;
34pub mod manage_team;
34pub mod message_actions;
35pub mod message_actions;
35pub mod notice;
36pub mod notice;
36pub mod notify;
37pub mod notify;
crates/app-state/src/manage_team.rs added +185 −0
@@ -0,0 +1,185 @@
1 use std::cmp::Ordering;
2
3 use gpui_kit::*;
4
5 use crate::app_state::{AppEvent, AppState};
6 use crate::runtime;
7
8 #[derive(Debug, Clone, PartialEq, Eq)]
9 pub struct TeamMember {
10 pub user_id: Option<String>,
11 pub name: String,
12 pub email: Option<String>,
13 pub owner: bool,
14 }
15
16 #[derive(Debug, Clone, PartialEq, Eq)]
17 pub enum MembersLoad {
18 Loading,
19 Loaded(Vec<TeamMember>),
20 Failed(String),
21 }
22
23 #[derive(Debug, Clone, PartialEq, Eq)]
24 pub struct ManageTeam {
25 pub team_id: String,
26 pub team_name: String,
27 pub members: MembersLoad,
28 }
29
30 #[derive(Debug, Default, PartialEq, Eq)]
31 pub struct MemberGroups<'a> {
32 pub owners: Vec<&'a TeamMember>,
33 pub others: Vec<&'a TeamMember>,
34 }
35
36 pub fn member_groups<'a>(members: &'a [TeamMember], query: &str) -> MemberGroups<'a> {
37 let query = query.trim().to_lowercase();
38 let mut matching: Vec<&TeamMember> = members
39 .iter()
40 .filter(|member| {
41 query.is_empty()
42 || member.name.to_lowercase().contains(&query)
43 || member.email.as_deref().is_some_and(|email| email.to_lowercase().contains(&query))
44 })
45 .collect();
46 matching.sort_by(|left, right| compare_names(&left.name, &right.name));
47 let (owners, others) = matching.into_iter().partition(|member| member.owner);
48 MemberGroups { owners, others }
49 }
50
51 fn compare_names(left: &str, right: &str) -> Ordering {
52 left.to_lowercase().cmp(&right.to_lowercase()).then_with(|| left.cmp(right))
53 }
54
55 fn team_member(member: graph::Member) -> TeamMember {
56 TeamMember {
57 name: member.name().to_owned(),
58 owner: member.is_owner(),
59 user_id: member.user_id,
60 email: member.email.filter(|email| !email.is_empty()),
61 }
62 }
63
64 impl AppState {
65 pub fn open_manage_team(&mut self, team_id: &str, cx: &mut Context<Self>) {
66 let Some(team_name) = self
67 .sidebar
68 .teams
69 .iter()
70 .find(|team| team.team.id == team_id)
71 .map(|team| team.team.name.clone())
72 else {
73 return;
74 };
75 self.quick_view = None;
76 self.manage_team = Some(ManageTeam {
77 team_id: team_id.to_owned(),
78 team_name,
79 members: MembersLoad::Loading,
80 });
81 cx.emit(AppEvent::Sidebar);
82 cx.notify();
83 if self.mode.demo {
84 self.finish_member_load(team_id, Ok(crate::demo::team_members()), cx);
85 return;
86 }
87 let Some(engine) = self.engine.clone() else {
88 self.finish_member_load(team_id, Err("Not connected yet".to_owned()), cx);
89 return;
90 };
91 let lookup = team_id.to_owned();
92 let receiver = runtime::spawn(async move { engine.team_members(&lookup).await });
93 let team_id = team_id.to_owned();
94 cx.spawn(async move |this, cx| {
95 let result = match receiver.await {
96 Ok(Ok(members)) => Ok(members.into_iter().map(team_member).collect()),
97 Ok(Err(error)) => Err(error.to_string()),
98 Err(error) => Err(error.to_string()),
99 };
100 this.update(cx, |state, cx| state.finish_member_load(&team_id, result, cx))
101 .ok();
102 })
103 .detach();
104 }
105
106 fn finish_member_load(&mut self, team_id: &str, result: Result<Vec<TeamMember>, String>, cx: &mut Context<Self>) {
107 let Some(manage_team) = self.manage_team.as_mut().filter(|open| open.team_id == team_id) else {
108 return;
109 };
110 let mut user_ids = Vec::new();
111 manage_team.members = match result {
112 Ok(members) => {
113 user_ids = members.iter().filter_map(|member| member.user_id.clone()).collect();
114 MembersLoad::Loaded(members)
115 }
116 Err(error) => {
117 app_base::diagnostics::record(format!("manage team: members failed: {error}"));
118 MembersLoad::Failed("Couldn't load the members. Try again later.".to_owned())
119 }
120 };
121 self.request_avatars(user_ids, cx);
122 cx.notify();
123 }
124
125 pub fn close_manage_team(&mut self, cx: &mut Context<Self>) {
126 if self.manage_team.take().is_some() {
127 cx.emit(AppEvent::Sidebar);
128 cx.notify();
129 }
130 }
131 }
132
133 #[cfg(test)]
134 mod tests {
135 use super::{MemberGroups, TeamMember, member_groups, team_member};
136
137 fn member(name: &str, email: Option<&str>, owner: bool) -> TeamMember {
138 TeamMember {
139 user_id: Some(name.to_lowercase()),
140 name: name.to_owned(),
141 email: email.map(str::to_owned),
142 owner,
143 }
144 }
145
146 #[test]
147 fn owners_come_first_and_each_group_is_sorted_by_name() {
148 let members = [
149 member("tobias", None, false),
150 member("Mara", None, true),
151 member("Anna", None, false),
152 member("Bert", None, true),
153 ];
154 let groups = member_groups(&members, "");
155 let names = |group: &[&TeamMember]| group.iter().map(|member| member.name.clone()).collect::<Vec<_>>();
156 assert_eq!(names(&groups.owners), ["Bert", "Mara"]);
157 assert_eq!(names(&groups.others), ["Anna", "tobias"]);
158 }
159
160 #[test]
161 fn search_matches_name_or_email_ignoring_case() {
162 let members = [
163 member("Mara Lindqvist", Some("mara@example.com"), true),
164 member("Jonas Ortega", Some("j.ortega@example.com"), false),
165 ];
166 assert_eq!(member_groups(&members, "LIND").owners.len(), 1);
167 assert_eq!(member_groups(&members, "ortega@").others.len(), 1);
168 assert_eq!(member_groups(&members, "nobody"), MemberGroups::default());
169 }
170
171 #[test]
172 fn graph_roles_mark_owners() {
173 let graph_member = |roles: &[&str]| graph::Member {
174 id: None,
175 user_id: Some("u".to_owned()),
176 tenant_id: None,
177 display_name: Some("Name".to_owned()),
178 email: Some(String::new()),
179 roles: roles.iter().map(|role| (*role).to_owned()).collect(),
180 };
181 assert!(team_member(graph_member(&["owner"])).owner);
182 assert!(!team_member(graph_member(&["guest"])).owner);
183 assert_eq!(team_member(graph_member(&[])).email, None);
184 }
185 }
@@ -0,0 +1,185 @@
1use std::cmp::Ordering;
2
3use gpui_kit::*;
4
5use crate::app_state::{AppEvent, AppState};
6use crate::runtime;
7
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct TeamMember {
10 pub user_id: Option<String>,
11 pub name: String,
12 pub email: Option<String>,
13 pub owner: bool,
14}
15
16#[derive(Debug, Clone, PartialEq, Eq)]
17pub enum MembersLoad {
18 Loading,
19 Loaded(Vec<TeamMember>),
20 Failed(String),
21}
22
23#[derive(Debug, Clone, PartialEq, Eq)]
24pub struct ManageTeam {
25 pub team_id: String,
26 pub team_name: String,
27 pub members: MembersLoad,
28}
29
30#[derive(Debug, Default, PartialEq, Eq)]
31pub struct MemberGroups<'a> {
32 pub owners: Vec<&'a TeamMember>,
33 pub others: Vec<&'a TeamMember>,
34}
35
36pub fn member_groups<'a>(members: &'a [TeamMember], query: &str) -> MemberGroups<'a> {
37 let query = query.trim().to_lowercase();
38 let mut matching: Vec<&TeamMember> = members
39 .iter()
40 .filter(|member| {
41 query.is_empty()
42 || member.name.to_lowercase().contains(&query)
43 || member.email.as_deref().is_some_and(|email| email.to_lowercase().contains(&query))
44 })
45 .collect();
46 matching.sort_by(|left, right| compare_names(&left.name, &right.name));
47 let (owners, others) = matching.into_iter().partition(|member| member.owner);
48 MemberGroups { owners, others }
49}
50
51fn compare_names(left: &str, right: &str) -> Ordering {
52 left.to_lowercase().cmp(&right.to_lowercase()).then_with(|| left.cmp(right))
53}
54
55fn team_member(member: graph::Member) -> TeamMember {
56 TeamMember {
57 name: member.name().to_owned(),
58 owner: member.is_owner(),
59 user_id: member.user_id,
60 email: member.email.filter(|email| !email.is_empty()),
61 }
62}
63
64impl AppState {
65 pub fn open_manage_team(&mut self, team_id: &str, cx: &mut Context<Self>) {
66 let Some(team_name) = self
67 .sidebar
68 .teams
69 .iter()
70 .find(|team| team.team.id == team_id)
71 .map(|team| team.team.name.clone())
72 else {
73 return;
74 };
75 self.quick_view = None;
76 self.manage_team = Some(ManageTeam {
77 team_id: team_id.to_owned(),
78 team_name,
79 members: MembersLoad::Loading,
80 });
81 cx.emit(AppEvent::Sidebar);
82 cx.notify();
83 if self.mode.demo {
84 self.finish_member_load(team_id, Ok(crate::demo::team_members()), cx);
85 return;
86 }
87 let Some(engine) = self.engine.clone() else {
88 self.finish_member_load(team_id, Err("Not connected yet".to_owned()), cx);
89 return;
90 };
91 let lookup = team_id.to_owned();
92 let receiver = runtime::spawn(async move { engine.team_members(&lookup).await });
93 let team_id = team_id.to_owned();
94 cx.spawn(async move |this, cx| {
95 let result = match receiver.await {
96 Ok(Ok(members)) => Ok(members.into_iter().map(team_member).collect()),
97 Ok(Err(error)) => Err(error.to_string()),
98 Err(error) => Err(error.to_string()),
99 };
100 this.update(cx, |state, cx| state.finish_member_load(&team_id, result, cx))
101 .ok();
102 })
103 .detach();
104 }
105
106 fn finish_member_load(&mut self, team_id: &str, result: Result<Vec<TeamMember>, String>, cx: &mut Context<Self>) {
107 let Some(manage_team) = self.manage_team.as_mut().filter(|open| open.team_id == team_id) else {
108 return;
109 };
110 let mut user_ids = Vec::new();
111 manage_team.members = match result {
112 Ok(members) => {
113 user_ids = members.iter().filter_map(|member| member.user_id.clone()).collect();
114 MembersLoad::Loaded(members)
115 }
116 Err(error) => {
117 app_base::diagnostics::record(format!("manage team: members failed: {error}"));
118 MembersLoad::Failed("Couldn't load the members. Try again later.".to_owned())
119 }
120 };
121 self.request_avatars(user_ids, cx);
122 cx.notify();
123 }
124
125 pub fn close_manage_team(&mut self, cx: &mut Context<Self>) {
126 if self.manage_team.take().is_some() {
127 cx.emit(AppEvent::Sidebar);
128 cx.notify();
129 }
130 }
131}
132
133#[cfg(test)]
134mod tests {
135 use super::{MemberGroups, TeamMember, member_groups, team_member};
136
137 fn member(name: &str, email: Option<&str>, owner: bool) -> TeamMember {
138 TeamMember {
139 user_id: Some(name.to_lowercase()),
140 name: name.to_owned(),
141 email: email.map(str::to_owned),
142 owner,
143 }
144 }
145
146 #[test]
147 fn owners_come_first_and_each_group_is_sorted_by_name() {
148 let members = [
149 member("tobias", None, false),
150 member("Mara", None, true),
151 member("Anna", None, false),
152 member("Bert", None, true),
153 ];
154 let groups = member_groups(&members, "");
155 let names = |group: &[&TeamMember]| group.iter().map(|member| member.name.clone()).collect::<Vec<_>>();
156 assert_eq!(names(&groups.owners), ["Bert", "Mara"]);
157 assert_eq!(names(&groups.others), ["Anna", "tobias"]);
158 }
159
160 #[test]
161 fn search_matches_name_or_email_ignoring_case() {
162 let members = [
163 member("Mara Lindqvist", Some("mara@example.com"), true),
164 member("Jonas Ortega", Some("j.ortega@example.com"), false),
165 ];
166 assert_eq!(member_groups(&members, "LIND").owners.len(), 1);
167 assert_eq!(member_groups(&members, "ortega@").others.len(), 1);
168 assert_eq!(member_groups(&members, "nobody"), MemberGroups::default());
169 }
170
171 #[test]
172 fn graph_roles_mark_owners() {
173 let graph_member = |roles: &[&str]| graph::Member {
174 id: None,
175 user_id: Some("u".to_owned()),
176 tenant_id: None,
177 display_name: Some("Name".to_owned()),
178 email: Some(String::new()),
179 roles: roles.iter().map(|role| (*role).to_owned()).collect(),
180 };
181 assert!(team_member(graph_member(&["owner"])).owner);
182 assert!(!team_member(graph_member(&["guest"])).owner);
183 assert_eq!(team_member(graph_member(&[])).email, None);
184 }
185}
crates/app/src/views/manage_team_page.rs added +287 −0
@@ -0,0 +1,287 @@
1 use gpui_kit::assets::IconName;
2 use gpui_kit::component::input::{Input, InputEvent, InputState};
3 use gpui_kit::component::scroll::ScrollableElement as _;
4 use gpui_kit::component::{h_flex, v_flex};
5 use gpui_kit::prelude::FluentBuilder as _;
6 use gpui_kit::*;
7 use teams_core::team_avatar_key;
8
9 use super::avatar::{person_avatar, team_avatar};
10 use super::widgets::icon;
11 use crate::app_state::AppState;
12 use crate::data::Directory;
13 use crate::manage_team::{MembersLoad, TeamMember, member_groups};
14 use crate::theme;
15 use app_ui_kit::scroll_edge::with_top_edge;
16
17 const MANAGE_TEAM_TAG: &str = "shell/islands/main/manage-team";
18 const MANAGE_TEAM_SCROLL_DIVIDER: &str = "shell/islands/main/manage-team-divider-scroll";
19 const HEADER_HEIGHT: f32 = 60.;
20 const PAGE_PADDING: f32 = 20.;
21 const TEAM_AVATAR_SIZE: f32 = 32.;
22 const TEAM_AVATAR_RADIUS: f32 = 8.;
23 const MEMBER_AVATAR_SIZE: f32 = 32.;
24 const ROW_HEIGHT: f32 = 52.;
25 const SEARCH_WIDTH: f32 = 260.;
26 const SEARCH_HEIGHT: f32 = 32.;
27 const ROLE_WIDTH: f32 = 96.;
28 const LIST_MAX_WIDTH: f32 = 960.;
29 const SEARCH_PLACEHOLDER: &str = "Search for members";
30
31 pub struct ManageTeamPage {
32 app: Entity<AppState>,
33 search: Entity<InputState>,
34 owners_open: bool,
35 others_open: bool,
36 scroll: ScrollHandle,
37 _subscriptions: [Subscription; 2],
38 }
39
40 impl ManageTeamPage {
41 pub fn new(app: Entity<AppState>, window: &mut Window, cx: &mut Context<Self>) -> Self {
42 let search = cx.new(|cx| InputState::new(window, cx).placeholder(SEARCH_PLACEHOLDER));
43 let subscriptions = [
44 cx.observe(&app, |_, _, cx| cx.notify()),
45 cx.subscribe(&search, |_, _, event: &InputEvent, cx| {
46 if matches!(event, InputEvent::Change) {
47 cx.notify();
48 }
49 }),
50 ];
51 ManageTeamPage {
52 app,
53 search,
54 owners_open: true,
55 others_open: true,
56 scroll: ScrollHandle::new(),
57 _subscriptions: subscriptions,
58 }
59 }
60
61 fn header(&self, team_id: &str, team_name: &str, directory: &Directory, cx: &Context<Self>) -> Div {
62 let photo = directory.avatar(&team_avatar_key(team_id));
63 h_flex()
64 .h(px(HEADER_HEIGHT))
65 .flex_none()
66 .px(px(PAGE_PADDING))
67 .gap(px(12.))
68 .items_center()
69 .child(
70 div()
71 .id("manage-team-back")
72 .size(px(28.))
73 .flex()
74 .items_center()
75 .justify_center()
76 .rounded(px(6.))
77 .cursor_pointer()
78 .hover(|button| button.bg(theme::row_hover()))
79 .child(icon(IconName::ArrowLeft, 16., theme::text_muted()))
80 .on_click(cx.listener(|this, _, _, cx| {
81 this.app.update(cx, |state, cx| state.close_manage_team(cx));
82 })),
83 )
84 .child(team_avatar(photo, team_name, team_id, TEAM_AVATAR_SIZE, TEAM_AVATAR_RADIUS))
85 .child(
86 div()
87 .min_w_0()
88 .truncate()
89 .text_size(px(16.))
90 .font_weight(FontWeight::BOLD)
91 .text_color(theme::text())
92 .child(team_name.to_owned()),
93 )
94 .child(
95 div()
96 .ml(px(12.))
97 .h_full()
98 .flex()
99 .items_center()
100 .border_b_2()
101 .border_color(theme::accent())
102 .text_size(px(14.))
103 .font_weight(FontWeight::SEMIBOLD)
104 .text_color(theme::text())
105 .child("Members"),
106 )
107 .child(div().flex_1())
108 .child(
109 h_flex()
110 .id("manage-team-in-browser")
111 .h(px(28.))
112 .px(px(10.))
113 .gap(px(6.))
114 .items_center()
115 .rounded(px(6.))
116 .cursor_pointer()
117 .text_size(px(13.))
118 .text_color(theme::text_soft())
119 .hover(|button| button.bg(theme::row_hover()))
120 .child(icon(IconName::ExternalLink, 14., theme::text_muted()))
121 .child("Open in browser")
122 .on_click(cx.listener(|this, _, _, cx| {
123 this.app.update(cx, |state, cx| {
124 if let Some(team_id) = state.manage_team.as_ref().map(|open| open.team_id.clone()) {
125 state.manage_team_in_browser(&team_id, cx);
126 }
127 });
128 })),
129 )
130 }
131
132 fn search_box(&self) -> Div {
133 h_flex()
134 .w(px(SEARCH_WIDTH))
135 .max_w_full()
136 .h(px(SEARCH_HEIGHT))
137 .px(px(10.))
138 .gap(px(8.))
139 .items_center()
140 .rounded(px(6.))
141 .bg(theme::popup())
142 .child(icon(IconName::Search, 14., theme::text_muted()))
143 .child(div().flex_1().min_w_0().child(Input::new(&self.search).appearance(false).bordered(false)))
144 }
145
146 fn section(
147 &self,
148 id: &'static str,
149 title: &str,
150 members: &[&TeamMember],
151 open: bool,
152 directory: &Directory,
153 cx: &Context<Self>,
154 ) -> Div {
155 let toggle = h_flex()
156 .id(id)
157 .h(px(32.))
158 .flex_none()
159 .gap(px(6.))
160 .items_center()
161 .cursor_pointer()
162 .text_size(px(14.))
163 .font_weight(FontWeight::SEMIBOLD)
164 .text_color(theme::text())
165 .child(icon(if open { IconName::ChevronDown } else { IconName::ChevronRight }, 14., theme::text_muted()))
166 .child(format!("{title} ({})", members.len()))
167 .on_click(cx.listener(move |this, _, _, cx| {
168 if id == "manage-team-owners" {
169 this.owners_open = !this.owners_open;
170 } else {
171 this.others_open = !this.others_open;
172 }
173 cx.notify();
174 }));
175 v_flex()
176 .w_full()
177 .child(toggle)
178 .when(open, |section| {
179 section.children(members.iter().map(|member| member_row(member, directory)))
180 })
181 }
182 }
183
184 fn member_row(member: &TeamMember, directory: &Directory) -> Div {
185 h_flex()
186 .w_full()
187 .h(px(ROW_HEIGHT))
188 .flex_none()
189 .px(px(8.))
190 .gap(px(12.))
191 .items_center()
192 .rounded(px(8.))
193 .hover(|row| row.bg(theme::row_hover()))
194 .child(
195 div()
196 .flex_none()
197 .size(px(MEMBER_AVATAR_SIZE))
198 .child(person_avatar(directory, member.user_id.as_deref(), &member.name, MEMBER_AVATAR_SIZE)),
199 )
200 .child(
201 v_flex()
202 .flex_1()
203 .min_w_0()
204 .child(div().truncate().text_size(px(14.)).text_color(theme::text()).child(member.name.clone()))
205 .children(member.email.clone().map(|email| {
206 div().truncate().text_size(px(12.)).text_color(theme::text_muted()).child(email)
207 })),
208 )
209 .child(
210 div()
211 .flex_none()
212 .w(px(ROLE_WIDTH))
213 .text_size(px(13.))
214 .text_color(theme::text_soft())
215 .child(if member.owner { "Owner" } else { "Member" }),
216 )
217 }
218
219 fn notice(text: String) -> Div {
220 div()
221 .py(px(32.))
222 .flex()
223 .justify_center()
224 .text_size(px(13.))
225 .text_color(theme::text_muted())
226 .child(text)
227 }
228
229 impl Render for ManageTeamPage {
230 fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
231 let query = self.search.read(cx).value().to_string();
232 let state = self.app.read(cx);
233 let Some(manage_team) = state.manage_team.as_ref() else {
234 return div().into_any_element();
235 };
236 let directory = &state.directory;
237 let body: Vec<AnyElement> = match &manage_team.members {
238 MembersLoad::Loading => vec![notice("Loading members...".to_owned()).into_any_element()],
239 MembersLoad::Failed(message) => vec![notice(message.clone()).into_any_element()],
240 MembersLoad::Loaded(members) => {
241 let groups = member_groups(members, &query);
242 if groups.owners.is_empty() && groups.others.is_empty() {
243 vec![notice(format!("No members match \"{}\"", query.trim())).into_any_element()]
244 } else {
245 vec![
246 self.section("manage-team-owners", "Owners", &groups.owners, self.owners_open, directory, cx)
247 .into_any_element(),
248 self.section("manage-team-others", "Members and guests", &groups.others, self.others_open, directory, cx)
249 .into_any_element(),
250 ]
251 }
252 }
253 };
254 v_flex()
255 .debug_selector(|| MANAGE_TEAM_TAG.into())
256 .flex_1()
257 .w_full()
258 .min_w_0()
259 .h_full()
260 .rounded(px(10.))
261 .bg(theme::surface())
262 .overflow_hidden()
263 .child(self.header(&manage_team.team_id, &manage_team.team_name, directory, cx))
264 .child(div().w_full().h(px(1.)).flex_none().bg(theme::border()))
265 .child(with_top_edge(
266 v_flex()
267 .id("manage-team-list")
268 .flex_1()
269 .min_h_0()
270 .px(px(PAGE_PADDING - 8.))
271 .py(px(12.))
272 .overflow_y_scrollbar()
273 .track_scroll(&self.scroll)
274 .child(
275 v_flex()
276 .w_full()
277 .max_w(px(LIST_MAX_WIDTH))
278 .gap(px(12.))
279 .child(h_flex().w_full().px(px(8.)).justify_end().child(self.search_box()))
280 .children(body),
281 ),
282 &self.scroll,
283 MANAGE_TEAM_SCROLL_DIVIDER,
284 ))
285 .into_any_element()
286 }
287 }
@@ -0,0 +1,287 @@
1use gpui_kit::assets::IconName;
2use gpui_kit::component::input::{Input, InputEvent, InputState};
3use gpui_kit::component::scroll::ScrollableElement as _;
4use gpui_kit::component::{h_flex, v_flex};
5use gpui_kit::prelude::FluentBuilder as _;
6use gpui_kit::*;
7use teams_core::team_avatar_key;
8
9use super::avatar::{person_avatar, team_avatar};
10use super::widgets::icon;
11use crate::app_state::AppState;
12use crate::data::Directory;
13use crate::manage_team::{MembersLoad, TeamMember, member_groups};
14use crate::theme;
15use app_ui_kit::scroll_edge::with_top_edge;
16
17const MANAGE_TEAM_TAG: &str = "shell/islands/main/manage-team";
18const MANAGE_TEAM_SCROLL_DIVIDER: &str = "shell/islands/main/manage-team-divider-scroll";
19const HEADER_HEIGHT: f32 = 60.;
20const PAGE_PADDING: f32 = 20.;
21const TEAM_AVATAR_SIZE: f32 = 32.;
22const TEAM_AVATAR_RADIUS: f32 = 8.;
23const MEMBER_AVATAR_SIZE: f32 = 32.;
24const ROW_HEIGHT: f32 = 52.;
25const SEARCH_WIDTH: f32 = 260.;
26const SEARCH_HEIGHT: f32 = 32.;
27const ROLE_WIDTH: f32 = 96.;
28const LIST_MAX_WIDTH: f32 = 960.;
29const SEARCH_PLACEHOLDER: &str = "Search for members";
30
31pub struct ManageTeamPage {
32 app: Entity<AppState>,
33 search: Entity<InputState>,
34 owners_open: bool,
35 others_open: bool,
36 scroll: ScrollHandle,
37 _subscriptions: [Subscription; 2],
38}
39
40impl ManageTeamPage {
41 pub fn new(app: Entity<AppState>, window: &mut Window, cx: &mut Context<Self>) -> Self {
42 let search = cx.new(|cx| InputState::new(window, cx).placeholder(SEARCH_PLACEHOLDER));
43 let subscriptions = [
44 cx.observe(&app, |_, _, cx| cx.notify()),
45 cx.subscribe(&search, |_, _, event: &InputEvent, cx| {
46 if matches!(event, InputEvent::Change) {
47 cx.notify();
48 }
49 }),
50 ];
51 ManageTeamPage {
52 app,
53 search,
54 owners_open: true,
55 others_open: true,
56 scroll: ScrollHandle::new(),
57 _subscriptions: subscriptions,
58 }
59 }
60
61 fn header(&self, team_id: &str, team_name: &str, directory: &Directory, cx: &Context<Self>) -> Div {
62 let photo = directory.avatar(&team_avatar_key(team_id));
63 h_flex()
64 .h(px(HEADER_HEIGHT))
65 .flex_none()
66 .px(px(PAGE_PADDING))
67 .gap(px(12.))
68 .items_center()
69 .child(
70 div()
71 .id("manage-team-back")
72 .size(px(28.))
73 .flex()
74 .items_center()
75 .justify_center()
76 .rounded(px(6.))
77 .cursor_pointer()
78 .hover(|button| button.bg(theme::row_hover()))
79 .child(icon(IconName::ArrowLeft, 16., theme::text_muted()))
80 .on_click(cx.listener(|this, _, _, cx| {
81 this.app.update(cx, |state, cx| state.close_manage_team(cx));
82 })),
83 )
84 .child(team_avatar(photo, team_name, team_id, TEAM_AVATAR_SIZE, TEAM_AVATAR_RADIUS))
85 .child(
86 div()
87 .min_w_0()
88 .truncate()
89 .text_size(px(16.))
90 .font_weight(FontWeight::BOLD)
91 .text_color(theme::text())
92 .child(team_name.to_owned()),
93 )
94 .child(
95 div()
96 .ml(px(12.))
97 .h_full()
98 .flex()
99 .items_center()
100 .border_b_2()
101 .border_color(theme::accent())
102 .text_size(px(14.))
103 .font_weight(FontWeight::SEMIBOLD)
104 .text_color(theme::text())
105 .child("Members"),
106 )
107 .child(div().flex_1())
108 .child(
109 h_flex()
110 .id("manage-team-in-browser")
111 .h(px(28.))
112 .px(px(10.))
113 .gap(px(6.))
114 .items_center()
115 .rounded(px(6.))
116 .cursor_pointer()
117 .text_size(px(13.))
118 .text_color(theme::text_soft())
119 .hover(|button| button.bg(theme::row_hover()))
120 .child(icon(IconName::ExternalLink, 14., theme::text_muted()))
121 .child("Open in browser")
122 .on_click(cx.listener(|this, _, _, cx| {
123 this.app.update(cx, |state, cx| {
124 if let Some(team_id) = state.manage_team.as_ref().map(|open| open.team_id.clone()) {
125 state.manage_team_in_browser(&team_id, cx);
126 }
127 });
128 })),
129 )
130 }
131
132 fn search_box(&self) -> Div {
133 h_flex()
134 .w(px(SEARCH_WIDTH))
135 .max_w_full()
136 .h(px(SEARCH_HEIGHT))
137 .px(px(10.))
138 .gap(px(8.))
139 .items_center()
140 .rounded(px(6.))
141 .bg(theme::popup())
142 .child(icon(IconName::Search, 14., theme::text_muted()))
143 .child(div().flex_1().min_w_0().child(Input::new(&self.search).appearance(false).bordered(false)))
144 }
145
146 fn section(
147 &self,
148 id: &'static str,
149 title: &str,
150 members: &[&TeamMember],
151 open: bool,
152 directory: &Directory,
153 cx: &Context<Self>,
154 ) -> Div {
155 let toggle = h_flex()
156 .id(id)
157 .h(px(32.))
158 .flex_none()
159 .gap(px(6.))
160 .items_center()
161 .cursor_pointer()
162 .text_size(px(14.))
163 .font_weight(FontWeight::SEMIBOLD)
164 .text_color(theme::text())
165 .child(icon(if open { IconName::ChevronDown } else { IconName::ChevronRight }, 14., theme::text_muted()))
166 .child(format!("{title} ({})", members.len()))
167 .on_click(cx.listener(move |this, _, _, cx| {
168 if id == "manage-team-owners" {
169 this.owners_open = !this.owners_open;
170 } else {
171 this.others_open = !this.others_open;
172 }
173 cx.notify();
174 }));
175 v_flex()
176 .w_full()
177 .child(toggle)
178 .when(open, |section| {
179 section.children(members.iter().map(|member| member_row(member, directory)))
180 })
181 }
182}
183
184fn member_row(member: &TeamMember, directory: &Directory) -> Div {
185 h_flex()
186 .w_full()
187 .h(px(ROW_HEIGHT))
188 .flex_none()
189 .px(px(8.))
190 .gap(px(12.))
191 .items_center()
192 .rounded(px(8.))
193 .hover(|row| row.bg(theme::row_hover()))
194 .child(
195 div()
196 .flex_none()
197 .size(px(MEMBER_AVATAR_SIZE))
198 .child(person_avatar(directory, member.user_id.as_deref(), &member.name, MEMBER_AVATAR_SIZE)),
199 )
200 .child(
201 v_flex()
202 .flex_1()
203 .min_w_0()
204 .child(div().truncate().text_size(px(14.)).text_color(theme::text()).child(member.name.clone()))
205 .children(member.email.clone().map(|email| {
206 div().truncate().text_size(px(12.)).text_color(theme::text_muted()).child(email)
207 })),
208 )
209 .child(
210 div()
211 .flex_none()
212 .w(px(ROLE_WIDTH))
213 .text_size(px(13.))
214 .text_color(theme::text_soft())
215 .child(if member.owner { "Owner" } else { "Member" }),
216 )
217}
218
219fn notice(text: String) -> Div {
220 div()
221 .py(px(32.))
222 .flex()
223 .justify_center()
224 .text_size(px(13.))
225 .text_color(theme::text_muted())
226 .child(text)
227}
228
229impl Render for ManageTeamPage {
230 fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
231 let query = self.search.read(cx).value().to_string();
232 let state = self.app.read(cx);
233 let Some(manage_team) = state.manage_team.as_ref() else {
234 return div().into_any_element();
235 };
236 let directory = &state.directory;
237 let body: Vec<AnyElement> = match &manage_team.members {
238 MembersLoad::Loading => vec![notice("Loading members...".to_owned()).into_any_element()],
239 MembersLoad::Failed(message) => vec![notice(message.clone()).into_any_element()],
240 MembersLoad::Loaded(members) => {
241 let groups = member_groups(members, &query);
242 if groups.owners.is_empty() && groups.others.is_empty() {
243 vec![notice(format!("No members match \"{}\"", query.trim())).into_any_element()]
244 } else {
245 vec![
246 self.section("manage-team-owners", "Owners", &groups.owners, self.owners_open, directory, cx)
247 .into_any_element(),
248 self.section("manage-team-others", "Members and guests", &groups.others, self.others_open, directory, cx)
249 .into_any_element(),
250 ]
251 }
252 }
253 };
254 v_flex()
255 .debug_selector(|| MANAGE_TEAM_TAG.into())
256 .flex_1()
257 .w_full()
258 .min_w_0()
259 .h_full()
260 .rounded(px(10.))
261 .bg(theme::surface())
262 .overflow_hidden()
263 .child(self.header(&manage_team.team_id, &manage_team.team_name, directory, cx))
264 .child(div().w_full().h(px(1.)).flex_none().bg(theme::border()))
265 .child(with_top_edge(
266 v_flex()
267 .id("manage-team-list")
268 .flex_1()
269 .min_h_0()
270 .px(px(PAGE_PADDING - 8.))
271 .py(px(12.))
272 .overflow_y_scrollbar()
273 .track_scroll(&self.scroll)
274 .child(
275 v_flex()
276 .w_full()
277 .max_w(px(LIST_MAX_WIDTH))
278 .gap(px(12.))
279 .child(h_flex().w_full().px(px(8.)).justify_end().child(self.search_box()))
280 .children(body),
281 ),
282 &self.scroll,
283 MANAGE_TEAM_SCROLL_DIVIDER,
284 ))
285 .into_any_element()
286 }
287}
crates/app/src/views/mod.rs +1 −0
@@ -79,6 +79,7 @@ pub mod rail;
79 79 pub mod reaction_picker;
80 80 pub mod reaction_pills;
81 81 pub mod recap_tab;
82 pub mod manage_team_page;
82 83 pub mod quick_view_pane;
83 84 pub mod scheduled_toolbar;
84 85 pub mod section_dialog;
@@ -79,6 +79,7 @@ pub mod rail;
79pub mod reaction_picker;
79pub mod reaction_picker;
80pub mod reaction_pills;
80pub mod reaction_pills;
81pub mod recap_tab;
81pub mod recap_tab;
82pub mod manage_team_page;
82pub mod quick_view_pane;
83pub mod quick_view_pane;
83pub mod scheduled_toolbar;
84pub mod scheduled_toolbar;
84pub mod section_dialog;
85pub mod section_dialog;
crates/app/src/views/shell.rs +12 −1
@@ -35,6 +35,7 @@ use super::sidebar::{SidebarEvent, SidebarTab, SidebarView};
35 35 use app_ui_kit::render::hooks::RenderHooks;
36 36 use app_ui_kit::layout::{ISLAND_GAP, SIDEBAR_WIDTH};
37 37 use super::connection_banner::render_connection_banner;
38 use super::manage_team_page::ManageTeamPage;
38 39 use super::splash::{self, Phase, Splash, StartupFacts};
39 40 use super::notice_toast::NoticeToasts;
40 41 use super::status_menu::{own_status_button, settings_more_button};
@@ -168,6 +169,7 @@ pub struct AppShell {
168 169 sidebar: Entity<SidebarView>,
169 170 calendar: Entity<CalendarView>,
170 171 quick_pane: Entity<QuickViewPane>,
172 manage_team_page: Entity<ManageTeamPage>,
171 173 calls_page: Entity<CallsPage>,
172 174 shown_quick_view: Option<QuickView>,
173 175 conversation: Entity<ConversationView>,
@@ -254,6 +256,7 @@ impl AppShell {
254 256 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
255 257 let activity_panel = cx.new(|cx| ActivityPanel::new(state.clone(), activity.clone(), cx));
256 258 let quick_pane = cx.new(|cx| QuickViewPane::new(state.clone(), activity.clone(), cx));
259 let manage_team_page = cx.new(|cx| ManageTeamPage::new(state.clone(), window, cx));
257 260 let calls_page = cx.new(|cx| CallsPage::new(state.clone(), window, cx));
258 261 let agents_panel = crate::agents::runs_handle(cx)
259 262 .map(|runs| cx.new(|cx| crate::agents::AgentsPanel::new(runs, cx)));
@@ -393,6 +396,7 @@ impl AppShell {
393 396 sidebar,
394 397 calendar,
395 398 quick_pane,
399 manage_team_page,
396 400 calls_page,
397 401 shown_quick_view: None,
398 402 conversation,
@@ -913,6 +917,7 @@ impl AppShell {
913 917 calendar_open: bool,
914 918 quick_view_open: bool,
915 919 calls_open: bool,
920 manage_team_open: bool,
916 921 ) -> Div {
917 922 h_flex()
918 923 .debug_selector(|| "shell/islands".into())
@@ -947,6 +952,11 @@ impl AppShell {
947 952 .clone()
948 953 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
949 954 .into_any_element(),
955 None if manage_team_open => self
956 .manage_team_page
957 .clone()
958 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
959 .into_any_element(),
950 960 None if quick_view_open => self
951 961 .quick_pane
952 962 .clone()
@@ -1018,6 +1028,7 @@ impl Render for AppShell {
1018 1028 let state = self.state.read(cx);
1019 1029 let calendar_open = calendar_tab;
1020 1030 let quick_view_open = chats_tab && state.quick_view.is_some();
1031 let manage_team_open = !calendar_tab && !calls_tab && state.manage_team.is_some();
1021 1032 let calls_open = calls_tab;
1022 1033 let show_sidebar = !calendar_open && !calls_open;
1023 1034 let banner = state.connection_banner_text().filter(|_| !self.splash.is_up()).map(|banner| {
@@ -1232,7 +1243,7 @@ impl Render for AppShell {
1232 1243 .size_full()
1233 1244 .child(title_bar)
1234 1245 .children(banner)
1235 .child(rising_in(self.islands(show_sidebar, calendar_open, quick_view_open, calls_open), &self.splash, cx)),
1246 .child(rising_in(self.islands(show_sidebar, calendar_open, quick_view_open, calls_open, manage_team_open), &self.splash, cx)),
1236 1247 )
1237 1248 .children(splash)
1238 1249 .children(self.image_viewer.clone())
@@ -35,6 +35,7 @@ use super::sidebar::{SidebarEvent, SidebarTab, SidebarView};
35use app_ui_kit::render::hooks::RenderHooks;
35use app_ui_kit::render::hooks::RenderHooks;
36use app_ui_kit::layout::{ISLAND_GAP, SIDEBAR_WIDTH};
36use app_ui_kit::layout::{ISLAND_GAP, SIDEBAR_WIDTH};
37use super::connection_banner::render_connection_banner;
37use super::connection_banner::render_connection_banner;
38use super::manage_team_page::ManageTeamPage;
38use super::splash::{self, Phase, Splash, StartupFacts};
39use super::splash::{self, Phase, Splash, StartupFacts};
39use super::notice_toast::NoticeToasts;
40use super::notice_toast::NoticeToasts;
40use super::status_menu::{own_status_button, settings_more_button};
41use super::status_menu::{own_status_button, settings_more_button};
@@ -168,6 +169,7 @@ pub struct AppShell {
168 sidebar: Entity<SidebarView>,
169 sidebar: Entity<SidebarView>,
169 calendar: Entity<CalendarView>,
170 calendar: Entity<CalendarView>,
170 quick_pane: Entity<QuickViewPane>,
171 quick_pane: Entity<QuickViewPane>,
172 manage_team_page: Entity<ManageTeamPage>,
171 calls_page: Entity<CallsPage>,
173 calls_page: Entity<CallsPage>,
172 shown_quick_view: Option<QuickView>,
174 shown_quick_view: Option<QuickView>,
173 conversation: Entity<ConversationView>,
175 conversation: Entity<ConversationView>,
@@ -254,6 +256,7 @@ impl AppShell {
254 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
256 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
255 let activity_panel = cx.new(|cx| ActivityPanel::new(state.clone(), activity.clone(), cx));
257 let activity_panel = cx.new(|cx| ActivityPanel::new(state.clone(), activity.clone(), cx));
256 let quick_pane = cx.new(|cx| QuickViewPane::new(state.clone(), activity.clone(), cx));
258 let quick_pane = cx.new(|cx| QuickViewPane::new(state.clone(), activity.clone(), cx));
259 let manage_team_page = cx.new(|cx| ManageTeamPage::new(state.clone(), window, cx));
257 let calls_page = cx.new(|cx| CallsPage::new(state.clone(), window, cx));
260 let calls_page = cx.new(|cx| CallsPage::new(state.clone(), window, cx));
258 let agents_panel = crate::agents::runs_handle(cx)
261 let agents_panel = crate::agents::runs_handle(cx)
259 .map(|runs| cx.new(|cx| crate::agents::AgentsPanel::new(runs, cx)));
262 .map(|runs| cx.new(|cx| crate::agents::AgentsPanel::new(runs, cx)));
@@ -393,6 +396,7 @@ impl AppShell {
393 sidebar,
396 sidebar,
394 calendar,
397 calendar,
395 quick_pane,
398 quick_pane,
399 manage_team_page,
396 calls_page,
400 calls_page,
397 shown_quick_view: None,
401 shown_quick_view: None,
398 conversation,
402 conversation,
@@ -913,6 +917,7 @@ impl AppShell {
913 calendar_open: bool,
917 calendar_open: bool,
914 quick_view_open: bool,
918 quick_view_open: bool,
915 calls_open: bool,
919 calls_open: bool,
920 manage_team_open: bool,
916 ) -> Div {
921 ) -> Div {
917 h_flex()
922 h_flex()
918 .debug_selector(|| "shell/islands".into())
923 .debug_selector(|| "shell/islands".into())
@@ -947,6 +952,11 @@ impl AppShell {
947 .clone()
952 .clone()
948 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
953 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
949 .into_any_element(),
954 .into_any_element(),
955 None if manage_team_open => self
956 .manage_team_page
957 .clone()
958 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
959 .into_any_element(),
950 None if quick_view_open => self
960 None if quick_view_open => self
951 .quick_pane
961 .quick_pane
952 .clone()
962 .clone()
@@ -1018,6 +1028,7 @@ impl Render for AppShell {
1018 let state = self.state.read(cx);
1028 let state = self.state.read(cx);
1019 let calendar_open = calendar_tab;
1029 let calendar_open = calendar_tab;
1020 let quick_view_open = chats_tab && state.quick_view.is_some();
1030 let quick_view_open = chats_tab && state.quick_view.is_some();
1031 let manage_team_open = !calendar_tab && !calls_tab && state.manage_team.is_some();
1021 let calls_open = calls_tab;
1032 let calls_open = calls_tab;
1022 let show_sidebar = !calendar_open && !calls_open;
1033 let show_sidebar = !calendar_open && !calls_open;
1023 let banner = state.connection_banner_text().filter(|_| !self.splash.is_up()).map(|banner| {
1034 let banner = state.connection_banner_text().filter(|_| !self.splash.is_up()).map(|banner| {
@@ -1232,7 +1243,7 @@ impl Render for AppShell {
1232 .size_full()
1243 .size_full()
1233 .child(title_bar)
1244 .child(title_bar)
1234 .children(banner)
1245 .children(banner)
1235 .child(rising_in(self.islands(show_sidebar, calendar_open, quick_view_open, calls_open), &self.splash, cx)),
1246 .child(rising_in(self.islands(show_sidebar, calendar_open, quick_view_open, calls_open, manage_team_open), &self.splash, cx)),
1236 )
1247 )
1237 .children(splash)
1248 .children(splash)
1238 .children(self.image_viewer.clone())
1249 .children(self.image_viewer.clone())
crates/app/src/views/sidebar.rs +1 −1
@@ -1973,7 +1973,7 @@ fn team_menu(
1973 1973 TeamMenuItem::AddChannel => {}
1974 1974 TeamMenuItem::Show => state.set_team_shown(&action_id, true, cx),
1975 1975 TeamMenuItem::Hide => state.set_team_shown(&action_id, false, cx),
1976 TeamMenuItem::ManageTeam => state.manage_team_in_browser(&action_id, cx),
1976 TeamMenuItem::ManageTeam => state.open_manage_team(&action_id, cx),
1977 1977 TeamMenuItem::CopyLink => state.copy_team_link(&action_id, cx),
1978 1978 });
1979 1979 }),
@@ -1973,7 +1973,7 @@ fn team_menu(
1973 TeamMenuItem::AddChannel => {}
1973 TeamMenuItem::AddChannel => {}
1974 TeamMenuItem::Show => state.set_team_shown(&action_id, true, cx),
1974 TeamMenuItem::Show => state.set_team_shown(&action_id, true, cx),
1975 TeamMenuItem::Hide => state.set_team_shown(&action_id, false, cx),
1975 TeamMenuItem::Hide => state.set_team_shown(&action_id, false, cx),
1976 TeamMenuItem::ManageTeam => state.manage_team_in_browser(&action_id, cx),
1976 TeamMenuItem::ManageTeam => state.open_manage_team(&action_id, cx),
1977 TeamMenuItem::CopyLink => state.copy_team_link(&action_id, cx),
1977 TeamMenuItem::CopyLink => state.copy_team_link(&action_id, cx),
1978 });
1978 });
1979 }),
1979 }),
crates/core/src/library.rs +8 −0
@@ -32,6 +32,14 @@ impl<R: Remote> SyncEngine<R> {
32 32 self.remote.channel_member_count(&team_id, channel_id).await
33 33 }
34 34
35 pub async fn team_members(&self, team_id: &str) -> Result<Vec<graph::Member>> {
36 let general_channel_id = self
37 .store
38 .team_thread_id(team_id)?
39 .ok_or(Error::Unsupported("a team without its General channel"))?;
40 self.remote.channel_members(team_id, &general_channel_id).await
41 }
42
35 43 pub async fn library_children(&self, folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
36 44 self.remote.list_children(folder).await
37 45 }
@@ -32,6 +32,14 @@ impl<R: Remote> SyncEngine<R> {
32 self.remote.channel_member_count(&team_id, channel_id).await
32 self.remote.channel_member_count(&team_id, channel_id).await
33 }
33 }
34
34
35 pub async fn team_members(&self, team_id: &str) -> Result<Vec<graph::Member>> {
36 let general_channel_id = self
37 .store
38 .team_thread_id(team_id)?
39 .ok_or(Error::Unsupported("a team without its General channel"))?;
40 self.remote.channel_members(team_id, &general_channel_id).await
41 }
42
35 pub async fn library_children(&self, folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
43 pub async fn library_children(&self, folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
36 self.remote.list_children(folder).await
44 self.remote.list_children(folder).await
37 }
45 }
crates/core/src/remote.rs +8 −0
@@ -245,6 +245,10 @@ pub trait Remote {
245 245 Err(Error::Unsupported("a channel member count"))
246 246 }
247 247
248 async fn channel_members(&self, _team_id: &str, _channel_id: &str) -> Result<Vec<graph::Member>> {
249 Err(Error::Unsupported("a channel member list"))
250 }
251
248 252 async fn list_children(&self, _folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
249 253 Err(Error::Unsupported("a folder listing"))
250 254 }
@@ -1096,6 +1100,10 @@ impl Remote for Graph {
1096 1100 Ok(Graph::channel_member_count(self, team_id, channel_id).await?)
1097 1101 }
1098 1102
1103 async fn channel_members(&self, team_id: &str, channel_id: &str) -> Result<Vec<graph::Member>> {
1104 Ok(Graph::channel_member_list(self, team_id, channel_id).await?)
1105 }
1106
1099 1107 async fn list_children(&self, folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
1100 1108 Ok(Graph::list_children(self, folder).await?)
1101 1109 }
@@ -245,6 +245,10 @@ pub trait Remote {
245 Err(Error::Unsupported("a channel member count"))
245 Err(Error::Unsupported("a channel member count"))
246 }
246 }
247
247
248 async fn channel_members(&self, _team_id: &str, _channel_id: &str) -> Result<Vec<graph::Member>> {
249 Err(Error::Unsupported("a channel member list"))
250 }
251
248 async fn list_children(&self, _folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
252 async fn list_children(&self, _folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
249 Err(Error::Unsupported("a folder listing"))
253 Err(Error::Unsupported("a folder listing"))
250 }
254 }
@@ -1096,6 +1100,10 @@ impl Remote for Graph {
1096 Ok(Graph::channel_member_count(self, team_id, channel_id).await?)
1100 Ok(Graph::channel_member_count(self, team_id, channel_id).await?)
1097 }
1101 }
1098
1102
1103 async fn channel_members(&self, team_id: &str, channel_id: &str) -> Result<Vec<graph::Member>> {
1104 Ok(Graph::channel_member_list(self, team_id, channel_id).await?)
1105 }
1106
1099 async fn list_children(&self, folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
1107 async fn list_children(&self, folder: &DriveFolder) -> Result<Vec<DriveEntry>> {
1100 Ok(Graph::list_children(self, folder).await?)
1108 Ok(Graph::list_children(self, folder).await?)
1101 }
1109 }
crates/graph/src/models.rs +6 −0
@@ -24,9 +24,15 @@ pub struct Member {
24 24 pub tenant_id: Option<String>,
25 25 pub display_name: Option<String>,
26 26 pub email: Option<String>,
27 #[serde(default)]
28 pub roles: Vec<String>,
27 29 }
28 30
29 31 impl Member {
32 pub fn is_owner(&self) -> bool {
33 self.roles.iter().any(|role| role.eq_ignore_ascii_case("owner"))
34 }
35
30 36 pub fn name(&self) -> &str {
31 37 [&self.display_name, &self.email]
32 38 .into_iter()
@@ -24,9 +24,15 @@ pub struct Member {
24 pub tenant_id: Option<String>,
24 pub tenant_id: Option<String>,
25 pub display_name: Option<String>,
25 pub display_name: Option<String>,
26 pub email: Option<String>,
26 pub email: Option<String>,
27 #[serde(default)]
28 pub roles: Vec<String>,
27}
29}
28
30
29impl Member {
31impl Member {
32 pub fn is_owner(&self) -> bool {
33 self.roles.iter().any(|role| role.eq_ignore_ascii_case("owner"))
34 }
35
30 pub fn name(&self) -> &str {
36 pub fn name(&self) -> &str {
31 [&self.display_name, &self.email]
37 [&self.display_name, &self.email]
32 .into_iter()
38 .into_iter()
crates/graph/src/tabs.rs +6 −0
@@ -3,6 +3,7 @@ use session::Scope;
3 3
4 4 use crate::client::Graph;
5 5 use crate::error::Result;
6 use crate::models::Member;
6 7 use crate::urls;
7 8
8 9 const TABS_SCOPE: &str = "TeamsTab.ReadWrite.All";
@@ -40,6 +41,11 @@ impl Graph {
40 41 .await?;
41 42 Ok(members.len())
42 43 }
44
45 pub async fn channel_member_list(&self, team_id: &str, channel_id: &str) -> Result<Vec<Member>> {
46 self.get_all(&urls::channel_member_list(team_id, channel_id), Scope::graph(MEMBERS_SCOPE))
47 .await
48 }
43 49 }
44 50
45 51 #[cfg(test)]
@@ -3,6 +3,7 @@ use session::Scope;
3
3
4use crate::client::Graph;
4use crate::client::Graph;
5use crate::error::Result;
5use crate::error::Result;
6use crate::models::Member;
6use crate::urls;
7use crate::urls;
7
8
8const TABS_SCOPE: &str = "TeamsTab.ReadWrite.All";
9const TABS_SCOPE: &str = "TeamsTab.ReadWrite.All";
@@ -40,6 +41,11 @@ impl Graph {
40 .await?;
41 .await?;
41 Ok(members.len())
42 Ok(members.len())
42 }
43 }
44
45 pub async fn channel_member_list(&self, team_id: &str, channel_id: &str) -> Result<Vec<Member>> {
46 self.get_all(&urls::channel_member_list(team_id, channel_id), Scope::graph(MEMBERS_SCOPE))
47 .await
48 }
43}
49}
44
50
45#[cfg(test)]
51#[cfg(test)]
crates/graph/src/urls.rs +8 −0
@@ -196,6 +196,14 @@ pub fn channel_members(team_id: &str, channel_id: &str) -> String {
196 196 )
197 197 }
198 198
199 pub fn channel_member_list(team_id: &str, channel_id: &str) -> String {
200 format!(
201 "{GRAPH}/v1.0/teams/{}/channels/{}/members?$top=999",
202 segment(team_id),
203 segment(channel_id)
204 )
205 }
206
199 207 pub fn channel_tab(team_id: &str, channel_id: &str, tab_id: &str) -> String {
200 208 format!(
201 209 "{GRAPH}/v1.0/teams/{}/channels/{}/tabs/{}",
@@ -196,6 +196,14 @@ pub fn channel_members(team_id: &str, channel_id: &str) -> String {
196 )
196 )
197}
197}
198
198
199pub fn channel_member_list(team_id: &str, channel_id: &str) -> String {
200 format!(
201 "{GRAPH}/v1.0/teams/{}/channels/{}/members?$top=999",
202 segment(team_id),
203 segment(channel_id)
204 )
205}
206
199pub fn channel_tab(team_id: &str, channel_id: &str, tab_id: &str) -> String {
207pub fn channel_tab(team_id: &str, channel_id: &str, tab_id: &str) -> String {
200 format!(
208 format!(
201 "{GRAPH}/v1.0/teams/{}/channels/{}/tabs/{}",
209 "{GRAPH}/v1.0/teams/{}/channels/{}/tabs/{}",
crates/graph/src/writes.rs +1 −0
@@ -319,6 +319,7 @@ mod tests {
319 319 tenant_id: None,
320 320 display_name: None,
321 321 email: None,
322 roles: Vec::new(),
322 323 }
323 324 }
324 325
@@ -319,6 +319,7 @@ mod tests {
319 tenant_id: None,
319 tenant_id: None,
320 display_name: None,
320 display_name: None,
321 email: None,
321 email: None,
322 roles: Vec::new(),
322 }
323 }
323 }
324 }
324
325