feedback.rs

 1use crate::OpenBrowser;
 2use gpui::{
 3    elements::{MouseEventHandler, Text},
 4    platform::CursorStyle,
 5    Element, Entity, MouseButton, RenderContext, View,
 6};
 7use settings::Settings;
 8use workspace::{item::ItemHandle, StatusItemView};
 9
10pub const NEW_ISSUE_URL: &str = "https://github.com/zed-industries/feedback/issues/new/choose";
11
12pub struct FeedbackLink;
13
14impl Entity for FeedbackLink {
15    type Event = ();
16}
17
18impl View for FeedbackLink {
19    fn ui_name() -> &'static str {
20        "FeedbackLink"
21    }
22
23    fn render(&mut self, cx: &mut RenderContext<'_, Self>) -> gpui::ElementBox {
24        MouseEventHandler::<Self>::new(0, cx, |state, cx| {
25            let theme = &cx.global::<Settings>().theme;
26            let theme = &theme.workspace.status_bar.feedback;
27            Text::new(
28                "Give Feedback".to_string(),
29                theme.style_for(state, false).clone(),
30            )
31            .boxed()
32        })
33        .with_cursor_style(CursorStyle::PointingHand)
34        .on_click(MouseButton::Left, |_, cx| {
35            cx.dispatch_action(OpenBrowser {
36                url: NEW_ISSUE_URL.into(),
37            })
38        })
39        .boxed()
40    }
41}
42
43impl StatusItemView for FeedbackLink {
44    fn set_active_pane_item(
45        &mut self,
46        _: Option<&dyn ItemHandle>,
47        _: &mut gpui::ViewContext<Self>,
48    ) {
49    }
50}