diff --git a/client/accept-invite/invite-form-header/index.jsx b/client/accept-invite/invite-form-header/index.jsx index 0522d212286cd..0b38f1dce94c6 100644 --- a/client/accept-invite/invite-form-header/index.jsx +++ b/client/accept-invite/invite-form-header/index.jsx @@ -1,20 +1,259 @@ /** * External dependencies */ -import React from 'react' +import React from 'react'; +import { get } from 'lodash'; + +/** + * Internal dependencies + */ +import userModule from 'lib/user'; + +/** + * Module variables + */ +const user = userModule(); export default React.createClass( { displayName: 'InviteFormHeader', + getRole() { + return get( this.props, 'invite.meta.role' ); + }, + + getSiteName() { + return get( this.props, 'blog_details.title' ); + }, + + getSiteDomain() { + return get( this.props, 'blog_details.domain' ); + }, + + getSiteLink() { + const siteName = this.getSiteName(); + const siteDomain = this.getSiteDomain(); + + if ( ! siteName || ! siteDomain ) { + return null; + } + + return ( + + { siteName } + + ); + }, + + getLoggedOutTitleForInvite() { + let title = ''; + + switch ( this.getRole() ) { + case 'administrator': + title = this.translate( + 'Sign up to become an administrator of {{siteLink/}}.', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + case 'editor': + title = this.translate( + 'Sign up to become an editor of {{siteLink/}}.', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + case 'author': + title = this.translate( + 'Sign up to become an author of {{siteLink/}}.', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + case 'contributor': + title = this.translate( + 'Sign up to become a contributor to {{siteLink/}}.', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + case 'subscriber': + title = this.translate( + 'Sign up to become a subscriber of {{siteLink/}}.', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + case 'follower': + title = this.translate( + 'Sign up to become a follower of {{siteLink/}}.', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + default: + title = this.translate( + 'Sign up to join {{siteLink/}} with a role of: {{strong}}%(siteRole)s{{/strong}}.', { + args: { + siteRole: this.getRole() + }, + components: { + siteLink: this.getSiteLink(), + strong: + } + } + ); + } + + return title; + }, + + getLoggedInTitleForInvite() { + let title = ''; + + switch ( this.getRole() ) { + case 'administrator': + title = this.translate( + 'Would you like to become an administrator of {{siteLink/}}?', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + case 'editor': + title = this.translate( + 'Would you like to become an editor of {{siteLink/}}?', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + case 'author': + title = this.translate( + 'Would you like to become an author of {{siteLink/}}?', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + case 'contributor': + title = this.translate( + 'Would you like to become a contributor to {{siteLink/}}?', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + case 'subscriber': + title = this.translate( + 'Would you like to become a subscriber of {{siteLink/}}?', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + case 'follower': + title = this.translate( + 'Would you like to become a follower of {{siteLink/}}?', { + components: { + siteLink: this.getSiteLink() + } + } + ); + break; + default: + title = this.translate( + 'Would you like to join {{siteLink/}} with a role of: {{strong}}%(siteRole)s{{/strong}}?', { + args: { + siteRole: this.getRole() + }, + components: { + siteLink: this.getSiteLink(), + strong: + } + } + ); + } + + return title; + }, + + getExplanationForInvite() { + let explanation = ''; + switch ( this.getRole() ) { + case 'administrator': + explanation = this.translate( + 'As an administrator, you will be able to manage all aspects of %(siteName)s.', { + args: { + siteName: this.getSiteName() + } + } + ); + break; + case 'editor': + explanation = this.translate( + 'As an editor, you will be able to publish and manage your own posts and the posts of others, as well as upload media.' + ); + break; + case 'author': + explanation = this.translate( + 'As an author, you will be able to publish and edit your own posts as well as upload media.' + ); + break; + case 'contributor': + explanation = this.translate( + 'As a contributor, you will be able to write and manage your own posts, but you will not be able to publish.' + ); + break; + case 'subscriber': + explanation = this.translate( + 'As a subscriber, you will be able to manage your profile on %(siteName)s', { + args: { + siteName: this.getSiteName() + } + } + ); + break; + case 'follower': + explanation = this.translate( + 'As a follower, you will receive updates every time there is a new post on %(siteName)s', { + args: { + siteName: this.getSiteName() + } + } + ); + break + } + + return explanation; + }, + render() { + let roleExplanation = this.getExplanationForInvite(); return (

- { this.props.title } + { user.get() ? this.getLoggedInTitleForInvite() : this.getLoggedOutTitleForInvite() }

- { this.props.explanation && + { roleExplanation &&

- { this.props.explanation } + { roleExplanation }

}
diff --git a/client/accept-invite/logged-in-accept/index.jsx b/client/accept-invite/logged-in-accept/index.jsx index 53af4cef58a30..4b3649bad3a4d 100644 --- a/client/accept-invite/logged-in-accept/index.jsx +++ b/client/accept-invite/logged-in-accept/index.jsx @@ -3,7 +3,6 @@ */ import React from 'react'; import classNames from 'classnames'; -import { get } from 'lodash'; /** * Internal dependencies @@ -21,10 +20,6 @@ export default React.createClass( { displayName: 'LoggedInAccept', - getInviteRole() { - return get( this.props, 'invite.meta.role', '' ); - }, - render() { let userObject = user.get(), signInLink = config( 'login_url' ) + '?redirect_to=' + encodeURIComponent( window.location.href ); @@ -32,28 +27,7 @@ export default React.createClass( { return (
- - } - } ) - } - explanation={ - this.translate( - 'As an %(siteRole)s you will be able to publish and edit your own posts as well as upload media.', { - args: { - siteRole: this.getInviteRole() - } - } - ) - } - /> +
{ diff --git a/client/accept-invite/logged-out-invite/signup-form.jsx b/client/accept-invite/logged-out-invite/signup-form.jsx index 39ec649f6e484..82384e8e4ff9f 100644 --- a/client/accept-invite/logged-out-invite/signup-form.jsx +++ b/client/accept-invite/logged-out-invite/signup-form.jsx @@ -45,28 +45,7 @@ export default React.createClass( { getFormHeader() { return ( - - } - } ) - } - explanation={ - this.translate( - 'As an %(siteRole)s you will be able to publish and edit your own posts as well as upload media.', { - args: { - siteRole: get( this.props, 'invite.meta.role' ) - } - } - ) - } - /> + ); },