Skip to content

feat(cms): connect a brand's WordPress site from Settings › Integrations (#1331) - #1571

Merged
gkhngyk merged 13 commits into
ansvisor:mainfrom
cihan-gyk:feature/cms-wordpress-web
Oct 28, 2026
Merged

gkhngyk merged 13 commits into
ansvisor:mainfrom
cihan-gyk:feature/cms-wordpress-web

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Send to CMS, phase 2 (#1331): WordPress, part 3: the Settings › Integrations card. It sits below Webflow's and follows its layout.

Stacked on #1570, which is stacked on #1569. This PR's own change is its last commit, web only.

Admins and managers connect the active brand's site with three fields:

  • Site address. Typed as people have it. The API reads it as the site: https added, /wp-admin and /wp-json taken off.
  • User.
  • Application Password. A password field, never shown again.
    • It's marked autocomplete="new-password", so the browser's password manager doesn't offer the person's saved Ansvisor password here, which would then go to the WordPress site.
    • A password too short to be an Application Password (24 letters and digits) keeps Connect off, with a hint. This catches pasting the user's own password, the usual mix-up.

The hint says where to make the password (Users › Profile › Application Passwords). It also suggests a separate Author user, since Ansvisor writes drafts only.

The API checks the site before anything is kept (#1569). Each reason has its own message (settings.wordpress.errors):

  • not WordPress, or Plain permalinks;
  • Application Passwords off;
  • the user or password refused;
  • the server dropped the Authorization header, with the two fixes;
  • users hidden;
  • a firewall;
  • a redirect;
  • a user who can't write posts.

What's typed stays in the form on a failure, the password included. Cancel is off while the site is checked.

The API's invalid (an address it can't take, or a field the form didn't fill right) says to check both the https address and that the Application Password is WordPress's.

The redirect message covers both cases. If the address is WordPress, use the address /wp-json/ goes to; if it isn't, there's no WordPress there. Found in the browser: Webflow, like www.ansvisor.com, redirects /wp-json/ to drop the slash.

Connected, the card shows:

  • Connected, the site's address, and which user it signs in as;
  • "Pages go to {site} as draft posts";
  • Change sign-in (the form, with Cancel);
  • Disconnect, behind a confirmation.
    • The API revokes the Application Password where the site allows.
    • When it couldn't, the toast says to delete it in WordPress under Users › Profile.

A refused sign-in shows Sign-in refused, with a note. The form is filled in with the site and user as they were, to paste a new password.

Members see where pages go, or that it isn't connected, with no form or buttons. A server without CONNECTOR_CREDENTIALS_KEY says WordPress isn't set up. A failed read says it couldn't be read.

lib/wordpress-client.ts calls the API through the same-origin proxy, as webflow-client.ts does. The password goes from the browser to the API once, never through a server action. Strings are in en.json (settings.wordpress).

Next: part 4, the Send dialog's WordPress target (editor, Library row, bulk), the Library reading /wordpress-status, and the "went as a new draft" note for a live post. Then the docs.

Related issue

Part of #1331 (phase 2, WordPress). Stacked on #1570 → #1569.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd web && yarn vitest run src/components/settings/wordpress-card.test.tsx src/lib/wordpress-client.test.ts
  2. With feat(cms): connect a brand's WordPress site with an Application Password and send pages to it as draft posts (#1331) #1569's API (and CONNECTOR_CREDENTIALS_KEY set), open Settings › Integrations as an admin. Below Webflow, the WordPress card asks for the site, a user and an Application Password.
    • A site that isn't WordPress says so, and no password is sent to it.
    • A real site (gkhngyk) connects and shows its address and user. Disconnect revokes the password.

Checked in the browser (this branch's API and web, against the dev DB with 00294) at 1024 px, light and dark:

  • the empty form;
  • www.ansvisor.com and ansvisor.com (our own Webflow site): the redirect message, with no password sent;
  • a connection (a temporary row): Connected, its site and user, Change sign-in with the form filled in;
  • Sign-in refused, with its note;
  • Disconnect: with no sign-in to revoke, the toast says to delete the password in WordPress. The temporary row went with it.

Screenshots follow in a comment.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run: yarn format, yarn lint (0 errors), yarn typecheck, yarn test (4,108 tests) and yarn build in web/. After the pre-push review's fixes (the password field, the short-password hint, Cancel while checking, a disconnect while changing the sign-in, the invalid wording, and tests for a brand switch and a revoked password), I ran the card's tests, eslint, typecheck and the format check again. ERROR_TEXTS: Record<WordPressError, string> in the test makes a missing error string a typecheck error.

🤖 Generated with Claude Code

cihan-gyk and others added 3 commits October 27, 2026 10:18
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 27, 2026
cihan-gyk and others added 4 commits October 28, 2026 03:07
… has ended

Since ansvisor#1589 a workspace whose plan has ended can't write, but taking back an
outside account's access stays open (COST_STOPPING), as Webflow's disconnect
does. WordPress's disconnect revokes the Application Password where the site
allows, so it joins the list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Merged #1570's new head in (acc9086). integrations-section.tsx: main groups the cards now, so the WordPress card sits in the CMS group under Webflow, with main's Merchant Center imports kept. Checks: typecheck on every web tip, the server suite at #1579 (3,522 tests), and the whole web suite (4,438 tests) and yarn build at #1580.

…space is read-only

Connect and Change sign-in open it before anything is sent, and a connect
or disconnect the API refuses for the plan opens it instead of saying
WordPress couldn't be reached. Disconnect stays open, as Webflow's.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with 3f79126: I opened the plan dialog from the WordPress card in a read-only workspace

Reviewed this PR's own change (#1570's head da8e326 → acc9086). It merges clean on main cfd8a35, but was written before main's read-only workspace (#1599, #1609).

What I changed (main merged in, then one commit)

  • In a workspace whose plan has ended, the card said "Couldn't reach WordPress. Try again later." for a connect: the client mapped the API's subscription_inactive to failed. Now it works the way the Webflow card does. Connect and Change sign-in open the plan dialog before anything is sent. A connect or disconnect the API refuses for the plan opens the dialog instead of a toast. Disconnect stays open, since it only ends an access.
  • Tests: wordpress-client.test.ts maps a 402 subscription_inactive to subscription. Two new card tests cover a refused connect and disconnect, and the read-only gate (Connect and Change sign-in blocked, Disconnect still works). Without the fix, all three fail.

What I checked

  • The password field is type="password" with autoComplete="new-password". It's cleared after a connect and never shown again. The API answer has no password to show.
  • Connect, Change sign-in and Disconnect show for admins and managers only (canManage). The server enforces this too (#1569). Members see where pages go.
  • A connection read for one brand never shows under another (read.brandId === activeBrandId).
  • English copy: the error texts cover every code the client names. A missing one fails typecheck through ERROR_TEXTS.
  • Tests on this tree: wordpress-card and wordpress-client (16 passed). Web tsc, eslint and prettier are clean.

Follow-ups

  1. SignInForm isn't keyed by brand. Switching brands while both show the form keeps what was typed for the first brand, and Connect would then send it for the second. key={activeBrandId} on the form fixes it.

@gkhngyk
gkhngyk merged commit 6b38c2b into ansvisor:main Oct 28, 2026
4 of 5 checks passed
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 28, 2026
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