oliver-zehentleitner / maity
clean-up: web forms: one field-refusal helper, statusLine.ok, one field builder
tsk-d2mm4pwvwzza Open
From the web clean-up audit, area 17 (tsk-hgnbapyw7hnh), read at 80647565 (findings sent to lotse, seq 125512, 125528, 125544). Line numbers are from 80647565, so re-check them on current main. Four findings describe one missing shared layer for form feedback.
#32 Project views: refusal words translated a second time (duplication).
- board-edit.js:21-34 has a REFUSALS map for invalid_transition, dependencies_open, not_holder, lease_active, release_not_ready and project_closed.
- forge.js:38-46 covers secret_key_missing, forge_app_missing and forge_unavailable.
- Per-view helpers do the same: memory.js:18, project-message.js:28, ticker.js:115, board.js:176 (hubWords), board.js:390 (editError), contract.js:39.
- ApiError already translates these codes through M.errorWords (api.js:19, errors.js CODES). Each code therefore has two catalog entries (cards.refused. or forge.back. next to error.*) that can drift.
- Proposal: drop the codes errors.js already covers.
- Effort M. Risk low: wording.
#65 Admin, auth-pages, register, landing, site-io: field refusals formatted nine ways (duplication).
- Where:
- admin-maintenance.js:24-29 (fieldError)
- instance-admin.js:26-30 (mailError)
- admin-registration.js:56-60 (said) and 185-195
- admin-limits.js:113-131
- admin-sign-in.js:82-83, 116-117 and 190-196
- auth-pages.js:39-43 (refusal)
- register.js:156
- site-io.js:83-86 (refusalWords, a copy of auth-pages.js:39-43) and site-io.js:161
- landing.js:331-348 (showErrors)
- Some translate the reason through a local REASONS map. auth-pages, register and site-io show the raw English "field: reason".
- Proposal: one M.fieldRefusal(err, {reasons, labels, at: {key: node}}) in errors.js, which writes each error at its field and returns the rest as the status message.
- Effort M. Risk low-medium: wording, smoke assertions.
#52 Account, new project, report and others: field errors hand-rolled in every form (duplication).
- The same builder (label, input, hint, a p.field-error with id-error, aria-invalid) appears in:
- account.js:353-369 and new-project.js:86-90, each with its own showErrors (account.js:365, new-project.js:198)
- handles.js:34, step-up.js:66, landing.js:161, public-page.js:75, app.js:598, admin-limits.js:84, admin-sign-in.js:136
- notify-settings.js writes its own error map and fail closure at 79-85, 145-152, 299-304, 398/409 and 784/806/818. report.js does the same at 84-87.
- The guard "err.code is invalid and err.details.fields is set" appears 50+ times.
- Proposal: M.dom.field(id, label, input, hint) returning {nodes, fail, clear}, plus M.dom.invalidFields(err), next to the helper of #65.
- Effort M. Risk low-medium: ids and aria-describedby must stay for smoke and e2e.
#51 All views: "saved" built by hand about 50 times, "unchanged" said two ways (duplication).
- statusLine (app.js:171-182) has busy, done and fail, but no success method. So each view calls status.done() and then appends its own span.ok.
- Copies:
- notify-settings.js: 11 (e.g. 99, 107-108, 334, 341-342, 422, 504, 808, 815, 849)
- account.js: 3 (84, 397, ...)
- sessions.js, preferences.js, second-factor.js and your-data.js: one each
- orgs.js:237 says "unchanged" with status.busy(...), while notify-settings.js:99/334/808 and account.js:84 use done() plus an ok span.
- Proposal: statusLine.ok(words), replaced mechanically.
- Effort S-M. Risk low.
Order:
- First #51 and the helper of #65 and #52 (one PR).
- Then move the views over, in groups (project views, admin, account).
- The admin settings-form card and the account card touch the same files. Coordinate with them or go first.