0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Fixed incorrect link/path handling

no refs

Last release broke the handling of incorrect portal link or attribute as no default value was used for link path
This commit is contained in:
Rish 2020-11-18 16:02:31 +05:30
parent 16c2224b9b
commit 9d853be979

View file

@ -62,12 +62,14 @@ export default class App extends React.Component {
setupCustomTriggerButton() {
// Handler for custom buttons
this.clickHandler = (event) => {
event.preventDefault();
const target = event.currentTarget;
const pagePath = (target && target.dataset.portal);
const {page, pageQuery} = this.getPageFromLinkPath(pagePath);
const {page, pageQuery} = this.getPageFromLinkPath(pagePath) || {};
event.preventDefault();
this.onAction('openPopup', {page, pageQuery});
if (page) {
this.onAction('openPopup', {page, pageQuery});
}
};
const customTriggerSelector = '[data-portal]';
const popupCloseClass = 'gh-members-popup-close';
@ -227,7 +229,7 @@ export default class App extends React.Component {
const linkRegex = /^\/portal(?:\/(\w+(?:\/\w+)?))?$/;
if (path && linkRegex.test(path)) {
const [,pagePath] = path.match(linkRegex);
const {page, pageQuery} = this.getPageFromLinkPath(pagePath);
const {page, pageQuery} = this.getPageFromLinkPath(pagePath) || {};
const lastPage = ['accountPlan', 'accountProfile'].includes(page) ? 'accountHome' : null;
return {
showPopup: true,