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

Clean up the React app #820

Merged
merged 21 commits into from
Dec 4, 2023
Merged

Clean up the React app #820

merged 21 commits into from
Dec 4, 2023

Conversation

wpalani
Copy link
Member

@wpalani wpalani commented Nov 27, 2023

Proposed changes

Since we moved a little bit quickly in 3.0 release, we didn't have enough time to clean up old code and structure the app properly, also we received new components/code from other teams with little time to give feedback. This PR aims to clean up the code of the React app including:

  • Unified function definitions (Arrow functions).
  • Remove old components since they're not being used anymore.
  • Organize module imports throughout the app's components and files.
  • Introduce ESLint and lint the app using plugin:@wordpress/eslint-plugin/recommended.
  • Add ESLint Github action for future pushes and PRs.

Todo:

  • Add a proper preloader to the app. Right now, the app loads in a blank screen. most likely, we need something PHP side since the app grew larger recently.
  • Clean up the error catcher/boundaries and the error template.

Type of Change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • Linting and tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Copy link

replay-io bot commented Nov 27, 2023

bluehost/bluehost-wordpress-plugin

StatusComplete ↗︎
Commit9ee2848
Results
1 Failed
  • tests/cypress/integration/help.cy.js
27 Passed
  • tests/cypress/integration/home.cy.js
  • tests/cypress/integration/navigation.cy.js
  • tests/cypress/integration/settings.cy.js
  • tests/cypress/integration/version-check.cy.js
  • vendor/newfold-labs/wp-module-coming-soon/tests/cypress/integration/coming-soon.cy.js
  • vendor/newfold-labs/wp-module-ctb/tests/cypress/integration/ctb.cy.js
  • vendor/newfold-labs/wp-module-deactivation/tests/cypress/integration/deactivation-survey.cy.js
  • vendor/newfold-labs/wp-module-global-ctb/tests/cypress/integration/global-ctb.cy.js
  • vendor/newfold-labs/wp-module-marketplace/tests/cypress/integration/marketplace.cy.js
  • vendor/newfold-labs/wp-module-marketplace/tests/cypress/integration/premium-plugins-tab.cy.js
  • vendor/newfold-labs/wp-module-notifications/tests/cypress/integration/notifications.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/1-Initial-steps/branding.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/1-Initial-steps/whats-next.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/2-general-onboarding-flow/get-started-experience.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/2-general-onboarding-flow/get-started-welcome.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/2-general-onboarding-flow/sitetype-primary.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/2-general-onboarding-flow/sitetype-secondary.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/2-general-onboarding-flow/top-priority.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/3-ecommerce-onboarding-flow/address.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/3-ecommerce-onboarding-flow/get-started-experience.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/3-ecommerce-onboarding-flow/products.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/3-ecommerce-onboarding-flow/site-features.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/3-ecommerce-onboarding-flow/sitetype-primary.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/3-ecommerce-onboarding-flow/sitetype-secondary.cy.js
  • vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/sidebar.cy.js
  • vendor/newfold-labs/wp-module-performance/tests/cypress/integration/performance.cy.js
  • vendor/newfold-labs/wp-module-staging/tests/cypress/integration/staging.cy.js

src/app/data/routes.js Outdated Show resolved Hide resolved
@wpalani wpalani requested a review from circlecube November 28, 2023 04:36
description: __(
"Contact one of our friendly Customer Care Specialists, as we are waiting to help at " + getSupportPhoneNumber() + ". Open 24 hours - 7 days.",
`Contact one of our friendly Customer Care Specialists, as we are waiting to help at ${ getSupportPhoneNumber() }. Open 24 hours - 7 days.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we replace the hyphen with an en () or em () dash? Pedantically I think that is more appropriate, but also this is a very minor nitpick.

'wp-plugin-bluehost')}
title={ __( 'Help', 'wp-plugin-bluehost' ) }
subTitle={ __(
'We are available 24/7 to help answer questions and solve your problems.',
Copy link
Contributor

Choose a reason for hiding this comment

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

We use "24 hours - 7 days" elsewhere, should these be consistent?

If this text comes from marketing or somewhere else, feel free to ignore.

/>
<p>From DIY to full-service help.</p>
<p>
Call or chat 24/7 for support or let our experts build
Copy link
Contributor

Choose a reason for hiding this comment

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

🔢 "24/7" vs "24 hours - 7 days"

Comment on lines +26 to +31
'Oops, there was an error loading the marketplace, please try again later.',
'bluehost-wordpress-plugin'
),
noProducts: __(
'Sorry, no marketplace items. Please, try again later.',
'bluehost-wordpress-plugin'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make the "Please try again later" consistent?

I'd suggest , please try again later. for both.

'bluehost-wordpress-plugin'
),
noProducts: __(
'Sorry, no marketplace items. Please, try again later.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to "Sorry, no marketplace items found" to be more clear?

<SectionHeader
title={ __( 'Performance', 'wp-plugin-bluehost' ) }
subTitle={ __(
'This is where you can manage cache settings for your website.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the "This is where you" necessary?

Maybe simplify to "Manage your website's cache settings"?

'Coming soon page is active. Site requires login.',
'wp-plugin-bluehost'
)
'Coming soon page is active. Site requires login.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'Coming soon page is active. Site requires login.',
'Coming soon page is active. Site is only accessible to logged in users.',

'Coming soon page is not active. Site is live to visitors.',
'wp-plugin-bluehost'
);
'Coming soon page is not active. Site is live to visitors.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'Coming soon page is not active. Site is live to visitors.',
'Coming soon page is not active. Site is public and accessible to all visitors.',

<Alert variant="info">
{__('Your website is currently displaying a "Coming Soon" page.', 'wp-plugin-bluehost')}
{ __(
'Your website is currently displaying a "Coming Soon" page.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'Your website is currently displaying a "Coming Soon" page.',
'Your site is currently displaying a "Coming Soon" page.',

If we prefer "website", then there's a few other places we should update from "site" → "website" for consistency.

<Alert variant="error">
{__('Oops! Something went wrong. Please try again.', 'wp-plugin-bluehost')}
{ __(
'Oops! Something went wrong. Please try again.',
Copy link
Contributor

Choose a reason for hiding this comment

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

🔢 Related to previous comments about "please try again", let's have this match whatever gets decided there.

Comment on lines +84 to +92
'Comments on posts are disabled after ',
'wp-plugin-bluehost'
) +
closeCommentsDays +
_n(' day.', ' days.', parseInt(closeCommentsDays), 'wp-plugin-bluehost')
_n(
' day.',
' days.',
parseInt( closeCommentsDays ),
'wp-plugin-bluehost'
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be using sprintf to fill the closeCommentsDays and the day/days, not all languages will follow the same grammatical format as English.

<SectionHeader
title={ __( 'Settings', 'wp-plugin-bluehost' ) }
subTitle={ __(
'This is where you can manage common settings for your website.',
Copy link
Contributor

Choose a reason for hiding this comment

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

🔢 "this is where you can manage X" vs "Manage X"

nextWebinar.hasTime = nextWebinar.time ? true : false;
nextWebinar.link = nextWebinar.link ?? 'https://www.bluehost.com/blog/events/';
nextWebinar.link =
nextWebinar.link ?? 'https://www.bluehost.com/blog/events/';
nextWebinar.ctaText = nextWebinar.ctaText ?? 'Register Now';
Copy link
Contributor

Choose a reason for hiding this comment

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

🔢 Need to make this translatable

src={ SupportIllustration }
alt="Help Agent Illustration"
/>
<p>From DIY to full-service help.</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

🔢 Need to make this translatable

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in this commit: f2189f1

<Alert variant="error">
{__('Oops! Something went wrong. Please try again.', 'wp-plugin-bluehost')}
{ __(
'Oops! Something went wrong. Please try again.',
Copy link
Contributor

Choose a reason for hiding this comment

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

🔢 please try again consistency


/**
* Wrapper method to dispatch snackbar notice
*
* @param string text text for notice
* @param text
* @param {string} text text for notice
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param {string} text text for notice
* @param {string} text Text for notice.

Comment on lines +32 to +34
* @param {Object} data object of data
* @param {Function} passError setter for the error in component
* @param {Function} thenCallback method to call in promise then
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param {Object} data object of data
* @param {Function} passError setter for the error in component
* @param {Function} thenCallback method to call in promise then
* @param {Object} data Object of data.
* @param {Function} passError Setter for the error in component.
* @param {Function} thenCallback Method to call in promise then.

Comment on lines +54 to +56
* @param {Object} data object of data
* @param {Function} passError setter for the error in component
* @param {Function} thenCallback method to call in promise then
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param {Object} data object of data
* @param {Function} passError setter for the error in component
* @param {Function} thenCallback method to call in promise then
* @param {Object} data Object of data.
* @param {Function} passError Setter for the error in component.
* @param {Function} thenCallback Method to call in promise then.

comingsoonadminbar.style.color = "#E01C1C";
comingsoonadminbar.textContent = "Coming Soon";
comingsoonadminbar.style.color = '#E01C1C';
comingsoonadminbar.textContent = 'Coming Soon';
Copy link
Contributor

Choose a reason for hiding this comment

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

🔢 translation strings

@wpalani
Copy link
Member Author

wpalani commented Nov 28, 2023

@bradp Thanks for your feedback. I addressed some of your comments in this commit: f2189f1

I think most of what's left is a language/copy change that we should address in a different PR in a more thought-out way. Since this language is being used across other brand plugins, so we don't have to go back and change it again.

wpalani and others added 7 commits November 28, 2023 16:57
Add some pizzazz to the "Welcome to Bluehost" console.log
…eaner-imports

* update/react-app-cleanup:
  Fix minor ESLint issue after PR merge
  Translate strings
  Fix linting
  Update console ascii art
  Update eslint.yml
  Remove example page
  Add php dependencies to eslint action
  Move handlePageLoad function to react hook
  ESLint action
  Fix webinar banner component lint issue
  Other lint fixes
  Add `eslint` and lint js files

# Conflicts:
#	src/app/data/routes.js
#	webpack.config.js
…mports

Add module alias for cleaner imports
Copy link

cypress bot commented Nov 30, 2023

1 flaky test on run #5511 ↗︎

0 237 57 0 Flakiness 1

Details:

Update package-lock.json
Project: Bluehost Brand Plugin Commit: 2c4b4ba6fa
Status: Passed Duration: 15:07 💡
Started: Dec 4, 2023 1:17 AM Ended: Dec 4, 2023 1:32 AM
Flakiness  tests/cypress/integration/help.cy.js • 1 flaky test

View Output Video

Test Artifacts
Help Page > Is Accessible Test Replay Screenshots Video

Review all test suite changes for PR #820 ↗︎

@wpalani wpalani merged commit dbcbf8e into develop Dec 4, 2023
3 checks passed
@wpalani wpalani deleted the update/react-app-cleanup branch December 4, 2023 01:36
@bradp bradp mentioned this pull request Dec 5, 2023
9 tasks
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.

5 participants