From 07c7778cffc895f6cfb1ad4dbc99e90a09be32e5 Mon Sep 17 00:00:00 2001 From: Subash Chandra Sapkota Date: Fri, 16 Feb 2024 21:30:55 +0545 Subject: [PATCH] Add cancel button on GitHub Copilot actions (#7850) Release Notes: - Added cancel button on Copilot actions ([#6878](https://github.com/zed-industries/zed/issues/6878)). Here is the screenshot of the UI change: Screenshot 2024-02-15 at 13 00 53 --- crates/copilot_ui/src/sign_in.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/copilot_ui/src/sign_in.rs b/crates/copilot_ui/src/sign_in.rs index d841ee8ced..1ac0469f2d 100644 --- a/crates/copilot_ui/src/sign_in.rs +++ b/crates/copilot_ui/src/sign_in.rs @@ -116,6 +116,11 @@ impl CopilotCodeVerification { .full_width() .style(ButtonStyle::Filled), ) + .child( + Button::new("copilot-enable-cancel-button", "Cancel") + .full_width() + .on_click(cx.listener(|_, _, cx| cx.emit(DismissEvent))), + ) } fn render_enabled_modal(cx: &mut ViewContext) -> impl Element { v_flex() @@ -131,7 +136,7 @@ impl CopilotCodeVerification { ) } - fn render_unauthorized_modal() -> impl Element { + fn render_unauthorized_modal(cx: &mut ViewContext) -> impl Element { v_flex() .child(Headline::new("You must have an active GitHub Copilot subscription.").size(HeadlineSize::Large)) @@ -143,6 +148,11 @@ impl CopilotCodeVerification { .full_width() .on_click(|_, cx| cx.open_url(COPILOT_SIGN_UP_URL)), ) + .child( + Button::new("copilot-subscribe-cancel-button", "Cancel") + .full_width() + .on_click(cx.listener(|_, _, cx| cx.emit(DismissEvent))), + ) } fn render_disabled_modal() -> impl Element { @@ -160,7 +170,7 @@ impl Render for CopilotCodeVerification { } => Self::render_prompting_modal(self.connect_clicked, &prompt, cx).into_any_element(), Status::Unauthorized => { self.connect_clicked = false; - Self::render_unauthorized_modal().into_any_element() + Self::render_unauthorized_modal(cx).into_any_element() } Status::Authorized => { self.connect_clicked = false;