mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-27 09:02:26 +03:00
Merge pull request #1001 from zed-industries/request-to-join-project
Request to join projects instead of sharing/unsharing
This commit is contained in:
commit
ad94b4cc73
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -768,6 +768,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"async-recursion",
|
"async-recursion",
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
|
"collections",
|
||||||
"futures",
|
"futures",
|
||||||
"gpui",
|
"gpui",
|
||||||
"image",
|
"image",
|
||||||
@ -3404,6 +3405,7 @@ dependencies = [
|
|||||||
"sum_tree",
|
"sum_tree",
|
||||||
"tempdir",
|
"tempdir",
|
||||||
"text",
|
"text",
|
||||||
|
"thiserror",
|
||||||
"toml",
|
"toml",
|
||||||
"unindent",
|
"unindent",
|
||||||
"util",
|
"util",
|
||||||
|
@ -90,6 +90,16 @@
|
|||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
"background": "#26232a",
|
"background": "#26232a",
|
||||||
|
"joining_project_avatar": {
|
||||||
|
"corner_radius": 40,
|
||||||
|
"width": 80
|
||||||
|
},
|
||||||
|
"joining_project_message": {
|
||||||
|
"padding": 12,
|
||||||
|
"family": "Zed Sans",
|
||||||
|
"color": "#e2dfe7",
|
||||||
|
"size": 18
|
||||||
|
},
|
||||||
"leader_border_opacity": 0.7,
|
"leader_border_opacity": 0.7,
|
||||||
"leader_border_width": 2,
|
"leader_border_width": 2,
|
||||||
"tab": {
|
"tab": {
|
||||||
@ -1359,41 +1369,7 @@
|
|||||||
"button_width": 16,
|
"button_width": 16,
|
||||||
"corner_radius": 8
|
"corner_radius": 8
|
||||||
},
|
},
|
||||||
"shared_project_row": {
|
"project_row": {
|
||||||
"guest_avatar_spacing": 4,
|
|
||||||
"height": 24,
|
|
||||||
"guest_avatar": {
|
|
||||||
"corner_radius": 8,
|
|
||||||
"width": 14
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"family": "Zed Mono",
|
|
||||||
"color": "#8b8792",
|
|
||||||
"size": 14,
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 6
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"guests": {
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 8
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"padding": {
|
|
||||||
"left": 12,
|
|
||||||
"right": 12
|
|
||||||
},
|
|
||||||
"background": "#26232a",
|
|
||||||
"hover": {
|
|
||||||
"background": "#332f38"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"background": "#3f3b45"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"unshared_project_row": {
|
|
||||||
"guest_avatar_spacing": 4,
|
"guest_avatar_spacing": 4,
|
||||||
"height": 24,
|
"height": 24,
|
||||||
"guest_avatar": {
|
"guest_avatar": {
|
||||||
|
@ -90,6 +90,16 @@
|
|||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
"background": "#e2dfe7",
|
"background": "#e2dfe7",
|
||||||
|
"joining_project_avatar": {
|
||||||
|
"corner_radius": 40,
|
||||||
|
"width": 80
|
||||||
|
},
|
||||||
|
"joining_project_message": {
|
||||||
|
"padding": 12,
|
||||||
|
"family": "Zed Sans",
|
||||||
|
"color": "#26232a",
|
||||||
|
"size": 18
|
||||||
|
},
|
||||||
"leader_border_opacity": 0.7,
|
"leader_border_opacity": 0.7,
|
||||||
"leader_border_width": 2,
|
"leader_border_width": 2,
|
||||||
"tab": {
|
"tab": {
|
||||||
@ -1359,41 +1369,7 @@
|
|||||||
"button_width": 16,
|
"button_width": 16,
|
||||||
"corner_radius": 8
|
"corner_radius": 8
|
||||||
},
|
},
|
||||||
"shared_project_row": {
|
"project_row": {
|
||||||
"guest_avatar_spacing": 4,
|
|
||||||
"height": 24,
|
|
||||||
"guest_avatar": {
|
|
||||||
"corner_radius": 8,
|
|
||||||
"width": 14
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"family": "Zed Mono",
|
|
||||||
"color": "#585260",
|
|
||||||
"size": 14,
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 6
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"guests": {
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 8
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"padding": {
|
|
||||||
"left": 12,
|
|
||||||
"right": 12
|
|
||||||
},
|
|
||||||
"background": "#e2dfe7",
|
|
||||||
"hover": {
|
|
||||||
"background": "#ccc9d2"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"background": "#b7b3bd"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"unshared_project_row": {
|
|
||||||
"guest_avatar_spacing": 4,
|
"guest_avatar_spacing": 4,
|
||||||
"height": 24,
|
"height": 24,
|
||||||
"guest_avatar": {
|
"guest_avatar": {
|
||||||
|
@ -90,6 +90,16 @@
|
|||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
"background": "#073642",
|
"background": "#073642",
|
||||||
|
"joining_project_avatar": {
|
||||||
|
"corner_radius": 40,
|
||||||
|
"width": 80
|
||||||
|
},
|
||||||
|
"joining_project_message": {
|
||||||
|
"padding": 12,
|
||||||
|
"family": "Zed Sans",
|
||||||
|
"color": "#eee8d5",
|
||||||
|
"size": 18
|
||||||
|
},
|
||||||
"leader_border_opacity": 0.7,
|
"leader_border_opacity": 0.7,
|
||||||
"leader_border_width": 2,
|
"leader_border_width": 2,
|
||||||
"tab": {
|
"tab": {
|
||||||
@ -1359,41 +1369,7 @@
|
|||||||
"button_width": 16,
|
"button_width": 16,
|
||||||
"corner_radius": 8
|
"corner_radius": 8
|
||||||
},
|
},
|
||||||
"shared_project_row": {
|
"project_row": {
|
||||||
"guest_avatar_spacing": 4,
|
|
||||||
"height": 24,
|
|
||||||
"guest_avatar": {
|
|
||||||
"corner_radius": 8,
|
|
||||||
"width": 14
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"family": "Zed Mono",
|
|
||||||
"color": "#93a1a1",
|
|
||||||
"size": 14,
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 6
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"guests": {
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 8
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"padding": {
|
|
||||||
"left": 12,
|
|
||||||
"right": 12
|
|
||||||
},
|
|
||||||
"background": "#073642",
|
|
||||||
"hover": {
|
|
||||||
"background": "#1b444f"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"background": "#30525c"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"unshared_project_row": {
|
|
||||||
"guest_avatar_spacing": 4,
|
"guest_avatar_spacing": 4,
|
||||||
"height": 24,
|
"height": 24,
|
||||||
"guest_avatar": {
|
"guest_avatar": {
|
||||||
|
@ -90,6 +90,16 @@
|
|||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
"background": "#eee8d5",
|
"background": "#eee8d5",
|
||||||
|
"joining_project_avatar": {
|
||||||
|
"corner_radius": 40,
|
||||||
|
"width": 80
|
||||||
|
},
|
||||||
|
"joining_project_message": {
|
||||||
|
"padding": 12,
|
||||||
|
"family": "Zed Sans",
|
||||||
|
"color": "#073642",
|
||||||
|
"size": 18
|
||||||
|
},
|
||||||
"leader_border_opacity": 0.7,
|
"leader_border_opacity": 0.7,
|
||||||
"leader_border_width": 2,
|
"leader_border_width": 2,
|
||||||
"tab": {
|
"tab": {
|
||||||
@ -1359,41 +1369,7 @@
|
|||||||
"button_width": 16,
|
"button_width": 16,
|
||||||
"corner_radius": 8
|
"corner_radius": 8
|
||||||
},
|
},
|
||||||
"shared_project_row": {
|
"project_row": {
|
||||||
"guest_avatar_spacing": 4,
|
|
||||||
"height": 24,
|
|
||||||
"guest_avatar": {
|
|
||||||
"corner_radius": 8,
|
|
||||||
"width": 14
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"family": "Zed Mono",
|
|
||||||
"color": "#586e75",
|
|
||||||
"size": 14,
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 6
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"guests": {
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 8
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"padding": {
|
|
||||||
"left": 12,
|
|
||||||
"right": 12
|
|
||||||
},
|
|
||||||
"background": "#eee8d5",
|
|
||||||
"hover": {
|
|
||||||
"background": "#d7d6c8"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"background": "#c1c5bb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"unshared_project_row": {
|
|
||||||
"guest_avatar_spacing": 4,
|
"guest_avatar_spacing": 4,
|
||||||
"height": 24,
|
"height": 24,
|
||||||
"guest_avatar": {
|
"guest_avatar": {
|
||||||
|
@ -90,6 +90,16 @@
|
|||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
"background": "#293256",
|
"background": "#293256",
|
||||||
|
"joining_project_avatar": {
|
||||||
|
"corner_radius": 40,
|
||||||
|
"width": 80
|
||||||
|
},
|
||||||
|
"joining_project_message": {
|
||||||
|
"padding": 12,
|
||||||
|
"family": "Zed Sans",
|
||||||
|
"color": "#dfe2f1",
|
||||||
|
"size": 18
|
||||||
|
},
|
||||||
"leader_border_opacity": 0.7,
|
"leader_border_opacity": 0.7,
|
||||||
"leader_border_width": 2,
|
"leader_border_width": 2,
|
||||||
"tab": {
|
"tab": {
|
||||||
@ -1359,41 +1369,7 @@
|
|||||||
"button_width": 16,
|
"button_width": 16,
|
||||||
"corner_radius": 8
|
"corner_radius": 8
|
||||||
},
|
},
|
||||||
"shared_project_row": {
|
"project_row": {
|
||||||
"guest_avatar_spacing": 4,
|
|
||||||
"height": 24,
|
|
||||||
"guest_avatar": {
|
|
||||||
"corner_radius": 8,
|
|
||||||
"width": 14
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"family": "Zed Mono",
|
|
||||||
"color": "#979db4",
|
|
||||||
"size": 14,
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 6
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"guests": {
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 8
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"padding": {
|
|
||||||
"left": 12,
|
|
||||||
"right": 12
|
|
||||||
},
|
|
||||||
"background": "#293256",
|
|
||||||
"hover": {
|
|
||||||
"background": "#363f62"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"background": "#444c6f"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"unshared_project_row": {
|
|
||||||
"guest_avatar_spacing": 4,
|
"guest_avatar_spacing": 4,
|
||||||
"height": 24,
|
"height": 24,
|
||||||
"guest_avatar": {
|
"guest_avatar": {
|
||||||
|
@ -90,6 +90,16 @@
|
|||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
"background": "#dfe2f1",
|
"background": "#dfe2f1",
|
||||||
|
"joining_project_avatar": {
|
||||||
|
"corner_radius": 40,
|
||||||
|
"width": 80
|
||||||
|
},
|
||||||
|
"joining_project_message": {
|
||||||
|
"padding": 12,
|
||||||
|
"family": "Zed Sans",
|
||||||
|
"color": "#293256",
|
||||||
|
"size": 18
|
||||||
|
},
|
||||||
"leader_border_opacity": 0.7,
|
"leader_border_opacity": 0.7,
|
||||||
"leader_border_width": 2,
|
"leader_border_width": 2,
|
||||||
"tab": {
|
"tab": {
|
||||||
@ -1359,41 +1369,7 @@
|
|||||||
"button_width": 16,
|
"button_width": 16,
|
||||||
"corner_radius": 8
|
"corner_radius": 8
|
||||||
},
|
},
|
||||||
"shared_project_row": {
|
"project_row": {
|
||||||
"guest_avatar_spacing": 4,
|
|
||||||
"height": 24,
|
|
||||||
"guest_avatar": {
|
|
||||||
"corner_radius": 8,
|
|
||||||
"width": 14
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"family": "Zed Mono",
|
|
||||||
"color": "#5e6687",
|
|
||||||
"size": 14,
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 6
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"guests": {
|
|
||||||
"margin": {
|
|
||||||
"left": 8,
|
|
||||||
"right": 8
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"padding": {
|
|
||||||
"left": 12,
|
|
||||||
"right": 12
|
|
||||||
},
|
|
||||||
"background": "#dfe2f1",
|
|
||||||
"hover": {
|
|
||||||
"background": "#cdd1e2"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"background": "#bbc0d3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"unshared_project_row": {
|
|
||||||
"guest_avatar_spacing": 4,
|
"guest_avatar_spacing": 4,
|
||||||
"height": 24,
|
"height": 24,
|
||||||
"guest_avatar": {
|
"guest_avatar": {
|
||||||
|
@ -8,9 +8,10 @@ path = "src/client.rs"
|
|||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = ["gpui/test-support", "rpc/test-support"]
|
test-support = ["collections/test-support", "gpui/test-support", "rpc/test-support"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
collections = { path = "../collections" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
rpc = { path = "../rpc" }
|
rpc = { path = "../rpc" }
|
||||||
@ -33,5 +34,6 @@ tiny_http = "0.8"
|
|||||||
url = "2.2"
|
url = "2.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
collections = { path = "../collections", features = ["test-support"] }
|
||||||
gpui = { path = "../gpui", features = ["test-support"] }
|
gpui = { path = "../gpui", features = ["test-support"] }
|
||||||
rpc = { path = "../rpc", features = ["test-support"] }
|
rpc = { path = "../rpc", features = ["test-support"] }
|
||||||
|
@ -1106,7 +1106,7 @@ mod tests {
|
|||||||
let (done_tx1, mut done_rx1) = smol::channel::unbounded();
|
let (done_tx1, mut done_rx1) = smol::channel::unbounded();
|
||||||
let (done_tx2, mut done_rx2) = smol::channel::unbounded();
|
let (done_tx2, mut done_rx2) = smol::channel::unbounded();
|
||||||
client.add_model_message_handler(
|
client.add_model_message_handler(
|
||||||
move |model: ModelHandle<Model>, _: TypedEnvelope<proto::UnshareProject>, _, cx| {
|
move |model: ModelHandle<Model>, _: TypedEnvelope<proto::JoinProject>, _, cx| {
|
||||||
match model.read_with(&cx, |model, _| model.id) {
|
match model.read_with(&cx, |model, _| model.id) {
|
||||||
1 => done_tx1.try_send(()).unwrap(),
|
1 => done_tx1.try_send(()).unwrap(),
|
||||||
2 => done_tx2.try_send(()).unwrap(),
|
2 => done_tx2.try_send(()).unwrap(),
|
||||||
@ -1135,8 +1135,8 @@ mod tests {
|
|||||||
let subscription3 = model3.update(cx, |_, cx| client.add_model_for_remote_entity(3, cx));
|
let subscription3 = model3.update(cx, |_, cx| client.add_model_for_remote_entity(3, cx));
|
||||||
drop(subscription3);
|
drop(subscription3);
|
||||||
|
|
||||||
server.send(proto::UnshareProject { project_id: 1 });
|
server.send(proto::JoinProject { project_id: 1 });
|
||||||
server.send(proto::UnshareProject { project_id: 2 });
|
server.send(proto::JoinProject { project_id: 2 });
|
||||||
done_rx1.next().await.unwrap();
|
done_rx1.next().await.unwrap();
|
||||||
done_rx2.next().await.unwrap();
|
done_rx2.next().await.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
use super::{http::HttpClient, proto, Client, Status, TypedEnvelope};
|
use super::{http::HttpClient, proto, Client, Status, TypedEnvelope};
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
|
use collections::{hash_map::Entry, BTreeSet, HashMap, HashSet};
|
||||||
use futures::{channel::mpsc, future, AsyncReadExt, Future, StreamExt};
|
use futures::{channel::mpsc, future, AsyncReadExt, Future, StreamExt};
|
||||||
use gpui::{AsyncAppContext, Entity, ImageData, ModelContext, ModelHandle, Task};
|
use gpui::{AsyncAppContext, Entity, ImageData, ModelContext, ModelHandle, Task};
|
||||||
use postage::{prelude::Stream, sink::Sink, watch};
|
use postage::{prelude::Stream, sink::Sink, watch};
|
||||||
use rpc::proto::{RequestMessage, UsersResponse};
|
use rpc::proto::{RequestMessage, UsersResponse};
|
||||||
use std::{
|
use std::sync::{Arc, Weak};
|
||||||
collections::{hash_map::Entry, HashMap, HashSet},
|
|
||||||
sync::{Arc, Weak},
|
|
||||||
};
|
|
||||||
use util::TryFutureExt as _;
|
use util::TryFutureExt as _;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -17,6 +15,26 @@ pub struct User {
|
|||||||
pub avatar: Option<Arc<ImageData>>,
|
pub avatar: Option<Arc<ImageData>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for User {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
|
Some(self.cmp(&other))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for User {
|
||||||
|
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||||
|
self.github_login.cmp(&other.github_login)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for User {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.id == other.id && self.github_login == other.github_login
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Eq for User {}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Contact {
|
pub struct Contact {
|
||||||
pub user: Arc<User>,
|
pub user: Arc<User>,
|
||||||
@ -27,9 +45,8 @@ pub struct Contact {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ProjectMetadata {
|
pub struct ProjectMetadata {
|
||||||
pub id: u64,
|
pub id: u64,
|
||||||
pub is_shared: bool,
|
|
||||||
pub worktree_root_names: Vec<String>,
|
pub worktree_root_names: Vec<String>,
|
||||||
pub guests: Vec<Arc<User>>,
|
pub guests: BTreeSet<Arc<User>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
@ -170,7 +187,7 @@ impl UserStore {
|
|||||||
self.client.upgrade().unwrap().id,
|
self.client.upgrade().unwrap().id,
|
||||||
message
|
message
|
||||||
);
|
);
|
||||||
let mut user_ids = HashSet::new();
|
let mut user_ids = HashSet::default();
|
||||||
for contact in &message.contacts {
|
for contact in &message.contacts {
|
||||||
user_ids.insert(contact.user_id);
|
user_ids.insert(contact.user_id);
|
||||||
user_ids.extend(contact.projects.iter().flat_map(|w| &w.guests).copied());
|
user_ids.extend(contact.projects.iter().flat_map(|w| &w.guests).copied());
|
||||||
@ -547,9 +564,9 @@ impl Contact {
|
|||||||
.await?;
|
.await?;
|
||||||
let mut projects = Vec::new();
|
let mut projects = Vec::new();
|
||||||
for project in contact.projects {
|
for project in contact.projects {
|
||||||
let mut guests = Vec::new();
|
let mut guests = BTreeSet::new();
|
||||||
for participant_id in project.guests {
|
for participant_id in project.guests {
|
||||||
guests.push(
|
guests.insert(
|
||||||
user_store
|
user_store
|
||||||
.update(cx, |user_store, cx| {
|
.update(cx, |user_store, cx| {
|
||||||
user_store.fetch_user(participant_id, cx)
|
user_store.fetch_user(participant_id, cx)
|
||||||
@ -560,7 +577,6 @@ impl Contact {
|
|||||||
projects.push(ProjectMetadata {
|
projects.push(ProjectMetadata {
|
||||||
id: project.id,
|
id: project.id,
|
||||||
worktree_root_names: project.worktree_root_names.clone(),
|
worktree_root_names: project.worktree_root_names.clone(),
|
||||||
is_shared: project.is_shared,
|
|
||||||
guests,
|
guests,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,8 @@
|
|||||||
use crate::db::{self, ChannelId, UserId};
|
use crate::db::{self, ChannelId, UserId};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use collections::{BTreeMap, HashMap, HashSet};
|
use collections::{hash_map::Entry, BTreeMap, HashMap, HashSet};
|
||||||
use rpc::{proto, ConnectionId};
|
use rpc::{proto, ConnectionId, Receipt};
|
||||||
use std::{collections::hash_map, path::PathBuf};
|
use std::{collections::hash_map, mem, path::PathBuf};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -17,31 +17,24 @@ pub struct Store {
|
|||||||
struct ConnectionState {
|
struct ConnectionState {
|
||||||
user_id: UserId,
|
user_id: UserId,
|
||||||
projects: HashSet<u64>,
|
projects: HashSet<u64>,
|
||||||
|
requested_projects: HashSet<u64>,
|
||||||
channels: HashSet<ChannelId>,
|
channels: HashSet<ChannelId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Project {
|
pub struct Project {
|
||||||
pub host_connection_id: ConnectionId,
|
pub host_connection_id: ConnectionId,
|
||||||
pub host_user_id: UserId,
|
pub host_user_id: UserId,
|
||||||
pub share: Option<ProjectShare>,
|
pub guests: HashMap<ConnectionId, (ReplicaId, UserId)>,
|
||||||
|
pub join_requests: HashMap<UserId, Vec<Receipt<proto::JoinProject>>>,
|
||||||
|
pub active_replica_ids: HashSet<ReplicaId>,
|
||||||
pub worktrees: HashMap<u64, Worktree>,
|
pub worktrees: HashMap<u64, Worktree>,
|
||||||
pub language_servers: Vec<proto::LanguageServer>,
|
pub language_servers: Vec<proto::LanguageServer>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Worktree {
|
pub struct Worktree {
|
||||||
pub root_name: String,
|
pub root_name: String,
|
||||||
pub visible: bool,
|
pub visible: bool,
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct ProjectShare {
|
|
||||||
pub guests: HashMap<ConnectionId, (ReplicaId, UserId)>,
|
|
||||||
pub active_replica_ids: HashSet<ReplicaId>,
|
|
||||||
pub worktrees: HashMap<u64, WorktreeShare>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct WorktreeShare {
|
|
||||||
pub entries: HashMap<u64, proto::Entry>,
|
pub entries: HashMap<u64, proto::Entry>,
|
||||||
pub diagnostic_summaries: BTreeMap<PathBuf, proto::DiagnosticSummary>,
|
pub diagnostic_summaries: BTreeMap<PathBuf, proto::DiagnosticSummary>,
|
||||||
pub scan_id: u64,
|
pub scan_id: u64,
|
||||||
@ -58,25 +51,17 @@ pub type ReplicaId = u16;
|
|||||||
pub struct RemovedConnectionState {
|
pub struct RemovedConnectionState {
|
||||||
pub user_id: UserId,
|
pub user_id: UserId,
|
||||||
pub hosted_projects: HashMap<u64, Project>,
|
pub hosted_projects: HashMap<u64, Project>,
|
||||||
pub guest_project_ids: HashMap<u64, Vec<ConnectionId>>,
|
pub guest_project_ids: HashSet<u64>,
|
||||||
pub contact_ids: HashSet<UserId>,
|
pub contact_ids: HashSet<UserId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct JoinedProject<'a> {
|
|
||||||
pub replica_id: ReplicaId,
|
|
||||||
pub project: &'a Project,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct SharedProject {}
|
|
||||||
|
|
||||||
pub struct UnsharedProject {
|
|
||||||
pub connection_ids: Vec<ConnectionId>,
|
|
||||||
pub host_user_id: UserId,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct LeftProject {
|
pub struct LeftProject {
|
||||||
pub connection_ids: Vec<ConnectionId>,
|
|
||||||
pub host_user_id: UserId,
|
pub host_user_id: UserId,
|
||||||
|
pub host_connection_id: ConnectionId,
|
||||||
|
pub connection_ids: Vec<ConnectionId>,
|
||||||
|
pub remove_collaborator: bool,
|
||||||
|
pub cancel_request: Option<UserId>,
|
||||||
|
pub unshare: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
@ -93,7 +78,7 @@ impl Store {
|
|||||||
let mut shared_projects = 0;
|
let mut shared_projects = 0;
|
||||||
for project in self.projects.values() {
|
for project in self.projects.values() {
|
||||||
registered_projects += 1;
|
registered_projects += 1;
|
||||||
if project.share.is_some() {
|
if !project.guests.is_empty() {
|
||||||
shared_projects += 1;
|
shared_projects += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,6 +97,7 @@ impl Store {
|
|||||||
ConnectionState {
|
ConnectionState {
|
||||||
user_id,
|
user_id,
|
||||||
projects: Default::default(),
|
projects: Default::default(),
|
||||||
|
requested_projects: Default::default(),
|
||||||
channels: Default::default(),
|
channels: Default::default(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -126,39 +112,40 @@ impl Store {
|
|||||||
&mut self,
|
&mut self,
|
||||||
connection_id: ConnectionId,
|
connection_id: ConnectionId,
|
||||||
) -> Result<RemovedConnectionState> {
|
) -> Result<RemovedConnectionState> {
|
||||||
let connection = if let Some(connection) = self.connections.remove(&connection_id) {
|
let connection = self
|
||||||
connection
|
.connections
|
||||||
} else {
|
.get_mut(&connection_id)
|
||||||
return Err(anyhow!("no such connection"))?;
|
.ok_or_else(|| anyhow!("no such connection"))?;
|
||||||
};
|
|
||||||
|
|
||||||
for channel_id in &connection.channels {
|
let user_id = connection.user_id;
|
||||||
if let Some(channel) = self.channels.get_mut(&channel_id) {
|
let connection_projects = mem::take(&mut connection.projects);
|
||||||
channel.connection_ids.remove(&connection_id);
|
let connection_channels = mem::take(&mut connection.channels);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let user_connections = self
|
|
||||||
.connections_by_user_id
|
|
||||||
.get_mut(&connection.user_id)
|
|
||||||
.unwrap();
|
|
||||||
user_connections.remove(&connection_id);
|
|
||||||
if user_connections.is_empty() {
|
|
||||||
self.connections_by_user_id.remove(&connection.user_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut result = RemovedConnectionState::default();
|
let mut result = RemovedConnectionState::default();
|
||||||
result.user_id = connection.user_id;
|
result.user_id = user_id;
|
||||||
for project_id in connection.projects.clone() {
|
|
||||||
|
// Leave all channels.
|
||||||
|
for channel_id in connection_channels {
|
||||||
|
self.leave_channel(connection_id, channel_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unregister and leave all projects.
|
||||||
|
for project_id in connection_projects {
|
||||||
if let Ok(project) = self.unregister_project(project_id, connection_id) {
|
if let Ok(project) = self.unregister_project(project_id, connection_id) {
|
||||||
result.hosted_projects.insert(project_id, project);
|
result.hosted_projects.insert(project_id, project);
|
||||||
} else if let Ok(project) = self.leave_project(connection_id, project_id) {
|
} else if self.leave_project(connection_id, project_id).is_ok() {
|
||||||
result
|
result.guest_project_ids.insert(project_id);
|
||||||
.guest_project_ids
|
|
||||||
.insert(project_id, project.connection_ids);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let user_connections = self.connections_by_user_id.get_mut(&user_id).unwrap();
|
||||||
|
user_connections.remove(&connection_id);
|
||||||
|
if user_connections.is_empty() {
|
||||||
|
self.connections_by_user_id.remove(&user_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.connections.remove(&connection_id).unwrap();
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,18 +262,15 @@ impl Store {
|
|||||||
if project.host_user_id == user_id {
|
if project.host_user_id == user_id {
|
||||||
metadata.push(proto::ProjectMetadata {
|
metadata.push(proto::ProjectMetadata {
|
||||||
id: project_id,
|
id: project_id,
|
||||||
is_shared: project.share.is_some(),
|
|
||||||
worktree_root_names: project
|
worktree_root_names: project
|
||||||
.worktrees
|
.worktrees
|
||||||
.values()
|
.values()
|
||||||
.map(|worktree| worktree.root_name.clone())
|
.map(|worktree| worktree.root_name.clone())
|
||||||
.collect(),
|
.collect(),
|
||||||
guests: project
|
guests: project
|
||||||
.share
|
.guests
|
||||||
.iter()
|
.values()
|
||||||
.flat_map(|share| {
|
.map(|(_, user_id)| user_id.to_proto())
|
||||||
share.guests.values().map(|(_, user_id)| user_id.to_proto())
|
|
||||||
})
|
|
||||||
.collect(),
|
.collect(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -307,7 +291,9 @@ impl Store {
|
|||||||
Project {
|
Project {
|
||||||
host_connection_id,
|
host_connection_id,
|
||||||
host_user_id,
|
host_user_id,
|
||||||
share: None,
|
guests: Default::default(),
|
||||||
|
join_requests: Default::default(),
|
||||||
|
active_replica_ids: Default::default(),
|
||||||
worktrees: Default::default(),
|
worktrees: Default::default(),
|
||||||
language_servers: Default::default(),
|
language_servers: Default::default(),
|
||||||
},
|
},
|
||||||
@ -332,10 +318,6 @@ impl Store {
|
|||||||
.ok_or_else(|| anyhow!("no such project"))?;
|
.ok_or_else(|| anyhow!("no such project"))?;
|
||||||
if project.host_connection_id == connection_id {
|
if project.host_connection_id == connection_id {
|
||||||
project.worktrees.insert(worktree_id, worktree);
|
project.worktrees.insert(worktree_id, worktree);
|
||||||
if let Ok(share) = project.share_mut() {
|
|
||||||
share.worktrees.insert(worktree_id, Default::default());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(anyhow!("no such project"))?
|
Err(anyhow!("no such project"))?
|
||||||
@ -356,10 +338,22 @@ impl Store {
|
|||||||
host_connection.projects.remove(&project_id);
|
host_connection.projects.remove(&project_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(share) = &project.share {
|
for guest_connection in project.guests.keys() {
|
||||||
for guest_connection in share.guests.keys() {
|
if let Some(connection) = self.connections.get_mut(&guest_connection) {
|
||||||
if let Some(connection) = self.connections.get_mut(&guest_connection) {
|
connection.projects.remove(&project_id);
|
||||||
connection.projects.remove(&project_id);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for requester_user_id in project.join_requests.keys() {
|
||||||
|
if let Some(requester_connection_ids) =
|
||||||
|
self.connections_by_user_id.get_mut(&requester_user_id)
|
||||||
|
{
|
||||||
|
for requester_connection_id in requester_connection_ids.iter() {
|
||||||
|
if let Some(requester_connection) =
|
||||||
|
self.connections.get_mut(requester_connection_id)
|
||||||
|
{
|
||||||
|
requester_connection.requested_projects.remove(&project_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,64 +385,7 @@ impl Store {
|
|||||||
.worktrees
|
.worktrees
|
||||||
.remove(&worktree_id)
|
.remove(&worktree_id)
|
||||||
.ok_or_else(|| anyhow!("no such worktree"))?;
|
.ok_or_else(|| anyhow!("no such worktree"))?;
|
||||||
|
Ok((worktree, project.guest_connection_ids()))
|
||||||
let mut guest_connection_ids = Vec::new();
|
|
||||||
if let Ok(share) = project.share_mut() {
|
|
||||||
guest_connection_ids.extend(share.guests.keys());
|
|
||||||
share.worktrees.remove(&worktree_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok((worktree, guest_connection_ids))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn share_project(
|
|
||||||
&mut self,
|
|
||||||
project_id: u64,
|
|
||||||
connection_id: ConnectionId,
|
|
||||||
) -> Result<SharedProject> {
|
|
||||||
if let Some(project) = self.projects.get_mut(&project_id) {
|
|
||||||
if project.host_connection_id == connection_id {
|
|
||||||
let mut share = ProjectShare::default();
|
|
||||||
for worktree_id in project.worktrees.keys() {
|
|
||||||
share.worktrees.insert(*worktree_id, Default::default());
|
|
||||||
}
|
|
||||||
project.share = Some(share);
|
|
||||||
return Ok(SharedProject {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(anyhow!("no such project"))?
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn unshare_project(
|
|
||||||
&mut self,
|
|
||||||
project_id: u64,
|
|
||||||
acting_connection_id: ConnectionId,
|
|
||||||
) -> Result<UnsharedProject> {
|
|
||||||
let project = if let Some(project) = self.projects.get_mut(&project_id) {
|
|
||||||
project
|
|
||||||
} else {
|
|
||||||
return Err(anyhow!("no such project"))?;
|
|
||||||
};
|
|
||||||
|
|
||||||
if project.host_connection_id != acting_connection_id {
|
|
||||||
return Err(anyhow!("not your project"))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let connection_ids = project.connection_ids();
|
|
||||||
if let Some(share) = project.share.take() {
|
|
||||||
for connection_id in share.guests.into_keys() {
|
|
||||||
if let Some(connection) = self.connections.get_mut(&connection_id) {
|
|
||||||
connection.projects.remove(&project_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(UnsharedProject {
|
|
||||||
connection_ids,
|
|
||||||
host_user_id: project.host_user_id,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
Err(anyhow!("project is not shared"))?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_diagnostic_summary(
|
pub fn update_diagnostic_summary(
|
||||||
@ -464,7 +401,6 @@ impl Store {
|
|||||||
.ok_or_else(|| anyhow!("no such project"))?;
|
.ok_or_else(|| anyhow!("no such project"))?;
|
||||||
if project.host_connection_id == connection_id {
|
if project.host_connection_id == connection_id {
|
||||||
let worktree = project
|
let worktree = project
|
||||||
.share_mut()?
|
|
||||||
.worktrees
|
.worktrees
|
||||||
.get_mut(&worktree_id)
|
.get_mut(&worktree_id)
|
||||||
.ok_or_else(|| anyhow!("no such worktree"))?;
|
.ok_or_else(|| anyhow!("no such worktree"))?;
|
||||||
@ -495,35 +431,77 @@ impl Store {
|
|||||||
Err(anyhow!("no such project"))?
|
Err(anyhow!("no such project"))?
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn join_project(
|
pub fn request_join_project(
|
||||||
&mut self,
|
&mut self,
|
||||||
connection_id: ConnectionId,
|
requester_id: UserId,
|
||||||
user_id: UserId,
|
|
||||||
project_id: u64,
|
project_id: u64,
|
||||||
) -> Result<JoinedProject> {
|
receipt: Receipt<proto::JoinProject>,
|
||||||
|
) -> Result<()> {
|
||||||
let connection = self
|
let connection = self
|
||||||
.connections
|
.connections
|
||||||
.get_mut(&connection_id)
|
.get_mut(&receipt.sender_id)
|
||||||
.ok_or_else(|| anyhow!("no such connection"))?;
|
.ok_or_else(|| anyhow!("no such connection"))?;
|
||||||
let project = self
|
let project = self
|
||||||
.projects
|
.projects
|
||||||
.get_mut(&project_id)
|
.get_mut(&project_id)
|
||||||
.ok_or_else(|| anyhow!("no such project"))?;
|
.ok_or_else(|| anyhow!("no such project"))?;
|
||||||
|
connection.requested_projects.insert(project_id);
|
||||||
|
project
|
||||||
|
.join_requests
|
||||||
|
.entry(requester_id)
|
||||||
|
.or_default()
|
||||||
|
.push(receipt);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
let share = project.share_mut()?;
|
pub fn deny_join_project_request(
|
||||||
connection.projects.insert(project_id);
|
&mut self,
|
||||||
|
responder_connection_id: ConnectionId,
|
||||||
let mut replica_id = 1;
|
requester_id: UserId,
|
||||||
while share.active_replica_ids.contains(&replica_id) {
|
project_id: u64,
|
||||||
replica_id += 1;
|
) -> Option<Vec<Receipt<proto::JoinProject>>> {
|
||||||
|
let project = self.projects.get_mut(&project_id)?;
|
||||||
|
if responder_connection_id != project.host_connection_id {
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
share.active_replica_ids.insert(replica_id);
|
|
||||||
share.guests.insert(connection_id, (replica_id, user_id));
|
|
||||||
|
|
||||||
Ok(JoinedProject {
|
let receipts = project.join_requests.remove(&requester_id)?;
|
||||||
replica_id,
|
for receipt in &receipts {
|
||||||
project: &self.projects[&project_id],
|
let requester_connection = self.connections.get_mut(&receipt.sender_id)?;
|
||||||
})
|
requester_connection.requested_projects.remove(&project_id);
|
||||||
|
}
|
||||||
|
Some(receipts)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn accept_join_project_request(
|
||||||
|
&mut self,
|
||||||
|
responder_connection_id: ConnectionId,
|
||||||
|
requester_id: UserId,
|
||||||
|
project_id: u64,
|
||||||
|
) -> Option<(Vec<(Receipt<proto::JoinProject>, ReplicaId)>, &Project)> {
|
||||||
|
let project = self.projects.get_mut(&project_id)?;
|
||||||
|
if responder_connection_id != project.host_connection_id {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let receipts = project.join_requests.remove(&requester_id)?;
|
||||||
|
let mut receipts_with_replica_ids = Vec::new();
|
||||||
|
for receipt in receipts {
|
||||||
|
let requester_connection = self.connections.get_mut(&receipt.sender_id)?;
|
||||||
|
requester_connection.requested_projects.remove(&project_id);
|
||||||
|
requester_connection.projects.insert(project_id);
|
||||||
|
let mut replica_id = 1;
|
||||||
|
while project.active_replica_ids.contains(&replica_id) {
|
||||||
|
replica_id += 1;
|
||||||
|
}
|
||||||
|
project.active_replica_ids.insert(replica_id);
|
||||||
|
project
|
||||||
|
.guests
|
||||||
|
.insert(receipt.sender_id, (replica_id, requester_id));
|
||||||
|
receipts_with_replica_ids.push((receipt, replica_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
Some((receipts_with_replica_ids, project))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn leave_project(
|
pub fn leave_project(
|
||||||
@ -531,27 +509,48 @@ impl Store {
|
|||||||
connection_id: ConnectionId,
|
connection_id: ConnectionId,
|
||||||
project_id: u64,
|
project_id: u64,
|
||||||
) -> Result<LeftProject> {
|
) -> Result<LeftProject> {
|
||||||
|
let user_id = self.user_id_for_connection(connection_id)?;
|
||||||
let project = self
|
let project = self
|
||||||
.projects
|
.projects
|
||||||
.get_mut(&project_id)
|
.get_mut(&project_id)
|
||||||
.ok_or_else(|| anyhow!("no such project"))?;
|
.ok_or_else(|| anyhow!("no such project"))?;
|
||||||
let share = project
|
|
||||||
.share
|
// If the connection leaving the project is a collaborator, remove it.
|
||||||
.as_mut()
|
let remove_collaborator =
|
||||||
.ok_or_else(|| anyhow!("project is not shared"))?;
|
if let Some((replica_id, _)) = project.guests.remove(&connection_id) {
|
||||||
let (replica_id, _) = share
|
project.active_replica_ids.remove(&replica_id);
|
||||||
.guests
|
true
|
||||||
.remove(&connection_id)
|
} else {
|
||||||
.ok_or_else(|| anyhow!("cannot leave a project before joining it"))?;
|
false
|
||||||
share.active_replica_ids.remove(&replica_id);
|
};
|
||||||
|
|
||||||
|
// If the connection leaving the project has a pending request, remove it.
|
||||||
|
// If that user has no other pending requests on other connections, indicate that the request should be cancelled.
|
||||||
|
let mut cancel_request = None;
|
||||||
|
if let Entry::Occupied(mut entry) = project.join_requests.entry(user_id) {
|
||||||
|
entry
|
||||||
|
.get_mut()
|
||||||
|
.retain(|receipt| receipt.sender_id != connection_id);
|
||||||
|
if entry.get().is_empty() {
|
||||||
|
entry.remove();
|
||||||
|
cancel_request = Some(user_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(connection) = self.connections.get_mut(&connection_id) {
|
if let Some(connection) = self.connections.get_mut(&connection_id) {
|
||||||
connection.projects.remove(&project_id);
|
connection.projects.remove(&project_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let connection_ids = project.connection_ids();
|
||||||
|
let unshare = connection_ids.len() <= 1 && project.join_requests.is_empty();
|
||||||
|
|
||||||
Ok(LeftProject {
|
Ok(LeftProject {
|
||||||
connection_ids: project.connection_ids(),
|
host_connection_id: project.host_connection_id,
|
||||||
host_user_id: project.host_user_id,
|
host_user_id: project.host_user_id,
|
||||||
|
connection_ids,
|
||||||
|
cancel_request,
|
||||||
|
unshare,
|
||||||
|
remove_collaborator,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,7 +565,6 @@ impl Store {
|
|||||||
) -> Result<Vec<ConnectionId>> {
|
) -> Result<Vec<ConnectionId>> {
|
||||||
let project = self.write_project(project_id, connection_id)?;
|
let project = self.write_project(project_id, connection_id)?;
|
||||||
let worktree = project
|
let worktree = project
|
||||||
.share_mut()?
|
|
||||||
.worktrees
|
.worktrees
|
||||||
.get_mut(&worktree_id)
|
.get_mut(&worktree_id)
|
||||||
.ok_or_else(|| anyhow!("no such worktree"))?;
|
.ok_or_else(|| anyhow!("no such worktree"))?;
|
||||||
@ -611,12 +609,7 @@ impl Store {
|
|||||||
.get(&project_id)
|
.get(&project_id)
|
||||||
.ok_or_else(|| anyhow!("no such project"))?;
|
.ok_or_else(|| anyhow!("no such project"))?;
|
||||||
if project.host_connection_id == connection_id
|
if project.host_connection_id == connection_id
|
||||||
|| project
|
|| project.guests.contains_key(&connection_id)
|
||||||
.share
|
|
||||||
.as_ref()
|
|
||||||
.ok_or_else(|| anyhow!("project is not shared"))?
|
|
||||||
.guests
|
|
||||||
.contains_key(&connection_id)
|
|
||||||
{
|
{
|
||||||
Ok(project)
|
Ok(project)
|
||||||
} else {
|
} else {
|
||||||
@ -634,12 +627,7 @@ impl Store {
|
|||||||
.get_mut(&project_id)
|
.get_mut(&project_id)
|
||||||
.ok_or_else(|| anyhow!("no such project"))?;
|
.ok_or_else(|| anyhow!("no such project"))?;
|
||||||
if project.host_connection_id == connection_id
|
if project.host_connection_id == connection_id
|
||||||
|| project
|
|| project.guests.contains_key(&connection_id)
|
||||||
.share
|
|
||||||
.as_ref()
|
|
||||||
.ok_or_else(|| anyhow!("project is not shared"))?
|
|
||||||
.guests
|
|
||||||
.contains_key(&connection_id)
|
|
||||||
{
|
{
|
||||||
Ok(project)
|
Ok(project)
|
||||||
} else {
|
} else {
|
||||||
@ -653,28 +641,21 @@ impl Store {
|
|||||||
for project_id in &connection.projects {
|
for project_id in &connection.projects {
|
||||||
let project = &self.projects.get(&project_id).unwrap();
|
let project = &self.projects.get(&project_id).unwrap();
|
||||||
if project.host_connection_id != *connection_id {
|
if project.host_connection_id != *connection_id {
|
||||||
assert!(project
|
assert!(project.guests.contains_key(connection_id));
|
||||||
.share
|
|
||||||
.as_ref()
|
|
||||||
.unwrap()
|
|
||||||
.guests
|
|
||||||
.contains_key(connection_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(share) = project.share.as_ref() {
|
for (worktree_id, worktree) in project.worktrees.iter() {
|
||||||
for (worktree_id, worktree) in share.worktrees.iter() {
|
let mut paths = HashMap::default();
|
||||||
let mut paths = HashMap::default();
|
for entry in worktree.entries.values() {
|
||||||
for entry in worktree.entries.values() {
|
let prev_entry = paths.insert(&entry.path, entry);
|
||||||
let prev_entry = paths.insert(&entry.path, entry);
|
assert_eq!(
|
||||||
assert_eq!(
|
prev_entry,
|
||||||
prev_entry,
|
None,
|
||||||
None,
|
"worktree {:?}, duplicate path for entries {:?} and {:?}",
|
||||||
"worktree {:?}, duplicate path for entries {:?} and {:?}",
|
worktree_id,
|
||||||
worktree_id,
|
prev_entry.unwrap(),
|
||||||
prev_entry.unwrap(),
|
entry
|
||||||
entry
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -702,21 +683,19 @@ impl Store {
|
|||||||
let host_connection = self.connections.get(&project.host_connection_id).unwrap();
|
let host_connection = self.connections.get(&project.host_connection_id).unwrap();
|
||||||
assert!(host_connection.projects.contains(project_id));
|
assert!(host_connection.projects.contains(project_id));
|
||||||
|
|
||||||
if let Some(share) = &project.share {
|
for guest_connection_id in project.guests.keys() {
|
||||||
for guest_connection_id in share.guests.keys() {
|
let guest_connection = self.connections.get(guest_connection_id).unwrap();
|
||||||
let guest_connection = self.connections.get(guest_connection_id).unwrap();
|
assert!(guest_connection.projects.contains(project_id));
|
||||||
assert!(guest_connection.projects.contains(project_id));
|
|
||||||
}
|
|
||||||
assert_eq!(share.active_replica_ids.len(), share.guests.len(),);
|
|
||||||
assert_eq!(
|
|
||||||
share.active_replica_ids,
|
|
||||||
share
|
|
||||||
.guests
|
|
||||||
.values()
|
|
||||||
.map(|(replica_id, _)| *replica_id)
|
|
||||||
.collect::<HashSet<_>>(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
assert_eq!(project.active_replica_ids.len(), project.guests.len(),);
|
||||||
|
assert_eq!(
|
||||||
|
project.active_replica_ids,
|
||||||
|
project
|
||||||
|
.guests
|
||||||
|
.values()
|
||||||
|
.map(|(replica_id, _)| *replica_id)
|
||||||
|
.collect::<HashSet<_>>(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (channel_id, channel) in &self.channels {
|
for (channel_id, channel) in &self.channels {
|
||||||
@ -730,38 +709,15 @@ impl Store {
|
|||||||
|
|
||||||
impl Project {
|
impl Project {
|
||||||
pub fn guest_connection_ids(&self) -> Vec<ConnectionId> {
|
pub fn guest_connection_ids(&self) -> Vec<ConnectionId> {
|
||||||
if let Some(share) = &self.share {
|
self.guests.keys().copied().collect()
|
||||||
share.guests.keys().copied().collect()
|
|
||||||
} else {
|
|
||||||
Vec::new()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn connection_ids(&self) -> Vec<ConnectionId> {
|
pub fn connection_ids(&self) -> Vec<ConnectionId> {
|
||||||
if let Some(share) = &self.share {
|
self.guests
|
||||||
share
|
.keys()
|
||||||
.guests
|
.copied()
|
||||||
.keys()
|
.chain(Some(self.host_connection_id))
|
||||||
.copied()
|
.collect()
|
||||||
.chain(Some(self.host_connection_id))
|
|
||||||
.collect()
|
|
||||||
} else {
|
|
||||||
vec![self.host_connection_id]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn share(&self) -> Result<&ProjectShare> {
|
|
||||||
Ok(self
|
|
||||||
.share
|
|
||||||
.as_ref()
|
|
||||||
.ok_or_else(|| anyhow!("worktree is not shared"))?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn share_mut(&mut self) -> Result<&mut ProjectShare> {
|
|
||||||
Ok(self
|
|
||||||
.share
|
|
||||||
.as_mut()
|
|
||||||
.ok_or_else(|| anyhow!("worktree is not shared"))?)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ editor = { path = "../editor" }
|
|||||||
fuzzy = { path = "../fuzzy" }
|
fuzzy = { path = "../fuzzy" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
picker = { path = "../picker" }
|
picker = { path = "../picker" }
|
||||||
|
project = { path = "../project" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
|
use crate::notifications::render_user_notification;
|
||||||
use client::{ContactEvent, ContactEventKind, UserStore};
|
use client::{ContactEvent, ContactEventKind, UserStore};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*, impl_internal_actions, platform::CursorStyle, Entity, ModelHandle,
|
elements::*, impl_internal_actions, Entity, ModelHandle, MutableAppContext, RenderContext,
|
||||||
MutableAppContext, RenderContext, View, ViewContext,
|
View, ViewContext,
|
||||||
};
|
};
|
||||||
use settings::Settings;
|
|
||||||
use workspace::Notification;
|
use workspace::Notification;
|
||||||
|
|
||||||
use crate::render_icon_button;
|
|
||||||
|
|
||||||
impl_internal_actions!(contact_notifications, [Dismiss, RespondToContactRequest]);
|
impl_internal_actions!(contact_notifications, [Dismiss, RespondToContactRequest]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut MutableAppContext) {
|
||||||
@ -33,9 +31,6 @@ pub enum Event {
|
|||||||
Dismiss,
|
Dismiss,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Decline {}
|
|
||||||
enum Accept {}
|
|
||||||
|
|
||||||
impl Entity for ContactNotification {
|
impl Entity for ContactNotification {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
}
|
}
|
||||||
@ -47,8 +42,40 @@ impl View for ContactNotification {
|
|||||||
|
|
||||||
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
||||||
match self.event.kind {
|
match self.event.kind {
|
||||||
ContactEventKind::Requested => self.render_incoming_request(cx),
|
ContactEventKind::Requested => render_user_notification(
|
||||||
ContactEventKind::Accepted => self.render_acceptance(cx),
|
self.event.user.clone(),
|
||||||
|
"wants to add you as a contact",
|
||||||
|
Some("They won't know if you decline."),
|
||||||
|
RespondToContactRequest {
|
||||||
|
user_id: self.event.user.id,
|
||||||
|
accept: false,
|
||||||
|
},
|
||||||
|
vec![
|
||||||
|
(
|
||||||
|
"Decline",
|
||||||
|
Box::new(RespondToContactRequest {
|
||||||
|
user_id: self.event.user.id,
|
||||||
|
accept: false,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"Accept",
|
||||||
|
Box::new(RespondToContactRequest {
|
||||||
|
user_id: self.event.user.id,
|
||||||
|
accept: true,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
cx,
|
||||||
|
),
|
||||||
|
ContactEventKind::Accepted => render_user_notification(
|
||||||
|
self.event.user.clone(),
|
||||||
|
"accepted your contact request",
|
||||||
|
None,
|
||||||
|
Dismiss(self.event.user.id),
|
||||||
|
vec![],
|
||||||
|
cx,
|
||||||
|
),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,138 +109,6 @@ impl ContactNotification {
|
|||||||
Self { event, user_store }
|
Self { event, user_store }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_incoming_request(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
|
||||||
let theme = cx.global::<Settings>().theme.clone();
|
|
||||||
let theme = &theme.contact_notification;
|
|
||||||
let user = &self.event.user;
|
|
||||||
let user_id = user.id;
|
|
||||||
|
|
||||||
Flex::column()
|
|
||||||
.with_child(self.render_header("wants to add you as a contact.", theme, cx))
|
|
||||||
.with_child(
|
|
||||||
Label::new(
|
|
||||||
"They won't know if you decline.".to_string(),
|
|
||||||
theme.body_message.text.clone(),
|
|
||||||
)
|
|
||||||
.contained()
|
|
||||||
.with_style(theme.body_message.container)
|
|
||||||
.boxed(),
|
|
||||||
)
|
|
||||||
.with_child(
|
|
||||||
Flex::row()
|
|
||||||
.with_child(
|
|
||||||
MouseEventHandler::new::<Decline, _, _>(
|
|
||||||
self.event.user.id as usize,
|
|
||||||
cx,
|
|
||||||
|state, _| {
|
|
||||||
let button = theme.button.style_for(state, false);
|
|
||||||
Label::new("Decline".to_string(), button.text.clone())
|
|
||||||
.contained()
|
|
||||||
.with_style(button.container)
|
|
||||||
.boxed()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
|
||||||
.on_click(move |_, cx| {
|
|
||||||
cx.dispatch_action(RespondToContactRequest {
|
|
||||||
user_id,
|
|
||||||
accept: false,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.boxed(),
|
|
||||||
)
|
|
||||||
.with_child(
|
|
||||||
MouseEventHandler::new::<Accept, _, _>(user.id as usize, cx, |state, _| {
|
|
||||||
let button = theme.button.style_for(state, false);
|
|
||||||
Label::new("Accept".to_string(), button.text.clone())
|
|
||||||
.contained()
|
|
||||||
.with_style(button.container)
|
|
||||||
.boxed()
|
|
||||||
})
|
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
|
||||||
.on_click(move |_, cx| {
|
|
||||||
cx.dispatch_action(RespondToContactRequest {
|
|
||||||
user_id,
|
|
||||||
accept: true,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.boxed(),
|
|
||||||
)
|
|
||||||
.aligned()
|
|
||||||
.right()
|
|
||||||
.boxed(),
|
|
||||||
)
|
|
||||||
.contained()
|
|
||||||
.boxed()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_acceptance(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
|
||||||
let theme = cx.global::<Settings>().theme.clone();
|
|
||||||
let theme = &theme.contact_notification;
|
|
||||||
|
|
||||||
self.render_header("accepted your contact request", theme, cx)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_header(
|
|
||||||
&self,
|
|
||||||
message: &'static str,
|
|
||||||
theme: &theme::ContactNotification,
|
|
||||||
cx: &mut RenderContext<Self>,
|
|
||||||
) -> ElementBox {
|
|
||||||
let user = &self.event.user;
|
|
||||||
let user_id = user.id;
|
|
||||||
Flex::row()
|
|
||||||
.with_children(user.avatar.clone().map(|avatar| {
|
|
||||||
Image::new(avatar)
|
|
||||||
.with_style(theme.header_avatar)
|
|
||||||
.aligned()
|
|
||||||
.constrained()
|
|
||||||
.with_height(
|
|
||||||
cx.font_cache()
|
|
||||||
.line_height(theme.header_message.text.font_size),
|
|
||||||
)
|
|
||||||
.aligned()
|
|
||||||
.top()
|
|
||||||
.boxed()
|
|
||||||
}))
|
|
||||||
.with_child(
|
|
||||||
Text::new(
|
|
||||||
format!("{} {}", user.github_login, message),
|
|
||||||
theme.header_message.text.clone(),
|
|
||||||
)
|
|
||||||
.contained()
|
|
||||||
.with_style(theme.header_message.container)
|
|
||||||
.aligned()
|
|
||||||
.top()
|
|
||||||
.left()
|
|
||||||
.flex(1., true)
|
|
||||||
.boxed(),
|
|
||||||
)
|
|
||||||
.with_child(
|
|
||||||
MouseEventHandler::new::<Dismiss, _, _>(user.id as usize, cx, |state, _| {
|
|
||||||
render_icon_button(
|
|
||||||
theme.dismiss_button.style_for(state, false),
|
|
||||||
"icons/decline.svg",
|
|
||||||
)
|
|
||||||
.boxed()
|
|
||||||
})
|
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
|
||||||
.with_padding(Padding::uniform(5.))
|
|
||||||
.on_click(move |_, cx| cx.dispatch_action(Dismiss(user_id)))
|
|
||||||
.aligned()
|
|
||||||
.constrained()
|
|
||||||
.with_height(
|
|
||||||
cx.font_cache()
|
|
||||||
.line_height(theme.header_message.text.font_size),
|
|
||||||
)
|
|
||||||
.aligned()
|
|
||||||
.top()
|
|
||||||
.flex_float()
|
|
||||||
.boxed(),
|
|
||||||
)
|
|
||||||
.named("contact notification header")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn dismiss(&mut self, _: &Dismiss, cx: &mut ViewContext<Self>) {
|
fn dismiss(&mut self, _: &Dismiss, cx: &mut ViewContext<Self>) {
|
||||||
self.user_store.update(cx, |store, cx| {
|
self.user_store.update(cx, |store, cx| {
|
||||||
store
|
store
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
mod contact_finder;
|
mod contact_finder;
|
||||||
mod contact_notification;
|
mod contact_notification;
|
||||||
|
mod join_project_notification;
|
||||||
|
mod notifications;
|
||||||
|
|
||||||
use client::{Contact, ContactEventKind, User, UserStore};
|
use client::{Contact, ContactEventKind, User, UserStore};
|
||||||
use contact_notification::ContactNotification;
|
use contact_notification::ContactNotification;
|
||||||
@ -13,6 +15,7 @@ use gpui::{
|
|||||||
AppContext, Element, ElementBox, Entity, LayoutContext, ModelHandle, MutableAppContext,
|
AppContext, Element, ElementBox, Entity, LayoutContext, ModelHandle, MutableAppContext,
|
||||||
RenderContext, Subscription, View, ViewContext, ViewHandle, WeakViewHandle,
|
RenderContext, Subscription, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
|
use join_project_notification::JoinProjectNotification;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@ -76,6 +79,7 @@ pub struct RespondToContactRequest {
|
|||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut MutableAppContext) {
|
||||||
contact_finder::init(cx);
|
contact_finder::init(cx);
|
||||||
contact_notification::init(cx);
|
contact_notification::init(cx);
|
||||||
|
join_project_notification::init(cx);
|
||||||
cx.add_action(ContactsPanel::request_contact);
|
cx.add_action(ContactsPanel::request_contact);
|
||||||
cx.add_action(ContactsPanel::remove_contact);
|
cx.add_action(ContactsPanel::remove_contact);
|
||||||
cx.add_action(ContactsPanel::respond_to_contact_request);
|
cx.add_action(ContactsPanel::respond_to_contact_request);
|
||||||
@ -118,6 +122,37 @@ impl ContactsPanel {
|
|||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
|
cx.defer({
|
||||||
|
let workspace = workspace.clone();
|
||||||
|
move |_, cx| {
|
||||||
|
if let Some(workspace_handle) = workspace.upgrade(cx) {
|
||||||
|
cx.subscribe(&workspace_handle.read(cx).project().clone(), {
|
||||||
|
let workspace = workspace.clone();
|
||||||
|
move |_, project, event, cx| match event {
|
||||||
|
project::Event::ContactRequestedJoin(user) => {
|
||||||
|
if let Some(workspace) = workspace.upgrade(cx) {
|
||||||
|
workspace.update(cx, |workspace, cx| {
|
||||||
|
workspace.show_notification(
|
||||||
|
cx.add_view(|cx| {
|
||||||
|
JoinProjectNotification::new(
|
||||||
|
project,
|
||||||
|
user.clone(),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
cx.subscribe(&app_state.user_store, {
|
cx.subscribe(&app_state.user_store, {
|
||||||
let user_store = app_state.user_store.downgrade();
|
let user_store = app_state.user_store.downgrade();
|
||||||
move |_, _, event, cx| {
|
move |_, _, event, cx| {
|
||||||
@ -305,22 +340,16 @@ impl ContactsPanel {
|
|||||||
fn render_contact_project(
|
fn render_contact_project(
|
||||||
contact: Arc<Contact>,
|
contact: Arc<Contact>,
|
||||||
current_user_id: Option<u64>,
|
current_user_id: Option<u64>,
|
||||||
project_ix: usize,
|
project_index: usize,
|
||||||
app_state: Arc<AppState>,
|
app_state: Arc<AppState>,
|
||||||
theme: &theme::ContactsPanel,
|
theme: &theme::ContactsPanel,
|
||||||
is_last_project: bool,
|
is_last_project: bool,
|
||||||
is_selected: bool,
|
is_selected: bool,
|
||||||
cx: &mut LayoutContext,
|
cx: &mut LayoutContext,
|
||||||
) -> ElementBox {
|
) -> ElementBox {
|
||||||
let project = &contact.projects[project_ix];
|
let project = &contact.projects[project_index];
|
||||||
let project_id = project.id;
|
let project_id = project.id;
|
||||||
let is_host = Some(contact.user.id) == current_user_id;
|
let is_host = Some(contact.user.id) == current_user_id;
|
||||||
let is_guest = !is_host
|
|
||||||
&& project
|
|
||||||
.guests
|
|
||||||
.iter()
|
|
||||||
.any(|guest| Some(guest.id) == current_user_id);
|
|
||||||
let is_shared = project.is_shared;
|
|
||||||
|
|
||||||
let font_cache = cx.font_cache();
|
let font_cache = cx.font_cache();
|
||||||
let host_avatar_height = theme
|
let host_avatar_height = theme
|
||||||
@ -328,7 +357,7 @@ impl ContactsPanel {
|
|||||||
.width
|
.width
|
||||||
.or(theme.contact_avatar.height)
|
.or(theme.contact_avatar.height)
|
||||||
.unwrap_or(0.);
|
.unwrap_or(0.);
|
||||||
let row = &theme.unshared_project_row.default;
|
let row = &theme.project_row.default;
|
||||||
let tree_branch = theme.tree_branch.clone();
|
let tree_branch = theme.tree_branch.clone();
|
||||||
let line_height = row.name.text.line_height(font_cache);
|
let line_height = row.name.text.line_height(font_cache);
|
||||||
let cap_height = row.name.text.cap_height(font_cache);
|
let cap_height = row.name.text.cap_height(font_cache);
|
||||||
@ -337,12 +366,7 @@ impl ContactsPanel {
|
|||||||
|
|
||||||
MouseEventHandler::new::<JoinProject, _, _>(project_id as usize, cx, |mouse_state, _| {
|
MouseEventHandler::new::<JoinProject, _, _>(project_id as usize, cx, |mouse_state, _| {
|
||||||
let tree_branch = *tree_branch.style_for(mouse_state, is_selected);
|
let tree_branch = *tree_branch.style_for(mouse_state, is_selected);
|
||||||
let row = if project.is_shared {
|
let row = theme.project_row.style_for(mouse_state, is_selected);
|
||||||
&theme.shared_project_row
|
|
||||||
} else {
|
|
||||||
&theme.unshared_project_row
|
|
||||||
}
|
|
||||||
.style_for(mouse_state, is_selected);
|
|
||||||
|
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child(
|
.with_child(
|
||||||
@ -412,15 +436,16 @@ impl ContactsPanel {
|
|||||||
.with_style(row.container)
|
.with_style(row.container)
|
||||||
.boxed()
|
.boxed()
|
||||||
})
|
})
|
||||||
.with_cursor_style(if !is_host && is_shared {
|
.with_cursor_style(if !is_host {
|
||||||
CursorStyle::PointingHand
|
CursorStyle::PointingHand
|
||||||
} else {
|
} else {
|
||||||
CursorStyle::Arrow
|
CursorStyle::Arrow
|
||||||
})
|
})
|
||||||
.on_click(move |_, cx| {
|
.on_click(move |_, cx| {
|
||||||
if !is_host && !is_guest {
|
if !is_host {
|
||||||
cx.dispatch_global_action(JoinProject {
|
cx.dispatch_global_action(JoinProject {
|
||||||
project_id,
|
contact: contact.clone(),
|
||||||
|
project_index,
|
||||||
app_state: app_state.clone(),
|
app_state: app_state.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -743,12 +768,12 @@ impl ContactsPanel {
|
|||||||
let section = *section;
|
let section = *section;
|
||||||
self.toggle_expanded(&ToggleExpanded(section), cx);
|
self.toggle_expanded(&ToggleExpanded(section), cx);
|
||||||
}
|
}
|
||||||
ContactEntry::ContactProject(contact, project_ix) => {
|
ContactEntry::ContactProject(contact, project_index) => cx
|
||||||
cx.dispatch_global_action(JoinProject {
|
.dispatch_global_action(JoinProject {
|
||||||
project_id: contact.projects[*project_ix].id,
|
contact: contact.clone(),
|
||||||
|
project_index: *project_index,
|
||||||
app_state: self.app_state.clone(),
|
app_state: self.app_state.clone(),
|
||||||
})
|
}),
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -947,7 +972,6 @@ mod tests {
|
|||||||
projects: vec![proto::ProjectMetadata {
|
projects: vec![proto::ProjectMetadata {
|
||||||
id: 101,
|
id: 101,
|
||||||
worktree_root_names: vec!["dir1".to_string()],
|
worktree_root_names: vec!["dir1".to_string()],
|
||||||
is_shared: true,
|
|
||||||
guests: vec![2],
|
guests: vec![2],
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
@ -958,7 +982,6 @@ mod tests {
|
|||||||
projects: vec![proto::ProjectMetadata {
|
projects: vec![proto::ProjectMetadata {
|
||||||
id: 102,
|
id: 102,
|
||||||
worktree_root_names: vec!["dir2".to_string()],
|
worktree_root_names: vec!["dir2".to_string()],
|
||||||
is_shared: true,
|
|
||||||
guests: vec![2],
|
guests: vec![2],
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
|
80
crates/contacts_panel/src/join_project_notification.rs
Normal file
80
crates/contacts_panel/src/join_project_notification.rs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
use client::User;
|
||||||
|
use gpui::{
|
||||||
|
actions, ElementBox, Entity, ModelHandle, MutableAppContext, RenderContext, View, ViewContext,
|
||||||
|
};
|
||||||
|
use project::Project;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use workspace::Notification;
|
||||||
|
|
||||||
|
use crate::notifications::render_user_notification;
|
||||||
|
|
||||||
|
pub fn init(cx: &mut MutableAppContext) {
|
||||||
|
cx.add_action(JoinProjectNotification::decline);
|
||||||
|
cx.add_action(JoinProjectNotification::accept);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum Event {
|
||||||
|
Dismiss,
|
||||||
|
}
|
||||||
|
|
||||||
|
actions!(contacts_panel, [Accept, Decline]);
|
||||||
|
|
||||||
|
pub struct JoinProjectNotification {
|
||||||
|
project: ModelHandle<Project>,
|
||||||
|
user: Arc<User>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl JoinProjectNotification {
|
||||||
|
pub fn new(project: ModelHandle<Project>, user: Arc<User>, cx: &mut ViewContext<Self>) -> Self {
|
||||||
|
cx.subscribe(&project, |this, _, event, cx| {
|
||||||
|
if let project::Event::ContactCancelledJoinRequest(user) = event {
|
||||||
|
if *user == this.user {
|
||||||
|
cx.emit(Event::Dismiss);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
Self { project, user }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decline(&mut self, _: &Decline, cx: &mut ViewContext<Self>) {
|
||||||
|
self.project.update(cx, |project, cx| {
|
||||||
|
project.respond_to_join_request(self.user.id, false, cx)
|
||||||
|
});
|
||||||
|
cx.emit(Event::Dismiss)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn accept(&mut self, _: &Accept, cx: &mut ViewContext<Self>) {
|
||||||
|
self.project.update(cx, |project, cx| {
|
||||||
|
project.respond_to_join_request(self.user.id, true, cx)
|
||||||
|
});
|
||||||
|
cx.emit(Event::Dismiss)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Entity for JoinProjectNotification {
|
||||||
|
type Event = Event;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl View for JoinProjectNotification {
|
||||||
|
fn ui_name() -> &'static str {
|
||||||
|
"JoinProjectNotification"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
||||||
|
render_user_notification(
|
||||||
|
self.user.clone(),
|
||||||
|
"wants to join your project",
|
||||||
|
None,
|
||||||
|
Decline,
|
||||||
|
vec![("Decline", Box::new(Decline)), ("Accept", Box::new(Accept))],
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Notification for JoinProjectNotification {
|
||||||
|
fn should_dismiss_notification_on_event(&self, event: &<Self as Entity>::Event) -> bool {
|
||||||
|
matches!(event, Event::Dismiss)
|
||||||
|
}
|
||||||
|
}
|
113
crates/contacts_panel/src/notifications.rs
Normal file
113
crates/contacts_panel/src/notifications.rs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
use crate::render_icon_button;
|
||||||
|
use client::User;
|
||||||
|
use gpui::{
|
||||||
|
elements::{Flex, Image, Label, MouseEventHandler, Padding, ParentElement, Text},
|
||||||
|
platform::CursorStyle,
|
||||||
|
Action, Element, ElementBox, RenderContext, View,
|
||||||
|
};
|
||||||
|
use settings::Settings;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
enum Dismiss {}
|
||||||
|
enum Button {}
|
||||||
|
|
||||||
|
pub fn render_user_notification<V: View, A: Action + Clone>(
|
||||||
|
user: Arc<User>,
|
||||||
|
title: &str,
|
||||||
|
body: Option<&str>,
|
||||||
|
dismiss_action: A,
|
||||||
|
buttons: Vec<(&'static str, Box<dyn Action>)>,
|
||||||
|
cx: &mut RenderContext<V>,
|
||||||
|
) -> ElementBox {
|
||||||
|
let theme = cx.global::<Settings>().theme.clone();
|
||||||
|
let theme = &theme.contact_notification;
|
||||||
|
|
||||||
|
Flex::column()
|
||||||
|
.with_child(
|
||||||
|
Flex::row()
|
||||||
|
.with_children(user.avatar.clone().map(|avatar| {
|
||||||
|
Image::new(avatar)
|
||||||
|
.with_style(theme.header_avatar)
|
||||||
|
.aligned()
|
||||||
|
.constrained()
|
||||||
|
.with_height(
|
||||||
|
cx.font_cache()
|
||||||
|
.line_height(theme.header_message.text.font_size),
|
||||||
|
)
|
||||||
|
.aligned()
|
||||||
|
.top()
|
||||||
|
.boxed()
|
||||||
|
}))
|
||||||
|
.with_child(
|
||||||
|
Text::new(
|
||||||
|
format!("{} {}", user.github_login, title),
|
||||||
|
theme.header_message.text.clone(),
|
||||||
|
)
|
||||||
|
.contained()
|
||||||
|
.with_style(theme.header_message.container)
|
||||||
|
.aligned()
|
||||||
|
.top()
|
||||||
|
.left()
|
||||||
|
.flex(1., true)
|
||||||
|
.boxed(),
|
||||||
|
)
|
||||||
|
.with_child(
|
||||||
|
MouseEventHandler::new::<Dismiss, _, _>(user.id as usize, cx, |state, _| {
|
||||||
|
render_icon_button(
|
||||||
|
theme.dismiss_button.style_for(state, false),
|
||||||
|
"icons/decline.svg",
|
||||||
|
)
|
||||||
|
.boxed()
|
||||||
|
})
|
||||||
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
|
.with_padding(Padding::uniform(5.))
|
||||||
|
.on_click(move |_, cx| cx.dispatch_any_action(dismiss_action.boxed_clone()))
|
||||||
|
.aligned()
|
||||||
|
.constrained()
|
||||||
|
.with_height(
|
||||||
|
cx.font_cache()
|
||||||
|
.line_height(theme.header_message.text.font_size),
|
||||||
|
)
|
||||||
|
.aligned()
|
||||||
|
.top()
|
||||||
|
.flex_float()
|
||||||
|
.boxed(),
|
||||||
|
)
|
||||||
|
.named("contact notification header"),
|
||||||
|
)
|
||||||
|
.with_children(body.map(|body| {
|
||||||
|
Label::new(
|
||||||
|
body.to_string(),
|
||||||
|
theme.body_message.text.clone(),
|
||||||
|
)
|
||||||
|
.contained()
|
||||||
|
.with_style(theme.body_message.container)
|
||||||
|
.boxed()
|
||||||
|
}))
|
||||||
|
.with_children(if buttons.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(
|
||||||
|
Flex::row()
|
||||||
|
.with_children(buttons.into_iter().enumerate().map(
|
||||||
|
|(ix, (message, action))| {
|
||||||
|
MouseEventHandler::new::<Button, _, _>(ix, cx, |state, _| {
|
||||||
|
let button = theme.button.style_for(state, false);
|
||||||
|
Label::new(message.to_string(), button.text.clone())
|
||||||
|
.contained()
|
||||||
|
.with_style(button.container)
|
||||||
|
.boxed()
|
||||||
|
})
|
||||||
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
|
.on_click(move |_, cx| cx.dispatch_any_action(action.boxed_clone()))
|
||||||
|
.boxed()
|
||||||
|
},
|
||||||
|
))
|
||||||
|
.aligned()
|
||||||
|
.right()
|
||||||
|
.boxed(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.contained()
|
||||||
|
.boxed()
|
||||||
|
}
|
@ -1611,6 +1611,20 @@ impl MutableAppContext {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn replace_root_view<T, F>(&mut self, window_id: usize, build_root_view: F) -> ViewHandle<T>
|
||||||
|
where
|
||||||
|
T: View,
|
||||||
|
F: FnOnce(&mut ViewContext<T>) -> T,
|
||||||
|
{
|
||||||
|
self.update(|this| {
|
||||||
|
let root_view = this.add_view(window_id, build_root_view);
|
||||||
|
let window = this.cx.windows.get_mut(&window_id).unwrap();
|
||||||
|
window.root_view = root_view.clone().into();
|
||||||
|
window.focused_view_id = Some(root_view.id());
|
||||||
|
root_view
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn remove_window(&mut self, window_id: usize) {
|
pub fn remove_window(&mut self, window_id: usize) {
|
||||||
self.cx.windows.remove(&window_id);
|
self.cx.windows.remove(&window_id);
|
||||||
self.presenters_and_platform_windows.remove(&window_id);
|
self.presenters_and_platform_windows.remove(&window_id);
|
||||||
@ -1628,20 +1642,22 @@ impl MutableAppContext {
|
|||||||
|
|
||||||
{
|
{
|
||||||
let mut app = self.upgrade();
|
let mut app = self.upgrade();
|
||||||
let presenter = presenter.clone();
|
let presenter = Rc::downgrade(&presenter);
|
||||||
window.on_event(Box::new(move |event| {
|
window.on_event(Box::new(move |event| {
|
||||||
app.update(|cx| {
|
app.update(|cx| {
|
||||||
if let Event::KeyDown { keystroke, .. } = &event {
|
if let Some(presenter) = presenter.upgrade() {
|
||||||
if cx.dispatch_keystroke(
|
if let Event::KeyDown { keystroke, .. } = &event {
|
||||||
window_id,
|
if cx.dispatch_keystroke(
|
||||||
presenter.borrow().dispatch_path(cx.as_ref()),
|
window_id,
|
||||||
keystroke,
|
presenter.borrow().dispatch_path(cx.as_ref()),
|
||||||
) {
|
keystroke,
|
||||||
return;
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
presenter.borrow_mut().dispatch_event(event, cx);
|
presenter.borrow_mut().dispatch_event(event, cx);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -3224,6 +3240,21 @@ impl<'a, T: View> ViewContext<'a, T> {
|
|||||||
self.app.add_option_view(self.window_id, build_view)
|
self.app.add_option_view(self.window_id, build_view)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn replace_root_view<V, F>(&mut self, build_root_view: F) -> ViewHandle<V>
|
||||||
|
where
|
||||||
|
V: View,
|
||||||
|
F: FnOnce(&mut ViewContext<V>) -> V,
|
||||||
|
{
|
||||||
|
let window_id = self.window_id;
|
||||||
|
self.update(|this| {
|
||||||
|
let root_view = this.add_view(window_id, build_root_view);
|
||||||
|
let window = this.cx.windows.get_mut(&window_id).unwrap();
|
||||||
|
window.root_view = root_view.clone().into();
|
||||||
|
window.focused_view_id = Some(root_view.id());
|
||||||
|
root_view
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn subscribe<E, H, F>(&mut self, handle: &H, mut callback: F) -> Subscription
|
pub fn subscribe<E, H, F>(&mut self, handle: &H, mut callback: F) -> Subscription
|
||||||
where
|
where
|
||||||
E: Entity,
|
E: Entity,
|
||||||
|
@ -388,13 +388,17 @@ impl<'a> EventContext<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dispatch_action<A: Action>(&mut self, action: A) {
|
pub fn dispatch_any_action(&mut self, action: Box<dyn Action>) {
|
||||||
self.dispatched_actions.push(DispatchDirective {
|
self.dispatched_actions.push(DispatchDirective {
|
||||||
path: self.view_stack.clone(),
|
path: self.view_stack.clone(),
|
||||||
action: Box::new(action),
|
action,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn dispatch_action<A: Action>(&mut self, action: A) {
|
||||||
|
self.dispatch_any_action(Box::new(action));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn notify(&mut self) {
|
pub fn notify(&mut self) {
|
||||||
self.notify_count += 1;
|
self.notify_count += 1;
|
||||||
if let Some(view_id) = self.view_stack.last() {
|
if let Some(view_id) = self.view_stack.last() {
|
||||||
|
@ -45,6 +45,7 @@ serde_json = { version = "1.0.64", features = ["preserve_order"] }
|
|||||||
sha2 = "0.10"
|
sha2 = "0.10"
|
||||||
similar = "1.3"
|
similar = "1.3"
|
||||||
smol = "1.2.5"
|
smol = "1.2.5"
|
||||||
|
thiserror = "1.0.29"
|
||||||
toml = "0.5"
|
toml = "0.5"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -49,6 +49,7 @@ use std::{
|
|||||||
},
|
},
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
use thiserror::Error;
|
||||||
use util::{post_inc, ResultExt, TryFutureExt as _};
|
use util::{post_inc, ResultExt, TryFutureExt as _};
|
||||||
|
|
||||||
pub use fs::*;
|
pub use fs::*;
|
||||||
@ -90,6 +91,18 @@ pub struct Project {
|
|||||||
nonce: u128,
|
nonce: u128,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum JoinProjectError {
|
||||||
|
#[error("host declined join request")]
|
||||||
|
HostDeclined,
|
||||||
|
#[error("host closed the project")]
|
||||||
|
HostClosedProject,
|
||||||
|
#[error("host went offline")]
|
||||||
|
HostWentOffline,
|
||||||
|
#[error("{0}")]
|
||||||
|
Other(#[from] anyhow::Error),
|
||||||
|
}
|
||||||
|
|
||||||
enum OpenBuffer {
|
enum OpenBuffer {
|
||||||
Strong(ModelHandle<Buffer>),
|
Strong(ModelHandle<Buffer>),
|
||||||
Weak(WeakModelHandle<Buffer>),
|
Weak(WeakModelHandle<Buffer>),
|
||||||
@ -123,7 +136,7 @@ pub struct Collaborator {
|
|||||||
pub replica_id: ReplicaId,
|
pub replica_id: ReplicaId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
ActiveEntryChanged(Option<ProjectEntryId>),
|
ActiveEntryChanged(Option<ProjectEntryId>),
|
||||||
WorktreeRemoved(WorktreeId),
|
WorktreeRemoved(WorktreeId),
|
||||||
@ -133,6 +146,8 @@ pub enum Event {
|
|||||||
DiagnosticsUpdated(ProjectPath),
|
DiagnosticsUpdated(ProjectPath),
|
||||||
RemoteIdChanged(Option<u64>),
|
RemoteIdChanged(Option<u64>),
|
||||||
CollaboratorLeft(PeerId),
|
CollaboratorLeft(PeerId),
|
||||||
|
ContactRequestedJoin(Arc<User>),
|
||||||
|
ContactCancelledJoinRequest(Arc<User>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
@ -248,15 +263,18 @@ impl ProjectEntryId {
|
|||||||
|
|
||||||
impl Project {
|
impl Project {
|
||||||
pub fn init(client: &Arc<Client>) {
|
pub fn init(client: &Arc<Client>) {
|
||||||
|
client.add_model_message_handler(Self::handle_request_join_project);
|
||||||
client.add_model_message_handler(Self::handle_add_collaborator);
|
client.add_model_message_handler(Self::handle_add_collaborator);
|
||||||
client.add_model_message_handler(Self::handle_buffer_reloaded);
|
client.add_model_message_handler(Self::handle_buffer_reloaded);
|
||||||
client.add_model_message_handler(Self::handle_buffer_saved);
|
client.add_model_message_handler(Self::handle_buffer_saved);
|
||||||
client.add_model_message_handler(Self::handle_start_language_server);
|
client.add_model_message_handler(Self::handle_start_language_server);
|
||||||
client.add_model_message_handler(Self::handle_update_language_server);
|
client.add_model_message_handler(Self::handle_update_language_server);
|
||||||
client.add_model_message_handler(Self::handle_remove_collaborator);
|
client.add_model_message_handler(Self::handle_remove_collaborator);
|
||||||
|
client.add_model_message_handler(Self::handle_join_project_request_cancelled);
|
||||||
client.add_model_message_handler(Self::handle_register_worktree);
|
client.add_model_message_handler(Self::handle_register_worktree);
|
||||||
client.add_model_message_handler(Self::handle_unregister_worktree);
|
client.add_model_message_handler(Self::handle_unregister_worktree);
|
||||||
client.add_model_message_handler(Self::handle_unshare_project);
|
client.add_model_message_handler(Self::handle_unregister_project);
|
||||||
|
client.add_model_message_handler(Self::handle_project_unshared);
|
||||||
client.add_model_message_handler(Self::handle_update_buffer_file);
|
client.add_model_message_handler(Self::handle_update_buffer_file);
|
||||||
client.add_model_message_handler(Self::handle_update_buffer);
|
client.add_model_message_handler(Self::handle_update_buffer);
|
||||||
client.add_model_message_handler(Self::handle_update_diagnostic_summary);
|
client.add_model_message_handler(Self::handle_update_diagnostic_summary);
|
||||||
@ -353,7 +371,7 @@ impl Project {
|
|||||||
languages: Arc<LanguageRegistry>,
|
languages: Arc<LanguageRegistry>,
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
cx: &mut AsyncAppContext,
|
cx: &mut AsyncAppContext,
|
||||||
) -> Result<ModelHandle<Self>> {
|
) -> Result<ModelHandle<Self>, JoinProjectError> {
|
||||||
client.authenticate_and_connect(true, &cx).await?;
|
client.authenticate_and_connect(true, &cx).await?;
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
@ -362,6 +380,24 @@ impl Project {
|
|||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
let response = match response.variant.ok_or_else(|| anyhow!("missing variant"))? {
|
||||||
|
proto::join_project_response::Variant::Accept(response) => response,
|
||||||
|
proto::join_project_response::Variant::Decline(decline) => {
|
||||||
|
match proto::join_project_response::decline::Reason::from_i32(decline.reason) {
|
||||||
|
Some(proto::join_project_response::decline::Reason::Declined) => {
|
||||||
|
Err(JoinProjectError::HostDeclined)?
|
||||||
|
}
|
||||||
|
Some(proto::join_project_response::decline::Reason::Closed) => {
|
||||||
|
Err(JoinProjectError::HostClosedProject)?
|
||||||
|
}
|
||||||
|
Some(proto::join_project_response::decline::Reason::WentOffline) => {
|
||||||
|
Err(JoinProjectError::HostWentOffline)?
|
||||||
|
}
|
||||||
|
None => Err(anyhow!("missing decline reason"))?,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let replica_id = response.replica_id as ReplicaId;
|
let replica_id = response.replica_id as ReplicaId;
|
||||||
|
|
||||||
let mut worktrees = Vec::new();
|
let mut worktrees = Vec::new();
|
||||||
@ -400,7 +436,7 @@ impl Project {
|
|||||||
// Even if we're initially connected, any future change of the status means we momentarily disconnected.
|
// Even if we're initially connected, any future change of the status means we momentarily disconnected.
|
||||||
if !is_connected || status.next().await.is_some() {
|
if !is_connected || status.next().await.is_some() {
|
||||||
if let Some(this) = this.upgrade(&cx) {
|
if let Some(this) = this.upgrade(&cx) {
|
||||||
this.update(&mut cx, |this, cx| this.project_unshared(cx))
|
this.update(&mut cx, |this, cx| this.removed_from_project(cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -550,7 +586,7 @@ impl Project {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn unregister(&mut self, cx: &mut ModelContext<Self>) {
|
fn unregister(&mut self, cx: &mut ModelContext<Self>) {
|
||||||
self.unshare(cx);
|
self.unshared(cx);
|
||||||
for worktree in &self.worktrees {
|
for worktree in &self.worktrees {
|
||||||
if let Some(worktree) = worktree.upgrade(cx) {
|
if let Some(worktree) = worktree.upgrade(cx) {
|
||||||
worktree.update(cx, |worktree, _| {
|
worktree.update(cx, |worktree, _| {
|
||||||
@ -810,64 +846,59 @@ impl Project {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn can_share(&self, cx: &AppContext) -> bool {
|
fn share(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<()>> {
|
||||||
self.is_local() && self.visible_worktrees(cx).next().is_some()
|
let project_id;
|
||||||
}
|
if let ProjectClientState::Local {
|
||||||
|
remote_id_rx,
|
||||||
|
is_shared,
|
||||||
|
..
|
||||||
|
} = &mut self.client_state
|
||||||
|
{
|
||||||
|
if *is_shared {
|
||||||
|
return Task::ready(Ok(()));
|
||||||
|
}
|
||||||
|
*is_shared = true;
|
||||||
|
if let Some(id) = *remote_id_rx.borrow() {
|
||||||
|
project_id = id;
|
||||||
|
} else {
|
||||||
|
return Task::ready(Err(anyhow!("project hasn't been registered")));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Task::ready(Err(anyhow!("can't share a remote project")));
|
||||||
|
};
|
||||||
|
|
||||||
pub fn share(&self, cx: &mut ModelContext<Self>) -> Task<Result<()>> {
|
for open_buffer in self.opened_buffers.values_mut() {
|
||||||
let rpc = self.client.clone();
|
match open_buffer {
|
||||||
cx.spawn(|this, mut cx| async move {
|
OpenBuffer::Strong(_) => {}
|
||||||
let project_id = this.update(&mut cx, |this, cx| {
|
OpenBuffer::Weak(buffer) => {
|
||||||
if let ProjectClientState::Local {
|
if let Some(buffer) = buffer.upgrade(cx) {
|
||||||
is_shared,
|
*open_buffer = OpenBuffer::Strong(buffer);
|
||||||
remote_id_rx,
|
|
||||||
..
|
|
||||||
} = &mut this.client_state
|
|
||||||
{
|
|
||||||
*is_shared = true;
|
|
||||||
|
|
||||||
for open_buffer in this.opened_buffers.values_mut() {
|
|
||||||
match open_buffer {
|
|
||||||
OpenBuffer::Strong(_) => {}
|
|
||||||
OpenBuffer::Weak(buffer) => {
|
|
||||||
if let Some(buffer) = buffer.upgrade(cx) {
|
|
||||||
*open_buffer = OpenBuffer::Strong(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OpenBuffer::Loading(_) => unreachable!(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
OpenBuffer::Loading(_) => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for worktree_handle in this.worktrees.iter_mut() {
|
for worktree_handle in self.worktrees.iter_mut() {
|
||||||
match worktree_handle {
|
match worktree_handle {
|
||||||
WorktreeHandle::Strong(_) => {}
|
WorktreeHandle::Strong(_) => {}
|
||||||
WorktreeHandle::Weak(worktree) => {
|
WorktreeHandle::Weak(worktree) => {
|
||||||
if let Some(worktree) = worktree.upgrade(cx) {
|
if let Some(worktree) = worktree.upgrade(cx) {
|
||||||
*worktree_handle = WorktreeHandle::Strong(worktree);
|
*worktree_handle = WorktreeHandle::Strong(worktree);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remote_id_rx
|
|
||||||
.borrow()
|
|
||||||
.ok_or_else(|| anyhow!("no project id"))
|
|
||||||
} else {
|
|
||||||
Err(anyhow!("can't share a remote project"))
|
|
||||||
}
|
}
|
||||||
})?;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rpc.request(proto::ShareProject { project_id }).await?;
|
let mut tasks = Vec::new();
|
||||||
|
for worktree in self.worktrees(cx).collect::<Vec<_>>() {
|
||||||
let mut tasks = Vec::new();
|
worktree.update(cx, |worktree, cx| {
|
||||||
this.update(&mut cx, |this, cx| {
|
let worktree = worktree.as_local_mut().unwrap();
|
||||||
for worktree in this.worktrees(cx).collect::<Vec<_>>() {
|
tasks.push(worktree.share(project_id, cx));
|
||||||
worktree.update(cx, |worktree, cx| {
|
|
||||||
let worktree = worktree.as_local_mut().unwrap();
|
|
||||||
tasks.push(worktree.share(project_id, cx));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cx.spawn(|this, mut cx| async move {
|
||||||
for task in tasks {
|
for task in tasks {
|
||||||
task.await?;
|
task.await?;
|
||||||
}
|
}
|
||||||
@ -876,15 +907,8 @@ impl Project {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unshare(&mut self, cx: &mut ModelContext<Self>) {
|
fn unshared(&mut self, cx: &mut ModelContext<Self>) {
|
||||||
let rpc = self.client.clone();
|
if let ProjectClientState::Local { is_shared, .. } = &mut self.client_state {
|
||||||
|
|
||||||
if let ProjectClientState::Local {
|
|
||||||
is_shared,
|
|
||||||
remote_id_rx,
|
|
||||||
..
|
|
||||||
} = &mut self.client_state
|
|
||||||
{
|
|
||||||
if !*is_shared {
|
if !*is_shared {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -913,17 +937,35 @@ impl Project {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(project_id) = *remote_id_rx.borrow() {
|
|
||||||
rpc.send(proto::UnshareProject { project_id }).log_err();
|
|
||||||
}
|
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
} else {
|
} else {
|
||||||
log::error!("attempted to unshare a remote project");
|
log::error!("attempted to unshare a remote project");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn project_unshared(&mut self, cx: &mut ModelContext<Self>) {
|
pub fn respond_to_join_request(
|
||||||
|
&mut self,
|
||||||
|
requester_id: u64,
|
||||||
|
allow: bool,
|
||||||
|
cx: &mut ModelContext<Self>,
|
||||||
|
) {
|
||||||
|
if let Some(project_id) = self.remote_id() {
|
||||||
|
let share = self.share(cx);
|
||||||
|
let client = self.client.clone();
|
||||||
|
cx.foreground()
|
||||||
|
.spawn(async move {
|
||||||
|
share.await?;
|
||||||
|
client.send(proto::RespondToJoinProjectRequest {
|
||||||
|
requester_id,
|
||||||
|
project_id,
|
||||||
|
allow,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.detach_and_log_err(cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn removed_from_project(&mut self, cx: &mut ModelContext<Self>) {
|
||||||
if let ProjectClientState::Remote {
|
if let ProjectClientState::Remote {
|
||||||
sharing_has_stopped,
|
sharing_has_stopped,
|
||||||
..
|
..
|
||||||
@ -3504,25 +3546,36 @@ impl Project {
|
|||||||
});
|
});
|
||||||
let worktree = worktree?;
|
let worktree = worktree?;
|
||||||
|
|
||||||
let (remote_project_id, is_shared) =
|
let remote_project_id = project.update(&mut cx, |project, cx| {
|
||||||
project.update(&mut cx, |project, cx| {
|
project.add_worktree(&worktree, cx);
|
||||||
project.add_worktree(&worktree, cx);
|
project.remote_id()
|
||||||
(project.remote_id(), project.is_shared())
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if let Some(project_id) = remote_project_id {
|
if let Some(project_id) = remote_project_id {
|
||||||
if is_shared {
|
// Because sharing is async, we may have *unshared* the project by the time it completes,
|
||||||
worktree
|
// in which case we need to register the worktree instead.
|
||||||
.update(&mut cx, |worktree, cx| {
|
loop {
|
||||||
worktree.as_local_mut().unwrap().share(project_id, cx)
|
if project.read_with(&cx, |project, _| project.is_shared()) {
|
||||||
})
|
if worktree
|
||||||
.await?;
|
.update(&mut cx, |worktree, cx| {
|
||||||
} else {
|
worktree.as_local_mut().unwrap().share(project_id, cx)
|
||||||
worktree
|
})
|
||||||
.update(&mut cx, |worktree, cx| {
|
.await
|
||||||
worktree.as_local_mut().unwrap().register(project_id, cx)
|
.is_ok()
|
||||||
})
|
{
|
||||||
.await?;
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
worktree
|
||||||
|
.update(&mut cx, |worktree, cx| {
|
||||||
|
worktree
|
||||||
|
.as_local_mut()
|
||||||
|
.unwrap()
|
||||||
|
.register(project_id, cx)
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3745,13 +3798,46 @@ impl Project {
|
|||||||
|
|
||||||
// RPC message handlers
|
// RPC message handlers
|
||||||
|
|
||||||
async fn handle_unshare_project(
|
async fn handle_request_join_project(
|
||||||
this: ModelHandle<Self>,
|
this: ModelHandle<Self>,
|
||||||
_: TypedEnvelope<proto::UnshareProject>,
|
message: TypedEnvelope<proto::RequestJoinProject>,
|
||||||
_: Arc<Client>,
|
_: Arc<Client>,
|
||||||
mut cx: AsyncAppContext,
|
mut cx: AsyncAppContext,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
this.update(&mut cx, |this, cx| this.project_unshared(cx));
|
let user_id = message.payload.requester_id;
|
||||||
|
if this.read_with(&cx, |project, _| {
|
||||||
|
project.collaborators.values().any(|c| c.user.id == user_id)
|
||||||
|
}) {
|
||||||
|
this.update(&mut cx, |this, cx| {
|
||||||
|
this.respond_to_join_request(user_id, true, cx)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let user_store = this.read_with(&cx, |this, _| this.user_store.clone());
|
||||||
|
let user = user_store
|
||||||
|
.update(&mut cx, |store, cx| store.fetch_user(user_id, cx))
|
||||||
|
.await?;
|
||||||
|
this.update(&mut cx, |_, cx| cx.emit(Event::ContactRequestedJoin(user)));
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_unregister_project(
|
||||||
|
this: ModelHandle<Self>,
|
||||||
|
_: TypedEnvelope<proto::UnregisterProject>,
|
||||||
|
_: Arc<Client>,
|
||||||
|
mut cx: AsyncAppContext,
|
||||||
|
) -> Result<()> {
|
||||||
|
this.update(&mut cx, |this, cx| this.removed_from_project(cx));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_project_unshared(
|
||||||
|
this: ModelHandle<Self>,
|
||||||
|
_: TypedEnvelope<proto::ProjectUnshared>,
|
||||||
|
_: Arc<Client>,
|
||||||
|
mut cx: AsyncAppContext,
|
||||||
|
) -> Result<()> {
|
||||||
|
this.update(&mut cx, |this, cx| this.unshared(cx));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3796,12 +3882,34 @@ impl Project {
|
|||||||
buffer.update(cx, |buffer, cx| buffer.remove_peer(replica_id, cx));
|
buffer.update(cx, |buffer, cx| buffer.remove_peer(replica_id, cx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.emit(Event::CollaboratorLeft(peer_id));
|
cx.emit(Event::CollaboratorLeft(peer_id));
|
||||||
cx.notify();
|
cx.notify();
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn handle_join_project_request_cancelled(
|
||||||
|
this: ModelHandle<Self>,
|
||||||
|
envelope: TypedEnvelope<proto::JoinProjectRequestCancelled>,
|
||||||
|
_: Arc<Client>,
|
||||||
|
mut cx: AsyncAppContext,
|
||||||
|
) -> Result<()> {
|
||||||
|
let user = this
|
||||||
|
.update(&mut cx, |this, cx| {
|
||||||
|
this.user_store.update(cx, |user_store, cx| {
|
||||||
|
user_store.fetch_user(envelope.payload.requester_id, cx)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
this.update(&mut cx, |_, cx| {
|
||||||
|
cx.emit(Event::ContactCancelledJoinRequest(user));
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn handle_register_worktree(
|
async fn handle_register_worktree(
|
||||||
this: ModelHandle<Self>,
|
this: ModelHandle<Self>,
|
||||||
envelope: TypedEnvelope<proto::RegisterWorktree>,
|
envelope: TypedEnvelope<proto::RegisterWorktree>,
|
||||||
@ -4052,6 +4160,7 @@ impl Project {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|op| language::proto::deserialize_operation(op))
|
.map(|op| language::proto::deserialize_operation(op))
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
let is_remote = this.is_remote();
|
||||||
match this.opened_buffers.entry(buffer_id) {
|
match this.opened_buffers.entry(buffer_id) {
|
||||||
hash_map::Entry::Occupied(mut e) => match e.get_mut() {
|
hash_map::Entry::Occupied(mut e) => match e.get_mut() {
|
||||||
OpenBuffer::Strong(buffer) => {
|
OpenBuffer::Strong(buffer) => {
|
||||||
@ -4061,6 +4170,11 @@ impl Project {
|
|||||||
OpenBuffer::Weak(_) => {}
|
OpenBuffer::Weak(_) => {}
|
||||||
},
|
},
|
||||||
hash_map::Entry::Vacant(e) => {
|
hash_map::Entry::Vacant(e) => {
|
||||||
|
assert!(
|
||||||
|
is_remote,
|
||||||
|
"received buffer update from {:?}",
|
||||||
|
envelope.original_sender_id
|
||||||
|
);
|
||||||
e.insert(OpenBuffer::Loading(ops));
|
e.insert(OpenBuffer::Loading(ops));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,8 +616,10 @@ impl LocalWorktree {
|
|||||||
let text = fs.load(&abs_path).await?;
|
let text = fs.load(&abs_path).await?;
|
||||||
// Eagerly populate the snapshot with an updated entry for the loaded file
|
// Eagerly populate the snapshot with an updated entry for the loaded file
|
||||||
let entry = this
|
let entry = this
|
||||||
.update(&mut cx, |this, _| {
|
.update(&mut cx, |this, cx| {
|
||||||
this.as_local().unwrap().refresh_entry(path, abs_path, None)
|
this.as_local()
|
||||||
|
.unwrap()
|
||||||
|
.refresh_entry(path, abs_path, None, cx)
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
this.update(&mut cx, |this, cx| this.poll_snapshot(cx));
|
this.update(&mut cx, |this, cx| this.poll_snapshot(cx));
|
||||||
@ -753,11 +755,12 @@ impl LocalWorktree {
|
|||||||
Some(cx.spawn(|this, mut cx| async move {
|
Some(cx.spawn(|this, mut cx| async move {
|
||||||
rename.await?;
|
rename.await?;
|
||||||
let entry = this
|
let entry = this
|
||||||
.update(&mut cx, |this, _| {
|
.update(&mut cx, |this, cx| {
|
||||||
this.as_local_mut().unwrap().refresh_entry(
|
this.as_local_mut().unwrap().refresh_entry(
|
||||||
new_path.clone(),
|
new_path.clone(),
|
||||||
abs_new_path,
|
abs_new_path,
|
||||||
Some(old_path),
|
Some(old_path),
|
||||||
|
cx,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
@ -793,10 +796,10 @@ impl LocalWorktree {
|
|||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
write.await?;
|
write.await?;
|
||||||
let entry = this
|
let entry = this
|
||||||
.update(&mut cx, |this, _| {
|
.update(&mut cx, |this, cx| {
|
||||||
this.as_local_mut()
|
this.as_local_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.refresh_entry(path, abs_path, None)
|
.refresh_entry(path, abs_path, None, cx)
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
@ -813,18 +816,17 @@ impl LocalWorktree {
|
|||||||
path: Arc<Path>,
|
path: Arc<Path>,
|
||||||
abs_path: PathBuf,
|
abs_path: PathBuf,
|
||||||
old_path: Option<Arc<Path>>,
|
old_path: Option<Arc<Path>>,
|
||||||
) -> impl Future<Output = Result<Entry>> {
|
cx: &mut ModelContext<Worktree>,
|
||||||
|
) -> Task<Result<Entry>> {
|
||||||
|
let fs = self.fs.clone();
|
||||||
let root_char_bag;
|
let root_char_bag;
|
||||||
let next_entry_id;
|
let next_entry_id;
|
||||||
let fs = self.fs.clone();
|
|
||||||
let shared_snapshots_tx = self.share.as_ref().map(|share| share.snapshots_tx.clone());
|
|
||||||
let snapshot = self.background_snapshot.clone();
|
|
||||||
{
|
{
|
||||||
let snapshot = snapshot.lock();
|
let snapshot = self.background_snapshot.lock();
|
||||||
root_char_bag = snapshot.root_char_bag;
|
root_char_bag = snapshot.root_char_bag;
|
||||||
next_entry_id = snapshot.next_entry_id.clone();
|
next_entry_id = snapshot.next_entry_id.clone();
|
||||||
}
|
}
|
||||||
async move {
|
cx.spawn_weak(|this, mut cx| async move {
|
||||||
let entry = Entry::new(
|
let entry = Entry::new(
|
||||||
path,
|
path,
|
||||||
&fs.metadata(&abs_path)
|
&fs.metadata(&abs_path)
|
||||||
@ -833,16 +835,29 @@ impl LocalWorktree {
|
|||||||
&next_entry_id,
|
&next_entry_id,
|
||||||
root_char_bag,
|
root_char_bag,
|
||||||
);
|
);
|
||||||
let mut snapshot = snapshot.lock();
|
|
||||||
if let Some(old_path) = old_path {
|
let this = this
|
||||||
snapshot.remove_path(&old_path);
|
.upgrade(&cx)
|
||||||
}
|
.ok_or_else(|| anyhow!("worktree was dropped"))?;
|
||||||
let entry = snapshot.insert_entry(entry, fs.as_ref());
|
let (entry, snapshot, snapshots_tx) = this.read_with(&cx, |this, _| {
|
||||||
if let Some(tx) = shared_snapshots_tx {
|
let this = this.as_local().unwrap();
|
||||||
tx.send(snapshot.clone()).await.ok();
|
let mut snapshot = this.background_snapshot.lock();
|
||||||
|
if let Some(old_path) = old_path {
|
||||||
|
snapshot.remove_path(&old_path);
|
||||||
|
}
|
||||||
|
let entry = snapshot.insert_entry(entry, fs.as_ref());
|
||||||
|
snapshot.scan_id += 1;
|
||||||
|
let snapshots_tx = this.share.as_ref().map(|s| s.snapshots_tx.clone());
|
||||||
|
(entry, snapshot.clone(), snapshots_tx)
|
||||||
|
});
|
||||||
|
this.update(&mut cx, |this, cx| this.poll_snapshot(cx));
|
||||||
|
|
||||||
|
if let Some(snapshots_tx) = snapshots_tx {
|
||||||
|
snapshots_tx.send(snapshot).await.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(entry)
|
Ok(entry)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register(
|
pub fn register(
|
||||||
@ -2171,8 +2186,7 @@ impl BackgroundScanner {
|
|||||||
let root_abs_path;
|
let root_abs_path;
|
||||||
let next_entry_id;
|
let next_entry_id;
|
||||||
{
|
{
|
||||||
let mut snapshot = self.snapshot.lock();
|
let snapshot = self.snapshot.lock();
|
||||||
snapshot.scan_id += 1;
|
|
||||||
root_char_bag = snapshot.root_char_bag;
|
root_char_bag = snapshot.root_char_bag;
|
||||||
root_abs_path = snapshot.abs_path.clone();
|
root_abs_path = snapshot.abs_path.clone();
|
||||||
next_entry_id = snapshot.next_entry_id.clone();
|
next_entry_id = snapshot.next_entry_id.clone();
|
||||||
@ -2197,6 +2211,7 @@ impl BackgroundScanner {
|
|||||||
let (scan_queue_tx, scan_queue_rx) = channel::unbounded();
|
let (scan_queue_tx, scan_queue_rx) = channel::unbounded();
|
||||||
{
|
{
|
||||||
let mut snapshot = self.snapshot.lock();
|
let mut snapshot = self.snapshot.lock();
|
||||||
|
snapshot.scan_id += 1;
|
||||||
for event in &events {
|
for event in &events {
|
||||||
if let Ok(path) = event.path.strip_prefix(&root_abs_path) {
|
if let Ok(path) = event.path.strip_prefix(&root_abs_path) {
|
||||||
snapshot.remove_path(&path);
|
snapshot.remove_path(&path);
|
||||||
|
@ -14,89 +14,91 @@ message Envelope {
|
|||||||
RegisterProject register_project = 8;
|
RegisterProject register_project = 8;
|
||||||
RegisterProjectResponse register_project_response = 9;
|
RegisterProjectResponse register_project_response = 9;
|
||||||
UnregisterProject unregister_project = 10;
|
UnregisterProject unregister_project = 10;
|
||||||
ShareProject share_project = 11;
|
RequestJoinProject request_join_project = 11;
|
||||||
UnshareProject unshare_project = 12;
|
RespondToJoinProjectRequest respond_to_join_project_request = 12;
|
||||||
JoinProject join_project = 13;
|
JoinProjectRequestCancelled join_project_request_cancelled = 13;
|
||||||
JoinProjectResponse join_project_response = 14;
|
JoinProject join_project = 14;
|
||||||
LeaveProject leave_project = 15;
|
JoinProjectResponse join_project_response = 15;
|
||||||
AddProjectCollaborator add_project_collaborator = 16;
|
LeaveProject leave_project = 16;
|
||||||
RemoveProjectCollaborator remove_project_collaborator = 17;
|
AddProjectCollaborator add_project_collaborator = 17;
|
||||||
|
RemoveProjectCollaborator remove_project_collaborator = 18;
|
||||||
|
ProjectUnshared project_unshared = 19;
|
||||||
|
|
||||||
GetDefinition get_definition = 18;
|
GetDefinition get_definition = 20;
|
||||||
GetDefinitionResponse get_definition_response = 19;
|
GetDefinitionResponse get_definition_response = 21;
|
||||||
GetReferences get_references = 20;
|
GetReferences get_references = 22;
|
||||||
GetReferencesResponse get_references_response = 21;
|
GetReferencesResponse get_references_response = 23;
|
||||||
GetDocumentHighlights get_document_highlights = 22;
|
GetDocumentHighlights get_document_highlights = 24;
|
||||||
GetDocumentHighlightsResponse get_document_highlights_response = 23;
|
GetDocumentHighlightsResponse get_document_highlights_response = 25;
|
||||||
GetProjectSymbols get_project_symbols = 24;
|
GetProjectSymbols get_project_symbols = 26;
|
||||||
GetProjectSymbolsResponse get_project_symbols_response = 25;
|
GetProjectSymbolsResponse get_project_symbols_response = 27;
|
||||||
OpenBufferForSymbol open_buffer_for_symbol = 26;
|
OpenBufferForSymbol open_buffer_for_symbol = 28;
|
||||||
OpenBufferForSymbolResponse open_buffer_for_symbol_response = 27;
|
OpenBufferForSymbolResponse open_buffer_for_symbol_response = 29;
|
||||||
|
|
||||||
RegisterWorktree register_worktree = 28;
|
RegisterWorktree register_worktree = 30;
|
||||||
UnregisterWorktree unregister_worktree = 29;
|
UnregisterWorktree unregister_worktree = 31;
|
||||||
UpdateWorktree update_worktree = 31;
|
UpdateWorktree update_worktree = 32;
|
||||||
|
|
||||||
CreateProjectEntry create_project_entry = 32;
|
CreateProjectEntry create_project_entry = 33;
|
||||||
RenameProjectEntry rename_project_entry = 33;
|
RenameProjectEntry rename_project_entry = 34;
|
||||||
DeleteProjectEntry delete_project_entry = 34;
|
DeleteProjectEntry delete_project_entry = 35;
|
||||||
ProjectEntryResponse project_entry_response = 35;
|
ProjectEntryResponse project_entry_response = 36;
|
||||||
|
|
||||||
UpdateDiagnosticSummary update_diagnostic_summary = 36;
|
UpdateDiagnosticSummary update_diagnostic_summary = 37;
|
||||||
StartLanguageServer start_language_server = 37;
|
StartLanguageServer start_language_server = 38;
|
||||||
UpdateLanguageServer update_language_server = 38;
|
UpdateLanguageServer update_language_server = 39;
|
||||||
|
|
||||||
OpenBufferById open_buffer_by_id = 39;
|
OpenBufferById open_buffer_by_id = 40;
|
||||||
OpenBufferByPath open_buffer_by_path = 40;
|
OpenBufferByPath open_buffer_by_path = 41;
|
||||||
OpenBufferResponse open_buffer_response = 41;
|
OpenBufferResponse open_buffer_response = 42;
|
||||||
UpdateBuffer update_buffer = 42;
|
UpdateBuffer update_buffer = 43;
|
||||||
UpdateBufferFile update_buffer_file = 43;
|
UpdateBufferFile update_buffer_file = 44;
|
||||||
SaveBuffer save_buffer = 44;
|
SaveBuffer save_buffer = 45;
|
||||||
BufferSaved buffer_saved = 45;
|
BufferSaved buffer_saved = 46;
|
||||||
BufferReloaded buffer_reloaded = 46;
|
BufferReloaded buffer_reloaded = 47;
|
||||||
ReloadBuffers reload_buffers = 47;
|
ReloadBuffers reload_buffers = 48;
|
||||||
ReloadBuffersResponse reload_buffers_response = 48;
|
ReloadBuffersResponse reload_buffers_response = 49;
|
||||||
FormatBuffers format_buffers = 49;
|
FormatBuffers format_buffers = 50;
|
||||||
FormatBuffersResponse format_buffers_response = 50;
|
FormatBuffersResponse format_buffers_response = 51;
|
||||||
GetCompletions get_completions = 51;
|
GetCompletions get_completions = 52;
|
||||||
GetCompletionsResponse get_completions_response = 52;
|
GetCompletionsResponse get_completions_response = 53;
|
||||||
ApplyCompletionAdditionalEdits apply_completion_additional_edits = 53;
|
ApplyCompletionAdditionalEdits apply_completion_additional_edits = 54;
|
||||||
ApplyCompletionAdditionalEditsResponse apply_completion_additional_edits_response = 54;
|
ApplyCompletionAdditionalEditsResponse apply_completion_additional_edits_response = 55;
|
||||||
GetCodeActions get_code_actions = 55;
|
GetCodeActions get_code_actions = 56;
|
||||||
GetCodeActionsResponse get_code_actions_response = 56;
|
GetCodeActionsResponse get_code_actions_response = 57;
|
||||||
ApplyCodeAction apply_code_action = 57;
|
ApplyCodeAction apply_code_action = 58;
|
||||||
ApplyCodeActionResponse apply_code_action_response = 58;
|
ApplyCodeActionResponse apply_code_action_response = 59;
|
||||||
PrepareRename prepare_rename = 59;
|
PrepareRename prepare_rename = 60;
|
||||||
PrepareRenameResponse prepare_rename_response = 60;
|
PrepareRenameResponse prepare_rename_response = 61;
|
||||||
PerformRename perform_rename = 61;
|
PerformRename perform_rename = 62;
|
||||||
PerformRenameResponse perform_rename_response = 62;
|
PerformRenameResponse perform_rename_response = 63;
|
||||||
SearchProject search_project = 63;
|
SearchProject search_project = 64;
|
||||||
SearchProjectResponse search_project_response = 64;
|
SearchProjectResponse search_project_response = 65;
|
||||||
|
|
||||||
GetChannels get_channels = 65;
|
GetChannels get_channels = 66;
|
||||||
GetChannelsResponse get_channels_response = 66;
|
GetChannelsResponse get_channels_response = 67;
|
||||||
JoinChannel join_channel = 67;
|
JoinChannel join_channel = 68;
|
||||||
JoinChannelResponse join_channel_response = 68;
|
JoinChannelResponse join_channel_response = 69;
|
||||||
LeaveChannel leave_channel = 69;
|
LeaveChannel leave_channel = 70;
|
||||||
SendChannelMessage send_channel_message = 70;
|
SendChannelMessage send_channel_message = 71;
|
||||||
SendChannelMessageResponse send_channel_message_response = 71;
|
SendChannelMessageResponse send_channel_message_response = 72;
|
||||||
ChannelMessageSent channel_message_sent = 72;
|
ChannelMessageSent channel_message_sent = 73;
|
||||||
GetChannelMessages get_channel_messages = 73;
|
GetChannelMessages get_channel_messages = 74;
|
||||||
GetChannelMessagesResponse get_channel_messages_response = 74;
|
GetChannelMessagesResponse get_channel_messages_response = 75;
|
||||||
|
|
||||||
UpdateContacts update_contacts = 75;
|
UpdateContacts update_contacts = 76;
|
||||||
|
|
||||||
GetUsers get_users = 76;
|
GetUsers get_users = 77;
|
||||||
FuzzySearchUsers fuzzy_search_users = 77;
|
FuzzySearchUsers fuzzy_search_users = 78;
|
||||||
UsersResponse users_response = 78;
|
UsersResponse users_response = 79;
|
||||||
RequestContact request_contact = 79;
|
RequestContact request_contact = 80;
|
||||||
RespondToContactRequest respond_to_contact_request = 80;
|
RespondToContactRequest respond_to_contact_request = 81;
|
||||||
RemoveContact remove_contact = 81;
|
RemoveContact remove_contact = 82;
|
||||||
|
|
||||||
Follow follow = 82;
|
Follow follow = 83;
|
||||||
FollowResponse follow_response = 83;
|
FollowResponse follow_response = 84;
|
||||||
UpdateFollowers update_followers = 84;
|
UpdateFollowers update_followers = 85;
|
||||||
Unfollow unfollow = 85;
|
Unfollow unfollow = 86;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,12 +126,20 @@ message UnregisterProject {
|
|||||||
uint64 project_id = 1;
|
uint64 project_id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ShareProject {
|
message RequestJoinProject {
|
||||||
uint64 project_id = 1;
|
uint64 requester_id = 1;
|
||||||
|
uint64 project_id = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UnshareProject {
|
message RespondToJoinProjectRequest {
|
||||||
uint64 project_id = 1;
|
uint64 requester_id = 1;
|
||||||
|
uint64 project_id = 2;
|
||||||
|
bool allow = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message JoinProjectRequestCancelled {
|
||||||
|
uint64 requester_id = 1;
|
||||||
|
uint64 project_id = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message JoinProject {
|
message JoinProject {
|
||||||
@ -137,10 +147,27 @@ message JoinProject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message JoinProjectResponse {
|
message JoinProjectResponse {
|
||||||
uint32 replica_id = 1;
|
oneof variant {
|
||||||
repeated Worktree worktrees = 2;
|
Accept accept = 1;
|
||||||
repeated Collaborator collaborators = 3;
|
Decline decline = 2;
|
||||||
repeated LanguageServer language_servers = 4;
|
}
|
||||||
|
|
||||||
|
message Accept {
|
||||||
|
uint32 replica_id = 1;
|
||||||
|
repeated Worktree worktrees = 2;
|
||||||
|
repeated Collaborator collaborators = 3;
|
||||||
|
repeated LanguageServer language_servers = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Decline {
|
||||||
|
Reason reason = 1;
|
||||||
|
|
||||||
|
enum Reason {
|
||||||
|
Declined = 0;
|
||||||
|
Closed = 1;
|
||||||
|
WentOffline = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message LeaveProject {
|
message LeaveProject {
|
||||||
@ -201,6 +228,10 @@ message RemoveProjectCollaborator {
|
|||||||
uint32 peer_id = 2;
|
uint32 peer_id = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ProjectUnshared {
|
||||||
|
uint64 project_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message GetDefinition {
|
message GetDefinition {
|
||||||
uint64 project_id = 1;
|
uint64 project_id = 1;
|
||||||
uint64 buffer_id = 2;
|
uint64 buffer_id = 2;
|
||||||
@ -882,7 +913,6 @@ message Contact {
|
|||||||
|
|
||||||
message ProjectMetadata {
|
message ProjectMetadata {
|
||||||
uint64 id = 1;
|
uint64 id = 1;
|
||||||
bool is_shared = 2;
|
|
||||||
repeated string worktree_root_names = 3;
|
repeated string worktree_root_names = 3;
|
||||||
repeated uint64 guests = 4;
|
repeated uint64 guests = 4;
|
||||||
}
|
}
|
||||||
|
@ -114,6 +114,7 @@ messages!(
|
|||||||
(JoinChannelResponse, Foreground),
|
(JoinChannelResponse, Foreground),
|
||||||
(JoinProject, Foreground),
|
(JoinProject, Foreground),
|
||||||
(JoinProjectResponse, Foreground),
|
(JoinProjectResponse, Foreground),
|
||||||
|
(JoinProjectRequestCancelled, Foreground),
|
||||||
(LeaveChannel, Foreground),
|
(LeaveChannel, Foreground),
|
||||||
(LeaveProject, Foreground),
|
(LeaveProject, Foreground),
|
||||||
(OpenBufferById, Background),
|
(OpenBufferById, Background),
|
||||||
@ -128,6 +129,7 @@ messages!(
|
|||||||
(ProjectEntryResponse, Foreground),
|
(ProjectEntryResponse, Foreground),
|
||||||
(RegisterProjectResponse, Foreground),
|
(RegisterProjectResponse, Foreground),
|
||||||
(Ping, Foreground),
|
(Ping, Foreground),
|
||||||
|
(ProjectUnshared, Foreground),
|
||||||
(RegisterProject, Foreground),
|
(RegisterProject, Foreground),
|
||||||
(RegisterWorktree, Foreground),
|
(RegisterWorktree, Foreground),
|
||||||
(ReloadBuffers, Foreground),
|
(ReloadBuffers, Foreground),
|
||||||
@ -135,19 +137,19 @@ messages!(
|
|||||||
(RemoveProjectCollaborator, Foreground),
|
(RemoveProjectCollaborator, Foreground),
|
||||||
(RenameProjectEntry, Foreground),
|
(RenameProjectEntry, Foreground),
|
||||||
(RequestContact, Foreground),
|
(RequestContact, Foreground),
|
||||||
|
(RequestJoinProject, Foreground),
|
||||||
(RespondToContactRequest, Foreground),
|
(RespondToContactRequest, Foreground),
|
||||||
|
(RespondToJoinProjectRequest, Foreground),
|
||||||
(SaveBuffer, Foreground),
|
(SaveBuffer, Foreground),
|
||||||
(SearchProject, Background),
|
(SearchProject, Background),
|
||||||
(SearchProjectResponse, Background),
|
(SearchProjectResponse, Background),
|
||||||
(SendChannelMessage, Foreground),
|
(SendChannelMessage, Foreground),
|
||||||
(SendChannelMessageResponse, Foreground),
|
(SendChannelMessageResponse, Foreground),
|
||||||
(ShareProject, Foreground),
|
|
||||||
(StartLanguageServer, Foreground),
|
(StartLanguageServer, Foreground),
|
||||||
(Test, Foreground),
|
(Test, Foreground),
|
||||||
(Unfollow, Foreground),
|
(Unfollow, Foreground),
|
||||||
(UnregisterProject, Foreground),
|
(UnregisterProject, Foreground),
|
||||||
(UnregisterWorktree, Foreground),
|
(UnregisterWorktree, Foreground),
|
||||||
(UnshareProject, Foreground),
|
|
||||||
(UpdateBuffer, Foreground),
|
(UpdateBuffer, Foreground),
|
||||||
(UpdateBufferFile, Foreground),
|
(UpdateBufferFile, Foreground),
|
||||||
(UpdateContacts, Foreground),
|
(UpdateContacts, Foreground),
|
||||||
@ -195,7 +197,6 @@ request_messages!(
|
|||||||
(SaveBuffer, BufferSaved),
|
(SaveBuffer, BufferSaved),
|
||||||
(SearchProject, SearchProjectResponse),
|
(SearchProject, SearchProjectResponse),
|
||||||
(SendChannelMessage, SendChannelMessageResponse),
|
(SendChannelMessage, SendChannelMessageResponse),
|
||||||
(ShareProject, Ack),
|
|
||||||
(Test, Test),
|
(Test, Test),
|
||||||
(UpdateBuffer, Ack),
|
(UpdateBuffer, Ack),
|
||||||
(UpdateWorktree, Ack),
|
(UpdateWorktree, Ack),
|
||||||
@ -220,20 +221,23 @@ entity_messages!(
|
|||||||
GetReferences,
|
GetReferences,
|
||||||
GetProjectSymbols,
|
GetProjectSymbols,
|
||||||
JoinProject,
|
JoinProject,
|
||||||
|
JoinProjectRequestCancelled,
|
||||||
LeaveProject,
|
LeaveProject,
|
||||||
OpenBufferById,
|
OpenBufferById,
|
||||||
OpenBufferByPath,
|
OpenBufferByPath,
|
||||||
OpenBufferForSymbol,
|
OpenBufferForSymbol,
|
||||||
PerformRename,
|
PerformRename,
|
||||||
PrepareRename,
|
PrepareRename,
|
||||||
|
ProjectUnshared,
|
||||||
ReloadBuffers,
|
ReloadBuffers,
|
||||||
RemoveProjectCollaborator,
|
RemoveProjectCollaborator,
|
||||||
|
RequestJoinProject,
|
||||||
SaveBuffer,
|
SaveBuffer,
|
||||||
SearchProject,
|
SearchProject,
|
||||||
StartLanguageServer,
|
StartLanguageServer,
|
||||||
Unfollow,
|
Unfollow,
|
||||||
|
UnregisterProject,
|
||||||
UnregisterWorktree,
|
UnregisterWorktree,
|
||||||
UnshareProject,
|
|
||||||
UpdateBuffer,
|
UpdateBuffer,
|
||||||
UpdateBufferFile,
|
UpdateBufferFile,
|
||||||
UpdateDiagnosticSummary,
|
UpdateDiagnosticSummary,
|
||||||
|
@ -6,4 +6,4 @@ pub use conn::Connection;
|
|||||||
pub use peer::*;
|
pub use peer::*;
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
||||||
pub const PROTOCOL_VERSION: u32 = 17;
|
pub const PROTOCOL_VERSION: u32 = 18;
|
||||||
|
@ -48,6 +48,8 @@ pub struct Workspace {
|
|||||||
pub modal: ContainerStyle,
|
pub modal: ContainerStyle,
|
||||||
pub notification: ContainerStyle,
|
pub notification: ContainerStyle,
|
||||||
pub notifications: Notifications,
|
pub notifications: Notifications,
|
||||||
|
pub joining_project_avatar: ImageStyle,
|
||||||
|
pub joining_project_message: ContainedText,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Default)]
|
#[derive(Clone, Deserialize, Default)]
|
||||||
@ -251,8 +253,7 @@ pub struct ContactsPanel {
|
|||||||
pub add_contact_button: IconButton,
|
pub add_contact_button: IconButton,
|
||||||
pub header_row: Interactive<ContainedText>,
|
pub header_row: Interactive<ContainedText>,
|
||||||
pub contact_row: Interactive<ContainerStyle>,
|
pub contact_row: Interactive<ContainerStyle>,
|
||||||
pub shared_project_row: Interactive<ProjectRow>,
|
pub project_row: Interactive<ProjectRow>,
|
||||||
pub unshared_project_row: Interactive<ProjectRow>,
|
|
||||||
pub row_height: f32,
|
pub row_height: f32,
|
||||||
pub contact_avatar: ImageStyle,
|
pub contact_avatar: ImageStyle,
|
||||||
pub contact_username: ContainedText,
|
pub contact_username: ContainedText,
|
||||||
|
190
crates/workspace/src/waiting_room.rs
Normal file
190
crates/workspace/src/waiting_room.rs
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
use crate::{
|
||||||
|
sidebar::{Side, ToggleSidebarItem},
|
||||||
|
AppState, ToggleFollow,
|
||||||
|
};
|
||||||
|
use anyhow::Result;
|
||||||
|
use client::{proto, Client, Contact};
|
||||||
|
use gpui::{
|
||||||
|
elements::*, ElementBox, Entity, ImageData, MutableAppContext, RenderContext, Task, View,
|
||||||
|
ViewContext,
|
||||||
|
};
|
||||||
|
use project::Project;
|
||||||
|
use settings::Settings;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use util::ResultExt;
|
||||||
|
|
||||||
|
pub struct WaitingRoom {
|
||||||
|
project_id: u64,
|
||||||
|
avatar: Option<Arc<ImageData>>,
|
||||||
|
message: String,
|
||||||
|
waiting: bool,
|
||||||
|
client: Arc<Client>,
|
||||||
|
_join_task: Task<Result<()>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Entity for WaitingRoom {
|
||||||
|
type Event = ();
|
||||||
|
|
||||||
|
fn release(&mut self, _: &mut MutableAppContext) {
|
||||||
|
if self.waiting {
|
||||||
|
self.client
|
||||||
|
.send(proto::LeaveProject {
|
||||||
|
project_id: self.project_id,
|
||||||
|
})
|
||||||
|
.log_err();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl View for WaitingRoom {
|
||||||
|
fn ui_name() -> &'static str {
|
||||||
|
"WaitingRoom"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
|
||||||
|
let theme = &cx.global::<Settings>().theme.workspace;
|
||||||
|
|
||||||
|
Flex::column()
|
||||||
|
.with_children(self.avatar.clone().map(|avatar| {
|
||||||
|
Image::new(avatar)
|
||||||
|
.with_style(theme.joining_project_avatar)
|
||||||
|
.aligned()
|
||||||
|
.boxed()
|
||||||
|
}))
|
||||||
|
.with_child(
|
||||||
|
Text::new(
|
||||||
|
self.message.clone(),
|
||||||
|
theme.joining_project_message.text.clone(),
|
||||||
|
)
|
||||||
|
.contained()
|
||||||
|
.with_style(theme.joining_project_message.container)
|
||||||
|
.aligned()
|
||||||
|
.boxed(),
|
||||||
|
)
|
||||||
|
.aligned()
|
||||||
|
.contained()
|
||||||
|
.with_background_color(theme.background)
|
||||||
|
.boxed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WaitingRoom {
|
||||||
|
pub fn new(
|
||||||
|
contact: Arc<Contact>,
|
||||||
|
project_index: usize,
|
||||||
|
app_state: Arc<AppState>,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) -> Self {
|
||||||
|
let project_id = contact.projects[project_index].id;
|
||||||
|
let client = app_state.client.clone();
|
||||||
|
let _join_task = cx.spawn_weak({
|
||||||
|
let contact = contact.clone();
|
||||||
|
|this, mut cx| async move {
|
||||||
|
let project = Project::remote(
|
||||||
|
project_id,
|
||||||
|
app_state.client.clone(),
|
||||||
|
app_state.user_store.clone(),
|
||||||
|
app_state.languages.clone(),
|
||||||
|
app_state.fs.clone(),
|
||||||
|
&mut cx,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
if let Some(this) = this.upgrade(&cx) {
|
||||||
|
this.update(&mut cx, |this, cx| {
|
||||||
|
this.waiting = false;
|
||||||
|
match project {
|
||||||
|
Ok(project) => {
|
||||||
|
cx.replace_root_view(|cx| {
|
||||||
|
let mut workspace = (app_state.build_workspace)(
|
||||||
|
project.clone(),
|
||||||
|
&app_state,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
workspace.toggle_sidebar_item(
|
||||||
|
&ToggleSidebarItem {
|
||||||
|
side: Side::Left,
|
||||||
|
item_index: 0,
|
||||||
|
},
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
if let Some((host_peer_id, _)) = project
|
||||||
|
.read(cx)
|
||||||
|
.collaborators()
|
||||||
|
.iter()
|
||||||
|
.find(|(_, collaborator)| collaborator.replica_id == 0)
|
||||||
|
{
|
||||||
|
if let Some(follow) = workspace
|
||||||
|
.toggle_follow(&ToggleFollow(*host_peer_id), cx)
|
||||||
|
{
|
||||||
|
follow.detach_and_log_err(cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
workspace
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Err(error @ _) => {
|
||||||
|
let login = &contact.user.github_login;
|
||||||
|
let message = match error {
|
||||||
|
project::JoinProjectError::HostDeclined => {
|
||||||
|
format!("@{} declined your request.", login)
|
||||||
|
}
|
||||||
|
project::JoinProjectError::HostClosedProject => {
|
||||||
|
format!(
|
||||||
|
"@{} closed their copy of {}.",
|
||||||
|
login,
|
||||||
|
humanize_list(
|
||||||
|
&contact.projects[project_index]
|
||||||
|
.worktree_root_names
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
project::JoinProjectError::HostWentOffline => {
|
||||||
|
format!("@{} went offline.", login)
|
||||||
|
}
|
||||||
|
project::JoinProjectError::Other(error) => {
|
||||||
|
log::error!("error joining project: {}", error);
|
||||||
|
"An error occurred.".to_string()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.message = message;
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self {
|
||||||
|
project_id,
|
||||||
|
avatar: contact.user.avatar.clone(),
|
||||||
|
message: format!(
|
||||||
|
"Asking to join @{}'s copy of {}...",
|
||||||
|
contact.user.github_login,
|
||||||
|
humanize_list(&contact.projects[project_index].worktree_root_names)
|
||||||
|
),
|
||||||
|
waiting: true,
|
||||||
|
client,
|
||||||
|
_join_task,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn humanize_list<'a>(items: impl IntoIterator<Item = &'a String>) -> String {
|
||||||
|
let mut list = String::new();
|
||||||
|
let mut items = items.into_iter().enumerate().peekable();
|
||||||
|
while let Some((ix, item)) = items.next() {
|
||||||
|
if ix > 0 {
|
||||||
|
list.push_str(", ");
|
||||||
|
if items.peek().is_none() {
|
||||||
|
list.push_str("and ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list.push_str(item);
|
||||||
|
}
|
||||||
|
list
|
||||||
|
}
|
@ -5,10 +5,12 @@ pub mod pane_group;
|
|||||||
pub mod sidebar;
|
pub mod sidebar;
|
||||||
mod status_bar;
|
mod status_bar;
|
||||||
mod toolbar;
|
mod toolbar;
|
||||||
|
mod waiting_room;
|
||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use client::{
|
use client::{
|
||||||
proto, Authenticate, ChannelList, Client, PeerId, Subscription, TypedEnvelope, User, UserStore,
|
proto, Authenticate, ChannelList, Client, Contact, PeerId, Subscription, TypedEnvelope, User,
|
||||||
|
UserStore,
|
||||||
};
|
};
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use collections::{hash_map, HashMap, HashSet};
|
use collections::{hash_map, HashMap, HashSet};
|
||||||
@ -49,6 +51,7 @@ use std::{
|
|||||||
use theme::{Theme, ThemeRegistry};
|
use theme::{Theme, ThemeRegistry};
|
||||||
pub use toolbar::{ToolbarItemLocation, ToolbarItemView};
|
pub use toolbar::{ToolbarItemLocation, ToolbarItemView};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
use waiting_room::WaitingRoom;
|
||||||
|
|
||||||
type ProjectItemBuilders = HashMap<
|
type ProjectItemBuilders = HashMap<
|
||||||
TypeId,
|
TypeId,
|
||||||
@ -72,7 +75,6 @@ type FollowableItemBuilders = HashMap<
|
|||||||
actions!(
|
actions!(
|
||||||
workspace,
|
workspace,
|
||||||
[
|
[
|
||||||
ToggleShare,
|
|
||||||
Unfollow,
|
Unfollow,
|
||||||
Save,
|
Save,
|
||||||
ActivatePreviousPane,
|
ActivatePreviousPane,
|
||||||
@ -98,7 +100,8 @@ pub struct ToggleFollow(pub PeerId);
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct JoinProject {
|
pub struct JoinProject {
|
||||||
pub project_id: u64,
|
pub contact: Arc<Contact>,
|
||||||
|
pub project_index: usize,
|
||||||
pub app_state: Arc<AppState>,
|
pub app_state: Arc<AppState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,10 +121,14 @@ pub fn init(client: &Arc<Client>, cx: &mut MutableAppContext) {
|
|||||||
open_new(&action.0, cx)
|
open_new(&action.0, cx)
|
||||||
});
|
});
|
||||||
cx.add_global_action(move |action: &JoinProject, cx: &mut MutableAppContext| {
|
cx.add_global_action(move |action: &JoinProject, cx: &mut MutableAppContext| {
|
||||||
join_project(action.project_id, &action.app_state, cx).detach();
|
join_project(
|
||||||
|
action.contact.clone(),
|
||||||
|
action.project_index,
|
||||||
|
&action.app_state,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.add_action(Workspace::toggle_share);
|
|
||||||
cx.add_async_action(Workspace::toggle_follow);
|
cx.add_async_action(Workspace::toggle_follow);
|
||||||
cx.add_async_action(Workspace::follow_next_collaborator);
|
cx.add_async_action(Workspace::follow_next_collaborator);
|
||||||
cx.add_action(
|
cx.add_action(
|
||||||
@ -692,6 +699,7 @@ impl WorkspaceParams {
|
|||||||
|
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
PaneAdded(ViewHandle<Pane>),
|
PaneAdded(ViewHandle<Pane>),
|
||||||
|
ContactRequestedJoin(u64),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Workspace {
|
pub struct Workspace {
|
||||||
@ -1366,18 +1374,6 @@ impl Workspace {
|
|||||||
&self.active_pane
|
&self.active_pane
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_share(&mut self, _: &ToggleShare, cx: &mut ViewContext<Self>) {
|
|
||||||
self.project.update(cx, |project, cx| {
|
|
||||||
if project.is_local() {
|
|
||||||
if project.is_shared() {
|
|
||||||
project.unshare(cx);
|
|
||||||
} else if project.can_share(cx) {
|
|
||||||
project.share(cx).detach();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn project_remote_id_changed(&mut self, remote_id: Option<u64>, cx: &mut ViewContext<Self>) {
|
fn project_remote_id_changed(&mut self, remote_id: Option<u64>, cx: &mut ViewContext<Self>) {
|
||||||
if let Some(remote_id) = remote_id {
|
if let Some(remote_id) = remote_id {
|
||||||
self.remote_entity_subscription =
|
self.remote_entity_subscription =
|
||||||
@ -1580,7 +1576,6 @@ impl Workspace {
|
|||||||
cx,
|
cx,
|
||||||
))
|
))
|
||||||
.with_children(self.render_connection_status(cx))
|
.with_children(self.render_connection_status(cx))
|
||||||
.with_children(self.render_share_icon(theme, cx))
|
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
.right()
|
.right()
|
||||||
@ -1701,39 +1696,6 @@ impl Workspace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_share_icon(&self, theme: &Theme, cx: &mut RenderContext<Self>) -> Option<ElementBox> {
|
|
||||||
if self.project().read(cx).is_local()
|
|
||||||
&& self.client.user_id().is_some()
|
|
||||||
&& self.project().read(cx).can_share(cx)
|
|
||||||
{
|
|
||||||
Some(
|
|
||||||
MouseEventHandler::new::<ToggleShare, _, _>(0, cx, |state, cx| {
|
|
||||||
let style = &theme
|
|
||||||
.workspace
|
|
||||||
.titlebar
|
|
||||||
.share_icon
|
|
||||||
.style_for(state, self.project().read(cx).is_shared());
|
|
||||||
Svg::new("icons/share.svg")
|
|
||||||
.with_color(style.color)
|
|
||||||
.constrained()
|
|
||||||
.with_height(14.)
|
|
||||||
.aligned()
|
|
||||||
.contained()
|
|
||||||
.with_style(style.container)
|
|
||||||
.constrained()
|
|
||||||
.with_width(24.)
|
|
||||||
.aligned()
|
|
||||||
.boxed()
|
|
||||||
})
|
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
|
||||||
.on_click(|_, cx| cx.dispatch_action(ToggleShare))
|
|
||||||
.boxed(),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render_disconnected_overlay(&self, cx: &AppContext) -> Option<ElementBox> {
|
fn render_disconnected_overlay(&self, cx: &AppContext) -> Option<ElementBox> {
|
||||||
if self.project.read(cx).is_read_only() {
|
if self.project.read(cx).is_read_only() {
|
||||||
let theme = &cx.global::<Settings>().theme;
|
let theme = &cx.global::<Settings>().theme;
|
||||||
@ -2315,36 +2277,25 @@ pub fn open_paths(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn join_project(
|
pub fn join_project(
|
||||||
project_id: u64,
|
contact: Arc<Contact>,
|
||||||
|
project_index: usize,
|
||||||
app_state: &Arc<AppState>,
|
app_state: &Arc<AppState>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut MutableAppContext,
|
||||||
) -> Task<Result<ViewHandle<Workspace>>> {
|
) {
|
||||||
|
let project_id = contact.projects[project_index].id;
|
||||||
|
|
||||||
for window_id in cx.window_ids().collect::<Vec<_>>() {
|
for window_id in cx.window_ids().collect::<Vec<_>>() {
|
||||||
if let Some(workspace) = cx.root_view::<Workspace>(window_id) {
|
if let Some(workspace) = cx.root_view::<Workspace>(window_id) {
|
||||||
if workspace.read(cx).project().read(cx).remote_id() == Some(project_id) {
|
if workspace.read(cx).project().read(cx).remote_id() == Some(project_id) {
|
||||||
return Task::ready(Ok(workspace));
|
cx.activate_window(window_id);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let app_state = app_state.clone();
|
cx.add_window((app_state.build_window_options)(), |cx| {
|
||||||
cx.spawn(|mut cx| async move {
|
WaitingRoom::new(contact, project_index, app_state.clone(), cx)
|
||||||
let project = Project::remote(
|
});
|
||||||
project_id,
|
|
||||||
app_state.client.clone(),
|
|
||||||
app_state.user_store.clone(),
|
|
||||||
app_state.languages.clone(),
|
|
||||||
app_state.fs.clone(),
|
|
||||||
&mut cx,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
Ok(cx.update(|cx| {
|
|
||||||
cx.add_window((app_state.build_window_options)(), |cx| {
|
|
||||||
(app_state.build_workspace)(project, &app_state, cx)
|
|
||||||
})
|
|
||||||
.1
|
|
||||||
}))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_new(app_state: &Arc<AppState>, cx: &mut MutableAppContext) {
|
fn open_new(app_state: &Arc<AppState>, cx: &mut MutableAppContext) {
|
||||||
|
@ -123,17 +123,18 @@ pub fn build_workspace(
|
|||||||
cx.subscribe(&cx.handle(), {
|
cx.subscribe(&cx.handle(), {
|
||||||
let project = project.clone();
|
let project = project.clone();
|
||||||
move |_, _, event, cx| {
|
move |_, _, event, cx| {
|
||||||
let workspace::Event::PaneAdded(pane) = event;
|
if let workspace::Event::PaneAdded(pane) = event {
|
||||||
pane.update(cx, |pane, cx| {
|
pane.update(cx, |pane, cx| {
|
||||||
pane.toolbar().update(cx, |toolbar, cx| {
|
pane.toolbar().update(cx, |toolbar, cx| {
|
||||||
let breadcrumbs = cx.add_view(|_| Breadcrumbs::new(project.clone()));
|
let breadcrumbs = cx.add_view(|_| Breadcrumbs::new(project.clone()));
|
||||||
toolbar.add_item(breadcrumbs, cx);
|
toolbar.add_item(breadcrumbs, cx);
|
||||||
let buffer_search_bar = cx.add_view(|cx| BufferSearchBar::new(cx));
|
let buffer_search_bar = cx.add_view(|cx| BufferSearchBar::new(cx));
|
||||||
toolbar.add_item(buffer_search_bar, cx);
|
toolbar.add_item(buffer_search_bar, cx);
|
||||||
let project_search_bar = cx.add_view(|_| ProjectSearchBar::new());
|
let project_search_bar = cx.add_view(|_| ProjectSearchBar::new());
|
||||||
toolbar.add_item(project_search_bar, cx);
|
toolbar.add_item(project_search_bar, cx);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
7
script/watch-themes
Executable file
7
script/watch-themes
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd styles
|
||||||
|
npm install
|
||||||
|
npm run watch
|
531
styles/dist/dark.json
vendored
531
styles/dist/dark.json
vendored
@ -1,531 +0,0 @@
|
|||||||
{
|
|
||||||
"meta": {
|
|
||||||
"themeName": "cave-dark"
|
|
||||||
},
|
|
||||||
"text": {
|
|
||||||
"primary": {
|
|
||||||
"value": "#e2dfe7",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"secondary": {
|
|
||||||
"value": "#8b8792",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"muted": {
|
|
||||||
"value": "#8b8792",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"placeholder": {
|
|
||||||
"value": "#7e7887",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#efecf4",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"feature": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"ok": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"error": {
|
|
||||||
"value": "#be4678",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"warning": {
|
|
||||||
"value": "#a06e3b",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"info": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"icon": {
|
|
||||||
"primary": {
|
|
||||||
"value": "#e2dfe7",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"secondary": {
|
|
||||||
"value": "#8b8792",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"muted": {
|
|
||||||
"value": "#8b8792",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"placeholder": {
|
|
||||||
"value": "#7e7887",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#efecf4",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"feature": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"ok": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"error": {
|
|
||||||
"value": "#be4678",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"warning": {
|
|
||||||
"value": "#a06e3b",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"info": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"background": {
|
|
||||||
"100": {
|
|
||||||
"base": {
|
|
||||||
"value": "#26232a",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#5852603d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#5852605c",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"300": {
|
|
||||||
"base": {
|
|
||||||
"value": "#26232a",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#5852603d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#5852605c",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"base": {
|
|
||||||
"value": "#19171c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#26232a3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#26232a5c",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"on300": {
|
|
||||||
"base": {
|
|
||||||
"value": "#19171c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#26232a3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#26232a7a",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"on500": {
|
|
||||||
"base": {
|
|
||||||
"value": "#26232a",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#5852603d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#5852607a",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ok": {
|
|
||||||
"base": {
|
|
||||||
"value": "#2a929226",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#2a929233",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#2a929240",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"error": {
|
|
||||||
"base": {
|
|
||||||
"value": "#be467826",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#be467833",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#be467840",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"warning": {
|
|
||||||
"base": {
|
|
||||||
"value": "#a06e3b26",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#a06e3b33",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#a06e3b40",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"info": {
|
|
||||||
"base": {
|
|
||||||
"value": "#576ddb26",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#576ddb33",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#576ddb40",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"border": {
|
|
||||||
"primary": {
|
|
||||||
"value": "#19171c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"secondary": {
|
|
||||||
"value": "#26232a",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"muted": {
|
|
||||||
"value": "#655f6d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#655f6d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"onMedia": {
|
|
||||||
"value": "#19171c1a",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"ok": {
|
|
||||||
"value": "#2a929226",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"error": {
|
|
||||||
"value": "#be467826",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"warning": {
|
|
||||||
"value": "#a06e3b26",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"info": {
|
|
||||||
"value": "#576ddb26",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"editor": {
|
|
||||||
"background": {
|
|
||||||
"value": "#19171c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"indent_guide": {
|
|
||||||
"value": "#655f6d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"indent_guide_active": {
|
|
||||||
"value": "#26232a",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"line": {
|
|
||||||
"active": {
|
|
||||||
"value": "#efecf412",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"highlighted": {
|
|
||||||
"value": "#efecf41f",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"inserted": {
|
|
||||||
"value": "#2a929240",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"deleted": {
|
|
||||||
"value": "#be467840",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"modified": {
|
|
||||||
"value": "#576ddb40",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"highlight": {
|
|
||||||
"selection": {
|
|
||||||
"value": "#576ddb3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"occurrence": {
|
|
||||||
"value": "#efecf41f",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"activeOccurrence": {
|
|
||||||
"value": "#efecf43d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"matchingBracket": {
|
|
||||||
"value": "#26232a5c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"match": {
|
|
||||||
"value": "#955ae77a",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"activeMatch": {
|
|
||||||
"value": "#955ae7b8",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"related": {
|
|
||||||
"value": "#26232a3d",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"gutter": {
|
|
||||||
"primary": {
|
|
||||||
"value": "#7e7887",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#efecf4",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"syntax": {
|
|
||||||
"primary": {
|
|
||||||
"value": "#efecf4",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"comment": {
|
|
||||||
"value": "#8b8792",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"keyword": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"function": {
|
|
||||||
"value": "#a06e3b",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"value": "#398bc6",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"variant": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"property": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"enum": {
|
|
||||||
"value": "#aa573c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"operator": {
|
|
||||||
"value": "#aa573c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"string": {
|
|
||||||
"value": "#aa573c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"number": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"boolean": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"player": {
|
|
||||||
"1": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#576ddb3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#576ddbcc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"2": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#2a92923d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#2a9292cc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#bf40bf",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#bf40bf",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#bf40bf3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#bf40bfcc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"4": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#aa573c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#aa573c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#aa573c3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#aa573ccc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"5": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#955ae7",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#955ae7",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#955ae73d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#955ae7cc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"6": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#398bc6",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#398bc6",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#398bc63d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#398bc6cc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"7": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#be4678",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#be4678",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#be46783d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#be4678cc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"8": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#a06e3b",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#a06e3b",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#a06e3b3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#a06e3bcc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"shadowAlpha": {
|
|
||||||
"value": 0.24,
|
|
||||||
"type": "number"
|
|
||||||
}
|
|
||||||
}
|
|
531
styles/dist/light.json
vendored
531
styles/dist/light.json
vendored
@ -1,531 +0,0 @@
|
|||||||
{
|
|
||||||
"meta": {
|
|
||||||
"themeName": "cave-light"
|
|
||||||
},
|
|
||||||
"text": {
|
|
||||||
"primary": {
|
|
||||||
"value": "#26232a",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"secondary": {
|
|
||||||
"value": "#585260",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"muted": {
|
|
||||||
"value": "#585260",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"placeholder": {
|
|
||||||
"value": "#655f6d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#19171c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"feature": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"ok": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"error": {
|
|
||||||
"value": "#be4678",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"warning": {
|
|
||||||
"value": "#a06e3b",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"info": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"icon": {
|
|
||||||
"primary": {
|
|
||||||
"value": "#26232a",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"secondary": {
|
|
||||||
"value": "#585260",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"muted": {
|
|
||||||
"value": "#585260",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"placeholder": {
|
|
||||||
"value": "#655f6d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#19171c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"feature": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"ok": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"error": {
|
|
||||||
"value": "#be4678",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"warning": {
|
|
||||||
"value": "#a06e3b",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"info": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"background": {
|
|
||||||
"100": {
|
|
||||||
"base": {
|
|
||||||
"value": "#e2dfe7",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#8b87921f",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#8b87922e",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"300": {
|
|
||||||
"base": {
|
|
||||||
"value": "#e2dfe7",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#8b87921f",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#8b87922e",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"500": {
|
|
||||||
"base": {
|
|
||||||
"value": "#efecf4",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#e2dfe71f",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#e2dfe72e",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"on300": {
|
|
||||||
"base": {
|
|
||||||
"value": "#efecf4",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#e2dfe71f",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#e2dfe73d",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"on500": {
|
|
||||||
"base": {
|
|
||||||
"value": "#e2dfe7",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#8b87921f",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#8b87923d",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ok": {
|
|
||||||
"base": {
|
|
||||||
"value": "#2a929226",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#2a929233",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#2a929240",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"error": {
|
|
||||||
"base": {
|
|
||||||
"value": "#be467826",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#be467833",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#be467840",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"warning": {
|
|
||||||
"base": {
|
|
||||||
"value": "#a06e3b26",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#a06e3b33",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#a06e3b40",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"info": {
|
|
||||||
"base": {
|
|
||||||
"value": "#576ddb26",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"hovered": {
|
|
||||||
"value": "#576ddb33",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#576ddb40",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"border": {
|
|
||||||
"primary": {
|
|
||||||
"value": "#efecf4",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"secondary": {
|
|
||||||
"value": "#e2dfe7",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"muted": {
|
|
||||||
"value": "#7e7887",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#7e7887",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"onMedia": {
|
|
||||||
"value": "#efecf41a",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"ok": {
|
|
||||||
"value": "#2a929226",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"error": {
|
|
||||||
"value": "#be467826",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"warning": {
|
|
||||||
"value": "#a06e3b26",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"info": {
|
|
||||||
"value": "#576ddb26",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"editor": {
|
|
||||||
"background": {
|
|
||||||
"value": "#efecf4",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"indent_guide": {
|
|
||||||
"value": "#7e7887",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"indent_guide_active": {
|
|
||||||
"value": "#e2dfe7",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"line": {
|
|
||||||
"active": {
|
|
||||||
"value": "#19171c12",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"highlighted": {
|
|
||||||
"value": "#19171c1f",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"inserted": {
|
|
||||||
"value": "#2a929240",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"deleted": {
|
|
||||||
"value": "#be467840",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"modified": {
|
|
||||||
"value": "#576ddb40",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"highlight": {
|
|
||||||
"selection": {
|
|
||||||
"value": "#576ddb3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"occurrence": {
|
|
||||||
"value": "#19171c0f",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"activeOccurrence": {
|
|
||||||
"value": "#19171c1f",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"matchingBracket": {
|
|
||||||
"value": "#e2dfe72e",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"match": {
|
|
||||||
"value": "#955ae73d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"activeMatch": {
|
|
||||||
"value": "#955ae75c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"related": {
|
|
||||||
"value": "#e2dfe71f",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"gutter": {
|
|
||||||
"primary": {
|
|
||||||
"value": "#655f6d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"active": {
|
|
||||||
"value": "#19171c",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"syntax": {
|
|
||||||
"primary": {
|
|
||||||
"value": "#19171c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"comment": {
|
|
||||||
"value": "#585260",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"keyword": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"function": {
|
|
||||||
"value": "#a06e3b",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"type": {
|
|
||||||
"value": "#398bc6",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"variant": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"property": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"enum": {
|
|
||||||
"value": "#aa573c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"operator": {
|
|
||||||
"value": "#aa573c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"string": {
|
|
||||||
"value": "#aa573c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"number": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"boolean": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"player": {
|
|
||||||
"1": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#576ddb",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#576ddb3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#576ddbcc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"2": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#2a9292",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#2a92923d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#2a9292cc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"3": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#bf40bf",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#bf40bf",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#bf40bf3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#bf40bfcc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"4": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#aa573c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#aa573c",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#aa573c3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#aa573ccc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"5": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#955ae7",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#955ae7",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#955ae73d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#955ae7cc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"6": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#398bc6",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#398bc6",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#398bc63d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#398bc6cc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"7": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#be4678",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#be4678",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#be46783d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#be4678cc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"8": {
|
|
||||||
"baseColor": {
|
|
||||||
"value": "#a06e3b",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"cursorColor": {
|
|
||||||
"value": "#a06e3b",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"selectionColor": {
|
|
||||||
"value": "#a06e3b3d",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"borderColor": {
|
|
||||||
"value": "#a06e3bcc",
|
|
||||||
"type": "color"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"shadowAlpha": {
|
|
||||||
"value": 0.12,
|
|
||||||
"type": "number"
|
|
||||||
}
|
|
||||||
}
|
|
52
styles/dist/solarized-dark.json
vendored
52
styles/dist/solarized-dark.json
vendored
@ -89,15 +89,15 @@
|
|||||||
"background": {
|
"background": {
|
||||||
"100": {
|
"100": {
|
||||||
"base": {
|
"base": {
|
||||||
"value": "#073642",
|
"value": "#1b444f",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"hovered": {
|
"hovered": {
|
||||||
"value": "#586e753d",
|
"value": "#30525c",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#586e755c",
|
"value": "#446068",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -107,11 +107,11 @@
|
|||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"hovered": {
|
"hovered": {
|
||||||
"value": "#586e753d",
|
"value": "#1b444f",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#586e755c",
|
"value": "#30525c",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -121,11 +121,11 @@
|
|||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"hovered": {
|
"hovered": {
|
||||||
"value": "#0736423d",
|
"value": "#022e39",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#0736425c",
|
"value": "#04313c",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -135,25 +135,25 @@
|
|||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"hovered": {
|
"hovered": {
|
||||||
"value": "#0736423d",
|
"value": "#022e39",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#0736427a",
|
"value": "#04313c",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"on500": {
|
"on500": {
|
||||||
"base": {
|
"base": {
|
||||||
"value": "#073642",
|
"value": "#1b444f",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"hovered": {
|
"hovered": {
|
||||||
"value": "#586e753d",
|
"value": "#30525c",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#586e757a",
|
"value": "#446068",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -267,23 +267,11 @@
|
|||||||
},
|
},
|
||||||
"line": {
|
"line": {
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#fdf6e312",
|
"value": "#073642",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"highlighted": {
|
"highlighted": {
|
||||||
"value": "#fdf6e31f",
|
"value": "#1b444f",
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"inserted": {
|
|
||||||
"value": "#85990040",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"deleted": {
|
|
||||||
"value": "#dc322f40",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"modified": {
|
|
||||||
"value": "#268bd240",
|
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -293,27 +281,27 @@
|
|||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"occurrence": {
|
"occurrence": {
|
||||||
"value": "#fdf6e31f",
|
"value": "#586e753d",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"activeOccurrence": {
|
"activeOccurrence": {
|
||||||
"value": "#fdf6e33d",
|
"value": "#586e757a",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"matchingBracket": {
|
"matchingBracket": {
|
||||||
"value": "#0736425c",
|
"value": "#04313c",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"match": {
|
"match": {
|
||||||
"value": "#6c71c47a",
|
"value": "#1b1f6b",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"activeMatch": {
|
"activeMatch": {
|
||||||
"value": "#6c71c4b8",
|
"value": "#434abc7a",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"related": {
|
"related": {
|
||||||
"value": "#0736423d",
|
"value": "#022e39",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
64
styles/dist/solarized-light.json
vendored
64
styles/dist/solarized-light.json
vendored
@ -89,15 +89,15 @@
|
|||||||
"background": {
|
"background": {
|
||||||
"100": {
|
"100": {
|
||||||
"base": {
|
"base": {
|
||||||
"value": "#eee8d5",
|
"value": "#d7d6c8",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"hovered": {
|
"hovered": {
|
||||||
"value": "#93a1a11f",
|
"value": "#c1c5bb",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#93a1a12e",
|
"value": "#aab3ae",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -107,11 +107,11 @@
|
|||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"hovered": {
|
"hovered": {
|
||||||
"value": "#93a1a11f",
|
"value": "#d7d6c8",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#93a1a12e",
|
"value": "#c1c5bb",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -121,11 +121,11 @@
|
|||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"hovered": {
|
"hovered": {
|
||||||
"value": "#eee8d51f",
|
"value": "#f9f3e0",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#eee8d52e",
|
"value": "#f6efdc",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -135,25 +135,25 @@
|
|||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"hovered": {
|
"hovered": {
|
||||||
"value": "#eee8d51f",
|
"value": "#f9f3e0",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#eee8d53d",
|
"value": "#f6efdc",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"on500": {
|
"on500": {
|
||||||
"base": {
|
"base": {
|
||||||
"value": "#eee8d5",
|
"value": "#d7d6c8",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"hovered": {
|
"hovered": {
|
||||||
"value": "#93a1a11f",
|
"value": "#c1c5bb",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#93a1a13d",
|
"value": "#aab3ae",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -216,19 +216,19 @@
|
|||||||
},
|
},
|
||||||
"border": {
|
"border": {
|
||||||
"primary": {
|
"primary": {
|
||||||
"value": "#fdf6e3",
|
"value": "#93a1a1",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"secondary": {
|
"secondary": {
|
||||||
"value": "#eee8d5",
|
"value": "#93a1a1",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"muted": {
|
"muted": {
|
||||||
"value": "#839496",
|
"value": "#657b83",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#839496",
|
"value": "#657b83",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"onMedia": {
|
"onMedia": {
|
||||||
@ -258,32 +258,20 @@
|
|||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"indent_guide": {
|
"indent_guide": {
|
||||||
"value": "#839496",
|
"value": "#657b83",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"indent_guide_active": {
|
"indent_guide_active": {
|
||||||
"value": "#eee8d5",
|
"value": "#93a1a1",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"line": {
|
"line": {
|
||||||
"active": {
|
"active": {
|
||||||
"value": "#002b3612",
|
"value": "#eee8d5",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"highlighted": {
|
"highlighted": {
|
||||||
"value": "#002b361f",
|
"value": "#d7d6c8",
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"inserted": {
|
|
||||||
"value": "#85990040",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"deleted": {
|
|
||||||
"value": "#dc322f40",
|
|
||||||
"type": "color"
|
|
||||||
},
|
|
||||||
"modified": {
|
|
||||||
"value": "#268bd240",
|
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -293,27 +281,27 @@
|
|||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"occurrence": {
|
"occurrence": {
|
||||||
"value": "#002b360f",
|
"value": "#93a1a11f",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"activeOccurrence": {
|
"activeOccurrence": {
|
||||||
"value": "#002b361f",
|
"value": "#93a1a13d",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"matchingBracket": {
|
"matchingBracket": {
|
||||||
"value": "#eee8d52e",
|
"value": "#f6efdc",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"match": {
|
"match": {
|
||||||
"value": "#6c71c43d",
|
"value": "#bcc0f6",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"activeMatch": {
|
"activeMatch": {
|
||||||
"value": "#6c71c45c",
|
"value": "#7f84d73d",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
},
|
},
|
||||||
"related": {
|
"related": {
|
||||||
"value": "#eee8d51f",
|
"value": "#f9f3e0",
|
||||||
"type": "color"
|
"type": "color"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
1270
styles/dist/tokens.json
vendored
1270
styles/dist/tokens.json
vendored
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,9 @@
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import app from "./styleTree/app";
|
import app from "./styleTree/app";
|
||||||
import { dark as caveDark, light as caveLight } from "./themes/cave";
|
import themes from "./themes";
|
||||||
import { dark as solarizedDark, light as solarizedLight } from "./themes/solarized";
|
|
||||||
import { dark as sulphurpoolDark, light as sulphurpoolLight } from "./themes/sulphurpool";
|
|
||||||
import snakeCase from "./utils/snakeCase";
|
import snakeCase from "./utils/snakeCase";
|
||||||
|
|
||||||
const themes = [
|
|
||||||
caveDark, caveLight,
|
|
||||||
solarizedDark, solarizedLight,
|
|
||||||
sulphurpoolDark, sulphurpoolLight
|
|
||||||
];
|
|
||||||
|
|
||||||
const themeDirectory = `${__dirname}/../../assets/themes/`;
|
const themeDirectory = `${__dirname}/../../assets/themes/`;
|
||||||
|
|
||||||
// Clear existing themes
|
// Clear existing themes
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import { light as solarizedLight, dark as solarizedDark } from "./themes/solarized";
|
import themes from "./themes";
|
||||||
// Use cave as "light" and "dark" themes
|
import Theme from "./themes/common/theme";
|
||||||
import { light, dark } from "./themes/cave";
|
|
||||||
import Theme from "./themes/theme";
|
|
||||||
import { colors, fontFamilies, fontSizes, fontWeights, sizes } from "./tokens";
|
import { colors, fontFamilies, fontSizes, fontWeights, sizes } from "./tokens";
|
||||||
|
|
||||||
// Organize theme tokens
|
// Organize theme tokens
|
||||||
@ -50,6 +48,9 @@ const coreTokens = {
|
|||||||
const combinedTokens: any = {};
|
const combinedTokens: any = {};
|
||||||
|
|
||||||
const distPath = path.resolve(`${__dirname}/../dist`);
|
const distPath = path.resolve(`${__dirname}/../dist`);
|
||||||
|
for (const file of fs.readdirSync(distPath)) {
|
||||||
|
fs.unlinkSync(path.join(distPath, file));
|
||||||
|
}
|
||||||
|
|
||||||
// Add core tokens to the combined tokens and write `core.json`.
|
// Add core tokens to the combined tokens and write `core.json`.
|
||||||
// We write `core.json` as a separate file for the design team's convenience, but it isn't consumed by Figma Tokens directly.
|
// We write `core.json` as a separate file for the design team's convenience, but it isn't consumed by Figma Tokens directly.
|
||||||
@ -60,7 +61,6 @@ combinedTokens.core = coreTokens;
|
|||||||
|
|
||||||
// Add each theme to the combined tokens and write ${theme}.json.
|
// Add each theme to the combined tokens and write ${theme}.json.
|
||||||
// We write `${theme}.json` as a separate file for the design team's convenience, but it isn't consumed by Figma Tokens directly.
|
// We write `${theme}.json` as a separate file for the design team's convenience, but it isn't consumed by Figma Tokens directly.
|
||||||
let themes = [dark, light, solarizedDark, solarizedLight];
|
|
||||||
themes.forEach((theme) => {
|
themes.forEach((theme) => {
|
||||||
const themePath = `${distPath}/${theme.name}.json`
|
const themePath = `${distPath}/${theme.name}.json`
|
||||||
fs.writeFileSync(themePath, JSON.stringify(themeTokens(theme), null, 2));
|
fs.writeFileSync(themePath, JSON.stringify(themeTokens(theme), null, 2));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import chatPanel from "./chatPanel";
|
import chatPanel from "./chatPanel";
|
||||||
import { text } from "./components";
|
import { text } from "./components";
|
||||||
import contactFinder from "./contactFinder";
|
import contactFinder from "./contactFinder";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import { panel } from "./app";
|
import { panel } from "./app";
|
||||||
import {
|
import {
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import { text, backgroundColor, border } from "./components";
|
import { text, backgroundColor, border } from "./components";
|
||||||
|
|
||||||
export default function commandPalette(theme: Theme) {
|
export default function commandPalette(theme: Theme) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import chroma from "chroma-js";
|
import chroma from "chroma-js";
|
||||||
import Theme, { BackgroundColorSet } from "../themes/theme";
|
import Theme, { BackgroundColorSet } from "../themes/common/theme";
|
||||||
import { fontFamilies, fontSizes, FontWeight } from "../tokens";
|
import { fontFamilies, fontSizes, FontWeight } from "../tokens";
|
||||||
import { Color } from "../utils/color";
|
import { Color } from "../utils/color";
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import picker from "./picker";
|
import picker from "./picker";
|
||||||
import { backgroundColor, iconColor } from "./components";
|
import { backgroundColor, iconColor } from "./components";
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import { backgroundColor, iconColor, text } from "./components";
|
import { backgroundColor, iconColor, text } from "./components";
|
||||||
|
|
||||||
const avatarSize = 12;
|
const avatarSize = 12;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import { panel } from "./app";
|
import { panel } from "./app";
|
||||||
import { backgroundColor, border, borderColor, iconColor, player, text } from "./components";
|
import { backgroundColor, border, borderColor, iconColor, player, text } from "./components";
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ export default function contactsPanel(theme: Theme) {
|
|||||||
background: backgroundColor(theme, 100),
|
background: backgroundColor(theme, 100),
|
||||||
color: iconColor(theme, "muted"),
|
color: iconColor(theme, "muted"),
|
||||||
},
|
},
|
||||||
sharedProjectRow: {
|
projectRow: {
|
||||||
...projectRow,
|
...projectRow,
|
||||||
background: backgroundColor(theme, 300),
|
background: backgroundColor(theme, 300),
|
||||||
name: {
|
name: {
|
||||||
@ -136,19 +136,5 @@ export default function contactsPanel(theme: Theme) {
|
|||||||
background: backgroundColor(theme, 300, "active"),
|
background: backgroundColor(theme, 300, "active"),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
unsharedProjectRow: {
|
|
||||||
...projectRow,
|
|
||||||
background: backgroundColor(theme, 300),
|
|
||||||
name: {
|
|
||||||
...projectRow.name,
|
|
||||||
...text(theme, "mono", "secondary", { size: "sm" }),
|
|
||||||
},
|
|
||||||
hover: {
|
|
||||||
background: backgroundColor(theme, 300, "hovered"),
|
|
||||||
},
|
|
||||||
active: {
|
|
||||||
background: backgroundColor(theme, 300, "active"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import {
|
import {
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
border,
|
border,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import { backgroundColor, border, player, shadow, text } from "./components";
|
import { backgroundColor, border, player, shadow, text } from "./components";
|
||||||
|
|
||||||
export default function picker(theme: Theme) {
|
export default function picker(theme: Theme) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import {
|
import {
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
text,
|
text,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import { panel } from "./app";
|
import { panel } from "./app";
|
||||||
import { backgroundColor, iconColor, player, text } from "./components";
|
import { backgroundColor, iconColor, player, text } from "./components";
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import { backgroundColor, border, player, text } from "./components";
|
import { backgroundColor, border, player, text } from "./components";
|
||||||
|
|
||||||
export default function search(theme: Theme) {
|
export default function search(theme: Theme) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import { backgroundColor, border, iconColor, text } from "./components";
|
import { backgroundColor, border, iconColor, text } from "./components";
|
||||||
import { workspaceBackground } from "./workspace";
|
import { workspaceBackground } from "./workspace";
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Theme from "../themes/theme";
|
import Theme from "../themes/common/theme";
|
||||||
import { backgroundColor, border, iconColor, shadow, text } from "./components";
|
import { backgroundColor, border, iconColor, shadow, text } from "./components";
|
||||||
import statusBar from "./statusBar";
|
import statusBar from "./statusBar";
|
||||||
|
|
||||||
@ -41,6 +41,14 @@ export default function workspace(theme: Theme) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
background: backgroundColor(theme, 300),
|
background: backgroundColor(theme, 300),
|
||||||
|
joiningProjectAvatar: {
|
||||||
|
cornerRadius: 40,
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
joiningProjectMessage: {
|
||||||
|
padding: 12,
|
||||||
|
...text(theme, "sans", "primary", { size: "lg" })
|
||||||
|
},
|
||||||
leaderBorderOpacity: 0.7,
|
leaderBorderOpacity: 0.7,
|
||||||
leaderBorderWidth: 2.0,
|
leaderBorderWidth: 2.0,
|
||||||
tab,
|
tab,
|
||||||
|
16
styles/src/themes.ts
Normal file
16
styles/src/themes.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import Theme from "./themes/common/theme";
|
||||||
|
|
||||||
|
const themes: Theme[] = [];
|
||||||
|
export default themes;
|
||||||
|
|
||||||
|
const themesPath = path.resolve(`${__dirname}/themes`);
|
||||||
|
for (const fileName of fs.readdirSync(themesPath)) {
|
||||||
|
const filePath = path.join(themesPath, fileName);
|
||||||
|
if (fs.statSync(filePath).isFile()) {
|
||||||
|
const theme = require(filePath);
|
||||||
|
themes.push(theme.dark);
|
||||||
|
themes.push(theme.light);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import chroma from "chroma-js";
|
import chroma from "chroma-js";
|
||||||
import { colorRamp, createTheme } from "./base16";
|
import { colorRamp, createTheme } from "./common/base16";
|
||||||
|
|
||||||
const name = "cave";
|
const name = "cave";
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import chroma from "chroma-js";
|
import chroma from "chroma-js";
|
||||||
import { Scale, Color } from "chroma-js";
|
import { Scale, Color } from "chroma-js";
|
||||||
import { color, ColorToken, fontWeights, NumberToken } from "../tokens";
|
import { color, ColorToken, fontWeights, NumberToken } from "../../tokens";
|
||||||
import { withOpacity } from "../utils/color";
|
import { withOpacity } from "../../utils/color";
|
||||||
import Theme, { buildPlayer, Syntax } from "./theme";
|
import Theme, { buildPlayer, Syntax } from "./theme";
|
||||||
|
|
||||||
export function colorRamp(color: Color): Scale {
|
export function colorRamp(color: Color): Scale {
|
@ -1,5 +1,5 @@
|
|||||||
import { ColorToken, FontWeightToken, NumberToken } from "../tokens";
|
import { ColorToken, FontWeightToken, NumberToken } from "../../tokens";
|
||||||
import { withOpacity } from "../utils/color";
|
import { withOpacity } from "../../utils/color";
|
||||||
|
|
||||||
export interface SyntaxHighlightStyle {
|
export interface SyntaxHighlightStyle {
|
||||||
color: ColorToken;
|
color: ColorToken;
|
@ -1,30 +0,0 @@
|
|||||||
import chroma from "chroma-js";
|
|
||||||
import { createTheme } from "./base16";
|
|
||||||
|
|
||||||
const name = "cave";
|
|
||||||
|
|
||||||
const colors = {
|
|
||||||
"red": chroma("#be4678"),
|
|
||||||
"orange": chroma("#aa573c"),
|
|
||||||
"yellow": chroma("#a06e3b"),
|
|
||||||
"green": chroma("#2a9292"),
|
|
||||||
"cyan": chroma("#398bc6"),
|
|
||||||
"blue": chroma("#576ddb"),
|
|
||||||
"violet": chroma("#955ae7"),
|
|
||||||
"magenta": chroma("#bf40bf"),
|
|
||||||
};
|
|
||||||
|
|
||||||
const ramps = {
|
|
||||||
neutral: chroma.scale(["#19171c", "#26232a", "#585260", "#655f6d", "#7e7887", "#8b8792", "#e2dfe7", "#efecf4"]),
|
|
||||||
red: chroma.scale([colors.red.darken(3), colors.red, colors.red.brighten(3)]),
|
|
||||||
orange: chroma.scale([colors.orange.darken(3), colors.orange, colors.orange.brighten(3)]),
|
|
||||||
yellow: chroma.scale([colors.yellow.darken(3), colors.yellow, colors.yellow.brighten(3)]),
|
|
||||||
green: chroma.scale([colors.green.darken(3), colors.green, colors.green.brighten(3)]),
|
|
||||||
cyan: chroma.scale([colors.cyan.darken(3), colors.cyan, colors.cyan.brighten(3)]),
|
|
||||||
blue: chroma.scale([colors.blue.darken(3), colors.blue, colors.blue.brighten(3)]),
|
|
||||||
violet: chroma.scale([colors.violet.darken(3), colors.violet, colors.violet.brighten(3)]),
|
|
||||||
magenta: chroma.scale([colors.magenta.darken(3), colors.magenta, colors.magenta.brighten(3)]),
|
|
||||||
}
|
|
||||||
|
|
||||||
export const dark = createTheme(`${name}-dark`, false, ramps);
|
|
||||||
export const light = createTheme(`${name}-light`, true, ramps);
|
|
@ -1,5 +1,5 @@
|
|||||||
import chroma from "chroma-js";
|
import chroma from "chroma-js";
|
||||||
import { colorRamp, createTheme } from "./base16";
|
import { colorRamp, createTheme } from "./common/base16";
|
||||||
|
|
||||||
const name = "solarized";
|
const name = "solarized";
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import chroma from "chroma-js";
|
import chroma from "chroma-js";
|
||||||
import { colorRamp, createTheme } from "./base16";
|
import { colorRamp, createTheme } from "./common/base16";
|
||||||
|
|
||||||
const name = "sulphurpool";
|
const name = "sulphurpool";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user