Skip to content

Commit f715bc4

Browse files
authored
Merge pull request #1972 from processing/bug/embed-cookie-popup
Bug/embed cookie popup
2 parents 5819ad8 + 7077583 commit f715bc4

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

client/modules/App/App.jsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import { setPreviousPath } from '../IDE/actions/ide';
77
import { setLanguage } from '../IDE/actions/preferences';
88
import CookieConsent from '../User/components/CookieConsent';
99

10+
function hideCookieConsent(pathname) {
11+
if (pathname.includes('/full/') || pathname.includes('/embed/')) {
12+
return true;
13+
}
14+
return false;
15+
}
16+
1017
class App extends React.Component {
1118
constructor(props, context) {
1219
super(props, context);
@@ -40,9 +47,10 @@ class App extends React.Component {
4047
}
4148

4249
render() {
50+
const hide = hideCookieConsent(this.props.location.pathname);
4351
return (
4452
<div className="app">
45-
<CookieConsent />
53+
<CookieConsent hide={hide} />
4654
{this.state.isMounted &&
4755
!window.devToolsExtension &&
4856
getConfig('NODE_ENV') === 'development' && <DevTools />}

client/modules/User/components/CookieConsent.jsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ReactGA from 'react-ga';
66
import { Transition } from 'react-transition-group';
77
import { Link } from 'react-router';
88
import { Trans, useTranslation } from 'react-i18next';
9+
import { PropTypes } from 'prop-types';
910
import getConfig from '../../../utils/getConfig';
1011
import { setUserCookieConsent } from '../actions';
1112
import { remSize, prop, device } from '../../../theme';
@@ -72,7 +73,7 @@ const CookieConsentButtons = styled.div`
7273
}
7374
`;
7475

75-
function CookieConsent() {
76+
function CookieConsent({ hide }) {
7677
const user = useSelector((state) => state.user);
7778
const [cookieConsent, setBrowserCookieConsent] = useState('none');
7879
const [inProp, setInProp] = useState(false);
@@ -154,6 +155,8 @@ function CookieConsent() {
154155
}
155156
}, [cookieConsent]);
156157

158+
if (hide) return null;
159+
157160
return (
158161
<Transition in={inProp} timeout={500}>
159162
{(state) => (
@@ -186,4 +189,12 @@ function CookieConsent() {
186189
);
187190
}
188191

192+
CookieConsent.propTypes = {
193+
hide: PropTypes.bool
194+
};
195+
196+
CookieConsent.defaultProps = {
197+
hide: false
198+
};
199+
189200
export default CookieConsent;

0 commit comments

Comments
 (0)