feedback2.rs

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