Skip to content

Commit 7d71147

Browse files
committed
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 7b53470 commit 7d71147

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
@@ -82,11 +82,11 @@ import DomainCheckbox, { domainToPublishName } from "./domain-checkbox";
8282
import { CopyToClipboard } from "~/builder/shared/copy-to-clipboard";
8383
import { $openProjectSettings } from "~/shared/nano-states/project-settings";
8484
import { RelativeTime } from "~/builder/shared/relative-time";
85-
import cmsUpgradeBanner from "../settings-panel/cms-upgrade-banner.svg?url";
8685
import { showAttribute } from "@webstudio-is/react-sdk";
87-
import { $styleObjectModel } from "../style-panel/shared/model";
8886
import { toValue, type CssProperty } from "@webstudio-is/css-engine";
8987
import { getComputedStyleDecl } from "~/shared/style-object-model";
88+
import { $styleObjectModel } from "../style-panel/shared/model";
89+
import cmsUpgradeBanner from "../settings-panel/cms-upgrade-banner.svg?url";
9090

9191
type ChangeProjectDomainProps = {
9292
project: Project;
@@ -774,6 +774,108 @@ const buttonLinkClass = css({
774774
...textVariants.link,
775775
}).toString();
776776

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

792-
const { canAddDomain, maxDomainsAllowedPerUser } = useCanAddDomain();
793894
const { userPublishCount, maxPublishesAllowedPerUser } =
794895
useUserPublishCount();
795896

796897
return (
797898
<form>
798899
<ScrollArea>
799-
{userPublishCount >= maxPublishesAllowedPerUser ? (
800-
<PanelBanner>
801-
<Text variant="regularBold">
802-
Upgrade to publish more than {maxPublishesAllowedPerUser} times
803-
per day:
804-
</Text>
805-
<Link
806-
className={buttonStyle({ color: "gradient" })}
807-
color="contrast"
808-
underline="none"
809-
href="https://webstudio.is/pricing"
810-
target="_blank"
811-
>
812-
Upgrade
813-
</Link>
814-
</PanelBanner>
815-
) : usedProFeatures.size > 0 && hasProPlan === false ? (
816-
<PanelBanner>
817-
<img
818-
src={cmsUpgradeBanner}
819-
alt="Upgrade for CMS"
820-
width={rawTheme.spacing[28]}
821-
style={{ aspectRatio: "4.1" }}
822-
/>
823-
<Text variant="regularBold">
824-
Upgrade to publish with following features:
825-
</Text>
826-
<Text as="ul">
827-
{Array.from(usedProFeatures).map(
828-
([message, { awareness, info } = {}], index) => (
829-
<li key={index}>
830-
<Flex align="center" gap="1">
831-
{awareness ? (
832-
<button
833-
className={buttonLinkClass}
834-
type="button"
835-
onClick={() => $awareness.set(awareness)}
836-
>
837-
{message}
838-
</button>
839-
) : (
840-
message
841-
)}
842-
{info && (
843-
<Tooltip variant="wrapped" content={info}>
844-
<SmallIconButton icon={<HelpIcon />} />
845-
</Tooltip>
846-
)}
847-
</Flex>
848-
</li>
849-
)
850-
)}
851-
</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-
) : canAddDomain === false ? (
864-
<PanelBanner>
865-
<Text variant="regularBold">Free domains limit reached</Text>
866-
<Text variant="regular">
867-
You have reached the limit of {maxDomainsAllowedPerUser} custom
868-
domains on your account.{" "}
869-
<Text variant="regularBold" inline>
870-
Upgrade to a Pro account
871-
</Text>{" "}
872-
to add unlimited domains and publish to each domain individually.
873-
</Text>
874-
<Link
875-
className={buttonStyle({ color: "gradient" })}
876-
color="contrast"
877-
underline="none"
878-
href="https://webstudio.is/pricing"
879-
target="_blank"
880-
>
881-
Upgrade
882-
</Link>
883-
</PanelBanner>
884-
) : null}
885900
<RadioGroup name="publishDomain">
886901
<ChangeProjectDomain
887902
refresh={refreshProject}
@@ -911,6 +926,7 @@ const Content = (props: {
911926
}}
912927
onExportClick={props.onExportClick}
913928
/>
929+
{hasProPlan === false && <UpgradeBanner />}
914930
<Publish
915931
project={project}
916932
refresh={refreshProject}

0 commit comments

Comments
 (0)