cal.com
cal.com copied to clipboard
feat: New Organization Schema along with the ability to invite existing users to an organization
What does this PR do?
Existing cal.com user can be invited to an organization now.
Schema Changes
- Remove organizationId and organization from User table
- Instead have Profile table with organizationId and userId relation.
Seeder
- Added an organization seeder that adds a User and a Team to an organization. Also, adds one eventType for user and team each - Login using [email protected]:owner1-org1
Repositories
- Two new repositories are created
ProfileandUserwhich mostly abstract out the reusable queries together. - A repository is a class at the moment just to be a collection of methods, we can do other OOP stuff later on.
Brainstorming here
https://docs.google.com/document/d/1ii3eyn0F0LaUCrX1c58YgdMt2V7xZWI2AGX1yKKM2Ik/edit
TODO
- [x] Write migration to create Profile table and populate it with all org user entries and open a separate PR that would go live before this.(v0-preparation)
Type of change
- [x] New feature (non-breaking change which adds functionality)
How should this be tested?
There is a lot to test
Mandatory Tasks
- [] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.
Checklist
- I haven't added tests that prove my fix is effective or that my feature works
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| ai | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Feb 2, 2024 6:54pm |
| api | ❌ Failed (Inspect) | Feb 2, 2024 6:54pm | ||
| dev | ❌ Failed (Inspect) | Feb 2, 2024 6:54pm |
5 Ignored Deployments
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| cal | ⬜️ Ignored (Inspect) | Visit Preview | Feb 2, 2024 6:54pm | |
| cal-demo | ⬜️ Ignored (Inspect) | Visit Preview | Feb 2, 2024 6:54pm | |
| calcom-web-canary | ⬜️ Ignored (Inspect) | Visit Preview | Feb 2, 2024 6:54pm | |
| qa | ⬜️ Ignored (Inspect) | Visit Preview | Feb 2, 2024 6:54pm | |
| ui | ⬜️ Ignored (Inspect) | Visit Preview | Feb 2, 2024 6:54pm |
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.
[!WARNING] This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite. Learn more
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite.
📦 Next.js Bundle Analysis for @calcom/web
This analysis was generated by the Next.js Bundle Analysis action. 🤖
Seventy-one 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) |
|---|---|---|---|
/[user]/[type] |
265.07 KB |
453.2 KB | 129.49% (🟡 +0.29%) |
/[user]/[type]/embed |
265.08 KB |
453.2 KB | 129.49% (🟡 +0.29%) |
/apps |
279.12 KB |
467.25 KB | 133.50% (🟡 +2.23%) |
/apps/[slug] |
296.63 KB |
484.76 KB | 138.50% (🟡 +2.23%) |
/apps/categories |
256.81 KB |
444.93 KB | 127.12% (🟡 +2.23%) |
/apps/categories/[category] |
261.12 KB |
449.24 KB | 128.35% (🟡 +2.23%) |
/apps/installed/[category] |
280.2 KB |
468.33 KB | 133.81% (🟡 +2.23%) |
/auth/setup |
149.55 KB |
337.67 KB | 96.48% (🟢 -0.27%) |
/availability/troubleshoot |
172.7 KB |
360.83 KB | 103.09% (🟡 +0.25%) |
/booking/[uid] |
190.15 KB |
378.28 KB | 108.08% (🟢 -0.23%) |
/booking/[uid]/embed |
190.16 KB |
378.28 KB | 108.08% (🟢 -0.23%) |
/d/[link]/[slug] |
264.9 KB |
453.03 KB | 129.44% (🟡 +0.29%) |
/enterprise |
257.28 KB |
445.4 KB | 127.26% (🟡 +2.22%) |
/more |
256.43 KB |
444.56 KB | 127.02% (🟡 +2.22%) |
/org/[orgSlug] |
236.92 KB |
425.05 KB | 121.44% (🟡 +2.05%) |
/org/[orgSlug]/[user] |
243.33 KB |
431.45 KB | 123.27% (🟡 +2.03%) |
/org/[orgSlug]/[user]/[type] |
265.27 KB |
453.4 KB | 129.54% (🟡 +0.30%) |
/org/[orgSlug]/[user]/[type]/embed |
265.3 KB |
453.42 KB | 129.55% (🟡 +0.30%) |
/org/[orgSlug]/[user]/embed |
243.35 KB |
431.48 KB | 123.28% (🟡 +2.02%) |
/org/[orgSlug]/embed |
236.94 KB |
425.07 KB | 121.45% (🟡 +2.04%) |
/org/[orgSlug]/instant-meeting/team/[slug]/[type] |
264.91 KB |
453.04 KB | 129.44% (🟡 +0.30%) |
/org/[orgSlug]/team/[slug] |
236.93 KB |
425.06 KB | 121.45% (🟡 +2.04%) |
/org/[orgSlug]/team/[slug]/[type] |
264.95 KB |
453.07 KB | 129.45% (🟡 +0.30%) |
/settings/admin |
263.14 KB |
451.27 KB | 128.93% (🟡 +2.24%) |
/settings/admin/apps |
274.62 KB |
462.74 KB | 132.21% (🟡 +1.72%) |
/settings/admin/apps/[category] |
274.57 KB |
462.7 KB | 132.20% (🟡 +1.71%) |
/settings/admin/flags |
266.9 KB |
455.03 KB | 130.01% (🟡 +2.23%) |
/settings/admin/impersonation |
263.44 KB |
451.56 KB | 129.02% (🟡 +2.23%) |
/settings/admin/oAuth |
275.15 KB |
463.28 KB | 132.36% (🟡 +2.24%) |
/settings/admin/orgMigrations/_OrgMigrationLayout |
255.91 KB |
444.03 KB | 126.87% (🟡 +2.23%) |
/settings/admin/organizations |
265.16 KB |
453.29 KB | 129.51% (🟡 +2.23%) |
/settings/admin/organizations/[id]/edit |
263.66 KB |
451.79 KB | 129.08% (🟡 +2.23%) |
/settings/admin/users |
265.86 KB |
453.99 KB | 129.71% (🟡 +2.23%) |
/settings/billing |
263.34 KB |
451.47 KB | 128.99% (🟡 +2.23%) |
/settings/developer/api-keys |
267.77 KB |
455.89 KB | 130.25% (🟡 +2.24%) |
/settings/developer/webhooks |
267.69 KB |
455.81 KB | 130.23% (🟡 +2.23%) |
/settings/developer/webhooks/[id] |
268.75 KB |
456.87 KB | 130.54% (🟡 +2.23%) |
/settings/developer/webhooks/new |
268.79 KB |
456.92 KB | 130.55% (🟡 +2.23%) |
/settings/my-account/calendars |
274.13 KB |
462.26 KB | 132.07% (🟡 +2.24%) |
/settings/my-account/conferencing |
275.02 KB |
463.14 KB | 132.33% (🟡 +2.23%) |
/settings/my-account/general |
351.49 KB |
539.61 KB | 154.17% (🟡 +2.24%) |
/settings/my-account/out-of-office |
267.56 KB |
455.69 KB | 130.20% (🟡 +2.23%) |
/settings/my-account/profile |
399.91 KB |
588.04 KB | 168.01% (🟡 +2.08%) |
/settings/organizations/[id]/about |
152.38 KB |
340.51 KB | 97.29% (🟡 +0.25%) |
/settings/organizations/[id]/add-teams |
152.44 KB |
340.56 KB | 97.30% (🟡 +0.26%) |
/settings/organizations/[id]/set-password |
152.37 KB |
340.49 KB | 97.28% (🟡 +0.26%) |
/settings/organizations/appearance |
286.76 KB |
474.88 KB | 135.68% (🟡 +2.23%) |
/settings/organizations/billing |
263.38 KB |
451.51 KB | 129.00% (🟡 +2.23%) |
/settings/organizations/general |
344.03 KB |
532.16 KB | 152.04% (🟡 +2.24%) |
/settings/organizations/members |
435.88 KB |
624.01 KB | 178.29% (🟡 +2.23%) |
/settings/organizations/new |
152.39 KB |
340.51 KB | 97.29% (🟡 +0.25%) |
/settings/organizations/profile |
396.9 KB |
585.02 KB | 167.15% (🟡 +2.07%) |
/settings/organizations/teams/other |
264.2 KB |
452.32 KB | 129.24% (🟡 +2.23%) |
/settings/organizations/teams/other/[id]/appearance |
275.84 KB |
463.97 KB | 132.56% (🟡 +2.24%) |
/settings/organizations/teams/other/[id]/members |
270.73 KB |
458.86 KB | 131.10% (🟡 +2.24%) |
/settings/organizations/teams/other/[id]/profile |
469.07 KB |
657.19 KB | 187.77% (🟡 +2.23%) |
/settings/security/impersonation |
268.46 KB |
456.58 KB | 130.45% (🟡 +2.23%) |
/settings/security/sso |
273.44 KB |
461.57 KB | 131.88% (🟡 +2.23%) |
/settings/security/two-factor-auth |
272.28 KB |
460.41 KB | 131.55% (🟡 +2.23%) |
/settings/teams |
262.88 KB |
451 KB | 128.86% (🟡 +2.23%) |
/settings/teams/[id]/appearance |
275.83 KB |
463.96 KB | 132.56% (🟡 +2.23%) |
/settings/teams/[id]/billing |
263.38 KB |
451.51 KB | 129.00% (🟡 +2.23%) |
/settings/teams/[id]/profile |
469.9 KB |
658.02 KB | 188.01% (🟡 +2.23%) |
/settings/teams/[id]/sso |
273.97 KB |
462.1 KB | 132.03% (🟡 +2.23%) |
/settings/teams/new |
206.8 KB |
394.93 KB | 112.84% (🟡 +4.64%) |
/team/[slug] |
236.89 KB |
425.01 KB | 121.43% (🟡 +2.05%) |
/team/[slug]/[type] |
264.91 KB |
453.04 KB | 129.44% (🟡 +0.29%) |
/team/[slug]/[type]/embed |
264.94 KB |
453.07 KB | 129.45% (🟡 +0.29%) |
/team/[slug]/embed |
236.93 KB |
425.05 KB | 121.44% (🟡 +2.05%) |
/teams |
256.71 KB |
444.84 KB | 127.10% (🟡 +2.22%) |
/upgrade |
256.88 KB |
445.01 KB | 127.15% (🟡 +2.22%) |
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 "+/-
Current Playwright Test Results Summary
✅ 439 Passing - ⚠️ 17 Flaky
Run may still be in progress, this comment will be updated as current testing workflow or job completes...
(Last updated on 02/02/2024 07:09:02pm UTC)
Run Details
Running Workflow PR Update on Github Actions
Commit: f74ba88adde6d391f48e13097170aa805ead3202
Started: 02/02/2024 06:59:05pm UTC
⚠️ Flakes
📄 apps/web/playwright/booking/selectQuestion.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Booking With Phone Question and Each Other Question Booking With Select Question and Short text question Select required and Short text required
Retry 1 • Initial Attempt |
0.86% (2)2 / 233 runsfailed over last 7 days |
3.43% (8)8 / 233 runsflaked over last 7 days |
📄 apps/web/playwright/login.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
user can login & logout succesfully -- future login flow user & logout using dashboard
Retry 1 • Initial Attempt |
4.58% (11)11 / 240 runsfailed over last 7 days |
42.08% (101)101 / 240 runsflaked over last 7 days |
📄 apps/web/playwright/booking/checkboxGroupQuestion.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Booking With Checkbox Group Question and Each Other Question Booking With Checkbox Group Question and Address Question Booking With Checkbox Group Question and select Question Checkbox Group and select not required
Retry 1 • Initial Attempt |
0% (0)0 / 253 runsfailed over last 7 days |
3.16% (8)8 / 253 runsflaked over last 7 days |
📄 apps/web/playwright/booking/phoneQuestion.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Booking With Phone Question and Each Other Question Booking With Phone Question and Address Question Booking With Phone Question and Short text question Phone required and Short text not required
Retry 1 • Initial Attempt |
0% (0)0 / 252 runsfailed over last 7 days |
6.75% (17)17 / 252 runsflaked over last 7 days |
📄 apps/web/playwright/booking/allQuestions.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Booking With All Questions Selecting and filling all questions as required
Retry 1 • Initial Attempt |
0.76% (2)2 / 262 runsfailed over last 7 days |
4.96% (13)13 / 262 runsflaked over last 7 days |
📄 apps/web/playwright/insights.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Insights should be able to go to insights as members
Retry 1 • Initial Attempt |
0% (0)0 / 256 runsfailed over last 7 days |
4.69% (12)12 / 256 runsflaked over last 7 days |
📄 apps/web/playwright/booking/multipleEmailQuestion.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Booking With Multiple Email Question and Each Other Question Booking With Multiple Email Question and Radio group Question Multiple Email and Radio group not required
Retry 1 • Initial Attempt |
0% (0)0 / 258 runsfailed over last 7 days |
3.49% (9)9 / 258 runsflaked over last 7 days |
📄 packages/embeds/embed-core/playwright/tests/action-based.e2e.ts • 8 Flakes
Top 1 Common Error Messages
|
|
8 Test Cases Affected |
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Popup Tests should open embed iframe on click - Configured with light theme
Retry 1 • Initial Attempt |
-3.73% (-10)-10 / 268 runsfailed over last 7 days |
46.27% (124)124 / 268 runsflaked over last 7 days |
|
Popup Tests should be able to reschedule
Retry 1 • Initial Attempt |
-81.05% (-124)-124 / 153 runsfailed over last 7 days |
81.05% (124)124 / 153 runsflaked over last 7 days |
|
Popup Tests should open Routing Forms embed on click
Retry 1 • Initial Attempt |
-68.63% (-105)-105 / 153 runsfailed over last 7 days |
71.90% (110)110 / 153 runsflaked over last 7 days |
|
Popup Tests Floating Button Popup Pro User - Configured in App with default setting of system theme should open embed iframe according to system theme when no theme is configured through Embed API
Retry 1 • Initial Attempt |
-74.32% (-110)-110 / 148 runsfailed over last 7 days |
74.32% (110)110 / 148 runsflaked over last 7 days |
|
Popup Tests Floating Button Popup Pro User - Configured in App with default setting of system theme should open embed iframe according to system theme when configured with 'auto' theme using Embed API
Retry 1 • Initial Attempt |
-74.32% (-110)-110 / 148 runsfailed over last 7 days |
74.32% (110)110 / 148 runsflaked over last 7 days |
|
Popup Tests Floating Button Popup Pro User - Configured in App with default setting of system theme should open embed iframe(Booker Profile Page) with dark theme when configured with dark theme using Embed API
Retry 1 • Initial Attempt |
-74.32% (-110)-110 / 148 runsfailed over last 7 days |
74.32% (110)110 / 148 runsflaked over last 7 days |
|
Popup Tests Floating Button Popup Pro User - Configured in App with default setting of system theme should open embed iframe(Event Booking Page) with dark theme when configured with dark theme using Embed API
Retry 1 • Initial Attempt |
-74.32% (-110)-110 / 148 runsfailed over last 7 days |
74.32% (110)110 / 148 runsflaked over last 7 days |
|
Popup Tests prendered embed should be loaded and apply the config given to it
Retry 1 • Initial Attempt |
-74.32% (-110)-110 / 148 runsfailed over last 7 days |
74.32% (110)110 / 148 runsflaked over last 7 days |
📄 packages/embeds/embed-core/playwright/tests/preview.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Preview Preview - embed-core should load
Retry 1 • Initial Attempt |
0% (0)0 / 267 runsfailed over last 7 days |
25.84% (69)69 / 267 runsflaked over last 7 days |
📄 packages/embeds/embed-core/playwright/tests/inline.e2e.ts • 1 Flake
Test Case Results
| Test Case | Last 7 days Failures | Last 7 days Flakes |
|---|---|---|
|
Inline Iframe Inline Iframe - Configured with Dark Theme
Retry 1 • Initial Attempt |
0.75% (2)2 / 267 runsfailed over last 7 days |
37.83% (101)101 / 267 runsflaked over last 7 days |
Right now a user can't be invited to more than one organization as we still need to figure out the way that would allow us to clearly identify which entities are owned by which profile.
i think that is fine for now 🙏
I want to bring up I'm not sure I like the idea of the naming of "profile". While reading through the PR I had to get a grasp of what a profile in this context is. From my understanding, it's the org information and how it relates to the user. I think for maintainability we should name it something more obvious. What about
userOrgRepository&userOrgProfileor something along those lines?
Actually Profile is going to hold all the profiles including Personal Profile which is currently stored in User table in a way. So, as soon as a user is added to an organization, the User table stops being acting as his profile. After that, to create his personal profile, we would create an entry in Profile table only with organizationId=0 probably. This is how he would be able to switch b/w Personal and Organization Profile(both being stored in Profile table)
Thank you so much for the detailed review @joeauyeung !! Really appreciate going through the huge PR for even minute details 🙏
I have addressed all the feedback.
Thanks for the testing @joeauyeung. I have Fixed the profile switcher, it was a regression. https://www.loom.com/share/6bd6d89766764fa38e7e43b26af84bb5
Also, we aren't enable Profile Switcher in this release - Here is the releases plan https://docs.google.com/document/d/1ii3eyn0F0LaUCrX1c58YgdMt2V7xZWI2AGX1yKKM2Ik/edit#heading=h.b2ecpp7kmwhx
"When accepting an org invite from an existing user, the organization doesn't render until the user has logged out. Should we force a logout after accepting?" -After accepting the invite a refresh of the app is needed. I don't think logout is necessary.
This is in my todo list and I think a refetch for session should fix the issue.
