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

feat: org-wide workflows

Open CarinaWolli opened this issue 1 year ago • 3 comments

What does this PR do?

  • Fixes #XXXX (GitHub issue number)
  • Fixes CAL-XXXX (Linear issue number - should be visible at the bottom of the GitHub issue description)

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

CarinaWolli avatar May 16 '24 17:05 CarinaWolli

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

github-actions[bot] avatar May 16 '24 17:05 github-actions[bot]

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 Jul 8, 2024 9:15am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Jul 8, 2024 9:15am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Jul 8, 2024 9:15am

vercel[bot] avatar May 16 '24 17:05 vercel[bot]

📦 Next.js Bundle Analysis for @calcom/web

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

Seventy-eight 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)
/apps 279.9 KB 507.58 KB 145.02% (🟢 -1.22%)
/apps/[slug] 297.49 KB 525.17 KB 150.05% (🟢 -1.23%)
/apps/[slug]/[...pages] 588.56 KB 816.23 KB 233.21% (🟢 -1.17%)
/apps/categories 256.25 KB 483.93 KB 138.27% (🟢 -1.23%)
/apps/categories/[category] 262.01 KB 489.69 KB 139.91% (🟢 -1.23%)
/apps/installed/[category] 278.35 KB 506.03 KB 144.58% (🟢 -1.79%)
/auth/saml-idp 12.22 KB 239.9 KB 68.54% (🟢 -20.80%)
/availability 426.15 KB 653.83 KB 186.81% (🟢 -1.79%)
/availability/[schedule] 410.57 KB 638.25 KB 182.36% (🟢 -1.65%)
/bookings/[status] 325.94 KB 553.61 KB 158.18% (🟢 -1.22%)
/enterprise 256.31 KB 483.99 KB 138.28% (🟢 -1.22%)
/event-types 561.26 KB 788.94 KB 225.41% (🟢 -1.17%)
/event-types/[type] 437.53 KB 665.21 KB 190.06% (🟢 -1.14%)
/insights 474.66 KB 702.34 KB 200.67% (🟢 -1.68%)
/more 255.81 KB 483.49 KB 138.14% (🟢 -1.22%)
/settings/admin 262.25 KB 489.93 KB 139.98% (🟢 -1.21%)
/settings/admin/apps 275.49 KB 503.17 KB 143.76% (🟢 -1.24%)
/settings/admin/apps/[category] 275.48 KB 503.16 KB 143.76% (🟢 -1.24%)
/settings/admin/flags 265.97 KB 493.65 KB 141.04% (🟢 -1.24%)
/settings/admin/impersonation 262.64 KB 490.32 KB 140.09% (🟢 -1.21%)
/settings/admin/lockedSMS 283.74 KB 511.42 KB 146.12% (🟢 -1.18%)
/settings/admin/oAuth 274.25 KB 501.93 KB 143.41% (🟢 -1.24%)
/settings/admin/orgMigrations/_OrgMigrationLayout 251.18 KB 478.86 KB 136.82% (🟢 -1.22%)
/settings/admin/orgMigrations/moveTeamToOrg 300.92 KB 528.6 KB 151.03% (🟢 -1.20%)
/settings/admin/orgMigrations/moveUserToOrg 320.75 KB 548.42 KB 156.69% (🟢 -1.17%)
/settings/admin/orgMigrations/removeTeamFromOrg 300.68 KB 528.36 KB 150.96% (🟢 -1.20%)
/settings/admin/orgMigrations/removeUserFromOrg 300.69 KB 528.37 KB 150.96% (🟢 -1.19%)
/settings/admin/organizations 264.14 KB 491.81 KB 140.52% (🟢 -1.21%)
/settings/admin/organizations/[id]/edit 262.8 KB 490.48 KB 140.14% (🟢 -1.22%)
/settings/admin/users 264.91 KB 492.59 KB 140.74% (🟢 -1.21%)
/settings/admin/users/[id]/edit 393.97 KB 621.64 KB 177.61% (🟢 -1.21%)
/settings/admin/users/add 393.63 KB 621.31 KB 177.52% (🟢 -1.22%)
/settings/billing 262.46 KB 490.13 KB 140.04% (🟢 -1.21%)
/settings/developer/api-keys 266.74 KB 494.42 KB 141.26% (🟢 -1.24%)
/settings/developer/webhooks 266.92 KB 494.6 KB 141.31% (🟢 -1.24%)
/settings/developer/webhooks/[id] 267.9 KB 495.58 KB 141.59% (🟢 -1.22%)
/settings/developer/webhooks/new 267.92 KB 495.6 KB 141.60% (🟢 -1.22%)
/settings/my-account/appearance 314.34 KB 542.02 KB 154.86% (🟢 -1.52%)
/settings/my-account/calendars 274.37 KB 502.05 KB 143.44% (🟢 -1.10%)
/settings/my-account/conferencing 272.35 KB 500.03 KB 142.86% (🟢 -1.94%)
/settings/my-account/general 377.86 KB 605.54 KB 173.01% (🟢 -1.23%)
/settings/my-account/out-of-office 267.38 KB 495.06 KB 141.44% (🟢 -1.24%)
/settings/my-account/profile 410.31 KB 637.98 KB 182.28% (🟢 -1.23%)
/settings/organizations/[id]/about 159.67 KB 387.35 KB 110.67% (🟡 +0.48%)
/settings/organizations/[id]/add-teams 159.67 KB 387.34 KB 110.67% (🟡 +0.47%)
/settings/organizations/admin-api 262.41 KB 490.09 KB 140.03% (🟢 -1.22%)
/settings/organizations/appearance 122.33 KB 350.01 KB 100.00% (🟢 -48.02%)
/settings/organizations/billing 262.49 KB 490.17 KB 140.05% (🟢 -1.21%)
/settings/organizations/dsync 295.12 KB 522.79 KB 149.37% (🟢 -1.21%)
/settings/organizations/general 350.7 KB 578.38 KB 165.25% (🟢 -1.23%)
/settings/organizations/members 400.52 KB 628.2 KB 179.48% (🟢 -1.61%)
/settings/organizations/new 159.68 KB 387.36 KB 110.67% (🟡 +0.48%)
/settings/organizations/privacy 267.9 KB 495.58 KB 141.59% (🟢 -1.24%)
/settings/organizations/profile 415.17 KB 642.85 KB 183.67% (🟡 +2.30%)
/settings/organizations/sso 273.08 KB 500.76 KB 143.07% (🟢 -1.21%)
/settings/organizations/teams/other 263.32 KB 491 KB 140.29% (🟢 -1.22%)
/settings/organizations/teams/other/[id]/appearance 275.13 KB 502.8 KB 143.66% (🟢 -1.19%)
/settings/organizations/teams/other/[id]/members 269.81 KB 497.49 KB 142.14% (🟢 -1.24%)
/settings/organizations/teams/other/[id]/profile 473.53 KB 701.21 KB 200.34% (🟢 -1.23%)
/settings/platform 260.91 KB 488.59 KB 139.60% (🟢 -1.23%)
/settings/platform/new 120.69 KB 348.37 KB 99.53% (🟡 +0.52%)
/settings/platform/oauth-clients/[clientId]/edit 259.22 KB 486.9 KB 139.11% (🟢 -1.22%)
/settings/platform/oauth-clients/create 258.36 KB 486.04 KB 138.87% (🟢 -1.23%)
/settings/security/impersonation 267.56 KB 495.24 KB 141.50% (🟢 -1.25%)
/settings/security/password 305.71 KB 533.39 KB 152.40% (🟢 -1.23%)
/settings/security/sso 272.53 KB 500.21 KB 142.92% (🟢 -1.21%)
/settings/security/two-factor-auth 271.04 KB 498.72 KB 142.49% (🟢 -1.24%)
/settings/teams 261.99 KB 489.67 KB 139.90% (🟢 -1.21%)
/settings/teams/[id]/appearance 275.11 KB 502.79 KB 143.65% (🟢 -1.19%)
/settings/teams/[id]/billing 262.49 KB 490.17 KB 140.05% (🟢 -1.21%)
/settings/teams/[id]/members 379.93 KB 607.61 KB 173.60% (🟢 -1.23%)
/settings/teams/[id]/profile 474.31 KB 701.99 KB 200.57% (🟢 -1.24%)
/settings/teams/new 193.08 KB 420.76 KB 120.22% (🟢 -1.81%)
/teams 256.04 KB 483.72 KB 138.21% (🟢 -1.23%)
/upgrade 256.16 KB 483.84 KB 138.24% (🟢 -1.23%)
/video/[uid] 291.18 KB 518.86 KB 148.24% (🟢 -0.17%)
/workflows 288.07 KB 515.75 KB 147.36% (🟢 -1.17%)
/workflows/[workflow] 414.61 KB 642.29 KB 183.51% (🟢 -1.44%)
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 "+/-

