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

[Earn] Remove jQuery dependency from Thickbox #28318

Open
wants to merge 28 commits into
base: trunk
Choose a base branch
from

Conversation

millerf
Copy link
Contributor

@millerf millerf commented Jan 12, 2023

Fixes Automattic/wp-calypso#71048
See #32237

Proposed changes:

Jetpack product discussion

p9dueE-6Cp-p2

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

  • No

Testing instructions:

  • See p81Rsd-1am-p2

@millerf millerf marked this pull request as draft January 12, 2023 13:00
@github-actions github-actions bot added [Block] Donations [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Feature] Memberships labels Jan 12, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2023

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 reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Jetpack plugin:

  • Next scheduled release: August 23, 2023.
  • Scheduled code freeze: August 21, 2023.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Jan 12, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2023

Are you an Automattician? You can now test your Pull Request on WordPress.com. On your sandbox, run

bin/jetpack-downloader test jetpack test/remove-thickbox

to get started. More details: p9dueE-5Nn-p2

Copy link
Contributor

@artpi artpi left a comment

Choose a reason for hiding this comment

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

I like this approach, but let's trim this code as much as possible!

  • Works well, mostly
  • Code needs trimming
  • Loading animation has a wrong URL:

Zrzut ekranu 2023-01-17 o 15 56 24

Zrzut ekranu 2023-01-17 o 15 58 39


// This line has to come after the Thickbox has opened otherwise Firefox doesn't scroll to the top.
window.scrollTo( 0, 0 );
} );
}

