Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Max projects callout #7096

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ const BuildSection = ({
<SectionContainer
showUrgentAnnouncements={shouldDisplayAnnouncements}
renderFooter={
limits && hasTooManyCloudProjects
!isMobile && limits && hasTooManyCloudProjects
? () => (
<Line>
<Column expand>
Expand Down Expand Up @@ -618,6 +618,19 @@ const BuildSection = ({
}
/>
))}
{isMobile && limits && hasTooManyCloudProjects && (
<MaxProjectCountAlertMessage
margin="dense"
limits={limits}
onUpgrade={() =>
openSubscriptionDialog({
analyticsMetadata: {
reason: 'Cloud Project limit reached',
},
})
}
/>
)}
</List>
</Column>
</Line>
Expand Down
23 changes: 22 additions & 1 deletion newIDE/app/src/QuickCustomization/QuickPublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export const QuickPublish = ({
const eventsFunctionsExtensionsState = React.useContext(
EventsFunctionsExtensionsContext
);
const [
numberOfCloudProjectsBeforeSavingCustomizedGame,
setNumberOfCloudProjectsBeforeSavingCustomizedGame,
] = React.useState<number | null>(null);
const [exportState, setExportState] = React.useState<
'' | 'started' | 'succeeded' | 'errored'
>('');
Expand All @@ -94,12 +98,29 @@ export const QuickPublish = ({
/>
);

React.useEffect(
() => {
if (!cloudProjects) {
setNumberOfCloudProjectsBeforeSavingCustomizedGame(null);
} else if (numberOfCloudProjectsBeforeSavingCustomizedGame === null) {
setNumberOfCloudProjectsBeforeSavingCustomizedGame(
cloudProjects.filter(cloudProject => !cloudProject.deletedAt).length
);
}
},
// Store the number of cloud projects **before** the user saved this quick-customized
// game. Otherwise, they might reach the max number saving it, and the callout would
// be displayed instead of the game link.
[cloudProjects, numberOfCloudProjectsBeforeSavingCustomizedGame]
);

const isLoadingCloudProjects = !!profile && !cloudProjects;
const isCloudProjectsMaximumReached =
!!limits &&
!!cloudProjects &&
limits.capabilities.cloudProjects.maximumCount > 0 &&
cloudProjects.filter(cloudProject => !cloudProject.deletedAt).length >=
numberOfCloudProjectsBeforeSavingCustomizedGame !== null &&
numberOfCloudProjectsBeforeSavingCustomizedGame >=
limits.capabilities.cloudProjects.maximumCount;
const shouldSaveAndLaunchExport =
!!profile &&
Expand Down
Loading