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: Improve primary form component. #21090

Merged
merged 15 commits into from
Sep 22, 2021

Conversation

retrofox
Copy link
Contributor

Branched off from #21085

This PR reimplements the form of the Publicize plugin.
Currently, it has two form and form-unwrapped components that make it kind of confusing.
With these changes, the form in a single component, in a single file. Also, it adds two React hooks making the whole implementation more readable, at least from my PoV 😅

Fixes #21086

Changes proposed in this Pull Request:

Publicize: Improve primary form.

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • It doesn't change the functionality of the feature, so the first testing is confirm that everything is working as expected:
    • create a new post
    • add some content
    • start to edit the message to share the post on the social media
    • publish the post
    • check the post is shared in the social media account

Testing the hooks in the Publicize component
You can take a look at the hooks in the <PublicizeForm /> component using the React dev tool:

Screen Shot 2021-09-14 at 3 50 02 PM

Testing the data propagation
Similarly, you can take a look at the core sub store tree, using the Redux dev tool.

Screen Shot 2021-09-14 at 3 46 10 PM

The image above shows how the data is stored in the subtree while the user edits the publicize content via the message box component.

@retrofox retrofox added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Pri] Normal [Status] Needs Team Review [Size] M [Extensions] Publicize labels Sep 14, 2021
@retrofox retrofox requested a review from a team September 14, 2021 18:53
@retrofox retrofox linked an issue Sep 14, 2021 that may be closed by this pull request
@github-actions github-actions bot added [Extension] Publicize Block editor plugin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Sep 14, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Sep 14, 2021

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: October 5, 2021.
  • Scheduled code freeze: September 28, 2021.

Copy link
Member

@DustyReagan DustyReagan left a comment

Choose a reason for hiding this comment

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

Just a couple of small suggestions. I'll run the code next to test the functionality.

@DustyReagan
Copy link
Member

DustyReagan commented Sep 16, 2021

Checked-out and built update/publicize-add-hooks-to-improve-data-flow branch. Ran through jurassic.tube.

  • ☑️ create a new post
  • ☑️ add some content
  • ☑️ start to edit the message to share the post on the social media
  • ☑️ publish the post
  • ☑️ check the post is shared in the social media account

✅ Facebook, Twitter, Tumblr, and LinkedIn posts worked as expected!
✅ Viewed <PublicizeForm /> component using the React dev tool.
✅ Viewed core sub store tree, using the Redux dev tool.

Works as expected! 👍

Base automatically changed from update/publicize-add-message-control-component to master September 17, 2021 16:17
@retrofox retrofox force-pushed the update/publicize-add-hooks-to-improve-data-flow branch from 4284dcd to 4eddd4c Compare September 17, 2021 16:21
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello retrofox! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D67058-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

@retrofox retrofox added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Team Review labels Sep 17, 2021
@retrofox
Copy link
Contributor Author

Thanks, @DustyReagan for your review. Suggestions have been committed 👍

Copy link
Contributor

@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.

I'm not sure if this is introduced by this PR, but if I add a title, the message box is populated with it. Then selecting the text in the message box and typing to completely replace it, the first action's undo state has the message as blank:

image

@retrofox
Copy link
Contributor Author

I'm not sure if this is introduced by this PR, but if I add a title, the message box is populated with it. Then selecting the text in the message box and typing to completely replace it, the first action's undo state has the message as blank:

Pretty sure it was not introduced by this PR.
Checking...

@retrofox retrofox added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Sep 20, 2021
@retrofox
Copy link
Contributor Author

I'm not sure if this is introduced by this PR, but if I add a title, the message box is populated with it. Then selecting the text in the message box and typing to completely replace it, the first action's undo state has the message as blank:

Pretty sure it was not introduced by this PR.
Checking...

It happens in prod right now. Do you'd like to change it? I suggest creating a new issue in that case :-D

