0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-25 02:31:59 -05:00

Added helpers to generate portal link for pages

no issue

- Adds new helpers to create portal links on existing site url paths
- Updates retry links for signin and signup to use new helpers
- Helps preventing any unwanted bugs with Portal links by providing consistent link creation
This commit is contained in:
Rish 2020-09-24 15:43:39 +05:30
parent 71fcfb4918
commit 4f00604ed4
2 changed files with 26 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import AppContext from '../AppContext';
import NotificationStyle from './Notification.styles';
import {ReactComponent as CloseIcon} from '../images/icons/close.svg';
import NotificationParser, {clearURLParams} from '../utils/notifications';
import { getPortalLink } from '../utils/helpers';
const React = require('react');
@ -24,6 +25,8 @@ const Styles = () => {
};
const NotificationText = ({type, status, context}) => {
const signinPortalLink = getPortalLink({page: 'signin', siteUrl: context.site.url});
const singupPortalLink = getPortalLink({page: 'signup', siteUrl: context.site.url});
if (type === 'signin' && status === 'success') {
return (
<p>
@ -33,7 +36,7 @@ const NotificationText = ({type, status, context}) => {
} else if (type === 'signin' && status === 'error') {
return (
<p>
Could not sign in! Login link expired. <a href="/#/portal/signin" target="_parent">Click here to retry</a>
Could not sign in! Login link expired. <a href={signinPortalLink} target="_parent">Click here to retry</a>
</p>
);
} else if (type === 'signup' && status === 'success') {
@ -45,7 +48,7 @@ const NotificationText = ({type, status, context}) => {
} else if (type === 'signup' && status === 'error') {
return (
<p>
Could not sign up! Invalid sign up link. <a href="/#/portal/signup" target="_parent">Click here to retry</a>
Could not sign up! Invalid sign up link. <a href={singupPortalLink} target="_parent">Click here to retry</a>
</p>
);
} else if (type === 'stripe:checkout' && status === 'success') {

View file

@ -1,5 +1,26 @@
import CalculateDiscount from './discount';
export function getPortalLinkPath({page}) {
const Links = {
'default': '#/portal',
'signin': '#/portal/signin',
'signup': '#/portal/signup',
'account': '#/portal/account',
'account-plans': '#/portal/account/plans',
'account-profile': '#/portal/account/profile',
};
if (Object.keys(Links).includes(page)) {
return Links[page];
}
return Links.default;
}
export function getPortalLink({page, siteUrl}) {
const url = siteUrl || `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
const portalLinkPath = getPortalLinkPath({page});
return `${url}${portalLinkPath}`;
}
export function isCookiesDisabled() {
return !(navigator && navigator.cookieEnabled);
}