github-actions[bot] avatar May 16 '24 17:05 github-actions[bot]

Graphite Automations

"Add foundation team as reviewer" took an action on this PR • (06/11/24)

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

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

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

graphite-app[bot] avatar Jun 11 '24 13:06 graphite-app[bot]

Workflow count is wrong on the left. This is the case for Acme's owner's event

Also, the Org workflow toggle isn't in its disabled state visually image

hariombalhara avatar Jun 12 '24 12:06 hariombalhara

I think to clearly communicate the meaning, we should change the message to Active on all teams and their members

Initially I thought it could be just the team events but it is those team's members' events as well.

image

hariombalhara avatar Jun 12 '24 12:06 hariombalhara

Have we handled the cleanup of workflows when a user is removed from a team. In my testing I found that the reminder remains even when there is no team.

No Team is there. The user was a member of a team earlier image

But workflow that came from Org is still there image

hariombalhara avatar Jun 12 '24 14:06 hariombalhara

Have we handled the cleanup of workflows when a user is removed from a team. In my testing I found that the reminder remains even when there is no team.

Should be handled here: https://github.com/calcom/cal.com/pull/15083/files#diff-00296740ffe644796cf7e681b96fe07cd4fa0283d1cef7ef345635f789a34cc9L1

do you have 'active on all including future teams' enabled? I think in that case it currently doesn't remove the reminder, which it should tho (https://github.com/calcom/cal.com/pull/15083/files#diff-00296740ffe644796cf7e681b96fe07cd4fa0283d1cef7ef345635f789a34cc9R160)

