1use gpui::{AnyElement, Render, ViewContext, WeakView};
2use ui::{prelude::*, ButtonCommon, Icon, IconButton, Tooltip};
3use workspace::{item::ItemHandle, StatusItemView, Workspace};
4
5use crate::{feedback_modal::FeedbackModal, GiveFeedback};
6
7pub struct DeployFeedbackButton {
8 workspace: WeakView<Workspace>,
9}
10
11impl DeployFeedbackButton {
12 pub fn new(workspace: &Workspace) -> Self {
13 DeployFeedbackButton {
14 workspace: workspace.weak_handle(),
15 }
16 }
17}
18
19impl Render for DeployFeedbackButton {
20 type Element = AnyElement;
21
22 fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
23 let is_open = self
24 .workspace
25 .upgrade()
26 .and_then(|workspace| {
27 workspace.update(cx, |workspace, cx| {
28 workspace.active_modal::<FeedbackModal>(cx)
29 })
30 })
31 .is_some();
32 IconButton::new("give-feedback", Icon::Envelope)
33 .style(ui::ButtonStyle::Subtle)
34 .selected(is_open)
35 .tooltip(|cx| Tooltip::text("Give Feedback", cx))
36 .on_click(|_, cx| {
37 cx.dispatch_action(Box::new(GiveFeedback));
38 })
39 .into_any_element()
40 }
41}
42
43impl StatusItemView for DeployFeedbackButton {
44 fn set_active_pane_item(
45 &mut self,
46 _item: Option<&dyn ItemHandle>,
47 _cx: &mut ViewContext<Self>,
48 ) {
49 }
50}