Skip to content

Extract shared DeletePageDialog; fix delete-button styling and Special:Schemas i18n#1129

Merged
JeroenDeDauw merged 6 commits into
masterfrom
refactor/delete-page-dialog
Jul 22, 2026
Merged

Extract shared DeletePageDialog; fix delete-button styling and Special:Schemas i18n#1129
JeroenDeDauw merged 6 commits into
masterfrom
refactor/delete-page-dialog

Conversation

@alistair3149

@alistair3149 alistair3149 commented Jul 22, 2026

Copy link
Copy Markdown
Member

Extracts the page-deletion confirmation shared by Special:Schemas, Special:Layouts, and Special:Mappings into one component, and fixes two bugs found.

What this changes

  • New components/common/DeletePageDialog.vue — a self-contained confirmation dialog (CdxDialog + generic delete message + a SummaryAction footer configured destructive + trash icon with a "Reason" field) that performs action=delete and notifies. Replaces three byte-identical dialogs + executeDelete bodies.
  • Fix — the confirm button was progressive (blue) + checkmark; now destructive (red) + trash icon. All three pages inherited the wrong styling because the confirm button defaulted to progressive/cdxIconCheck.
  • Fix — Special:Schemas delete UI rendered raw message keys. Root cause was ResourceLoader registration, not missing messages: the neowiki-schema-delete-* dialog keys and the neowiki-schema-delete aria-label were absent from the ext.neowiki module's messages list. The refactor replaces the per-entity dialog keys with a single generic neowiki-delete-* set (registered once) and registers the orphaned neowiki-schema-delete.
  • Rename EditSummarySummaryAction (no longer edit-specific) + add optional label/placeholder props so the delete dialog can label the field "Reason".
  • i18n — retire the 18 per-entity neowiki-{schema,layout,mapping}-delete-{confirm-*,summary-default,success,error} keys for ~8 generic ones. The confirmation message names the entity type ("The mapping EDM will be deleted") — it avoids exposing that a Schema/Layout/Mapping is stored as a page, and drops "permanently" (untrue for MediaWiki's soft delete). Each page supplies its noun via neowiki-{schema,layout,mapping}-noun. Per-entity row-button aria-labels (neowiki-<entity>-delete) stay, since the trigger button lives on each page.

Commits (ordered for review)

  1. Rename EditSummarySummaryAction (pure rename).
  2. Add label/placeholder props to SummaryAction.
  3. New DeletePageDialog + generic neowiki-delete-* messages.
  4. Migrate the three pages, retire per-entity keys, register neowiki-schema-delete.
  5. Review fixes (LayoutsPage delete-wiring test + spec-helper rename).
  6. Name the entity type in the confirmation message (drop "page"/"permanently").

Judgment calls

  • SummaryAction stays bundled (field + button); no reshape. Splitting the button out to use CdxDialog's native primaryAction/defaultAction was considered but rejected: those props are label-only and cannot carry the trash/checkmark icons these buttons rely on.
  • Deletion behaviour is preserved — close-on-confirm, default-reason fallback, success/error notify, refetch on @deleted.
  • Per-entity row aria-labels stay ("Delete schema", …) — more informative for screen readers than a generic "Delete", and the button is page-specific.

Known / out of scope

  • Error-notification shape (pre-existing). The error instanceof Error ? … : String(error) handler is carried over verbatim; mw.Api().post() rejects with a (code, result) pair, so a real API failure shows a raw code. This predates the PR and affects every create/delete dialog uniformly — left for a separate fix.
  • public-api.ts breaking rename. The EditSummary export becomes SummaryAction. No in-repo consumer imports it and NeoWiki is pre-production, but an external extension importing EditSummary would break — heads-up for HW.

Verification

make ts-build, make ts-lint, and the full vitest suite (110 files, 1109 tests) pass. New/updated tests: DeletePageDialog.spec (delete flow + destructive/trash wiring), SummaryAction label/placeholder cases, LayoutsPage.spec (delete wiring), and the Schemas/Mappings page specs.

Manual Browser Check

Verified live on the dev wiki as an admin. To reproduce on each of Special:Schemas, Special:Mappings, Special:Layouts:

  1. Open the special page and confirm it renders real text — no raw ⟨neowiki-…⟩ keys (this was broken on Schemas, including the row Delete button's label).
  2. Click a row's Delete (trash) button. The confirmation dialog should show:
    • Title "Delete <name>?" and body "The <type> <name> will be deleted." with the name in bold and the type noun matching the page (e.g. "The mapping EDM will be deleted." on Mappings) — no "page", no "permanently".
    • A collapsible "Reason (optional)" field (not "Edit summary").
    • A red (destructive) "Delete" button with a trash icon — not a blue button with a checkmark.
  3. (Optional) Expand "Reason", type a reason, confirm — the page is deleted, a success toast shows, and the list refreshes.

Verified end-to-end: Schemas ("The schema Company will be deleted."), Mappings ("The mapping EDM will be deleted."), Layouts ("The layout CompanyOverview will be deleted."). Nothing was actually deleted during verification.

AI-authored — Claude Code, Opus 4.8 (1M context). Diff not yet human-reviewed; ts-build/lint + full vitest suite green locally, live-verified end-to-end on the dev wiki (all three pages), plus an adversarial code-review pass (2 findings fixed, 2 noted above).

alistair3149 and others added 6 commits July 22, 2026 12:43
The component backs the save/create dialogs today and will also back the
delete confirmation dialogs, so the edit-specific name no longer fits.

Pure mechanical rename: the component symbol, its file, its LESS class
prefix, and the public-api export. The neowiki-edit-summary-* message
keys are left unchanged — they remain the component's default label.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The field is hardwired to the "Edit summary" wording. To let the delete
confirmation dialog reuse this component and label the field a "reason",
expose optional `label` and `placeholder` props that fall back to the
existing edit-summary messages, so every current caller is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extract the page-deletion confirmation shared by Special:Schemas,
Special:Layouts, and Special:Mappings into a self-contained component: a
confirmation dialog wrapping SummaryAction (destructive action + trash
icon, "reason" label) that performs the delete via the API and notifies.

Introduce a generic neowiki-delete-* message set keyed on the page name,
replacing the need for per-entity delete wording. The three pages are
migrated onto this component in the following commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the duplicated delete-confirmation dialog and executeDelete
logic in all three special pages with the shared DeletePageDialog, and
retire the 18 now-unused per-entity delete messages in favour of the
generic neowiki-delete-* set. The per-entity row-button aria-labels
(neowiki-<entity>-delete) stay, since the trigger button lives on each
page.

Also register neowiki-schema-delete, which was defined but never added
to the ResourceLoader module: the Schemas delete button aria-label (and,
via the old per-entity keys, its whole confirmation dialog) rendered raw
message keys. This is the reported "Special:Schemas is missing the i18n
messages" bug.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Add LayoutsPage.spec.ts. LayoutsPage had no spec, so its delete wiring
  (`Layout:${name}` -> DeletePageDialog) was the one untested page after
  the migration; a wrong namespace prefix could ship silently. Mirrors
  the Schemas/Mappings "opens the delete confirmation" coverage.
- Rename the leftover mountDialogWithRealEditSummary helper in
  MappingCreatorDialog.spec.ts to mountDialogWithRealSummaryAction.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
"The page EDM will be permanently deleted" was doubly wrong: users do
not necessarily know a Schema/Layout/Mapping is stored as a page, and
"permanently" is false in MediaWiki (a deleted revision is retained and
can be undeleted).

The message now reads "The <type> <name> will be deleted" (e.g. "The
mapping EDM will be deleted"), with the name kept bold. DeletePageDialog
gains a typeLabel prop; each page passes its entity noun via the new
neowiki-{schema,layout,mapping}-noun messages.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alistair3149

alistair3149 commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

Manually tested the delete and create flow.
There are no regression and the delete reason appears in the log.

image

@alistair3149
alistair3149 marked this pull request as ready for review July 22, 2026 17:51
@JeroenDeDauw
JeroenDeDauw merged commit 5ab228e into master Jul 22, 2026
12 checks passed
@JeroenDeDauw
JeroenDeDauw deleted the refactor/delete-page-dialog branch July 22, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants