Skip to content

Commit

Permalink
Merge pull request #1108 from Automattic/update/move-accept-invite-to…
Browse files Browse the repository at this point in the history
…-invites

Invites: move /accept-invite to /my-sites/invites
  • Loading branch information
lezama committed Dec 1, 2015
2 parents 8ede0cd + 06d3b40 commit 31def71
Show file tree
Hide file tree
Showing 28 changed files with 133 additions and 208 deletions.
10 changes: 5 additions & 5 deletions assets/stylesheets/_components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
// stylesheet order does not matter.
// ==========================================================================

@import 'accept-invite/invite-form-header/style';
@import 'accept-invite/invite-header/style';
@import 'accept-invite/logged-in-accept/style';
@import 'accept-invite/style';
@import 'auth/style';
@import 'accept-invite/logged-out-invite/style';
@import 'components/accordion/style';
@import 'components/add-new-button/style';
@import 'components/author-selector/style';
Expand Down Expand Up @@ -177,6 +172,11 @@
@import 'my-sites/draft/style';
@import 'my-sites/drafts/style';
@import 'my-sites/exporter/style';
@import 'my-sites/invites/invite-form-header/style';
@import 'my-sites/invites/invite-header/style';
@import 'my-sites/invites/invite-accept/logged-in/style';
@import 'my-sites/invites/invite-accept/logged-out/style';
@import 'my-sites/invites/invite-accept/style';
@import 'my-sites/media-library/style';
@import 'my-sites/no-results/style';
@import 'my-sites/pages/style';
Expand Down
52 changes: 0 additions & 52 deletions client/accept-invite/actions.js

This file was deleted.

25 changes: 0 additions & 25 deletions client/accept-invite/controller.js

This file was deleted.

33 changes: 0 additions & 33 deletions client/accept-invite/invite-header/mock-data.js

This file was deleted.

11 changes: 0 additions & 11 deletions client/accept-invite/invite-message/constants.js

This file was deleted.

15 changes: 0 additions & 15 deletions client/accept-invite/logged-out-invite/index.jsx

This file was deleted.

5 changes: 3 additions & 2 deletions client/boot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ var config = require( 'config' ),
translatorInvitation = require( 'layout/community-translator/invitation-utils' ),
layoutFocus = require( 'lib/layout-focus' ),
nuxWelcome = require( 'nux-welcome' ),
inviteActions = require( 'accept-invite/actions' ),
emailVerification = require( 'components/email-verification' ),
viewport = require( 'lib/viewport' ),
detectHistoryNavigation = require( 'lib/detect-history-navigation' ),
Expand All @@ -43,6 +42,8 @@ var config = require( 'config' ),
Layout,
LoggedOutLayout;

import { displayInviteAccepted } from 'lib/invites/actions';

