@@ -401,19 +401,28 @@ const Publish = ({
401401 timesLeft,
402402 disabled,
403403 refresh,
404+ restrictedFeatures,
404405} : {
405406 project : Project ;
406407 timesLeft : number ;
407408 disabled : boolean ;
408409 refresh : ( ) => Promise < void > ;
410+ restrictedFeatures : Map <
411+ string ,
412+ | undefined
413+ | { awareness ?: Awareness ; view ?: "pageSettings" ; info ?: ReactNode }
414+ > ;
409415} ) => {
410416 const { maxDailyPublishesPerUser } = useStore ( $permissions ) ;
417+ const { userPublishCount } = useUserPublishCount ( ) ;
411418 const [ publishError , setPublishError ] = useState <
412419 undefined | JSX . Element | string
413420 > ( ) ;
414421 const [ isPublishing , setIsPublishing ] = useOptimistic ( false ) ;
415422 const buttonRef = useRef < HTMLButtonElement > ( null ) ;
416423 const [ hasSelectedDomains , setHasSelectedDomains ] = useState ( false ) ;
424+ const [ hasCustomDomainsSelected , setHasCustomDomainsSelected ] =
425+ useState ( false ) ;
417426 const countdown = usePublishCountdown ( isPublishing ) ;
418427
419428 useEffect ( ( ) => {
@@ -425,8 +434,18 @@ const Publish = ({
425434
426435 const handleFormInput = ( ) => {
427436 const formData = new FormData ( form ) ;
428- const domainsSelected = formData . getAll ( domainToPublishName ) . length ;
429- setHasSelectedDomains ( domainsSelected > 0 ) ;
437+ const domainsSelected = formData
438+ . getAll ( domainToPublishName )
439+ . map ( ( domain ) => domain . toString ( ) ) ;
440+
441+ setHasSelectedDomains ( domainsSelected . length > 0 ) ;
442+
443+ // Check if any custom domains are selected
444+ // Custom domains are those that are NOT the staging domain (project.domain)
445+ const hasCustom = domainsSelected . some (
446+ ( domain ) => domain !== project . domain
447+ ) ;
448+ setHasCustomDomainsSelected ( hasCustom ) ;
430449 } ;
431450
432451 const observer = new MutationObserver ( ( ) => {
@@ -445,7 +464,7 @@ const Publish = ({
445464 return ( ) => {
446465 observer . disconnect ( ) ;
447466 } ;
448- } , [ ] ) ;
467+ } , [ project . domain ] ) ;
449468
450469 const handlePublish = async ( formData : FormData ) => {
451470 setPublishError ( undefined ) ;
@@ -582,7 +601,12 @@ const Publish = ({
582601 formAction = { handlePublish }
583602 color = "positive"
584603 state = { showPendingState ? "pending" : undefined }
585- disabled = { hasSelectedDomains === false || disabled }
604+ disabled = {
605+ hasSelectedDomains === false ||
606+ disabled ||
607+ ( restrictedFeatures . size > 0 && hasCustomDomainsSelected ) ||
608+ userPublishCount >= maxDailyPublishesPerUser
609+ }
586610 >
587611 { countdown !== undefined && countdown > 0
588612 ? `Publishing (${ countdown } s)`
@@ -789,7 +813,7 @@ const buttonLinkClass = css({
789813 ...textVariants . link ,
790814} ) . toString ( ) ;
791815
792- const UpgradeBanner = ( ) => {
816+ const UpgradeBanner = ( { hasCustomDomains } : { hasCustomDomains : boolean } ) => {
793817 const restrictedFeatures = useStore ( $restrictedFeatures ) ;
794818 const { canAddDomain } = useCanAddDomain ( ) ;
795819 const { userPublishCount, maxDailyPublishesPerUser } = useUserPublishCount ( ) ;
@@ -812,7 +836,9 @@ const UpgradeBanner = () => {
812836 ) ;
813837 }
814838
815- if ( restrictedFeatures . size > 0 ) {
839+ // Only show Pro feature upgrade banner if custom domains are available
840+ // Free tier users can still publish to staging domain with Pro features
841+ if ( restrictedFeatures . size > 0 && hasCustomDomains ) {
816842 return (
817843 < PanelBanner >
818844 < img
@@ -854,7 +880,9 @@ const UpgradeBanner = () => {
854880 )
855881 ) }
856882 </ Text >
857- < Text > You can delete these features or upgrade.</ Text >
883+ < Text >
884+ You can delete these features or upgrade to publish to custom domains.
885+ </ Text >
858886 < Flex align = "center" gap = { 1 } >
859887 < UpgradeIcon />
860888 < Link
@@ -915,6 +943,11 @@ const Content = (props: {
915943 domain . latestBuildVirtual == null
916944 ) ;
917945
946+ // Check if any custom domains exist (active and verified)
947+ const hasCustomDomains = project . domainsVirtual . some (
948+ ( domain ) => domain . status === "ACTIVE" && domain . verified
949+ ) ;
950+
918951 return (
919952 < form >
920953 < ScrollArea >
@@ -947,7 +980,7 @@ const Content = (props: {
947980 } }
948981 onExportClick = { props . onExportClick }
949982 />
950- < UpgradeBanner />
983+ < UpgradeBanner hasCustomDomains = { hasCustomDomains } />
951984 { hasUnpublishedDomains && (
952985 < PanelBanner >
953986 < Flex align = "center" gap = "1" >
@@ -964,10 +997,8 @@ const Content = (props: {
964997 project = { project }
965998 refresh = { refreshProject }
966999 timesLeft = { maxDailyPublishesPerUser - userPublishCount }
967- disabled = {
968- restrictedFeatures . size > 0 ||
969- userPublishCount >= maxDailyPublishesPerUser
970- }
1000+ disabled = { false }
1001+ restrictedFeatures = { restrictedFeatures }
9711002 />
9721003 </ Flex >
9731004 </ form >
0 commit comments