-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publicize Components: Move remaining components to the package. #24464
Conversation
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 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
… package. This PR builds on #24408 and moves over the remaining components to the package which are required by Jetpack Social. This is mainly moving files, but with a few changes: - JSDoc has been updated to satisfy the new lint rules - Styles have been moved into the components where possible - We no longer display the message box and twitter options when the toggle is used to disable Publicize
5441eb8
to
4dd6971
Compare
Caution: This PR has changes that must be merged to WordPress.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The WPCOM check is failing as this involves new files, and moving existing ones. I've updated the patch and we can review that separately.
I've added some notes to the code as a review, because I feel some of the additional changes might require a bit more explanation.
@@ -29,7 +31,11 @@ class PublicizeConnection extends Component { | |||
*/ | |||
maybeDisplayLinkedInNotice = () => | |||
this.connectionNeedsReauth() && ( | |||
<Notice className="jetpack-publicize-notice" isDismissible={ false } status="error"> | |||
<Notice | |||
className={ componentStyles[ 'publicize-notice' ] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, and the other CSS changes means that we can remove the editor.scss
file and it makes the build a bit cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see you've already done what I mentioned above in some places. Nice 👍🏼
checked={ enabled } | ||
onChange={ this.onConnectionChange } | ||
disabled={ disabled } | ||
disabled={ disabled || this.connectionIsFailing() || this.connectionNeedsReauth() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discovered that we were unnecessarily wrapping this in a Disabled
component, so I incorporated the extra checks into this disabled
prop
return connections.every( connection => ! connection.toggleable ); | ||
} | ||
|
||
const isDisabled = () => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight refactor here, and it helped make the linter happy.
@@ -34,20 +40,22 @@ export default function PublicizeSettingsButton() { | |||
refresh(); | |||
}, refreshThreshold ); | |||
|
|||
const connectionsUrl = | |||
getJetpackData()?.publicizeConnectionsUrl ?? 'https://wordpress.com/marketing/connections/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a temporary measure. We're not ready to send current Jetpack sites to Jetpack Cloud for the connections screen, so for now we'll default to Calypso, and this lets us change that with the initial state data.
@@ -19,7 +20,9 @@ import { SUPPORTED_CONTAINER_BLOCKS } from '../components/twitter'; | |||
*/ | |||
export async function refreshConnectionTestResults() { | |||
try { | |||
const results = await apiFetch( { path: '/wpcom/v2/publicize/connection-test-results' } ); | |||
const connectionRefreshPath = | |||
getJetpackData()?.connectionRefreshPath ?? '/wpcom/v2/publicize/connection-test-results'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly to the Jetpack Cloud connections screen, we don't want to default to the new endpoint for WPCOM until we've moved to the new package. This allows us to configure the URL used in the initial state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! All the components still worked in my testing and Publicize worked with no issues. 👍🏼
|
||
.jetpack-publicize-gutenberg-social-icon, | ||
.jetpack-publicize-connection-label-copy { | ||
display: inline-block; | ||
vertical-align: middle; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely not this PR, but I wonder if we should import this CSS similar to how we do it in other places (className={ styles.icon }
), so we don't have to worry about namespacing the classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I've done that for the other components, but here I copied the extra rules over rather than doing that slightly bigger change. Definitely something that would be good to do as a follow up.
@@ -29,7 +31,11 @@ class PublicizeConnection extends Component { | |||
*/ | |||
maybeDisplayLinkedInNotice = () => | |||
this.connectionNeedsReauth() && ( | |||
<Notice className="jetpack-publicize-notice" isDismissible={ false } status="error"> | |||
<Notice | |||
className={ componentStyles[ 'publicize-notice' ] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see you've already done what I mentioned above in some places. Nice 👍🏼
|
||
.jetpack-publicize-gutenberg-social-icon, | ||
.jetpack-publicize-connection-label-copy { | ||
display: inline-block; | ||
vertical-align: middle; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely not this PR, but I wonder if we should import this CSS similar to how we do it in other places (className={ styles.icon }
), so we don't have to worry about namespacing the classes.
Not sure why this posted again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me.
r246300-wpcom |
Great news! One last step: head over to your WordPress.com diff, D81359-code, and deploy it. Thank you! |
Changes proposed in this Pull Request:
This PR builds on #24408 and moves over the remaining components to the
package which are required by Jetpack Social.
This is mainly moving files, but with a few changes:
toggle is used to disable Publicize
It also adds an option to override the URL used to manage connections. It previously updated it to use the new Jetpack redirect URL, but that will send Jetpack customers to Jetpack Cloud, and we're not ready for that yet. This way we can override it for Jetpack Social and update it for all at a later date.
Does this pull request change what data or activity we track or use?
No
Testing instructions:
As this is mainly a refactor, testing involves ensuring that the Publicize editor plugin in the Jetpack plugin still functions as before.
It would probably be worth waiting until #24408 is merged, and this is rebased, before testing this properly.That's merged now and this has been rebased.