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