Skip to content

Commit

Permalink
Introduce new subscription dialog design for creators without a plan (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementPasteau authored Jan 17, 2025
1 parent 9a0df07 commit 56575e7
Show file tree
Hide file tree
Showing 43 changed files with 1,595 additions and 2,215 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ const PrivateAssetPackInformationPage = ({
openSubscriptionDialog({
analyticsMetadata: {
reason: 'Claim asset pack',
recommendedPlanId: 'gdevelop_gold',
},
filter: 'individual',
})
Expand Down
1 change: 1 addition & 0 deletions newIDE/app/src/Course/CourseChapterView.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ const CourseChapterView = React.forwardRef<Props, HTMLDivElement>(
openSubscriptionDialog({
analyticsMetadata: {
reason: 'Unlock course chapter',
recommendedPlanId: 'gdevelop_silver',
},
})
}
Expand Down
5 changes: 4 additions & 1 deletion newIDE/app/src/ExportAndShare/ShareDialog/InviteHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ const InviteHome = ({ cloudProjectId }: Props) => {
{!hasSufficientPermissionsWithSubscription &&
!!projectUserAcls &&
fetchError !== 'project-not-owned' && (
<GetSubscriptionCard subscriptionDialogOpeningReason="Add collaborators on project">
<GetSubscriptionCard
subscriptionDialogOpeningReason="Add collaborators on project"
recommendedPlanIdIfNoSubscription="gdevelop_startup"
>
<Text>
<Trans>
Get a startup subscription to invite collaborators into your
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ function LeaderboardAppearanceDialog({
/>
</ResponsiveLineStackLayout>
{!canUseTheme ? (
<GetSubscriptionCard subscriptionDialogOpeningReason="Leaderboard customization">
<GetSubscriptionCard
subscriptionDialogOpeningReason="Leaderboard customization"
recommendedPlanIdIfNoSubscription="gdevelop_silver"
>
<Line>
<Column noMargin>
<Text noMargin>
Expand Down Expand Up @@ -400,7 +403,10 @@ function LeaderboardAppearanceDialog({
disabled={!useCustomCss || isLoading}
/>
{!canUseCustomCss ? (
<GetSubscriptionCard subscriptionDialogOpeningReason="Leaderboard customization">
<GetSubscriptionCard
subscriptionDialogOpeningReason="Leaderboard customization"
recommendedPlanIdIfNoSubscription="gdevelop_startup"
>
<Line>
<Column noMargin>
<Text noMargin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ function LeaderboardOptionsDialog({
}
/>
{!canDisableLoginInLeaderboard && (
<GetSubscriptionCard subscriptionDialogOpeningReason="Leaderboard customization">
<GetSubscriptionCard
subscriptionDialogOpeningReason="Leaderboard customization"
recommendedPlanIdIfNoSubscription="gdevelop_startup"
>
<Line>
<Column noMargin>
<Text noMargin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const MaxLeaderboardCountAlertMessage = () => {
)
}
hideButton={!leaderboardLimits.canMaximumCountPerGameBeIncreased}
recommendedPlanIdIfNoSubscription="gdevelop_silver"
>
<Line>
<Column noMargin expand>
Expand Down
1 change: 1 addition & 0 deletions newIDE/app/src/GameDashboard/Widgets/ServicesWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const ServicesWidget = ({
openSubscriptionDialog({
analyticsMetadata: {
reason: 'Leaderboard count per game limit reached',
recommendedPlanId: 'gdevelop_silver',
},
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const MaxProjectCountAlertMessage = ({ margin }: Props) => {
)
}
hideButton={!canMaximumCountBeIncreased}
recommendedPlanIdIfNoSubscription="gdevelop_silver"
>
<Line>
<Column noMargin expand>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ const EducationMarketingSection = ({
filter: 'education',
analyticsMetadata: {
reason: 'Callout in Classroom tab',
recommendedPlanId: 'gdevelop_education',
},
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ const ManageEducationAccountDialog = ({ onClose }: Props) => {
openSubscriptionDialog({
analyticsMetadata: {
reason: 'Manage subscription as teacher',
recommendedPlanId: 'gdevelop_education',
},
filter: 'education',
})
Expand Down
3 changes: 2 additions & 1 deletion newIDE/app/src/MainFrame/RouterContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type RouteKey =
| 'game-template'
| 'tutorial-id'
| 'course-id'
| 'create-from-example';
| 'create-from-example'
| 'recommended-plan-id';
export type RouteArguments = { [RouteKey]: string };

export type Router = {|
Expand Down
6 changes: 4 additions & 2 deletions newIDE/app/src/Profile/CurrentUsageDisplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const CurrentUsageDisplayer = ({
if (!quota || !subscription || !usagePrice) return <PlaceholderLoader />;

const isFeatureLocked = quota.max === 0;
const hasSubscription = hasValidSubscriptionPlan(subscription);
const hasValidSubscription = hasValidSubscriptionPlan(subscription);
const remainingBuilds = Math.max(quota.max - quota.current, 0);
const usageRatio = `${quota.current}/${quota.max}`;
const remainingMultipleMessage =
Expand Down Expand Up @@ -132,7 +132,7 @@ const CurrentUsageDisplayer = ({

return (
<ColumnStackLayout noMargin>
{hasSubscription ? (
{hasValidSubscription ? (
!quota.limitReached ? (
<div
style={{
Expand Down Expand Up @@ -172,6 +172,7 @@ const CurrentUsageDisplayer = ({
}
}
hideButton={cannotUpgradeSubscription}
recommendedPlanIdIfNoSubscription="gdevelop_silver"
>
<Line>
{!isFeatureLocked ? (
Expand Down Expand Up @@ -217,6 +218,7 @@ const CurrentUsageDisplayer = ({
onPayWithCredits: onPurchaseBuildWithCredits,
}
}
recommendedPlanIdIfNoSubscription="gdevelop_silver"
>
<Line>
{!isFeatureLocked ? (
Expand Down
1 change: 1 addition & 0 deletions newIDE/app/src/Profile/RedeemCodeDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export default function RedeemCodeDialog({
floatingLabelFixed
errorText={getRedeemCodeErrorText(error)}
autoFocus="desktop"
disabled={isLoading}
/>
{!subscription ||
!subscription.planId ? null : !!subscription.redemptionCodeValidUntil ? ( // No subscription, do not show a warning.
Expand Down
14 changes: 14 additions & 0 deletions newIDE/app/src/Profile/Subscription/GetSubscriptionCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import classes from './GetSubscriptionCard.module.css';
import Paper from '../../UI/Paper';
import CrownShining from '../../UI/CustomSvgIcons/CrownShining';
import { useResponsiveWindowSize } from '../../UI/Responsive/ResponsiveWindowMeasurer';
import AuthenticatedUserContext from '../AuthenticatedUserContext';
import { hasValidSubscriptionPlan } from '../../Utils/GDevelopServices/Usage';

const styles = {
paper: {
Expand Down Expand Up @@ -42,6 +44,11 @@ type Props = {|
onUpgrade?: () => void,
forceColumnLayout?: boolean,
filter?: 'individual' | 'team' | 'education',
recommendedPlanIdIfNoSubscription?:
| 'gdevelop_silver'
| 'gdevelop_gold'
| 'gdevelop_startup'
| 'gdevelop_education',
|};

const GetSubscriptionCard = ({
Expand All @@ -53,7 +60,13 @@ const GetSubscriptionCard = ({
onUpgrade,
forceColumnLayout,
filter,
recommendedPlanIdIfNoSubscription,
}: Props) => {
const { subscription } = React.useContext(AuthenticatedUserContext);
const actualPlanIdToRecommend = hasValidSubscriptionPlan(subscription)
? // If the user already has a subscription, show the original subscription dialog.
undefined
: recommendedPlanIdIfNoSubscription;
const { openSubscriptionDialog } = React.useContext(
SubscriptionSuggestionContext
);
Expand Down Expand Up @@ -93,6 +106,7 @@ const GetSubscriptionCard = ({
openSubscriptionDialog({
analyticsMetadata: {
reason: subscriptionDialogOpeningReason,
recommendedPlanId: actualPlanIdToRecommend,
},
filter,
});
Expand Down
Loading

0 comments on commit 56575e7

Please sign in to comment.