From e0abef6e28bfaad19bd58d205d0688857cbf6d60 Mon Sep 17 00:00:00 2001 From: cballevre Date: Thu, 18 Jul 2024 16:35:13 +0200 Subject: [PATCH] feat(nextcloud): Update trash query after moving a file to trash --- src/declarations.d.ts | 1 + .../components/NextcloudDeleteConfirm.jsx | 6 +++++ .../actions/deleteNextcloudFile.tsx | 22 ++++--------------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/declarations.d.ts b/src/declarations.d.ts index 520f989261..db474d7244 100644 --- a/src/declarations.d.ts +++ b/src/declarations.d.ts @@ -87,6 +87,7 @@ declare module 'cozy-ui/transpiled/react/ActionsMenu/Actions' { displayCondition?: ( docs: import('cozy-client/types/types').IOCozyFile[] ) => boolean + disabled?: (docs: import('cozy-client/types/types').IOCozyFile[]) => boolean action?: ( docs: import('cozy-client/types/types').IOCozyFile[], opts: { handleAction: HandleActionCallback } diff --git a/src/modules/nextcloud/components/NextcloudDeleteConfirm.jsx b/src/modules/nextcloud/components/NextcloudDeleteConfirm.jsx index 69d9ce6f75..43ce0631db 100644 --- a/src/modules/nextcloud/components/NextcloudDeleteConfirm.jsx +++ b/src/modules/nextcloud/components/NextcloudDeleteConfirm.jsx @@ -36,6 +36,12 @@ const NextcloudDeleteConfirm = ({ files, onClose }) => { path: files[0].parentPath }) ) + client.resetQuery( + computeNextcloudFolderQueryId({ + sourceAccount: files[0].cozyMetadata.sourceAccount, + path: '/trash/' + }) + '/trashed' + ) } catch (e) { showAlert({ message: t('NextcloudDeleteConfirm.error'), diff --git a/src/modules/nextcloud/components/actions/deleteNextcloudFile.tsx b/src/modules/nextcloud/components/actions/deleteNextcloudFile.tsx index 59e4b2f489..704b30c0e4 100644 --- a/src/modules/nextcloud/components/actions/deleteNextcloudFile.tsx +++ b/src/modules/nextcloud/components/actions/deleteNextcloudFile.tsx @@ -1,7 +1,7 @@ import React, { forwardRef } from 'react' -import { NextcloudFile } from 'cozy-client/types/types' import flag from 'cozy-flags' +import { Action } from 'cozy-ui/transpiled/react/ActionsMenu/Actions' import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem' import Icon from 'cozy-ui/transpiled/react/Icon' import TrashIcon from 'cozy-ui/transpiled/react/Icons/Trash' @@ -17,15 +17,6 @@ interface DeleteNextcloudFileProps { search: string } -interface ActionsMenuItemProps { - name: string - label: string - icon: React.ReactNode - action: (files: never[]) => void - disabled: () => boolean - Component: React.ReactNode -} - /** * Deletes a Nextcloud file. * @@ -40,7 +31,7 @@ export const deleteNextcloudFile = ({ pathname, navigate, search -}: DeleteNextcloudFileProps): ActionsMenuItemProps => { +}: DeleteNextcloudFileProps): Action => { const label = t('SelectionBar.trash') const icon = TrashIcon @@ -48,7 +39,7 @@ export const deleteNextcloudFile = ({ name: 'deleteNextcloudFile', label, icon, - action: (files: NextcloudFile[]): void => { + action: (files): void => { navigateToModalWithMultipleFile({ files, pathname, @@ -58,12 +49,7 @@ export const deleteNextcloudFile = ({ }) }, disabled: () => !flag('drive.show-nextcloud-delete-dev'), - Component: forwardRef(function DeleteNextcloudFile( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - props: any, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - ref: React.Ref - ) { + Component: forwardRef(function DeleteNextcloudFile(props, ref) { return (