1use gpui::{actions, AppContext, ClipboardItem, PromptLevel};
2use system_specs::SystemSpecs;
3use workspace::Workspace;
4
5pub mod feedback_modal;
6
7actions!(feedback, [GiveFeedback, SubmitFeedback]);
8
9mod system_specs;
10
11actions!(
12 zed,
13 [
14 CopySystemSpecsIntoClipboard,
15 FileBugReport,
16 RequestFeature,
17 OpenZedRepo
18 ]
19);
20
21const fn zed_repo_url() -> &'static str {
22 "https://github.com/zed-industries/zed"
23}
24
25const fn request_feature_url() -> &'static str {
26 "https://github.com/zed-industries/zed/issues/new?assignees=&labels=admin+read%2Ctriage%2Cenhancement&projects=&template=0_feature_request.yml"
27}
28
29fn file_bug_report_url(specs: &SystemSpecs) -> String {
30 format!(
31 "https://github.com/zed-industries/zed/issues/new?assignees=&labels=admin+read%2Ctriage%2Cdefect&projects=&template=1_bug_report.yml&environment={}",
32 urlencoding::encode(&specs.to_string())
33 )
34}
35
36pub fn init(cx: &mut AppContext) {
37 cx.observe_new_views(|workspace: &mut Workspace, cx| {
38 feedback_modal::FeedbackModal::register(workspace, cx);
39 workspace
40 .register_action(|_, _: &CopySystemSpecsIntoClipboard, cx| {
41 let specs = SystemSpecs::new(&cx).to_string();
42
43 let prompt = cx.prompt(
44 PromptLevel::Info,
45 "Copied into clipboard",
46 Some(&specs),
47 &["OK"],
48 );
49 cx.spawn(|_, _cx| async move {
50 prompt.await.ok();
51 })
52 .detach();
53 cx.write_to_clipboard(ClipboardItem::new(specs.clone()));
54 })
55 .register_action(|_, _: &RequestFeature, cx| {
56 cx.open_url(request_feature_url());
57 })
58 .register_action(move |_, _: &FileBugReport, cx| {
59 cx.open_url(&file_bug_report_url(&SystemSpecs::new(&cx)));
60 })
61 .register_action(move |_, _: &OpenZedRepo, cx| {
62 cx.open_url(zed_repo_url());
63 });
64 })
65 .detach();
66}