mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-08 02:52:39 -05:00
Updated custom data attribute name and value
no issue - Adds guard to open right page based on member logged in state from data attribute - Updated data attribute name to `data-portal` and values same as link handling
This commit is contained in:
parent
2ed7ebb03d
commit
c1eb4e6540
3 changed files with 42 additions and 14 deletions
|
@ -143,21 +143,31 @@ export default class App extends React.Component {
|
|||
return this.getStateFromQueryString(qs);
|
||||
}
|
||||
|
||||
if (path === '/portal/signup') {
|
||||
previewState.page = 'signup';
|
||||
} else if (path === '/portal/signin') {
|
||||
previewState.page = 'signin';
|
||||
} else if (path === '/portal/account') {
|
||||
previewState.page = 'accountHome';
|
||||
} else if (path === '/portal/account/plans') {
|
||||
previewState.page = 'accountPlan';
|
||||
} else if (path === '/portal/account/profile') {
|
||||
previewState.page = 'accountProfile';
|
||||
if (path.startsWith('/portal/')) {
|
||||
const pagePath = path.replace('/portal/', '');
|
||||
const pageFromPath = this.getPageFromPath(pagePath);
|
||||
if (pageFromPath) {
|
||||
previewState.page = 'signup';
|
||||
}
|
||||
}
|
||||
}
|
||||
return previewState;
|
||||
}
|
||||
|
||||
getPageFromPath(path) {
|
||||
if (path === 'signup') {
|
||||
return 'signup';
|
||||
} else if (path === 'signin') {
|
||||
return 'signin';
|
||||
} else if (path === 'account') {
|
||||
return 'accountHome';
|
||||
} else if (path === 'account/plans') {
|
||||
return 'accountPlan';
|
||||
} else if (path === 'account/profile') {
|
||||
return 'accountProfile';
|
||||
}
|
||||
}
|
||||
|
||||
getPreviewMember() {
|
||||
const [path, qs] = window.location.hash.substr(1).split('?');
|
||||
|
||||
|
@ -222,12 +232,13 @@ export default class App extends React.Component {
|
|||
this.clickHandler = (event) => {
|
||||
const target = event.currentTarget;
|
||||
const {page: defaultPage} = this.getDefaultPage();
|
||||
const page = (target && target.dataset.membersTriggerButton) || defaultPage;
|
||||
const pagePath = (target && target.dataset.portal);
|
||||
const pageFromPath = this.getPageFromPath(pagePath) || defaultPage;
|
||||
|
||||
event.preventDefault();
|
||||
this.onAction('openPopup', {page});
|
||||
this.onAction('openPopup', {page: pageFromPath});
|
||||
};
|
||||
const customTriggerSelector = '[data-members-trigger-button]';
|
||||
const customTriggerSelector = '[data-portal]';
|
||||
const popupCloseClass = 'gh-members-popup-close';
|
||||
this.customTriggerButtons = document.querySelectorAll(customTriggerSelector) || [];
|
||||
this.customTriggerButtons.forEach((customTriggerButton) => {
|
||||
|
@ -373,7 +384,6 @@ export default class App extends React.Component {
|
|||
render() {
|
||||
if (this.state.initStatus === 'success') {
|
||||
const {site, member, action, page, lastPage} = this.state;
|
||||
|
||||
return (
|
||||
<AppContext.Provider value={{
|
||||
site,
|
||||
|
|
|
@ -14,6 +14,15 @@ export default class SigninPage extends React.Component {
|
|||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const {member} = this.context;
|
||||
if (member) {
|
||||
this.context.onAction('switchPage', {
|
||||
page: 'accountHome'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleSignin(e) {
|
||||
e.preventDefault();
|
||||
const email = this.state.email;
|
||||
|
|
|
@ -17,6 +17,15 @@ class SignupPage extends React.Component {
|
|||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const {member} = this.context;
|
||||
if (member) {
|
||||
this.context.onAction('switchPage', {
|
||||
page: 'accountHome'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleSignup(e) {
|
||||
e.preventDefault();
|
||||
const {onAction} = this.context;
|
||||
|
|
Loading…
Add table
Reference in a new issue