-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support: Add concierge offer to contact form #16144
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
89307cd
Help: Add concierge offer to contact form
585ee7d
Move the logic that checkes if the current user is a business user into
southp 337da43
Apply `isBusinessPlanUser` selector to `HelpContactForm` component.
southp 9f0706b
Extract the `renderCalendlyOffer()` function and its related setup code
southp d7345d4
Remove unnecessary div wrapper.
southp 20e9239
Add the test suite for `isBusinessPlanUser` selector.
southp 555ba80
Add from / to time properties to ChatBusinessConciergeNotice component.
southp 89c6b3e
Fix typos
unDemian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { identity } from 'lodash'; | ||
import React, { Component, PropTypes } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import i18n, { localize } from 'i18n-calypso'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import analytics from 'lib/analytics'; | ||
import HelpTeaserButton from '../help-teaser-button'; | ||
import { isBusinessPlanUser } from 'state/selectors'; | ||
|
||
class ChatBusinessConciergeNotice extends Component { | ||
static propTypes = { | ||
translate: PropTypes.func, | ||
isBusinessPlanUser: PropTypes.bool.isRequired, | ||
from: PropTypes.string.isRequired, | ||
to: PropTypes.string.isRequired, | ||
}; | ||
|
||
static defaultProps = { | ||
translate: identity, | ||
}; | ||
|
||
trackCalendlyOfferClick = () => { | ||
analytics.tracks.recordEvent( 'calypso_help_calendly_offer_click' ); | ||
}; | ||
|
||
render = () => { | ||
const { translate } = this.props; | ||
const fromDate = i18n.moment( this.props.from ); | ||
const toDate = i18n.moment( this.props.to ); | ||
|
||
if ( ! i18n.moment().isAfter( fromDate ) || ! i18n.moment().isBefore( toDate ) ) { | ||
return null; | ||
} | ||
|
||
if ( ! this.props.isBusinessPlanUser ) { | ||
return ( | ||
<HelpTeaserButton | ||
title={ translate( 'Chat is temporarily closed.' ) } | ||
description={ translate( | ||
'We\'re still available over email in the meantime. ' + | ||
'Chat will be back on Friday, July 21st!' | ||
) } /> | ||
); | ||
} | ||
|
||
return ( | ||
<HelpTeaserButton | ||
onClick={ this.trackCalendlyOfferClick } | ||
href="https://calendly.com/wordpressdotcom/wordpress-com-business-site-setup/" | ||
title={ translate( 'Chat with us over screenshare!' ) } | ||
description={ translate( 'Click here to get one-on-one help with a Happiness Engineer.' ) } /> | ||
); | ||
} | ||
} | ||
|
||
export default connect( | ||
( state ) => ( { | ||
isBusinessPlanUser: isBusinessPlanUser( state ), | ||
} ) | ||
)( localize( ChatBusinessConciergeNotice ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getCurrentUserId } from 'state/current-user/selectors'; | ||
import { getUserPurchases } from 'state/purchases/selectors'; | ||
import { PLAN_BUSINESS } from 'lib/plans/constants'; | ||
|
||
/** | ||
* Returns a boolean flag indicating if the current user is a business plan user. | ||
* | ||
* @param {Object} state Global state tree | ||
* @return {Boolean} If the current user is a business plan user. | ||
*/ | ||
export default ( state ) => { | ||
const userId = getCurrentUserId( state ); | ||
|
||
if ( ! userId ) { | ||
return false; | ||
} | ||
|
||
const purchases = getUserPurchases( state, userId ); | ||
|
||
if ( ! purchases || 0 === purchases.length ) { | ||
return false; | ||
} | ||
|
||
return purchases.some( ( purchase ) => PLAN_BUSINESS === purchase.productSlug ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { assert } from 'chai'; | ||
import deepFreeze from 'deep-freeze'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { isBusinessPlanUser } from '../'; | ||
import { PLAN_BUSINESS } from 'lib/plans/constants'; | ||
|
||
describe( 'isBusinessPlanUser()', () => { | ||
it( 'should return true if any purchase is a business plan.', () => { | ||
const state = deepFreeze( { | ||
currentUser: { | ||
id: 123, | ||
}, | ||
purchases: { | ||
data: [ | ||
{ | ||
user_id: '123', | ||
product_slug: 'some-other-plan', | ||
}, | ||
{ | ||
user_id: '123', | ||
product_slug: PLAN_BUSINESS, | ||
} | ||
], | ||
hasLoadedUserPurchasesFromServer: true, | ||
}, | ||
} ); | ||
|
||
assert.isTrue( isBusinessPlanUser( state ) ); | ||
} ); | ||
|
||
it( 'should return false if non of the purchases is a business plan.', () => { | ||
const state = deepFreeze( { | ||
currentUser: { | ||
id: 123, | ||
}, | ||
purchases: { | ||
data: [ | ||
{ | ||
user_id: '123', | ||
product_slug: 'some-other-plan', | ||
}, | ||
{ | ||
user_id: '123', | ||
product_slug: 'yet-another-plan', | ||
} | ||
], | ||
hasLoadedUserPurchasesFromServer: true, | ||
}, | ||
} ); | ||
|
||
assert.isFalse( isBusinessPlanUser( state ) ); | ||
} ); | ||
|
||
it( 'should return false if current user id is null.', () => { | ||
const state = deepFreeze( { | ||
currentUser: {} | ||
} ); | ||
|
||
assert.isFalse( isBusinessPlanUser( state ) ); | ||
} ); | ||
|
||
it( 'should return false if purchasing data is null.', () => { | ||
const state = deepFreeze( { | ||
currentUser: { | ||
id: 123, | ||
}, | ||
purchases: { | ||
data: [ | ||
{ // intentionally put a purchase that doesn't belong to the user 123 here. | ||
user_id: '789', | ||
product_slug: PLAN_BUSINESS, | ||
} | ||
], | ||
hasLoadedUserPurchasesFromServer: true, | ||
}, | ||
} ); | ||
|
||
assert.isFalse( isBusinessPlanUser( state ) ); | ||
} ); | ||
} ); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just nitpicking around, not a blocker but I guess we could destructure all used props here instead of using
this.props