mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
Add feature flags handling to the client, rewrite staff mode to a trait extension style
This commit is contained in:
parent
6fdf101745
commit
74565ed0b8
28
Cargo.lock
generated
28
Cargo.lock
generated
@ -1200,6 +1200,7 @@ dependencies = [
|
|||||||
"client",
|
"client",
|
||||||
"collections",
|
"collections",
|
||||||
"db",
|
"db",
|
||||||
|
"feature_flags",
|
||||||
"futures 0.3.28",
|
"futures 0.3.28",
|
||||||
"gpui",
|
"gpui",
|
||||||
"image",
|
"image",
|
||||||
@ -1215,7 +1216,6 @@ dependencies = [
|
|||||||
"serde_derive",
|
"serde_derive",
|
||||||
"settings",
|
"settings",
|
||||||
"smol",
|
"smol",
|
||||||
"staff_mode",
|
|
||||||
"sum_tree",
|
"sum_tree",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"text",
|
"text",
|
||||||
@ -1374,6 +1374,7 @@ dependencies = [
|
|||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
"collections",
|
"collections",
|
||||||
"db",
|
"db",
|
||||||
|
"feature_flags",
|
||||||
"futures 0.3.28",
|
"futures 0.3.28",
|
||||||
"gpui",
|
"gpui",
|
||||||
"image",
|
"image",
|
||||||
@ -1388,7 +1389,6 @@ dependencies = [
|
|||||||
"serde_derive",
|
"serde_derive",
|
||||||
"settings",
|
"settings",
|
||||||
"smol",
|
"smol",
|
||||||
"staff_mode",
|
|
||||||
"sum_tree",
|
"sum_tree",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"text",
|
"text",
|
||||||
@ -1528,6 +1528,7 @@ dependencies = [
|
|||||||
"context_menu",
|
"context_menu",
|
||||||
"db",
|
"db",
|
||||||
"editor",
|
"editor",
|
||||||
|
"feature_flags",
|
||||||
"feedback",
|
"feedback",
|
||||||
"futures 0.3.28",
|
"futures 0.3.28",
|
||||||
"fuzzy",
|
"fuzzy",
|
||||||
@ -1543,7 +1544,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"settings",
|
"settings",
|
||||||
"staff_mode",
|
|
||||||
"theme",
|
"theme",
|
||||||
"theme_selector",
|
"theme_selector",
|
||||||
"util",
|
"util",
|
||||||
@ -2529,6 +2529,14 @@ version = "2.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764"
|
checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "feature_flags"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"gpui",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "feedback"
|
name = "feedback"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -6834,6 +6842,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"collections",
|
"collections",
|
||||||
|
"feature_flags",
|
||||||
"fs",
|
"fs",
|
||||||
"futures 0.3.28",
|
"futures 0.3.28",
|
||||||
"gpui",
|
"gpui",
|
||||||
@ -6849,7 +6858,6 @@ dependencies = [
|
|||||||
"serde_json_lenient",
|
"serde_json_lenient",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"sqlez",
|
"sqlez",
|
||||||
"staff_mode",
|
|
||||||
"toml 0.5.11",
|
"toml 0.5.11",
|
||||||
"tree-sitter",
|
"tree-sitter",
|
||||||
"tree-sitter-json 0.19.0",
|
"tree-sitter-json 0.19.0",
|
||||||
@ -7284,14 +7292,6 @@ version = "1.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "staff_mode"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"gpui",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "static_assertions"
|
name = "static_assertions"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
@ -7672,6 +7672,7 @@ name = "theme_selector"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"editor",
|
"editor",
|
||||||
|
"feature_flags",
|
||||||
"fs",
|
"fs",
|
||||||
"fuzzy",
|
"fuzzy",
|
||||||
"gpui",
|
"gpui",
|
||||||
@ -7681,7 +7682,6 @@ dependencies = [
|
|||||||
"postage",
|
"postage",
|
||||||
"settings",
|
"settings",
|
||||||
"smol",
|
"smol",
|
||||||
"staff_mode",
|
|
||||||
"theme",
|
"theme",
|
||||||
"util",
|
"util",
|
||||||
"workspace",
|
"workspace",
|
||||||
@ -9726,6 +9726,7 @@ dependencies = [
|
|||||||
"diagnostics",
|
"diagnostics",
|
||||||
"editor",
|
"editor",
|
||||||
"env_logger 0.9.3",
|
"env_logger 0.9.3",
|
||||||
|
"feature_flags",
|
||||||
"feedback",
|
"feedback",
|
||||||
"file_finder",
|
"file_finder",
|
||||||
"fs",
|
"fs",
|
||||||
@ -9772,7 +9773,6 @@ dependencies = [
|
|||||||
"simplelog",
|
"simplelog",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"smol",
|
"smol",
|
||||||
"staff_mode",
|
|
||||||
"sum_tree",
|
"sum_tree",
|
||||||
"tempdir",
|
"tempdir",
|
||||||
"terminal_view",
|
"terminal_view",
|
||||||
|
@ -62,7 +62,7 @@ members = [
|
|||||||
"crates/snippet",
|
"crates/snippet",
|
||||||
"crates/sqlez",
|
"crates/sqlez",
|
||||||
"crates/sqlez_macros",
|
"crates/sqlez_macros",
|
||||||
"crates/staff_mode",
|
"crates/feature_flags",
|
||||||
"crates/sum_tree",
|
"crates/sum_tree",
|
||||||
"crates/terminal",
|
"crates/terminal",
|
||||||
"crates/text",
|
"crates/text",
|
||||||
|
@ -21,7 +21,7 @@ rpc = { path = "../rpc" }
|
|||||||
text = { path = "../text" }
|
text = { path = "../text" }
|
||||||
language = { path = "../language" }
|
language = { path = "../language" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
staff_mode = { path = "../staff_mode" }
|
feature_flags = { path = "../feature_flags" }
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
@ -19,7 +19,7 @@ util = { path = "../util" }
|
|||||||
rpc = { path = "../rpc" }
|
rpc = { path = "../rpc" }
|
||||||
text = { path = "../text" }
|
text = { path = "../text" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
staff_mode = { path = "../staff_mode" }
|
feature_flags = { path = "../feature_flags" }
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
@ -135,8 +135,6 @@ impl Telemetry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This method takes the entire TelemetrySettings struct in order to force client code
|
|
||||||
/// to pull the struct out of the settings global. Do not remove!
|
|
||||||
pub fn set_authenticated_user_info(
|
pub fn set_authenticated_user_info(
|
||||||
self: &Arc<Self>,
|
self: &Arc<Self>,
|
||||||
metrics_id: Option<String>,
|
metrics_id: Option<String>,
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use super::{proto, Client, Status, TypedEnvelope};
|
use super::{proto, Client, Status, TypedEnvelope};
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use collections::{hash_map::Entry, HashMap, HashSet};
|
use collections::{hash_map::Entry, HashMap, HashSet};
|
||||||
|
use feature_flags::FeatureFlagAppExt;
|
||||||
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::{sink::Sink, watch};
|
use postage::{sink::Sink, watch};
|
||||||
use rpc::proto::{RequestMessage, UsersResponse};
|
use rpc::proto::{RequestMessage, UsersResponse};
|
||||||
use staff_mode::StaffMode;
|
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
use util::http::HttpClient;
|
use util::http::HttpClient;
|
||||||
use util::TryFutureExt as _;
|
use util::TryFutureExt as _;
|
||||||
@ -145,26 +145,23 @@ impl UserStore {
|
|||||||
let fetch_metrics_id =
|
let fetch_metrics_id =
|
||||||
client.request(proto::GetPrivateUserInfo {}).log_err();
|
client.request(proto::GetPrivateUserInfo {}).log_err();
|
||||||
let (user, info) = futures::join!(fetch_user, fetch_metrics_id);
|
let (user, info) = futures::join!(fetch_user, fetch_metrics_id);
|
||||||
cx.read(|cx| {
|
|
||||||
|
if let Some(info) = info {
|
||||||
|
cx.update(|cx| {
|
||||||
|
cx.update_flags(info.staff, info.flags);
|
||||||
client.telemetry.set_authenticated_user_info(
|
client.telemetry.set_authenticated_user_info(
|
||||||
info.as_ref().map(|info| info.metrics_id.clone()),
|
Some(info.metrics_id.clone()),
|
||||||
info.as_ref().map(|info| info.staff).unwrap_or(false),
|
info.staff,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
cx.update(|cx| {
|
cx.read(|cx| {
|
||||||
cx.update_default_global(|staff_mode: &mut StaffMode, _| {
|
client
|
||||||
if !staff_mode.0 {
|
.telemetry
|
||||||
*staff_mode = StaffMode(
|
.set_authenticated_user_info(None, false, cx)
|
||||||
info.as_ref()
|
});
|
||||||
.map(|info| info.staff)
|
|
||||||
.unwrap_or_default(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
current_user_tx.send(user).await.ok();
|
current_user_tx.send(user).await.ok();
|
||||||
|
|
||||||
|
@ -40,7 +40,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"}
|
feature_flags = {path = "../feature_flags"}
|
||||||
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" }
|
||||||
|
@ -9,6 +9,8 @@ use client::{proto::PeerId, Client, Contact, User, UserStore};
|
|||||||
use context_menu::{ContextMenu, ContextMenuItem};
|
use context_menu::{ContextMenu, ContextMenuItem};
|
||||||
use db::kvp::KEY_VALUE_STORE;
|
use db::kvp::KEY_VALUE_STORE;
|
||||||
use editor::{Cancel, Editor};
|
use editor::{Cancel, Editor};
|
||||||
|
|
||||||
|
use feature_flags::{ChannelsAlpha, FeatureFlagAppExt, FeatureFlagViewExt};
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use fuzzy::{match_strings, StringMatchCandidate};
|
use fuzzy::{match_strings, StringMatchCandidate};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
@ -33,7 +35,6 @@ 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::{borrow::Cow, mem, sync::Arc};
|
use std::{borrow::Cow, mem, sync::Arc};
|
||||||
use theme::{components::ComponentExt, IconButton};
|
use theme::{components::ComponentExt, IconButton};
|
||||||
use util::{iife, ResultExt, TryFutureExt};
|
use util::{iife, ResultExt, TryFutureExt};
|
||||||
@ -182,9 +183,9 @@ pub struct CollabPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct SerializedChannelsPanel {
|
struct SerializedCollabPanel {
|
||||||
width: Option<f32>,
|
width: Option<f32>,
|
||||||
collapsed_channels: Vec<ChannelId>,
|
collapsed_channels: Option<Vec<ChannelId>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -472,9 +473,10 @@ impl CollabPanel {
|
|||||||
}));
|
}));
|
||||||
this.subscriptions
|
this.subscriptions
|
||||||
.push(cx.observe(&active_call, |this, _, cx| this.update_entries(true, cx)));
|
.push(cx.observe(&active_call, |this, _, cx| this.update_entries(true, cx)));
|
||||||
this.subscriptions.push(
|
this.subscriptions
|
||||||
cx.observe_global::<StaffMode, _>(move |this, cx| this.update_entries(true, cx)),
|
.push(cx.observe_flag::<ChannelsAlpha, _>(move |_, this, cx| {
|
||||||
);
|
this.update_entries(true, cx)
|
||||||
|
}));
|
||||||
this.subscriptions.push(cx.subscribe(
|
this.subscriptions.push(cx.subscribe(
|
||||||
&this.channel_store,
|
&this.channel_store,
|
||||||
|this, _channel_store, e, cx| match e {
|
|this, _channel_store, e, cx| match e {
|
||||||
@ -510,7 +512,7 @@ impl CollabPanel {
|
|||||||
.log_err()
|
.log_err()
|
||||||
.flatten()
|
.flatten()
|
||||||
{
|
{
|
||||||
Some(serde_json::from_str::<SerializedChannelsPanel>(&panel)?)
|
Some(serde_json::from_str::<SerializedCollabPanel>(&panel)?)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
@ -520,7 +522,9 @@ impl CollabPanel {
|
|||||||
if let Some(serialized_panel) = serialized_panel {
|
if let Some(serialized_panel) = serialized_panel {
|
||||||
panel.update(cx, |panel, cx| {
|
panel.update(cx, |panel, cx| {
|
||||||
panel.width = serialized_panel.width;
|
panel.width = serialized_panel.width;
|
||||||
panel.collapsed_channels = serialized_panel.collapsed_channels;
|
panel.collapsed_channels = serialized_panel
|
||||||
|
.collapsed_channels
|
||||||
|
.unwrap_or_else(|| Vec::new());
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -537,9 +541,9 @@ impl CollabPanel {
|
|||||||
KEY_VALUE_STORE
|
KEY_VALUE_STORE
|
||||||
.write_kvp(
|
.write_kvp(
|
||||||
COLLABORATION_PANEL_KEY.into(),
|
COLLABORATION_PANEL_KEY.into(),
|
||||||
serde_json::to_string(&SerializedChannelsPanel {
|
serde_json::to_string(&SerializedCollabPanel {
|
||||||
width,
|
width,
|
||||||
collapsed_channels,
|
collapsed_channels: Some(collapsed_channels),
|
||||||
})?,
|
})?,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@ -672,7 +676,8 @@ impl CollabPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut request_entries = Vec::new();
|
let mut request_entries = Vec::new();
|
||||||
if self.include_channels_section(cx) {
|
|
||||||
|
if cx.has_flag::<ChannelsAlpha>() {
|
||||||
self.entries.push(ListEntry::Header(Section::Channels, 0));
|
self.entries.push(ListEntry::Header(Section::Channels, 0));
|
||||||
|
|
||||||
if channel_store.channel_count() > 0 || self.channel_editing_state.is_some() {
|
if channel_store.channel_count() > 0 || self.channel_editing_state.is_some() {
|
||||||
@ -1909,14 +1914,6 @@ 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: Option<Vector2F>,
|
position: Option<Vector2F>,
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "staff_mode"
|
name = "feature_flags"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
path = "src/staff_mode.rs"
|
path = "src/feature_flags.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
79
crates/feature_flags/src/feature_flags.rs
Normal file
79
crates/feature_flags/src/feature_flags.rs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
use gpui::{AppContext, Subscription, ViewContext};
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct FeatureFlags {
|
||||||
|
flags: Vec<String>,
|
||||||
|
staff: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FeatureFlags {
|
||||||
|
fn has_flag(&self, flag: &str) -> bool {
|
||||||
|
self.staff || self.flags.iter().find(|f| f.as_str() == flag).is_some()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait FeatureFlag {
|
||||||
|
const NAME: &'static str;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum ChannelsAlpha {}
|
||||||
|
|
||||||
|
impl FeatureFlag for ChannelsAlpha {
|
||||||
|
const NAME: &'static str = "channels_alpha";
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait FeatureFlagViewExt<V: 'static> {
|
||||||
|
fn observe_flag<T: FeatureFlag, F>(&mut self, callback: F) -> Subscription
|
||||||
|
where
|
||||||
|
F: Fn(bool, &mut V, &mut ViewContext<V>) + 'static;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<V: 'static> FeatureFlagViewExt<V> for ViewContext<'_, '_, V> {
|
||||||
|
fn observe_flag<T: FeatureFlag, F>(&mut self, callback: F) -> Subscription
|
||||||
|
where
|
||||||
|
F: Fn(bool, &mut V, &mut ViewContext<V>) + 'static,
|
||||||
|
{
|
||||||
|
self.observe_global::<FeatureFlags, _>(move |v, cx| {
|
||||||
|
let feature_flags = cx.global::<FeatureFlags>();
|
||||||
|
callback(feature_flags.has_flag(<T as FeatureFlag>::NAME), v, cx);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait FeatureFlagAppExt {
|
||||||
|
fn update_flags(&mut self, staff: bool, flags: Vec<String>);
|
||||||
|
fn set_staff(&mut self, staff: bool);
|
||||||
|
fn has_flag<T: FeatureFlag>(&self) -> bool;
|
||||||
|
fn is_staff(&self) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FeatureFlagAppExt for AppContext {
|
||||||
|
fn update_flags(&mut self, staff: bool, flags: Vec<String>) {
|
||||||
|
self.update_default_global::<FeatureFlags, _, _>(|feature_flags, _| {
|
||||||
|
feature_flags.staff = staff;
|
||||||
|
feature_flags.flags = flags;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_staff(&mut self, staff: bool) {
|
||||||
|
self.update_default_global::<FeatureFlags, _, _>(|feature_flags, _| {
|
||||||
|
feature_flags.staff = staff;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn has_flag<T: FeatureFlag>(&self) -> bool {
|
||||||
|
if self.has_global::<FeatureFlags>() {
|
||||||
|
self.global::<FeatureFlags>().has_flag(T::NAME)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_staff(&self) -> bool {
|
||||||
|
if self.has_global::<FeatureFlags>() {
|
||||||
|
return self.global::<FeatureFlags>().staff;
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,4 +6,4 @@ pub use conn::Connection;
|
|||||||
pub use peer::*;
|
pub use peer::*;
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
||||||
pub const PROTOCOL_VERSION: u32 = 62;
|
pub const PROTOCOL_VERSION: u32 = 61;
|
||||||
|
@ -16,7 +16,7 @@ collections = { path = "../collections" }
|
|||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
sqlez = { path = "../sqlez" }
|
sqlez = { path = "../sqlez" }
|
||||||
fs = { path = "../fs" }
|
fs = { path = "../fs" }
|
||||||
staff_mode = { path = "../staff_mode" }
|
feature_flags = { path = "../feature_flags" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
use gpui::AppContext;
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
pub struct StaffMode(pub bool);
|
|
||||||
|
|
||||||
impl std::ops::Deref for StaffMode {
|
|
||||||
type Target = bool;
|
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
|
||||||
&self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Despite what the type system requires me to tell you, the init function will only be called a once
|
|
||||||
/// as soon as we know that the staff mode is enabled.
|
|
||||||
pub fn staff_mode<F: FnMut(&mut AppContext) + 'static>(cx: &mut AppContext, mut init: F) {
|
|
||||||
if **cx.default_global::<StaffMode>() {
|
|
||||||
init(cx)
|
|
||||||
} else {
|
|
||||||
let mut once = Some(());
|
|
||||||
cx.observe_global::<StaffMode, _>(move |cx| {
|
|
||||||
if **cx.global::<StaffMode>() && once.take().is_some() {
|
|
||||||
init(cx);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.detach();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Immediately checks and runs the init function if the staff mode is not enabled.
|
|
||||||
/// This is only included for symettry with staff_mode() above
|
|
||||||
pub fn not_staff_mode<F: FnOnce(&mut AppContext) + 'static>(cx: &mut AppContext, init: F) {
|
|
||||||
if !**cx.default_global::<StaffMode>() {
|
|
||||||
init(cx)
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,7 +16,7 @@ gpui = { path = "../gpui" }
|
|||||||
picker = { path = "../picker" }
|
picker = { path = "../picker" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
staff_mode = { path = "../staff_mode" }
|
feature_flags = { path = "../feature_flags" }
|
||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
use feature_flags::FeatureFlagAppExt;
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
||||||
use gpui::{actions, elements::*, AnyElement, AppContext, Element, MouseState, ViewContext};
|
use gpui::{actions, elements::*, AnyElement, AppContext, Element, MouseState, ViewContext};
|
||||||
use picker::{Picker, PickerDelegate, PickerEvent};
|
use picker::{Picker, PickerDelegate, PickerEvent};
|
||||||
use settings::{update_settings_file, SettingsStore};
|
use settings::{update_settings_file, SettingsStore};
|
||||||
use staff_mode::StaffMode;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use theme::{Theme, ThemeMeta, ThemeRegistry, ThemeSettings};
|
use theme::{Theme, ThemeMeta, ThemeRegistry, ThemeSettings};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
@ -54,7 +54,7 @@ impl ThemeSelectorDelegate {
|
|||||||
fn new(fs: Arc<dyn Fs>, cx: &mut ViewContext<ThemeSelector>) -> Self {
|
fn new(fs: Arc<dyn Fs>, cx: &mut ViewContext<ThemeSelector>) -> Self {
|
||||||
let original_theme = theme::current(cx).clone();
|
let original_theme = theme::current(cx).clone();
|
||||||
|
|
||||||
let staff_mode = **cx.default_global::<StaffMode>();
|
let staff_mode = cx.is_staff();
|
||||||
let registry = cx.global::<Arc<ThemeRegistry>>();
|
let registry = cx.global::<Arc<ThemeRegistry>>();
|
||||||
let mut theme_names = registry.list(staff_mode).collect::<Vec<_>>();
|
let mut theme_names = registry.list(staff_mode).collect::<Vec<_>>();
|
||||||
theme_names.sort_unstable_by(|a, b| a.is_light.cmp(&b.is_light).then(a.name.cmp(&b.name)));
|
theme_names.sort_unstable_by(|a, b| a.is_light.cmp(&b.is_light).then(a.name.cmp(&b.name)));
|
||||||
|
@ -60,7 +60,7 @@ quick_action_bar = { path = "../quick_action_bar" }
|
|||||||
recent_projects = { path = "../recent_projects" }
|
recent_projects = { path = "../recent_projects" }
|
||||||
rpc = { path = "../rpc" }
|
rpc = { path = "../rpc" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
staff_mode = { path = "../staff_mode" }
|
feature_flags = { path = "../feature_flags" }
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
text = { path = "../text" }
|
text = { path = "../text" }
|
||||||
terminal_view = { path = "../terminal_view" }
|
terminal_view = { path = "../terminal_view" }
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
|
use feature_flags::FeatureFlagAppExt;
|
||||||
use futures::{future::BoxFuture, FutureExt, StreamExt};
|
use futures::{future::BoxFuture, FutureExt, StreamExt};
|
||||||
use gpui::AppContext;
|
use gpui::AppContext;
|
||||||
use language::{LanguageRegistry, LanguageServerName, LspAdapter, LspAdapterDelegate};
|
use language::{LanguageRegistry, LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||||
@ -9,7 +10,6 @@ use node_runtime::NodeRuntime;
|
|||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use settings::{KeymapFile, SettingsJsonSchemaParams, SettingsStore};
|
use settings::{KeymapFile, SettingsJsonSchemaParams, SettingsStore};
|
||||||
use smol::fs;
|
use smol::fs;
|
||||||
use staff_mode::StaffMode;
|
|
||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
ffi::OsString,
|
ffi::OsString,
|
||||||
@ -104,7 +104,7 @@ impl LspAdapter for JsonLspAdapter {
|
|||||||
cx: &mut AppContext,
|
cx: &mut AppContext,
|
||||||
) -> Option<BoxFuture<'static, serde_json::Value>> {
|
) -> Option<BoxFuture<'static, serde_json::Value>> {
|
||||||
let action_names = cx.all_action_names().collect::<Vec<_>>();
|
let action_names = cx.all_action_names().collect::<Vec<_>>();
|
||||||
let staff_mode = cx.default_global::<StaffMode>().0;
|
let staff_mode = cx.is_staff();
|
||||||
let language_names = &self.languages.language_names();
|
let language_names = &self.languages.language_names();
|
||||||
let settings_schema = cx.global::<SettingsStore>().json_schema(
|
let settings_schema = cx.global::<SettingsStore>().json_schema(
|
||||||
&SettingsJsonSchemaParams {
|
&SettingsJsonSchemaParams {
|
||||||
|
@ -53,8 +53,6 @@ use uuid::Uuid;
|
|||||||
use welcome::{show_welcome_experience, FIRST_OPEN};
|
use welcome::{show_welcome_experience, FIRST_OPEN};
|
||||||
|
|
||||||
use fs::RealFs;
|
use fs::RealFs;
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
use staff_mode::StaffMode;
|
|
||||||
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
|
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
|
||||||
use workspace::AppState;
|
use workspace::AppState;
|
||||||
use zed::{
|
use zed::{
|
||||||
@ -122,7 +120,10 @@ fn main() {
|
|||||||
cx.set_global(*RELEASE_CHANNEL);
|
cx.set_global(*RELEASE_CHANNEL);
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
cx.set_global(StaffMode(true));
|
{
|
||||||
|
use feature_flags::FeatureFlagAppExt;
|
||||||
|
cx.set_staff(true);
|
||||||
|
}
|
||||||
|
|
||||||
let mut store = SettingsStore::default();
|
let mut store = SettingsStore::default();
|
||||||
store
|
store
|
||||||
|
Loading…
Reference in New Issue
Block a user