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

Add a get help link to mismatched url errors. #5636

Merged
merged 5 commits into from Aug 8, 2022

Conversation

maciejost
Copy link
Collaborator

@maciejost maciejost commented Aug 2, 2022

Summary

Addresses issue:

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 4.7 and PHP 5.6.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@maciejost maciejost force-pushed the enhancement/##5481-add-get-help branch from b0478b7 to 237d421 Compare August 2, 2022 11:23
@github-actions
Copy link

github-actions bot commented Aug 2, 2022

Size Change: +2.2 kB (0%)

Total Size: 6.23 MB

Filename Size Change
./dist/assets/css/googlesitekit-admin-css-********************.min.css 48.2 kB -19 B (0%)
./dist/assets/js/32-********************.js 2.28 kB +1 B (0%)
./dist/assets/js/36-********************.js 3.38 MB +1 B (0%)
./dist/assets/js/37-********************.js 605 kB +1 B (0%)
./dist/assets/js/38-********************.js 3.12 kB -1 B (0%)
./dist/assets/js/googlesitekit-activation-********************.js 27.9 kB +9 B (0%)
./dist/assets/js/googlesitekit-adminbar-********************.js 38.1 kB +5 B (0%)
./dist/assets/js/googlesitekit-api-********************.js 9.19 kB -3 B (0%)
./dist/assets/js/googlesitekit-base-********************.js 1.13 kB -2 B (0%)
./dist/assets/js/googlesitekit-dashboard-details-********************.js 55.1 kB -5 B (0%)
./dist/assets/js/googlesitekit-dashboard-********************.js 63.4 kB -2 B (0%)
./dist/assets/js/googlesitekit-dashboard-splash-********************.js 70.2 kB +158 B (0%)
./dist/assets/js/googlesitekit-data-********************.js 2.09 kB +3 B (0%)
./dist/assets/js/googlesitekit-datastore-forms-********************.js 8.83 kB -2 B (0%)
./dist/assets/js/googlesitekit-datastore-location-********************.js 2.08 kB +1 B (0%)
./dist/assets/js/googlesitekit-datastore-site-********************.js 14.8 kB +42 B (0%)
./dist/assets/js/googlesitekit-datastore-ui-********************.js 8.91 kB -3 B (0%)
./dist/assets/js/googlesitekit-datastore-user-********************.js 30 kB +44 B (0%)
./dist/assets/js/googlesitekit-idea-hub-post-list-********************.js 26 kB +8 B (0%)
./dist/assets/js/googlesitekit-modules-adsense-********************.js 69.4 kB +144 B (0%)
./dist/assets/js/googlesitekit-modules-analytics-4-********************.js 19 kB -3 B (0%)
./dist/assets/js/googlesitekit-modules-analytics-********************.js 69.1 kB +135 B (0%)
./dist/assets/js/googlesitekit-modules-********************.js 19.4 kB +13 B (0%)
./dist/assets/js/googlesitekit-modules-idea-hub-********************.js 27.9 kB -11 B (0%)
./dist/assets/js/googlesitekit-modules-optimize-********************.js 19.3 kB -5 B (0%)
./dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 18.4 kB +21 B (0%)
./dist/assets/js/googlesitekit-modules-search-console-********************.js 39.3 kB +14 B (0%)
./dist/assets/js/googlesitekit-modules-tagmanager-********************.js 30.4 kB +350 B (+1%)
./dist/assets/js/googlesitekit-modules-thank-with-google-********************.js 24.2 kB +1.28 kB (+6%) 🔍
./dist/assets/js/googlesitekit-polyfills-********************.js 378 B -1 B (0%)
./dist/assets/js/googlesitekit-settings-********************.js 49.8 kB +24 B (0%)
./dist/assets/js/googlesitekit-user-input-********************.js 44.7 kB +23 B (0%)
./dist/assets/js/googlesitekit-vendor-********************.js 323 kB +7 B (0%)
./dist/assets/js/googlesitekit-widgets-********************.js 19.4 kB +12 B (0%)
./dist/assets/js/googlesitekit-wp-dashboard-********************.js 61 kB -43 B (0%)
./dist/assets/js/runtime-********************.js 1.34 kB -3 B (0%)
ℹ️ View Unchanged
Filename Size
./dist/assets/css/googlesitekit-adminbar-css-********************.min.css 11.1 kB
./dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 5.96 kB
./dist/assets/js/31-********************.js 2.8 kB
./dist/assets/js/33-********************.js 3.72 kB
./dist/assets/js/34-********************.js 51.9 kB
./dist/assets/js/35-********************.js 879 kB
./dist/assets/js/analytics-advanced-tracking-********************.js 769 B
./dist/assets/js/googlesitekit-i18n-********************.js 3.92 kB
./dist/assets/js/googlesitekit-idea-hub-notice-********************.js 45.1 kB

