mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Refactored swtichPage
action call syntax
no issue Updates switchPage syntax to pass object so we can pass `lastPage` value as well for back button
This commit is contained in:
parent
4931ea68bd
commit
859b5502eb
6 changed files with 20 additions and 7 deletions
|
@ -16,7 +16,8 @@ export default class ParentContainer extends React.Component {
|
|||
page: 'loading',
|
||||
showPopup: false,
|
||||
action: 'init:running',
|
||||
initStatus: 'running'
|
||||
initStatus: 'running',
|
||||
lastPage: null
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -102,7 +103,8 @@ export default class ParentContainer extends React.Component {
|
|||
try {
|
||||
if (action === 'switchPage') {
|
||||
this.setState({
|
||||
page: data
|
||||
page: data.page,
|
||||
lastPage: data.lastPage || null
|
||||
});
|
||||
} else if (action === 'togglePopup') {
|
||||
this.setState({
|
||||
|
|
|
@ -17,7 +17,12 @@ export default class MagicLinkPage extends React.Component {
|
|||
renderLoginMessage() {
|
||||
return (
|
||||
<div style={{display: 'flex', justifyContent: 'center'}}>
|
||||
<div style={{color: '#3db0ef', fontWeight: 'bold', cursor: 'pointer'}} onClick={() => this.context.onAction('switchPage', 'signin')}> Back to Log in </div>
|
||||
<div
|
||||
style={{color: '#3db0ef', fontWeight: 'bold', cursor: 'pointer'}}
|
||||
onClick={() => this.context.onAction('switchPage', {page: 'signin'})}
|
||||
>
|
||||
Back to Log in
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,13 @@ export default class SigninPage extends React.Component {
|
|||
return (
|
||||
<div style={{display: 'flex', justifyContent: 'center'}}>
|
||||
<div style={{marginRight: '6px', color: '#929292'}}> Don't have an account ? </div>
|
||||
<div style={{color: brandColor, fontWeight: 'bold', cursor: 'pointer'}} role="button" onClick={() => this.context.onAction('switchPage', 'signup')}> Subscribe </div>
|
||||
<div
|
||||
style={{color: brandColor, fontWeight: 'bold', cursor: 'pointer'}}
|
||||
role="button"
|
||||
onClick={() => this.context.onAction('switchPage', {page: 'signup'})}
|
||||
>
|
||||
Subscribe
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,6 @@ describe('SigninPage', () => {
|
|||
const {signupButton, mockOnActionFn} = setup();
|
||||
|
||||
fireEvent.click(signupButton);
|
||||
expect(mockOnActionFn).toHaveBeenCalledWith('switchPage', 'signup');
|
||||
expect(mockOnActionFn).toHaveBeenCalledWith('switchPage', {page: 'signup'});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -106,7 +106,7 @@ class SignupPage extends React.Component {
|
|||
return (
|
||||
<div style={{display: 'flex', justifyContent: 'center'}}>
|
||||
<div style={{marginRight: '6px', color: '#929292'}}> Already a member ? </div>
|
||||
<div style={{color: brandColor, fontWeight: 'bold', cursor: 'pointer'}} role="button" onClick={() => onAction('switchPage', 'signin')}> Log in </div>
|
||||
<div style={{color: brandColor, fontWeight: 'bold', cursor: 'pointer'}} role="button" onClick={() => onAction('switchPage', {page: 'signin'})}> Log in </div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,6 @@ describe('SignupPage', () => {
|
|||
const {signinButton, mockOnActionFn} = setup();
|
||||
|
||||
fireEvent.click(signinButton);
|
||||
expect(mockOnActionFn).toHaveBeenCalledWith('switchPage', 'signin');
|
||||
expect(mockOnActionFn).toHaveBeenCalledWith('switchPage', {page: 'signin'});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue