Skip to content

Commit 78d3145

Browse files
authored
fix: Improve clarity of the upgrade banner (#5282)
## Description <img width="348" alt="image" src="https://github.com/user-attachments/assets/85ff2cb9-9cdf-4283-b932-c03423fcc02e" /> 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
1 parent 88a29bf commit 78d3145

File tree

1 file changed

+105
-89
lines changed

1 file changed

+105
-89
lines changed

apps/builder/app/builder/features/topbar/publish.tsx

Lines changed: 105 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ import DomainCheckbox, { domainToPublishName } from "./domain-checkbox";
8383
import { CopyToClipboard } from "~/builder/shared/copy-to-clipboard";
8484
import { $openProjectSettings } from "~/shared/nano-states/project-settings";
8585
import { RelativeTime } from "~/builder/shared/relative-time";
86-
import cmsUpgradeBanner from "../settings-panel/cms-upgrade-banner.svg?url";
8786
import { showAttribute } from "@webstudio-is/react-sdk";
88-
import { $styleObjectModel } from "../style-panel/shared/model";
8987
import { toValue, type CssProperty } from "@webstudio-is/css-engine";
9088
import { getComputedStyleDecl } from "~/shared/style-object-model";
89+
import { $styleObjectModel } from "../style-panel/shared/model";
90+
import cmsUpgradeBanner from "../settings-panel/cms-upgrade-banner.svg?url";
9191

9292
type ChangeProjectDomainProps = {
9393
project: Project;
@@ -786,6 +786,108 @@ const buttonLinkClass = css({
786786
...textVariants.link,
787787
}).toString();
788788

789+
const UpgradeBanner = () => {
790+
const usedProFeatures = useStore($usedProFeatures);
791+
const { canAddDomain, maxDomainsAllowedPerUser } = useCanAddDomain();
792+
const { userPublishCount, maxPublishesAllowedPerUser } =
793+
useUserPublishCount();
794+
795+
if (userPublishCount >= maxPublishesAllowedPerUser) {
796+
return (
797+
<PanelBanner>
798+
<Text variant="regularBold">
799+
Upgrade to publish more than {maxPublishesAllowedPerUser} times per
800+
day:
801+
</Text>
802+
<Link
803+
className={buttonStyle({ color: "gradient" })}
804+
color="contrast"
805+
underline="none"
806+
href="https://webstudio.is/pricing"
807+
target="_blank"
808+
>
809+
Upgrade
810+
</Link>
811+
</PanelBanner>
812+
);
813+
}
814+
815+
if (usedProFeatures.size > 0) {
816+
return (
817+
<PanelBanner>
818+
<img
819+
src={cmsUpgradeBanner}
820+
alt="Upgrade for CMS"
821+
width={rawTheme.spacing[28]}
822+
style={{ aspectRatio: "4.1" }}
823+
/>
824+
<Text variant="regularBold">Following Pro features are used:</Text>
825+
<Text as="ul" color="destructive" css={{ paddingLeft: "1em" }}>
826+
{Array.from(usedProFeatures).map(
827+
([message, { awareness, info } = {}], index) => (
828+
<li key={index}>
829+
<Flex align="center" gap="1">
830+
{awareness ? (
831+
<button
832+
className={buttonLinkClass}
833+
type="button"
834+
onClick={() => $awareness.set(awareness)}
835+
>
836+
{message}
837+
</button>
838+
) : (
839+
message
840+
)}
841+
{info && (
842+
<Tooltip variant="wrapped" content={info}>
843+
<SmallIconButton icon={<HelpIcon />} />
844+
</Tooltip>
845+
)}
846+
</Flex>
847+
</li>
848+
)
849+
)}
850+
</Text>
851+
<Text>You can delete these features or upgrade.</Text>
852+
<Flex align="center" gap={1}>
853+
<UpgradeIcon />
854+
<Link
855+
color="inherit"
856+
target="_blank"
857+
href="https://webstudio.is/pricing"
858+
>
859+
Upgrade to Pro
860+
</Link>
861+
</Flex>
862+
</PanelBanner>
863+
);
864+
}
865+
if (canAddDomain === false) {
866+
return (
867+
<PanelBanner>
868+
<Text variant="regularBold">Free domains limit reached</Text>
869+
<Text variant="regular">
870+
You have reached the limit of {maxDomainsAllowedPerUser} custom
871+
domains on your account.{" "}
872+
<Text variant="regularBold" inline>
873+
Upgrade to a Pro account
874+
</Text>{" "}
875+
to add unlimited domains and publish to each domain individually.
876+
</Text>
877+
<Link
878+
className={buttonStyle({ color: "gradient" })}
879+
color="contrast"
880+
underline="none"
881+
href="https://webstudio.is/pricing"
882+
target="_blank"
883+
>
884+
Upgrade
885+
</Link>
886+
</PanelBanner>
887+
);
888+
}
889+
};
890+
789891
const Content = (props: {
790892
projectId: Project["id"];
791893
onExportClick: () => void;
@@ -801,99 +903,12 @@ const Content = (props: {
801903
}
802904
const projectState = "idle";
803905

804-
const { canAddDomain, maxDomainsAllowedPerUser } = useCanAddDomain();
805906
const { userPublishCount, maxPublishesAllowedPerUser } =
806907
useUserPublishCount();
807908

808909
return (
809910
<form>
810911
<ScrollArea>
811-
{userPublishCount >= maxPublishesAllowedPerUser ? (
812-
<PanelBanner>
813-
<Text variant="regularBold">
814-
Upgrade to publish more than {maxPublishesAllowedPerUser} times
815-
per day:
816-
</Text>
817-
<Link
818-
className={buttonStyle({ color: "gradient" })}
819-
color="contrast"
820-
underline="none"
821-
href="https://webstudio.is/pricing"
822-
target="_blank"
823-
>
824-
Upgrade
825-
</Link>
826-
</PanelBanner>
827-
) : usedProFeatures.size > 0 && hasProPlan === false ? (
828-
<PanelBanner>
829-
<img
830-
src={cmsUpgradeBanner}
831-
alt="Upgrade for CMS"
832-
width={rawTheme.spacing[28]}
833-
style={{ aspectRatio: "4.1" }}
834-
/>
835-
<Text variant="regularBold">
836-
Upgrade to publish with following features:
837-
</Text>
838-
<Text as="ul">
839-
{Array.from(usedProFeatures).map(
840-
([message, { awareness, info } = {}], index) => (
841-
<li key={index}>
842-
<Flex align="center" gap="1">
843-
{awareness ? (
844-
<button
845-
className={buttonLinkClass}
846-
type="button"
847-
onClick={() => $awareness.set(awareness)}
848-
>
849-
{message}
850-
</button>
851-
) : (
852-
message
853-
)}
854-
{info && (
855-
<Tooltip variant="wrapped" content={info}>
856-
<SmallIconButton icon={<HelpIcon />} />
857-
</Tooltip>
858-
)}
859-
</Flex>
860-
</li>
861-
)
862-
)}
863-
</Text>
864-
<Flex align="center" gap={1}>
865-
<UpgradeIcon />
866-
<Link
867-
color="inherit"
868-
target="_blank"
869-
href="https://webstudio.is/pricing"
870-
>
871-
Upgrade to Pro
872-
</Link>
873-
</Flex>
874-
</PanelBanner>
875-
) : canAddDomain === false ? (
876-
<PanelBanner>
877-
<Text variant="regularBold">Free domains limit reached</Text>
878-
<Text variant="regular">
879-
You have reached the limit of {maxDomainsAllowedPerUser} custom
880-
domains on your account.{" "}
881-
<Text variant="regularBold" inline>
882-
Upgrade to a Pro account
883-
</Text>{" "}
884-
to add unlimited domains and publish to each domain individually.
885-
</Text>
886-
<Link
887-
className={buttonStyle({ color: "gradient" })}
888-
color="contrast"
889-
underline="none"
890-
href="https://webstudio.is/pricing"
891-
target="_blank"
892-
>
893-
Upgrade
894-
</Link>
895-
</PanelBanner>
896-
) : null}
897912
<RadioGroup name="publishDomain">
898913
<ChangeProjectDomain
899914
refresh={refreshProject}
@@ -923,6 +938,7 @@ const Content = (props: {
923938
}}
924939
onExportClick={props.onExportClick}
925940
/>
941+
{hasProPlan === false && <UpgradeBanner />}
926942
<Publish
927943
project={project}
928944
refresh={refreshProject}

0 commit comments

Comments
 (0)