9df4867fca
* WIP License server * WIP * Moves locations to App Store and Core * LocationType fixes * Runs db migrations post-deploy * WIP * WIP * Cleanup * WIP * WIP * Decouples translations from NavTabs * Adds admin submodule * Adds admin submodule * Sync dependencies * WIP * WIP * Updates submodules * Renames package * Updates submodules * Adds scripts for console * Updates license checker URL * Updates admin * Adds staging/prod admin console links * Update yarn.lock * Update NavTabs.tsx * WIP * Update admin * WIP * Adds hint to InputField * Update admin * Adds turbo admin dependecies * Update admin * Prevents redirection on form submit * Form warning fixes * Update admin * Form fixes * Update yarn.lock * Update admin * Update admin * Update admin * Adds withLicenseRequired HOC * Adds LicenseRequired to EE components * Admin deploy fix? * Updates submodules * Use relative inside lib * type fixes * Fixes turbo race condition * Relocates admin to console * Relocates admin to console * Update console * Update api * Update turbo.json * Update ErrorBoundary.tsx * Update defaultEvents.ts * Update checkLicense.ts * Update yarn.lock * Skip on E2E Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import { ExclamationIcon } from "@heroicons/react/solid";
|
|
import { useSession } from "next-auth/react";
|
|
import React, { AriaRole, ComponentType, FC, Fragment } from "react";
|
|
|
|
import { CONSOLE_URL } from "@calcom/lib/constants";
|
|
|
|
import EmptyScreen from "@components/EmptyScreen";
|
|
|
|
type LicenseRequiredProps = {
|
|
as?: keyof JSX.IntrinsicElements | "";
|
|
className?: string;
|
|
role?: AriaRole | undefined;
|
|
children: React.ReactNode;
|
|
};
|
|
|
|
/**
|
|
* This component will only render it's children if the installation has a valid
|
|
* license.
|
|
*/
|
|
const LicenseRequired: FC<LicenseRequiredProps> = ({ children, as = "", ...rest }) => {
|
|
const session = useSession();
|
|
const Component = as || Fragment;
|
|
return (
|
|
<Component {...rest}>
|
|
{session.data?.hasValidLicense ? (
|
|
children
|
|
) : (
|
|
<EmptyScreen
|
|
Icon={ExclamationIcon}
|
|
headline="This is an enterprise feature"
|
|
description={
|
|
<>
|
|
To enable this feature, get a deployment key at{" "}
|
|
<a href={CONSOLE_URL} target="_blank" rel="noopener noreferrer" className="underline">
|
|
Cal.com console
|
|
</a>
|
|
.
|
|
</>
|
|
}
|
|
/>
|
|
)}
|
|
</Component>
|
|
);
|
|
};
|
|
|
|
export function withLicenseRequired<T>(Component: ComponentType<T>) {
|
|
// eslint-disable-next-line react/display-name
|
|
return (hocProps: T) => {
|
|
return (
|
|
<LicenseRequired>
|
|
<Component {...(hocProps as T)} />;
|
|
</LicenseRequired>
|
|
);
|
|
};
|
|
}
|
|
|
|
export default LicenseRequired;
|