cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

feat: Add Organization Admin scope to API V1

Open alishaz-polymath opened this issue 1 year ago • 14 comments

What does this PR do?

  • Updates the admin guard isAdminisSystemWideAdmin for added clarity by clarifying scope of access to be system wide
  • Updates the admin guard to consider Organization owners or admins with isOrganizationOwnerOrAdmin and the scope of access is the members of the organization
  • Implements isOrganizationOwnerOrAdmin on bookings endpoint as an example:
    • /bookings GET
    • /bookings POST
    • /bookings/[id] PATCH
    • /bookings/[id]/cancel DELETE
    • /bookings/[id] GET

This PR also adds Pagination to the bookings endpoint, accessible by passing take & page parameters, where take represents the number of items in the resulting array and page represents the page number when taking 'take' number of items per page.

For example, if there are 20 results, we can use take=5 and page=3 to get results 11-15.

  • Fixes #14974
  • Fixes CAL-3605

Mandatory Tasks (DO NOT REMOVE)

  • [x] I have self-reviewed the code (A decent size PR without self-review might be rejected)
  • [x] I have added a Docs issue here if this PR makes changes that would require a documentation change
  • [ ] I have added or modified automated tests that prove my fix is effective or that my feature works (PRs might be rejected if logical changes are not properly tested)

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings

alishaz-polymath avatar May 02 '24 13:05 alishaz-polymath

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

github-actions[bot] avatar May 02 '24 13:05 github-actions[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
ai ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 7:34pm
cal ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 7:34pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 7:34pm

vercel[bot] avatar May 02 '24 13:05 vercel[bot]

Current Playwright Test Results Summary

✅ 3 Passing - ⚠️ 1 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 05/21/2024 08:08:41pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: f0dab0c1de7400a6048a9af8717d294bd6765892

Started: 05/21/2024 08:08:06pm UTC

⚠️ Flakes

📄   packages/embeds/embed-react/playwright/tests/basic.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
React Embed Element Click Popup should verify that the iframe got created with correct URL - namespaced
Retry 2Retry 1Initial Attempt
20.66% (56) 56 / 271 runs
failed over last 7 days
34.32% (93) 93 / 271 runs
flaked over last 7 days

View Detailed Build Results


deploysentinel[bot] avatar May 06 '24 13:05 deploysentinel[bot]

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

github-actions[bot] avatar May 06 '24 13:05 github-actions[bot]

@Udit-takkar all suggestions sorted 🙏

alishaz-polymath avatar May 10 '24 12:05 alishaz-polymath

Code changes look really good, @alishaz-polymath. Nice work!

We just need to do some heavy testing before shipping this out.

I see that you updated some tests. It would be great to see some new tests around determining the scope of admin permissions and access around it.

joeauyeung avatar May 14 '24 14:05 joeauyeung

Code changes look really good, @alishaz-polymath. Nice work! We just need to do some heavy testing before shipping this out.

I see that you updated some tests. It would be great to see some new tests around determining the scope of admin permissions and access around it.

Yeah I did discuss this with Keith but the thing is, we plan to sunset V1 in favour of V2 fairly soon. I wonder if adding a test suite is worth it. I can add test for sure, not certain though if that's worth it in the grand scheme of things on this occasion

alishaz-polymath avatar May 14 '24 15:05 alishaz-polymath

I saw that we're planning to sunset this. Although I'm not sure if by sunsetting we mean removing it completely or just stop doing updates. Either way. We're touching a lot of files and adding no new tests. I'm not confortable shipping in the current state. Tests are also to prove that something works right now and it won't break unexpectedly. Even if we're sunsetting. Tests are transferable. I would try to add tests anyways.

Fair enough. Will add a few tests 🙏

alishaz-polymath avatar May 14 '24 18:05 alishaz-polymath

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (05/16/24)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add platform team as reviewer" took an action on this PR • (05/21/24)

1 reviewer was added to this PR based on Keith Williams's automation.

graphite-app[bot] avatar May 16 '24 20:05 graphite-app[bot]

@keithwillcode tests look good - is there any reason this is still in draft? Do we need to cover a few more edge cases some where

sean-brydon avatar May 17 '24 07:05 sean-brydon

@alishaz-polymath @zomars Update here: I've added a bunch of unit and integration tests here. All pass locally except 1 integration test that I think is due to a change in functionality that I'm not totally sure is correct. @alishaz-polymath is going to follow up on it.

What I'm going to focus on now is making sure our integration test suite can properly run on CI. Right now, when I run it, the tests pass but then almost all downstream E2E jobs fail so seems like the integration test suite is corrupting something.

keithwillcode avatar May 17 '24 16:05 keithwillcode

Ok - CI has been updated and is now correctly running all tests. See https://github.com/calcom/cal.com/actions/runs/9132154000. The 1 failing integration as mentioned can be seen there.

keithwillcode avatar May 17 '24 18:05 keithwillcode

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

:white_check_mark: keithwillcode
:white_check_mark: joeauyeung
:x: Syed Ali Shahbaz


Syed Ali Shahbaz seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar May 21 '24 10:05 CLAassistant

@alishaz-polymath @zomars Peeling out the integration tests skeleton to here so it's separated. We've already verified that all new integration tests added in this PR pass.

keithwillcode avatar May 21 '24 16:05 keithwillcode