compressed-size-action

Copy link
Collaborator

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

A few tweaks to make here first, then this should be good.

@@ -1113,11 +1113,13 @@ private function get_reconnect_after_url_mismatch_notice() {
$current_url = $this->context->get_canonical_home_url();
$content = '<p>' . sprintf(
/* translators: 1: Plugin name. 2: Message. 3: Proxy setup URL. 4: Reconnect string. */
__( '%1$s: %2$s <a href="%3$s">%4$s</a>', 'google-site-kit' ),
__( '%1$s: %2$s <a href="%3$s">%4$s</a>. <a targe="_blank" href="%5$s">%6$s</a>', 'google-site-kit' ),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like a typo here.

Suggested change
__( '%1$s: %2$s <a href="%3$s">%4$s</a>. <a targe="_blank" href="%5$s">%6$s</a>', 'google-site-kit' ),
__( '%1$s: %2$s <a href="%3$s">%4$s</a>. <a target="_blank" href="%5$s">%6$s</a>', 'google-site-kit' ),

@@ -1113,11 +1113,13 @@ private function get_reconnect_after_url_mismatch_notice() {
$current_url = $this->context->get_canonical_home_url();
$content = '<p>' . sprintf(
/* translators: 1: Plugin name. 2: Message. 3: Proxy setup URL. 4: Reconnect string. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment should have the two new properties being added to the gettext string here, so translators know what each variable is to help translation context.

esc_html__( 'Reconnect', 'google-site-kit' )
esc_html__( 'Reconnect', 'google-site-kit' ),
esc_url( $this->get_proxy_support_link_url() . '/?doc=url-has-changed' ),
esc_html__( 'Get Help', 'google-site-kit' )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
esc_html__( 'Get Help', 'google-site-kit' )
esc_html__( 'Get help', 'google-site-kit' )

We can lowercase this one too.

external
>
{ __(
'Get Help',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'Get Help',
'Get help',

We already use Get help as a translation string elsewhere in the plugin, and it's more grammatically correct, so let's lowercase the "h" 😄

Comment on lines 316 to 320
{ getHelp && (
<Link
href={ getHelp }
external
>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't quite understand the logic flow here… changedURLHelpLink is assigned to this variable only when it's truthy, and then getHelp is checked for truthiness in the render…

But I think checking changedURLHelpLink directly would result in the same logic without making the new variable, right?

{ changedURLHelpLink && (
	<Link
		href={ changedURLHelpLink }
		external
	>

EDIT: Oh, I see, getHelp is only set when 'revoked' === getQueryArg( location.href, 'googlesitekit_context' ).

In that case, might be better to assign a variable to the above check, eg.:

const authenticationRevoked = 'revoked' === getQueryArg( location.href, 'googlesitekit_context' );

And then use that as the check to display the help text, eg:

Suggested change
{ getHelp && (
<Link
href={ getHelp }
external
>
{ authenticationRevoked && (
<Link
href={ changedURLHelpLink }
external
>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's the other way around, getHelp is assigned only if 'revoked' !== getQueryArg( location.href and disconnectedReason === connected_url_mismatch.

Should I extract that conditional out to its own variable, or should I just let it stay in the same statement with the titles and descriptions?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I see, the GitHub diff made it a bit hard to catch that.

I think your solution works, but let's initialise the getHelp variable as null instead of empty string… and maybe call it getHelpURL. Just for a bit of extra clarity in variable naming.

Copy link
Collaborator

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

Looks good, just a few small tweaks, but I'll make them and push since they're small. Thanks! 👍🏻

Comment on lines 316 to 320
{ getHelp && (
<Link
href={ getHelp }
external
>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I see, the GitHub diff made it a bit hard to catch that.

I think your solution works, but let's initialise the getHelp variable as null instead of empty string… and maybe call it getHelpURL. Just for a bit of extra clarity in variable naming.

Comment on lines 222 to 224
if ( changedURLHelpLink ) {
getHelp = changedURLHelpLink;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This logic probably isn't needed, because if changedURLHelpLink is false-y (eg is undefined because the resolver is still loading) it still won't show anything as getHelp will still be false-y. I get why this is here but it's probably not needed actually. 🙂

includes/Core/Authentication/Authentication.php Outdated Show resolved Hide resolved
@tofumatt tofumatt merged commit 928efa3 into develop Aug 8, 2022
@tofumatt tofumatt deleted the enhancement/##5481-add-get-help branch August 8, 2022 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants