дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-27 21:12:34 +02:00
Порівняти коміти
9
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
1bd6036b67 | ||
|
|
112a4da502 | ||
|
|
dcd81d601b | ||
|
|
762ebecd86 | ||
|
|
fd4efff6e3 | ||
|
|
8968974f42 | ||
|
|
5f083ae47c | ||
|
|
83b14b4329 | ||
|
|
74eefd6116 |
No files matched your search
@@ -443,7 +443,15 @@ fn write_atomic(path: &Path, bytes: &[u8]) -> std::io::Result<()> {
|
||||
|
||||
/// Installs (or updates to) the registry's current version of `id`, streaming progress
|
||||
/// through `emit`, and points the agent file at it.
|
||||
pub fn install(paths: &RegistryPaths, id: &str, cancel: &CancellationToken, emit: Emit) -> IdeResult<()> {
|
||||
/// Installs agent `id`; an npm package retries against the public npm registry when the
|
||||
/// configured one misses it only with `public_npm_fallback`.
|
||||
pub fn install(
|
||||
paths: &RegistryPaths,
|
||||
id: &str,
|
||||
public_npm_fallback: bool,
|
||||
cancel: &CancellationToken,
|
||||
emit: Emit,
|
||||
) -> IdeResult<()> {
|
||||
let id = canonical_id(id);
|
||||
// The saved index is what the user picked from; fetch only when there is none.
|
||||
let text = match fs::read_to_string(&paths.cache_file) {
|
||||
@@ -455,9 +463,14 @@ pub fn install(paths: &RegistryPaths, id: &str, cancel: &CancellationToken, emit
|
||||
.iter()
|
||||
.find(|e| e.id == id)
|
||||
.ok_or_else(|| IdeError::not_found(format!("{id} is not in the ACP Registry")))?;
|
||||
install_entry(paths, entry, Platform::current(), &on_path, cancel, emit)
|
||||
let npm_installer =
|
||||
move |p: &Package, entry: &Entry, dir: &Path, platform, cancel: &CancellationToken, emit: Emit| {
|
||||
install_npm(p, entry, dir, platform, public_npm_fallback, cancel, emit)
|
||||
};
|
||||
install_entry_with(paths, entry, Platform::current(), &on_path, &npm_installer, cancel, emit)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn install_entry(
|
||||
paths: &RegistryPaths,
|
||||
entry: &Entry,
|
||||
@@ -466,7 +479,10 @@ fn install_entry(
|
||||
cancel: &CancellationToken,
|
||||
emit: Emit,
|
||||
) -> IdeResult<()> {
|
||||
install_entry_with(paths, entry, platform, on_path, &install_npm, cancel, emit)
|
||||
let npm_installer = |p: &Package, entry: &Entry, dir: &Path, platform, cancel: &CancellationToken, emit: Emit| {
|
||||
install_npm(p, entry, dir, platform, true, cancel, emit)
|
||||
};
|
||||
install_entry_with(paths, entry, platform, on_path, &npm_installer, cancel, emit)
|
||||
}
|
||||
|
||||
type NpmInstaller = dyn Fn(&Package, &Entry, &Path, Platform, &CancellationToken, Emit) -> IdeResult<PathBuf>;
|
||||
@@ -663,20 +679,23 @@ fn install_npm(
|
||||
entry: &Entry,
|
||||
dir: &Path,
|
||||
platform: Platform,
|
||||
public_fallback: bool,
|
||||
cancel: &CancellationToken,
|
||||
emit: Emit,
|
||||
) -> IdeResult<PathBuf> {
|
||||
let (name, _) = split_npm_spec(&p.package);
|
||||
let npm = which::which("npm").map_err(|_| IdeError::unavailable(format!("npm is required to install {name}")))?;
|
||||
install_npm_with(&npm, p, entry, dir, platform, cancel, emit)
|
||||
install_npm_with(&npm, p, entry, dir, platform, public_fallback, cancel, emit)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn install_npm_with(
|
||||
npm: &Path,
|
||||
p: &Package,
|
||||
entry: &Entry,
|
||||
dir: &Path,
|
||||
platform: Platform,
|
||||
public_fallback: bool,
|
||||
cancel: &CancellationToken,
|
||||
emit: Emit,
|
||||
) -> IdeResult<PathBuf> {
|
||||
@@ -704,6 +723,7 @@ fn install_npm_with(
|
||||
},
|
||||
&specs,
|
||||
false,
|
||||
public_fallback,
|
||||
cancel,
|
||||
emit,
|
||||
)?;
|
||||
@@ -1004,7 +1024,7 @@ mod tests {
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn npm_registry_agent_retries_against_public_npmjs_on_mirror_miss() {
|
||||
fn npm_registry_agent_retries_against_public_npmjs_on_mirror_miss_unless_registries_are_configured_only() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let install_dir = dir.path().join("acme/1.2.0");
|
||||
fs::create_dir_all(&install_dir).unwrap();
|
||||
@@ -1043,8 +1063,8 @@ esac
|
||||
]}"#;
|
||||
let entry = parse(index).unwrap().remove(0);
|
||||
let pkg = entry.distribution.npx.as_ref().unwrap();
|
||||
let exe =
|
||||
install_npm_with(&npm, pkg, &entry, &install_dir, MAC_ARM, &CancellationToken::new(), &|_| {}).unwrap();
|
||||
let exe = install_npm_with(&npm, pkg, &entry, &install_dir, MAC_ARM, true, &CancellationToken::new(), &|_| {})
|
||||
.unwrap();
|
||||
let calls: Vec<String> = fs::read_to_string(&log).unwrap().lines().map(str::to_owned).collect();
|
||||
assert_eq!(calls.len(), 2, "{calls:?}");
|
||||
assert!(!calls[0].contains("--registry="), "{calls:?}");
|
||||
@@ -1052,6 +1072,15 @@ esac
|
||||
assert!(calls[1].contains("--@acme:registry=https://registry.npmjs.org/"), "{calls:?}");
|
||||
assert_eq!(exe, install_dir.join("node_modules/.bin/agent-acp"));
|
||||
assert!(exe.is_file());
|
||||
// Only the configured registries: the miss is the error, and npmjs is never asked.
|
||||
let only = dir.path().join("acme-only/1.2.0");
|
||||
fs::create_dir_all(&only).unwrap();
|
||||
let err =
|
||||
install_npm_with(&npm, pkg, &entry, &only, MAC_ARM, false, &CancellationToken::new(), &|_| {}).unwrap_err();
|
||||
let calls: Vec<String> = fs::read_to_string(&log).unwrap().lines().map(str::to_owned).collect();
|
||||
assert_eq!(calls.len(), 3, "{calls:?}");
|
||||
assert!(!calls[2].contains("--registry="), "{calls:?}");
|
||||
assert!(err.message.contains("notarget"), "{err:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -432,6 +432,12 @@ pub struct ToolDownloadSettings {
|
||||
/// commas or whitespace and tried in order before the official host; empty keeps every
|
||||
/// download on its official host.
|
||||
pub github_mirror: String,
|
||||
/// Package registries only as configured (a company Nexus or Artifactory): npm and pnpm
|
||||
/// installs and update checks never retry against the public npm registry, and the IDE
|
||||
/// fetches nothing from public package registries itself (the JUnit Platform launcher from
|
||||
/// Maven Central, dependency version completion from Maven Central, npm, PyPI and
|
||||
/// crates.io). Off by default.
|
||||
pub configured_registries_only: bool,
|
||||
}
|
||||
|
||||
/// Absent profiles retain automatic discovery for existing projects.
|
||||
|
||||
@@ -701,6 +701,12 @@ impl Host {
|
||||
self.requests.begin(id)
|
||||
}
|
||||
|
||||
/// Settings › Tools › Download Mirrors › Use only the configured package registries: nothing
|
||||
/// is fetched from public package registries the user's tools weren't pointed at.
|
||||
pub fn configured_registries_only(&self) -> bool {
|
||||
self.global_settings.effective().tool_downloads.configured_registries_only
|
||||
}
|
||||
|
||||
pub fn begin_project_request(&self, window: &str, id: RequestId) -> CancellationToken {
|
||||
let token = self.begin_project_read_request(window, id);
|
||||
if self.project(window).is_ok_and(|p| !p.is_trusted()) {
|
||||
|
||||
@@ -185,6 +185,7 @@ pub async fn agent_registry_install(
|
||||
) -> IdeResult<()> {
|
||||
// The agent then shows in `agent_providers`.
|
||||
let paths = registry_paths(host);
|
||||
let public_npm_fallback = !host.configured_registries_only();
|
||||
let installing = Installing::begin(&id)?;
|
||||
let cancel = host.begin_request(request);
|
||||
// Also a background task of every project window, so it stays visible and can be
|
||||
@@ -211,7 +212,7 @@ pub async fn agent_registry_install(
|
||||
move || cancel.cancel()
|
||||
});
|
||||
report(None, None, false);
|
||||
let result = ide_agent::registry::install(&paths, &id, &cancel, &|e| {
|
||||
let result = ide_agent::registry::install(&paths, &id, public_npm_fallback, &cancel, &|e| {
|
||||
match &e {
|
||||
InstallEvent::Line { text } => report(Some(text.clone()), None, false),
|
||||
InstallEvent::Progress { fraction, message } => {
|
||||
|
||||
@@ -767,6 +767,7 @@ pub async fn maven_dependency_completion(
|
||||
use ide_build::maven::completion::{PomCompletionKind, local_options};
|
||||
let project = host.project(window)?;
|
||||
let cache = host.dependency_versions.clone();
|
||||
let central = !host.configured_registries_only();
|
||||
let cancel = host.begin_project_read_request(window, request);
|
||||
let result = host
|
||||
.blocking(move || {
|
||||
@@ -785,7 +786,10 @@ pub async fn maven_dependency_completion(
|
||||
// The local repository answers at once: Central gets `CENTRAL_WAIT`, then the
|
||||
// lookup finishes in the background and fills the cache for the next request.
|
||||
// Offline, behind a proxy or rate-limited, a failed fetch never fails completion.
|
||||
let remote = {
|
||||
// Only the configured package registries: the local repository alone.
|
||||
let remote = if !central {
|
||||
Vec::new()
|
||||
} else {
|
||||
let (cache, target) = (cache.clone(), target.clone());
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
std::thread::spawn(move || {
|
||||
|
||||
@@ -212,6 +212,8 @@ pub async fn dependency_versions(
|
||||
let project = host.project(window)?;
|
||||
let cache = host.dependency_versions.clone();
|
||||
let config_dir = host.config_dir.clone();
|
||||
// npm and crates.io are asked directly; `go` goes through the configured GOPROXY.
|
||||
let public_registries = !host.configured_registries_only();
|
||||
let cancel = host.begin_project_read_request(window, request);
|
||||
let result = host
|
||||
.blocking(move || {
|
||||
@@ -228,6 +230,9 @@ pub async fn dependency_versions(
|
||||
let versions = cache.versions(&source, &dependency.package, &cancel)?;
|
||||
return Ok(vec![DependencyVersions { dependency, versions, update: None }]);
|
||||
}
|
||||
if !public_registries {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
if snap.path.file_name().is_some_and(|name| name == "package.json") {
|
||||
let Some(dependency) = offset.and_then(|offset| npm::dependency_at(&snap.text, offset)) else {
|
||||
return Ok(Vec::new());
|
||||
@@ -310,6 +315,9 @@ pub async fn pypi_package(
|
||||
request: RequestId,
|
||||
) -> IdeResult<Option<pypi::PypiPackage>> {
|
||||
let url = pypi::project_url(name.trim()).ok_or_else(|| IdeError::invalid("not a package name"))?;
|
||||
if host.configured_registries_only() {
|
||||
return Ok(None);
|
||||
}
|
||||
let cancel = host.begin_project_read_request(window, request);
|
||||
let result = host
|
||||
.blocking(move || {
|
||||
@@ -334,6 +342,9 @@ pub async fn pypi_package(
|
||||
/// PyPI's name list, which the first search downloads and a search a day later refreshes.
|
||||
#[command(trust = outside_restricted)]
|
||||
pub async fn pypi_search(host: &Host, window: &str, query: String, request: RequestId) -> IdeResult<Vec<String>> {
|
||||
if host.configured_registries_only() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
let names = host.pypi_names.clone();
|
||||
let cancel = host.begin_project_read_request(window, request);
|
||||
let result = host
|
||||
|
||||
@@ -922,7 +922,7 @@ pub async fn java_build_workspace(
|
||||
/// The JVM of OpenIDEA's JUnit runner for the module at `module`, given its resolved test classpath:
|
||||
/// the classpath with the runner and `junit-platform-launcher` of the engine's version (unless the
|
||||
/// classpath has one, or has JUnit 4 alone; from the engine's repository, else downloaded once from
|
||||
/// Maven Central), and,
|
||||
/// Maven Central unless only the configured package registries are allowed), and,
|
||||
/// for a Maven module, what its Surefire configuration gives the forked test JVM.
|
||||
#[command(trust = trusted)]
|
||||
pub async fn java_junit_runner(
|
||||
@@ -935,6 +935,7 @@ pub async fn java_junit_runner(
|
||||
let project = host.project(window)?;
|
||||
let module = ide_core::project_roots::resolve(&project.root, &module);
|
||||
let data_dir = host.local_data_dir.clone();
|
||||
let registries_only = host.configured_registries_only();
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let scope = workspace::scope_for(&project, &module)?;
|
||||
let model = load_launch_model(&scope);
|
||||
@@ -948,7 +949,9 @@ pub async fn java_junit_runner(
|
||||
let launcher = match ide_sdk::java::junit_launcher(&class_paths) {
|
||||
ide_sdk::java::JunitLauncher::OnClasspath | ide_sdk::java::JunitLauncher::Junit4 => None,
|
||||
ide_sdk::java::JunitLauncher::Found(path) => Some(path),
|
||||
ide_sdk::java::JunitLauncher::Missing(version) => Some(download_junit_launcher(&data_dir, &version)?),
|
||||
ide_sdk::java::JunitLauncher::Missing(version) => {
|
||||
Some(download_junit_launcher(&data_dir, &version, registries_only)?)
|
||||
}
|
||||
ide_sdk::java::JunitLauncher::NoPlatform => {
|
||||
return Err(IdeError::unavailable(
|
||||
"Neither JUnit 5 (junit-platform-engine) nor JUnit 4 is on the test classpath. To run these tests \
|
||||
@@ -1017,7 +1020,9 @@ fn junit_launch(
|
||||
}
|
||||
}
|
||||
|
||||
fn download_junit_launcher(data_dir: &Path, version: &str) -> IdeResult<PathBuf> {
|
||||
/// The launcher jar downloaded once from Maven Central; with only the configured package
|
||||
/// registries allowed (Settings › Tools › Download Mirrors), only one downloaded before.
|
||||
fn download_junit_launcher(data_dir: &Path, version: &str, registries_only: bool) -> IdeResult<PathBuf> {
|
||||
if version.is_empty() || !version.chars().all(|c| c.is_ascii_alphanumeric() || "._-".contains(c)) {
|
||||
return Err(IdeError::invalid(format!("Unexpected JUnit Platform version '{version}'")));
|
||||
}
|
||||
@@ -1026,6 +1031,14 @@ fn download_junit_launcher(data_dir: &Path, version: &str) -> IdeResult<PathBuf>
|
||||
if dest.is_file() {
|
||||
return Ok(dest);
|
||||
}
|
||||
if registries_only {
|
||||
return Err(IdeError::unavailable(format!(
|
||||
"{name} is not on the test classpath, and Settings › Tools › Download Mirrors allows only the \
|
||||
configured package registries, so it is not downloaded from Maven Central. Add \
|
||||
org.junit.platform:junit-platform-launcher to the test dependencies, or set Settings › Build Tools › \
|
||||
Maven › Run tests using to Maven."
|
||||
)));
|
||||
}
|
||||
std::fs::create_dir_all(dest.parent().expect("has a parent"))?;
|
||||
let url = format!("https://repo1.maven.org/maven2/org/junit/platform/junit-platform-launcher/{version}/{name}");
|
||||
let partial = dest.with_extension("jar.part");
|
||||
|
||||
@@ -700,7 +700,10 @@ mod tests {
|
||||
// tampered package — and the official host must still be asked.
|
||||
let candidates = mirror::candidates(
|
||||
"https://github.com/acme/hello/releases/download/v1/acme.hello-1.0.0.oiplugin",
|
||||
&ide_core::settings::ToolDownloadSettings { github_mirror: "https://gh-proxy.com/".into() },
|
||||
&ide_core::settings::ToolDownloadSettings {
|
||||
github_mirror: "https://gh-proxy.com/".into(),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
let asked: std::cell::RefCell<Vec<usize>> = std::cell::RefCell::new(Vec::new());
|
||||
let picked = try_sources(&candidates, |index, candidate| {
|
||||
@@ -731,7 +734,10 @@ mod tests {
|
||||
let url = "https://github.com/acme/hello/releases/download/v1/acme.hello-1.0.0.oiplugin";
|
||||
let through = mirror::candidates(
|
||||
url,
|
||||
&ide_core::settings::ToolDownloadSettings { github_mirror: "https://gh-proxy.com/".into() },
|
||||
&ide_core::settings::ToolDownloadSettings {
|
||||
github_mirror: "https://gh-proxy.com/".into(),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
assert_eq!(through.len(), 2);
|
||||
assert_eq!(through[0].url, format!("https://gh-proxy.com/{url}"));
|
||||
@@ -741,7 +747,10 @@ mod tests {
|
||||
// A local index's own package is not on GitHub: no prefix may carry it.
|
||||
let local = mirror::candidates(
|
||||
"/srv/market/a.oiplugin",
|
||||
&ide_core::settings::ToolDownloadSettings { github_mirror: "https://gh-proxy.com/".into() },
|
||||
&ide_core::settings::ToolDownloadSettings {
|
||||
github_mirror: "https://gh-proxy.com/".into(),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
assert_eq!(local.len(), 1);
|
||||
assert_eq!(local[0].url, "/srv/market/a.oiplugin");
|
||||
|
||||
@@ -211,7 +211,7 @@ fn write_index(
|
||||
|
||||
/// The download sources setting with `mirror` as the GitHub proxy prefix (Tools › Download sources).
|
||||
fn download_sources(mirror: &str) -> ide_core::settings::ToolDownloadSettings {
|
||||
ide_core::settings::ToolDownloadSettings { github_mirror: mirror.into() }
|
||||
ide_core::settings::ToolDownloadSettings { github_mirror: mirror.into(), ..Default::default() }
|
||||
}
|
||||
|
||||
/// Security audit lead 5: an index entry's id and version name the download file,
|
||||
|
||||
@@ -1078,6 +1078,7 @@ impl Tools {
|
||||
},
|
||||
&specs,
|
||||
pnpm,
|
||||
!self.downloads.configured_registries_only,
|
||||
cancel,
|
||||
emit,
|
||||
)
|
||||
@@ -1463,6 +1464,12 @@ impl Tools {
|
||||
sources::openvsx_pick(&json, assets, self.platform)
|
||||
}
|
||||
ReleaseSource::MavenCentral { group, artifact } => {
|
||||
if self.downloads.configured_registries_only {
|
||||
return Err(IdeError::unavailable(format!(
|
||||
"{group}:{artifact} is downloaded from Maven Central, and Settings › Tools › Download Mirrors \
|
||||
allows only the configured package registries"
|
||||
)));
|
||||
}
|
||||
let xml = http.get_text(&sources::maven_metadata_url(group, artifact), cancel)?;
|
||||
sources::maven_pick(group, artifact, &xml)
|
||||
}
|
||||
@@ -1690,7 +1697,7 @@ impl Tools {
|
||||
// on a slow registry takes several seconds per package, more when run side by side.
|
||||
let out = match view(&[]) {
|
||||
Some((true, out)) => Some(out),
|
||||
Some((false, out)) if is_npm_registry_miss(&out) => {
|
||||
Some((false, out)) if !self.downloads.configured_registries_only && is_npm_registry_miss(&out) => {
|
||||
let extra = npm_public_registry_args([packages[0]], pnpm);
|
||||
view(&extra).and_then(|(ok, retry)| ok.then_some(retry))
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ mod tests {
|
||||
const ASSET: &str = "https://github.com/LuaLS/lua-language-server/releases/download/3.13.5/x.zip";
|
||||
|
||||
fn settings(mirror: &str) -> ToolDownloadSettings {
|
||||
ToolDownloadSettings { github_mirror: mirror.into() }
|
||||
ToolDownloadSettings { github_mirror: mirror.into(), ..Default::default() }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -110,13 +110,15 @@ pub fn run_streamed_picking(
|
||||
}
|
||||
|
||||
/// Runs an `npm` / `pnpm` command against the user's configured registry first (preserving
|
||||
/// corporate mirrors, proxies, and CAs), and retries once against [`PUBLIC_NPM_REGISTRY`] when
|
||||
/// the configured registry misses the package/version or rejects auth. Preserves the primary
|
||||
/// error if the public registry is unreachable.
|
||||
/// corporate mirrors, proxies, and CAs), and with `public_fallback` retries once against
|
||||
/// [`PUBLIC_NPM_REGISTRY`] when the configured registry misses the package/version or rejects
|
||||
/// auth. Preserves the primary error if the public registry is unreachable. Without
|
||||
/// `public_fallback` (Settings › Tools › Download Mirrors) the configured registry's error stands.
|
||||
pub fn run_npm_with_public_fallback(
|
||||
mut build: impl FnMut(&[String]) -> Command,
|
||||
specs: &[String],
|
||||
pnpm: bool,
|
||||
public_fallback: bool,
|
||||
cancel: &CancellationToken,
|
||||
emit: Emit,
|
||||
) -> IdeResult<String> {
|
||||
@@ -127,7 +129,7 @@ pub fn run_npm_with_public_fallback(
|
||||
return Ok(output);
|
||||
}
|
||||
let err = failed_command(&label, &output, &status);
|
||||
if cancel.is_cancelled() || !is_npm_registry_miss(&output) {
|
||||
if !public_fallback || cancel.is_cancelled() || !is_npm_registry_miss(&output) {
|
||||
return Err(err);
|
||||
}
|
||||
emit(InstallEvent::Line {
|
||||
|
||||
@@ -603,6 +603,34 @@ esac"#,
|
||||
assert!(!err.message.contains("ECONNRESET"), "{}", err.message);
|
||||
}
|
||||
|
||||
/// Settings › Tools › Download Mirrors › Use only the configured package registries: a registry
|
||||
/// that refuses a package (a firewall's 403) is the answer.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn configured_registries_only_never_reach_public_registries() {
|
||||
let env = Env::new();
|
||||
let log = env.root.parent().unwrap().join("npm-only.txt");
|
||||
env.script(&env.sys, "node", "exit 0");
|
||||
env.script(
|
||||
&env.sys,
|
||||
"npm",
|
||||
&format!(
|
||||
r#"echo "$@" >> '{log}'
|
||||
echo "npm error code E403" >&2
|
||||
echo "npm error 403 Forbidden - GET https://nexus.example/yaml-language-server - quarantined" >&2
|
||||
exit 1"#,
|
||||
log = log.display()
|
||||
),
|
||||
);
|
||||
let only = ToolDownloadSettings { configured_registries_only: true, ..Default::default() };
|
||||
let tools = env.tools().with_downloads(only);
|
||||
let err = tools.install("yaml-language-server", &langs(), &CancellationToken::new(), &|_| {}).unwrap_err();
|
||||
assert!(err.message.contains("quarantined"), "{}", err.message);
|
||||
let calls = fs::read_to_string(&log).unwrap();
|
||||
assert_eq!(calls.lines().count(), 1, "{calls}");
|
||||
assert!(!calls.contains("registry.npmjs.org"), "{calls}");
|
||||
}
|
||||
|
||||
/// Servers that load TypeScript as a library get one with its JS API: `@latest`
|
||||
/// is TypeScript 7 (native, no `ts.server`), which crashed vue-language-server (#25).
|
||||
/// Uninstalling one keeps the TypeScript another installed server still uses.
|
||||
@@ -1344,7 +1372,10 @@ esac"#,
|
||||
),
|
||||
);
|
||||
// The first mirror is down: the next one is tried before the official host.
|
||||
let downloads = ToolDownloadSettings { github_mirror: "https://down.mirror.test/, https://mirror.test/".into() };
|
||||
let downloads = ToolDownloadSettings {
|
||||
github_mirror: "https://down.mirror.test/, https://mirror.test/".into(),
|
||||
..Default::default()
|
||||
};
|
||||
let emit = |_: InstallEvent| {};
|
||||
env.tools()
|
||||
.with_downloads(downloads)
|
||||
|
||||
@@ -41,3 +41,19 @@ test("Copy Path/Reference keeps its preview and shortcut visible and can be resi
|
||||
await expect(popup).toBeHidden();
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe(path);
|
||||
});
|
||||
|
||||
test("Copy Path/Reference… in the Project view previews what each row copies", async ({ workbench: page, context }) => {
|
||||
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||||
await page.getByRole("treeitem", { name: "build.gradle.kts" }).click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "Copy Path/Reference…" }).click();
|
||||
|
||||
const popup = page.getByRole("dialog", { name: "Copy Path/Reference…" });
|
||||
const name = popup.getByRole("option", { name: /^File Name/ });
|
||||
await expect(name.locator('[title="build.gradle.kts"]')).toBeVisible();
|
||||
await expect(popup.getByRole("option", { name: /^Path From Content Root/ })).toBeVisible();
|
||||
await page.keyboard.type("file name");
|
||||
await expect(name).toHaveAttribute("aria-selected", "true");
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(popup).toBeHidden();
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe("build.gradle.kts");
|
||||
});
|
||||
@@ -2362,8 +2362,8 @@ argument, JSON text:
|
||||
|
||||
`host::start_run` still starts only the plugin's own configurations. To launch
|
||||
the user's configuration with the plugin's Java agent, bind the agent to an
|
||||
executor (_Java agents_): **Run '<name>' with <title>** and **Debug '<name>'
|
||||
with <title>** then appear in this menu for Application, Spring Boot and JAR
|
||||
executor (_Java agents_): **Run '`<name>`' with `<title>`** and **Debug '`<name>`'
|
||||
with `<title>`** then appear in this menu for Application, Spring Boot and JAR
|
||||
Application configurations, and go through the normal launch (build,
|
||||
classpath, JDK, debugger, Stop).
|
||||
|
||||
@@ -2891,11 +2891,11 @@ jdk = "jetbrains" # optional: only those VM options on
|
||||
shortened command line moves only the classpath into its argument file.
|
||||
- **Executors** (API 1.18). With `executor = "<title>"` (1–40 characters) the
|
||||
agent no longer loads into every launch. The plugin gets an executor beside
|
||||
Run and Debug instead, as IDEA's "Run with JRebel" or "Profile": **Run '<name>'
|
||||
with <title>** and **Debug '<name>' with <title>** in the run widget's ⋮ menu,
|
||||
Run and Debug instead, as IDEA's "Run with JRebel" or "Profile": **Run '`<name>`'
|
||||
with `<title>`** and **Debug '`<name>`' with `<title>`** in the run widget's ⋮ menu,
|
||||
the gutter's ▶ menu, the context menus' run entries and the Services context
|
||||
menu of those configurations, plus the actions **Run with <title>** and
|
||||
**Debug with <title>** (Find Action, Keymap). Only launches through them get
|
||||
menu of those configurations, plus the actions **Run with `<title>`** and
|
||||
**Debug with `<title>`** (Find Action, Keymap). Only launches through them get
|
||||
the agent and its `vmOptions`; the grant and jar pin are the same. Without
|
||||
`java.agent` the IDE says so instead of launching, and a configuration on a
|
||||
run target is refused the same way.
|
||||
@@ -3776,7 +3776,7 @@ no generic env-forwarding flags are added. Container env is forwarded only if
|
||||
the wrapper's own conventions allow it.
|
||||
|
||||
Registration never changes a selection. The first registration prompts the
|
||||
project's windows: “Use <name> for running PHP / Node / Composer in this project?”
|
||||
project's windows: “Use `<name>` for running PHP / Node / Composer in this project?”
|
||||
with **Use** / **Not now**. The first answer is remembered on the host per
|
||||
project + plugin + target id. Use sets the project's default run target and its
|
||||
PHP and Node run-target choices; Not now leaves settings alone. Interpreters
|
||||
|
||||
@@ -861,7 +861,7 @@ export const commands = {
|
||||
* The JVM of OpenIDEA's JUnit runner for the module at `module`, given its resolved test classpath:
|
||||
* the classpath with the runner and `junit-platform-launcher` of the engine's version (unless the
|
||||
* classpath has one, or has JUnit 4 alone; from the engine's repository, else downloaded once from
|
||||
* Maven Central), and,
|
||||
* Maven Central unless only the configured package registries are allowed), and,
|
||||
* for a Maven module, what its Surefire configuration gives the forked test JVM.
|
||||
*/
|
||||
javaJunitRunner: (module: string, classPaths: string[]) => typedError<JunitLaunch, IdeError>(__TAURI_INVOKE("java_junit_runner", { module, classPaths })),
|
||||
@@ -14164,6 +14164,14 @@ export type ToolDownloadSettings = {
|
||||
* download on its official host.
|
||||
*/
|
||||
githubMirror?: string,
|
||||
/**
|
||||
* Package registries only as configured (a company Nexus or Artifactory): npm and pnpm
|
||||
* installs and update checks never retry against the public npm registry, and the IDE
|
||||
* fetches nothing from public package registries itself (the JUnit Platform launcher from
|
||||
* Maven Central, dependency version completion from Maven Central, npm, PyPI and
|
||||
* crates.io). Off by default.
|
||||
*/
|
||||
configuredRegistriesOnly?: boolean,
|
||||
};
|
||||
|
||||
/** UI-facing state of one tool. */
|
||||
|
||||
@@ -34,7 +34,7 @@ import type { LanguageDescription } from "@codemirror/language";
|
||||
import type { HunkKind } from "@/bindings";
|
||||
import type { LineEnding } from "@/platform/ipc";
|
||||
import { create } from "zustand";
|
||||
import { maybeEditorService, type EditorInput } from "@/workbench/contributions";
|
||||
import { maybeEditorService, type EditorInput, type MenuGroupContext } from "@/workbench/contributions";
|
||||
import { isSameOrInside } from "@/platform/paths";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { rootOfPath } from "@/platform/projectRoots";
|
||||
@@ -1017,6 +1017,37 @@ export function _provideCodePreview(provider: typeof codePreviewProvider) {
|
||||
codePreviewProvider = provider;
|
||||
}
|
||||
|
||||
/** A row of the Copy Path/Reference… chooser. */
|
||||
export interface CopyPathRow {
|
||||
/** The action whose shortcut the row shows. */
|
||||
id: string;
|
||||
/** English label, translated by the chooser. */
|
||||
label: string;
|
||||
/** The copied text; a row without one is left out. */
|
||||
preview: string | null;
|
||||
run: () => void;
|
||||
}
|
||||
|
||||
type CopyPathChooser = (
|
||||
anchor: { x: number; y: number } | "center",
|
||||
rows: readonly CopyPathRow[],
|
||||
ctx: MenuGroupContext,
|
||||
) => void;
|
||||
let copyPathChooser: CopyPathChooser | null = null;
|
||||
|
||||
/**
|
||||
* The editor's Copy Path/Reference… chooser for files outside an editor (the Project view's
|
||||
* selection): `rows`, then the rows contributed to the `copyPath` menu for `ctx`, with previews.
|
||||
*/
|
||||
export function openCopyPathChooser(...args: Parameters<CopyPathChooser>): void {
|
||||
copyPathChooser?.(...args);
|
||||
}
|
||||
|
||||
/** @internal editor/core only. */
|
||||
export function _provideCopyPathChooser(open: CopyPathChooser) {
|
||||
copyPathChooser = open;
|
||||
}
|
||||
|
||||
let workspaceHistory: ((id: number, redo: boolean) => Promise<void>) | null = null;
|
||||
|
||||
/** Undo/redo a refactoring through the same history used by editor commands. */
|
||||
|
||||
@@ -70,7 +70,8 @@ import { customRegions } from "./cm/regions";
|
||||
import { toggleRenderedViewAtCaret } from "./cm/renderedDocs";
|
||||
import { enclosingHeaders } from "./cm/stickyScroll";
|
||||
import { moveElementLeft, moveElementRight } from "./cm/moveElement";
|
||||
import { caretAnchor, openPopup, updatePopup, useLspPopup, type LspPopup } from "@/editor/lsp/popupStore";
|
||||
import { caretAnchor, openPopup, updatePopup, useLspPopup } from "@/editor/lsp/popupStore";
|
||||
import { copyPathPopup } from "./copyPathChooser";
|
||||
import {
|
||||
cursorCodeBlockEnd,
|
||||
cursorCodeBlockStart,
|
||||
@@ -111,7 +112,7 @@ import {
|
||||
import { useProject } from "@/platform/project";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { editorPrefs } from "@/platform/editorSettings";
|
||||
import { menuGroupItems, notifications } from "@/workbench/contributions";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import { togglePinSelectedContent } from "@/workbench/toolwindows/content";
|
||||
import { useToolWindowLayout } from "@/workbench/toolwindows/store";
|
||||
import { toggleReadOnly } from "./fileAttributes";
|
||||
@@ -649,22 +650,6 @@ function copyPathReferencePopup(view: EditorView, slot: EditorSlot | null) {
|
||||
// The popup's items resolve against the open document; a notebook cell has none.
|
||||
if (!slot) return;
|
||||
const path = slot.model.path;
|
||||
const contributed = menuGroupItems("copyPath", {
|
||||
paths: [path],
|
||||
...selectedLineContext(view.state),
|
||||
}).flatMap((item) =>
|
||||
(item.kind ?? "item") === "item" && "run" in item && item.id && item.run && item.preview
|
||||
? [
|
||||
{
|
||||
id: item.id,
|
||||
label: item.verbatim ? item.label : tx(item.label),
|
||||
preview: item.preview,
|
||||
shortcut: shortcutLabel(item.id),
|
||||
run: item.run,
|
||||
},
|
||||
]
|
||||
: [],
|
||||
);
|
||||
const flavours = [
|
||||
{ id: "project.copyAbsolutePath", label: "Absolute Path", value: pathToCopy("absolute", path) },
|
||||
{
|
||||
@@ -681,26 +666,20 @@ function copyPathReferencePopup(view: EditorView, slot: EditorSlot | null) {
|
||||
value: pathWithLines(view.state, path),
|
||||
},
|
||||
];
|
||||
const popup: Extract<LspPopup, { kind: "list" }> = {
|
||||
kind: "list",
|
||||
title: tx("Copy Path/Reference…"),
|
||||
layout: "copyPath",
|
||||
anchor: caretAnchor(view, view.state.selection.main.head),
|
||||
items: [
|
||||
...flavours
|
||||
.filter((f) => f.value !== null)
|
||||
.map((f) => ({
|
||||
id: f.id,
|
||||
label: tx(f.label),
|
||||
preview: f.value!,
|
||||
shortcut: shortcutLabel(f.id),
|
||||
run: () => {
|
||||
const lineNumbered =
|
||||
f.id === "editor.copyPathWithLineNumber" || f.id === "editor.copyAbsolutePathWithLineNumber";
|
||||
void executeAction(f.id, lineNumbered ? f.value : path);
|
||||
},
|
||||
})),
|
||||
...contributed,
|
||||
const popup = copyPathPopup(
|
||||
caretAnchor(view, view.state.selection.main.head),
|
||||
flavours.map((f) => ({
|
||||
id: f.id,
|
||||
label: f.label,
|
||||
preview: f.value,
|
||||
run: () => {
|
||||
const lineNumbered =
|
||||
f.id === "editor.copyPathWithLineNumber" || f.id === "editor.copyAbsolutePathWithLineNumber";
|
||||
void executeAction(f.id, lineNumbered ? f.value : path);
|
||||
},
|
||||
})),
|
||||
{ paths: [path], ...selectedLineContext(view.state) },
|
||||
[
|
||||
{
|
||||
id: "editor.copyReference",
|
||||
label: tx("Reference"),
|
||||
@@ -710,7 +689,7 @@ function copyPathReferencePopup(view: EditorView, slot: EditorSlot | null) {
|
||||
run: () => {},
|
||||
},
|
||||
],
|
||||
};
|
||||
);
|
||||
openPopup(popup);
|
||||
void resolveReference(view, slot)
|
||||
.then((reference) => {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/** The Copy Path/Reference… chooser: each way to copy, with a preview of the text it copies. */
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { menuGroupItems, type MenuGroupContext } from "@/workbench/contributions";
|
||||
import { openPopup, type ListPopupItem, type LspPopup, type PopupPoint } from "@/editor/lsp/popupStore";
|
||||
import type { CopyPathRow } from "@/editor/api";
|
||||
|
||||
/** The chooser's popup: `rows`, then the rows contributed to the `copyPath` menu for `ctx`. */
|
||||
export function copyPathPopup(
|
||||
anchor: PopupPoint | "center",
|
||||
rows: readonly CopyPathRow[],
|
||||
ctx: MenuGroupContext,
|
||||
trailing: readonly ListPopupItem[] = [],
|
||||
): Extract<LspPopup, { kind: "list" }> {
|
||||
const contributed = menuGroupItems("copyPath", ctx).flatMap((item) =>
|
||||
(item.kind ?? "item") === "item" && "run" in item && item.id && item.run && item.preview
|
||||
? [
|
||||
{
|
||||
id: item.id,
|
||||
label: item.verbatim ? item.label : tx(item.label),
|
||||
preview: item.preview,
|
||||
shortcut: shortcutLabel(item.id),
|
||||
run: item.run,
|
||||
},
|
||||
]
|
||||
: [],
|
||||
);
|
||||
return {
|
||||
kind: "list",
|
||||
title: tx("Copy Path/Reference…"),
|
||||
layout: "copyPath",
|
||||
anchor,
|
||||
items: [
|
||||
...rows.flatMap((row) =>
|
||||
row.preview === null
|
||||
? []
|
||||
: [{ id: row.id, label: tx(row.label), preview: row.preview, shortcut: shortcutLabel(row.id), run: row.run }],
|
||||
),
|
||||
...contributed,
|
||||
...trailing,
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
/** Opens the chooser for files outside an editor (`openCopyPathChooser` of `@/editor/api`). */
|
||||
export function openCopyPathChooser(
|
||||
anchor: PopupPoint | "center",
|
||||
rows: readonly CopyPathRow[],
|
||||
ctx: MenuGroupContext,
|
||||
): void {
|
||||
openPopup(copyPathPopup(anchor, rows, ctx));
|
||||
}
|
||||
@@ -10,7 +10,8 @@ import {
|
||||
registerOverlay,
|
||||
registerStatusItem,
|
||||
} from "@/workbench/contributions";
|
||||
import { _provideCodePreview, _provideDocumentAttacher, editorsFor } from "@/editor/api";
|
||||
import { _provideCodePreview, _provideCopyPathChooser, _provideDocumentAttacher, editorsFor } from "@/editor/api";
|
||||
import { openCopyPathChooser } from "./copyPathChooser";
|
||||
import { isUntitledUri } from "@/platform/virtualDocs";
|
||||
import { formatDocument } from "@/editor/lsp/format";
|
||||
import { chooserTitle, locationItems, pinToFind } from "@/editor/lsp/navigation";
|
||||
@@ -82,6 +83,7 @@ export function activate(): void | (() => void) {
|
||||
},
|
||||
});
|
||||
_provideDocumentAttacher((path, options) => attachDocument(ctrl.manager, path, options));
|
||||
_provideCopyPathChooser(openCopyPathChooser);
|
||||
_provideCodePreview((path, editable) =>
|
||||
previewExtensions(path, ctrl.manager.settings()?.editor, ctrl.manager.backend, editable),
|
||||
);
|
||||
|
||||
@@ -70,6 +70,70 @@ export function ExtractorSelect({ value, onChange }: { value: ExportFormat; onCh
|
||||
export const copyFormatOf = (extractor: ExportFormat): CopyFormat =>
|
||||
extractor === "csv" ? "csv" : extractor === "onerow" ? "onerow" : "tsv";
|
||||
|
||||
/** The toolbar's extractor; `table` is the whole table to export (`null`: nothing, already reported). */
|
||||
export interface ExtractorMenu {
|
||||
value: ExportFormat;
|
||||
onChange: (f: ExportFormat) => void;
|
||||
table: () => ExportData | null | Promise<ExportData | null>;
|
||||
}
|
||||
|
||||
const PANEL_ENTRIES: ReadonlyArray<{ panel: DataPanel; label: string }> = [
|
||||
{ panel: "record", label: "Show Record View" },
|
||||
{ panel: "value", label: "Open in Value Editor" },
|
||||
{ panel: "aggregates", label: "Show Aggregate View" },
|
||||
];
|
||||
|
||||
/**
|
||||
* The view's entries of the grid's context menu (DataGrip's): the side panels, checked while
|
||||
* shown, then the toolbar's extractor and Export Table to Clipboard when the view has them.
|
||||
*/
|
||||
export function viewMenu(
|
||||
panel: DataPanel | null,
|
||||
onPanelChange: (panel: DataPanel | null) => void,
|
||||
extractor?: ExtractorMenu,
|
||||
): MenuItem[] {
|
||||
const items: MenuItem[] = PANEL_ENTRIES.map(({ panel: p, label }) => ({
|
||||
label,
|
||||
checked: panel === p,
|
||||
run: () => onPanelChange(panel === p ? null : p),
|
||||
}));
|
||||
if (!extractor) return items;
|
||||
return [
|
||||
...items,
|
||||
{ kind: "separator" },
|
||||
{
|
||||
label: "Data Extractor",
|
||||
submenu: EXPORT_FORMATS.map((f) => ({
|
||||
label: f.label,
|
||||
checked: f.id === extractor.value,
|
||||
run: () => extractor.onChange(f.id),
|
||||
})),
|
||||
},
|
||||
{
|
||||
label: "Export Table to Clipboard",
|
||||
icon: "copy",
|
||||
run: () =>
|
||||
void Promise.resolve(extractor.table()).then(
|
||||
(data) => data && writeClipboardText(exportData(extractor.value, data)),
|
||||
),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** Copy as › SQL INSERT / UPDATE / DELETE of the whole selected rows, in the selected order. */
|
||||
function sqlCopies(rows: readonly number[], extractor: ExtractorMenu): MenuItem[] {
|
||||
const copy = (format: ExportFormat) => () =>
|
||||
void Promise.resolve(extractor.table()).then((data) => {
|
||||
const picked = data && rows.flatMap((r) => (data.rows[r] ? [data.rows[r]] : []));
|
||||
if (picked?.length) void writeClipboardText(exportData(format, { ...data!, rows: picked }));
|
||||
});
|
||||
return [
|
||||
{ label: "SQL INSERT", run: copy("sql") },
|
||||
{ label: "SQL UPDATE", run: copy("sqlUpdates") },
|
||||
{ label: "SQL DELETE", run: copy("sqlDeletes") },
|
||||
];
|
||||
}
|
||||
|
||||
/** The Record / Value / Aggregates panel's toggle (IDEA's "Show Value Editor"). */
|
||||
export function PanelToggle({ panel, onChange }: { panel: DataPanel | null; onChange: (p: DataPanel | null) => void }) {
|
||||
return (
|
||||
@@ -117,6 +181,8 @@ export interface DataViewProps extends Pick<
|
||||
onPanelChange: (panel: DataPanel | null) => void;
|
||||
/** Plain ⌘C's copy format (the toolbar's extractor; TSV by default). */
|
||||
copyFormat?: CopyFormat;
|
||||
/** The toolbar's extractor, also offered in the grid's context menu with the whole table to copy. */
|
||||
extractor?: ExtractorMenu;
|
||||
/** The search bar is shown (the toolbar's search button, ⌘F in the grid). */
|
||||
searchOpen?: boolean;
|
||||
onSearchOpenChange?: (open: boolean) => void;
|
||||
@@ -248,7 +314,12 @@ export function DataView(props: DataViewProps) {
|
||||
driver={props.driver}
|
||||
sort={sort}
|
||||
onSort={onSort}
|
||||
rowMenu={props.rowMenu && ((rows) => props.rowMenu!(rows.map(at)))}
|
||||
copyAs={props.extractor && ((rows) => sqlCopies(rows.map(at), props.extractor!))}
|
||||
rowMenu={(rows) => {
|
||||
const own = props.rowMenu?.(rows.map(at)) ?? [];
|
||||
const view = viewMenu(panel, onPanelChange, props.extractor);
|
||||
return own.length ? [...own, { kind: "separator" }, ...view] : view;
|
||||
}}
|
||||
rowNumber={(r) => (props.firstRowNumber ?? 1) + at(r)}
|
||||
copyFormat={props.copyFormat}
|
||||
onSelectionChange={setRange}
|
||||
|
||||
@@ -954,6 +954,23 @@
|
||||
padding: 2px 4px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.modifyFilter {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.modifyGroup {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
height: 22px;
|
||||
padding: 0 6px;
|
||||
color: var(--fg-muted);
|
||||
cursor: default;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.modifyGroup:hover {
|
||||
color: var(--fg);
|
||||
}
|
||||
.modifyList {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
|
||||
@@ -10,6 +10,7 @@ import { notifications } from "@/workbench/contributions";
|
||||
import {
|
||||
DEFAULT_EXPORT_OPTIONS,
|
||||
EXPORT_FORMATS,
|
||||
SQL_FORMATS,
|
||||
exportData,
|
||||
type ExportData,
|
||||
type ExportFormat,
|
||||
@@ -169,7 +170,7 @@ export function ExportDialog({
|
||||
<CodePreview
|
||||
className={styles.exportPreviewText}
|
||||
aria-label="Export preview"
|
||||
sql={format === "sql"}
|
||||
sql={SQL_FORMATS.has(format)}
|
||||
text={preview + (data.rows.length > PREVIEW_ROWS ? `\n… ${data.rows.length - PREVIEW_ROWS} more rows` : "")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1013,3 +1013,106 @@ describe("local filter (#6022)", () => {
|
||||
expect(cities()).toEqual(["Shanghai", "Beijing", "Shenzhen", "Hangzhou"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("the data view's context menu (DataGrip)", () => {
|
||||
const columns = [
|
||||
{ name: "id", type: "int" },
|
||||
{ name: "city", type: "text" },
|
||||
];
|
||||
const data = [
|
||||
["1", "Shanghai"],
|
||||
["2", "Beijing"],
|
||||
];
|
||||
const value = (r: number, c: number) => data[r]?.[c] ?? null;
|
||||
|
||||
it("toggles the side panels, switches the extractor and exports the whole table to the clipboard", async () => {
|
||||
const writeText = vi.fn(() => Promise.resolve());
|
||||
Object.defineProperty(navigator, "clipboard", { configurable: true, value: { writeText } });
|
||||
const onPanelChange = vi.fn();
|
||||
const onExtractor = vi.fn();
|
||||
const table = () => ({ columns, rows: data, table: "cities", driver: "postgres" as const });
|
||||
const { rerender } = render(
|
||||
<>
|
||||
<DataView
|
||||
columns={columns}
|
||||
rowCount={2}
|
||||
value={value}
|
||||
panel="value"
|
||||
onPanelChange={onPanelChange}
|
||||
extractor={{ value: "csv", onChange: onExtractor, table }}
|
||||
/>
|
||||
<ContextMenuHost />
|
||||
</>,
|
||||
);
|
||||
const open = () => {
|
||||
fireEvent.mouseDown(screen.getAllByRole("gridcell")[0]!, { button: 0 });
|
||||
fireEvent.contextMenu(screen.getByRole("grid"), { clientX: 5, clientY: 5 });
|
||||
};
|
||||
open();
|
||||
expect(screen.getByRole("menuitemcheckbox", { name: /Open in Value Editor/ })).toHaveAttribute(
|
||||
"aria-checked",
|
||||
"true",
|
||||
);
|
||||
fireEvent.click(screen.getByRole("menuitemcheckbox", { name: /Show Record View/ }));
|
||||
expect(onPanelChange).toHaveBeenLastCalledWith("record");
|
||||
open();
|
||||
// The shown panel's entry hides it.
|
||||
fireEvent.click(screen.getByRole("menuitemcheckbox", { name: /Open in Value Editor/ }));
|
||||
expect(onPanelChange).toHaveBeenLastCalledWith(null);
|
||||
|
||||
open();
|
||||
await act(async () => void fireEvent.click(screen.getByRole("menuitem", { name: /Export Table to Clipboard/ })));
|
||||
expect(writeText).toHaveBeenCalledWith(exportData("csv", table()));
|
||||
|
||||
open();
|
||||
fireEvent.click(screen.getByRole("menuitem", { name: /Data Extractor/ }));
|
||||
expect(screen.getByRole("menuitemcheckbox", { name: /^CSV/ })).toHaveAttribute("aria-checked", "true");
|
||||
fireEvent.click(screen.getByRole("menuitemcheckbox", { name: /SQL Inserts/ }));
|
||||
expect(onExtractor).toHaveBeenCalledWith("sql");
|
||||
|
||||
// Without an extractor (a view with no toolbar one) only the panels are offered.
|
||||
rerender(
|
||||
<>
|
||||
<DataView columns={columns} rowCount={2} value={value} panel={null} onPanelChange={onPanelChange} />
|
||||
<ContextMenuHost />
|
||||
</>,
|
||||
);
|
||||
open();
|
||||
expect(screen.queryByRole("menuitem", { name: /Export Table to Clipboard/ })).toBeNull();
|
||||
expect(screen.getByRole("menuitemcheckbox", { name: /Show Aggregate View/ })).toHaveAttribute(
|
||||
"aria-checked",
|
||||
"false",
|
||||
);
|
||||
});
|
||||
|
||||
it("copies the selected whole rows as SQL INSERT / UPDATE / DELETE (#6143)", async () => {
|
||||
const writeText = vi.fn((_text: string) => Promise.resolve());
|
||||
Object.defineProperty(navigator, "clipboard", { configurable: true, value: { writeText } });
|
||||
const keyed = [{ ...columns[0]!, primaryKey: true }, columns[1]!];
|
||||
const table = () => ({ columns: keyed, rows: data, table: "cities", driver: "postgres" as const });
|
||||
render(
|
||||
<>
|
||||
<DataView
|
||||
columns={keyed}
|
||||
rowCount={2}
|
||||
value={value}
|
||||
panel={null}
|
||||
onPanelChange={() => {}}
|
||||
extractor={{ value: "csv", onChange: () => {}, table }}
|
||||
/>
|
||||
<ContextMenuHost />
|
||||
</>,
|
||||
);
|
||||
// Only the second row's city cell: the statements still cover its whole row.
|
||||
fireEvent.mouseDown(screen.getAllByRole("gridcell")[3]!, { button: 0 });
|
||||
const copyAs = async (entry: string) => {
|
||||
fireEvent.contextMenu(screen.getByRole("grid"), { clientX: 5, clientY: 5 });
|
||||
fireEvent.click(screen.getByRole("menuitem", { name: /^Copy as/ }));
|
||||
await act(async () => void fireEvent.click(screen.getByRole("menuitem", { name: new RegExp(`^${entry}`) })));
|
||||
return writeText.mock.lastCall?.[0];
|
||||
};
|
||||
expect(await copyAs("SQL INSERT")).toBe("INSERT INTO cities (id, city) VALUES (2, 'Beijing');");
|
||||
expect(await copyAs("SQL UPDATE")).toBe("UPDATE cities SET city = 'Beijing' WHERE id = 2;");
|
||||
expect(await copyAs("SQL DELETE")).toBe("DELETE FROM cities WHERE id = 2;");
|
||||
});
|
||||
});
|
||||
@@ -86,6 +86,8 @@ export interface GridProps {
|
||||
onSort?: (column: string, add: boolean) => void;
|
||||
/** Extra context menu items for the selected rows. */
|
||||
rowMenu?: (rows: number[]) => MenuItem[];
|
||||
/** More Copy as entries for the selected rows (SQL statements of the whole rows). */
|
||||
copyAs?: (rows: number[]) => MenuItem[];
|
||||
/** Row number shown for row 0 (paging). */
|
||||
firstRowNumber?: number;
|
||||
/** Row number shown for a row (local sort / filter reorder them); `firstRowNumber + row` otherwise. */
|
||||
@@ -629,6 +631,10 @@ export function Grid(props: GridProps) {
|
||||
{ kind: "action", action: "db.copyAsTsv", label: "TSV", arg: cellActions.current },
|
||||
{ kind: "action", action: "db.copyAsCsv", label: "CSV", arg: cellActions.current },
|
||||
{ kind: "action", action: "db.copyAsOneRow", label: "One-Row", arg: cellActions.current },
|
||||
...(() => {
|
||||
const more = props.copyAs?.(selectedRows()) ?? [];
|
||||
return more.length ? [{ kind: "separator" } as const, ...more] : [];
|
||||
})(),
|
||||
],
|
||||
},
|
||||
{ kind: "action", action: "db.copyWithHeader", arg: cellActions.current },
|
||||
|
||||
@@ -4,7 +4,14 @@
|
||||
* Preview of the SQL they run), Remove Data Source, Data Source from URL, and the Quick Documentation popup.
|
||||
*/
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { call, commands, type DbColumnInfo, type DbDriver, type DbTableGrant } from "@/platform/ipc";
|
||||
import {
|
||||
call,
|
||||
commands,
|
||||
type DbColumnInfo,
|
||||
type DbDriver,
|
||||
type DbTableDetails,
|
||||
type DbTableGrant,
|
||||
} from "@/platform/ipc";
|
||||
import { highlightInto } from "@/editor/lsp/markdown";
|
||||
import {
|
||||
Button,
|
||||
@@ -14,6 +21,7 @@ import {
|
||||
Input,
|
||||
Popup,
|
||||
Icon,
|
||||
SearchField,
|
||||
Select,
|
||||
T,
|
||||
Tabs,
|
||||
@@ -551,7 +559,8 @@ function ModifyTableDialog(props: ModifyProps) {
|
||||
if (table && !details) void loadDetails(id, schema, table);
|
||||
}, [details, id, schema, table]);
|
||||
if (!table) return <ModifyTableForm {...props} initial={null} />;
|
||||
if (details?.status === "ok") return <ModifyTableForm {...props} initial={details.value.columns} />;
|
||||
if (details?.status === "ok")
|
||||
return <ModifyTableForm {...props} initial={details.value.columns} details={details.value} />;
|
||||
return (
|
||||
<Dialog
|
||||
open
|
||||
@@ -565,6 +574,64 @@ function ModifyTableDialog(props: ModifyProps) {
|
||||
);
|
||||
}
|
||||
|
||||
/** A read-only row of the Modify Table list (a key, foreign key, index or trigger). */
|
||||
interface ObjectRow {
|
||||
key: string;
|
||||
name: string;
|
||||
detail: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The groups after Columns, as DataGrip lists them: the primary key of the columns as edited,
|
||||
* then the foreign keys, indexes and triggers the table has (shown, not edited here).
|
||||
*/
|
||||
function objectGroups(
|
||||
columns: readonly ColumnDraft[],
|
||||
details: DbTableDetails | null | undefined,
|
||||
): Array<{ id: string; label: string; icon: string; rows: ObjectRow[] }> {
|
||||
const pk = columns.filter((c) => c.primaryKey && !c.dropped).map((c) => c.name);
|
||||
const list = (names: readonly string[]) => `(${names.join(", ")})`;
|
||||
return [
|
||||
{
|
||||
id: "keys",
|
||||
label: "Keys",
|
||||
icon: "db-key",
|
||||
rows: pk.length ? [{ key: "primary", name: "PRIMARY KEY", detail: list(pk) }] : [],
|
||||
},
|
||||
{
|
||||
id: "foreignKeys",
|
||||
label: "Foreign Keys",
|
||||
icon: "db-foreign-key",
|
||||
rows: (details?.foreignKeys ?? []).map((fk, i) => ({
|
||||
key: `fk-${i}`,
|
||||
name: list(fk.columns),
|
||||
detail: `→ ${fk.refTable} ${list(fk.refColumns)}`,
|
||||
})),
|
||||
},
|
||||
{
|
||||
id: "indexes",
|
||||
label: "Indexes",
|
||||
icon: "db-index",
|
||||
rows: (details?.indexes ?? []).map((ix) => ({
|
||||
key: `ix-${ix.name}`,
|
||||
name: ix.name,
|
||||
// `UNIQUE` is SQL, not UI text.
|
||||
detail: ix.unique ? ["UNIQUE", list(ix.columns)].join(" ") : list(ix.columns),
|
||||
})),
|
||||
},
|
||||
{
|
||||
id: "triggers",
|
||||
label: "Triggers",
|
||||
icon: "db-trigger",
|
||||
rows: (details?.triggers ?? []).map((t) => ({
|
||||
key: `tr-${t.name}`,
|
||||
name: t.name,
|
||||
detail: `${t.timing} ${t.events}`.toUpperCase(),
|
||||
})),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function ModifyTableForm({
|
||||
id,
|
||||
schema,
|
||||
@@ -572,7 +639,8 @@ function ModifyTableForm({
|
||||
focusColumn,
|
||||
addColumn,
|
||||
initial,
|
||||
}: ModifyProps & { initial: DbColumnInfo[] | null }) {
|
||||
details,
|
||||
}: ModifyProps & { initial: DbColumnInfo[] | null; details?: DbTableDetails }) {
|
||||
const driver = driverOf(id);
|
||||
const [name, setName] = useState(table ?? "table_name");
|
||||
const [columns, setColumns] = useState<ColumnDraft[]>(() => {
|
||||
@@ -611,6 +679,28 @@ function ModifyTableForm({
|
||||
}
|
||||
};
|
||||
const locked = !!current && !canAlterColumn(driver, current);
|
||||
// The list's filter (names and types) and its collapsed groups.
|
||||
const [filter, setFilter] = useState("");
|
||||
const [collapsed, setCollapsed] = useState<ReadonlySet<string>>(new Set());
|
||||
const query = filter.trim().toLowerCase();
|
||||
const matches = (...texts: string[]) => !query || texts.some((t) => t.toLowerCase().includes(query));
|
||||
const shownColumns = columns.filter((c) => matches(c.name, c.dataType));
|
||||
const groups = objectGroups(columns, details)
|
||||
.map((g) => ({ ...g, rows: g.rows.filter((r) => matches(r.name, r.detail)) }))
|
||||
.filter((g) => g.rows.length);
|
||||
const toggleGroup = (group: string) =>
|
||||
setCollapsed((c) => {
|
||||
const next = new Set(c);
|
||||
if (!next.delete(group)) next.add(group);
|
||||
return next;
|
||||
});
|
||||
const groupHeader = (group: string, label: string, count: number) => (
|
||||
<div className={styles.modifyGroup} onMouseDown={() => toggleGroup(group)}>
|
||||
<Icon name={collapsed.has(group) ? "chevron-right" : "chevron-down"} size={12} />
|
||||
<span>{tx(label)}</span>
|
||||
<span className={styles.treeType}>{count}</span>
|
||||
</div>
|
||||
);
|
||||
const showGrants = !!table && grantsSupported(driver);
|
||||
const [tab, setTab] = useState<"columns" | "grants">("columns");
|
||||
const title = table ? `Modify Table ${table}` : "Create Table";
|
||||
@@ -672,21 +762,52 @@ function ModifyTableForm({
|
||||
disabled={!current}
|
||||
onClick={remove}
|
||||
/>
|
||||
<SearchField
|
||||
variant="bare"
|
||||
className={styles.modifyFilter}
|
||||
value={filter}
|
||||
onChange={setFilter}
|
||||
placeholder="Filter by name or type"
|
||||
aria-label="Filter columns"
|
||||
/>
|
||||
</div>
|
||||
<div role="listbox" aria-label={tx("Columns")} className={styles.modifyList}>
|
||||
{columns.map((c) => (
|
||||
<div
|
||||
key={c.key}
|
||||
role="option"
|
||||
aria-selected={c.key === selected}
|
||||
tabIndex={-1}
|
||||
className={styles.modifyItem}
|
||||
data-dropped={c.dropped || undefined}
|
||||
onMouseDown={() => setSelected(c.key)}
|
||||
>
|
||||
<Icon name={c.primaryKey ? "db-column-key" : "db-column"} size={16} />
|
||||
<span className={styles.nodeLabel}>{c.name || "<unnamed>"}</span>
|
||||
<span className={styles.treeType}>{c.dataType}</span>
|
||||
<div role="group" aria-label={tx("Columns")}>
|
||||
{groupHeader("columns", "Columns", shownColumns.length)}
|
||||
{!collapsed.has("columns") &&
|
||||
shownColumns.map((c) => (
|
||||
<div
|
||||
key={c.key}
|
||||
role="option"
|
||||
aria-selected={c.key === selected}
|
||||
tabIndex={-1}
|
||||
className={styles.modifyItem}
|
||||
data-dropped={c.dropped || undefined}
|
||||
onMouseDown={() => setSelected(c.key)}
|
||||
>
|
||||
<Icon name={c.primaryKey ? "db-column-key" : "db-column"} size={16} />
|
||||
<span className={styles.nodeLabel}>{c.name || "<unnamed>"}</span>
|
||||
<span className={styles.treeType}>{c.dataType}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{groups.map((g) => (
|
||||
<div key={g.id} role="group" aria-label={tx(g.label)}>
|
||||
{groupHeader(g.id, g.label, g.rows.length)}
|
||||
{!collapsed.has(g.id) &&
|
||||
g.rows.map((r) => (
|
||||
<div
|
||||
key={r.key}
|
||||
role="option"
|
||||
aria-selected={false}
|
||||
aria-disabled
|
||||
className={styles.modifyItem}
|
||||
>
|
||||
<Icon name={g.icon} size={16} />
|
||||
<span className={styles.nodeLabel}>{r.name}</span>
|
||||
<span className={styles.treeType}>{r.detail}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -453,9 +453,9 @@ export function Result({ tab, onClose }: { tab: ResultTab; onClose?: () => void
|
||||
}
|
||||
};
|
||||
|
||||
const showExport = async (at: { x: number; y: number }) => {
|
||||
if (!r) return;
|
||||
// What is exported or copied is the whole values, not the starts the page carries.
|
||||
/** The result to export or copy: the whole values, not the starts the page carries. */
|
||||
const exportSource = async (): Promise<ExportData | null> => {
|
||||
if (!r) return null;
|
||||
if (hasCutCells(r)) {
|
||||
try {
|
||||
await loadPage(tab);
|
||||
@@ -466,17 +466,19 @@ export function Result({ tab, onClose }: { tab: ResultTab; onClose?: () => void
|
||||
body: e instanceof Error ? e.message : String(e),
|
||||
key: "db-whole-value",
|
||||
});
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
showContextMenu(
|
||||
at,
|
||||
exportMenu(
|
||||
{ columns, rows: rowsOf(r), driver, table: queryTable(text, { driver }) },
|
||||
queryTable(text, { driver }),
|
||||
extractor,
|
||||
),
|
||||
);
|
||||
return {
|
||||
columns: gridColumns.map((c) => ({ name: c.name, type: c.type, primaryKey: c.primaryKey })),
|
||||
rows: rowsOf(r),
|
||||
driver,
|
||||
table: queryTable(text, { driver }),
|
||||
};
|
||||
};
|
||||
const showExport = async (at: { x: number; y: number }) => {
|
||||
const data = await exportSource();
|
||||
if (data) showContextMenu(at, exportMenu(data, queryTable(text, { driver }), extractor));
|
||||
};
|
||||
|
||||
// Submit / Revert / Go to Column (⌘↩ / ⌥⌘Z / ⌘F12) reach the latest state through the handle, as in the table editor.
|
||||
@@ -635,6 +637,7 @@ export function Result({ tab, onClose }: { tab: ResultTab; onClose?: () => void
|
||||
panel={panel}
|
||||
onPanelChange={setPanel}
|
||||
copyFormat={copyFormatOf(extractor)}
|
||||
extractor={{ value: extractor, onChange: setExtractor, table: exportSource }}
|
||||
searchOpen={searchOpen}
|
||||
onSearchOpenChange={setSearchOpen}
|
||||
firstRowNumber={(tab.page ?? 0) * (tab.pageSize ?? 0) + 1}
|
||||
|
||||
@@ -440,6 +440,16 @@ export function TableEditor({ input }: { input: EditorInput }) {
|
||||
panel={panel}
|
||||
onPanelChange={setPanel}
|
||||
copyFormat={copyFormatOf(extractor)}
|
||||
extractor={{
|
||||
value: extractor,
|
||||
onChange: setExtractor,
|
||||
table: () => ({
|
||||
columns: gridColumns,
|
||||
rows: page.result.rows,
|
||||
table: ref.table,
|
||||
driver: sourceById(ref.id)?.driver ?? "sqlite",
|
||||
}),
|
||||
}}
|
||||
searchOpen={searchOpen}
|
||||
onSearchOpenChange={setSearchOpen}
|
||||
firstRowNumber={offset + 1}
|
||||
|
||||
@@ -195,3 +195,60 @@ it.each<ExportFormat>(["csv", "tsv", "sql", "markdown", "onerow"])("%s retains e
|
||||
const value = "9223372036854775807";
|
||||
expect(exportData(format, data(value))).toContain(value);
|
||||
});
|
||||
|
||||
describe("SQL statements of rows (#6143)", () => {
|
||||
const rows: ExportData = {
|
||||
columns: [
|
||||
{ name: "id", type: "INTEGER", primaryKey: true },
|
||||
{ name: "name", type: "TEXT" },
|
||||
{ name: "note", type: "TEXT" },
|
||||
],
|
||||
rows: [
|
||||
["2", "O'Hara", null],
|
||||
["1", "Ann", "x"],
|
||||
],
|
||||
table: "people",
|
||||
driver: "postgres",
|
||||
};
|
||||
|
||||
it("writes one statement per row, in order, matching rows by the primary key", () => {
|
||||
expect(exportData("sql", rows)).toBe(
|
||||
[
|
||||
`INSERT INTO people (id, name, note) VALUES (2, 'O''Hara', NULL);`,
|
||||
`INSERT INTO people (id, name, note) VALUES (1, 'Ann', 'x');`,
|
||||
].join("\n"),
|
||||
);
|
||||
expect(exportData("sqlUpdates", rows)).toBe(
|
||||
[
|
||||
`UPDATE people SET name = 'O''Hara', note = NULL WHERE id = 2;`,
|
||||
`UPDATE people SET name = 'Ann', note = 'x' WHERE id = 1;`,
|
||||
].join("\n"),
|
||||
);
|
||||
expect(exportData("sqlDeletes", rows)).toBe(
|
||||
[`DELETE FROM people WHERE id = 2;`, `DELETE FROM people WHERE id = 1;`].join("\n"),
|
||||
);
|
||||
expect(exportData("where", rows)).toBe(`WHERE (id = 2) OR (id = 1)`);
|
||||
expect(exportData("where", { ...rows, rows: rows.rows.slice(1) })).toBe(`WHERE id = 1`);
|
||||
});
|
||||
|
||||
it("matches on every column, saying so, when no key is known, and writes IS NULL for a null", () => {
|
||||
const keyless = { ...rows, columns: rows.columns.map((c) => ({ ...c, primaryKey: false })), rows: [rows.rows[0]!] };
|
||||
expect(exportData("sqlDeletes", keyless)).toBe(
|
||||
`-- No primary key is known: rows are matched on every column.\n` +
|
||||
`DELETE FROM people WHERE id = 2 AND name = 'O''Hara' AND note IS NULL;`,
|
||||
);
|
||||
// A null key value too.
|
||||
const nullKey = { ...rows, rows: [[null, "x", "y"]] };
|
||||
expect(exportData("sqlDeletes", nullKey)).toBe(`DELETE FROM people WHERE id IS NULL;`);
|
||||
});
|
||||
|
||||
it("escapes backslashes for drivers that read them, as SQL Inserts did", () => {
|
||||
const d: ExportData = {
|
||||
columns: [{ name: "p", type: "String" }],
|
||||
rows: [["a\\b'"]],
|
||||
table: "t",
|
||||
driver: "clickhouse",
|
||||
};
|
||||
expect(exportData("sql", d)).toBe(`INSERT INTO t (p) VALUES ('a\\\\b''');`);
|
||||
});
|
||||
});
|
||||
@@ -7,24 +7,40 @@
|
||||
import type { DbDriver } from "@/platform/ipc";
|
||||
import { jsonNumber } from "@/platform/losslessJson";
|
||||
import { isNumericColumn } from "./Grid";
|
||||
import { toCsv, toOneRow, toTsv, type Cell } from "./model";
|
||||
import { sqlLiteral, toCsv, toOneRow, toTsv, type Cell } from "./model";
|
||||
import { quoteIdent } from "./sql/complete";
|
||||
|
||||
export type ExportFormat = "csv" | "tsv" | "json" | "sql" | "markdown" | "onerow";
|
||||
export type ExportFormat =
|
||||
| "csv"
|
||||
| "tsv"
|
||||
| "json"
|
||||
| "sql"
|
||||
| "sqlUpdates"
|
||||
| "sqlDeletes"
|
||||
| "where"
|
||||
| "markdown"
|
||||
| "onerow";
|
||||
|
||||
/** The formats written as SQL (highlighted as SQL in the Export Data preview). */
|
||||
export const SQL_FORMATS: ReadonlySet<ExportFormat> = new Set(["sql", "sqlUpdates", "sqlDeletes", "where"]);
|
||||
|
||||
export const EXPORT_FORMATS: ReadonlyArray<{ id: ExportFormat; label: string; extension: string }> = [
|
||||
{ id: "csv", label: "CSV", extension: "csv" },
|
||||
{ id: "tsv", label: "TSV", extension: "tsv" },
|
||||
{ id: "json", label: "JSON", extension: "json" },
|
||||
{ id: "sql", label: "SQL Inserts", extension: "sql" },
|
||||
{ id: "sqlUpdates", label: "SQL Updates", extension: "sql" },
|
||||
{ id: "sqlDeletes", label: "SQL Deletes", extension: "sql" },
|
||||
{ id: "where", label: "Where Clause", extension: "sql" },
|
||||
{ id: "markdown", label: "Markdown", extension: "md" },
|
||||
{ id: "onerow", label: "One-Row", extension: "txt" },
|
||||
];
|
||||
|
||||
export interface ExportData {
|
||||
columns: ReadonlyArray<{ name: string; type: string }>;
|
||||
/** `primaryKey` columns identify a row in SQL Updates, SQL Deletes and Where Clause. */
|
||||
columns: ReadonlyArray<{ name: string; type: string; primaryKey?: boolean }>;
|
||||
rows: ReadonlyArray<readonly Cell[]>;
|
||||
/** Target of SQL inserts (the query's table, when it reads one). */
|
||||
/** Target of SQL statements (the query's table, when it reads one). */
|
||||
table: string;
|
||||
driver: DbDriver;
|
||||
}
|
||||
@@ -89,16 +105,11 @@ export function exportData(
|
||||
});
|
||||
return rows.length ? `[\n${rows.join(",\n")}\n]` : "[]";
|
||||
}
|
||||
case "sql": {
|
||||
const literal = (v: Cell, i: number) =>
|
||||
v === null
|
||||
? "NULL"
|
||||
: numeric[i] && Number.isFinite(Number(v))
|
||||
? v
|
||||
: `'${(d.driver === "clickhouse" || d.driver === "snowflake" ? v.replace(/\\/g, "\\\\") : v).replace(/'/g, "''")}'`;
|
||||
const head = `INSERT INTO ${quoteIdent(d.table, d.driver)} (${names.map((n) => quoteIdent(n, d.driver)).join(", ")}) VALUES`;
|
||||
return d.rows.map((r) => `${head} (${r.map(literal).join(", ")});`).join("\n");
|
||||
}
|
||||
case "sql":
|
||||
case "sqlUpdates":
|
||||
case "sqlDeletes":
|
||||
case "where":
|
||||
return sqlStatements(format, d, numeric);
|
||||
case "markdown": {
|
||||
const cell = (v: Cell) => (v ?? "").replace(/\|/g, "\\|").replace(/\r?\n/g, " ");
|
||||
const t = laidOut(d, options);
|
||||
@@ -115,3 +126,41 @@ export function exportData(
|
||||
return toOneRow(d.rows, (c) => numeric[c]!);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL Inserts, Updates, Deletes and the Where Clause of the rows, one statement per row in
|
||||
* their order. A row is identified by its primary key columns; with none known, by every
|
||||
* column, which the text says first.
|
||||
*/
|
||||
function sqlStatements(format: ExportFormat, d: ExportData, numeric: readonly boolean[]): string {
|
||||
const ident = (name: string) => quoteIdent(name, d.driver);
|
||||
const names = d.columns.map((c) => ident(c.name));
|
||||
const literal = (v: Cell | undefined, i: number) => sqlLiteral(v ?? null, numeric[i]!, d.driver);
|
||||
const table = ident(d.table);
|
||||
if (format === "sql")
|
||||
return d.rows
|
||||
.map((r) => `INSERT INTO ${table} (${names.join(", ")}) VALUES (${r.map(literal).join(", ")});`)
|
||||
.join("\n");
|
||||
const keys = d.columns.flatMap((c, i) => (c.primaryKey ? [i] : []));
|
||||
const match = keys.length ? keys : names.map((_, i) => i);
|
||||
const where = (r: readonly Cell[]) =>
|
||||
match.map((i) => (r[i] == null ? `${names[i]} IS NULL` : `${names[i]} = ${literal(r[i], i)}`)).join(" AND ");
|
||||
const note = keys.length || !d.rows.length ? "" : "-- No primary key is known: rows are matched on every column.\n";
|
||||
if (format === "where") {
|
||||
if (!d.rows.length) return "";
|
||||
const body = d.rows.length === 1 ? where(d.rows[0]!) : d.rows.map((r) => `(${where(r)})`).join(" OR ");
|
||||
return `${note}WHERE ${body}`;
|
||||
}
|
||||
if (format === "sqlDeletes") return note + d.rows.map((r) => `DELETE FROM ${table} WHERE ${where(r)};`).join("\n");
|
||||
// Updates set the other columns (every column when no key is known).
|
||||
const set = keys.length ? names.flatMap((_, i) => (keys.includes(i) ? [] : [i])) : match;
|
||||
return (
|
||||
note +
|
||||
d.rows
|
||||
.map(
|
||||
(r) =>
|
||||
`UPDATE ${table} SET ${set.map((i) => `${names[i]} = ${literal(r[i], i)}`).join(", ")} WHERE ${where(r)};`,
|
||||
)
|
||||
.join("\n")
|
||||
);
|
||||
}
|
||||
@@ -30,9 +30,18 @@ export function toTsv(header: readonly string[] | null, rows: ReadonlyArray<read
|
||||
* single-quoted with `'` doubled. `numeric(c)` decides quoting per column.
|
||||
*/
|
||||
export function toOneRow(rows: ReadonlyArray<readonly Cell[]>, numeric: (col: number) => boolean): string {
|
||||
const literal = (v: Cell, c: number) =>
|
||||
v === null ? "NULL" : numeric(c) && Number.isFinite(Number(v)) ? v : `'${v.replace(/'/g, "''")}'`;
|
||||
return rows.flatMap((r) => r.map(literal)).join(", ");
|
||||
return rows.flatMap((r) => r.map((v, c) => sqlLiteral(v, numeric(c)))).join(", ");
|
||||
}
|
||||
|
||||
/**
|
||||
* A value as an SQL literal: NULL, a number unquoted in a numeric column, else single-quoted
|
||||
* with `'` doubled (and `\\` doubled for drivers that read backslash escapes in strings).
|
||||
*/
|
||||
export function sqlLiteral(v: Cell, numeric: boolean, driver?: DbDriver): string {
|
||||
if (v === null) return "NULL";
|
||||
if (numeric && Number.isFinite(Number(v))) return v;
|
||||
const escaped = driver === "clickhouse" || driver === "snowflake" ? v.replace(/\\/g, "\\\\") : v;
|
||||
return `'${escaped.replace(/'/g, "''")}'`;
|
||||
}
|
||||
|
||||
/** RFC 4180 CSV; NULL is an empty field. */
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { fireEvent, render, screen, within } from "@testing-library/react";
|
||||
import { ObjectDialogs } from "./ObjectDialogs";
|
||||
import { detailsKey, openDialog, useDatabase } from "./store";
|
||||
|
||||
const column = (name: string, dataType: string, primaryKey = false) => ({
|
||||
name,
|
||||
dataType,
|
||||
nullable: !primaryKey,
|
||||
default: null,
|
||||
primaryKey,
|
||||
});
|
||||
|
||||
function open() {
|
||||
useDatabase.setState({
|
||||
details: {
|
||||
[detailsKey("db", "main", "orders")]: {
|
||||
status: "ok",
|
||||
value: {
|
||||
columns: [column("id", "integer", true), column("customer_id", "integer"), column("note", "text")],
|
||||
indexes: [{ name: "orders_customer", unique: false, columns: ["customer_id"] }],
|
||||
foreignKeys: [
|
||||
{
|
||||
schema: "main",
|
||||
table: "orders",
|
||||
columns: ["customer_id"],
|
||||
refSchema: "main",
|
||||
refTable: "customers",
|
||||
refColumns: ["id"],
|
||||
},
|
||||
],
|
||||
triggers: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
} as never);
|
||||
openDialog({ kind: "modifyTable", id: "db", schema: "main", table: "orders" });
|
||||
render(<ObjectDialogs />);
|
||||
}
|
||||
|
||||
const rows = (group: string) =>
|
||||
within(screen.getByRole("group", { name: group }))
|
||||
.queryAllByRole("option")
|
||||
.map((o) => o.textContent);
|
||||
|
||||
afterEach(() => useDatabase.setState({ dialog: null, details: {} } as never));
|
||||
|
||||
describe("Modify Table's list (DataGrip)", () => {
|
||||
it("groups the columns, keys, foreign keys and indexes, and filters them by name or type", () => {
|
||||
open();
|
||||
expect(rows("Columns")).toEqual(["idinteger", "customer_idinteger", "notetext"]);
|
||||
expect(rows("Keys")).toEqual(["PRIMARY KEY(id)"]);
|
||||
expect(rows("Foreign Keys")).toEqual(["(customer_id)→ customers (id)"]);
|
||||
expect(rows("Indexes")).toEqual(["orders_customer(customer_id)"]);
|
||||
// No triggers: no group.
|
||||
expect(screen.queryByRole("group", { name: "Triggers" })).toBeNull();
|
||||
|
||||
// A group collapses from its header.
|
||||
fireEvent.mouseDown(within(screen.getByRole("group", { name: "Indexes" })).getByText("Indexes"));
|
||||
expect(rows("Indexes")).toEqual([]);
|
||||
|
||||
fireEvent.change(screen.getByRole("textbox", { name: "Filter columns" }), { target: { value: "TEXT" } });
|
||||
expect(rows("Columns")).toEqual(["notetext"]);
|
||||
expect(screen.queryByRole("group", { name: "Foreign Keys" })).toBeNull();
|
||||
|
||||
fireEvent.change(screen.getByRole("textbox", { name: "Filter columns" }), { target: { value: "customer" } });
|
||||
expect(rows("Columns")).toEqual(["customer_idinteger"]);
|
||||
expect(rows("Foreign Keys")).toEqual(["(customer_id)→ customers (id)"]);
|
||||
});
|
||||
|
||||
it("keeps Keys on the primary key as edited in Create Table", () => {
|
||||
openDialog({ kind: "modifyTable", id: "db", schema: "main", table: null });
|
||||
render(<ObjectDialogs />);
|
||||
expect(rows("Keys")).toEqual(["PRIMARY KEY(id)"]);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Add Column" }));
|
||||
fireEvent.click(screen.getByRole("checkbox", { name: "Primary key" }));
|
||||
expect(rows("Keys")).toEqual(["PRIMARY KEY(id, column_2)"]);
|
||||
});
|
||||
});
|
||||
@@ -605,7 +605,7 @@ export function ProjectView() {
|
||||
const rootNode = m.roots[0];
|
||||
if (!rootNode) return;
|
||||
setSelection(new Set([rootNode.key]), rootNode.key);
|
||||
showContextMenu(e, contextMenuItems([rootNode]));
|
||||
showContextMenu(e, contextMenuItems([rootNode], { x: e.clientX, y: e.clientY }));
|
||||
return;
|
||||
}
|
||||
const nodes = [...sel].map((k) => m.byKey.get(k)).filter((n): n is ProjectNode => !!n && !n.placeholder);
|
||||
@@ -614,7 +614,7 @@ export function ProjectView() {
|
||||
// Contributed groups may read the file first (bounded wait).
|
||||
const at = { x: e.clientX, y: e.clientY };
|
||||
void prepareMenuGroups("projectView", menuGroupContext(target)).then(() =>
|
||||
showContextMenu(at, contextMenuItems(target)),
|
||||
showContextMenu(at, contextMenuItems(target, at)),
|
||||
);
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@ import { registerMenuGroup } from "@/workbench/contributions";
|
||||
import { contextMenuItems, keyLabel, revealLabel } from "./contextMenu";
|
||||
import type { ProjectNode } from "./model";
|
||||
import { useProjectTree } from "./store";
|
||||
import { closePopup, useLspPopup } from "@/editor/lsp/popupStore";
|
||||
import { _provideCopyPathChooser } from "@/editor/api";
|
||||
import { openCopyPathChooser } from "@/editor/core/copyPathChooser";
|
||||
|
||||
_provideCopyPathChooser(openCopyPathChooser);
|
||||
|
||||
vi.mock("@/platform/ipc", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("@/platform/ipc")>()),
|
||||
@@ -79,6 +84,7 @@ beforeEach(() => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
closePopup();
|
||||
disposers.forEach((d) => d());
|
||||
useProject.setState({ project: null, settings: null });
|
||||
useProjectTree.setState({ root: null });
|
||||
@@ -147,38 +153,56 @@ describe("project view context menu", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("lists contributed links in Copy Path/Reference…", () => {
|
||||
/** Runs Copy Path/Reference… and returns the chooser's rows as `label: preview`. */
|
||||
const chooser = (items: MenuItem[]) => {
|
||||
const item = resolveMenuItems(items).find((r) => r.label === "Copy Path/Reference…");
|
||||
expect(item?.submenu).toBeUndefined();
|
||||
item!.run!();
|
||||
const popup = useLspPopup.getState().popup;
|
||||
return popup?.kind === "list" ? popup.items.map((i) => `${i.label}: ${i.preview}`) : undefined;
|
||||
};
|
||||
|
||||
it("previews each way Copy Path/Reference… copies the selection, contributed links included", () => {
|
||||
disposers.push(
|
||||
registerMenuGroup({
|
||||
id: "test.link",
|
||||
menus: ["copyPath"],
|
||||
items: (_menu, ctx) => [
|
||||
{ label: `Link ${ctx.paths.join()} ${ctx.dirs?.join()}`, verbatim: true, run: () => undefined },
|
||||
{
|
||||
id: "test.link",
|
||||
label: "Link",
|
||||
verbatim: true,
|
||||
preview: `${ctx.paths.join()} ${ctx.dirs?.join()}`,
|
||||
run: () => undefined,
|
||||
},
|
||||
// Without a preview a contribution has nothing to show in the chooser.
|
||||
{ id: "test.bare", label: "Bare", run: () => undefined },
|
||||
],
|
||||
}),
|
||||
);
|
||||
expect(sub(contextMenuItems([node("/p/src", true)]), "Copy Path/Reference…")).toEqual([
|
||||
"Absolute Path",
|
||||
"File Name",
|
||||
"Path From Content Root",
|
||||
"-",
|
||||
"Link /p/src true",
|
||||
expect(chooser(contextMenuItems([node("/p/src", true), node("/p/src/a.ts")], { x: 10, y: 20 }))).toEqual([
|
||||
"Absolute Path: /p/src\n/p/src/a.ts",
|
||||
"File Name: src\na.ts",
|
||||
"Path From Content Root: src\nsrc/a.ts",
|
||||
"Link: /p/src,/p/src/a.ts true,false",
|
||||
]);
|
||||
expect(useLspPopup.getState().popup).toMatchObject({ layout: "copyPath", anchor: { x: 10, y: 20 } });
|
||||
});
|
||||
|
||||
it("lists contributed links in Copy Path/Reference… of library files too", () => {
|
||||
it("offers no content root paths for library files in Copy Path/Reference…", () => {
|
||||
disposers.push(
|
||||
registerMenuGroup({
|
||||
id: "test.link",
|
||||
menus: ["copyPath"],
|
||||
items: (_menu, ctx) => [{ label: `Link ${ctx.paths.join()}`, verbatim: true, run: () => undefined }],
|
||||
items: (_menu, ctx) => [
|
||||
{ id: "test.link", label: "Link", verbatim: true, preview: ctx.paths.join(), run: () => undefined },
|
||||
],
|
||||
}),
|
||||
);
|
||||
expect(sub(contextMenuItems([{ ...node("/root/.m2/lib.jar"), readOnly: true }]), "Copy Path/Reference…")).toEqual([
|
||||
"Absolute Path",
|
||||
"File Name",
|
||||
"-",
|
||||
"Link /root/.m2/lib.jar",
|
||||
expect(chooser(contextMenuItems([{ ...node("/root/.m2/lib.jar"), readOnly: true }]))).toEqual([
|
||||
"Absolute Path: /root/.m2/lib.jar",
|
||||
"File Name: lib.jar",
|
||||
"Link: /root/.m2/lib.jar",
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/** Context menu and "New" popup of the project view. */
|
||||
import { openCopyPathChooser } from "@/editor/api";
|
||||
import { executeAction, getAction } from "@/platform/actions";
|
||||
import type { PathKind } from "@/platform/copyPath";
|
||||
import { getContext } from "@/platform/context";
|
||||
import { canOpenWithSystemApp, canRevealInFileManager, fileManagerName } from "@/platform/fileManager";
|
||||
import { formatBinding, hostBinding, isMacHost, shortcutLabel } from "@/platform/keymap";
|
||||
@@ -18,6 +20,7 @@ import {
|
||||
canPaste,
|
||||
copyPaths,
|
||||
copySelection,
|
||||
pathsFor,
|
||||
delegate,
|
||||
deleteSelection,
|
||||
findFileUsages,
|
||||
@@ -151,6 +154,8 @@ function delegated(
|
||||
}
|
||||
|
||||
type Entry = MenuItem | null | false | undefined;
|
||||
/** Where a menu opens; popups its items open appear there. */
|
||||
type MenuPoint = { x: number; y: number } | "center";
|
||||
|
||||
/** A submenu of the present entries, or nothing when none is left (never an empty submenu). */
|
||||
function submenu(id: string, label: string, entries: Entry[], icon?: string): MenuItem | null {
|
||||
@@ -160,8 +165,13 @@ function submenu(id: string, label: string, entries: Entry[], icon?: string): Me
|
||||
}
|
||||
|
||||
/** Project view actions available for the selected files and directories. */
|
||||
export function contextMenuItems(nodes: ProjectNode[]): MenuItem[] {
|
||||
if (nodes.some((n) => n.readOnly)) return libraryMenuItems(nodes.filter((n) => !n.group));
|
||||
/** `at`: where the menu opens, for the popups its items open (Copy Path/Reference…). */
|
||||
export function contextMenuItems(nodes: ProjectNode[], at: MenuPoint = "center"): MenuItem[] {
|
||||
if (nodes.some((n) => n.readOnly))
|
||||
return libraryMenuItems(
|
||||
nodes.filter((n) => !n.group),
|
||||
at,
|
||||
);
|
||||
const lead = nodes[0] ?? null;
|
||||
const single = nodes.length === 1 ? lead : null;
|
||||
const nonRoot = nodes.filter((n) => !n.root);
|
||||
@@ -217,22 +227,7 @@ export function contextMenuItems(nodes: ProjectNode[]): MenuItem[] {
|
||||
disabled: !nonRoot.length,
|
||||
run: () => copySelection(false),
|
||||
},
|
||||
{
|
||||
id: "copyPath",
|
||||
label: "Copy Path/Reference…",
|
||||
submenu: [
|
||||
{
|
||||
id: "abs",
|
||||
label: "Absolute Path",
|
||||
shortcut: keyLabel("project.copyAbsolutePath"),
|
||||
run: () => void copyPaths("absolute", nodes),
|
||||
},
|
||||
{ id: "name", label: "File Name", run: () => void copyPaths("name", nodes) },
|
||||
{ id: "rel", label: "Path From Content Root", run: () => void copyPaths("relative", nodes) },
|
||||
{ kind: "separator" },
|
||||
...menuGroupItems("copyPath", menuGroupContext(nodes)),
|
||||
],
|
||||
},
|
||||
copyPathItem(nodes, at, false),
|
||||
{
|
||||
id: "paste",
|
||||
label: "Paste",
|
||||
@@ -464,27 +459,13 @@ function openInRightSplitItem(files: ProjectNode[]): MenuItem {
|
||||
}
|
||||
|
||||
/** Library sources (External Libraries) are read-only: copy, find and reveal only. */
|
||||
function libraryMenuItems(nodes: ProjectNode[]): MenuItem[] {
|
||||
function libraryMenuItems(nodes: ProjectNode[], at: MenuPoint): MenuItem[] {
|
||||
if (!nodes.length) return [];
|
||||
const single = nodes.length === 1 ? nodes[0]! : null;
|
||||
const folder = single?.dir ? single.path : null;
|
||||
const items: Entry[] = [
|
||||
{ id: "copy", label: "Copy", icon: "copy", shortcut: keyLabel("project.copy"), run: () => copySelection(false) },
|
||||
{
|
||||
id: "copyPath",
|
||||
label: "Copy Path/Reference…",
|
||||
submenu: [
|
||||
{
|
||||
id: "abs",
|
||||
label: "Absolute Path",
|
||||
shortcut: keyLabel("project.copyAbsolutePath"),
|
||||
run: () => void copyPaths("absolute", nodes),
|
||||
},
|
||||
{ id: "name", label: "File Name", run: () => void copyPaths("name", nodes) },
|
||||
{ kind: "separator" },
|
||||
...menuGroupItems("copyPath", menuGroupContext(nodes)),
|
||||
],
|
||||
},
|
||||
copyPathItem(nodes, at, true),
|
||||
{ kind: "separator" },
|
||||
!!folder && delegated("find.inPath", { directory: folder }, "Find in Files…", { icon: "search" }),
|
||||
!!folder && { kind: "separator" },
|
||||
@@ -518,6 +499,43 @@ export function revealLabel() {
|
||||
return fileManagerName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy Path/Reference…: a chooser previewing what each way copies for the selection (several
|
||||
* paths one per line), contributed links and references included. Library files have no
|
||||
* content or source root.
|
||||
*/
|
||||
function copyPathItem(nodes: ProjectNode[], at: MenuPoint, library: boolean): Entry {
|
||||
const row = (kind: PathKind, id: string, label: string) => {
|
||||
const paths = pathsFor(kind, nodes);
|
||||
return {
|
||||
id,
|
||||
label,
|
||||
// A selection only partly under a source root has no source-root path.
|
||||
preview: paths.length && paths.length === nodes.length ? paths.join("\n") : null,
|
||||
run: () => void copyPaths(kind, nodes),
|
||||
};
|
||||
};
|
||||
return {
|
||||
id: "copyPath",
|
||||
label: "Copy Path/Reference…",
|
||||
run: () =>
|
||||
openCopyPathChooser(
|
||||
at,
|
||||
[
|
||||
row("absolute", "project.copyAbsolutePath", "Absolute Path"),
|
||||
row("name", "project.copyFileName", "File Name"),
|
||||
...(library
|
||||
? []
|
||||
: [
|
||||
row("relative", "project.copyRelativePath", "Path From Content Root"),
|
||||
row("source", "project.copySourceRootPath", "Path From Source Root"),
|
||||
]),
|
||||
],
|
||||
menuGroupContext(nodes),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/** What contributed menu groups see: the selected (non-placeholder) paths. */
|
||||
export function menuGroupContext(nodes: ProjectNode[]): MenuGroupContext {
|
||||
const real = nodes.filter((n) => !n.placeholder);
|
||||
|
||||
@@ -118,7 +118,7 @@ export interface ValidSettings extends WorkflowSettings {
|
||||
proxy: ProxySettingsValid;
|
||||
remoteDevelopment: { idleTimeoutMinutes: number };
|
||||
/** Tools › Download sources: a mirror prefix for the installer's release downloads. */
|
||||
toolDownloads: { githubMirror: string };
|
||||
toolDownloads: { githubMirror: string; configuredRegistriesOnly: boolean };
|
||||
languages: LanguagesValid;
|
||||
cmake: ReturnType<typeof validateCMake>;
|
||||
projectStructure: ProjectStructureValid;
|
||||
@@ -227,7 +227,7 @@ export const DEFAULT_SETTINGS: ValidSettings = {
|
||||
notifications: DEFAULT_NOTIFICATIONS,
|
||||
proxy: DEFAULT_PROXY,
|
||||
remoteDevelopment: { idleTimeoutMinutes: DEFAULT_REMOTE_IDLE_MINUTES },
|
||||
toolDownloads: { githubMirror: "" },
|
||||
toolDownloads: { githubMirror: "", configuredRegistriesOnly: false },
|
||||
languages: DEFAULT_LANGUAGES,
|
||||
cmake: {},
|
||||
projectStructure: DEFAULT_PROJECT_STRUCTURE,
|
||||
@@ -435,6 +435,7 @@ export function validateSettings(raw: Settings | unknown): ValidSettings {
|
||||
typeof obj(root.toolDownloads).githubMirror === "string"
|
||||
? String(obj(root.toolDownloads).githubMirror).trim()
|
||||
: "",
|
||||
configuredRegistriesOnly: obj(root.toolDownloads).configuredRegistriesOnly === true,
|
||||
},
|
||||
languages: validateLanguages(root.languages),
|
||||
cmake: validateCMake(root.cmake),
|
||||
|
||||
@@ -892,7 +892,20 @@ export const TOOLS_PAGES: PageSpec[] = [
|
||||
title: "Download Mirrors",
|
||||
group: TOOLS_GROUP,
|
||||
order: 590,
|
||||
keywords: ["mirror", "download", "github", "proxy", "slow", "language server", "accelerate"],
|
||||
keywords: [
|
||||
"mirror",
|
||||
"download",
|
||||
"github",
|
||||
"proxy",
|
||||
"slow",
|
||||
"language server",
|
||||
"accelerate",
|
||||
"registry",
|
||||
"npm",
|
||||
"maven central",
|
||||
"nexus",
|
||||
"artifactory",
|
||||
],
|
||||
sections: [
|
||||
{
|
||||
title: "GitHub",
|
||||
@@ -905,6 +918,17 @@ export const TOOLS_PAGES: PageSpec[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Package Registries",
|
||||
options: [
|
||||
{
|
||||
kind: "toggle",
|
||||
key: "toolDownloads.configuredRegistriesOnly",
|
||||
label: "Use only the configured package registries",
|
||||
hint: "For a company registry such as Nexus or Artifactory: installing tools and agents never retries against the public npm registry when the configured one refuses or misses a package, and the IDE fetches nothing from Maven Central, npm, PyPI or crates.io itself (the JUnit launcher, dependency version completion).",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -4148,5 +4148,23 @@
|
||||
"Semicolons": "Semicolons",
|
||||
"Quotes": "Quotes",
|
||||
"For the strings and imports the TypeScript server adds.": "For the strings and imports the TypeScript server adds.",
|
||||
"The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones.": "The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones."
|
||||
"The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones.": "The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones.",
|
||||
"Show Record View": "Show Record View",
|
||||
"Open in Value Editor": "Open in Value Editor",
|
||||
"Show Aggregate View": "Show Aggregate View",
|
||||
"Data Extractor": "Data Extractor",
|
||||
"Export Table to Clipboard": "Export Table to Clipboard",
|
||||
"Keys": "Keys",
|
||||
"Triggers": "Triggers",
|
||||
"Filter by name or type": "Filter by name or type",
|
||||
"Filter columns": "Filter columns",
|
||||
"Package Registries": "Package Registries",
|
||||
"Use only the configured package registries": "Use only the configured package registries",
|
||||
"For a company registry such as Nexus or Artifactory: installing tools and agents never retries against the public npm registry when the configured one refuses or misses a package, and the IDE fetches nothing from Maven Central, npm, PyPI or crates.io itself (the JUnit launcher, dependency version completion).": "For a company registry such as Nexus or Artifactory: installing tools and agents never retries against the public npm registry when the configured one refuses or misses a package, and the IDE fetches nothing from Maven Central, npm, PyPI or crates.io itself (the JUnit launcher, dependency version completion).",
|
||||
"SQL Updates": "SQL Updates",
|
||||
"SQL Deletes": "SQL Deletes",
|
||||
"Where Clause": "Where Clause",
|
||||
"SQL INSERT": "SQL INSERT",
|
||||
"SQL UPDATE": "SQL UPDATE",
|
||||
"SQL DELETE": "SQL DELETE"
|
||||
}
|
||||
@@ -10163,5 +10163,23 @@
|
||||
"Allowed command pattern": "Шаблон разрешённой команды",
|
||||
"Blocked command pattern": "Шаблон заблокированной команды",
|
||||
"Mode applies to": "Режим действует для",
|
||||
"Allow all optional permissions": "Разрешить все необязательные разрешения"
|
||||
"Allow all optional permissions": "Разрешить все необязательные разрешения",
|
||||
"Show Record View": "Показать представление записи",
|
||||
"Open in Value Editor": "Открыть в редакторе значений",
|
||||
"Show Aggregate View": "Показать агрегаты",
|
||||
"Data Extractor": "Экстрактор данных",
|
||||
"Export Table to Clipboard": "Экспортировать таблицу в буфер обмена",
|
||||
"Keys": "Ключи",
|
||||
"Triggers": "Триггеры",
|
||||
"Filter by name or type": "Фильтр по имени или типу",
|
||||
"Filter columns": "Фильтр столбцов",
|
||||
"Package Registries": "Реестры пакетов",
|
||||
"Use only the configured package registries": "Использовать только настроенные реестры пакетов",
|
||||
"For a company registry such as Nexus or Artifactory: installing tools and agents never retries against the public npm registry when the configured one refuses or misses a package, and the IDE fetches nothing from Maven Central, npm, PyPI or crates.io itself (the JUnit launcher, dependency version completion).": "Для корпоративного реестра, например Nexus или Artifactory: при установке инструментов и агентов не выполняется повторная попытка через публичный реестр npm, если настроенный реестр отклонил пакет или не нашёл его, а сама IDE ничего не загружает из Maven Central, npm, PyPI или crates.io (JUnit Launcher, автодополнение версий зависимостей).",
|
||||
"SQL Updates": "SQL-обновления",
|
||||
"SQL Deletes": "SQL-удаления",
|
||||
"Where Clause": "Условие WHERE",
|
||||
"SQL INSERT": "SQL INSERT",
|
||||
"SQL UPDATE": "SQL UPDATE",
|
||||
"SQL DELETE": "SQL DELETE"
|
||||
}
|
||||
@@ -8824,5 +8824,23 @@
|
||||
"Allowed command pattern": "İzin verilen komut kalıbı",
|
||||
"Blocked command pattern": "Engellenen komut kalıbı",
|
||||
"Mode applies to": "Modun uygulandığı yer",
|
||||
"Allow all optional permissions": "Tüm isteğe bağlı izinlere izin ver"
|
||||
"Allow all optional permissions": "Tüm isteğe bağlı izinlere izin ver",
|
||||
"Show Record View": "Kayıt Görünümünü Göster",
|
||||
"Open in Value Editor": "Değer Düzenleyicide Aç",
|
||||
"Show Aggregate View": "Toplam Görünümünü Göster",
|
||||
"Data Extractor": "Veri Çıkarıcı",
|
||||
"Export Table to Clipboard": "Tabloyu Panoya Aktar",
|
||||
"Keys": "Anahtarlar",
|
||||
"Triggers": "Tetikleyiciler",
|
||||
"Filter by name or type": "Ada veya türe göre filtrele",
|
||||
"Filter columns": "Sütunları filtrele",
|
||||
"Package Registries": "Paket Kayıt Defterleri",
|
||||
"Use only the configured package registries": "Yalnızca yapılandırılmış paket kayıt defterlerini kullan",
|
||||
"For a company registry such as Nexus or Artifactory: installing tools and agents never retries against the public npm registry when the configured one refuses or misses a package, and the IDE fetches nothing from Maven Central, npm, PyPI or crates.io itself (the JUnit launcher, dependency version completion).": "Nexus veya Artifactory gibi bir şirket kayıt defteri için: araçlar ve ajanlar yüklenirken yapılandırılmış kayıt defteri bir paketi reddederse ya da bulamazsa genel npm kayıt defterinde yeniden denenmez ve IDE kendisi Maven Central, npm, PyPI veya crates.io'dan hiçbir şey indirmez (JUnit başlatıcısı, bağımlılık sürümü tamamlama).",
|
||||
"SQL Updates": "SQL Güncelleme İfadeleri",
|
||||
"SQL Deletes": "SQL Silme İfadeleri",
|
||||
"Where Clause": "WHERE Koşulu",
|
||||
"SQL INSERT": "SQL INSERT",
|
||||
"SQL UPDATE": "SQL UPDATE",
|
||||
"SQL DELETE": "SQL DELETE"
|
||||
}
|
||||
@@ -9362,5 +9362,23 @@
|
||||
"Allowed command pattern": "允許的命令模式",
|
||||
"Blocked command pattern": "封鎖的命令模式",
|
||||
"Mode applies to": "模式作用範圍",
|
||||
"Allow all optional permissions": "允許全部可選權限"
|
||||
"Allow all optional permissions": "允許全部可選權限",
|
||||
"Show Record View": "顯示記錄檢視",
|
||||
"Open in Value Editor": "在值編輯器中開啟",
|
||||
"Show Aggregate View": "顯示彙總檢視",
|
||||
"Data Extractor": "資料擷取器",
|
||||
"Export Table to Clipboard": "將表格匯出到剪貼簿",
|
||||
"Keys": "鍵",
|
||||
"Triggers": "觸發器",
|
||||
"Filter by name or type": "依名稱或類型篩選",
|
||||
"Filter columns": "篩選欄",
|
||||
"Package Registries": "套件倉庫",
|
||||
"Use only the configured package registries": "僅使用已設定的套件倉庫",
|
||||
"For a company registry such as Nexus or Artifactory: installing tools and agents never retries against the public npm registry when the configured one refuses or misses a package, and the IDE fetches nothing from Maven Central, npm, PyPI or crates.io itself (the JUnit launcher, dependency version completion).": "適用於 Nexus、Artifactory 等公司倉庫:安裝工具和 agent 時,若已設定的倉庫拒絕或找不到某個套件,不再改從公開 npm 倉庫重試;IDE 本身也不會從 Maven Central、npm、PyPI 或 crates.io 取得任何內容(JUnit 啟動器、相依版本補全)。",
|
||||
"SQL Updates": "SQL Update 陳述式",
|
||||
"SQL Deletes": "SQL Delete 陳述式",
|
||||
"Where Clause": "Where 子句",
|
||||
"SQL INSERT": "SQL INSERT 陳述式",
|
||||
"SQL UPDATE": "SQL UPDATE 陳述式",
|
||||
"SQL DELETE": "SQL DELETE 陳述式"
|
||||
}
|
||||
@@ -10592,5 +10592,23 @@
|
||||
"Semicolons": "分号",
|
||||
"Quotes": "引号",
|
||||
"For the strings and imports the TypeScript server adds.": "用于 TypeScript 服务器添加的字符串和导入。",
|
||||
"The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones.": "TypeScript 服务器将空格和标点设置用于重新格式化代码,以及它添加的代码:快速修复、导入、重构和优化导入。位于 Prettier、Biome 或 oxfmt 配置之下的文件由该工具格式化。.editorconfig 的 quote_type 和 ij_* 属性优先。TSX 文件使用 TypeScript 设置,JSX 文件使用 JavaScript 设置。"
|
||||
"The TypeScript server applies Spaces and Punctuation to Reformat Code and to the code it adds: quick fixes, imports, refactorings and organize imports. Files below a Prettier, Biome or oxfmt configuration are formatted by that tool. A .editorconfig's quote_type and ij_* properties come first. TSX files use the TypeScript settings, JSX files the JavaScript ones.": "TypeScript 服务器将空格和标点设置用于重新格式化代码,以及它添加的代码:快速修复、导入、重构和优化导入。位于 Prettier、Biome 或 oxfmt 配置之下的文件由该工具格式化。.editorconfig 的 quote_type 和 ij_* 属性优先。TSX 文件使用 TypeScript 设置,JSX 文件使用 JavaScript 设置。",
|
||||
"Show Record View": "显示记录视图",
|
||||
"Open in Value Editor": "在值编辑器中打开",
|
||||
"Show Aggregate View": "显示聚合视图",
|
||||
"Data Extractor": "数据提取器",
|
||||
"Export Table to Clipboard": "将表导出到剪贴板",
|
||||
"Keys": "键",
|
||||
"Triggers": "触发器",
|
||||
"Filter by name or type": "按名称或类型过滤",
|
||||
"Filter columns": "过滤列",
|
||||
"Package Registries": "包仓库",
|
||||
"Use only the configured package registries": "仅使用已配置的包仓库",
|
||||
"For a company registry such as Nexus or Artifactory: installing tools and agents never retries against the public npm registry when the configured one refuses or misses a package, and the IDE fetches nothing from Maven Central, npm, PyPI or crates.io itself (the JUnit launcher, dependency version completion).": "适用于 Nexus、Artifactory 等公司仓库:安装工具和 agent 时,若已配置的仓库拒绝或找不到某个包,不再改从公共 npm 仓库重试;IDE 自身也不会从 Maven Central、npm、PyPI 或 crates.io 获取任何内容(JUnit 启动器、依赖版本补全)。",
|
||||
"SQL Updates": "SQL Update 语句",
|
||||
"SQL Deletes": "SQL Delete 语句",
|
||||
"Where Clause": "Where 子句",
|
||||
"SQL INSERT": "SQL INSERT 语句",
|
||||
"SQL UPDATE": "SQL UPDATE 语句",
|
||||
"SQL DELETE": "SQL DELETE 语句"
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача