1use gpui::{actions, AppContext, ClipboardItem, PromptLevel};
2use system_specs::SystemSpecs;
3use workspace::Workspace;
4
5pub mod deploy_feedback_button;
6pub mod feedback_modal;
7
8actions!(feedback, [GiveFeedback, SubmitFeedback]);
9
10mod system_specs;
11
12actions!(
13 zed,
14 [
15 CopySystemSpecsIntoClipboard,
16 FileBugReport,
17 RequestFeature,
18 OpenZedCommunityRepo
19 ]
20);
21
22pub fn init(cx: &mut AppContext) {
23 // TODO: a way to combine these two into one?
24 cx.observe_new_views(feedback_modal::FeedbackModal::register)
25 .detach();
26
27 cx.observe_new_views(|workspace: &mut Workspace, _| {
28 workspace
29 .register_action(|_, _: &CopySystemSpecsIntoClipboard, cx| {
30 let specs = SystemSpecs::new(&cx).to_string();
31
32 let prompt = cx.prompt(
33 PromptLevel::Info,
34 &format!("Copied into clipboard:\n\n{specs}"),
35 &["OK"],
36 );
37 cx.spawn(|_, _cx| async move {
38 prompt.await.ok();
39 })
40 .detach();
41 let item = ClipboardItem::new(specs.clone());
42 cx.write_to_clipboard(item);
43 })
44 .register_action(|_, _: &RequestFeature, cx| {
45 let url = "https://github.com/zed-industries/community/issues/new?assignees=&labels=enhancement%2Ctriage&template=0_feature_request.yml";
46 cx.open_url(url);
47 })
48 .register_action(move |_, _: &FileBugReport, cx| {
49 let url = format!(
50 "https://github.com/zed-industries/community/issues/new?assignees=&labels=defect%2Ctriage&template=2_bug_report.yml&environment={}",
51 urlencoding::encode(&SystemSpecs::new(&cx).to_string())
52 );
53 cx.open_url(&url);
54 })
55 .register_action(move |_, _: &OpenZedCommunityRepo, cx| {
56 let url = "https://github.com/zed-industries/community";
57 cx.open_url(&url);
58 });
59 })
60 .detach();
61}