onboarding: Adjust skip button as flow progresses (#35596)

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2025-08-04 15:16:52 -03:00 committed by GitHub
parent 9fa634f02f
commit 0ea4016e66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -254,6 +254,40 @@ impl Onboarding {
cx.emit(ItemEvent::UpdateTab); cx.emit(ItemEvent::UpdateTab);
} }
fn go_to_welcome_page(&self, cx: &mut App) {
with_active_or_new_workspace(cx, |workspace, window, cx| {
let Some((onboarding_id, onboarding_idx)) = workspace
.active_pane()
.read(cx)
.items()
.enumerate()
.find_map(|(idx, item)| {
let _ = item.downcast::<Onboarding>()?;
Some((item.item_id(), idx))
})
else {
return;
};
workspace.active_pane().update(cx, |pane, cx| {
// Get the index here to get around the borrow checker
let idx = pane.items().enumerate().find_map(|(idx, item)| {
let _ = item.downcast::<WelcomePage>()?;
Some(idx)
});
if let Some(idx) = idx {
pane.activate_item(idx, true, true, window, cx);
} else {
let item = Box::new(WelcomePage::new(window, cx));
pane.add_item(item, true, true, Some(onboarding_idx), window, cx);
}
pane.remove_item(onboarding_id, false, false, window, cx);
});
});
}
fn render_nav_buttons( fn render_nav_buttons(
&mut self, &mut self,
window: &mut Window, window: &mut Window,
@ -319,6 +353,8 @@ impl Onboarding {
} }
fn render_nav(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render_nav(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let ai_setup_page = matches!(self.selected_page, SelectedPage::AiSetup);
v_flex() v_flex()
.h_full() .h_full()
.w(rems_from_px(220.)) .w(rems_from_px(220.))
@ -357,67 +393,38 @@ impl Onboarding {
.gap_1() .gap_1()
.children(self.render_nav_buttons(window, cx)), .children(self.render_nav_buttons(window, cx)),
) )
.child( .map(|this| {
ButtonLike::new("skip_all") if ai_setup_page {
.child(Label::new("Skip All").ml_1()) this.child(
.on_click(|_, _, cx| { ButtonLike::new("start_building")
with_active_or_new_workspace( .style(ButtonStyle::Outlined)
cx, .size(ButtonSize::Medium)
|workspace, window, cx| { .child(
let Some((onboarding_id, onboarding_idx)) = h_flex()
workspace .ml_1()
.active_pane() .w_full()
.read(cx) .justify_between()
.items() .child(Label::new("Start Building"))
.enumerate() .child(
.find_map(|(idx, item)| { Icon::new(IconName::Check)
let _ = .size(IconSize::Small),
item.downcast::<Onboarding>()?; ),
Some((item.item_id(), idx)) )
}) .on_click(cx.listener(|this, _, _, cx| {
else { this.go_to_welcome_page(cx);
return; })),
}; )
} else {
workspace.active_pane().update(cx, |pane, cx| { this.child(
// Get the index here to get around the borrow checker ButtonLike::new("skip_all")
let idx = pane.items().enumerate().find_map( .size(ButtonSize::Medium)
|(idx, item)| { .child(Label::new("Skip All").ml_1())
let _ = .on_click(cx.listener(|this, _, _, cx| {
item.downcast::<WelcomePage>()?; this.go_to_welcome_page(cx);
Some(idx) })),
}, )
); }
}),
if let Some(idx) = idx {
pane.activate_item(
idx, true, true, window, cx,
);
} else {
let item =
Box::new(WelcomePage::new(window, cx));
pane.add_item(
item,
true,
true,
Some(onboarding_idx),
window,
cx,
);
}
pane.remove_item(
onboarding_id,
false,
false,
window,
cx,
);
});
},
);
}),
),
), ),
) )
.child( .child(
@ -430,8 +437,8 @@ impl Onboarding {
.into_any_element() .into_any_element()
} else { } else {
Button::new("sign_in", "Sign In") Button::new("sign_in", "Sign In")
.style(ButtonStyle::Outlined)
.full_width() .full_width()
.style(ButtonStyle::Outlined)
.on_click(|_, window, cx| { .on_click(|_, window, cx| {
let client = Client::global(cx); let client = Client::global(cx);
window window