Move feedback items into a feedback crate
This commit is contained in:
parent
a73e264c3d
commit
c1e61b479c
10 changed files with 128 additions and 58 deletions
62
crates/feedback/src/feedback.rs
Normal file
62
crates/feedback/src/feedback.rs
Normal file
|
@ -0,0 +1,62 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
pub mod feedback_popover;
|
||||
mod system_specs;
|
||||
use gpui::{actions, impl_actions, ClipboardItem, ViewContext};
|
||||
use serde::Deserialize;
|
||||
use system_specs::SystemSpecs;
|
||||
use workspace::Workspace;
|
||||
|
||||
// TODO FEEDBACK: This open brownser code is duplicated from the zed crate, where should we refactor it to?
|
||||
#[derive(Deserialize, Clone, PartialEq)]
|
||||
struct OpenBrowser {
|
||||
url: Arc<str>,
|
||||
}
|
||||
|
||||
impl_actions!(zed, [OpenBrowser]);
|
||||
|
||||
actions!(
|
||||
zed,
|
||||
[CopySystemSpecsIntoClipboard, FileBugReport, RequestFeature,]
|
||||
);
|
||||
|
||||
pub fn init(cx: &mut gpui::MutableAppContext) {
|
||||
feedback_popover::init(cx);
|
||||
|
||||
cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
|
||||
|
||||
cx.add_action(
|
||||
|_: &mut Workspace, _: &CopySystemSpecsIntoClipboard, cx: &mut ViewContext<Workspace>| {
|
||||
let system_specs = SystemSpecs::new(cx).to_string();
|
||||
let item = ClipboardItem::new(system_specs.clone());
|
||||
cx.prompt(
|
||||
gpui::PromptLevel::Info,
|
||||
&format!("Copied into clipboard:\n\n{system_specs}"),
|
||||
&["OK"],
|
||||
);
|
||||
cx.write_to_clipboard(item);
|
||||
},
|
||||
);
|
||||
|
||||
cx.add_action(
|
||||
|_: &mut Workspace, _: &RequestFeature, cx: &mut ViewContext<Workspace>| {
|
||||
let url = "https://github.com/zed-industries/feedback/issues/new?assignees=&labels=enhancement%2Ctriage&template=0_feature_request.yml";
|
||||
cx.dispatch_action(OpenBrowser {
|
||||
url: url.into(),
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
cx.add_action(
|
||||
|_: &mut Workspace, _: &FileBugReport, cx: &mut ViewContext<Workspace>| {
|
||||
let system_specs_text = SystemSpecs::new(cx).to_string();
|
||||
let url = format!(
|
||||
"https://github.com/zed-industries/feedback/issues/new?assignees=&labels=defect%2Ctriage&template=2_bug_report.yml&environment={}",
|
||||
urlencoding::encode(&system_specs_text)
|
||||
);
|
||||
cx.dispatch_action(OpenBrowser {
|
||||
url: url.into(),
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue