From 860db6c95946db31180eb9860431457e5f01e04f Mon Sep 17 00:00:00 2001 From: Peer Richelsen Date: Fri, 1 Oct 2021 00:42:08 +0100 Subject: [PATCH] added license banner (#833) * added license banner and NEXT_PUBLIC_LICENSE_CONSENT in .env.example. agree to hide the banner * minor changes to license banner * added /ee/ to tailwind purge config * wip --- .env.example | 9 ++ components/DonateBanner.tsx | 42 --------- components/Shell.tsx | 2 + .../dialog/ConfirmationDialogContent.tsx | 15 +++- ee/components/LicenseBanner.tsx | 90 +++++++++++++++++++ tailwind.config.js | 6 +- 6 files changed, 119 insertions(+), 45 deletions(-) delete mode 100644 components/DonateBanner.tsx create mode 100644 ee/components/LicenseBanner.tsx diff --git a/.env.example b/.env.example index a7335b31..a7731d6b 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,12 @@ +# Set this value to 'agree' to accept our license: +# LICENSE: https://github.com/calendso/calendso/blob/main/LICENSE +# +# Summary of terms: +# - The codebase has to stay open source, whether it was modified or not +# - You can not repackage or sell the codebase +# - Acquire a commercial license to remove these terms by emailing: license@cal.com +NEXT_PUBLIC_LICENSE_CONSENT='' + # DATABASE_URL='postgresql://:@:/' DATABASE_URL="postgresql://postgres:@localhost:5432/calendso?schema=public" diff --git a/components/DonateBanner.tsx b/components/DonateBanner.tsx deleted file mode 100644 index 2ee634ff..00000000 --- a/components/DonateBanner.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { GiftIcon } from "@heroicons/react/outline"; - -export default function DonateBanner() { - if (location.hostname.endsWith(".cal.com")) { - return null; - } - - return ( - <> -
-
-
-
-
-
- - -

- Support the ongoing development - - You're using the free self-hosted version. Support the ongoing development by making - a donation. - -

-
- -
-
-
-
- - ); -} diff --git a/components/Shell.tsx b/components/Shell.tsx index e5686235..4438688a 100644 --- a/components/Shell.tsx +++ b/components/Shell.tsx @@ -15,6 +15,7 @@ import { useRouter } from "next/router"; import React, { Fragment, ReactNode, useEffect } from "react"; import { Toaster } from "react-hot-toast"; +import LicenseBanner from "@ee/components/LicenseBanner"; import HelpMenuItemDynamic from "@ee/lib/intercom/HelpMenuItemDynamic"; import classNames from "@lib/classNames"; @@ -241,6 +242,7 @@ export default function Shell(props: { {/* add padding to content for mobile navigation*/}
+
diff --git a/components/dialog/ConfirmationDialogContent.tsx b/components/dialog/ConfirmationDialogContent.tsx index f3a3ef23..30698c85 100644 --- a/components/dialog/ConfirmationDialogContent.tsx +++ b/components/dialog/ConfirmationDialogContent.tsx @@ -1,4 +1,5 @@ import { ExclamationIcon } from "@heroicons/react/outline"; +import { CheckIcon } from "@heroicons/react/solid"; import * as DialogPrimitive from "@radix-ui/react-dialog"; import React, { PropsWithChildren } from "react"; @@ -8,9 +9,9 @@ import { Button } from "@components/ui/Button"; export type ConfirmationDialogContentProps = { confirmBtnText?: string; cancelBtnText?: string; - onConfirm: (event: React.MouseEvent) => void; + onConfirm?: (event: React.MouseEvent) => void; title: string; - variety?: "danger" /* no others yet */; + variety?: "danger" | "warning" | "success"; }; export default function ConfirmationDialogContent(props: PropsWithChildren) { @@ -26,6 +27,16 @@ export default function ConfirmationDialogContent(props: PropsWithChildren )} + {variety === "warning" && ( +
+ +
+ )} + {variety === "success" && ( +
+ +
+ )} )}
diff --git a/ee/components/LicenseBanner.tsx b/ee/components/LicenseBanner.tsx new file mode 100644 index 00000000..70888b28 --- /dev/null +++ b/ee/components/LicenseBanner.tsx @@ -0,0 +1,90 @@ +import { XIcon } from "@heroicons/react/outline"; +import { BadgeCheckIcon } from "@heroicons/react/solid"; + +import { Dialog, DialogTrigger } from "@components/Dialog"; +import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; + +export default function LicenseBanner() { + /* + Set this value to 'agree' to accept our license: + LICENSE: https://github.com/calendso/calendso/blob/main/LICENSE + + Summary of terms: + - The codebase has to stay open source, whether it was modified or not + - You can not repackage or sell the codebase + - Acquire a commercial license to remove these terms by emailing: license@cal.com + NEXT_PUBLIC_LICENSE_CONSENT='' + */ + if (process.env.NEXT_PUBLIC_LICENSE_CONSENT === "agree") { + return null; + } + + return ( +
+
+
+
+
+ + +

+ + Accept our license by changing the .env variable{" "} + NEXT_PUBLIC_LICENSE_CONSENT to + 'I agree'. + +

+
+
+ + + + + + +
+
+ + + + + + +
+
+
+
+
+ ); + + function DialogContent() { + return ( + + To remove this banner, please open your .env file and change the{" "} + NEXT_PUBLIC_LICENSE_CONSENT{" "} + variable to 'agree'. +

Summary of terms:

+
    +
  • The codebase has to stay open source, whether it was modified or not
  • +
  • You can not repackage or sell the codebase
  • +
  • + Acquire a commercial license to remove these terms by emailing:{" "} + + license@cal.com + +
  • +
+
+ ); + } +} diff --git a/tailwind.config.js b/tailwind.config.js index 6ab100d5..13e77804 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,6 +1,10 @@ module.exports = { mode: "jit", - purge: ["./pages/**/*.{js,ts,jsx,tsx}", "./components/**/*.{js,ts,jsx,tsx}"], + purge: [ + "./pages/**/*.{js,ts,jsx,tsx}", + "./components/**/*.{js,ts,jsx,tsx}", + "./ee/components/**/*.{js,ts,jsx,tsx}", + ], darkMode: "class", theme: { extend: {