From 83114589313dcbe9f16f9963da43cf19d3fe370b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 7 Jun 2022 15:48:12 -0700 Subject: [PATCH] Add status bar link and Help menu item to open an issue on feedback repo --- crates/theme/src/theme.rs | 1 + crates/zed/src/feedback.rs | 51 +++++++++++++++++++++++++++++++ crates/zed/src/menus.rs | 6 ++++ crates/zed/src/zed.rs | 3 ++ styles/src/styleTree/statusBar.ts | 4 +++ 5 files changed, 65 insertions(+) create mode 100644 crates/zed/src/feedback.rs diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 58bf70eae8..8e282100d4 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -157,6 +157,7 @@ pub struct StatusBar { pub auto_update_progress_message: TextStyle, pub auto_update_done_message: TextStyle, pub lsp_status: Interactive, + pub feedback: Interactive, pub sidebar_buttons: StatusBarSidebarButtons, pub diagnostic_summary: Interactive, pub diagnostic_message: Interactive, diff --git a/crates/zed/src/feedback.rs b/crates/zed/src/feedback.rs new file mode 100644 index 0000000000..9e7564f411 --- /dev/null +++ b/crates/zed/src/feedback.rs @@ -0,0 +1,51 @@ +use crate::OpenBrowser; +use gpui::{ + elements::{MouseEventHandler, Text}, + platform::CursorStyle, + Element, Entity, RenderContext, View, +}; +use settings::Settings; +use workspace::StatusItemView; + +pub const NEW_ISSUE_URL: &'static str = + "https://github.com/zed-industries/feedback/issues/new/choose"; + +pub struct FeedbackLink; + +impl Entity for FeedbackLink { + type Event = (); +} + +impl View for FeedbackLink { + fn ui_name() -> &'static str { + "FeedbackLink" + } + + fn render(&mut self, cx: &mut RenderContext<'_, Self>) -> gpui::ElementBox { + MouseEventHandler::new::(0, cx, |state, cx| { + let theme = &cx.global::().theme; + let theme = &theme.workspace.status_bar.feedback; + Text::new( + "Give Feedback".to_string(), + theme.style_for(state, false).clone(), + ) + .boxed() + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(|_, _, cx| { + cx.dispatch_action(OpenBrowser { + url: NEW_ISSUE_URL.into(), + }) + }) + .boxed() + } +} + +impl StatusItemView for FeedbackLink { + fn set_active_pane_item( + &mut self, + _: Option<&dyn workspace::ItemHandle>, + _: &mut gpui::ViewContext, + ) { + } +} diff --git a/crates/zed/src/menus.rs b/crates/zed/src/menus.rs index cc5f128bc0..ed66953ad8 100644 --- a/crates/zed/src/menus.rs +++ b/crates/zed/src/menus.rs @@ -253,6 +253,12 @@ pub fn menus() -> Vec> { action: Box::new(command_palette::Toggle), }, MenuItem::Separator, + MenuItem::Action { + name: "Give Feedback", + action: Box::new(crate::OpenBrowser { + url: super::feedback::NEW_ISSUE_URL.into(), + }), + }, MenuItem::Action { name: "Zed.dev", action: Box::new(crate::OpenBrowser { diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 1ebb1dc446..0f4598b1b7 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -1,3 +1,4 @@ +mod feedback; pub mod languages; pub mod menus; pub mod settings_file; @@ -203,11 +204,13 @@ pub fn initialize_workspace( }); let cursor_position = cx.add_view(|_| editor::items::CursorPosition::new()); let auto_update = cx.add_view(|cx| auto_update::AutoUpdateIndicator::new(cx)); + let feedback_link = cx.add_view(|_| feedback::FeedbackLink); workspace.status_bar().update(cx, |status_bar, cx| { status_bar.add_left_item(diagnostic_summary, cx); status_bar.add_left_item(lsp_status, cx); status_bar.add_right_item(cursor_position, cx); status_bar.add_right_item(auto_update, cx); + status_bar.add_right_item(feedback_link, cx); }); auto_update::notify_of_any_new_update(cx.weak_handle(), cx); diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 4b3fbaafea..47050fe3ca 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -43,6 +43,10 @@ export default function statusBar(theme: Theme) { ...text(theme, "sans", "muted"), hover: text(theme, "sans", "secondary"), }, + feedback: { + ...text(theme, "sans", "muted"), + hover: text(theme, "sans", "active"), + }, diagnosticSummary: { height: 16, iconWidth: 14,