-
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
People: Invites: Add accepted invite welcome message #636
Changes from all commits
e654252
a97b33c
e33ad52
88bb827
4189d7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import keyMirror from 'react/lib/keyMirror'; | ||
|
||
export default keyMirror( { | ||
DISPLAY_INVITE_ACCEPTED_NOTICE: null, | ||
DISMISS_INVITE_ACCEPTED_NOTICE: null, | ||
DISPLAY_INVITE_DECLINED_NOTICE: null, | ||
DISMISS_INVITE_DECLINED_NOTICE: null | ||
} ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd consider putting the |
||
* External dependencies | ||
*/ | ||
import React from 'react' | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Notice from 'components/notice' | ||
import { dismissInviteAccepted, dismissInviteDeclined } from 'accept-invite/actions' | ||
import store from 'accept-invite/invite-message/store' | ||
|
||
export default React.createClass( { | ||
|
||
getInitialState: function() { | ||
return store.get(); | ||
}, | ||
|
||
componentWillMount() { | ||
store.on( 'change', () => this.setState( this.getInitialState ) ); | ||
}, | ||
|
||
componentWillUnmount() { | ||
store.off( 'change', () => this.setState( this.getInitialState ) ); | ||
}, | ||
|
||
render() { | ||
if ( ! this.props.sites ) { | ||
return null; | ||
} | ||
const { accepted, declined, siteId } = this.state; | ||
if ( accepted ) { | ||
const site = this.props.sites.getSite( siteId ); | ||
if ( ! site ) { | ||
return null; | ||
} | ||
return ( | ||
<Notice status="is-success" onClick={ dismissInviteAccepted }> | ||
<h3 className="invite-message__title">{ this.translate( 'You\'re now a user of: %(site)s', { args: { site: site.slug } } ) }</h3> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the site should be a link to the front-end. Also the sentence would read better without the |
||
<p className="invite-message__intro"> | ||
{ this.translate( 'This is your site dashboard where you can write posts and control your site. ' ) } | ||
</p> | ||
<p className="invite-message__intro"> | ||
{ | ||
this.translate( | ||
'Since you\'re new, you might like to {{docsLink}}take a tour{{/docsLink}}.', | ||
{ components: { docsLink: <a href="http://en.support.wordpress.com/" target="_blank" /> } } | ||
) | ||
} | ||
</p> | ||
</Notice> | ||
); | ||
} | ||
if ( declined ) { | ||
return ( | ||
<Notice status="is-success" onClick={ dismissInviteDeclined }> | ||
<h3> | ||
{ this.translate( 'You declined to join' ) } | ||
</h3> | ||
</Notice> | ||
); | ||
} | ||
return null; | ||
} | ||
} ) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { createReducerStore } from 'lib/store' | ||
import { DISPLAY_INVITE_ACCEPTED_NOTICE, DISMISS_INVITE_ACCEPTED_NOTICE, DISPLAY_INVITE_DECLINED_NOTICE, DISMISS_INVITE_DECLINED_NOTICE } from './constants' | ||
|
||
const InviteMessageStore = createReducerStore( ( state, payload ) => { | ||
const { action } = payload; | ||
let newState = Object.assign( {}, state ); | ||
switch ( action.type ) { | ||
case DISPLAY_INVITE_ACCEPTED_NOTICE: | ||
newState.accepted = true; | ||
newState.siteId = action.siteId; | ||
return newState; | ||
case DISPLAY_INVITE_DECLINED_NOTICE: | ||
newState.declined = true; | ||
newState.siteId = action.siteId; | ||
return newState; | ||
case DISMISS_INVITE_ACCEPTED_NOTICE: | ||
case DISMISS_INVITE_DECLINED_NOTICE: | ||
newState.accepted = false; | ||
newState.declined = false; | ||
newState.siteId = false; | ||
return newState; | ||
} | ||
return state; | ||
}, { accepted: false, declined: false, siteId: false } ); | ||
|
||
export default InviteMessageStore; |
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.
Oooh, I love this. Great idea!! I'm going to copy it :D