|
1 | 1 | use ai_onboarding::YoungAccountBanner; |
2 | 2 | use anthropic::AnthropicModelMode; |
3 | 3 | use anyhow::{Context as _, Result, anyhow}; |
4 | | -use chrono::{DateTime, Utc}; |
5 | 4 | use client::{Client, UserStore, zed_urls}; |
6 | 5 | use cloud_api_types::{OrganizationId, Plan}; |
7 | 6 | use cloud_llm_client::{ |
@@ -1091,39 +1090,41 @@ fn response_lines<T: DeserializeOwned>( |
1091 | 1090 | struct ZedAiConfiguration { |
1092 | 1091 | is_connected: bool, |
1093 | 1092 | plan: Option<Plan>, |
1094 | | - subscription_period: Option<(DateTime<Utc>, DateTime<Utc>)>, |
1095 | 1093 | eligible_for_trial: bool, |
1096 | 1094 | account_too_young: bool, |
1097 | 1095 | sign_in_callback: Arc<dyn Fn(&mut Window, &mut App) + Send + Sync>, |
1098 | 1096 | } |
1099 | 1097 |
|
1100 | 1098 | impl RenderOnce for ZedAiConfiguration { |
1101 | 1099 | fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement { |
1102 | | - let is_pro = self.plan.is_some_and(|plan| plan == Plan::ZedPro); |
1103 | | - let subscription_text = match (self.plan, self.subscription_period) { |
1104 | | - (Some(Plan::ZedPro), Some(_)) => { |
1105 | | - "You have access to Zed's hosted models through your Pro subscription." |
1106 | | - } |
1107 | | - (Some(Plan::ZedProTrial), Some(_)) => { |
1108 | | - "You have access to Zed's hosted models through your Pro trial." |
1109 | | - } |
1110 | | - (Some(Plan::ZedFree), Some(_)) => { |
1111 | | - if self.eligible_for_trial { |
1112 | | - "Subscribe for access to Zed's hosted models. Start with a 14 day free trial." |
1113 | | - } else { |
1114 | | - "Subscribe for access to Zed's hosted models." |
1115 | | - } |
1116 | | - } |
1117 | | - _ => { |
| 1100 | + let (subscription_text, has_paid_plan) = match self.plan { |
| 1101 | + Some(Plan::ZedPro) => ( |
| 1102 | + "You have access to Zed's hosted models through your Pro subscription.", |
| 1103 | + true, |
| 1104 | + ), |
| 1105 | + Some(Plan::ZedProTrial) => ( |
| 1106 | + "You have access to Zed's hosted models through your Pro trial.", |
| 1107 | + false, |
| 1108 | + ), |
| 1109 | + Some(Plan::ZedStudent) => ( |
| 1110 | + "You have access to Zed's hosted models through your Student subscription.", |
| 1111 | + true, |
| 1112 | + ), |
| 1113 | + Some(Plan::ZedBusiness) => ( |
| 1114 | + "You have access to Zed's hosted models through your Organization.", |
| 1115 | + true, |
| 1116 | + ), |
| 1117 | + Some(Plan::ZedFree) | None => ( |
1118 | 1118 | if self.eligible_for_trial { |
1119 | 1119 | "Subscribe for access to Zed's hosted models. Start with a 14 day free trial." |
1120 | 1120 | } else { |
1121 | 1121 | "Subscribe for access to Zed's hosted models." |
1122 | | - } |
1123 | | - } |
| 1122 | + }, |
| 1123 | + false, |
| 1124 | + ), |
1124 | 1125 | }; |
1125 | 1126 |
|
1126 | | - let manage_subscription_buttons = if is_pro { |
| 1127 | + let manage_subscription_buttons = if has_paid_plan { |
1127 | 1128 | Button::new("manage_settings", "Manage Subscription") |
1128 | 1129 | .full_width() |
1129 | 1130 | .label_size(LabelSize::Small) |
@@ -1207,7 +1208,6 @@ impl Render for ConfigurationView { |
1207 | 1208 | ZedAiConfiguration { |
1208 | 1209 | is_connected: !state.is_signed_out(cx), |
1209 | 1210 | plan: user_store.plan(), |
1210 | | - subscription_period: user_store.subscription_period(), |
1211 | 1211 | eligible_for_trial: user_store.trial_started_at().is_none(), |
1212 | 1212 | account_too_young: user_store.account_too_young(), |
1213 | 1213 | sign_in_callback: self.sign_in_callback.clone(), |
@@ -1238,9 +1238,6 @@ impl Component for ZedAiConfiguration { |
1238 | 1238 | ZedAiConfiguration { |
1239 | 1239 | is_connected, |
1240 | 1240 | plan, |
1241 | | - subscription_period: plan |
1242 | | - .is_some() |
1243 | | - .then(|| (Utc::now(), Utc::now() + chrono::Duration::days(7))), |
1244 | 1241 | eligible_for_trial, |
1245 | 1242 | account_too_young, |
1246 | 1243 | sign_in_callback: Arc::new(|_, _| {}), |
|
0 commit comments