1pub mod deploy_feedback_button;
2pub mod feedback_editor;
3pub mod feedback_info_text;
4pub mod submit_feedback_button;
5
6use std::sync::Arc;
7
8mod system_specs;
9use gpui::{actions, impl_actions, ClipboardItem, MutableAppContext, PromptLevel, ViewContext};
10use serde::Deserialize;
11use system_specs::SystemSpecs;
12use workspace::{AppState, Workspace};
13
14#[derive(Deserialize, Clone, PartialEq)]
15pub struct OpenBrowser {
16 pub url: Arc<str>,
17}
18
19impl_actions!(zed, [OpenBrowser]);
20
21actions!(
22 zed,
23 [
24 CopySystemSpecsIntoClipboard,
25 FileBugReport,
26 RequestFeature,
27 OpenZedCommunityRepo
28 ]
29);
30
31pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
32 let system_specs = SystemSpecs::new(&cx);
33 let system_specs_text = system_specs.to_string();
34
35 feedback_editor::init(system_specs, app_state, cx);
36
37 cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
38
39 let url = format!(
40 "https://github.com/zed-industries/community/issues/new?assignees=&labels=defect%2Ctriage&template=2_bug_report.yml&environment={}",
41 urlencoding::encode(&system_specs_text)
42 );
43
44 cx.add_action(
45 move |_: &mut Workspace,
46 _: &CopySystemSpecsIntoClipboard,
47 cx: &mut ViewContext<Workspace>| {
48 cx.prompt(
49 PromptLevel::Info,
50 &format!("Copied into clipboard:\n\n{system_specs_text}"),
51 &["OK"],
52 );
53 let item = ClipboardItem::new(system_specs_text.clone());
54 cx.write_to_clipboard(item);
55 },
56 );
57
58 cx.add_action(
59 |_: &mut Workspace, _: &RequestFeature, cx: &mut ViewContext<Workspace>| {
60 let url = "https://github.com/zed-industries/community/issues/new?assignees=&labels=enhancement%2Ctriage&template=0_feature_request.yml";
61 cx.dispatch_action(OpenBrowser {
62 url: url.into(),
63 });
64 },
65 );
66
67 cx.add_action(
68 move |_: &mut Workspace, _: &FileBugReport, cx: &mut ViewContext<Workspace>| {
69 cx.dispatch_action(OpenBrowser {
70 url: url.clone().into(),
71 });
72 },
73 );
74
75 cx.add_action(
76 |_: &mut Workspace, _: &OpenZedCommunityRepo, cx: &mut ViewContext<Workspace>| {
77 let url = "https://github.com/zed-industries/community";
78 cx.dispatch_action(OpenBrowser { url: url.into() });
79 },
80 );
81}