Skip to content

Commit

Permalink
Improve Max projects callout (#7096)
Browse files Browse the repository at this point in the history
Don't show in changelog
  • Loading branch information
AlexandreSi authored Oct 22, 2024
1 parent a2ea751 commit bb5291a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
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

0 comments on commit bb5291a

Please sign in to comment.