WIP
This commit is contained in:
parent
ee45db8a78
commit
79e0d8ce3b
4 changed files with 57 additions and 24 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3195,6 +3195,7 @@ dependencies = [
|
||||||
"language2",
|
"language2",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
|
"menu2",
|
||||||
"postage",
|
"postage",
|
||||||
"project2",
|
"project2",
|
||||||
"regex",
|
"regex",
|
||||||
|
|
|
@ -14,16 +14,17 @@ test-support = []
|
||||||
client = { package = "client2", path = "../client2" }
|
client = { package = "client2", path = "../client2" }
|
||||||
db = { package = "db2", path = "../db2" }
|
db = { package = "db2", path = "../db2" }
|
||||||
editor = { package = "editor2", path = "../editor2" }
|
editor = { package = "editor2", path = "../editor2" }
|
||||||
language = { package = "language2", path = "../language2" }
|
|
||||||
gpui = { package = "gpui2", path = "../gpui2" }
|
gpui = { package = "gpui2", path = "../gpui2" }
|
||||||
|
language = { package = "language2", path = "../language2" }
|
||||||
|
menu = { package = "menu2", path = "../menu2" }
|
||||||
project = { package = "project2", path = "../project2" }
|
project = { package = "project2", path = "../project2" }
|
||||||
regex.workspace = true
|
regex.workspace = true
|
||||||
search = { package = "search2", path = "../search2" }
|
search = { package = "search2", path = "../search2" }
|
||||||
settings = { package = "settings2", path = "../settings2" }
|
settings = { package = "settings2", path = "../settings2" }
|
||||||
theme = { package = "theme2", path = "../theme2" }
|
theme = { package = "theme2", path = "../theme2" }
|
||||||
|
ui = { package = "ui2", path = "../ui2" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
workspace = { package = "workspace2", path = "../workspace2"}
|
workspace = { package = "workspace2", path = "../workspace2"}
|
||||||
ui = { package = "ui2", path = "../ui2" }
|
|
||||||
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
|
|
|
@ -17,11 +17,11 @@ actions!(
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
// TODO - a way to combine these two into one?
|
// TODO: a way to combine these two into one?
|
||||||
cx.observe_new_views(feedback_modal::FeedbackModal::register)
|
cx.observe_new_views(feedback_modal::FeedbackModal::register)
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
cx.observe_new_views(|workspace: &mut Workspace, _cx| {
|
cx.observe_new_views(|workspace: &mut Workspace, _| {
|
||||||
workspace
|
workspace
|
||||||
.register_action(|_, _: &CopySystemSpecsIntoClipboard, cx| {
|
.register_action(|_, _: &CopySystemSpecsIntoClipboard, cx| {
|
||||||
let specs = SystemSpecs::new(&cx).to_string();
|
let specs = SystemSpecs::new(&cx).to_string();
|
||||||
|
|
|
@ -231,6 +231,14 @@ impl FeedbackModal {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Escape button calls dismiss
|
||||||
|
// TODO: Should do same as hitting cancel / clicking outside of modal
|
||||||
|
// Close immediately if no text in field
|
||||||
|
// Ask to close if text in the field
|
||||||
|
fn cancel(&mut self, _: &menu::Cancel, cx: &mut ViewContext<Self>) {
|
||||||
|
cx.emit(DismissEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for FeedbackModal {
|
impl Render for FeedbackModal {
|
||||||
|
@ -253,26 +261,35 @@ impl Render for FeedbackModal {
|
||||||
let allow_submission =
|
let allow_submission =
|
||||||
valid_character_count && valid_email_address && !self.pending_submission;
|
valid_character_count && valid_email_address && !self.pending_submission;
|
||||||
|
|
||||||
let dismiss = cx.listener(|_, _, cx| {
|
let has_feedback = self.feedback_editor.read(cx).text_option(cx).is_some();
|
||||||
// TODO
|
|
||||||
// if self.feedback_editor.read(cx).text_option(cx).is_some() {
|
|
||||||
// let answer = cx.prompt(PromptLevel::Info, "Exit feedback?", &["Yes", "No"]);
|
|
||||||
// cx.spawn(|_, cx| async move {
|
|
||||||
// let answer = answer.await.ok();
|
|
||||||
// if answer == Some(0) {
|
|
||||||
// cx.emit(DismissEvent);
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .detach();
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
let submit_button_text = if self.pending_submission {
|
||||||
|
"Sending..."
|
||||||
|
} else {
|
||||||
|
"Send Feedback"
|
||||||
|
};
|
||||||
|
let dismiss = cx.listener(|_, _, cx| {
|
||||||
cx.emit(DismissEvent);
|
cx.emit(DismissEvent);
|
||||||
});
|
});
|
||||||
|
// TODO: get the "are you sure you want to dismiss?" prompt here working
|
||||||
|
let dismiss_prompt = cx.listener(|_, _, _| {
|
||||||
|
// let answer = cx.prompt(PromptLevel::Info, "Exit feedback?", &["Yes", "No"]);
|
||||||
|
// cx.spawn(|_, _| async move {
|
||||||
|
// let answer = answer.await.ok();
|
||||||
|
// if answer == Some(0) {
|
||||||
|
// cx.emit(DismissEvent);
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// .detach();
|
||||||
|
});
|
||||||
let open_community_repo =
|
let open_community_repo =
|
||||||
cx.listener(|_, _, cx| cx.dispatch_action(Box::new(OpenZedCommunityRepo)));
|
cx.listener(|_, _, cx| cx.dispatch_action(Box::new(OpenZedCommunityRepo)));
|
||||||
|
|
||||||
|
// TODO: Nate UI pass
|
||||||
v_stack()
|
v_stack()
|
||||||
.elevation_3(cx)
|
.elevation_3(cx)
|
||||||
|
.key_context("GiveFeedback")
|
||||||
|
.on_action(cx.listener(Self::cancel))
|
||||||
.min_w(rems(40.))
|
.min_w(rems(40.))
|
||||||
.max_w(rems(96.))
|
.max_w(rems(96.))
|
||||||
.border()
|
.border()
|
||||||
|
@ -302,11 +319,15 @@ impl Render for FeedbackModal {
|
||||||
"Characters: {}",
|
"Characters: {}",
|
||||||
characters_remaining
|
characters_remaining
|
||||||
))
|
))
|
||||||
.when(valid_character_count, |this| this.color(Color::Success))
|
.when_else(
|
||||||
.when(!valid_character_count, |this| this.color(Color::Error))
|
valid_character_count,
|
||||||
|
|this| this.color(Color::Success),
|
||||||
|
|this| this.color(Color::Error)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.child( div()
|
.child(
|
||||||
|
div()
|
||||||
.bg(cx.theme().colors().editor_background)
|
.bg(cx.theme().colors().editor_background)
|
||||||
.border()
|
.border()
|
||||||
.border_color(cx.theme().colors().border)
|
.border_color(cx.theme().colors().border)
|
||||||
|
@ -326,14 +347,24 @@ impl Render for FeedbackModal {
|
||||||
Button::new("cancel_feedback", "Cancel")
|
Button::new("cancel_feedback", "Cancel")
|
||||||
.style(ButtonStyle::Subtle)
|
.style(ButtonStyle::Subtle)
|
||||||
.color(Color::Muted)
|
.color(Color::Muted)
|
||||||
.on_click(dismiss),
|
// TODO: replicate this logic when clicking outside the modal
|
||||||
|
// TODO: Will require somehow overriding the modal dismal default behavior
|
||||||
|
.when_else(
|
||||||
|
has_feedback,
|
||||||
|
|this| this.on_click(dismiss_prompt),
|
||||||
|
|this| this.on_click(dismiss)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("send_feedback", "Send Feedback")
|
Button::new("send_feedback", submit_button_text)
|
||||||
.color(Color::Accent)
|
.color(Color::Accent)
|
||||||
.style(ButtonStyle::Filled)
|
.style(ButtonStyle::Filled)
|
||||||
// TODO - error handling - show modal on error
|
// TODO: Ensure that while submitting, "Sending..." is shown and disable the button
|
||||||
.on_click(cx.listener(|this, _, cx| {let _ = this.submit(cx);}))
|
// TODO: If submit errors: show popup with error, don't close modal, set text back to "Send Feedback", and re-enable button
|
||||||
|
// TODO: If submit is successful, close the modal
|
||||||
|
.on_click(cx.listener(|this, _, cx| {
|
||||||
|
let _ = this.submit(cx);
|
||||||
|
}))
|
||||||
.tooltip(|cx| {
|
.tooltip(|cx| {
|
||||||
Tooltip::with_meta(
|
Tooltip::with_meta(
|
||||||
"Submit feedback to the Zed team.",
|
"Submit feedback to the Zed team.",
|
||||||
|
@ -342,7 +373,7 @@ impl Render for FeedbackModal {
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.when(!allow_submission, |this| this.disabled(true)),
|
.when(!allow_submission, |this| this.disabled(true))
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue