From 71fcfb4918f89a5ee7b6e8d41c20ed34ac9df719 Mon Sep 17 00:00:00 2001 From: Rish <zrishabhgarg@gmail.com> Date: Thu, 24 Sep 2020 13:37:49 +0530 Subject: [PATCH] Added cookies disabled check no issue - Added dummy banner if cookies are disabled - Adds new helper to check if cookies are disabled --- ghost/portal/src/components/PopupModal.js | 12 ++++++++++++ ghost/portal/src/utils/helpers.js | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/ghost/portal/src/components/PopupModal.js b/ghost/portal/src/components/PopupModal.js index 1a058e6ce3..f05e55b925 100644 --- a/ghost/portal/src/components/PopupModal.js +++ b/ghost/portal/src/components/PopupModal.js @@ -4,6 +4,7 @@ import AppContext from '../AppContext'; import FrameStyle from './Frame.styles'; import Pages, {getActivePage} from '../pages'; import PopupNotification from './common/PopupNotification'; +import { isCookiesDisabled } from '../utils/helpers'; const React = require('react'); @@ -38,6 +39,16 @@ const StylesWrapper = ({member}) => { }; }; +const CookieDisabledBanner = () => { + const cookieDisabled = isCookiesDisabled(); + if (cookieDisabled) { + return ( + <div> Cookies are disabled </div> + ); + } + return null; +} + class PopupContent extends React.Component { static contextType = AppContext; @@ -100,6 +111,7 @@ class PopupContent extends React.Component { return ( <div className='gh-portal-popup-wrapper'> <div className={(hasMode(['preview', 'dev']) ? 'gh-portal-popup-container preview' : 'gh-portal-popup-container') + ' ' + popupWidthStyle} style={pageStyle} ref={node => (this.node = node)} tabIndex="-1"> + <CookieDisabledBanner /> {this.renderPopupNotification()} {this.renderActivePage()} </div> diff --git a/ghost/portal/src/utils/helpers.js b/ghost/portal/src/utils/helpers.js index 8635e43b8e..dd257655c7 100644 --- a/ghost/portal/src/utils/helpers.js +++ b/ghost/portal/src/utils/helpers.js @@ -1,5 +1,9 @@ import CalculateDiscount from './discount'; +export function isCookiesDisabled() { + return !(navigator && navigator.cookieEnabled); +} + export function getMemberSubscription({member = {}}) { if (member.paid) { const [subscription] = member.subscriptions || [];