diff --git a/newIDE/app/src/ExportAndShare/GenericExporters/OnlineWebExport/OnlineGameLink.js b/newIDE/app/src/ExportAndShare/GenericExporters/OnlineWebExport/OnlineGameLink.js index 5443b0ca9d45..4bc6e66120d5 100644 --- a/newIDE/app/src/ExportAndShare/GenericExporters/OnlineWebExport/OnlineGameLink.js +++ b/newIDE/app/src/ExportAndShare/GenericExporters/OnlineWebExport/OnlineGameLink.js @@ -194,10 +194,10 @@ const OnlineGameLink = ({ )} - {isShareDialogOpen && game && ( + {isShareDialogOpen && ( setIsShareDialogOpen(false)} - onOpenGameDashboard={openGameDashboard} + onOpenGameDashboard={game ? openGameDashboard : undefined} /> )} diff --git a/newIDE/app/src/ExportAndShare/GenericExporters/OnlineWebExport/OnlineWebExportFlow.js b/newIDE/app/src/ExportAndShare/GenericExporters/OnlineWebExport/OnlineWebExportFlow.js index 6dbe5ecf4d6b..24c7e54b470c 100644 --- a/newIDE/app/src/ExportAndShare/GenericExporters/OnlineWebExport/OnlineWebExportFlow.js +++ b/newIDE/app/src/ExportAndShare/GenericExporters/OnlineWebExport/OnlineWebExportFlow.js @@ -27,24 +27,31 @@ const OnlineWebExportFlow = ({ isExporting, uiMode, }: OnlineWebExportFlowProps) => { - const { game, builds, refreshGame, setGame } = gameAndBuildsManager; - const hasGameExistingBuilds = + const { + game, + builds, + refreshGame, + setGame, + gameAvailabilityError, + } = gameAndBuildsManager; + const isGameOwnedByCurrentUser = + !gameAvailabilityError || gameAvailabilityError !== 'not-owned'; + const hasGameExistingWebBuilds = game && builds - ? !!builds.filter(build => build.gameId === game.id).length + ? !!builds.filter( + build => build.gameId === game.id && build.type === 'web-build' + ).length : false; const isPublishedOnGdGames = !!game && !!game.publicWebBuildId; - const webBuilds = builds - ? builds.filter(build => build.type === 'web-build') - : null; - const hasAlreadyPublishedOnWeb = webBuilds ? webBuilds.length > 0 : false; - const publishOnGdGamesByDefault = - // This check ensures the user has done the process of unpublishing the game from gd.games - !(hasAlreadyPublishedOnWeb && !isPublishedOnGdGames); const [ automaticallyPublishNewBuild, setAutomaticallyPublishNewBuild, - ] = React.useState(publishOnGdGamesByDefault || !hasGameExistingBuilds); + ] = React.useState( + isGameOwnedByCurrentUser && + (!hasGameExistingWebBuilds || // Never built for web? Let's publish automatically. + isPublishedOnGdGames) // Already published on GDevelop games? Let's update automatically. + ); // Only show the buttons when the export is not started or when it's done. const shouldShowButtons = @@ -60,7 +67,9 @@ const OnlineWebExportFlow = ({ > Generate a link + ) : !hasGameExistingWebBuilds ? ( Publish game ) : automaticallyPublishNewBuild ? ( Publish new version @@ -74,7 +83,7 @@ const OnlineWebExportFlow = ({ disabled={disabled} /> - {hasGameExistingBuilds && ( + {hasGameExistingWebBuilds && ( void, + onOpenGameDashboard?: () => void, onClose: () => void, loadingText: ?React.Node, |}; @@ -63,10 +63,11 @@ const ShareOnlineGameDialog = ({ label={Done} primary onClick={onClose} + disabled={!!loadingText} />, ]} secondaryActions={[ - buildOrGameUrl && !loadingText ? ( + buildOrGameUrl && !loadingText && onOpenGameDashboard ? ( - {gameThumbnailUrl && ( + {gameThumbnailUrl && gameName && (