From 099969ed79f641854352ed52180c3aeae164fdd2 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 15 Sep 2023 10:12:28 -0700 Subject: [PATCH] Ensure the chat panel is fully feature flagged --- crates/collab_ui/src/chat_panel.rs | 18 ++++++++++++++++-- crates/zed/src/main.rs | 6 ------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/crates/collab_ui/src/chat_panel.rs b/crates/collab_ui/src/chat_panel.rs index be2dbf811cd34f4b441294e2c8446112e7c52d62..c8f0f9bc8d39ed51d99614020046109c56713ca9 100644 --- a/crates/collab_ui/src/chat_panel.rs +++ b/crates/collab_ui/src/chat_panel.rs @@ -5,6 +5,7 @@ use channel::{ChannelChat, ChannelChatEvent, ChannelMessageId, ChannelStore}; use client::Client; use db::kvp::KEY_VALUE_STORE; use editor::Editor; +use feature_flags::{ChannelsAlpha, FeatureFlagAppExt}; use gpui::{ actions, elements::*, @@ -628,9 +629,14 @@ impl Panel for ChatPanel { cx.notify(); } + fn set_active(&mut self, active: bool, cx: &mut ViewContext) { + if active && !is_chat_feature_enabled(cx) { + cx.emit(Event::Dismissed); + } + } + fn icon_path(&self, cx: &gpui::WindowContext) -> Option<&'static str> { - settings::get::(cx) - .button + (settings::get::(cx).button && is_chat_feature_enabled(cx)) .then(|| "icons/conversations.svg") } @@ -642,6 +648,10 @@ impl Panel for ChatPanel { matches!(event, Event::DockPositionChanged) } + fn should_close_on_event(event: &Self::Event) -> bool { + matches!(event, Event::Dismissed) + } + fn has_focus(&self, _cx: &gpui::WindowContext) -> bool { self.has_focus } @@ -651,6 +661,10 @@ impl Panel for ChatPanel { } } +fn is_chat_feature_enabled(cx: &gpui::WindowContext<'_>) -> bool { + cx.is_staff() || cx.has_flag::() +} + fn format_timestamp( mut timestamp: OffsetDateTime, mut now: OffsetDateTime, diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index f78a4f6419ea57240f0d1bab3a2e9f0e26e0b9dd..c800e4e11097b02101c730b6e47b2263294a38cd 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -119,12 +119,6 @@ fn main() { app.run(move |cx| { cx.set_global(*RELEASE_CHANNEL); - #[cfg(debug_assertions)] - { - use feature_flags::FeatureFlagAppExt; - cx.set_staff(true); - } - let mut store = SettingsStore::default(); store .set_default_settings(default_settings().as_ref(), cx)