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: Support moving a user and it's teams to an org as temporary approach #11892

Merged
merged 4 commits into from
Oct 17, 2023

Conversation

hariombalhara
Copy link
Member

@hariombalhara hariombalhara commented Oct 14, 2023

What does this PR do?

Corresponding website PR:
https://github.com/calcom/website/pull/638

Type of change

  • New feature (non-breaking change which adds functionality)

How should this be tested?

  • Have a user within a team with many apps installed and many event-types across teams
  • Migrate the user to an org
  • Check that all the teams and event-types and apps are accessible.

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

@vercel
Copy link

vercel bot commented Oct 14, 2023

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

Name Status Preview Comments Updated (UTC)
ai ❌ Failed (Inspect) Oct 16, 2023 10:24am
api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2023 10:24am
cal-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2023 10:24am
dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2023 10:24am
qa 🔄 Building (Inspect) Visit Preview 💬 Add feedback Oct 16, 2023 10:24am
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Oct 16, 2023 10:24am
ui ⬜️ Ignored (Inspect) Visit Preview Oct 16, 2023 10:24am

@github-actions
Copy link
Contributor

github-actions bot commented Oct 14, 2023

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

@github-actions github-actions bot added the ❗️ migrations contains migration files label Oct 14, 2023
@zomars zomars added the core area: core, team members only label Oct 14, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 14, 2023

📦 Next.js Bundle Analysis for @calcom/web

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

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 177.05 KB (🟡 +21.09 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

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

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Nine 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] 234.99 KB 412.04 KB 117.72% (🟢 -0.18%)
/[user]/[type]/embed 235.02 KB 412.07 KB 117.73% (🟢 -0.18%)
/apps/[slug]/[...pages] 549.04 KB 726.09 KB 207.45% (🟢 -0.21%)
/d/[link]/[slug] 234.98 KB 412.03 KB 117.72% (🟢 -0.18%)
/org/[orgSlug]/[user]/[type] 235.15 KB 412.2 KB 117.77% (🟢 -0.18%)
/org/[orgSlug]/[user]/[type]/embed 235.18 KB 412.23 KB 117.78% (🟢 -0.18%)
/org/[orgSlug]/team/[slug]/[type] 235.01 KB 412.06 KB 117.73% (🟢 -0.18%)
/team/[slug]/[type] 234.98 KB 412.03 KB 117.72% (🟢 -0.18%)
/team/[slug]/[type]/embed 235.01 KB 412.06 KB 117.73% (🟢 -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.

@deploysentinel
Copy link

deploysentinel bot commented Oct 14, 2023

Current Playwright Test Results Summary

✅ 147 Passing - ⚠️ 4 Flaky

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

(Last updated on 10/16/2023 10:21:02am UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: 3eb2e12

Started: 10/16/2023 10:19:11am 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 Change stripe presented currency Should be able to change currency
Retry 1Initial Attempt
0.71% (2) 2 / 283 runs
failed over last 7 days
2.83% (8) 8 / 283 runs
flaked over last 7 days

📄   packages/app-store/routing-forms/playwright/tests/basic.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Routing Forms Seeded Routing Form Router URL should work
Retry 1Initial Attempt
1% (3) 3 / 301 runs
failed over last 7 days
14.95% (45) 45 / 301 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/action-based.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 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 1Initial Attempt
2.93% (9) 9 / 307 runs
failed over last 7 days
32.25% (99) 99 / 307 runs
flaked over last 7 days
Popup Tests should be able to reschedule
Retry 1Initial Attempt
7.52% (23) 23 / 306 runs
failed over last 7 days
91.18% (279) 279 / 306 runs
flaked over last 7 days

View Detailed Build Results


@hariombalhara hariombalhara changed the title wip feat: Support moving an account to an org as temporary approach Oct 15, 2023
@hariombalhara hariombalhara changed the title feat: Support moving an account to an org as temporary approach feat: Support moving a user and it's teams to an org as temporary approach Oct 15, 2023
@hariombalhara hariombalhara force-pushed the fix/user-migration-to-org-strategy branch from f634eff to 3c73fcf Compare October 15, 2023 08:34
@hariombalhara hariombalhara force-pushed the fix/user-migration-to-org-strategy branch 2 times, most recently from c716e3c to e4140b8 Compare October 15, 2023 08:39
@@ -312,6 +316,18 @@ export const getServerSideProps: GetServerSideProps<UserPageProps> = async (cont
avatar: `/${user.username}/avatar.png`,
}));

if (!isOrgContext) {
const redirect = await getTemporaryOrgRedirect({
slug: usernameList[0],
Copy link
Member Author

Choose a reason for hiding this comment

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

Not supporting redirect for dynamic booking link for now as they would most probably be not hardcoded anywhere.

if (!isOrgContext) {
const redirect = await getTemporaryOrgRedirect({
slug: usernameList[0],
redirectType: RedirectType.User,
Copy link
Member Author

Choose a reason for hiding this comment

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

Redirect for user profile page.

const redirect = await getTemporaryOrgRedirect({
slug: usernames[0],
redirectType: RedirectType.User,
eventTypeSlug: slug,
Copy link
Member Author

Choose a reason for hiding this comment

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

Redirect for user even-type page.

if (!isOrgContext && slug) {
const redirect = await getTemporaryOrgRedirect({
slug: slug,
redirectType: RedirectType.Team,
Copy link
Member Author

Choose a reason for hiding this comment

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

Redirect for team profile page.

const redirect = await getTemporaryOrgRedirect({
slug: teamSlug,
redirectType: RedirectType.Team,
eventTypeSlug: meetingSlug,
Copy link
Member Author

Choose a reason for hiding this comment

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

Redirect for team event.

@@ -29,6 +29,13 @@ export const listHandler = async ({ ctx }: ListHandlerInput) => {
},
});

if (!membership) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Without membership wouldn't be able to see listing of an orgzniation

eventTypeSlug,
})
);
const redirect = await prisma.tempOrgRedirect.findUnique({
Copy link
Member Author

Choose a reason for hiding this comment

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

It's a temporary table and would be really lightweight. So, It should be quick to query but there would still be DB latency that would be added in querying a booking page.

I feel it's okay to have it for now, till we actually see a significant issue with it(as we will remove it anyway soon when mono-user Org schema is ready)

If we see an issue, our option then is to query this in parallel, with other queries on Booking Page which is possible


import { getServerSideProps as _getServerSideProps } from "../[type]";

export { default } from "../[type]";

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure why it wasn't using withEmbedSsr, all other embed pages were using that only.

Copy link
Member

@zomars zomars left a comment

Choose a reason for hiding this comment

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

Left some comments in the website PR. Also. Shouldn't this live in the web app admin panel instead of the website? (even if it's temporary)

@hariombalhara
Copy link
Member Author

Thanks for the review @zomars 🙏

There are 2 reasons why I didn't put into Admin Panel

  • It doesn't concern our self-hosters at all because it is something only we are going to need and that too temporarily.
  • More importantly, there is an endpoint in there that I don't want to be exposed to people. That endpoint that allow people to join an org by themselves(Though that logic is explicitly limited to isAdmin at the moment) and that could be abused.

Copy link
Member

@zomars zomars left a comment

Choose a reason for hiding this comment

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

Concerns were addressed 🙏🏽

@hariombalhara hariombalhara merged commit 225055f into main Oct 17, 2023
@hariombalhara hariombalhara deleted the fix/user-migration-to-org-strategy branch October 17, 2023 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core area: core, team members only High priority Created by Linear-GitHub Sync ❗️ migrations contains migration files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants