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 #5767 #5774

Closed

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.

Signed-off-by: Abdelrahman Essawy <abdelrahman.mo.essawy@gmail.com>
@abdelrahman-essawy abdelrahman-essawy requested a review from a team as a code owner March 19, 2024 21:15
Copy link

changeset-bot bot commented Mar 19, 2024

🦋 Changeset detected

Latest commit: df85083

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

@BatuhanW BatuhanW added this to the April Release milestone Mar 20, 2024
Copy link

nx-cloud bot commented Mar 20, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit df85083. 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


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Copy link
Member

@BatuhanW BatuhanW 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 thanks for the quick PR! Added a minor comment, let's get rid of fallback any permissions completely.

packages/appwrite/src/dataProvider.ts Outdated Show resolved Hide resolved
…defaultWritePermissions`

Signed-off-by: Abdelrahman Essawy <abdelrahman.mo.essawy@gmail.com>
@abdelrahman-essawy
Copy link
Contributor Author

abdelrahman-essawy commented Mar 22, 2024

@BatuhanW I did remove the fallback value, but note that test packages/appwrite/test/create/index.spec.ts now fails.

it only passes with defaultWritePermissions, defaultReadPermissions passed in options AND not empty array.

describe("create", () => {
  it("correct response with meta", async () => {
    const { data } = await dataProvider(client, {
      databaseId: "632455a0b8d017403ce9",
      defaultWritePermissions: [Permission.write(Role.any())],
      defaultReadPermissions: [Permission.read(Role.any())]
    }).create({
      resource: "632455a55dc72e1aa016",
      variables: {
        title: "Lorem",
      },
    });
    
    expect(data.title).toEqual("Lorem");
    expect(data.id).toBeTruthy();
  });
});

@BatuhanW
Copy link
Member

@BatuhanW I did remove the fallback value, but note that test packages/appwrite/test/create/index.spec.ts now fails.

it only passes with defaultWritePermissions, defaultReadPermissions passed in options AND not empty array.

describe("create", () => {
  it("correct response with meta", async () => {
    const { data } = await dataProvider(client, {
      databaseId: "632455a0b8d017403ce9",
      defaultWritePermissions: [Permission.write(Role.any())],
      defaultReadPermissions: [Permission.read(Role.any())]
    }).create({
      resource: "632455a55dc72e1aa016",
      variables: {
        title: "Lorem",
      },
    });
    
    expect(data.title).toEqual("Lorem");
    expect(data.id).toBeTruthy();
  });
});

Yeah, we need to update tests too. And also ideally re-record them with nock.

@BatuhanW BatuhanW changed the base branch from master to releases/april March 29, 2024 07:15
@BatuhanW BatuhanW requested a review from a team as a code owner March 29, 2024 07:15
@BatuhanW BatuhanW modified the milestones: April Release, May Release Apr 1, 2024
@BatuhanW BatuhanW deleted the branch refinedev:releases/april April 3, 2024 06:46
@BatuhanW BatuhanW closed this Apr 3, 2024
@BatuhanW
Copy link
Member

BatuhanW commented Apr 3, 2024

Hey @abdelrahman-essawy, we've merged releases/april branch, so your PR is closed. Could you re-open your PR?

@abdelrahman-essawy
Copy link
Contributor Author

@BatuhanW hello, I think I don't have the permission to re-open the PR nor change the base branch. note that the base branch is still refinedev:releases/april which is deleted.

@BatuhanW
Copy link
Member

BatuhanW commented Apr 3, 2024

Hey @abdelrahman-essawy, I can't do it too 😨

Could you checkout a new branch from latest master and create a new PR then?

@BatuhanW
Copy link
Member

Hey @abdelrahman-essawy we would like to release this one with May Release. Do you have time to re-open this PR so we can get it released?

@abdelrahman-essawy
Copy link
Contributor Author

@BatuhanW sure thing, I will re-open it and update the tests this weekend.

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)
2 participants