From 72c797cd8163ed7b021961469a64e0c62a280b28 Mon Sep 17 00:00:00 2001 From: Antonin Cezard Date: Wed, 24 Apr 2024 15:01:34 +0200 Subject: [PATCH] feat: Implement new alert remove old api use new api add new button to go to folder --- src/locales/en.json | 1 + src/locales/fr.json | 1 + src/modules/move/MoveModal.jsx | 54 ++++++++++++++++++++++++++-------- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 8b840eb19c..8db6247c3f 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -575,6 +575,7 @@ }, "Move": { "to": "Move to:", + "go_to_dir": "Open directory", "action": "Move", "cancel": "Cancel", "modalTitle": "Move", diff --git a/src/locales/fr.json b/src/locales/fr.json index 3e01109dbd..205c0d67c2 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -576,6 +576,7 @@ }, "Move": { "to": "Déplacer vers:", + "go_to_dir": "Ouvrir le dossier", "action": "Déplacer", "cancel": "Annuler", "modalTitle": "Déplacer", diff --git a/src/modules/move/MoveModal.jsx b/src/modules/move/MoveModal.jsx index 00c2f8ec95..530d5001f3 100644 --- a/src/modules/move/MoveModal.jsx +++ b/src/modules/move/MoveModal.jsx @@ -2,12 +2,15 @@ import { useDisplayedFolder } from 'hooks' import { CozyFile } from 'models' import PropTypes from 'prop-types' import React, { useEffect, useState } from 'react' +import { useNavigate } from 'react-router-dom' import { cancelable, Q, useClient } from 'cozy-client' import { useSharingContext } from 'cozy-sharing' import { useBreakpoints } from 'cozy-ui/transpiled/react' +import Button from 'cozy-ui/transpiled/react/Buttons' import { FixedDialog } from 'cozy-ui/transpiled/react/CozyDialogs' import Alerter from 'cozy-ui/transpiled/react/deprecated/Alerter' +import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert' import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' import { withStyles } from 'cozy-ui/transpiled/react/styles' @@ -53,6 +56,8 @@ const MoveModal = ({ onClose, entries, classes }) => { byDocId, allLoaded } = useSharingContext() + const navigate = useNavigate() + const { showAlert } = useAlert() const [folderId, setFolderId] = useState( displayedFolder ? displayedFolder._id : ROOT_DIR_ID @@ -146,19 +151,42 @@ const MoveModal = ({ onClose, entries, classes }) => { client.query(Q('io.cozy.files').getById(folderId)) ) const targetName = response.data?.name || t('breadcrumb.title_drive') - Alerter.info('Move.success', { - subject: entries.length === 1 ? entries[0].name : '', - target: targetName, - smart_count: entries.length, - buttonText: t('Move.cancel'), - buttonAction: () => - cancelMove({ - entries, - trashedFiles, - client, - registerCancelable, - refreshSharing - }) + const targetDir = response.data?.id + + showAlert({ + action: ( + <> +