Implement UpgradeTip in App install flow (#8968)
This commit is contained in:
1 parent
b36043b637
commit
bfa30aa504
7 files changed
+31
-4
No files matched your search
@@ -36,6 +36,7 @@ const Component = ({
|
|||||||
tos,
|
tos,
|
||||||
privacy,
|
privacy,
|
||||||
isProOnly,
|
isProOnly,
|
||||||
|
teamsPlanRequired,
|
||||||
descriptionItems,
|
descriptionItems,
|
||||||
isTemplate,
|
isTemplate,
|
||||||
dependencies,
|
dependencies,
|
||||||
@@ -152,6 +153,7 @@ const Component = ({
|
|||||||
type={type}
|
type={type}
|
||||||
isProOnly={isProOnly}
|
isProOnly={isProOnly}
|
||||||
disableInstall={disableInstall}
|
disableInstall={disableInstall}
|
||||||
|
teamsPlanRequired={teamsPlanRequired}
|
||||||
render={({ useDefaultComponent, ...props }) => {
|
render={({ useDefaultComponent, ...props }) => {
|
||||||
if (useDefaultComponent) {
|
if (useDefaultComponent) {
|
||||||
props = {
|
props = {
|
||||||
@@ -192,6 +194,7 @@ const Component = ({
|
|||||||
type={type}
|
type={type}
|
||||||
isProOnly={isProOnly}
|
isProOnly={isProOnly}
|
||||||
disableInstall={disableInstall}
|
disableInstall={disableInstall}
|
||||||
|
teamsPlanRequired={teamsPlanRequired}
|
||||||
render={({ useDefaultComponent, ...props }) => {
|
render={({ useDefaultComponent, ...props }) => {
|
||||||
if (useDefaultComponent) {
|
if (useDefaultComponent) {
|
||||||
props = {
|
props = {
|
||||||
@@ -241,7 +244,9 @@ const Component = ({
|
|||||||
</div>
|
</div>
|
||||||
<h4 className="text-emphasis mt-8 font-semibold ">{t("pricing")}</h4>
|
<h4 className="text-emphasis mt-8 font-semibold ">{t("pricing")}</h4>
|
||||||
<span className="text-default">
|
<span className="text-default">
|
||||||
{price === 0 ? (
|
{teamsPlanRequired ? (
|
||||||
|
t("teams_plan_required")
|
||||||
|
) : price === 0 ? (
|
||||||
t("free_to_use_apps")
|
t("free_to_use_apps")
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
@@ -358,6 +363,7 @@ export default function App(props: {
|
|||||||
privacy?: string;
|
privacy?: string;
|
||||||
licenseRequired: AppType["licenseRequired"];
|
licenseRequired: AppType["licenseRequired"];
|
||||||
isProOnly: AppType["isProOnly"];
|
isProOnly: AppType["isProOnly"];
|
||||||
|
teamsPlanRequired: AppType["teamsPlanRequired"];
|
||||||
descriptionItems?: Array<string | { iframe: IframeHTMLAttributes<HTMLIFrameElement> }>;
|
descriptionItems?: Array<string | { iframe: IframeHTMLAttributes<HTMLIFrameElement> }>;
|
||||||
isTemplate?: boolean;
|
isTemplate?: boolean;
|
||||||
disableInstall?: boolean;
|
disableInstall?: boolean;
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ function SingleAppPage(props: inferSSRProps<typeof getStaticProps>) {
|
|||||||
website={data.url}
|
website={data.url}
|
||||||
email={data.email}
|
email={data.email}
|
||||||
licenseRequired={data.licenseRequired}
|
licenseRequired={data.licenseRequired}
|
||||||
|
teamsPlanRequired={data.teamsPlanRequired}
|
||||||
isProOnly={data.isProOnly}
|
isProOnly={data.isProOnly}
|
||||||
descriptionItems={source.data?.items as string[] | undefined}
|
descriptionItems={source.data?.items as string[] | undefined}
|
||||||
isTemplate={data.isTemplate}
|
isTemplate={data.isTemplate}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export default function OmniInstallAppButton({
|
|||||||
<InstallAppButton
|
<InstallAppButton
|
||||||
type={app.type}
|
type={app.type}
|
||||||
isProOnly={app.isProOnly}
|
isProOnly={app.isProOnly}
|
||||||
|
teamsPlanRequired={app.teamsPlanRequired}
|
||||||
wrapperClassName={classNames("[@media(max-width:260px)]:w-full", className)}
|
wrapperClassName={classNames("[@media(max-width:260px)]:w-full", className)}
|
||||||
render={({ useDefaultComponent, ...props }) => {
|
render={({ useDefaultComponent, ...props }) => {
|
||||||
if (useDefaultComponent) {
|
if (useDefaultComponent) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import classNames from "@calcom/lib/classNames";
|
|||||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||||
import { CAL_URL } from "@calcom/lib/constants";
|
import { CAL_URL } from "@calcom/lib/constants";
|
||||||
import { deriveAppDictKeyFromType } from "@calcom/lib/deriveAppDictKeyFromType";
|
import { deriveAppDictKeyFromType } from "@calcom/lib/deriveAppDictKeyFromType";
|
||||||
|
import { useHasTeamPlan } from "@calcom/lib/hooks/useHasPaidPlan";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { trpc } from "@calcom/trpc/react";
|
import { trpc } from "@calcom/trpc/react";
|
||||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||||
@@ -49,14 +50,17 @@ export const InstallAppButtonWithoutPlanCheck = (
|
|||||||
export const InstallAppButton = (
|
export const InstallAppButton = (
|
||||||
props: {
|
props: {
|
||||||
isProOnly?: App["isProOnly"];
|
isProOnly?: App["isProOnly"];
|
||||||
|
teamsPlanRequired?: App["teamsPlanRequired"];
|
||||||
type: App["type"];
|
type: App["type"];
|
||||||
wrapperClassName?: string;
|
wrapperClassName?: string;
|
||||||
disableInstall?: boolean;
|
disableInstall?: boolean;
|
||||||
} & InstallAppButtonProps
|
} & InstallAppButtonProps
|
||||||
) => {
|
) => {
|
||||||
const { isLoading, data: user } = trpc.viewer.me.useQuery();
|
const { isLoading: isUserLoading, data: user } = trpc.viewer.me.useQuery();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const proProtectionElementRef = useRef<HTMLDivElement | null>(null);
|
const proProtectionElementRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const { isLoading: isTeamPlanStatusLoading, hasTeamPlan } = useHasTeamPlan();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const el = proProtectionElementRef.current;
|
const el = proProtectionElementRef.current;
|
||||||
if (!el) {
|
if (!el) {
|
||||||
@@ -72,12 +76,19 @@ export const InstallAppButton = (
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (props.teamsPlanRequired && !hasTeamPlan) {
|
||||||
|
// TODO: I think we should show the UpgradeTip in a Dialog here. This would solve the problem of no way to go back to the App page from the UpgradeTip page(except browser's back button)
|
||||||
|
router.push(props.teamsPlanRequired.upgradeUrl);
|
||||||
|
e.stopPropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}, [isLoading, user, router, props.isProOnly]);
|
}, [isUserLoading, user, router, props.isProOnly, hasTeamPlan, props.teamsPlanRequired]);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isUserLoading || isTeamPlanStatusLoading) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
"publisher": "Cal.com",
|
"publisher": "Cal.com",
|
||||||
"email": "[email protected]",
|
"email": "[email protected]",
|
||||||
"licenseRequired": true,
|
"licenseRequired": true,
|
||||||
|
"teamsPlanRequired": {
|
||||||
|
"upgradeUrl": "/apps/routing-forms/forms"
|
||||||
|
},
|
||||||
"description": "It would allow a booker to connect with the right person or choose the right event, faster. It would work by taking inputs from the booker and using that data to route to the correct booker/event as configured by Cal user",
|
"description": "It would allow a booker to connect with the right person or choose the right event, faster. It would work by taking inputs from the booker and using that data to route to the correct booker/event as configured by Cal user",
|
||||||
"__createdUsingCli": true
|
"__createdUsingCli": true
|
||||||
}
|
}
|
||||||
Vendored
+3
@@ -126,6 +126,9 @@ export interface App {
|
|||||||
/** only required for "usage-based" billing. % of commission for paid bookings */
|
/** only required for "usage-based" billing. % of commission for paid bookings */
|
||||||
commission?: number;
|
commission?: number;
|
||||||
licenseRequired?: boolean;
|
licenseRequired?: boolean;
|
||||||
|
teamsPlanRequired?: {
|
||||||
|
upgradeUrl: string;
|
||||||
|
};
|
||||||
isProOnly?: boolean;
|
isProOnly?: boolean;
|
||||||
appData?: AppData;
|
appData?: AppData;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ export function AppCard({ app, credentials, searchText }: AppCardProps) {
|
|||||||
<InstallAppButton
|
<InstallAppButton
|
||||||
type={app.type}
|
type={app.type}
|
||||||
isProOnly={app.isProOnly}
|
isProOnly={app.isProOnly}
|
||||||
|
teamsPlanRequired={app.teamsPlanRequired}
|
||||||
disableInstall={!!app.dependencies && !app.dependencyData?.some((data) => !data.installed)}
|
disableInstall={!!app.dependencies && !app.dependencyData?.some((data) => !data.installed)}
|
||||||
wrapperClassName="[@media(max-width:260px)]:w-full"
|
wrapperClassName="[@media(max-width:260px)]:w-full"
|
||||||
render={({ useDefaultComponent, ...props }) => {
|
render={({ useDefaultComponent, ...props }) => {
|
||||||
@@ -127,6 +128,7 @@ export function AppCard({ app, credentials, searchText }: AppCardProps) {
|
|||||||
isProOnly={app.isProOnly}
|
isProOnly={app.isProOnly}
|
||||||
wrapperClassName="[@media(max-width:260px)]:w-full"
|
wrapperClassName="[@media(max-width:260px)]:w-full"
|
||||||
disableInstall={!!app.dependencies && app.dependencyData?.some((data) => !data.installed)}
|
disableInstall={!!app.dependencies && app.dependencyData?.some((data) => !data.installed)}
|
||||||
|
teamsPlanRequired={app.teamsPlanRequired}
|
||||||
render={({ useDefaultComponent, ...props }) => {
|
render={({ useDefaultComponent, ...props }) => {
|
||||||
if (useDefaultComponent) {
|
if (useDefaultComponent) {
|
||||||
props = {
|
props = {
|
||||||
|
|||||||
Reference in new issue
Block a user