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

feat: Add Organization Admin scope to API V1 #14860

Draft
wants to merge 57 commits into
base: main
Choose a base branch
from

Conversation

alishaz-polymath
Copy link
Member

@alishaz-polymath alishaz-polymath commented May 2, 2024

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.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected)
  • 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

Copy link
Contributor

github-actions bot commented May 2, 2024

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

Copy link

vercel bot commented May 2, 2024

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 17, 2024 6:06pm
cal ⬜️ Ignored (Inspect) Visit Preview May 17, 2024 6:06pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview May 17, 2024 6:06pm

@alishaz-polymath alishaz-polymath changed the title feat: Add Organization And Team Admin scope to API V1 feat: Add Organization Admin scope to API V1 May 6, 2024
Copy link

deploysentinel bot commented May 6, 2024

Current Playwright Test Results Summary

✅ 66 Passing - ⚠️ 3 Flaky

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

(Last updated on 05/17/2024 06:45:28pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: 8bd1cfb

Started: 05/17/2024 06:42:22pm UTC

⚠️ Flakes

📄   apps/web/playwright/integrations-stripe.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Stripe integration Can book a paid booking
Retry 1Initial Attempt
4.24% (10) 10 / 236 runs
failed over last 7 days
15.25% (36) 36 / 236 runs
flaked over last 7 days

📄   apps/web/playwright/hash-my-url.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
hash my url generate url hash
Retry 1Initial Attempt
5.69% (14) 14 / 246 runs
failed over last 7 days
29.67% (73) 73 / 246 runs
flaked over last 7 days

📄   apps/web/playwright/event-types.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Event Types tests -- future user can add multiple organizer address
Retry 1Initial Attempt
1.56% (4) 4 / 256 runs
failed over last 7 days
21.48% (55) 55 / 256 runs
flaked over last 7 days

View Detailed Build Results


Copy link
Contributor

github-actions bot commented May 6, 2024

📦 Next.js Bundle Analysis for @calcom/web

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

Three Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/settings/platform 261.21 KB 489.84 KB 139.95% (🟢 -0.18%)
/settings/platform/oauth-clients/[clientId]/edit 259.82 KB 488.45 KB 139.56% (🟢 -0.18%)
/settings/platform/oauth-clients/create 259.1 KB 487.72 KB 139.35% (🟢 -0.18%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@keithwillcode
Copy link
Contributor

@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
Copy link
Contributor

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.

@@ -36,7 +36,7 @@ jobs:
secrets: inherit

test:
name: Unit tests
name: Tests
Copy link
Contributor

Choose a reason for hiding this comment

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

Screenshot 2024-05-17 at 3 02 56 PM

Naming all of these Tests results in the following grouping, which is nicer than having all of the tests separated.

@alishaz-polymath
Copy link
Member Author

alishaz-polymath commented May 18, 2024

@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.

So I had a look and basically the system-wide admin functionality hasn't been changed. As you can see here the system-admin check is only supposed to function when userId is passed along with it. Now I'm not entirely sure about the reasoning behind this, but I think with pagination, and continuing to allow this as well, we could very well do the same for systemwide admins as we do with org admins here as well.
What are your thoughts? @keithwillcode

tldr; I didn't modify the functionality of systemwide admins in this PR, but I think we should, as that's intuitive IMO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api area: API, enterprise API, access token, OAuth bookings area: bookings, availability, timezones, double booking consumer core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ✨ feature New feature or request High priority Created by Linear-GitHub Sync high-risk Requires approval by Foundation team organizations area: organizations, orgs zapier Created by Linear-GitHub Sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CAL-3677] Add Organization Admin Scope for API V1
7 participants