We dont need this window
This commit is contained in:
parent
fb628f5f85
commit
5ff504e549
3 changed files with 57 additions and 26 deletions
|
|
@ -3624,21 +3624,25 @@ class WolfWorkflowTab(QWidget):
|
||||||
report.sync_failures.append((json_name, err or "unknown error"))
|
report.sync_failures.append((json_name, err or "unknown error"))
|
||||||
log(f" ✗ sync {json_name}: {err}")
|
log(f" ✗ sync {json_name}: {err}")
|
||||||
|
|
||||||
title, body = wolf_inject.format_report_dialog(report)
|
dialog = wolf_inject.format_report_dialog(report)
|
||||||
inject_state["dialog"] = (title, body)
|
status = wolf_inject.format_report_status(report)
|
||||||
|
inject_state["dialog"] = dialog
|
||||||
inject_state["report"] = report
|
inject_state["report"] = report
|
||||||
inject_state["selected"] = set(selected)
|
inject_state["selected"] = set(selected)
|
||||||
return report.ok, title
|
log(status)
|
||||||
|
return report.ok, status
|
||||||
|
|
||||||
def _after_inject(ok: bool, msg: str):
|
def _after_inject(ok: bool, msg: str):
|
||||||
title, body = inject_state.get("dialog", ("Inject", msg))
|
dialog = inject_state.get("dialog")
|
||||||
report = inject_state.get("report")
|
report = inject_state.get("report")
|
||||||
if report and (report.failed or report.sync_failures):
|
if dialog:
|
||||||
|
title, body = dialog
|
||||||
QMessageBox.warning(self, title, body)
|
QMessageBox.warning(self, title, body)
|
||||||
elif report and report.succeeded:
|
elif report is not None and not report.succeeded and not (
|
||||||
QMessageBox.information(self, title, body)
|
report.failed or report.sync_failures
|
||||||
elif body:
|
):
|
||||||
QMessageBox.information(self, title, body)
|
QMessageBox.information(self, "Inject", msg or "Nothing was injected.")
|
||||||
|
# Full success: no popup (per-file detail is already in the log).
|
||||||
|
|
||||||
inject_state: dict = {}
|
inject_state: dict = {}
|
||||||
self._run_task(task, on_done=_after_inject)
|
self._run_task(task, on_done=_after_inject)
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,17 @@ class InjectOrderTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
class ReportDialogTests(unittest.TestCase):
|
class ReportDialogTests(unittest.TestCase):
|
||||||
def test_failure_dialog_lists_every_problem(self):
|
def test_success_has_no_dialog(self):
|
||||||
|
report = wi.InjectReport(
|
||||||
|
files=[
|
||||||
|
wi.FileInjectResult("a.json", True, "applied 3 line(s)"),
|
||||||
|
wi.FileInjectResult("b.json", True, "no changes needed"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
self.assertIsNone(wi.format_report_dialog(report))
|
||||||
|
self.assertEqual(wi.format_report_status(report), "Inject complete: 2 file(s).")
|
||||||
|
|
||||||
|
def test_failure_dialog_lists_only_problems(self):
|
||||||
report = wi.InjectReport(
|
report = wi.InjectReport(
|
||||||
files=[
|
files=[
|
||||||
wi.FileInjectResult("a.json", True, "applied 3 line(s)"),
|
wi.FileInjectResult("a.json", True, "applied 3 line(s)"),
|
||||||
|
|
@ -252,11 +262,18 @@ class ReportDialogTests(unittest.TestCase):
|
||||||
],
|
],
|
||||||
sync_failures=[("c.json", "permission denied")],
|
sync_failures=[("c.json", "permission denied")],
|
||||||
)
|
)
|
||||||
title, body = wi.format_report_dialog(report)
|
dialog = wi.format_report_dialog(report)
|
||||||
|
self.assertIsNotNone(dialog)
|
||||||
|
title, body = dialog
|
||||||
self.assertIn("errors", title)
|
self.assertIn("errors", title)
|
||||||
self.assertIn("✗ b.json", body)
|
self.assertIn("✗ b.json", body)
|
||||||
self.assertIn("✗ sync c.json", body)
|
self.assertIn("✗ sync c.json", body)
|
||||||
self.assertIn("✓ a.json", body)
|
self.assertNotIn("✓ a.json", body)
|
||||||
|
self.assertIn("1 file(s) succeeded", body)
|
||||||
|
self.assertEqual(
|
||||||
|
wi.format_report_status(report),
|
||||||
|
"Inject: 1 ok, 2 failed (see dialog).",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -516,23 +516,33 @@ def inject_selected(
|
||||||
return report
|
return report
|
||||||
|
|
||||||
|
|
||||||
def format_report_dialog(report: InjectReport) -> tuple[str, str]:
|
def format_report_dialog(report: InjectReport) -> tuple[str, str] | None:
|
||||||
"""Return (title, body) for a completion dialog."""
|
"""Return ``(title, body)`` for a failure dialog, or ``None`` on full success.
|
||||||
if report.ok and report.succeeded:
|
|
||||||
title = "Inject complete"
|
Success details already go to the workflow log; a per-file success popup
|
||||||
lines = [f"✓ {r.json_name}: {r.summary}" for r in report.succeeded]
|
overflows the screen on large games.
|
||||||
elif report.failed or report.sync_failures:
|
"""
|
||||||
title = "Inject finished with errors"
|
if report.failed or report.sync_failures:
|
||||||
lines = []
|
lines: list[str] = []
|
||||||
for r in report.succeeded:
|
ok_n = len(report.succeeded)
|
||||||
lines.append(f"✓ {r.json_name}: {r.summary}")
|
if ok_n:
|
||||||
|
lines.append(f"{ok_n} file(s) succeeded; failures:")
|
||||||
for r in report.failed:
|
for r in report.failed:
|
||||||
lines.append(f"✗ {r.json_name}: {r.summary}")
|
lines.append(f"✗ {r.json_name}: {r.summary}")
|
||||||
if r.detail:
|
if r.detail:
|
||||||
lines.append(f" {r.detail}")
|
lines.append(f" {r.detail}")
|
||||||
for name, err in report.sync_failures:
|
for name, err in report.sync_failures:
|
||||||
lines.append(f"✗ sync {name}: {err}")
|
lines.append(f"✗ sync {name}: {err}")
|
||||||
else:
|
return "Inject finished with errors", "\n".join(lines)
|
||||||
title = "Inject"
|
return None
|
||||||
lines = ["Nothing was injected."]
|
|
||||||
return title, "\n".join(lines)
|
|
||||||
|
def format_report_status(report: InjectReport) -> str:
|
||||||
|
"""One-line status for the log / status bar after inject."""
|
||||||
|
ok_n = len(report.succeeded)
|
||||||
|
fail_n = len(report.failed) + len(report.sync_failures)
|
||||||
|
if fail_n:
|
||||||
|
return f"Inject: {ok_n} ok, {fail_n} failed (see dialog)."
|
||||||
|
if ok_n:
|
||||||
|
return f"Inject complete: {ok_n} file(s)."
|
||||||
|
return "Inject: nothing was injected."
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue