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

KMW / 7465 Implement Insufficient Permissions Error CTA on KMW Tiles #7554

Conversation

10upsimon
Copy link
Collaborator

@10upsimon 10upsimon commented Sep 6, 2023

Summary

Addresses issue:

Relevant technical choices

  • Updated <MetricTileError> component error to conditionally show and pass text based on whether error is one of insufficient permissions or not.
  • Defined getHelpText prop and type, and updated logic to conditionally show getHelpText based on it's presence.
  • Updated <MetricTileError> component styles to accommodate anchor tag based buttons as opposed to just button elements.
  • Added InsufficientPermissions scenarios to all KMW stories and updated VRT references accordingly.

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

…-insufficient-permissions-error-cta-kmw-tiles.
…ss text based on whether error is one of insufficient permissions or not.
@10upsimon 10upsimon marked this pull request as ready for review September 6, 2023 22:04
@github-actions
Copy link

github-actions bot commented Sep 6, 2023

Build files for a7fddbe are ready:

Copy link
Collaborator

@hussain-t hussain-t left a comment

Choose a reason for hiding this comment

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

Thanks, @10upsimon. I've noticed some discrepancies between the implementation and the expected behavior, explicitly concerning the Trouble getting access? and Get help links. I've provided specific comments on the relevant sections.

Please review those comments and make the necessary changes to align the implementation with the requirements.

assets/js/components/KeyMetrics/MetricTileError.js Outdated Show resolved Hide resolved
@@ -132,7 +140,7 @@ export default function ReportErrorActions( { moduleSlug, error } ) {
</Fragment>
) : (
<Link href={ errorTroubleshootingLinkURL } external>
{ __( 'Get help', 'google-site-kit' ) }
{ getHelpText || __( '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.

The current implementation replaces the Get help link, which is not the intended behavior. According to the IB, the goal is to add a descriptive label to the existing Get help link for the insufficient permissions error. This should be done like how the Retry didn't work? text is displayed alongside its respective link for the retryable errors.

Specifically, the IB states:

  • If the getHelpText prop is provided, render the Get help link with the provided text, similar to how Retry didn’t work? and Get help are rendered.

Comment on lines 130 to 134
{ getHelpText ||
__(
'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.

We don't need to change this. Please refer to the comment below.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We have to update all these new VRT images once the Trouble getting access? and Get help link is implemented.

assets/js/components/KeyMetrics/MetricTileError.js Outdated Show resolved Hide resolved
assets/js/components/KeyMetrics/MetricTileError.js Outdated Show resolved Hide resolved
10upsimon and others added 4 commits September 7, 2023 16:27
…mw-tiles' of github.com:google/site-kit-wp into kmw/7465-implement-insufficient-permissions-error-cta-kmw-tiles.
@github-actions
Copy link

github-actions bot commented Sep 7, 2023

Size Change: +961 B (0%)

Total Size: 1.41 MB

Filename Size Change
./dist/assets/css/googlesitekit-admin-css-********************.min.css 51.5 kB +8 B (0%)
./dist/assets/js/googlesitekit-activation-********************.js 22.1 kB -6 B (0%)
./dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 53.9 kB +37 B (0%)
./dist/assets/js/googlesitekit-adminbar-********************.js 32.4 kB +21 B (0%)
./dist/assets/js/googlesitekit-api-********************.js 9.55 kB -3 B (0%)
./dist/assets/js/googlesitekit-components-gm2-********************.js 5.61 kB -2 B (0%)
./dist/assets/js/googlesitekit-components-gm3-********************.js 9.98 kB -4 B (0%)
./dist/assets/js/googlesitekit-datastore-forms-********************.js 9 kB -1 B (0%)
./dist/assets/js/googlesitekit-datastore-location-********************.js 2.09 kB -2 B (0%)
./dist/assets/js/googlesitekit-datastore-site-********************.js 17.7 kB +2 B (0%)
./dist/assets/js/googlesitekit-datastore-ui-********************.js 9.1 kB -2 B (0%)
./dist/assets/js/googlesitekit-datastore-user-********************.js 23.3 kB +7 B (0%)
./dist/assets/js/googlesitekit-entity-dashboard-********************.js 65 kB +49 B (0%)
./dist/assets/js/googlesitekit-main-dashboard-********************.js 81.1 kB +37 B (0%)
./dist/assets/js/googlesitekit-modules-adsense-********************.js 106 kB -10 B (0%)
./dist/assets/js/googlesitekit-modules-analytics-********************.js 88.1 kB +34 B (0%)
./dist/assets/js/googlesitekit-modules-analytics-4-********************.js 67.8 kB +242 B (0%)
./dist/assets/js/googlesitekit-modules-********************.js 21.1 kB +3 B (0%)
./dist/assets/js/googlesitekit-modules-optimize-********************.js 18.9 kB +2 B (0%)
./dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 20.5 kB +42 B (0%)
./dist/assets/js/googlesitekit-modules-search-console-********************.js 60.4 kB +315 B (+1%)
./dist/assets/js/googlesitekit-modules-tagmanager-********************.js 30.8 kB +14 B (0%)
./dist/assets/js/googlesitekit-settings-********************.js 47.4 kB -4 B (0%)
./dist/assets/js/googlesitekit-splash-********************.js 65.4 kB +6 B (0%)
./dist/assets/js/googlesitekit-user-input-********************.js 40.1 kB -18 B (0%)
./dist/assets/js/googlesitekit-vendor-********************.js 317 kB -11 B (0%)
./dist/assets/js/googlesitekit-widgets-********************.js 27 kB +169 B (+1%)
./dist/assets/js/googlesitekit-wp-dashboard-********************.js 62.9 kB +32 B (0%)
./dist/assets/js/runtime-********************.js 1.3 kB +4 B (0%)
ℹ️ View Unchanged
Filename Size
./dist/assets/css/googlesitekit-adminbar-css-********************.min.css 11.4 kB
./dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 7.58 kB
./dist/assets/js/30-********************.js 2.8 kB
./dist/assets/js/31-********************.js 2.28 kB
./dist/assets/js/32-********************.js 3.72 kB
./dist/assets/js/33-********************.js 929 B
./dist/assets/js/34-********************.js 888 B
./dist/assets/js/35-********************.js 3.12 kB
./dist/assets/js/analytics-advanced-tracking-********************.js 769 B
./dist/assets/js/googlesitekit-data-********************.js 2.18 kB
./dist/assets/js/googlesitekit-i18n-********************.js 3.92 kB
./dist/assets/js/googlesitekit-polyfills-********************.js 379 B

compressed-size-action

@10upsimon
Copy link
Collaborator Author

@hussain-t this is ready for another round of review, thank you. I've also implemented a fix for tiles returning an array of error objects, as per this slack thread.

This fix can be found in commit at ed538cf

Copy link
Collaborator

@hussain-t hussain-t left a comment

Choose a reason for hiding this comment

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

Thanks, @10upsimon. Overall, the changes look good. However, a few minor improvements need to be taken care of, which I will address myself to avoid another iteration.

error={ error }
getHelpText={
hasInsufficientPermissionsError
? __( 'Trouble getting access?', '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.

Since we're appending the HelpLink in ReportErrorActions, it shouldn't be translatable here. The whole string incluidng the HelpLink should be translated.

<div>
{ getHelpText ? (
createInterpolateElement(
`${ getHelpText } <HelpLink />`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The whole string should be translated here instead. Please refer to the previous comment.

Comment on lines 193 to 209

const [ accountID, propertyID, webDataStreamID ] = [
'12345',
'34567',
'56789',
];

// Set accountID, propertyID and webDataStreamID values.
registry
.dispatch( MODULES_SEARCH_CONSOLE )
.receiveGetSettings( {
propertyID: 'http://example.com/',
} );
.dispatch( MODULES_ANALYTICS )
.setAccountID( accountID );
registry
.dispatch( MODULES_ANALYTICS_4 )
.setPropertyID( propertyID );
registry
.dispatch( MODULES_ANALYTICS_4 )
.setWebDataStreamID( webDataStreamID );
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need to mock the Analytics data since this tile's report depends on the Search Console module. We could set the SC property ID according to the getServiceEntityAccessURL selector. Even that's unnecessary as the selector doesn't return undefined. However, it's preferred.

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
Copy link
Collaborator

@hussain-t hussain-t Sep 8, 2023

Choose a reason for hiding this comment

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

This not related to this ticket. However, it was imported with the internal dependencies. I have fixed it.

Copy link
Collaborator

@hussain-t hussain-t left a comment

Choose a reason for hiding this comment

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

Nice one, @10upsimon. LGTM 🏅

Note: I have slightly tweaked the QAB to test the actual error state since it only aimed to simulate the error using the Tweak extension.

Copy link
Collaborator

@techanvil techanvil left a comment

Choose a reason for hiding this comment

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

Hey @10upsimon, nice work here. I've sent it back with a couple of comments - one small but important, the other super trivial :)

Copy link
Collaborator

@techanvil techanvil left a comment

Choose a reason for hiding this comment

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

LGTM, nice one @10upsimon!

Copy link
Collaborator

@techanvil techanvil left a comment

Choose a reason for hiding this comment

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

Post-review I noticed the GetHelpLink component was missing a propTypes definition, so added that too.

LGTM.

@techanvil techanvil merged commit 0e4c5a2 into develop Sep 20, 2023
15 of 18 checks passed
@techanvil techanvil deleted the kmw/7465-implement-insufficient-permissions-error-cta-kmw-tiles branch September 20, 2023 11:24
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.

3 participants