refactor: Skip license checks for development (#9375)

This commit is contained in:
Omar López 2023-06-21 19:13:26 -07:00 committed by GitHub
parent a3a6caa6dd
commit 5cecf3104f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 4 deletions

View File

@ -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 theyre 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</2> 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.",

View File

@ -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 (
<Component {...rest}>
{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 */
<>
<TopBanner
text=""
actions={
<>
{t("enterprise_license")}.{" "}
<Trans i18nKey="enterprise_license_development">
You can test this feature on development mode. For production usage please have an
administrator go to{" "}
<a href={`${WEBAPP_URL}/auth/setup`} className="underline">
/auth/setup
</a>{" "}
to enter a license key.
</Trans>
</>
}
variant="warning"
/>
{children}
</>
) : (
<EmptyScreen
Icon={AlertTriangle}