Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
feat: Show plan name instead of Pro badge (#2815)
Ivan Starkovb8067ac99629
diff --git a/apps/builder/app/builder/features/settings-panel/variable-popover.tsx b/apps/builder/app/builder/features/settings-panel/variable-popover.tsxindex 864da2cc1f..d9b56d52af 100644--- a/apps/builder/app/builder/features/settings-panel/variable-popover.tsx+++ b/apps/builder/app/builder/features/settings-panel/variable-popover.tsx@@ -395,7 +395,7 @@ const VariablePanel = forwardRef<{getTypeLabel(option)}{option === "resource" && allowResourceVariables === false && (<Box css={{ display: "inline-block", ml: theme.spacing[3] }}>- <ProBadge />+ <ProBadge>Pro</ProBadge></Box>)}</SelectItem>diff --git a/apps/builder/app/dashboard/header.tsx b/apps/builder/app/dashboard/header.tsxindex 5695bcf021..bf2d07c516 100644--- a/apps/builder/app/dashboard/header.tsx+++ b/apps/builder/app/dashboard/header.tsx@@ -50,7 +50,7 @@ const Menu = ({<Flex gap="1" align="center">{userPlanFeatures.hasProPlan && (<>- <ProBadge />+ <ProBadge>{userPlanFeatures.planName}</ProBadge><div /></>)}diff --git a/apps/builder/app/shared/db/user-plan-features.server.ts b/apps/builder/app/shared/db/user-plan-features.server.tsindex 38b18e6a2d..45fee29eea 100644--- a/apps/builder/app/shared/db/user-plan-features.server.ts+++ b/apps/builder/app/shared/db/user-plan-features.server.ts@@ -1,18 +1,7 @@import { prisma } from "@webstudio-is/prisma-client";+import type { AppContext } from "@webstudio-is/trpc-interface/index.server";-/**- * Plan features are available on the client, do not use any secrets, 3rd party ids etc- **/-export type UserPlanFeatures = {- allowShareAdminLinks: boolean;- allowResourceVariables: boolean;- maxDomainsAllowedPerUser: number;- hasSubscription: boolean;- hasProPlan: boolean;-};--// No strings - no secrets-({}) as UserPlanFeatures satisfies Record<string, boolean | number>;+export type UserPlanFeatures = NonNullable<AppContext["userPlanFeatures"]>;export const getTokenPlanFeatures = async (token: string) => {const projectOwnerIdByToken = await prisma.authorizationToken.findUnique({@@ -77,6 +66,7 @@ export const getUserPlanFeatures = async (maxDomainsAllowedPerUser: Number.MAX_SAFE_INTEGER,hasSubscription,hasProPlan: true,+ planName: userProducts[0].product.name,};}diff --git a/packages/design-system/src/components/pro-badge.tsx b/packages/design-system/src/components/pro-badge.tsxindex 6c3eda310d..9610f259f1 100644--- a/packages/design-system/src/components/pro-badge.tsx+++ b/packages/design-system/src/components/pro-badge.tsx@@ -1,7 +1,8 @@+import type { ReactNode } from "react";import { theme } from "../stitches.config";import { Text } from "./text";-export const ProBadge = () => {+export const ProBadge = (props: { children: ReactNode }) => {return (<Textcss={{@@ -20,7 +21,7 @@ export const ProBadge = () => {background: theme.colors.backgroundStyleSourceNeutral,}}>- Pro+ {props.children}</Text>);};diff --git a/packages/prisma-client/src/types.ts b/packages/prisma-client/src/types.tsindex ec7a182f16..f2c14b09c8 100644--- a/packages/prisma-client/src/types.ts+++ b/packages/prisma-client/src/types.ts@@ -13,4 +13,5 @@ export type {LatestBuildPerProjectDomain,LatestBuildPerProject,PublishStatus,+ Product,} from "./__generated__";diff --git a/packages/trpc-interface/src/context/context.server.ts b/packages/trpc-interface/src/context/context.server.tsindex ce07f70e80..d9390ea52f 100644--- a/packages/trpc-interface/src/context/context.server.ts+++ b/packages/trpc-interface/src/context/context.server.ts@@ -55,8 +55,19 @@ type UserPlanFeatures = {allowResourceVariables: boolean;maxDomainsAllowedPerUser: number;hasSubscription: boolean;- hasProPlan: boolean;-};+} & (+ | {+ hasProPlan: true;+ planName: string;+ }+ | { hasProPlan: false }+);++// No strings except planName - no secrets+({}) as Omit<UserPlanFeatures, "planName"> satisfies Record<+ string,+ boolean | number+>;/*** AppContext is a global context that is passed to all trpc/api queries/mutations