mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-09-09 19:31:57 +02:00
fix(import): parenthesize the number on a taken workspace name
"Name 2" reads as part of the name; "Name (2)" reads as the second one. The destination row leads with "New workspace ·" rather than trailing a second parenthetical after it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
83f2606624
commit
cdc034b25a
@@ -312,7 +312,7 @@ function LoadedImportDataDialog({
|
||||
if (plan.destination.type === "new_workspace") {
|
||||
const names = plan.resources.workspaces.map((w) => w.name).filter((n) => n !== "");
|
||||
if (names.length > 1) return pluralizeCount("new workspace", names.length);
|
||||
return names[0] == null ? "New workspace" : `${names[0]} (new workspace)`;
|
||||
return names[0] == null ? "New workspace" : `New workspace · ${names[0]}`;
|
||||
}
|
||||
const { workspaceId, folderId } = plan.destination;
|
||||
const name = workspaces.find((w) => w.id === workspaceId)?.name ?? "Unknown workspace";
|
||||
|
||||
@@ -1251,7 +1251,7 @@ fn unique_name(name: &str, taken: &[String]) -> String {
|
||||
}
|
||||
let mut n = 2;
|
||||
loop {
|
||||
let candidate = format!("{name} {n}");
|
||||
let candidate = format!("{name} ({n})");
|
||||
if !taken.iter().any(|t| *t == candidate) {
|
||||
return candidate;
|
||||
}
|
||||
@@ -1683,13 +1683,13 @@ mod tests {
|
||||
None,
|
||||
)
|
||||
.expect("plan second import");
|
||||
assert_eq!(second.resources.workspaces[0].name, "Imported 2");
|
||||
assert_eq!(second.resources.workspaces[0].name, "Imported (2)");
|
||||
let warning = second
|
||||
.warnings
|
||||
.iter()
|
||||
.find(|w| w.title == "Workspace renamed")
|
||||
.expect("the rename is explained");
|
||||
assert_eq!(warning.detail, "Imported → Imported 2 · that name is taken");
|
||||
assert_eq!(warning.detail, "Imported → Imported (2) · that name is taken");
|
||||
commit_import_plan(&query_manager, second).expect("commit second import");
|
||||
|
||||
let third = plan_import_resources(
|
||||
@@ -1701,7 +1701,7 @@ mod tests {
|
||||
None,
|
||||
)
|
||||
.expect("plan third import");
|
||||
assert_eq!(third.resources.workspaces[0].name, "Imported 3");
|
||||
assert_eq!(third.resources.workspaces[0].name, "Imported (3)");
|
||||
|
||||
let names = query_manager
|
||||
.connect()
|
||||
@@ -1711,7 +1711,7 @@ mod tests {
|
||||
.map(|w| w.name)
|
||||
.filter(|name| name.starts_with("Imported"))
|
||||
.collect::<BTreeSet<_>>();
|
||||
assert_eq!(names, BTreeSet::from(["Imported".to_string(), "Imported 2".to_string()]));
|
||||
assert_eq!(names, BTreeSet::from(["Imported".to_string(), "Imported (2)".to_string()]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user