Skip to content

Commit

Permalink
Update publish flow to allow creating links if game is not owned (#7184)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementPasteau authored Nov 22, 2024
1 parent 5f01ce8 commit 2a6e98c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ const OnlineGameLink = ({
</Line>
</Column>
)}
{isShareDialogOpen && game && (
{isShareDialogOpen && (
<ShareOnlineGameDialog
gameThumbnailUrl={gameThumbnailUrl}
gameName={game.gameName}
gameName={game ? game.gameName : undefined} // This can happen if the game is not owned.
buildOrGameUrl={buildOrGameUrl}
isBuildPublished={!!isBuildPublished}
loadingText={
Expand All @@ -209,7 +209,7 @@ const OnlineGameLink = ({
)
}
onClose={() => setIsShareDialogOpen(false)}
onOpenGameDashboard={openGameDashboard}
onOpenGameDashboard={game ? openGameDashboard : undefined}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -60,7 +67,9 @@ const OnlineWebExportFlow = ({
>
<RaisedButton
label={
!hasGameExistingBuilds ? (
!isGameOwnedByCurrentUser ? (
<Trans>Generate a link</Trans>
) : !hasGameExistingWebBuilds ? (
<Trans>Publish game</Trans>
) : automaticallyPublishNewBuild ? (
<Trans>Publish new version</Trans>
Expand All @@ -74,7 +83,7 @@ const OnlineWebExportFlow = ({
disabled={disabled}
/>
</Line>
{hasGameExistingBuilds && (
{hasGameExistingWebBuilds && (
<Line justifyContent="center">
<Toggle
toggled={automaticallyPublishNewBuild}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const styles = {
type Props = {|
buildOrGameUrl: ?string,
gameThumbnailUrl: ?string,
gameName: string,
gameName: ?string,
isBuildPublished: boolean,
onOpenGameDashboard: () => void,
onOpenGameDashboard?: () => void,
onClose: () => void,
loadingText: ?React.Node,
|};
Expand Down Expand Up @@ -63,10 +63,11 @@ const ShareOnlineGameDialog = ({
label={<Trans>Done</Trans>}
primary
onClick={onClose}
disabled={!!loadingText}
/>,
]}
secondaryActions={[
buildOrGameUrl && !loadingText ? (
buildOrGameUrl && !loadingText && onOpenGameDashboard ? (
<FlatButton
key="publish"
primary
Expand All @@ -83,7 +84,7 @@ const ShareOnlineGameDialog = ({
<ColumnStackLayout noMargin expand>
<Column noMargin>
<ResponsiveLineStackLayout noMargin noResponsiveLandscape>
{gameThumbnailUrl && (
{gameThumbnailUrl && gameName && (
<GameThumbnail
background="light"
fullWidthOnMobile
Expand Down

0 comments on commit 2a6e98c

Please sign in to comment.