From 79aeedc6c35331a2a58b8449e8be152220ab8e9d Mon Sep 17 00:00:00 2001 From: Timmy Huang Date: Mon, 4 Oct 2021 11:26:01 -0700 Subject: [PATCH] refactor: 2235 remove cookie banner (#2459) --- client/__tests__/e2e/puppeteerUtils.js | 7 - client/src/components/app.js | 2 - client/src/components/termsPrompt/index.js | 147 --------------------- client/src/components/util/localStorage.js | 21 --- 4 files changed, 177 deletions(-) delete mode 100644 client/src/components/termsPrompt/index.js delete mode 100644 client/src/components/util/localStorage.js diff --git a/client/__tests__/e2e/puppeteerUtils.js b/client/__tests__/e2e/puppeteerUtils.js index 8d3a497f..94ac9a28 100644 --- a/client/__tests__/e2e/puppeteerUtils.js +++ b/client/__tests__/e2e/puppeteerUtils.js @@ -100,12 +100,6 @@ export async function getElementCoordinates(testId) { }); } -async function clickTermsOfService() { - if (!(await isElementPresent(getTestId("tos-cookies-accept")))) return; - - await clickOn("tos-cookies-accept"); -} - async function nameNewAnnotation() { if (await isElementPresent(getTestId("annotation-dialog"))) { await typeInto("new-annotation-name", "ignoreE2E"); @@ -122,7 +116,6 @@ export async function goToPage(url) { }); await nameNewAnnotation(); - await clickTermsOfService(); } export async function isElementPresent(selector, options) { diff --git a/client/src/components/app.js b/client/src/components/app.js index eb46d3a6..d3b78761 100644 --- a/client/src/components/app.js +++ b/client/src/components/app.js @@ -11,7 +11,6 @@ import Graph from "./graph/graph"; import MenuBar from "./menubar"; import Autosave from "./autosave"; import Embedding from "./embedding"; -import TermsOfServicePrompt from "./termsPrompt"; import actions from "../actions"; @@ -75,7 +74,6 @@ class App extends React.Component { - diff --git a/client/src/components/termsPrompt/index.js b/client/src/components/termsPrompt/index.js deleted file mode 100644 index 11f1313d..00000000 --- a/client/src/components/termsPrompt/index.js +++ /dev/null @@ -1,147 +0,0 @@ -import React from "react"; -import { connect } from "react-redux"; -import { - Drawer, - Button, - Classes, - Position, - Colors, - Icon, -} from "@blueprintjs/core"; -import { storageGet, storageSet, KEYS } from "../util/localStorage"; - -@connect((state) => ({ - tosURL: state.config?.parameters?.about_legal_tos, - privacyURL: state.config?.parameters?.about_legal_privacy, -})) -class TermsPrompt extends React.PureComponent { - constructor(props) { - super(props); - const { tosURL, privacyURL } = this.props; - const cookieDecision = storageGet(KEYS.COOKIE_DECISION, null); - const hasDecided = cookieDecision !== null; - this.state = { - hasDecided, - isEnabled: !!tosURL || !!privacyURL, - isOpen: !hasDecided, - }; - } - - componentDidMount() { - const { hasDecided, isEnabled } = this.state; - if (isEnabled && !hasDecided) { - this.setState({ isOpen: true }); - } - } - - handleOK = () => { - this.setState({ isOpen: false }); - storageSet(KEYS.COOKIE_DECISION, "yes"); - if (window.cookieDecisionCallback instanceof Function) { - try { - window.cookieDecisionCallback(); - } catch (e) { - // continue - } - } - }; - - handleNo = () => { - this.setState({ isOpen: false }); - storageSet(KEYS.COOKIE_DECISION, "no"); - }; - - renderTos() { - const { tosURL } = this.props; - if (!tosURL) return null; - return ( - - By using this site, you are - agreeing to our{" "} - - terms of service - - .{" "} - - ); - } - - renderPrivacy() { - const { privacyURL } = this.props; - if (!privacyURL) return null; - return ( - - To learn more, read our{" "} - - privacy policy - - .  - - ); - } - - render() { - const { isOpen, isEnabled } = this.state; - if (!isEnabled || !isOpen) return null; - return ( - -
-
-
- {this.renderTos()} - - We use cookies to help us improve the site and to inform our - future efforts, and we also use necessary cookies to make our - site work.  - - {this.renderPrivacy()} -
-
-
- {" "} - -
-
-
- ); - } -} - -export default TermsPrompt; diff --git a/client/src/components/util/localStorage.js b/client/src/components/util/localStorage.js deleted file mode 100644 index fc4a8bb6..00000000 --- a/client/src/components/util/localStorage.js +++ /dev/null @@ -1,21 +0,0 @@ -export const KEYS = { - COOKIE_DECISION: "cxg.cookieDecision", -}; - -export function storageGet(key, defaultValue = null) { - try { - const val = window.localStorage.getItem(key); - if (val === null) return defaultValue; - return val; - } catch (e) { - return defaultValue; - } -} - -export function storageSet(key, value) { - try { - window.localStorage.setItem(key, value); - } catch { - // continue - } -}