Skip to content

fix(platform): apply the row menu's rule to contact bulk delete - #4215

Merged
yannickmonney merged 3 commits into
mainfrom
fix/contacts-bulk-delete-synced-eligibility
Oct 4, 2026
Merged

yannickmonney merged 3 commits into
mainfrom
fix/contacts-bulk-delete-synced-eligibility

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What changed

A synced contact (source salesforce, hubspot, conversation, …) offers no Edit or Delete in its row menu, but the contacts list gave every row a checkbox and handed the raw selection to BulkDeleteBar: ticking the synced row and choosing Delete selected trashed it. A Member, who cannot write, got checkboxes too.

  • One rule, three surfaces. canEditContact(ability, contact) in contacts/lib/contact-data.ts (a writer, on a contact entered or uploaded in Tale) is now what the row menu, the details dialog and the list ask. isEditableContact stays as its private half.
  • Selection. ContactsTable passes it as the per-row enableRowSelection predicate the DataTable already supports (members and projects lists use the same mechanism). A synced row renders no checkbox, not a disabled one, and Select all skips it.
  • Deletion. The table and BulkDeleteBar get the selection without any loaded contact that fails the rule. This covers a contact that a sync took over after it was ticked (PATCH /api/v1/contacts/{id} can change source) and a member who loses write access mid-session: neither can be deleted. An id that is no longer loaded stays selected, as before, so the count does not shrink while a delete's own refetch removes rows.
  • Design system (@tale/ui). When no row on the page can be selected, createSelectColumn used to drop the select-all box and leave an empty <th> (axe empty-table-header). This change made that state reachable on contacts (a synced-only page, a Member's view). The header now carries the column's per-row name, Select row (common.aria.selectRow, already in en/de/fr), the same way the expander column's header reads "Expand row". The members list gets the same fix when it shows only you.

Decision: the app route stays as it is

DELETE /api/app/contacts/:id still trashes a contact of any source. It shares deleteContact with the documented DELETE /api/v1/contacts/{id}, which the issue puts out of scope. The app's update route (POST /api/app/contacts/:id) has the same shape, and source ownership is a UI rule today: "the source would overwrite a local change", not an authorization rule. To make it a server refusal, both writes would need a code of their own, en/de/fr copy and a product decision on what an Editor may clean up (for example junk conversation contacts). I'd suggest a separate issue for that. After this change, both UI paths follow the same rule.

Sweep

  • Accessibility. No disabled checkbox exists: an unselectable row renders none, as the design system intends. axe runs clean on mixed rows and on a page where no row can be selected (the new test file). The empty header is fixed as described above.
  • en/de/fr. No new string. The header reuses common.aria.selectRow, which is present in every catalog.
  • Docs. No page described the source rule or bulk delete. knowledge/structured-data.md now says, in en, de and fr, which contacts can be edited or deleted, and that synced rows have no checkbox.
  • Manual register. New box KNOW-B21 (the real stack, the REST-seeded synced contact, the stale-selection PATCH, Member view and screen-reader name), plus its 🔶 component row in reference/automation.md. The agent note and the suite's Cost line are updated.

How I verified it

Code proof is at db9a71e5f. The head 3a4ed6229 only rewords one German docs sentence; the full docs suite (38 files, 254 tests) and lint:links were rerun there.

  • Regression test that fails on main. contact-table.bulk-delete.test.tsx uses the real column config, row menu, selection and bulk bar; only the backend hooks are stubbed. At 6524150fe (origin/main), 5 of 6 tests fail: the synced row has a checkbox, Select all puts every contact in the bar, a Member gets checkboxes, and the no-selectable-row page has checkboxes. With the fix, 6 of 6 pass. The manual-import control keeps both Delete and its checkbox.
  • DS test. data-table.test.tsx gets "names the select column when no row can be selected". It fails against main's column-builders.tsx and passes with the change.
  • bunx vitest run --config vitest.ui.config.ts app/features/contacts …/member-table.test.tsx …/projects-table.test.tsx …/teams-table.test.tsx: 16 files, 130 tests passed.
  • packages/ui: vitest --project unit data-table.test.tsx data-table-bulk-actions.test.tsx: 69 passed.
  • services/docs: full vitest --run: 38 files, 254 tests passed.
  • Type-aware oxlint and oxfmt --check on every changed TS file are clean. An isolated tsc over the changed platform files (with app/router.tsx and the global declarations) and over the changed UI files is clean.
  • bun run knip:check, bun run lint:links, bun run lint:manual (1443 boxes) and check-guide.ts on knowledge.md all pass.

Not run here: a browser, the stack, E2E, the test:browser project, the whole-platform suites and the full type check. CI owns those. Backend integration is not in scope, since no backend file changed.

Closes #3623

When every loaded row fails a table's `enableRowSelection` predicate,
`createSelectColumn` drops the select-all box and left the column's
`<th>` with no text (axe `empty-table-header`), the failure the
DataTable already fixes for the expander, action and skeleton select
headers. The header now carries the column's per-row name, "Select row"
(`common.aria.selectRow`, present in every locale), as the expander
column reads "Expand row".

Contacts reaches this once synced rows lose their checkboxes (a
synced-only page, a member who cannot write); the members list reaches
it already when it shows only you.
A synced contact (source salesforce, hubspot, conversation, …) offers no
Edit or Delete in its row menu, yet the contacts list gave every row a
checkbox and handed the raw selection to `BulkDeleteBar`, so ticking it
and choosing Delete selected trashed it. A member who cannot write got
checkboxes too.

The rule now has one home, `canEditContact(ability, contact)` (a writer,
on a manually entered or uploaded contact), and the row menu, the details
dialog and the list all ask it:

- `enableRowSelection` takes it per row, so a synced row renders no
  checkbox (never a disabled one) and Select all skips it;
- the table and the bar get the selection without any loaded contact
  that fails it, so a contact a sync took over after it was ticked (or a
  member who lost write access) is never deleted. An id no longer loaded
  stays, as before, so the count holds while a delete refetches.

The app's DELETE route is unchanged: it shares `deleteContact` with the
documented REST door, the update route has the same shape, and source
ownership becomes a server refusal only with its own code and copy.

The manual register gains KNOW-B21 and its automation row; the contacts
docs say which contacts can be edited or deleted, in en, de and fr.

Closes #3623
After the colon, the capitalised possessive read like the formal "Ihr" in a du-form page; the sentence now stands on its own.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent review verdict: accept

Reviewed exact head 3a4ed62292ffd1f9fa87f6acf47da950dddddac2. The single canEditContact rule consistently gates the row menu, details dialog, row selection, and bulk-delete bar; synced rows are not selectable, Select all skips them, and loaded selections are filtered again when eligibility changes. The @tale/ui Select row header fallback is scoped to the select column and addresses the no-selectable-row header case without affecting other tables.

The decision to leave DELETE /api/app/contacts/:id unchanged is correct for this UI-scoped issue: the route is shared and currently treats source ownership as a UI rule, not a server authorization rule. A separate server-side follow-up is warranted only as a product/security decision covering both app and REST write doors, including which source-owned contact classes Editors may clean up; it is not a blocker here.

Evidence checked: author evidence TALE-359 comment 07138b0f, PR diff, focused design-system test (56 passed). Unrun proof: the focused contact-table suite could not collect because the existing workspace dependency setup throws TypeError: undefined is not an object (evaluating 'z.number') in packages/shared/src/schemas/epoch-ms.ts; no browser, E2E, or CI was run.

@yannickmonney
yannickmonney merged commit bd2275c into main Oct 4, 2026
@yannickmonney
yannickmonney deleted the fix/contacts-bulk-delete-synced-eligibility branch October 4, 2026 05:31
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.

Bug: Bulk delete bypasses the synced-contact restriction enforced by row actions

1 participant