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") {
|
if (plan.destination.type === "new_workspace") {
|
||||||
const names = plan.resources.workspaces.map((w) => w.name).filter((n) => n !== "");
|
const names = plan.resources.workspaces.map((w) => w.name).filter((n) => n !== "");
|
||||||
if (names.length > 1) return pluralizeCount("new workspace", names.length);
|
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 { workspaceId, folderId } = plan.destination;
|
||||||
const name = workspaces.find((w) => w.id === workspaceId)?.name ?? "Unknown workspace";
|
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;
|
let mut n = 2;
|
||||||
loop {
|
loop {
|
||||||
let candidate = format!("{name} {n}");
|
let candidate = format!("{name} ({n})");
|
||||||
if !taken.iter().any(|t| *t == candidate) {
|
if !taken.iter().any(|t| *t == candidate) {
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
@@ -1683,13 +1683,13 @@ mod tests {
|
|||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.expect("plan second import");
|
.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
|
let warning = second
|
||||||
.warnings
|
.warnings
|
||||||
.iter()
|
.iter()
|
||||||
.find(|w| w.title == "Workspace renamed")
|
.find(|w| w.title == "Workspace renamed")
|
||||||
.expect("the rename is explained");
|
.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");
|
commit_import_plan(&query_manager, second).expect("commit second import");
|
||||||
|
|
||||||
let third = plan_import_resources(
|
let third = plan_import_resources(
|
||||||
@@ -1701,7 +1701,7 @@ mod tests {
|
|||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.expect("plan third import");
|
.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
|
let names = query_manager
|
||||||
.connect()
|
.connect()
|
||||||
@@ -1711,7 +1711,7 @@ mod tests {
|
|||||||
.map(|w| w.name)
|
.map(|w| w.name)
|
||||||
.filter(|name| name.starts_with("Imported"))
|
.filter(|name| name.starts_with("Imported"))
|
||||||
.collect::<BTreeSet<_>>();
|
.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]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user