Repository navigation
Settings: Move the Comments settings into the settings panel - #54903
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 7 files. Only the first 5 are listed here.
4 files are newly checked for coverage.
Full summary · PHP report · JS report Coverage check overridden by
Covered by non-unit tests
|
d368df3 to
71248b3
Compare
dhasilva
left a comment
There was a problem hiding this comment.
I reviewed the three commits on top of #54891 (efdf1ad, 71248b3, 95b6a69) at 95b6a69. I found no blockers and left three suggestions inline.
What I ran, in a worktree at the head: the my-jetpack settings-panel Jest suites (10 suites, 90 tests), the Jetpack plugin's test-gui (74 suites, 721 tests) and test-client (54 suites, 851 tests), and my-jetpack tsgo. Everything passes, and CI's Static analysis jobs are green. I did not click through it on a live site.
Checked and fine:
- Only admins reach the
#/discussion→ panel redirect, because non-admins getNonAdminViewbefore the route switch. - The nav tab change sits inside the
userCanManageModulesbranch. isModuleFound()returns false for a module that isn't loaded, so the destructure inpointTo()can't hitundefined.- Features search matches the translated module name, so
search={ name }works in every locale, as it does in Composing. - Comments, Comment Likes and Gravatar Hovercards all have Features rows (in the Engagement group).
isInSettingsPanel()gives the same result as the old checks at all three call sites.
Description: it says to review only the last commit, but this PR has three commits on top of #54891. Also, #54893 has merged, so the offline crash note under Testing instructions can go.
Generated by Claude.
| const blocksAvailable = | ||
| ( getScriptData() as JetpackPluginScriptData | undefined )?.jetpack | ||
| ?.isCommentBlocksAvailable === true; |
There was a problem hiding this comment.
[suggestion] The module already tells the panel whether blocks are available, so the new script-data key isn't needed. enable_blocks_comments joined the /jetpack/v4 options in #53031, in the same commit that added isCommentBlocksAvailable. So an option that is missing from $module.options is exactly the "older plugin" case. Comments::is_enabled() is false only for blog 522232 on WordPress.com, which never renders My Jetpack. Carousel already works this way: it hides its colour select when Jetpack sends no choices.
| const blocksAvailable = | |
| ( getScriptData() as JetpackPluginScriptData | undefined )?.jetpack | |
| ?.isCommentBlocksAvailable === true; | |
| const blocksAvailable = | |
| ! Array.isArray( $module.options ) && undefined !== $module.options?.enable_blocks_comments; |
With that change, the JetpackPluginScriptData type, the getScriptData import and the PHP lines in class-jetpack-script-data.php can all go. That removes the plugin→package contract. It also means a Jetpack release from after #53031 but before this PR shows the option instead of hiding an option that works. The three it.each rows would then vary the module's options instead of window.JetpackScriptData.
Generated by Claude.
There was a problem hiding this comment.
Done in f472875: the panel checks $module.options for enable_blocks_comments. The script-data key, type and PHP lines are gone, and the test rows vary the options.
| $data['jetpack']['themeSupports'] = array( | ||
| 'infiniteScroll' => self::theme_supports_infinite_scroll(), | ||
| ); | ||
| $data['jetpack']['isCommentBlocksAvailable'] = Comments::is_enabled(); |
There was a problem hiding this comment.
[suggestion] This line (and the use on L12) can go if the panel reads $module.options instead, as suggested on comments.tsx L30–32.
Generated by Claude.
| setPending( value ); | ||
| const result = queue.current.then( () => send( value ) ); | ||
| queue.current = result; |
There was a problem hiding this comment.
[suggestion] The queue never holds more than one save. comments.tsx disables the field while isSaving, so no second blur can start a save while one is running. (Google Analytics needs its queue because its switches stay enabled while the ID saves.) Without the queue, this hook is useModuleSetting() from use-module-option.ts with a String parse, except that it reports whether the save worked.
If useModuleSetting's setValue resolves to true/false (add return true; in the try and return false; in the catch; its three callers ignore the result), the panel can use:
const prompt = useModuleSetting( $module, 'highlander_comment_form_prompt', v => String( v ?? '' ) );
const { value: storedPrompt, setValue: savePrompt } = prompt;Then this file can go, leaving one copy of the POST and its notices instead of two. I tried this in a worktree: all 90 settings-panel tests pass, including comments.test.tsx unchanged, and tsgo is clean.
Generated by Claude.
There was a problem hiding this comment.
Done in f472875: useModuleSetting's setValue resolves to true/false, the panel uses it with a String parse, and use-module-text-setting.ts is gone.
| "rules": [ | ||
| { "destination": "admin.php?page=my-jetpack&p=%2Ffeatures%3Fconfigure%3Dcomments" } | ||
| ], |
There was a problem hiding this comment.
[suggestion] This rule is missing two things its sibling routes have:
- Non-admins. Today a non-admin who opens
#/discussionlands on#/settings. Once the redirect document reads this rule, it will send them to My Jetpack, which they can't open./readerhas no non-admin tab either, but its first rule iscanManageModules: false→ pending D9. The same rule here keeps them on Settings until the D9 change lands, and then/discussionmoves along with the other D9 routes. (/performancehas the same gap.) alreadyRedirects.main.jsxnow does this redirect, so the rule can carry"alreadyRedirects": true, like/performance,/sharingand/reader. (The/writingrule from Settings: Move the Markdown settings into the settings panel #54891 is missing it too.)
| "rules": [ | |
| { "destination": "admin.php?page=my-jetpack&p=%2Ffeatures%3Fconfigure%3Dcomments" } | |
| ], | |
| "rules": [ | |
| { "when": { "canManageModules": false }, "pending": [ "D9" ] }, | |
| { | |
| "destination": "admin.php?page=my-jetpack&p=%2Ffeatures%3Fconfigure%3Dcomments", | |
| "alreadyRedirects": true | |
| } | |
| ], |
Generated by Claude.
There was a problem hiding this comment.
95b6a69 to
f472875
Compare
Behind the my-jetpack-settings-consolidation flag. The My Jetpack panel holds the Comments module switch, the blocks-in-comments option and the comment form introduction, which saves on blur. The Jetpack plugin prints comment block availability to My Jetpack script data; without it, the panel hides the blocks option. With the flag on, admins get search pointers instead of the Comments card, the Discussion tab hides, and #/discussion opens the panel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
isInSettingsPanel() holds the flag + manage_modules check that Composing, Discussion and Post by Email each wrote inline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gate now comes from connect(), which the unconnected render skips. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The panel shows the blocks option when the module sends it, so the Jetpack plugin no longer prints isCommentBlocksAvailable. The introduction saves through useModuleSetting(), which now resolves to whether the save worked. Users who cannot manage modules keep /discussion until D9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f472875 to
4854156
Compare
dhasilva
left a comment
There was a problem hiding this comment.
Follow-up after the merge: I rechecked the final head, 4854156, against my review of 95b6a69.
My four suggestions landed as proposed:
- The panel reads
enable_blocks_commentsfrom$module.options. The script-data key, its type and the PHP lines are gone. useModuleSetting()'ssetValueresolves totrueorfalse, anduse-module-text-setting.tsis gone. The other callers ignore the result, so nothing else changes./discussionhas thecanManageModules: false→ D9 rule andalreadyRedirects./writingand/performancegot theirs in #54891.
New: I left one suggestion inline, on a redirect-map entry. Nothing reads the map yet, so the fix can wait for the PR that first reads it, or go into the next consolidation PR.
I didn't rerun the test suites this time. The comment-length and stale-comment checks are clean. At merge, the only failing job was coverage publishing, which this change doesn't affect.
Generated by Claude.
| }, | ||
| { | ||
| "source": "comment-likes", | ||
| "rules": [ { "destination": "admin.php?page=my-jetpack#/features?search=comment%20likes" } ] |
There was a problem hiding this comment.
[suggestion] search=comment%20likes finds Comment Likes only when the translated name or description still contains "comment". Features requires every word to match a module's name, search_terms or description (scoreFields(), moduleFields()). Only the name and description are translated. Comment Likes' search terms stay in English (like widget, like button, like, likes) and don't include "comment". So in a locale that translates "comment", the word matches nothing on Comment Likes, and the module drops out of the results.
The Discussion pointer works in every locale, because search={ name } sends the same translated name that Features shows. The gravatar entry above is fine too, because "gravatar" is one of that module's search terms. search=likes would match in every locale, though Likes ranks above Comment Likes. Alternatively, the redirect document could build the term from the translated module name, as the pointer does.
Generated by Claude.
Fixes JETPACK-3720
Proposed changes
Behind the
my-jetpack-settings-consolidationflag (off by default). With the flag off, nothing changes.settings-panel/comments.tsx). It shows a description, a support link, the module switch (PanelModuleToggle), "Enable blocks in comments" (enable_blocks_comments) and "Comment form introduction" (highlander_comment_form_prompt). The options are locked while the module is off.useModuleOption).useModuleSetting(), whosesetValuenow resolves to whether the save worked (its other callers ignore the result). The field is locked while it saves, and a failed save keeps the typed text.enable_blocks_commentsin its options. That option came with block comments (Comments: add a setting to enable the block editor #53031), so a Jetpack version without block comments leaves it out and the option stays hidden. Carousel hides its colour select the same way.commentsjoinsInitializer::SETTINGS_PANEL_MODULES, so itsconfigure_urlpoints at the panel while the flag is on.discussion/index.jsx):discussion/comments-moved.jsx).FeaturesPointer, searched by module name, as Composing does).isModuleFound, which this change makes dead.#/discussionsends them to the Comments panel (main.jsx). Users who cannot manage modules never had a Discussion tab, and their#/discussionalready goes to#/settings. A Settings search still shows them the classic Comments card, as on trunk.commentsand/discussionpoint at the Comments panel./discussionkeeps users who cannot manage modules on Settings until D9, and is markedalreadyRedirects.gravatar-hovercardsand the newcomment-likessource point at their Features rows. The D2 marker on these entries was already replaced by JETPACK-3720 in Settings: Move the Markdown settings into the settings panel #54891.Related product discussion/links
Does this pull request change what data or activity we track or use?
No new data. The module switch and the blocks switch send the existing panel Tracks events (
origin: my-jetpack-settings-panel). The introduction text is not recorded.Testing instructions
Needs a connected site: Comments needs a connection, so in offline mode the panel shows locked.
admin.php?page=jetpack-settings#/discussion: it opens the Comments panel.Unit tests:
comments.test.tsx(panel),discussion.test.jsx, and new rows in the nav-tab and route tests.