Skip to content

Commit

Permalink
feat(nextcloud): Update trash query after moving a file to trash
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Jul 22, 2024
1 parent 32b2701 commit 112f840
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
6 changes: 6 additions & 0 deletions src/modules/nextcloud/components/NextcloudDeleteConfirm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
22 changes: 4 additions & 18 deletions src/modules/nextcloud/components/actions/deleteNextcloudFile.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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.
*
Expand All @@ -40,15 +31,15 @@ export const deleteNextcloudFile = ({
pathname,
navigate,
search
}: DeleteNextcloudFileProps): ActionsMenuItemProps => {
}: DeleteNextcloudFileProps): Action => {
const label = t('SelectionBar.trash')
const icon = TrashIcon

return {
name: 'deleteNextcloudFile',
label,
icon,
action: (files: NextcloudFile[]): void => {
action: (files): void => {
navigateToModalWithMultipleFile({
files,
pathname,
Expand All @@ -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<any>
) {
Component: forwardRef(function DeleteNextcloudFile(props, ref) {
return (
<ActionsMenuItem {...props} ref={ref}>
<ListItemIcon>
Expand Down

0 comments on commit 112f840

Please sign in to comment.