Skip to content

Commit 61088df

Browse files
author
MargeBot
committed
Merge branch 'lumo/chat-delete-image-warning' into 'main'
Fix to inform users that chat deletion will also delete associated images. See merge request web/clients!25480
2 parents cedfd1b + 22caa9b commit 61088df

4 files changed

Lines changed: 63 additions & 46 deletions

File tree

applications/lumo/src/app/components/Modals/ConfirmDeleteModal.tsx

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,47 @@
1-
import { c } from 'ttag';
1+
import { c, msgid } from 'ttag';
22

33
import { Button } from '@proton/atoms/Button/Button';
44
import { Prompt } from '@proton/components';
55
import type { ModalStateProps } from '@proton/components/components/modalTwo/useModalState';
6+
import { IcExclamationTriangleFilled } from '@proton/icons/icons/IcExclamationTriangleFilled';
7+
import { useFlag } from '@proton/unleash/useFlag';
68

79
interface Props extends ModalStateProps {
810
handleDelete: () => void;
11+
/** Confirm deletion of every conversation (settings "Delete all"). */
912
deleteAll?: boolean;
13+
/** Number of conversations being deleted. Used for plural messaging on bulk delete. Defaults to 1. */
14+
count?: number;
1015
loading?: boolean;
1116
}
1217

13-
const ConfirmDeleteModal = ({ handleDelete, deleteAll = false, loading, ...modalProps }: Props) => {
14-
const title = deleteAll ? c('Action').t`Delete all conversations?` : c('Action').t`Delete conversation?`;
18+
const ConfirmDeleteModal = ({ handleDelete, deleteAll = false, count = 1, loading, ...modalProps }: Props) => {
19+
const imageTools = useFlag('LumoImageTools');
20+
21+
// "Delete all" and any multi-selection share the plural copy; a single conversation uses the singular copy.
22+
const isPlural = deleteAll || count > 1;
23+
24+
const title = deleteAll
25+
? c('Action').t`Delete all conversations?`
26+
: isPlural
27+
? // translator: ${count} is the number of selected conversations being deleted
28+
c('Action').ngettext(msgid`Delete ${count} conversation?`, `Delete ${count} conversations?`, count)
29+
: c('Action').t`Delete conversation?`;
30+
1531
const message = deleteAll
1632
? c('Action').t`Are you sure you want to delete all conversations?`
17-
: c('Action').t`Are you sure you want to delete the conversation?`;
33+
: isPlural
34+
? // translator: ${count} is the number of selected conversations being deleted
35+
c('Action').ngettext(
36+
msgid`Are you sure you want to delete ${count} conversation?`,
37+
`Are you sure you want to delete ${count} conversations?`,
38+
count
39+
)
40+
: c('Action').t`Are you sure you want to delete this conversation?`;
41+
42+
const imagesMessage = isPlural
43+
? c('collider_2025:Info').t`Any images generated in these conversations will also be deleted.`
44+
: c('collider_2025:Info').t`Any images generated in this conversation will also be deleted.`;
1845

1946
const deleteButtonText = deleteAll ? c('collider_2025').t`Delete all` : c('collider_2025').t`Delete`;
2047

@@ -30,6 +57,12 @@ const ConfirmDeleteModal = ({ handleDelete, deleteAll = false, loading, ...modal
3057
]}
3158
>
3259
<p className="m-0">{message}</p>
60+
{imageTools && (
61+
<div className="flex flex-row flex-nowrap items-start gap-2 mt-4 p-3 rounded bg-weak">
62+
<IcExclamationTriangleFilled className="color-warning shrink-0 mt-0.5" size={4} />
63+
<span className="text-bold">{imagesMessage}</span>
64+
</div>
65+
)}
3366
</Prompt>
3467
);
3568
};

applications/lumo/src/app/components/SelectableConversationList/SelectableConversationList.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { useCallback, useState } from 'react';
33
import { c, msgid } from 'ttag';
44

55
import { Button } from '@proton/atoms/Button/Button';
6-
import { Checkbox } from '@proton/components';
6+
import { Checkbox, useModalStateObject } from '@proton/components';
77
import { IcTrash } from '@proton/icons/icons/IcTrash';
88

99
import type { Conversation, ConversationId } from '../../types';
10+
import ConfirmDeleteModal from '../Modals/ConfirmDeleteModal';
1011