CarinaWolli avatar Jun 12 '24 15:06 CarinaWolli

I think to clearly communicate the meaning, we should change the message to Active on all teams and their members

Initially I thought it could be just the team events but it is those team's members' events as well.

image

What do you think about adding that information here? Screenshot 2024-06-12 at 12 21 36 PM

CarinaWolli avatar Jun 12 '24 16:06 CarinaWolli

Have we handled the cleanup of workflows when a user is removed from a team. In my testing I found that the reminder remains even when there is no team.

Should be handled here: https://github.com/calcom/cal.com/pull/15083/files#diff-00296740ffe644796cf7e681b96fe07cd4fa0283d1cef7ef345635f789a34cc9L1

do you have 'active on all including future teams' enabled? I think in that case it currently doesn't remove the reminder, which it should tho (https://github.com/calcom/cal.com/pull/15083/files#diff-00296740ffe644796cf7e681b96fe07cd4fa0283d1cef7ef345635f789a34cc9R160)

Yeah that was the case exactly

hariombalhara avatar Jun 12 '24 16:06 hariombalhara

I think to clearly communicate the meaning, we should change the message to Active on all teams and their members

Initially I thought it could be just the team events but it is those team's members' events as well.

image

What do you think about adding that information here? Screenshot 2024-06-12 at 12 21 36 PM

Yeah sounds good to me.

hariombalhara avatar Jun 12 '24 18:06 hariombalhara

Workflow count is wrong on the left.

I fixed the workflow count: https://github.com/calcom/cal.com/pull/15083/commits/303798e7239cafd278a3d4167289807dbf7efc42

CarinaWolli avatar Jun 12 '24 18:06 CarinaWolli

Toggle status bug https://www.loom.com/share/f05e5d66df15410c8c40454cdaaefb25

