onboarding: Add the AI page (#35351)
This PR starts the work on the AI onboarding page as well as the configuration modal Release Notes: - N/A --------- Co-authored-by: Danilo Leal <daniloleal09@gmail.com> Co-authored-by: Anthony <anthony@zed.dev>
This commit is contained in:
parent
e5c6a596a9
commit
b01d1872cc
12 changed files with 550 additions and 63 deletions
|
@ -1,5 +1,5 @@
|
|||
use crate::welcome::{ShowWelcome, WelcomePage};
|
||||
use client::{Client, UserStore};
|
||||
use client::{Client, CloudUserStore, UserStore};
|
||||
use command_palette_hooks::CommandPaletteFilter;
|
||||
use db::kvp::KEY_VALUE_STORE;
|
||||
use feature_flags::{FeatureFlag, FeatureFlagViewExt as _};
|
||||
|
@ -25,6 +25,7 @@ use workspace::{
|
|||
open_new, with_active_or_new_workspace,
|
||||
};
|
||||
|
||||
mod ai_setup_page;
|
||||
mod basics_page;
|
||||
mod editing_page;
|
||||
mod theme_preview;
|
||||
|
@ -78,11 +79,7 @@ pub fn init(cx: &mut App) {
|
|||
if let Some(existing) = existing {
|
||||
workspace.activate_item(&existing, true, true, window, cx);
|
||||
} else {
|
||||
let settings_page = Onboarding::new(
|
||||
workspace.weak_handle(),
|
||||
workspace.user_store().clone(),
|
||||
cx,
|
||||
);
|
||||
let settings_page = Onboarding::new(workspace, cx);
|
||||
workspace.add_item_to_active_pane(
|
||||
Box::new(settings_page),
|
||||
None,
|
||||
|
@ -198,8 +195,7 @@ pub fn show_onboarding_view(app_state: Arc<AppState>, cx: &mut App) -> Task<anyh
|
|||
|workspace, window, cx| {
|
||||
{
|
||||
workspace.toggle_dock(DockPosition::Left, window, cx);
|
||||
let onboarding_page =
|
||||
Onboarding::new(workspace.weak_handle(), workspace.user_store().clone(), cx);
|
||||
let onboarding_page = Onboarding::new(workspace, cx);
|
||||
workspace.add_item_to_center(Box::new(onboarding_page.clone()), window, cx);
|
||||
|
||||
window.focus(&onboarding_page.focus_handle(cx));
|
||||
|
@ -224,21 +220,19 @@ struct Onboarding {
|
|||
workspace: WeakEntity<Workspace>,
|
||||
focus_handle: FocusHandle,
|
||||
selected_page: SelectedPage,
|
||||
cloud_user_store: Entity<CloudUserStore>,
|
||||
user_store: Entity<UserStore>,
|
||||
_settings_subscription: Subscription,
|
||||
}
|
||||
|
||||
impl Onboarding {
|
||||
fn new(
|
||||
workspace: WeakEntity<Workspace>,
|
||||
user_store: Entity<UserStore>,
|
||||
cx: &mut App,
|
||||
) -> Entity<Self> {
|
||||
fn new(workspace: &Workspace, cx: &mut App) -> Entity<Self> {
|
||||
cx.new(|cx| Self {
|
||||
workspace,
|
||||
user_store,
|
||||
workspace: workspace.weak_handle(),
|
||||
focus_handle: cx.focus_handle(),
|
||||
selected_page: SelectedPage::Basics,
|
||||
cloud_user_store: workspace.app_state().cloud_user_store.clone(),
|
||||
user_store: workspace.user_store().clone(),
|
||||
_settings_subscription: cx.observe_global::<SettingsStore>(move |_, cx| cx.notify()),
|
||||
})
|
||||
}
|
||||
|
@ -391,13 +385,11 @@ impl Onboarding {
|
|||
SelectedPage::Editing => {
|
||||
crate::editing_page::render_editing_page(window, cx).into_any_element()
|
||||
}
|
||||
SelectedPage::AiSetup => self.render_ai_setup_page(window, cx).into_any_element(),
|
||||
SelectedPage::AiSetup => {
|
||||
crate::ai_setup_page::render_ai_setup_page(&self, window, cx).into_any_element()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn render_ai_setup_page(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
|
||||
div().child("ai setup page")
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for Onboarding {
|
||||
|
@ -418,7 +410,9 @@ impl Render for Onboarding {
|
|||
.gap_12()
|
||||
.child(self.render_nav(window, cx))
|
||||
.child(
|
||||
div()
|
||||
v_flex()
|
||||
.max_w_full()
|
||||
.min_w_0()
|
||||
.pl_12()
|
||||
.border_l_1()
|
||||
.border_color(cx.theme().colors().border_variant.opacity(0.5))
|
||||
|
@ -458,11 +452,9 @@ impl Item for Onboarding {
|
|||
_: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<Entity<Self>> {
|
||||
Some(Onboarding::new(
|
||||
self.workspace.clone(),
|
||||
self.user_store.clone(),
|
||||
cx,
|
||||
))
|
||||
self.workspace
|
||||
.update(cx, |workspace, cx| Onboarding::new(workspace, cx))
|
||||
.ok()
|
||||
}
|
||||
|
||||
fn to_item_events(event: &Self::Event, mut f: impl FnMut(workspace::item::ItemEvent)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue