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
Help Center: Connect chat pages #63242
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~18 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~19 bytes removed 📉 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~5931 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
This PR modifies the release build for editing-toolkit To test your changes on WordPress.com, run To deploy your changes after merging, see the documentation: PCYsg-mMA-p2 |
c6e90f6
to
921bdfb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's all coming together baby 🚀 Beautiful work!
const { data: dataChat, isLoading: isLoadingChat } = useSupportAvailability( 'CHAT' ); | ||
const { data: dataEmail, isLoading: isLoadingEmail } = useSupportAvailability( 'EMAIL' ); | ||
|
||
useEffect( () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit unclear. Deserves a comment.
useEffect( () => { | |
// open the contact form automatically if the user has one option. | |
useEffect( () => { |
const { __ } = useI18n(); | ||
const [ chatAvailable, setChatAvailable ] = useState( false ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be a state.
<div className={ classnames( 'inline-help__contact-box', 'chat' ) }> | ||
<div | ||
className={ classnames( 'inline-help__contact-boxes', { | ||
'is-reversed': ! chatAvailable, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'is-reversed': ! chatAvailable, | |
'is-reversed': ! dataChat.isClosed , |
> | ||
<div | ||
className={ classnames( 'inline-help__contact-box', 'chat', { | ||
'is-disabled': ! chatAvailable, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'is-disabled': ! chatAvailable, | |
'is-disabled': dataChat.isClosed , |
client/layout/masterbar/checkout.tsx
Outdated
contactForm ? ( | ||
<ContactForm | ||
mode={ contactForm } | ||
onBackClick={ () => { | ||
setOpenInContactPage( true ); | ||
setContactForm( null ); | ||
} } | ||
/> | ||
) : ( | ||
<InlineHelpCenterContent | ||
selectedArticle={ selectedArticle } | ||
setSelectedArticle={ setSelectedArticle } | ||
setHelpCenterFooter={ setFooterContent } | ||
setContactFormOpen={ setContactForm } | ||
openInContactPage={ openInContactPage } | ||
/> | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually we'll have to make a react router (maybe hash router) at one point for sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was thinking about that indeed. Not right now, but this may become way too complicated 👍
a6cbc59
to
54411ee
Compare
const secondaryViewRef = useRef(); | ||
|
||
//prefetch the values | ||
useSupportAvailability( 'CHAT' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid magic strings, we should have constants for these 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @klimeryk, thanks for your suggestion! I was already focused on deployment, so I lost your message, but I'll address that as soon as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Igor! This is not a magic string thanks to TypeScript, this function only accepts CHAT
or EMAIL
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL! But a constant has additional benefits that this approach seems to be missing (happy to be proven wrong, I'm a TypeScript newbie!):
- Defined in one place - easy to change the underlying value without searching for a possibly generic string like
EMAIL
. - Easier to search for these "constants" - if it's a named constant defined somewhere, most IDEs will be able to figure out all the references to it. And even simple search would work better than for a string.
- In some cases you need to reference those outside of just calling the function, like here: https://github.com/Automattic/wp-calypso/pull/63242/files#diff-ac4b8e65c1a3ef7336ecca35fe4c1be3628a73a08e045b237ad373f2366d8d9bR155. It becomes a magic string at that point and is completely decoupled from the definition of the function (OK, not completely, but you get the idea).
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/7294022 Thank you @escapemanuele for including a screenshot in the description! This is really helpful for our translators. |
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/7294022 Thank you @escapemanuele for including a screenshot in the description! This is really helpful for our translators. |
Translation for this Pull Request has now been finished. |
Changes proposed in this Pull Request
It is now possible to navigate between help center pages.
Screen.Capture.on.2022-05-04.at.19-45-41.mp4
If user is eligible for chat, but chat is not available
Changes:
ContactForm
to HelpCenter packageTesting instructions
TBD
Related to #