From 44f37afa95a30c4cdfdb7ba22323bf2978bc535b Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 6 May 2022 15:38:02 +0200 Subject: [PATCH] Define data types for the new contacts model Co-Authored-By: Nathan Sobo --- assets/themes/cave-dark.json | 11 +++++++ assets/themes/cave-light.json | 11 +++++++ assets/themes/dark.json | 11 +++++++ assets/themes/light.json | 11 +++++++ assets/themes/solarized-dark.json | 11 +++++++ assets/themes/solarized-light.json | 11 +++++++ assets/themes/sulphurpool-dark.json | 11 +++++++ assets/themes/sulphurpool-light.json | 11 +++++++ .../20220506130724_create_contacts.sql | 10 ++++++ crates/collab/src/rpc.rs | 2 ++ crates/contacts_panel/src/contacts_panel.rs | 8 +++++ crates/rpc/proto/zed.proto | 32 ++++++++++++++++--- crates/theme/src/theme.rs | 1 + styles/src/styleTree/contactsPanel.ts | 6 ++++ 14 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 crates/collab/migrations/20220506130724_create_contacts.sql diff --git a/assets/themes/cave-dark.json b/assets/themes/cave-dark.json index a2e224ed028dab93ce616f56547f04a3c6832b36..92319af4968f4db4fbb6ea6a23e263b624ddce66 100644 --- a/assets/themes/cave-dark.json +++ b/assets/themes/cave-dark.json @@ -1255,6 +1255,17 @@ "left": 8 } }, + "edit_contact": { + "family": "Zed Mono", + "color": "#e2dfe7", + "size": 14, + "background": "#26232a", + "corner_radius": 12, + "padding": { + "left": 7, + "right": 7 + } + }, "header": { "family": "Zed Mono", "color": "#8b8792", diff --git a/assets/themes/cave-light.json b/assets/themes/cave-light.json index 6ec03294ec841481e0166a8cbe27c904859ac6a4..f44069e49f19e6ca55cda82d3224da4caf940ce3 100644 --- a/assets/themes/cave-light.json +++ b/assets/themes/cave-light.json @@ -1255,6 +1255,17 @@ "left": 8 } }, + "edit_contact": { + "family": "Zed Mono", + "color": "#26232a", + "size": 14, + "background": "#e2dfe7", + "corner_radius": 12, + "padding": { + "left": 7, + "right": 7 + } + }, "header": { "family": "Zed Mono", "color": "#585260", diff --git a/assets/themes/dark.json b/assets/themes/dark.json index db72fd965cdfba2794a5a1c10d609755f946548f..f50e590fc42e3c92604c07d8e045bea48e52ac22 100644 --- a/assets/themes/dark.json +++ b/assets/themes/dark.json @@ -1255,6 +1255,17 @@ "left": 8 } }, + "edit_contact": { + "family": "Zed Mono", + "color": "#f1f1f1", + "size": 14, + "background": "#2b2b2b", + "corner_radius": 12, + "padding": { + "left": 7, + "right": 7 + } + }, "header": { "family": "Zed Mono", "color": "#9c9c9c", diff --git a/assets/themes/light.json b/assets/themes/light.json index f8754b7ede1cf33c179ab49cebba4b96aa27dbc6..08d4326414489f132cd78036edb65756c3d810ee 100644 --- a/assets/themes/light.json +++ b/assets/themes/light.json @@ -1255,6 +1255,17 @@ "left": 8 } }, + "edit_contact": { + "family": "Zed Mono", + "color": "#2b2b2b", + "size": 14, + "background": "#eaeaea", + "corner_radius": 12, + "padding": { + "left": 7, + "right": 7 + } + }, "header": { "family": "Zed Mono", "color": "#474747", diff --git a/assets/themes/solarized-dark.json b/assets/themes/solarized-dark.json index c6c9951779b601e9c763abf1d23021e27fcfc046..2b75c4364b124d315fbaed2ad3294e90ee7e6138 100644 --- a/assets/themes/solarized-dark.json +++ b/assets/themes/solarized-dark.json @@ -1255,6 +1255,17 @@ "left": 8 } }, + "edit_contact": { + "family": "Zed Mono", + "color": "#eee8d5", + "size": 14, + "background": "#073642", + "corner_radius": 12, + "padding": { + "left": 7, + "right": 7 + } + }, "header": { "family": "Zed Mono", "color": "#93a1a1", diff --git a/assets/themes/solarized-light.json b/assets/themes/solarized-light.json index 677bba00703e6e772ebde4cebab18bb9c201f6ef..47758db9986751375885d78ed85454129b01d00b 100644 --- a/assets/themes/solarized-light.json +++ b/assets/themes/solarized-light.json @@ -1255,6 +1255,17 @@ "left": 8 } }, + "edit_contact": { + "family": "Zed Mono", + "color": "#073642", + "size": 14, + "background": "#eee8d5", + "corner_radius": 12, + "padding": { + "left": 7, + "right": 7 + } + }, "header": { "family": "Zed Mono", "color": "#586e75", diff --git a/assets/themes/sulphurpool-dark.json b/assets/themes/sulphurpool-dark.json index b603dccb8d100cf56269df1fa4dacde9d77798b4..38761d606eb156fe3ea3043ee26f9c10108df09b 100644 --- a/assets/themes/sulphurpool-dark.json +++ b/assets/themes/sulphurpool-dark.json @@ -1255,6 +1255,17 @@ "left": 8 } }, + "edit_contact": { + "family": "Zed Mono", + "color": "#dfe2f1", + "size": 14, + "background": "#293256", + "corner_radius": 12, + "padding": { + "left": 7, + "right": 7 + } + }, "header": { "family": "Zed Mono", "color": "#979db4", diff --git a/assets/themes/sulphurpool-light.json b/assets/themes/sulphurpool-light.json index 3f4983c083f32502184d87d1b23fb651b1e3af87..6d3aeadd5fea179c37130af69adff503b1a06cb3 100644 --- a/assets/themes/sulphurpool-light.json +++ b/assets/themes/sulphurpool-light.json @@ -1255,6 +1255,17 @@ "left": 8 } }, + "edit_contact": { + "family": "Zed Mono", + "color": "#293256", + "size": 14, + "background": "#dfe2f1", + "corner_radius": 12, + "padding": { + "left": 7, + "right": 7 + } + }, "header": { "family": "Zed Mono", "color": "#5e6687", diff --git a/crates/collab/migrations/20220506130724_create_contacts.sql b/crates/collab/migrations/20220506130724_create_contacts.sql new file mode 100644 index 0000000000000000000000000000000000000000..a292674ac47b0c3cb8536f68d53fe25d3364b2ac --- /dev/null +++ b/crates/collab/migrations/20220506130724_create_contacts.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS "contacts" ( + "id" SERIAL PRIMARY KEY, + "requesting_user_id" INTEGER REFERENCES users (id) NOT NULL, + "receiving_user_id" INTEGER REFERENCES users (id) NOT NULL, + "accepted" BOOLEAN NOT NULL, + "blocked" BOOLEAN NOT NULL +); + +CREATE UNIQUE INDEX "index_org_contacts_requesting_user_id_and_receiving_user_id" ON "contacts" ("requesting_user_id", "receiving_user_id"); +CREATE UNIQUE INDEX "index_org_contacts_receiving_user" ON "contacts" ("receiving_user_id"); diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index 46ca033ee2ae43a289c35b3146f17161ed864e9a..9813de7aad69b8f73e792968333d94f074c552f6 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -905,6 +905,8 @@ impl Server { connection_id, proto::UpdateContacts { contacts: contacts.clone(), + pending_requests_from_user_ids: Default::default(), + pending_requests_to_user_ids: Default::default(), }, ) .trace_err(); diff --git a/crates/contacts_panel/src/contacts_panel.rs b/crates/contacts_panel/src/contacts_panel.rs index 4923e1aa8005f5812e5e625f07276992d606eee8..7c187ba7eeb8e6562d928c6fd1c3992c12f64d20 100644 --- a/crates/contacts_panel/src/contacts_panel.rs +++ b/crates/contacts_panel/src/contacts_panel.rs @@ -298,6 +298,14 @@ impl ContactsPanel { .left() .boxed(), ) + .with_child( + Label::new("+".to_string(), theme.edit_contact.text.clone()) + .contained() + .with_style(theme.edit_contact.container) + .aligned() + .flex_float() + .boxed(), + ) .constrained() .with_height(theme.row_height) .boxed() diff --git a/crates/rpc/proto/zed.proto b/crates/rpc/proto/zed.proto index 267dcb0ba99be66bed2967592600fc8474c1f44c..73f08345f6fd1c4c3d083b4751bfac8563ae0822 100644 --- a/crates/rpc/proto/zed.proto +++ b/crates/rpc/proto/zed.proto @@ -89,11 +89,13 @@ message Envelope { GetUsers get_users = 76; FuzzySearchUsers fuzzy_search_users = 77; UsersResponse users_response = 78; + RequestContact request_contact = 79; + RespondToContactRequest respond_to_contact_request = 80; - Follow follow = 79; - FollowResponse follow_response = 80; - UpdateFollowers update_followers = 81; - Unfollow unfollow = 82; + Follow follow = 81; + FollowResponse follow_response = 82; + UpdateFollowers update_followers = 83; + Unfollow unfollow = 84; } } @@ -547,6 +549,21 @@ message UsersResponse { repeated User users = 1; } +message RequestContact { + uint64 to_user_id = 1; +} + +message RespondToContactRequest { + uint64 requesting_user_id = 1; + ContactRequestResponse response = 2; +} + +enum ContactRequestResponse { + Accept = 0; + Reject = 1; + Block = 2; +} + message SendChannelMessage { uint64 channel_id = 1; string body = 2; @@ -574,6 +591,13 @@ message GetChannelMessagesResponse { message UpdateContacts { repeated Contact contacts = 1; + repeated IncomingContactRequest pending_requests_from_user_ids = 2; + repeated uint64 pending_requests_to_user_ids = 3; +} + +message IncomingContactRequest { + uint64 user_id = 1; + bool show_notification = 2; } message UpdateDiagnostics { diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 241cbc86738c30c11a34d0e88995ed95b2df83bb..1f320bd24ce173151b76d76d97ab326e18f536e9 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -239,6 +239,7 @@ pub struct ContactsPanel { pub row_height: f32, pub contact_avatar: ImageStyle, pub contact_username: ContainedText, + pub edit_contact: ContainedText, pub tree_branch_width: f32, pub tree_branch_color: Color, pub shared_project: ProjectRow, diff --git a/styles/src/styleTree/contactsPanel.ts b/styles/src/styleTree/contactsPanel.ts index dbcc9e4ccaa15380a5ca713c668a95eafa65ec75..237913c37e91494c72002d3a73785871f23ace5f 100644 --- a/styles/src/styleTree/contactsPanel.ts +++ b/styles/src/styleTree/contactsPanel.ts @@ -60,6 +60,12 @@ export default function(theme: Theme) { left: 8, }, }, + editContact: { + ...text(theme, "mono", "primary", { size: "sm" }), + background: backgroundColor(theme, 100), + cornerRadius: 12, + padding: { left: 7, right: 7 } + }, header: { ...text(theme, "mono", "secondary", { size: "sm" }), // padding: {