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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VO-711] feat: Add a collection to access files into a Nextcloud #1471

Merged
merged 3 commits into from
May 23, 2024

Conversation

cballevre
Copy link
Member

@cballevre cballevre commented May 7, 2024

This PR is the first one to implement the new type io.cozy.remote.nextcloud.files. It allow us to interact with Nextcloud server inside Drive 馃檪

Related PRs :

@cballevre cballevre changed the title feat: Add a collection to access files into a Nextcloud [VO-711] feat: Add a collection to access files into a Nextcloud May 7, 2024
To use the enabled option, the definition is passed in the form of a general function. I've adapted the typing to this practice. This allows me to display the warning also for definition passed with a function
@cballevre cballevre marked this pull request as ready for review May 22, 2024 15:17
@cballevre cballevre requested a review from Ldoppea May 23, 2024 08:30
Copy link
Contributor

@paultranvan paultranvan left a comment

Choose a reason for hiding this comment

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

Some questions about the returned data, but looks good!

path: `${path}${path.endsWith('/') ? '' : '/'}${file.attributes.name}`,
cozyMetadata: {
...file.attributes.cozyMetadata,
sourceAccount
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have to manually set the sourceAccount? I feel like this should be up to the client to set it, just like the other cozyMetadata聽attributes?

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 is for convenience, because in order to use all the routes in the stack we need to have the Nextcloud path and sourceAccount pair. This is only present in the shortcut describing the Nextcloud. To reuse the same action as the io.cozy.files, I've introduced it into the file so that you only have to pass a file as a parameter as expected

@@ -51,7 +51,7 @@ const useQuery = (queryDefinition, options) => {

const client = useClient()
const queryState = useSelector(() => {
if (options.singleDocData === undefined && queryDefinition.id) {
if (options.singleDocData === undefined && definition?.id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks to typing, yet another example, even with JSDoc

const normalizeNextcloudFile = (sourceAccount, path) => file => {
const extendedAttributes = {
...file.attributes,
path: `${path}${path.endsWith('/') ? '' : '/'}${file.attributes.name}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

The stack does not return the path like the other files?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nop, but maybe she could do it

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like it should for consistency, @nono what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Well, it makes the response bigger, and they are quite easy to compute client-side, so I decided to not include them.

@cballevre cballevre merged commit 21fca5c into master May 23, 2024
4 checks passed
@cballevre cballevre deleted the feat/nextcloud branch May 23, 2024 09:14
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.

None yet

3 participants