Skip to content

Commit

Permalink
feat(DeleteConfirm): Add filename into title
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Dec 27, 2023
1 parent 094cb3d commit 946ef76
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/drive/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
"more": "More"
},
"DeleteConfirm": {
"title": "Delete this element? |||| Delete these elements?",
"title": "Delete %{filename}? |||| Delete %{smart_count} %{type}?",
"trash": "It will be moved to the Trash. |||| They will be moved to the Trash.",
"restore": "You can still restore it whenever you want. |||| You can still restore them whenever you want.",
"share_accepted": "Sharing will be stopped. The following contacts will keep a copy, but your changes will no longer be synchronised:",
Expand Down
2 changes: 1 addition & 1 deletion src/drive/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
"more": "Afficher plus d'action"
},
"DeleteConfirm": {
"title": "Supprimer cet élément ? |||| Supprimer ces éléments ?",
"title": "Supprimer %{filename} ? |||| Supprimer %{smart_count} %{type} ?",
"trash": "Cet élément sera déplacé dans la corbeille. |||| Ces éléments seront déplacés dans la corbeille.",
"restore": "Vous pouvez toujours le restaurer quand vous voulez.",
"share_accepted": "Le partage sera arrêté. Ainsi, les contacts suivant conserveront une copie mais vos changements ne seront plus synchronisés :",
Expand Down
15 changes: 11 additions & 4 deletions src/drive/web/modules/drive/DeleteConfirm.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import React, { useCallback, useEffect, useState } from 'react'

import { useClient } from 'cozy-client'
import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs'
import Button from 'cozy-ui/transpiled/react/deprecated/Button'
import { buildAlbumByIdQuery } from 'drive/web/modules/queries'
import { Media, Img, Bd } from 'cozy-ui/transpiled/react/deprecated/Media'
import Icon from 'cozy-ui/transpiled/react/Icon'
import Stack from 'cozy-ui/transpiled/react/Stack'

import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'

import { SharedDocument, SharedRecipientsList } from 'cozy-sharing'
import { splitFilename } from 'cozy-client/dist/models/file'

import { buildAlbumByIdQuery } from 'drive/web/modules/queries'
import { trashFiles } from 'drive/web/modules/actions/utils'
import { DOCTYPE_ALBUMS } from 'drive/lib/doctypes'
import { getEntriesTypeTranslated } from 'drive/lib/entries'

const Message = ({ type, fileCount }) => {
const ico =
Expand Down Expand Up @@ -80,11 +81,17 @@ export const DeleteConfirm = ({
onClose()
}, [client, files, afterConfirmation, onClose])

const entriesType = getEntriesTypeTranslated(t, files)

return (
<ConfirmDialog
open={true}
onClose={onClose}
title={t('DeleteConfirm.title', fileCount)}
title={t('DeleteConfirm.title', {
filename: splitFilename(files[0]).filename,
smart_count: fileCount,
type: entriesType
})}
content={
<Stack>
<Message type="trash" fileCount={fileCount} />
Expand Down
2 changes: 1 addition & 1 deletion src/drive/web/modules/drive/DeleteConfirm.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('DeleteConfirm', () => {
</AppLike>
)

expect(getByText('Delete this element?')).toBeTruthy()
expect(getByText('Delete foobar10?')).toBeTruthy()

const confirmButton = getByText('Remove')
fireEvent.click(confirmButton)
Expand Down

0 comments on commit 946ef76

Please sign in to comment.