Skip to content

Commit 49ea27f

Browse files
authored
Slightly rework games dashboard (#4084)
Don't show in changelog
1 parent 23b5b16 commit 49ea27f

File tree

3 files changed

+90
-17
lines changed

3 files changed

+90
-17
lines changed

newIDE/app/src/GameDashboard/Feedbacks/FeedbackCard.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ const FeedbackCard = ({
9595
} catch (error) {
9696
console.error(`Unable to update comment: `, error);
9797
showErrorBox({
98-
message: i18n._(t`Unable to change resolved status of feedback.`),
98+
message:
99+
i18n._(t`Unable to change resolved status of feedback.`) +
100+
' ' +
101+
i18n._(t`Verify your internet connection or try again later.`),
99102
rawError: error,
100103
errorId: 'feedback-card-set-processed-error',
101104
});

newIDE/app/src/GameDashboard/GameCard.js

Lines changed: 79 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import AuthenticatedUserContext from '../Profile/AuthenticatedUserContext';
2323
import ShareDialog from './ShareDialog';
2424

2525
import {
26+
deleteGame,
2627
getGameUrl,
2728
updateGame,
2829
type Game,
@@ -94,6 +95,7 @@ export const GameCard = ({
9495
editedProperty,
9596
setEditedProperty,
9697
] = React.useState<?TogglableProperties>(null);
98+
const [isDeletingGame, setIsDeletingGame] = React.useState(false);
9799

98100
const { getAuthorizationHeader, profile } = React.useContext(
99101
AuthenticatedUserContext
@@ -119,14 +121,62 @@ export const GameCard = ({
119121
} catch (error) {
120122
console.error(`Unable to update property ${property}`, error);
121123
showErrorBox({
122-
message: i18n._(t`Unable to update game.`),
124+
message:
125+
i18n._(t`Unable to update game.`) +
126+
' ' +
127+
i18n._(t`Verify your internet connection or try again later.`),
123128
rawError: error,
124129
errorId: 'game-dashboard-update-game-error',
125130
});
126131
}
127132
setEditedProperty(null);
128133
};
129134

135+
const unregisterGame = async (i18n: I18nType) => {
136+
const answer = Window.showConfirmDialog(
137+
i18n._(t`Are you sure you want to unregister this game?`) +
138+
'\n\n' +
139+
i18n._(
140+
t`It will disappear from your games dashboard and you won't get access to analytics, unless you register it again.`
141+
)
142+
);
143+
if (!answer) return;
144+
145+
if (!profile) return;
146+
const { id } = profile;
147+
setIsDeletingGame(true);
148+
149+
try {
150+
await deleteGame(getAuthorizationHeader, id, game.id);
151+
await onUpdateGame();
152+
} catch (error) {
153+
console.error('Unable to delete the game:', error);
154+
if (
155+
error.response &&
156+
error.response.data &&
157+
error.response.data.code === 'game-deletion/leaderboards-exist'
158+
) {
159+
showErrorBox({
160+
message: i18n._(
161+
t`You cannot unregister a game that has active leaderboards. To delete them, go in the Leaderboards tab, and delete them one by one.`
162+
),
163+
rawError: error,
164+
errorId: 'game-dashboard-unregister-game-active-leaderboards-error',
165+
});
166+
} else {
167+
showErrorBox({
168+
message:
169+
i18n._(t`Unable to delete the game.`) +
170+
' ' +
171+
i18n._(t`Verify your internet connection or try again later.`),
172+
rawError: error,
173+
errorId: 'game-dashboard-unregister-game-active-leaderboards-error',
174+
});
175+
}
176+
setIsDeletingGame(false);
177+
}
178+
};
179+
130180
return (
131181
<I18n>
132182
{({ i18n }) => (
@@ -136,31 +186,38 @@ export const GameCard = ({
136186
cardCornerAction={
137187
<ElementWithMenu
138188
element={
139-
<IconButton size="small">
189+
<IconButton size="small" disabled={isDeletingGame}>
140190
<MoreVert />
141191
</IconButton>
142192
}
143193
buildMenuTemplate={(i18n: I18nType) => [
144194
{
145-
label: i18n._(t`Open details`),
195+
label: i18n._(t`Game details`),
146196
click: () => onOpenGameManager('details'),
147197
},
148198
{
149-
label: i18n._(t`See builds`),
199+
label: i18n._(t`Game builds`),
150200
click: () => onOpenGameManager('builds'),
151201
},
152202
{
153-
label: i18n._(t`See feedbacks`),
203+
label: i18n._(t`Game feedbacks`),
154204
click: () => onOpenGameManager('feedback'),
155205
},
156206
{
157-
label: i18n._(t`Open analytics`),
207+
label: i18n._(t`Game analytics`),
158208
click: () => onOpenGameManager('analytics'),
159209
},
160210
{
161-
label: i18n._(t`Manage leaderboards`),
211+
label: i18n._(t`Game leaderboards`),
162212
click: () => onOpenGameManager('leaderboards'),
163213
},
214+
{ type: 'separator' },
215+
{
216+
label: i18n._(t`Unregister game`),
217+
click: () => {
218+
unregisterGame(i18n);
219+
},
220+
},
164221
]}
165222
/>
166223
}
@@ -215,22 +272,22 @@ export const GameCard = ({
215272
noColumnMargin
216273
>
217274
<FlatButton
218-
label={<Trans>Access feedback</Trans>}
219-
onClick={() => onOpenGameManager('feedback')}
220-
disabled={!game.publicWebBuildId}
275+
label={<Trans>Manage game</Trans>}
276+
onClick={() => onOpenGameManager('details')}
277+
disabled={!game.publicWebBuildId || isDeletingGame}
221278
/>
222279
<LineStackLayout noMargin>
223280
<Column noMargin expand>
224281
<RaisedButton
225282
label={<Trans>Open in browser</Trans>}
226283
onClick={openGameUrl}
227284
primary
228-
disabled={!game.publicWebBuildId}
285+
disabled={!game.publicWebBuildId || isDeletingGame}
229286
/>
230287
</Column>
231288
<IconButton
232289
size="small"
233-
disabled={!game.publicWebBuildId}
290+
disabled={!game.publicWebBuildId || isDeletingGame}
234291
onClick={() => setShowShareDialog(true)}
235292
tooltip={t`Share`}
236293
>
@@ -248,7 +305,9 @@ export const GameCard = ({
248305
}}
249306
toggled={!!game.discoverable}
250307
label={<Trans>Make discoverable on Liluo.io</Trans>}
251-
disabled={editedProperty === 'discoverable'}
308+
disabled={
309+
editedProperty === 'discoverable' || isDeletingGame
310+
}
252311
/>
253312
<Toggle
254313
labelPosition="left"
@@ -263,7 +322,9 @@ export const GameCard = ({
263322
label={
264323
<Trans>Show feedback banner on Liluo.io game page</Trans>
265324
}
266-
disabled={editedProperty === 'acceptsGameComments'}
325+
disabled={
326+
editedProperty === 'acceptsGameComments' || isDeletingGame
327+
}
267328
/>
268329
<Toggle
269330
labelPosition="left"
@@ -276,7 +337,10 @@ export const GameCard = ({
276337
}}
277338
toggled={!!game.acceptsBuildComments}
278339
label={<Trans>Ask for feedback on all build pages</Trans>}
279-
disabled={editedProperty === 'acceptsBuildComments'}
340+
disabled={
341+
editedProperty === 'acceptsBuildComments' ||
342+
isDeletingGame
343+
}
280344
/>
281345
</Column>
282346
</Column>

newIDE/app/src/GameDashboard/GameDetailsDialog.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,13 @@ export const GameDetailsDialog = ({
496496
<FlatButton
497497
onClick={() => {
498498
const answer = Window.showConfirmDialog(
499-
"Are you sure you want to unregister this game? \n\nIt will disappear from your games dashboard and you won't get access to analytics, unless you register it again."
499+
i18n._(
500+
t`Are you sure you want to unregister this game?`
501+
) +
502+
'\n\n' +
503+
i18n._(
504+
t`It will disappear from your games dashboard and you won't get access to analytics, unless you register it again.`
505+
)
500506
);
501507

502508
if (!answer) return;

0 commit comments

Comments
 (0)