1use gpui::{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 fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
21 let is_open = self
22 .workspace
23 .upgrade()
24 .and_then(|workspace| {
25 workspace.update(cx, |workspace, cx| {
26 workspace.active_modal::<FeedbackModal>(cx)
27 })
28 })
29 .is_some();
30 IconButton::new("give-feedback", Icon::Envelope)
31 .style(ui::ButtonStyle::Subtle)
32 .icon_size(IconSize::Small)
33 .selected(is_open)
34 .tooltip(|cx| Tooltip::text("Share Feedback", cx))
35 .on_click(|_, cx| {
36 cx.dispatch_action(Box::new(GiveFeedback));
37 })
38 .into_any_element()
39 }
40}
41
42impl StatusItemView for DeployFeedbackButton {
43 fn set_active_pane_item(
44 &mut self,
45 _item: Option<&dyn ItemHandle>,
46 _cx: &mut ViewContext<Self>,
47 ) {
48 }
49}