temp
This commit is contained in:
@@ -2,7 +2,7 @@ use gpui::{AnyElement, Render, ViewContext, WeakView};
|
||||
use ui::{prelude::*, ButtonCommon, Icon, IconButton, Tooltip};
|
||||
use workspace::{item::ItemHandle, StatusItemView, Workspace};
|
||||
|
||||
use crate::feedback_editor::FeedbackEditor;
|
||||
use crate::{feedback_editor::GiveFeedback, feedback_modal::FeedbackModal};
|
||||
|
||||
pub struct DeployFeedbackButton {
|
||||
active: bool,
|
||||
@@ -22,34 +22,32 @@ impl Render for DeployFeedbackButton {
|
||||
type Element = AnyElement;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
let active = self.active;
|
||||
|
||||
let is_open = self
|
||||
.workspace
|
||||
.upgrade()
|
||||
.and_then(|workspace| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.active_modal::<FeedbackModal>(cx)
|
||||
})
|
||||
})
|
||||
.is_some();
|
||||
IconButton::new("give-feedback", Icon::Envelope)
|
||||
.style(ui::ButtonStyle::Subtle)
|
||||
.selected(is_open)
|
||||
.tooltip(|cx| Tooltip::text("Give Feedback", cx))
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
let Some(workspace) = this.workspace.upgrade() else {
|
||||
return;
|
||||
};
|
||||
|
||||
if !active {
|
||||
workspace.update(cx, |workspace, cx| FeedbackEditor::deploy(workspace, cx))
|
||||
}
|
||||
}))
|
||||
.on_click(|_, cx| {
|
||||
cx.dispatch_action(Box::new(GiveFeedback));
|
||||
})
|
||||
.into_any_element()
|
||||
}
|
||||
}
|
||||
|
||||
impl StatusItemView for DeployFeedbackButton {
|
||||
fn set_active_pane_item(&mut self, item: Option<&dyn ItemHandle>, cx: &mut ViewContext<Self>) {
|
||||
if let Some(item) = item {
|
||||
if let Some(_) = item.downcast::<FeedbackEditor>() {
|
||||
self.active = true;
|
||||
cx.notify();
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.active = false;
|
||||
cx.notify();
|
||||
fn set_active_pane_item(
|
||||
&mut self,
|
||||
_item: Option<&dyn ItemHandle>,
|
||||
_cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user