Files
wekan/client/components/settings/problemsSummary.jade
T
Lauri Ojansivu d168a9d302 Add a Repair button for "Broken cards N" in Admin Panel / Problems / Summary.
The Summary page reported "Broken cards N" and told the admin to "open the board
to auto-repair, or run the repair migration", but there was no button anywhere to
run one - and worse, no repair in the app could actually clear that count.

countBrokenCards() counts every card missing a boardId OR a swimlaneId OR a
listId. repairAllBoards() walks only NON-ARCHIVED boards and only ever sets
swimlaneId, so three kinds of counted card could never be repaired by anything:
cards on an archived board, cards with a missing listId, and cards with no
boardId at all. The count sat there forever with nothing to press.

The new repairBrokenCards method (admin only) runs the standard per-board pass
and then closes those gaps: orphaned-swimlane cards on archived boards, and cards
missing a listId and/or swimlaneId on any board, are assigned to that board's
first usable list/swimlane (creating a default one if the board has none). Each
board resolves its default list/swimlane once rather than once per card. Cards
with no boardId cannot be placed on any board - guessing would drop a user's card
onto an unrelated board - so they are reported back as `unfixable` and left
alone, never deleted, and the result line says so instead of leaving a count that
never reaches zero unexplained.

What counts as broken now lives in one pure module, models/lib/brokenCardsRepair.js,
used by BOTH the count and the repair, so they can no longer drift apart and
leave the admin pressing a button that does not move the number. Progress is
persisted through setBoardRepairStatus, so a running repair shows up in the same
"in progress" list as the startup pass.

Adds unit tests (positive + negative) for the shared rule, including the
regression itself: every card the count reports as broken must be either
repairable or explicitly unfixable, never silently neither.

Thanks to xet7 !
2026-07-24 03:23:37 +03:00

57 lines
2.2 KiB
Plaintext

template(name="problemsSummary")
.global-search-results-list-wrapper
h1 {{_ 'summary'}}
//- Status overview: migrations / repairs in progress + detected problems.
//- Same data as `snap run wekan.problems`.
if statusOverview
h2 {{_ 'problems-status-title'}}
if statusOverview.anyInProgress
p {{_ 'problems-in-progress-help'}}
.admin-problem-banner
each item in inProgress
.admin-problem-item
i.fa.fa-spinner.fa-spin
span.admin-problem-path {{item.message}}
else
p {{_ 'problems-none-in-progress'}}
if statusOverview.anyProblems
.admin-problem-banner
each problem in statusProblems
.admin-problem-item
i.fa.fa-exclamation-triangle
span.admin-problem-path {{problem.title}}
if problem.count
span.admin-problem-count {{problem.count}}
br
span.quiet {{problem.detail}}
//- Broken cards are the one detected problem the admin can fix
//- from here: run the repair migration over every board.
if isBrokenCards problem
.admin-problem-actions
button.js-repair-broken-cards.primary(disabled="{{#if repairRunning}}disabled{{/if}}")
if repairRunning
i.fa.fa-spinner.fa-spin
| {{_ 'repairing'}}
else
i.fa.fa-wrench
| {{_ 'repair-broken-cards'}}
if repairResult
br
span.quiet {{repairResult}}
h2 {{_ 'problems'}}
if hasProblems
p {{_ 'problems-summary-help'}}
.admin-problem-banner
each area in areas
label.admin-problem-item
input.js-problem-check(type="checkbox" data-stream="{{area.stream}}")
i.fa.fa-exclamation-triangle
span.admin-problem-path {{_ 'admin-panel'}} → {{_ 'problems'}} → {{areaLabel area.stream}}
span.admin-problem-count {{area.count}} {{_ 'new-problems'}}
.admin-problem-actions
button.js-ack-checked.primary {{_ 'acknowledge'}}
else
p {{_ 'no-new-problems'}}