From 5cecf3104fa5b48ac928e5b21bd274f1b7e0b6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Wed, 21 Jun 2023 19:13:26 -0700 Subject: [PATCH] refactor: Skip license checks for development (#9375) --- apps/web/public/static/locales/en/common.json | 5 +-- .../ee/common/components/LicenseRequired.tsx | 36 +++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index f1161d3d1f..df649dfdcb 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -246,7 +246,7 @@ "available_apps": "Available Apps", "check_email_reset_password": "Check your email. We sent you a link to reset your password.", "finish": "Finish", - "organization_general_description":"Manage settings for your team language and timezone", + "organization_general_description": "Manage settings for your team language and timezone", "few_sentences_about_yourself": "A few sentences about yourself. This will appear on your personal url page.", "nearly_there": "Nearly there!", "nearly_there_instructions": "Last thing, a brief description about you and a photo really help you get bookings and let people know who they’re booking with.", @@ -546,7 +546,7 @@ "team_description": "A few sentences about your team. This will appear on your team's url page.", "org_description": "A few sentances about your organization. This will appear on your organization's url page.", "members": "Members", - "organization_members":"Organization members", + "organization_members": "Organization members", "member": "Member", "number_member_one": "{{count}} member", "number_member_other": "{{count}} members", @@ -896,6 +896,7 @@ "create_events_on": "Create events on", "enterprise_license": "This is an enterprise feature", "enterprise_license_description": "To enable this feature, have an administrator go to {{setupUrl}} to enter a license key. If a license key is already in place, please contact {{supportMail}} for help.", + "enterprise_license_development": "You can test this feature on development mode. For production usage please have an administrator go to <2>/auth/setup to enter a license key.", "missing_license": "Missing License", "signup_requires": "Commercial license required", "signup_requires_description": "{{companyName}} currently does not offer a free open source version of the sign up page. To receive full access to the signup components you need to acquire a commercial license. For personal use we recommend the Prisma Data Platform or any other Postgres interface to create accounts.", diff --git a/packages/features/ee/common/components/LicenseRequired.tsx b/packages/features/ee/common/components/LicenseRequired.tsx index 103330b9f2..47a960ae47 100644 --- a/packages/features/ee/common/components/LicenseRequired.tsx +++ b/packages/features/ee/common/components/LicenseRequired.tsx @@ -1,11 +1,12 @@ import DOMPurify from "dompurify"; import { useSession } from "next-auth/react"; +import { Trans } from "next-i18next"; import type { AriaRole, ComponentType } from "react"; -import React, { Fragment } from "react"; +import React, { Fragment, useEffect } from "react"; import { APP_NAME, CONSOLE_URL, SUPPORT_MAIL_ADDRESS, WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; -import { EmptyScreen } from "@calcom/ui"; +import { EmptyScreen, TopBanner } from "@calcom/ui"; import { AlertTriangle } from "@calcom/ui/components/icon"; type LicenseRequiredProps = { @@ -21,10 +22,41 @@ const LicenseRequired = ({ children, as = "", ...rest }: LicenseRequiredProps) = const Component = as || Fragment; const hasValidLicense = session.data ? session.data.hasValidLicense : null; + useEffect(() => { + if (process.env.NODE_ENV === "development" && hasValidLicense === false) { + // Very few people will see this, so we don't need to translate it + console.info( + `You're using a feature that requires a valid license. Please go to ${WEBAPP_URL}/auth/setup to enter a license key.` + ); + } + }, []); + return ( {hasValidLicense === null || hasValidLicense ? ( children + ) : process.env.NODE_ENV === "development" ? ( + /** We only show a warning in development mode, but allow the feature to be displayed for development/testing purposes */ + <> + + {t("enterprise_license")}.{" "} + + You can test this feature on development mode. For production usage please have an + administrator go to{" "} + + /auth/setup + {" "} + to enter a license key. + + + } + variant="warning" + /> + {children} + ) : (