Skip to content
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

Merged
merged 8 commits into from
May 25, 2022

Conversation

pablinos
Copy link
Contributor

@pablinos pablinos commented May 22, 2022

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:

  • 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

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.

@pablinos pablinos self-assigned this May 22, 2022
@pablinos pablinos marked this pull request as draft May 22, 2022 12:45
@pablinos pablinos added [Feature] Publicize Now Jetpack Social, auto-sharing [Extension] Publicize Block editor plugin [JS Package] Publicize Components labels May 22, 2022
@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ RNA labels May 22, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 22, 2022

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ⚠️ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: June 7, 2022.
  • Scheduled code freeze: May 31, 2022.

Base automatically changed from add/publicize-js-package to master May 23, 2022 09:50
… 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
@pablinos pablinos force-pushed the update/move-publicize-components branch from 5441eb8 to 4dd6971 Compare May 23, 2022 20:32
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello pablinos! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D81359-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@pablinos pablinos marked this pull request as ready for review May 24, 2022 11:57
@pablinos pablinos requested a review from a team May 24, 2022 11:57
Copy link
Contributor Author

@pablinos pablinos left a 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' ] }
Copy link
Contributor Author

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.

Copy link
Contributor

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() }
Copy link
Contributor Author

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 = () =>
Copy link
Contributor Author

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/';
Copy link
Contributor Author

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';
Copy link
Contributor Author

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.

danielpost
danielpost previously approved these changes May 24, 2022
Copy link
Contributor

@danielpost danielpost left a 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. 👍🏼

Comment on lines +46 to +51

.jetpack-publicize-gutenberg-social-icon,
.jetpack-publicize-connection-label-copy {
display: inline-block;
vertical-align: middle;
}
Copy link
Contributor

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.

Copy link
Contributor Author

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' ] }
Copy link
Contributor

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 👍🏼

@pablinos pablinos added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Team Review labels May 24, 2022
Comment on lines +46 to +51

.jetpack-publicize-gutenberg-social-icon,
.jetpack-publicize-connection-label-copy {
display: inline-block;
vertical-align: middle;
}
Copy link
Contributor

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.

Copy link
Contributor

@bindlegirl bindlegirl left a comment

Choose a reason for hiding this comment

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

Works for me.

@bindlegirl bindlegirl added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels May 25, 2022
@bindlegirl bindlegirl added this to the jetpack/11.0 milestone May 25, 2022
@jeherve jeherve merged commit 1f14fd4 into master May 25, 2022
@jeherve jeherve deleted the update/move-publicize-components branch May 25, 2022 11:15
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label May 25, 2022
@jeherve
Copy link
Member

jeherve commented May 25, 2022

r246300-wpcom

@github-actions
Copy link
Contributor

Great news! One last step: head over to your WordPress.com diff, D81359-code, and deploy it.
Once you've done so, come back to this PR and add a comment with your changeset ID.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Extension] Publicize Block editor plugin [Feature] Publicize Now Jetpack Social, auto-sharing [JS Package] Publicize Components [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ RNA Touches WP.com Files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants