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

Enhance/6261 key metrics settings toggle #6718

Merged
merged 43 commits into from
Jun 2, 2023

Conversation

kuasha420
Copy link
Contributor

@kuasha420 kuasha420 commented Mar 13, 2023

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

@github-actions

This comment was marked as resolved.

Copy link
Collaborator

@jimmymadon jimmymadon left a comment

Choose a reason for hiding this comment

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

Thanks for all the refactoring @kuasha420! I've had a look at the non-test files in this PR and added some minor comments. Overall looks great.

assets/js/components/settings/SettingsKeyMetrics.js Outdated Show resolved Hide resolved
assets/js/components/settings/SettingsKeyMetrics.js Outdated Show resolved Hide resolved
assets/js/components/settings/SettingsKeyMetrics.js Outdated Show resolved Hide resolved
return array();
return array(
'widgetSlugs' => array(),
'isWidgetHidden' => true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this value is storing whether the widget is "hidden" or not, once it is setup. So we can default this to false perhaps? Semantically, if the widget is not set up, then it is technically "NOT" hidden even though it is invisible. It is just not available because there aren't any widgets to be displayed. If there are no key-metrics returned, then the widget area will automatically be invisible even though the isWidgetHidden flag is set to false.

Copy link
Contributor Author

@kuasha420 kuasha420 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 the PR where @jimmymadon and I decided to refactor a bunch of stuff to make things more streamlined. So leaving some comments to provide some context to potential code reviewers.

Comment on lines 83 to 125
{ isUserInputCompleted && (
<Layout
title={ __( 'Key metrics', 'google-site-kit' ) }
header
rounded
>
<div className="googlesitekit-settings-module googlesitekit-settings-module--active googlesitekit-settings-user-input">
<Grid>
<Layout
title={ __( 'Key metrics', 'google-site-kit' ) }
header
rounded
>
<div className="googlesitekit-settings-module googlesitekit-settings-module--active googlesitekit-settings-user-input">
<Grid>
<SettingsKeyMetrics />
</Grid>
<Grid>
{ isUserInputCompleted && (
<UserInputPreview
goTo={ goTo }
noHeader
noFooter
settingsView
showIndividualCTAs
/>
</Grid>
</div>
</Layout>
) }

{ isUserInputCompleted === false && (
<UserInputSettings isDismissible={ false } rounded />
) }
) }
{ isUserInputCompleted === false && (
<div className="googlesitekit-user-input__notification">
<Cell>
<p>
<span>
{ __(
'Answer 3 quick questions to help us show the most relevant data for your site',
'google-site-kit'
) }
</span>
</p>
<Link href={ userInputURL }>
{ __(
'Personalize your metrics',
'google-site-kit'
) }
</Link>
</Cell>
</div>
) }
</Grid>
</div>
</Layout>
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 changes are necessary due to the following reason:

  • The user should be able disable the Key Metrics Widget as long as the getKeyMetrics selector from CORE_WIDGETS returns one or more widgets, be it based on User Input Question or Manually Picked.
  • However, As long as user has not completed the user input questions, they'll continue to get the CTA to answer them. This is regardless of whether user has manually selected key metrics widgets or turned off the Key Metrics using the toggle.

Therefore, as long as userInput feature flag is enabled, the Key Metrics section in settings will remain and will be potentially populated with SettingsKeyMetrics and User Input CTA or Preview.

The UserInputSettings could no longer be used because it would cause multiple Key Metrics title/sections. Therefore I used the Link and p and styled them accordingly. Moreover, the UserInputSettings component will be removed once the user input dashboard CTA is created according to design in #6210.

assets/js/util/key-metrics.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@jimmymadon jimmymadon left a comment

Choose a reason for hiding this comment

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

@kuasha420 Thanks for these - I've added one comment if you want to move the key-metrics.js within utlils to the /components folder. But this is not a big issue and we don't have a definite pattern here - so I will leave this up to you. But everything else looks good to me.

Copy link
Collaborator

@eugene-manuilov eugene-manuilov left a comment

Choose a reason for hiding this comment

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

Thanks, @kuasha420. This is a good start, but there are things that we need address before merging this PR. Please, take a look at my comments.

@github-actions
Copy link

github-actions bot commented May 30, 2023

Build files for f1a254d have been deleted.

Copy link
Collaborator

@eugene-manuilov eugene-manuilov left a comment

Choose a reason for hiding this comment

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

Thanks, @kuasha420. Almost looks good to me. Left two more comments.

assets/js/components/settings/SettingsAdmin.js Outdated Show resolved Hide resolved
@kuasha420
Copy link
Contributor Author

@eugene-manuilov I've added more context on the changes. Also the VRT issue was fixed after merging develop. Please, let me know what you think. Cheers!

Copy link
Collaborator

@eugene-manuilov eugene-manuilov left a comment

Choose a reason for hiding this comment

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

@kuasha420, could you please fix merge conflicts?

@hussain-t
Copy link
Collaborator

@kuasha420 @eugene-manuilov, I think there is confusion regarding #6210. The feature description clearly says:

The Key metrics Setup CTA placeholder component created in #6209 should be designed fully in this issue.

KeyMetricsSetupCTAWidget was the only component added in #6209. So, as part of 6210, the KeyMetricsSetupCTAWidget component should be designed, not UserInputSettings. cc: @jimmymadon

@jimmymadon
Copy link
Collaborator

@hussain-t Originally, the UserInputSettings component contained the "KeyMetrics Setup CTA Banner" to originally ask users to answer the questionnaire. This component was being used in two places, the Dashboard and the Admin Settings panel. This was implemented as a BannerNotification based on the requirements at that time as part of User Input V1 epic. So essentially, all we have to do is to "refactor" (simply delete) the old UserInputSettings component and design the KeyMetricsSetupCTAWidget as per the ACs of #6210.

@kuasha420
Copy link
Contributor Author

@eugene-manuilov all sorted. Please have a look. Cheers!

@hussain-t
Copy link
Collaborator

@hussain-t Originally, the UserInputSettings component contained the "KeyMetrics Setup CTA Banner" to originally ask users to answer the questionnaire. This component was being used in two places, the Dashboard and the Admin Settings panel. This was implemented as a BannerNotification based on the requirements at that time as part of User Input V1 epic. So essentially, all we have to do is to "refactor" (simply delete) the old UserInputSettings component and design the KeyMetricsSetupCTAWidget as per the ACs of #6210.

Thanks for the clarification, @jimmymadon!

Copy link
Collaborator

@eugene-manuilov eugene-manuilov left a comment

Choose a reason for hiding this comment

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

Thanks, @kuasha420. LGTM!

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.

4 participants