mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
Improve local collaboration script to accept a zed impersonate
Gate channels UI behind a flag co-authored-by: max <max@zed.dev>
This commit is contained in:
parent
8980a9f1c1
commit
bedf60b6b2
4 changed files with 80 additions and 74 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1568,6 +1568,7 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"settings",
|
"settings",
|
||||||
|
"staff_mode",
|
||||||
"theme",
|
"theme",
|
||||||
"theme_selector",
|
"theme_selector",
|
||||||
"util",
|
"util",
|
||||||
|
|
|
@ -38,6 +38,7 @@ picker = { path = "../picker" }
|
||||||
project = { path = "../project" }
|
project = { path = "../project" }
|
||||||
recent_projects = {path = "../recent_projects"}
|
recent_projects = {path = "../recent_projects"}
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
|
staff_mode = {path = "../staff_mode"}
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
theme_selector = { path = "../theme_selector" }
|
theme_selector = { path = "../theme_selector" }
|
||||||
vcs_menu = { path = "../vcs_menu" }
|
vcs_menu = { path = "../vcs_menu" }
|
||||||
|
@ -45,7 +46,6 @@ util = { path = "../util" }
|
||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
zed-actions = {path = "../zed-actions"}
|
zed-actions = {path = "../zed-actions"}
|
||||||
|
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
|
|
|
@ -31,6 +31,7 @@ use panel_settings::{CollaborationPanelDockPosition, CollaborationPanelSettings}
|
||||||
use project::{Fs, Project};
|
use project::{Fs, Project};
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use settings::SettingsStore;
|
use settings::SettingsStore;
|
||||||
|
use staff_mode::StaffMode;
|
||||||
use std::{mem, sync::Arc};
|
use std::{mem, sync::Arc};
|
||||||
use theme::IconButton;
|
use theme::IconButton;
|
||||||
use util::{ResultExt, TryFutureExt};
|
use util::{ResultExt, TryFutureExt};
|
||||||
|
@ -347,6 +348,8 @@ impl CollabPanel {
|
||||||
.push(cx.observe(&this.channel_store, |this, _, cx| this.update_entries(cx)));
|
.push(cx.observe(&this.channel_store, |this, _, cx| this.update_entries(cx)));
|
||||||
this.subscriptions
|
this.subscriptions
|
||||||
.push(cx.observe(&active_call, |this, _, cx| this.update_entries(cx)));
|
.push(cx.observe(&active_call, |this, _, cx| this.update_entries(cx)));
|
||||||
|
this.subscriptions
|
||||||
|
.push(cx.observe_global::<StaffMode, _>(move |this, cx| this.update_entries(cx)));
|
||||||
|
|
||||||
this
|
this
|
||||||
})
|
})
|
||||||
|
@ -516,79 +519,76 @@ impl CollabPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.entries.push(ListEntry::Header(Section::Channels, 0));
|
let mut request_entries = Vec::new();
|
||||||
|
if self.include_channels_section(cx) {
|
||||||
|
self.entries.push(ListEntry::Header(Section::Channels, 0));
|
||||||
|
|
||||||
let channels = channel_store.channels();
|
let channels = channel_store.channels();
|
||||||
if !(channels.is_empty() && self.channel_editing_state.is_none()) {
|
if !(channels.is_empty() && self.channel_editing_state.is_none()) {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates
|
||||||
.extend(
|
.extend(channels.iter().enumerate().map(|(ix, channel)| {
|
||||||
channels
|
StringMatchCandidate {
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(ix, channel)| StringMatchCandidate {
|
|
||||||
id: ix,
|
id: ix,
|
||||||
string: channel.name.clone(),
|
string: channel.name.clone(),
|
||||||
char_bag: channel.name.chars().collect(),
|
char_bag: channel.name.chars().collect(),
|
||||||
}),
|
}
|
||||||
);
|
}));
|
||||||
let matches = executor.block(match_strings(
|
let matches = executor.block(match_strings(
|
||||||
&self.match_candidates,
|
&self.match_candidates,
|
||||||
&query,
|
&query,
|
||||||
true,
|
true,
|
||||||
usize::MAX,
|
usize::MAX,
|
||||||
&Default::default(),
|
&Default::default(),
|
||||||
executor.clone(),
|
executor.clone(),
|
||||||
));
|
));
|
||||||
if let Some(state) = &self.channel_editing_state {
|
|
||||||
if state.parent_id.is_none() {
|
|
||||||
self.entries.push(ListEntry::ChannelEditor { depth: 0 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for mat in matches {
|
|
||||||
let channel = &channels[mat.candidate_id];
|
|
||||||
self.entries.push(ListEntry::Channel(channel.clone()));
|
|
||||||
if let Some(state) = &self.channel_editing_state {
|
if let Some(state) = &self.channel_editing_state {
|
||||||
if state.parent_id == Some(channel.id) {
|
if state.parent_id.is_none() {
|
||||||
self.entries.push(ListEntry::ChannelEditor {
|
self.entries.push(ListEntry::ChannelEditor { depth: 0 });
|
||||||
depth: channel.depth + 1,
|
}
|
||||||
});
|
}
|
||||||
|
for mat in matches {
|
||||||
|
let channel = &channels[mat.candidate_id];
|
||||||
|
self.entries.push(ListEntry::Channel(channel.clone()));
|
||||||
|
if let Some(state) = &self.channel_editing_state {
|
||||||
|
if state.parent_id == Some(channel.id) {
|
||||||
|
self.entries.push(ListEntry::ChannelEditor {
|
||||||
|
depth: channel.depth + 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let mut request_entries = Vec::new();
|
let channel_invites = channel_store.channel_invitations();
|
||||||
let channel_invites = channel_store.channel_invitations();
|
if !channel_invites.is_empty() {
|
||||||
if !channel_invites.is_empty() {
|
self.match_candidates.clear();
|
||||||
self.match_candidates.clear();
|
self.match_candidates
|
||||||
self.match_candidates
|
.extend(channel_invites.iter().enumerate().map(|(ix, channel)| {
|
||||||
.extend(channel_invites.iter().enumerate().map(|(ix, channel)| {
|
StringMatchCandidate {
|
||||||
StringMatchCandidate {
|
id: ix,
|
||||||
id: ix,
|
string: channel.name.clone(),
|
||||||
string: channel.name.clone(),
|
char_bag: channel.name.chars().collect(),
|
||||||
char_bag: channel.name.chars().collect(),
|
}
|
||||||
}
|
}));
|
||||||
|
let matches = executor.block(match_strings(
|
||||||
|
&self.match_candidates,
|
||||||
|
&query,
|
||||||
|
true,
|
||||||
|
usize::MAX,
|
||||||
|
&Default::default(),
|
||||||
|
executor.clone(),
|
||||||
|
));
|
||||||
|
request_entries.extend(matches.iter().map(|mat| {
|
||||||
|
ListEntry::ChannelInvite(channel_invites[mat.candidate_id].clone())
|
||||||
}));
|
}));
|
||||||
let matches = executor.block(match_strings(
|
|
||||||
&self.match_candidates,
|
|
||||||
&query,
|
|
||||||
true,
|
|
||||||
usize::MAX,
|
|
||||||
&Default::default(),
|
|
||||||
executor.clone(),
|
|
||||||
));
|
|
||||||
request_entries.extend(
|
|
||||||
matches
|
|
||||||
.iter()
|
|
||||||
.map(|mat| ListEntry::ChannelInvite(channel_invites[mat.candidate_id].clone())),
|
|
||||||
);
|
|
||||||
|
|
||||||
if !request_entries.is_empty() {
|
if !request_entries.is_empty() {
|
||||||
self.entries
|
self.entries
|
||||||
.push(ListEntry::Header(Section::ChannelInvites, 1));
|
.push(ListEntry::Header(Section::ChannelInvites, 1));
|
||||||
if !self.collapsed_sections.contains(&Section::ChannelInvites) {
|
if !self.collapsed_sections.contains(&Section::ChannelInvites) {
|
||||||
self.entries.append(&mut request_entries);
|
self.entries.append(&mut request_entries);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -686,16 +686,9 @@ impl CollabPanel {
|
||||||
executor.clone(),
|
executor.clone(),
|
||||||
));
|
));
|
||||||
|
|
||||||
let (mut online_contacts, offline_contacts) = matches
|
let (online_contacts, offline_contacts) = matches
|
||||||
.iter()
|
.iter()
|
||||||
.partition::<Vec<_>, _>(|mat| contacts[mat.candidate_id].online);
|
.partition::<Vec<_>, _>(|mat| contacts[mat.candidate_id].online);
|
||||||
if let Some(room) = ActiveCall::global(cx).read(cx).room() {
|
|
||||||
let room = room.read(cx);
|
|
||||||
online_contacts.retain(|contact| {
|
|
||||||
let contact = &contacts[contact.candidate_id];
|
|
||||||
!room.contains_participant(contact.user.id)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (matches, section) in [
|
for (matches, section) in [
|
||||||
(online_contacts, Section::Online),
|
(online_contacts, Section::Online),
|
||||||
|
@ -1534,6 +1527,14 @@ impl CollabPanel {
|
||||||
.into_any()
|
.into_any()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn include_channels_section(&self, cx: &AppContext) -> bool {
|
||||||
|
if cx.has_global::<StaffMode>() {
|
||||||
|
cx.global::<StaffMode>().0
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn deploy_channel_context_menu(
|
fn deploy_channel_context_menu(
|
||||||
&mut self,
|
&mut self,
|
||||||
position: Vector2F,
|
position: Vector2F,
|
||||||
|
@ -1878,8 +1879,12 @@ impl View for CollabPanel {
|
||||||
})
|
})
|
||||||
.on_click(MouseButton::Left, |_, this, cx| {
|
.on_click(MouseButton::Left, |_, this, cx| {
|
||||||
let client = this.client.clone();
|
let client = this.client.clone();
|
||||||
cx.spawn(|_, cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
client.authenticate_and_connect(true, &cx).await.log_err()
|
client.authenticate_and_connect(true, &cx).await.log_err();
|
||||||
|
|
||||||
|
this.update(&mut cx, |_, cx| {
|
||||||
|
cx.notify();
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
})
|
})
|
||||||
|
|
|
@ -53,6 +53,6 @@ sleep 0.5
|
||||||
|
|
||||||
# Start the two Zed child processes. Open the given paths with the first instance.
|
# Start the two Zed child processes. Open the given paths with the first instance.
|
||||||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
||||||
ZED_IMPERSONATE=${username_1} ZED_WINDOW_POSITION=${position_1} target/debug/Zed $@ &
|
ZED_IMPERSONATE=${ZED_IMPERSONATE:=${username_1}} ZED_WINDOW_POSITION=${position_1} target/debug/Zed $@ &
|
||||||
SECOND=true ZED_IMPERSONATE=${username_2} ZED_WINDOW_POSITION=${position_2} target/debug/Zed &
|
SECOND=true ZED_IMPERSONATE=${username_2} ZED_WINDOW_POSITION=${position_2} target/debug/Zed &
|
||||||
wait
|
wait
|
||||||
|
|
Loading…
Reference in a new issue