Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VO-740] feat(nextcloud): Show trash #3187

Merged
merged 9 commits into from
Jul 22, 2024

Conversation

Copy link

bundlemon bot commented Jul 15, 2024

BundleMon

Files updated (3)
Status Path Size Limits
app/drive.(hash).js
178.77KB (+1.5KB +0.85%) 300KB
public/drive.(hash).js
1.56MB (-31B 0%) 1.7MB
intents/drive.(hash).js
105.11KB (-1.23KB -1.16%) 190KB
Unchanged files (15)
Status Path Size Limits
vendors/drive.(hash).js
1.78MB 2MB
public/pdf.worker.entry.(hash).worker.js
345.35KB 350KB
services/qualificationMigration/drive.js
280.06KB 500KB
services/dacc/drive.js
261.09KB 500KB
public/cozy-client-js.js
159.28KB 160KB
public/drive.(hash).min.css
69.71KB 100KB
app-drive.(hash).min.css
37.84KB 56KB
intents-drive.(hash).min.css
33.01KB 40KB
onlyOffice/slide.pptx
24.83KB 25KB
onlyOffice/text.docx
5.85KB 6KB
onlyOffice/spreadsheet.xlsx
5.02KB 6KB
manifest.webapp
1.87KB 2KB
index.html
598B 1KB
intents/index.html
508B 1KB
manifest.json
185B 1KB

Total files change +249B 0%

Groups updated (3)
Status Path Size Limits
app/**
178.77KB (+1.5KB +0.85%) -
public/**
2.13MB (-31B 0%) -
intents/**
105.6KB (-1.23KB -1.15%) -
Unchanged groups (4)
Status Path Size Limits
vendors/**
1.78MB -
services/**
541.15KB -
onlyOffice/**
35.7KB -
img/**
5.85KB -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@cballevre cballevre force-pushed the feat/show-trash-inside-nextcloud branch 2 times, most recently from 866c43d to 0b45b89 Compare July 18, 2024 15:27
@cballevre cballevre marked this pull request as ready for review July 18, 2024 15:29
@cballevre cballevre requested a review from acezard as a code owner July 18, 2024 15:29
@cballevre cballevre force-pushed the feat/show-trash-inside-nextcloud branch from 0b45b89 to e0abef6 Compare July 19, 2024 06:43
This is preparatory work to share code between IOCozyFile routes and the Nextcloud routes. This also makes it easier to go backwards on Android.
@cballevre cballevre force-pushed the feat/show-trash-inside-nextcloud branch from e0abef6 to 824b070 Compare July 22, 2024 07:51
@cballevre cballevre requested a review from Ldoppea July 22, 2024 07:52
try {
setBusy(true)
await onConfirm()
} finally {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't handle the error scenario with some UI feedback here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I've added alerts in case of success or error

const handleConfirm = async (): Promise<void> => {
if (!fileResult.data) return
for (const file of fileResult.data) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen multiple of these maybe it's easier to type cozy-client in d.ts for this method

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really want to modify CozyClient typing directly in Drive. We'd have to see how we could integrate this directly into the package, but we'd probably have to consider typing cozy-stack-client at the same time as .collection is direct access to their classes.

@@ -118,7 +117,7 @@ const File = ({
// because they are magic folder created by the stack
const canInteractWithFile =
attributes._id !== 'io.cozy.files.shared-drives-dir' &&
attributes._id !== TRASH_DIR_ID
!attributes._id.endsWith('.trash-dir')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why use a literal string instead of a constant here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows me to manage all the trash from both doctype io.cozy.files and io.cozy.remote.nextcloud.files in one line. You would have prefer something like that :

const canInteractWithFile =
    attributes._id !== SHARED_DRIVES_DIR_ID &&
    attributes._id !== TRASH_DIR_ID &&
    attributes._id !== NEXTCLOUD_TRASH_DIR_ID

Maybe this constant should be provided by cozy-client or cozy-stack-client as they are already set as type here.

Note: I tend to put the doctype directly because I find them quicker to search globally in a project.

@@ -32,12 +36,21 @@ const NextcloudTrashFolderBody: FC<NextcloudTrashFolderBodyProps> = ({
window.open(file.links.self, '_blank')
}

const fileActions = makeActions([], {
const handleRefresh = async (files: NextcloudFile[]): Promise<void> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is supposed to happen in case of throw during this refresh?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I move this part inside the action directly so its handle by try/catch for the restore. I took advantage of this to limit the number of query resets by duplicating the parents' paths.

However, your comment made me realise that the resetQuery function returns an error when the query didn't exist. I'm in the process of correcting it in cozy-client but I don't think it will be a problem for this PR.

state.fileIds?.includes(_id)
)

const handleConfirm = async (): Promise<void> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, what happens in case we can't handleConfirm? on ui side particularly (maybe it's irrelevant, not sure)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI side is handle inside the DestroyConfirm because the message are the same between io.cozy.files and io.cozy.remote.nextcloud.files

@cballevre cballevre force-pushed the feat/show-trash-inside-nextcloud branch from 824b070 to 10f846a Compare July 22, 2024 12:43
@cballevre cballevre requested a review from acezard July 22, 2024 12:50
@cballevre cballevre merged commit 9e6c800 into master Jul 22, 2024
3 checks passed
@cballevre cballevre deleted the feat/show-trash-inside-nextcloud branch July 22, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants