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: org-wide workflows #15083

Open
wants to merge 123 commits into
base: main
Choose a base branch
from
Open

feat: org-wide workflows #15083

wants to merge 123 commits into from

Conversation

CarinaWolli
Copy link
Member

@CarinaWolli CarinaWolli commented May 16, 2024

What does this PR do?

  • Org-workflow can be set active on teams and will trigger for all the team event types + all the user event types of the team members.
    • if a user is member of several active teams, the workflow only triggers once
  • Add 'apply to all, including future teams/event-types'
  • workflows/update.handler is refactored into smaller functions that can be reused and tested.
  • Also fixes some small existing bugs that I found when refactoring the code

Todo:

  • When member is removed from team and workflow has 'active on all, including future' set then reminders aren't deleted (reminders should be deleted if user isn't member of any other team)

Fixes #14638
Fixes CAL-3489

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 --> Created an issue for that: Org-wide workflows docs#93
  • 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?

Basic test:

  • Create an org workflow
  • Set active on a team (or all teams)
  • Book a team event type --> see if workflow triggers
  • Book a user event type of a team member --> see if workflow triggers

Test other cases, for example:

  • test with several teams when some team members are part of several teams --> a workflow should always just trigger once
  • Test updating a 'before event' workflow and see if WorkflowReminders are correctly adjusted
  • Test removing team workflow and see if reminders are deleted (if user is still part of another team that is active, the reminder should stay)
  • delete/add reminders for deleted/added steps
  • Add reminders for new active teams
  • Test if 'active on all teams/even-types, including future ones' works with new event types/teams

@graphite-app graphite-app bot requested a review from a team June 11, 2024 13:54
@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking teams area: teams, round robin, collective, managed event-types workflows area: workflows, automations ✨ feature New feature or request labels Jun 11, 2024
Copy link

graphite-app bot commented Jun 11, 2024

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.

@hariombalhara
Copy link
Member

hariombalhara commented Jun 12, 2024

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
Copy link
Member

hariombalhara commented Jun 12, 2024

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

Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

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

Getting my head around workflows right now. So, submitting partial review

packages/features/ee/workflows/lib/test/workflows.test.ts Outdated Show resolved Hide resolved
packages/trpc/server/routers/viewer/workflows/util.ts Outdated Show resolved Hide resolved
Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

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

Getting my head around workflows right now. So, submitting partial review

@hariombalhara
Copy link
Member

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

@CarinaWolli
Copy link
Member Author

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
Copy link
Member Author

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

@hariombalhara
Copy link
Member

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
Copy link
Member

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.

@CarinaWolli
Copy link
Member Author

Workflow count is wrong on the left.

I fixed the workflow count: 303798e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 ❗️ migrations contains migration files organizations area: organizations, orgs teams area: teams, round robin, collective, managed event-types workflows area: workflows, automations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CAL-3489] org-wide workflows
3 participants