diff --git a/apps/builder/app/builder/features/topbar/publish.tsx b/apps/builder/app/builder/features/topbar/publish.tsx index 6c4cddd76703..66ac15393929 100644 --- a/apps/builder/app/builder/features/topbar/publish.tsx +++ b/apps/builder/app/builder/features/topbar/publish.tsx @@ -44,7 +44,6 @@ import { import { validateProjectDomain, type Project } from "@webstudio-is/project"; import { $awareness, - $selectedPagePath, findAwarenessByInstanceId, type Awareness, } from "~/shared/awareness"; @@ -101,15 +100,11 @@ const ChangeProjectDomain = ({ }: ChangeProjectDomainProps) => { const id = useId(); const publishedOrigin = useStore($publishedOrigin); - const selectedPagePath = useStore($selectedPagePath); const [domain, setDomain] = useState(project.domain); const [error, setError] = useState(); const [isUpdateInProgress, setIsUpdateInProgress] = useOptimistic(false); - const pageUrl = new URL(publishedOrigin); - pageUrl.pathname = selectedPagePath; - const updateProjectDomain = async () => { setIsUpdateInProgress(true); const validationResult = validateProjectDomain(domain); @@ -148,7 +143,7 @@ const ChangeProjectDomain = ({ return ( - - Proceed to ${pageUrl.toString()} - - } - variant="wrapped" - > + { - window.open(pageUrl, "_blank"); + window.open(publishedOrigin, "_blank"); event.preventDefault(); }} > @@ -786,6 +774,108 @@ const buttonLinkClass = css({ ...textVariants.link, }).toString(); +const UpgradeBanner = () => { + const usedProFeatures = useStore($usedProFeatures); + const { canAddDomain, maxDomainsAllowedPerUser } = useCanAddDomain(); + const { userPublishCount, maxPublishesAllowedPerUser } = + useUserPublishCount(); + + if (userPublishCount >= maxPublishesAllowedPerUser) { + return ( + + + Upgrade to publish more than {maxPublishesAllowedPerUser} times per + day: + + + Upgrade + + + ); + } + + if (usedProFeatures.size > 0) { + return ( + + Upgrade for CMS + Following Pro features are used: + + {Array.from(usedProFeatures).map( + ([message, { awareness, info } = {}], index) => ( +
  • + + {awareness ? ( + + ) : ( + message + )} + {info && ( + + } /> + + )} + +
  • + ) + )} +
    + You can delete these features or upgrade. + + + + Upgrade to Pro + + +
    + ); + } + if (canAddDomain === false) { + return ( + + Free domains limit reached + + You have reached the limit of {maxDomainsAllowedPerUser} custom + domains on your account.{" "} + + Upgrade to a Pro account + {" "} + to add unlimited domains and publish to each domain individually. + + + Upgrade + + + ); + } +}; + const Content = (props: { projectId: Project["id"]; onExportClick: () => void; @@ -801,99 +891,12 @@ const Content = (props: { } const projectState = "idle"; - const { canAddDomain, maxDomainsAllowedPerUser } = useCanAddDomain(); const { userPublishCount, maxPublishesAllowedPerUser } = useUserPublishCount(); return (
    - {userPublishCount >= maxPublishesAllowedPerUser ? ( - - - Upgrade to publish more than {maxPublishesAllowedPerUser} times - per day: - - - Upgrade - - - ) : usedProFeatures.size > 0 && hasProPlan === false ? ( - - Upgrade for CMS - - Upgrade to publish with following features: - - - {Array.from(usedProFeatures).map( - ([message, { awareness, info } = {}], index) => ( -
  • - - {awareness ? ( - - ) : ( - message - )} - {info && ( - - } /> - - )} - -
  • - ) - )} -
    - - - - Upgrade to Pro - - -
    - ) : canAddDomain === false ? ( - - Free domains limit reached - - You have reached the limit of {maxDomainsAllowedPerUser} custom - domains on your account.{" "} - - Upgrade to a Pro account - {" "} - to add unlimited domains and publish to each domain individually. - - - Upgrade - - - ) : null} + {hasProPlan === false && }