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

fix(appwrite): make meta.permissions overrideable #5886

Merged
merged 13 commits into from May 2, 2024

Conversation

abdelrahman-essawy
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

Users couldn't override the default readPermissions / writePermissions values.

What is the new behavior?

Users are able to override the default permissions by passing options.defaultReadPermissions / options.defaultWritePermissions OR by passing meta?.readPermissions / meta?.writePermissions.

If user passed options.defaultReadPermissions AND meta?.readPermissions, then the priority will be as following:

meta?.readPermissions if not? then options.defaultReadPermissions if not? then Role.any().

fixes #5767

Notes for reviewers

This should be compatible with old users who are not passing meta?.readPermissions and expecting to get Role.any() by default.

@abdelrahman-essawy abdelrahman-essawy requested a review from a team as a code owner April 24, 2024 10:15
Copy link

changeset-bot bot commented Apr 24, 2024

🦋 Changeset detected

Latest commit: 0391c8c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@aliemir aliemir left a comment

Choose a reason for hiding this comment

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

Hey @abdelrahman-essawy thank you for the contribution! I think the defaultReadPermissions and defaultWritePermissions should respect the previous values:

[
  Permission.read(Role.any()),
  Permission.write(Role.any()),
]

to avoid any breaking changes due to this PR.

Am I missing something here?

@abdelrahman-essawy
Copy link
Contributor Author

Hey @aliemir , please check out my discussion #5767 (comment) with @BatuhanW on this regard, and tell me what you think.

@aliemir
Copy link
Member

aliemir commented Apr 25, 2024

Hey @aliemir , please check out my discussion #5767 (comment) with @BatuhanW on this regard, and tell me what you think.

Just discussed with @BatuhanW about this again. Here on Default Values - Permissions docs of Appwrite says that if there's no explicit permissions, client SDK will provide permissions to the author.

Tested out with our data-provider-appwrite example and used two different accounts. I can confirm that I was unable to update the record created with another account when I don't pass explicit permissions.

I confirm that this will be a breaking change if default permissions will be empty. Can you make the necessary changes to avoid this breaking change? 🙏 If you can, please let us know. We'll mark this PR to be included in our May release 🚀

We'll review again after you make the changes 🙌

Copy link
Member

@aliemir aliemir left a comment

Choose a reason for hiding this comment

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

Thank you for the update @abdelrahman-essawy, just left two small comments. Hope you can have time to check those 🙏

packages/appwrite/src/dataProvider.ts Outdated Show resolved Hide resolved
Comment on lines +11 to +12
defaultReadPermissions?: Permission[];
defaultWritePermissions?: Permission[];
Copy link
Member

Choose a reason for hiding this comment

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

Since we've added the ability to configure permissions through dataProvider instance. Can we add a section like "Handling Permissions" to our Appwrite docs? https://refine.dev/docs/data/packages/appwrite/#example Adding a small section above "Example" section will be enough I guess.

Can you add this?

@abdelrahman-essawy
Copy link
Contributor Author

Thank you for the update @abdelrahman-essawy, just left two small comments. Hope you can have time to check those 🙏

you are very welcome, sure thing!

@aliemir aliemir added this to the May Release milestone Apr 26, 2024
Copy link

nx-cloud bot commented May 2, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 0391c8c. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


🟥 Failed Commands
lerna run attw --scope @refinedev/*
✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@aliemir aliemir changed the base branch from master to releases/may May 2, 2024 08:46
@aliemir aliemir requested a review from a team as a code owner May 2, 2024 08:46
@aliemir aliemir merged commit f3ddcce into refinedev:releases/may May 2, 2024
15 of 17 checks passed
@aliemir aliemir mentioned this pull request May 2, 2024
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.

[BUG] Appwrite dataProvider meta.permissions (@refinedev/appwrite)
4 participants