Move feedback items into a feedback crate

This commit is contained in:
Joseph Lyons 2023-01-09 13:54:37 -05:00
parent a73e264c3d
commit c1e61b479c
10 changed files with 128 additions and 58 deletions

28
Cargo.lock generated
View File

@ -2022,6 +2022,26 @@ dependencies = [
"instant",
]
[[package]]
name = "feedback"
version = "0.1.0"
dependencies = [
"anyhow",
"client",
"editor",
"futures 0.3.25",
"gpui",
"human_bytes",
"isahc",
"lazy_static",
"serde",
"settings",
"sysinfo",
"urlencoding",
"util",
"workspace",
]
[[package]]
name = "file-per-thread-logger"
version = "0.1.5"
@ -6239,9 +6259,9 @@ dependencies = [
[[package]]
name = "sysinfo"
version = "0.27.1"
version = "0.27.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccb297c0afb439440834b4bcf02c5c9da8ec2e808e70f36b0d8e815ff403bd24"
checksum = "1620f9573034c573376acc550f3b9a2be96daeb08abb3c12c8523e1cee06e80f"
dependencies = [
"cfg-if 1.0.0",
"core-foundation-sys",
@ -8212,6 +8232,7 @@ dependencies = [
"easy-parallel",
"editor",
"env_logger",
"feedback",
"file_finder",
"fs",
"fsevent",
@ -8219,7 +8240,6 @@ dependencies = [
"fuzzy",
"go_to_line",
"gpui",
"human_bytes",
"ignore",
"image",
"indexmap",
@ -8253,7 +8273,6 @@ dependencies = [
"smallvec",
"smol",
"sum_tree",
"sysinfo",
"tempdir",
"terminal_view",
"text",
@ -8282,7 +8301,6 @@ dependencies = [
"tree-sitter-typescript",
"unindent",
"url",
"urlencoding",
"util",
"vim",
"workspace",

View File

@ -17,6 +17,7 @@ members = [
"crates/diagnostics",
"crates/drag_and_drop",
"crates/editor",
"crates/feedback",
"crates/file_finder",
"crates/fs",
"crates/fsevent",

View File

@ -0,0 +1,26 @@
[package]
name = "feedback"
version = "0.1.0"
edition = "2021"
[lib]
path = "src/feedback.rs"
[features]
test-support = []
[dependencies]
anyhow = "1.0.38"
client = { path = "../client" }
editor = { path = "../editor" }
futures = "0.3"
gpui = { path = "../gpui" }
human_bytes = "0.4.1"
isahc = "1.7"
lazy_static = "1.4.0"
serde = { version = "1.0", features = ["derive", "rc"] }
settings = { path = "../settings" }
sysinfo = "0.27.1"
urlencoding = "2.1.2"
util = { path = "../util" }
workspace = { path = "../workspace" }

View 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(),
});
},
);
}

View File

@ -230,6 +230,12 @@ impl View for FeedbackPopover {
fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
enum SubmitFeedback {}
// I'd like to just define:
// 1. Overall popover width x height dimensions (done)
// 2. Submit Feedback button height dimensions
// 3. Allow editor to dynamically fill in the remaining space
let theme = cx.global::<Settings>().theme.clone();
let submit_feedback_text_button_height = 20.0;

View File

@ -29,8 +29,8 @@ client = { path = "../client" }
clock = { path = "../clock" }
diagnostics = { path = "../diagnostics" }
editor = { path = "../editor" }
feedback = { path = "../feedback" }
file_finder = { path = "../file_finder" }
human_bytes = "0.4.1"
search = { path = "../search" }
fs = { path = "../fs" }
fsevent = { path = "../fsevent" }
@ -49,7 +49,6 @@ recent_projects = { path = "../recent_projects" }
rpc = { path = "../rpc" }
settings = { path = "../settings" }
sum_tree = { path = "../sum_tree" }
sysinfo = "0.27.1"
text = { path = "../text" }
terminal_view = { path = "../terminal_view" }
theme = { path = "../theme" }
@ -110,7 +109,6 @@ tree-sitter-html = "0.19.0"
tree-sitter-scheme = { git = "https://github.com/6cdh/tree-sitter-scheme", rev = "af0fd1fa452cb2562dc7b5c8a8c55551c39273b9"}
tree-sitter-racket = { git = "https://github.com/zed-industries/tree-sitter-racket", rev = "eb010cf2c674c6fd9a6316a84e28ef90190fe51a"}
url = "2.2"
urlencoding = "2.1.2"
[dev-dependencies]
call = { path = "../call", features = ["test-support"] }

View File

@ -14,6 +14,7 @@ use client::{
http::{self, HttpClient},
UserStore, ZED_SECRET_CLIENT_TOKEN,
};
use futures::{
channel::{mpsc, oneshot},
FutureExt, SinkExt, StreamExt,
@ -41,7 +42,7 @@ use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
use workspace::{
self, item::ItemHandle, notifications::NotifyResultExt, AppState, NewFile, OpenPaths, Workspace,
};
use zed::{self, build_window_options, feedback_popover, initialize_workspace, languages, menus};
use zed::{self, build_window_options, initialize_workspace, languages, menus};
fn main() {
let http = http::client();
@ -110,12 +111,12 @@ fn main() {
cx.set_global(client.clone());
feedback_popover::init(cx);
context_menu::init(cx);
project::Project::init(&client);
client::init(client.clone(), cx);
command_palette::init(cx);
editor::init(cx);
feedback::init(cx);
go_to_line::init(cx);
file_finder::init(cx);
outline::init(cx);

View File

@ -340,15 +340,15 @@ pub fn menus() -> Vec<Menu<'static>> {
MenuItem::Separator,
MenuItem::Action {
name: "Copy System Specs Into Clipboard",
action: Box::new(crate::CopySystemSpecsIntoClipboard),
action: Box::new(feedback::CopySystemSpecsIntoClipboard),
},
MenuItem::Action {
name: "File Bug Report",
action: Box::new(crate::FileBugReport),
action: Box::new(feedback::FileBugReport),
},
MenuItem::Action {
name: "Request Feature",
action: Box::new(crate::RequestFeature),
action: Box::new(feedback::RequestFeature),
},
MenuItem::Separator,
MenuItem::Action {

View File

@ -1,10 +1,7 @@
pub mod feedback_popover;
pub mod languages;
pub mod menus;
pub mod system_specs;
#[cfg(any(test, feature = "test-support"))]
pub mod test;
use anyhow::{anyhow, Context, Result};
use assets::Assets;
use breadcrumbs::Breadcrumbs;
@ -22,7 +19,7 @@ use gpui::{
},
impl_actions,
platform::{WindowBounds, WindowOptions},
AssetSource, AsyncAppContext, ClipboardItem, TitlebarOptions, ViewContext, WindowKind,
AssetSource, AsyncAppContext, TitlebarOptions, ViewContext, WindowKind,
};
use language::Rope;
use lazy_static::lazy_static;
@ -34,7 +31,6 @@ use serde::Deserialize;
use serde_json::to_string_pretty;
use settings::{keymap_file_json_schema, settings_file_json_schema, Settings};
use std::{env, path::Path, str, sync::Arc};
use system_specs::SystemSpecs;
use util::{channel::ReleaseChannel, paths, ResultExt};
pub use workspace;
use workspace::{sidebar::SidebarSide, AppState, Workspace};
@ -69,9 +65,6 @@ actions!(
ResetBufferFontSize,
InstallCommandLineInterface,
ResetDatabase,
CopySystemSpecsIntoClipboard,
RequestFeature,
FileBugReport
]
);
@ -250,41 +243,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
},
);
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(),
});
},
);
activity_indicator::init(cx);
call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
settings::KeymapFileContent::load_defaults(cx);
@ -369,12 +327,12 @@ pub fn initialize_workspace(
let activity_indicator =
activity_indicator::ActivityIndicator::new(workspace, app_state.languages.clone(), cx);
let cursor_position = cx.add_view(|_| editor::items::CursorPosition::new());
let feedback_link = cx.add_view(|_| feedback_popover::FeedbackButton::new());
let feedback_button = cx.add_view(|_| feedback::feedback_popover::FeedbackButton::new());
workspace.status_bar().update(cx, |status_bar, cx| {
status_bar.add_left_item(diagnostic_summary, cx);
status_bar.add_left_item(activity_indicator, cx);
status_bar.add_right_item(cursor_position, cx);
status_bar.add_right_item(feedback_link, cx);
status_bar.add_right_item(feedback_button, cx);
});
auto_update::notify_of_any_new_update(cx.weak_handle(), cx);