Start separating authentication from connection to collab (#35471)
This pull request should be idempotent, but lays the groundwork for avoiding to connect to collab in order to interact with AI features provided by Zed. Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <git@maxdeviant.com> Co-authored-by: Richard Feldman <oss@rtfeldman.com>
This commit is contained in:
parent
b01d1872cc
commit
f888f3fc0b
46 changed files with 653 additions and 855 deletions
|
@ -20,7 +20,7 @@ use crate::application_menu::{
|
|||
|
||||
use auto_update::AutoUpdateStatus;
|
||||
use call::ActiveCall;
|
||||
use client::{Client, CloudUserStore, UserStore, zed_urls};
|
||||
use client::{Client, UserStore, zed_urls};
|
||||
use cloud_llm_client::Plan;
|
||||
use gpui::{
|
||||
Action, AnyElement, App, Context, Corner, Element, Entity, Focusable, InteractiveElement,
|
||||
|
@ -126,7 +126,6 @@ pub struct TitleBar {
|
|||
platform_titlebar: Entity<PlatformTitleBar>,
|
||||
project: Entity<Project>,
|
||||
user_store: Entity<UserStore>,
|
||||
cloud_user_store: Entity<CloudUserStore>,
|
||||
client: Arc<Client>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
application_menu: Option<Entity<ApplicationMenu>>,
|
||||
|
@ -180,11 +179,9 @@ impl Render for TitleBar {
|
|||
children.push(self.banner.clone().into_any_element())
|
||||
}
|
||||
|
||||
let is_authenticated = self.cloud_user_store.read(cx).is_authenticated();
|
||||
let status = self.client.status();
|
||||
let status = &*status.borrow();
|
||||
|
||||
let show_sign_in = !is_authenticated || !matches!(status, client::Status::Connected { .. });
|
||||
let user = self.user_store.read(cx).current_user();
|
||||
|
||||
children.push(
|
||||
h_flex()
|
||||
|
@ -194,10 +191,10 @@ impl Render for TitleBar {
|
|||
.children(self.render_call_controls(window, cx))
|
||||
.children(self.render_connection_status(status, cx))
|
||||
.when(
|
||||
show_sign_in && TitleBarSettings::get_global(cx).show_sign_in,
|
||||
user.is_none() && TitleBarSettings::get_global(cx).show_sign_in,
|
||||
|el| el.child(self.render_sign_in_button(cx)),
|
||||
)
|
||||
.when(is_authenticated, |parent| {
|
||||
.when(user.is_some(), |parent| {
|
||||
parent.child(self.render_user_menu_button(cx))
|
||||
})
|
||||
.into_any_element(),
|
||||
|
@ -248,7 +245,6 @@ impl TitleBar {
|
|||
) -> Self {
|
||||
let project = workspace.project().clone();
|
||||
let user_store = workspace.app_state().user_store.clone();
|
||||
let cloud_user_store = workspace.app_state().cloud_user_store.clone();
|
||||
let client = workspace.app_state().client.clone();
|
||||
let active_call = ActiveCall::global(cx);
|
||||
|
||||
|
@ -296,7 +292,6 @@ impl TitleBar {
|
|||
workspace: workspace.weak_handle(),
|
||||
project,
|
||||
user_store,
|
||||
cloud_user_store,
|
||||
client,
|
||||
_subscriptions: subscriptions,
|
||||
banner,
|
||||
|
@ -622,9 +617,8 @@ impl TitleBar {
|
|||
window
|
||||
.spawn(cx, async move |cx| {
|
||||
client
|
||||
.authenticate_and_connect(true, &cx)
|
||||
.sign_in_with_optional_connect(true, &cx)
|
||||
.await
|
||||
.into_response()
|
||||
.notify_async_err(cx);
|
||||
})
|
||||
.detach();
|
||||
|
@ -632,15 +626,15 @@ impl TitleBar {
|
|||
}
|
||||
|
||||
pub fn render_user_menu_button(&mut self, cx: &mut Context<Self>) -> impl Element {
|
||||
let cloud_user_store = self.cloud_user_store.read(cx);
|
||||
if let Some(user) = cloud_user_store.authenticated_user() {
|
||||
let has_subscription_period = cloud_user_store.subscription_period().is_some();
|
||||
let plan = cloud_user_store.plan().filter(|_| {
|
||||
let user_store = self.user_store.read(cx);
|
||||
if let Some(user) = user_store.current_user() {
|
||||
let has_subscription_period = user_store.subscription_period().is_some();
|
||||
let plan = user_store.plan().filter(|_| {
|
||||
// Since the user might be on the legacy free plan we filter based on whether we have a subscription period.
|
||||
has_subscription_period
|
||||
});
|
||||
|
||||
let user_avatar = user.avatar_url.clone();
|
||||
let user_avatar = user.avatar_uri.clone();
|
||||
let free_chip_bg = cx
|
||||
.theme()
|
||||
.colors()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue