fix(reorganize): Apply on the first click, one offer per toast, no open dialog replaced
Review of owner review 2, phase 4a (R7): the Reorganize dialogs of the desktop and the web panel. Desktop - Clicking Apply first takes the focus from the template field, which committed it and started a dry run identical to the one on screen: Apply turned off under the click. A commit now plans only when the templates differ from the shown plan (or the last dry run failed). - The Settings toast's Reorganize… disposed whatever dialog the Archive screen had open, so a running Delete stopped without being asked. An open dialog now stays and its archive is not switched; Reorganize says it waits and opens once that dialog closes, with the archive's templates read again and every part the toasts offered meanwhile. - Each Settings toast takes its own archive's offer (one pending offer per archive), and a toast gone early (dismissed, pushed out) lets the next change of that archive raise its own toast: Toast.Closed now says when a toast leaves the screen. Web panel - The Library sends the selected ids up to a thousand. all:true is used only above that, when the selection is exactly what Select all fetched without a filter and the archive has not grown since, so a sequence unticked or added later is never reorganized; otherwise the toast asks to select again. - The preview's "before" of an untitled sequence is its old name, not the new title twice. - A dry run of the same request answering during the confirmation no longer drops the confirmed apply; a plan that really changed is shown and said (Admin.Reorganize.PlanChanged). - Enter in a template plans at once (the form never submitted on Enter). - The confirm tooltip and the module header no longer say the moves are verified: moves and renames are not hashed. Strings in en and it; the reworded key exists in no other culture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit bed718fb5af2ef69943fd348690c689259872a34)
This commit is contained in:
1 parent
9ae773aa5a
commit
59ee982e4d
14 files changed
+301
-49
No files matched your search
@@ -32,9 +32,12 @@ public sealed partial class AdminReorganizeTests(TestContext context)
|
||||
Assert.Contains(@"from ""../reorganize.js""", library);
|
||||
Assert.Contains(@"data-mass=""reorganize"" data-i18n=""Admin.Reorganize.Action"" data-i18n-title=""Admin.Reorganize.Action.Tip""", library);
|
||||
Assert.Contains(@"if (action === ""reorganize"") return reorganize();", library);
|
||||
// The selection: every sequence after Select all without a filter, else the ids (one request takes a thousand).
|
||||
Assert.Contains("openReorganize({ api, target: everything ? { all: true } : { sequenceIds: [...selection.ids] }", library);
|
||||
Assert.Contains("selection.size > BULK_LIMIT", library);
|
||||
// The selection: its ids up to a thousand (one request); beyond, every sequence only while the selection is exactly
|
||||
// what Select all fetched without a filter, the archive no larger since; a sequence unticked or added is never in it.
|
||||
Assert.Contains("openReorganize({ api, target: everything ? { all: true } : { sequenceIds: ids }", library);
|
||||
Assert.Contains("const everything = ids.length > BULK_LIMIT && matching !== null && !isFiltered() && total === matching.length &&", library);
|
||||
Assert.Contains("ids.length === matching.length && matching.every((s) => selection.has(s.id));", library);
|
||||
Assert.Contains("if (!everything && ids.length > BULK_LIMIT) {", library);
|
||||
var archive = await server.Client.GetStringAsync("/admin/pages/archive.js");
|
||||
Assert.Contains(@"from ""../reorganize.js""", archive);
|
||||
Assert.Contains("target: { all: true }", archive);
|
||||
@@ -56,6 +59,16 @@ public sealed partial class AdminReorganizeTests(TestContext context)
|
||||
Assert.Contains("api.post(ENDPOINT, { ...JSON.parse(chosen.key), dryRun: false, fingerprint: chosen.fingerprint })", dialog);
|
||||
Assert.Contains("#/jobs?job=", dialog);
|
||||
Assert.True(!Regex.IsMatch(dialog, @"\son[a-z]+="""), "inline handler");
|
||||
// Enter in a template plans at once: a form of three fields and no submit button never submits on Enter.
|
||||
Assert.Contains(@"form.addEventListener(""keydown"", (e) => {", dialog);
|
||||
Assert.Contains(@"if (e.key !== ""Enter"" || e.isComposing || !(e.target instanceof HTMLInputElement) || e.target.type === ""checkbox"") return;", dialog);
|
||||
// An untitled sequence that gets a title reads by its old name before, never by the new title twice.
|
||||
Assert.Contains("const before = fromTitle ?? names.get(s.sequenceId) ?? folderName(s.fromFolder);", dialog);
|
||||
Assert.Contains(@"change(before, toTitle ?? before, ""auto"")", dialog);
|
||||
// A dry run answering during the confirmation: the same plan is applied, a different one is shown and said.
|
||||
Assert.Contains("if (plan !== chosen && (plan?.key !== chosen.key || plan.fingerprint !== chosen.fingerprint)) {", dialog);
|
||||
Assert.Contains(@"showError(t(""Admin.Reorganize.PlanChanged""))", dialog);
|
||||
Assert.True(!dialog.Contains("plan !== chosen) return;", StringComparison.Ordinal), "a confirmed apply is dropped when the same plan is answered again");
|
||||
|
||||
var en = Assert.NotNull(await server.Client.GetFromJsonAsync("/api/v1/i18n/en", ProtocolJson.Default.DictionaryStringString));
|
||||
var it = Assert.NotNull(await server.Client.GetFromJsonAsync("/api/v1/i18n/it", ProtocolJson.Default.DictionaryStringString));
|
||||
@@ -65,6 +78,10 @@ public sealed partial class AdminReorganizeTests(TestContext context)
|
||||
Assert.True(en.ContainsKey(name) && it.ContainsKey(name), key);
|
||||
}
|
||||
Assert.Equal("Riorganizza…", it["Admin.Reorganize.Action"]);
|
||||
// The job renames and moves; nothing in it hashes a file again, so nothing says it verifies them.
|
||||
Assert.False(en["Admin.Reorganize.Confirm.Tip"].Contains("verif", StringComparison.OrdinalIgnoreCase), en["Admin.Reorganize.Confirm.Tip"]);
|
||||
Assert.False(it["Admin.Reorganize.Confirm.Tip"].Contains("verific", StringComparison.OrdinalIgnoreCase), it["Admin.Reorganize.Confirm.Tip"]);
|
||||
Assert.False(Regex.IsMatch(dialog, @"^//.*\bverified\b", RegexOptions.Multiline), "the header says the moves are verified");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in new issue
Block a user