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"))
|
||||
log(f" ✗ sync {json_name}: {err}")
|
||||
|
||||
title, body = wolf_inject.format_report_dialog(report)
|
||||
inject_state["dialog"] = (title, body)
|
||||
dialog = wolf_inject.format_report_dialog(report)
|
||||
status = wolf_inject.format_report_status(report)
|
||||
inject_state["dialog"] = dialog
|
||||
inject_state["report"] = report
|
||||
inject_state["selected"] = set(selected)
|
||||
return report.ok, title
|
||||
log(status)
|
||||
return report.ok, status
|
||||
|
||||
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")
|
||||
if report and (report.failed or report.sync_failures):
|
||||
if dialog:
|
||||
title, body = dialog
|
||||
QMessageBox.warning(self, title, body)
|
||||
elif report and report.succeeded:
|
||||
QMessageBox.information(self, title, body)
|
||||
elif body:
|
||||
QMessageBox.information(self, title, body)
|
||||
elif report is not None and not report.succeeded and not (
|
||||
report.failed or report.sync_failures
|
||||
):
|
||||
QMessageBox.information(self, "Inject", msg or "Nothing was injected.")
|
||||
# Full success: no popup (per-file detail is already in the log).
|
||||
|
||||
inject_state: dict = {}
|
||||
self._run_task(task, on_done=_after_inject)
|
||||
|
|
|
|||
|
|
@ -244,7 +244,17 @@ class InjectOrderTests(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(
|
||||
files=[
|
||||
wi.FileInjectResult("a.json", True, "applied 3 line(s)"),
|
||||
|
|
@ -252,11 +262,18 @@ class ReportDialogTests(unittest.TestCase):
|
|||
],
|
||||
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("✗ b.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__":
|
||||
|
|
|
|||
|
|
@ -516,23 +516,33 @@ def inject_selected(
|
|||
return report
|
||||
|
||||
|
||||
def format_report_dialog(report: InjectReport) -> tuple[str, str]:
|
||||
"""Return (title, body) for a completion dialog."""
|
||||
if report.ok and report.succeeded:
|
||||
title = "Inject complete"
|
||||
lines = [f"✓ {r.json_name}: {r.summary}" for r in report.succeeded]
|
||||
elif report.failed or report.sync_failures:
|
||||
title = "Inject finished with errors"
|
||||
lines = []
|
||||
for r in report.succeeded:
|
||||
lines.append(f"✓ {r.json_name}: {r.summary}")
|
||||
def format_report_dialog(report: InjectReport) -> tuple[str, str] | None:
|
||||
"""Return ``(title, body)`` for a failure dialog, or ``None`` on full success.
|
||||
|
||||
Success details already go to the workflow log; a per-file success popup
|
||||
overflows the screen on large games.
|
||||
"""
|
||||
if report.failed or report.sync_failures:
|
||||
lines: list[str] = []
|
||||
ok_n = len(report.succeeded)
|
||||
if ok_n:
|
||||
lines.append(f"{ok_n} file(s) succeeded; failures:")
|
||||
for r in report.failed:
|
||||
lines.append(f"✗ {r.json_name}: {r.summary}")
|
||||
if r.detail:
|
||||
lines.append(f" {r.detail}")
|
||||
for name, err in report.sync_failures:
|
||||
lines.append(f"✗ sync {name}: {err}")
|
||||
else:
|
||||
title = "Inject"
|
||||
lines = ["Nothing was injected."]
|
||||
return title, "\n".join(lines)
|
||||
return "Inject finished with errors", "\n".join(lines)
|
||||
return None
|
||||
|
||||
|
||||
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