hariombalhara avatar Jun 13 '24 08:06 hariombalhara

I had created 3 workflows that directly or indirectly targeted a team(T1) WF-1: Org Workflow -> With all future events selected(So it targets team T1 events as well) WF-2: Org Workflow -> T1 Team. WF-3: Team Workflow for T1

Steps:

  1. Book a team T1 event say t1/30min
  2. Observe that there are three reminders created
  3. Disband the team
  4. Observe that 2 reminders still exists corresponding to WF-1 and WF-2

hariombalhara avatar Jun 13 '24 13:06 hariombalhara

I want to confirm this as I am confused.

An org workflow which has ''include future events' flag enabled is applicable to the org members that aren't part of any team right?

hariombalhara avatar Jun 13 '24 18:06 hariombalhara

An org workflow which has ''include future events' flag enabled is applicable to the org members that aren't part of any team right?

That's something I was uncertain as well. But as it says 'Apply to all, including future teams', I think members that aren't part of a team shouldn't be included. That's why I implemented it like that in removeMember handler now.

However, I still would need to fix getAllWorkflows, it also returns the org workflow if the user is not part of any team.

Let me know if you think different about that

CarinaWolli avatar Jun 13 '24 19:06 CarinaWolli

I had created 3 workflows that directly or indirectly targeted a team(T1) WF-1: Org Workflow -> With all future events selected(So it targets team T1 events as well) WF-2: Org Workflow -> T1 Team. WF-3: Team Workflow for T1

Steps:

  1. Book a team T1 event say t1/30min
  2. Observe that there are three reminders created
  3. Disband the team
  4. Observe that 2 reminders still exists corresponding to WF-1 and WF-2

Nice find, deleting a team wasn't handled yet. This should fix the issue you described: https://github.com/calcom/cal.com/pull/15083/files#diff-2e09b54c1171b0e62fad257d21e021061f76bf6ad2a72c13d948d96be6127239R27

CarinaWolli avatar Jun 13 '24 22:06 CarinaWolli

However, I still would need to fix getAllWorkflows, it also returns the org workflow if the user is not part of any team.

Fixed that. Now, if a user in't part of any team then org workflows with 'active on all, including future teams' will not trigger

CarinaWolli avatar Jun 14 '24 00:06 CarinaWolli

However, I still would need to fix getAllWorkflows, it also returns the org workflow if the user is not part of any team.

Fixed that. Now, if a user in't part of any team then org workflows with 'active on all, including future teams' will not trigger

I think we have taken different decisions for this at different places. This is getting confusing. Maybe we can confirm from @ciaranha @PeerRich

e.g. An app installed at an org level is available for org members regardless of being a subteam member AFAIK Not sure how webhooks work.

hariombalhara avatar Jun 14 '24 03:06 hariombalhara

@ciaranha's answer to "should org workflow be triggered if user is not part of any team?":

I think the answer to this has to be yes. They're still in the org.

I fixed that now and also changed the text for the checkbox. I think that's more accurate: Screenshot 2024-06-17 at 4 02 26 PM

CarinaWolli avatar Jun 17 '24 20:06 CarinaWolli

Amazing work @CarinaWolli 🎉 It is a complex addition to workflows affecting a lot of places.

It was great reviewing this with your speed of iteration as well !!

I am not sure if we should merge this now or wait till after the retreat as it is a big PR.

Also, someone else who has more experience with workflows should also review this to ensure the entire functionality is working

hariombalhara avatar Jun 24 '24 06:06 hariombalhara

@CarinaWolli can i disable global org workflow on any event type?

I see the message "Locked by team admin" even on my personal event types

org workflows can't be disabled on any event type, that's by design

CarinaWolli avatar Jun 25 '24 13:06 CarinaWolli

@emrysal @zomars Just spoke with @CarinaWolli and we are going to wait until post-retreat to merge this. Moving back to draft for that reason.

keithwillcode avatar Jun 26 '24 14:06 keithwillcode

Fixed merge conflicts caused by https://github.com/calcom/cal.com/pull/15590/files (getEventTypesFromDB)

CarinaWolli avatar Jul 08 '24 09:07 CarinaWolli