From 542596260bffc532800f4cecf9391bead4d62295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Vivet?= Date: Wed, 5 Feb 2025 16:48:38 +0100 Subject: [PATCH] Add a header with the gmae thumbnail to the confirmDeleteDialog --- .../src/GameDashboard/GameDashboardCard.js | 33 +++++++++++++++---- newIDE/app/src/UI/Alert/AlertContext.js | 1 + newIDE/app/src/UI/Alert/AlertProvider.js | 1 + .../app/src/UI/Alert/ConfirmDeleteDialog.js | 5 ++- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/newIDE/app/src/GameDashboard/GameDashboardCard.js b/newIDE/app/src/GameDashboard/GameDashboardCard.js index 3356213d23b3..4432cb449c3b 100644 --- a/newIDE/app/src/GameDashboard/GameDashboardCard.js +++ b/newIDE/app/src/GameDashboard/GameDashboardCard.js @@ -51,12 +51,14 @@ import PreferencesContext from '../MainFrame/Preferences/PreferencesContext'; import { textEllipsisStyle } from '../UI/TextEllipsis'; import FileWithLines from '../UI/CustomSvgIcons/FileWithLines'; import TextButton from '../UI/TextButton'; +import { MarkdownText } from '../UI/MarkdownText'; import { getRelativeOrAbsoluteDisplayDate } from '../Utils/DateDisplay'; import { formatISO, subDays } from 'date-fns'; import { type GameMetrics, getGameMetricsFrom, } from '../Utils/GDevelopServices/Analytics'; +import ImageThumbnail from '../ResourcesList/ResourceThumbnail/ImageThumbnail'; // It's important to use remote and not electron for folder actions, // otherwise they will be opened in the background. @@ -539,18 +541,35 @@ const GameDashboardCard = ({ click: async () => { // Extract word translation to ensure it is not wrongly translated in the sentence. const translatedConfirmText = i18n._(t`delete`); - let message = t`Your game and this project will be deleted. This action is irreversible. Do you want to continue?`; - if (isPublishedOnGdGames) { - message = t`You're deleting a game that has:${'\n\n'} - - ${countOfSessionsLastWeek} views on the last 7 days${'\n'} - - Is published on gd.games${'\n\n'} - If you continue the game and this project will be deleted. This action is irreversible. Do you want to continue?`; - } + const hasPlayerMessage = countOfSessionsLastWeek + ? t`${countOfSessionsLastWeek} views on the last 7 days` + : t`No players`; + const hasBeenPublished = isPublishedOnGdGames + ? t`Is published on gd.games` + : t`Not published`; + + const message = t`You're deleting a game that has:${'\n\n'} + - ${i18n._(hasPlayerMessage)} + ${'\n'} + - ${i18n._(hasBeenPublished)} + ${'\n\n'} + If you continue the game and this project will be deleted.${'\n\n'} + This action is irreversible. Do you want to continue?`; const answer = await showDeleteConfirmation({ title: t`Delete game`, + header: ( + + ), message: message, + confirmButtonLabel: t`Delete game`, fieldMessage: t`To confirm, type "${translatedConfirmText}"`, confirmText: translatedConfirmText, diff --git a/newIDE/app/src/UI/Alert/AlertContext.js b/newIDE/app/src/UI/Alert/AlertContext.js index faae39aae0aa..d9f5108de5ba 100644 --- a/newIDE/app/src/UI/Alert/AlertContext.js +++ b/newIDE/app/src/UI/Alert/AlertContext.js @@ -38,6 +38,7 @@ export type ShowConfirmDeleteDialogOptions = {| message: MessageDescriptor, fieldMessage?: MessageDescriptor, confirmText?: string, + header?: React.Node, |}; export type ShowConfirmDeleteDialogOptionsWithCallback = {| ...ShowConfirmDeleteDialogOptions, diff --git a/newIDE/app/src/UI/Alert/AlertProvider.js b/newIDE/app/src/UI/Alert/AlertProvider.js index d90d2e9195ff..dcb3e190025f 100644 --- a/newIDE/app/src/UI/Alert/AlertProvider.js +++ b/newIDE/app/src/UI/Alert/AlertProvider.js @@ -140,6 +140,7 @@ function ConfirmProvider({ children }: Props) { message={confirmDeleteDialogConfig.message} fieldMessage={confirmDeleteDialogConfig.fieldMessage} confirmText={confirmDeleteDialogConfig.confirmText} + header={confirmDeleteDialogConfig.header} /> )} {yesNoCancelDialogConfig && ( diff --git a/newIDE/app/src/UI/Alert/ConfirmDeleteDialog.js b/newIDE/app/src/UI/Alert/ConfirmDeleteDialog.js index 9f6317851ea6..fa1f6a5c7f26 100644 --- a/newIDE/app/src/UI/Alert/ConfirmDeleteDialog.js +++ b/newIDE/app/src/UI/Alert/ConfirmDeleteDialog.js @@ -11,6 +11,7 @@ import { LargeSpacer } from '../Grid'; import Text from '../Text'; import TextField from '../TextField'; import { useShouldAutofocusInput } from '../Responsive/ScreenTypeMeasurer'; +import { MarkdownText } from '../MarkdownText'; type Props = {| open: boolean, @@ -22,6 +23,7 @@ type Props = {| onDismiss: () => void, confirmButtonLabel?: MessageDescriptor, dismissButtonLabel?: MessageDescriptor, + header?: React.Node, |}; function ConfirmDeleteDialog(props: Props) { @@ -98,8 +100,9 @@ function ConfirmDeleteDialog(props: Props) { ]} fullscreen="never-even-on-mobile" > + {props.header} - {i18n._(props.message)} + {props.confirmText && props.fieldMessage && ( <>