Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

collab_ui: Disable Collab panel based on organization configuration (#53567)

Marshall Bowers5a9f82583bda
diff --git a/crates/cloud_api_types/src/cloud_api_types.rs b/crates/cloud_api_types/src/cloud_api_types.rs
index b4435f5bf0d..439ed5b2e82 100644
--- a/crates/cloud_api_types/src/cloud_api_types.rs
+++ b/crates/cloud_api_types/src/cloud_api_types.rs
@@ -56,6 +56,7 @@ pub struct Organization {
pub struct OrganizationConfiguration {
pub is_zed_model_provider_enabled: bool,
pub is_agent_thread_feedback_enabled: bool,
+ pub is_collaboration_enabled: bool,
pub edit_prediction: OrganizationEditPredictionConfiguration,
}
diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs
index c17cdc3d6e5..a80d5682eb5 100644
--- a/crates/collab_ui/src/collab_panel.rs
+++ b/crates/collab_ui/src/collab_panel.rs
@@ -2620,6 +2620,18 @@ impl CollabPanel {
cx.write_to_clipboard(item)
}
+ fn render_disabled_by_organization(&mut self, _cx: &mut Context<Self>) -> Div {
+ v_flex()
+ .p_4()
+ .gap_4()
+ .size_full()
+ .text_center()
+ .justify_center()
+ .child(Label::new(
+ "Collaboration is disabled for this organization.",
+ ))
+ }
+
fn render_signed_out(&mut self, cx: &mut Context<Self>) -> Div {
let collab_blurb = "Work with your team in realtime with collaborative editing, voice, shared notes and more.";
@@ -3645,6 +3657,12 @@ impl Render for CollabPanel {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let status = *self.client.status().borrow();
+ let is_collaboration_disabled = self
+ .user_store
+ .read(cx)
+ .current_organization_configuration()
+ .is_some_and(|config| !config.is_collaboration_enabled);
+
v_flex()
.key_context(self.dispatch_context(window, cx))
.on_action(cx.listener(CollabPanel::cancel))
@@ -3664,7 +3682,9 @@ impl Render for CollabPanel {
.on_action(cx.listener(CollabPanel::move_channel_down))
.track_focus(&self.focus_handle)
.size_full()
- .child(if !status.is_or_was_connected() || status.is_signing_in() {
+ .child(if is_collaboration_disabled {
+ self.render_disabled_by_organization(cx)
+ } else if !status.is_or_was_connected() || status.is_signing_in() {
self.render_signed_out(cx)
} else {
self.render_signed_in(window, cx)