function init() {
var i18nLocaleStringsObject = null;

Expand Down Expand Up @@ -233,7 +234,7 @@ function boot() {
}

if ( context.query.invite_accepted ) {
inviteActions.displayInviteAccepted( parseInt( context.query.invite_accepted ) );
displayInviteAccepted( parseInt( context.query.invite_accepted ) );
page( context.pathname );
}

Expand Down
2 changes: 1 addition & 1 deletion client/layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var Masterbar = require( './masterbar' ),
EmailVerificationNotice = require( 'components/email-verification/email-verification-notice' ),
Welcome = require( 'my-sites/welcome/welcome' ),
WelcomeMessage = require( 'nux-welcome/welcome-message' ),
InviteMessage = require( 'accept-invite/invite-message' ),
InviteMessage = require( 'my-sites/invites/invite-message' ),
analytics = require( 'analytics' ),
config = require( 'config' ),
PulsingDot = require( 'components/pulsing-dot' ),
Expand Down
103 changes: 73 additions & 30 deletions client/lib/invites/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,82 @@ import { action as ActionTypes } from 'lib/invites/constants';
*/
const debug = new Debug( 'calypso:invites-actions' );

const InvitesActions = {
fetchInvites( siteId, number = 100, offset = 0 ) {
debug( 'fetchInvites', siteId );

Dispatcher.handleViewAction( {
type: ActionTypes.FETCH_INVITES,
siteId,
offset
} );
export function fetchInvites( siteId, number = 100, offset = 0 ) {
debug( 'fetchInvites', siteId );

wpcom.undocumented().invitesList( siteId, number, offset, function( error, data ) {
Dispatcher.handleServerAction( {
type: error ? ActionTypes.RECEIVE_INVITES_ERROR : ActionTypes.RECEIVE_INVITES,
siteId, offset, data, error
} );
} );
},
fetchInvite( siteId, inviteKey ) {
debug( 'fetchInvite', siteId, inviteKey );

Dispatcher.handleViewAction( {
type: ActionTypes.FETCH_INVITE,
siteId,
inviteKey
Dispatcher.handleViewAction( {
type: ActionTypes.FETCH_INVITES,
siteId,
offset
} );

wpcom.undocumented().invitesList( siteId, number, offset, function( error, data ) {
Dispatcher.handleServerAction( {
type: error ? ActionTypes.RECEIVE_INVITES_ERROR : ActionTypes.RECEIVE_INVITES,
siteId, offset, data, error
} );
} );
}

export function fetchInvite( siteId, inviteKey ) {
debug( 'fetchInvite', siteId, inviteKey );

Dispatcher.handleViewAction( {
type: ActionTypes.FETCH_INVITE,
siteId,
inviteKey
} );

wpcom.undocumented().getInvite( siteId, inviteKey, ( error, data ) => {
Dispatcher.handleServerAction( {
type: error ? ActionTypes.RECEIVE_INVITE_ERROR : ActionTypes.RECEIVE_INVITE,
siteId, inviteKey, data, error
} );
wpcom.undocumented().getInvite( siteId, inviteKey, ( error, data ) => {
Dispatcher.handleServerAction( {
type: error ? ActionTypes.RECEIVE_INVITE_ERROR : ActionTypes.RECEIVE_INVITE,
siteId, inviteKey, data, error
} );
} );
}

export function createAccount( userData, callback ) {
return wpcom.undocumented().usersNew(
Object.assign( {}, userData, { validate: false } ),
( error, response ) => {
const bearerToken = response && response.bearer_token;
callback( error, bearerToken );
}
);
}

export function acceptInvite( invite, callback, bearerToken ) {
if ( bearerToken ) {
wpcom.loadToken( bearerToken );
}
};
return wpcom.undocumented().acceptInvite(
invite.blog_id,
invite.invite_slug,
callback
);
}

export function displayInviteAccepted( siteId ) {
Dispatcher.handleViewAction( {
type: ActionTypes.DISPLAY_INVITE_ACCEPTED_NOTICE,
siteId
} );
}

export function dismissInviteAccepted() {
Dispatcher.handleViewAction( {
type: ActionTypes.DISMISS_INVITE_ACCEPTED_NOTICE
} );
}

export function displayInviteDeclined() {
Dispatcher.handleViewAction( {
type: ActionTypes.DISPLAY_INVITE_DECLINED_NOTICE
} );
}

export default InvitesActions;
export function dismissInviteDeclined() {
Dispatcher.handleViewAction( {
type: ActionTypes.DISMISS_INVITE_DECLINED_NOTICE
} );
}
6 changes: 5 additions & 1 deletion client/lib/invites/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ export const action = keyMirror( {
RECEIVE_INVITES: null,
RECEIVE_INVITE: null,
RECEIVE_INVITES_ERROR: null,
RECEIVE_INVITE_ERROR: null
RECEIVE_INVITE_ERROR: null,
DISPLAY_INVITE_ACCEPTED_NOTICE: null,
DISMISS_INVITE_ACCEPTED_NOTICE: null,
DISPLAY_INVITE_DECLINED_NOTICE: null,
DISMISS_INVITE_DECLINED_NOTICE: null
} );
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
* 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'
import { action as ActionTypes } from 'lib/invites/constants';

const InviteMessageStore = createReducerStore( ( state, payload ) => {
const { action } = payload;
let newState = Object.assign( {}, state );
switch ( action.type ) {
case DISPLAY_INVITE_ACCEPTED_NOTICE:
case ActionTypes.DISPLAY_INVITE_ACCEPTED_NOTICE:
newState.accepted = true;
newState.siteId = action.siteId;
return newState;
case DISPLAY_INVITE_DECLINED_NOTICE:
case ActionTypes.DISPLAY_INVITE_DECLINED_NOTICE:
newState.declined = true;
newState.siteId = action.siteId;
return newState;
case DISMISS_INVITE_ACCEPTED_NOTICE:
case DISMISS_INVITE_DECLINED_NOTICE:
case ActionTypes.DISMISS_INVITE_ACCEPTED_NOTICE:
case ActionTypes.DISMISS_INVITE_DECLINED_NOTICE:
newState.accepted = false;
newState.declined = false;
newState.siteId = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Internal dependencies
*/
import { createReducerStore } from 'lib/store';
import { reducer, initialState } from 'lib/invites/reducers/list-invites';
import { reducer, initialState } from 'lib/invites/reducers/invites-list';

const InvitesStore = createReducerStore( reducer, initialState );

Expand Down
2 changes: 1 addition & 1 deletion client/lib/invites/test/list-invites-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe( 'List Invites Store', function() {
};

beforeEach( function() {
ListInvitesStore = require( 'lib/invites/stores/list-invites' );
ListInvitesStore = require( 'lib/invites/stores/invites-list' );
} );

describe( 'Listing invites', function() {
Expand Down
23 changes: 23 additions & 0 deletions client/my-sites/invites/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* External Dependencies
*/
import React from 'react';

/**
* Internal Dependencies
*/
import i18n from 'lib/mixins/i18n';
import titleActions from 'lib/screen-title/actions';
import InviteAccept from 'my-sites/invites/invite-accept';

export function acceptInvite( context ) {
titleActions.setTitle( i18n.translate( 'Accept Invite', { textOnly: true } ) );

React.unmountComponentAtNode( document.getElementById( 'secondary' ) );
context.layout.setState( { noSidebar: true } );

React.render(
React.createElement( InviteAccept, context.params ),
document.getElementById( 'primary' )
);
}
Loading

0 comments on commit 31def71

Please sign in to comment.