Updated default page to signin for invite only sites

closes https://github.com/TryGhost/Team/issues/689

For invite only sites, the default page should be signin as it makes more sense and is actionable than a static signup page
This commit is contained in:
Rishabh 2021-05-12 17:11:48 +05:30
parent 0bbdccea72
commit 52d52c9a9e
4 changed files with 11 additions and 8 deletions

View File

@ -9,7 +9,7 @@ import * as Fixtures from './utils/fixtures';
import ActionHandler from './actions';
import './App.css';
import NotificationParser from './utils/notifications';
import {createPopupNotification, getCurrencySymbol, getFirstpromoterId, getQueryPrice, getSiteDomain, isComplimentaryMember, removePortalLinkFromUrl} from './utils/helpers';
import {createPopupNotification, getCurrencySymbol, getFirstpromoterId, getQueryPrice, getSiteDomain, isComplimentaryMember, isInviteOnlySite, removePortalLinkFromUrl} from './utils/helpers';
const handleDataAttributes = require('./data-attributes');
const React = require('react');
@ -516,10 +516,11 @@ export default class App extends React.Component {
}
/**Get final page set in App context from state data*/
getContextPage({page, member}) {
getContextPage({site, page, member}) {
/**Set default page based on logged-in status */
if (!page) {
page = member ? 'accountHome' : 'signup';
const loggedOutPage = isInviteOnlySite({site}) ? 'signin' : 'signup';
page = member ? 'accountHome' : loggedOutPage;
}
if (page === 'accountPlan' && isComplimentaryMember({member})) {
@ -552,7 +553,7 @@ export default class App extends React.Component {
/**Get final App level context from App state*/
getContextFromState() {
const {site, member, action, page, lastPage, showPopup, pageQuery, popupNotification} = this.state;
const contextPage = this.getContextPage({page, member});
const contextPage = this.getContextPage({site, page, member});
const contextMember = this.getContextMember({page: contextPage, member});
return {
site,

View File

@ -9,6 +9,7 @@ import {ReactComponent as ButtonIcon3} from '../images/icons/button-icon-3.svg';
import {ReactComponent as ButtonIcon4} from '../images/icons/button-icon-4.svg';
import {ReactComponent as ButtonIcon5} from '../images/icons/button-icon-5.svg';
import TriggerButtonStyle from './TriggerButton.styles';
import {isInviteOnlySite} from '../utils/helpers';
const React = require('react');
@ -163,11 +164,12 @@ class TriggerButtonContent extends React.Component {
}
onToggle() {
const {showPopup, member} = this.context;
const {showPopup, member, site} = this.context;
if (showPopup) {
this.context.onAction('closePopup');
} else {
const page = member ? 'accountHome' : 'signup';
const loggedOutPage = isInviteOnlySite({site}) ? 'signin' : 'signup';
const page = member ? 'accountHome' : loggedOutPage;
this.context.onAction('openPopup', {page});
}
}

View File

@ -388,7 +388,7 @@ function PlanOptions({plans, selectedPlan, onPlanSelect, changePlan}) {
const {site} = useContext(AppContext);
const {free_price_name: freePriceName, free_price_description: freePriceDescription} = site;
addDiscountToPlans(plans);
return plans.map(({ name, currency_symbol: currencySymbol, amount, description, interval, id}) => {
return plans.map(({name, currency_symbol: currencySymbol, amount, description, interval, id}) => {
const price = amount / 100;
const isChecked = selectedPlan === id;
const classes = (isChecked ? 'gh-portal-plan-section checked' : 'gh-portal-plan-section');

View File

@ -145,7 +145,7 @@ export function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
export function isInviteOnlySite({site = {}, pageQuery}) {
export function isInviteOnlySite({site = {}, pageQuery = ''}) {
const prices = getSitePrices({site, pageQuery});
return prices.length === 0 || (site && site.members_signup_access === 'invite');
}