1112
import './SelectableConversationList.scss';
1213

@@ -51,6 +52,7 @@ export const SelectableConversationList = ({
5152
const [isSelectionMode, setIsSelectionMode] = useState(false);
5253
const [selectedIds, setSelectedIds] = useState<Set<ConversationId>>(new Set());
5354
const [isDeleting, setIsDeleting] = useState(false);
55+
const confirmDeleteModal = useModalStateObject();
5456

5557
// Get all conversation IDs from all groups
5658
const allConversationIds = groups.flatMap((group) => group.conversations.map((c) => c.id));
@@ -83,6 +85,11 @@ export const SelectableConversationList = ({
8385
});
8486
}, []);
8587

88+
const requestDeleteSelected = useCallback(() => {
89+
if (selectedIds.size === 0) return;
90+
confirmDeleteModal.openModal(true);
91+
}, [selectedIds, confirmDeleteModal]);
92+
8693
const handleDeleteSelected = useCallback(async () => {
8794
if (selectedIds.size === 0) return;
8895

@@ -91,10 +98,11 @@ export const SelectableConversationList = ({
9198
await onDeleteSelected(Array.from(selectedIds));
9299
setSelectedIds(new Set());
93100
setIsSelectionMode(false);
101+
confirmDeleteModal.openModal(false);
94102
} finally {
95103
setIsDeleting(false);
96104
}
97-
}, [selectedIds, onDeleteSelected]);
105+
}, [selectedIds, onDeleteSelected, confirmDeleteModal]);
98106

99107
const handleConversationClick = useCallback(
100108
(conversationId: ConversationId) => {
@@ -150,7 +158,7 @@ export const SelectableConversationList = ({
150158
size="small"
151159
color="danger"
152160
shape="ghost"
153-
onClick={handleDeleteSelected}
161+
onClick={requestDeleteSelected}
154162
loading={isDeleting}
155163
disabled={isDeleting}
156164
className="text-sm"
@@ -229,6 +237,15 @@ export const SelectableConversationList = ({
229237
)
230238
)}
231239
</div>
240+
241+
{confirmDeleteModal.render && (
242+
<ConfirmDeleteModal
243+
{...confirmDeleteModal.modalProps}
244+
handleDelete={handleDeleteSelected}
245+
count={selectedCount}
246+
loading={isDeleting}
247+
/>
248+
)}
232249
</div>
233250
);
234251
};

applications/lumo/src/app/features/projects/ProjectDetailView.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ComposerComponent } from '../../components/Composer/ComposerComponent';
1313
import { useNativeComposerPromptApi } from '../../components/Composer/hooks/useNativeComposerPromptApi';
1414
import { sendMessage } from '../../components/Conversation/helper';
1515
import { FilesManagementView } from '../../components/Files';
16+
import ConfirmDeleteModal from '../../components/Modals/ConfirmDeleteModal';
1617
import { type ConversationGroup, SelectableConversationList } from '../../components/SelectableConversationList';
1718
import { usePersonalization } from '../../hooks';
1819
import { useIsLumoSmallScreen } from '../../hooks/useIsLumoSmallScreen';
@@ -45,7 +46,6 @@ import { ProjectEmptyState } from './components/ProjectEmptyState';
4546
import { getProjectCategory, getPromptSuggestionsForCategory } from './constants';
4647
import { useNativeComposerProjectDetailVisibilityApi } from './hooks/useNativeComposerProjectDetailVisibilityApi';
4748
import { useProjectActions } from './hooks/useProjectActions';
48-
import { DeleteConversationModal } from './modals/DeleteConversationModal';
4949
import { DeleteProjectModal } from './modals/DeleteProjectModal';
5050
import { ProjectInstructionsModal } from './modals/ProjectInstructionsModal';
5151
import type { Project } from './types';
@@ -438,9 +438,12 @@ const ProjectDetailViewInner = () => {
438438
)}
439439

440440
{deleteConversationModal.render && (
441-
<DeleteConversationModal
441+
<ConfirmDeleteModal
442442
{...deleteConversationModal.modalProps}
443-
onConfirm={confirmDeleteConversation}
443+
handleDelete={() => {
444+
confirmDeleteConversation();
445+
deleteConversationModal.openModal(false);
446+
}}
444447
/>
445448
)}
446449

applications/lumo/src/app/features/projects/modals/DeleteConversationModal.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)