export const initializeMembershipButtons = selector => {
const membershipButtons = Array.prototype.slice.call( document.querySelectorAll( selector ) );
const membershipButtons = [ ...document.querySelectorAll( selector ) ];
Copy link
Contributor

Choose a reason for hiding this comment

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

Check if this code is transpiled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. The fact that your browser supports it does not mean every will

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 don't know. I'll change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@artpi
Copy link
Contributor

artpi commented Jan 17, 2023

Also needs rebasing and proper labels and stuff

@artpi artpi mentioned this pull request Jan 17, 2023
3 tasks
@millerf millerf force-pushed the test/remove-thickbox branch from 49774f9 to 5975152 Compare January 18, 2023 13:36
@millerf
Copy link
Contributor Author

millerf commented Jan 18, 2023

  • Loading animation has a wrong URL:
Zrzut ekranu 2023-01-17 o 15 56 24

I have NO IDEA where to add static data.

@millerf millerf removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Jan 18, 2023
@artpi
Copy link
Contributor

artpi commented Jan 18, 2023

I have NO IDEA where to add static data.

You need to remove it as we have one displayed in https://github.com/Automattic/jetpack/blob/trunk/projects/plugins/jetpack/extensions/shared/memberships.scss#L9

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Any chance you could add some testing instructions, so I'm sure not to miss anything when I test this?

@@ -37,3 +37,151 @@
BODY.modal-open {
overflow: hidden;
}

/* ----------------------------------------------------------------------------------------------------------------*/
Copy link
Member

Choose a reason for hiding this comment

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

Should this CSS be moved to a central location, where other extensions using the thickbox can use it too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure we want to share this library just yet: this is a really down-sized (in term of feature) version of thickbox, and there is no documentation. Maybe it should stay with this extension...
But we can definitely start a talk about re-using and re-implementing the rest of the functionnalities if JP is eager to use this...

'beforeend',
"<div id='TB_title'><div id='TB_ajaxWindowTitle'>" +
caption +
"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div></div><iframe frameborder='0' hspace='0' src='" +
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if those strings were translated. Since you placed the lib in the extensions dir, it gets transpiled so you should be able to either:

  1. Import __ from @wordpress/i18n` and translate in place. I would not recommend this since it would bring a lot of extra dependencies on a file that we also load on the frontend.
  2. Pass those translations from php to js with wp_localize_script. We do not have a specific script handle to attach it to at the moment though.

This all makes me wonder if that new lib should be handled like a real lib, like some of the ones we have in projects/plugins/jetpack/_inc. We would then register it as a new script (jetpack-thickbox) in Jetpack::register_assets(), and pass the translations there. We could then add the script as a dependency when needed.

To give you a better idea of what I mean, I pushed 79d3e76 in a test branch. Let me know what you think about the idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That gos with my comment here.

I do like the idea, but maybe we should wrap this PR first and then extend its functionality and share it for other extensions after talking with the team?

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 opened the discussion here:
p9dueE-6Cp-p2

@jeherve jeherve 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 fellow Jetpack developers. Label will be renamed soon. labels Jan 23, 2023
@millerf millerf dismissed stale reviews from artpi and romarioraffington via e9f92ff January 24, 2023 09:52
@artpi
Copy link
Contributor

artpi commented Jan 24, 2023

To clarify my thoughts on this:

I am against creating a drop-in full-featured replacement for thickbox and especially creating a shared library because:

  1. The long-term solution is to use a modal shipped in Gutenberg anyway once that becomes mature.
  2. The way subscriptions use Thickbox is really hackish. We explicitly turn off certain thickbox features. We would not even know how to test Thickbox in a way that is safe for other modules
  3. Creating our own implementation of Thickbox will let us slowly refactor it to be able to transition to something else (1). Having to support other modules will make it harder.

We can take Fab's work and start the process of creating a shared thickbox replacement as a separate piece of work. However this is not something we can do in the timeline that we have

@millerf millerf changed the title [Earn] Remove thickbox and jQuery dependency [Earn] Remove jQuery dependency from Thickbox Jan 24, 2023
@millerf millerf added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. 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 Jan 25, 2023
@sgomes
Copy link
Contributor

sgomes commented Jan 31, 2023

@artpi : Regarding the long term solution, I want to note that most @wordpress packages aren't intended to be used in the frontend. @wordpress/data, @wordpress/components, and @wordpress/elements, for example, are incorrectly being used in the frontend in some Jetpack blocks, but they come with heavy dependencies that are really only meant to be used in the editor.

#28626 tries to keep tabs on what libraries are being used on frontend JS, to avoid the issue spreading further.

As such, what we really need to replace thickbox is a frontend-safe modal library. Is there anything like that currently planned for Gutenberg?

@artpi
Copy link
Contributor

artpi commented Jan 31, 2023

As such, what we really need to replace thickbox is a frontend-safe modal library. Is there anything like that currently planned for Gutenberg?

I will page @mtias as he is the instigator for this project and knows best

@n3f
Copy link
Contributor

n3f commented Jan 31, 2023

packages aren't intended to be used in the frontend

I'm going to go and close my PR then 😆.

@n3f
Copy link
Contributor

n3f commented Feb 3, 2023

As such, what we really need to replace thickbox is a frontend-safe modal library. Is there anything like that currently planned for Gutenberg?

I will page @mtias as he is the instigator for this project and knows best

Matias answered this in p9dueE-6Cp-p2#comment-9217 with a link about using this: https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/navigation/view-modal.js

@mtias
Copy link
Member

mtias commented Feb 4, 2023

@n3f that's the leanest implementation we have on the front-end. I'd also be curious if we can use <dialog> directly, which is now mature enough and handles all the interaction details. It might be tricky to make it work with an iframe, but it's worth checking since it's the simplest solution.

@jeherve jeherve added [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Block] Payment Button aka Recurring Payments [Type] Janitorial [Pri] Normal labels Feb 10, 2023
@jeherve
Copy link
Member

jeherve commented Feb 10, 2023

I updated this PR description and refreshed it with latest trunk so it can be tested, but I'm still not sure on the current status for this. Based on the different discussions on P2 and above, should we go with an implementation of view.modal.js or <dialog>?

@jeherve jeherve 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 fellow Jetpack developers. Label will be renamed soon. labels Feb 10, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 9, 2023

This PR has been marked as stale. This happened because:

  • It has been inactive in the past 3 months.
  • It hasn’t been labeled `[Pri] BLOCKER`, `[Pri] High`, etc.

No further action is needed. But it's worth checking if this PR has clear testing instructions, is it up to date with trunk, and it is still valid. Feel free to close this PR if you think it's not valid anymore — if you do, please add a brief explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Donations [Block] Payment Button aka Recurring Payments [Block] Subscriptions [Feature] Memberships [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Type] Janitorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rework the checkout modal
7 participants