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:
parent
16c2224b9b
commit
9d853be979
1 changed files with 6 additions and 4 deletions
|
@ -62,12 +62,14 @@ export default class App extends React.Component {
|
||||||
setupCustomTriggerButton() {
|
setupCustomTriggerButton() {
|
||||||
// Handler for custom buttons
|
// Handler for custom buttons
|
||||||
this.clickHandler = (event) => {
|
this.clickHandler = (event) => {
|
||||||
|
event.preventDefault();
|
||||||
const target = event.currentTarget;
|
const target = event.currentTarget;
|
||||||
const pagePath = (target && target.dataset.portal);
|
const pagePath = (target && target.dataset.portal);
|
||||||
const {page, pageQuery} = this.getPageFromLinkPath(pagePath);
|
const {page, pageQuery} = this.getPageFromLinkPath(pagePath) || {};
|
||||||
|
|
||||||
event.preventDefault();
|
if (page) {
|
||||||
this.onAction('openPopup', {page, pageQuery});
|
this.onAction('openPopup', {page, pageQuery});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const customTriggerSelector = '[data-portal]';
|
const customTriggerSelector = '[data-portal]';
|
||||||
const popupCloseClass = 'gh-members-popup-close';
|
const popupCloseClass = 'gh-members-popup-close';
|
||||||
|
@ -227,7 +229,7 @@ export default class App extends React.Component {
|
||||||
const linkRegex = /^\/portal(?:\/(\w+(?:\/\w+)?))?$/;
|
const linkRegex = /^\/portal(?:\/(\w+(?:\/\w+)?))?$/;
|
||||||
if (path && linkRegex.test(path)) {
|
if (path && linkRegex.test(path)) {
|
||||||
const [,pagePath] = path.match(linkRegex);
|
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;
|
const lastPage = ['accountPlan', 'accountProfile'].includes(page) ? 'accountHome' : null;
|
||||||
return {
|
return {
|
||||||
showPopup: true,
|
showPopup: true,
|
||||||
|
|
Loading…
Add table
Reference in a new issue