From 2a6e98c27ff8a2506873fab460d4fbede1e6cd3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pasteau?= <4895034+ClementPasteau@users.noreply.github.com> Date: Fri, 22 Nov 2024 09:57:46 +0100 Subject: [PATCH] Update publish flow to allow creating links if game is not owned (#7184) --- .../OnlineWebExport/OnlineGameLink.js | 6 ++-- .../OnlineWebExport/OnlineWebExportFlow.js | 35 ++++++++++++------- .../OnlineWebExport/ShareOnlineGameDialog.js | 9 ++--- 3 files changed, 30 insertions(+), 20 deletions(-) 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 && (