@retrofox retrofox added [Status] Needs Team Review and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Sep 20, 2021
retrofox and others added 10 commits September 21, 2021 11:32
…licize/components/form/index.js

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>
…licize/hooks/use-select-social-media/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>
…licize/hooks/use-select-social-media/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>
…licize/hooks/use-select-social-media/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>
…licize/hooks/use-social-media-connections/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>
…licize/hooks/use-social-media-connections/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>
…licize/hooks/use-social-media-connections/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>
@retrofox retrofox force-pushed the update/publicize-add-hooks-to-improve-data-flow branch 2 times, most recently from bcc4987 to 4582e5d Compare September 21, 2021 14:54
@DustyReagan DustyReagan self-requested a review September 21, 2021 15:38
DustyReagan
DustyReagan previously approved these changes Sep 21, 2021
Copy link
Member

@DustyReagan DustyReagan left a comment

Choose a reason for hiding this comment

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

✅ Facebook, Twitter, Tumblr, and LinkedIn posts worked as expected!

✅ Viewed component using the React dev tool.

✅ Viewed core sub store tree, using the Redux dev tool.

✅ Toggles seem to be working. I verified their state in 'core' sub store tree using Redux dev tool. I also tested manually. With Facebook, Twitter, Tumblr, and LinkedIn connected, I tested the toggles with two new posts. One post I toggled off Facebook and LinkedIn and it correctly published to Twitter and Tumblr. I did the opposite on a second post and it also posted correctly.

LGTM! 👍

Copy link
Contributor

@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.

This is working for me. I think it has thrown up some other things we might want to change, but as discussed, we should keep this to a refactor PR.

@pablinos pablinos added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Team Review labels Sep 21, 2021
@sdixon194 sdixon194 added this to the jetpack/10.2 milestone Sep 21, 2021
Copy link
Contributor

@sdixon194 sdixon194 left a comment

Choose a reason for hiding this comment

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

Tests well, looks good! :shipit:

@sdixon194 sdixon194 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 Sep 21, 2021
@retrofox retrofox merged commit cf686b4 into master Sep 22, 2021
@retrofox retrofox deleted the update/publicize-add-hooks-to-improve-data-flow branch September 22, 2021 10:09
@github-actions
Copy link
Contributor

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

Thank you!

@retrofox
Copy link
Contributor Author

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

r232110-wpcom

@retrofox retrofox removed the [Status] Ready to Merge Go ahead, you can push that green button! label Sep 22, 2021
samiff pushed a commit that referenced this pull request Sep 24, 2021
* [not verified] publicize: add hooks to deal whit the data flow

* [not verified] publicize: re-implement form using function and hooks

* [not verified] publicize: remove unwrapped form

* [not verified] changelog

* [not verified] Update projects/plugins/jetpack/extensions/plugins/publicize/components/form/index.js

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>

* [not verified] Update projects/plugins/jetpack/extensions/plugins/publicize/hooks/use-select-social-media/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>

* [not verified] Update projects/plugins/jetpack/extensions/plugins/publicize/hooks/use-select-social-media/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>

* [not verified] Update projects/plugins/jetpack/extensions/plugins/publicize/hooks/use-select-social-media/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>

* [not verified] Update projects/plugins/jetpack/extensions/plugins/publicize/hooks/use-social-media-connections/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>

* [not verified] Update projects/plugins/jetpack/extensions/plugins/publicize/hooks/use-social-media-connections/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>

* [not verified] Update projects/plugins/jetpack/extensions/plugins/publicize/hooks/use-social-media-connections/Readme.md

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>

* [not verified] publizice: implement selector inn single hooks

* [not verified] publicize: split hooks by message and connections

* publicize: fix toggling network issue

* publicize: extract hooks vars once

Co-authored-by: Dusty Reagan <dusty@dustyreagan.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Extension] Publicize Block editor plugin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Size] M Touches WP.com Files [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Publicize: simplify the main form
7 participants