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

refactor: Only send dirty fields for event type update call #13292

Merged
merged 61 commits into from
Feb 15, 2024

Conversation

alishaz-polymath
Copy link
Member

@alishaz-polymath alishaz-polymath commented Jan 18, 2024

What does this PR do?

Earlier we would pass all event type fields even if the change is in one field. This PR updates the logic to only pass in dirty fields instead of all fields. This is a pre-requisite to Managed Events V2, so this PR would need to be merged before we can continue sorting out the Managed Events V2.

Here's a list of all fields that currently identify as dirty accurately:

  • Setup Tab
    • Title
    • slug
    • Description
    • locations
    • length
  • hidden
  • hosts
  • users
  • hashedLink
  • bookings
  • availability tab
    • Availability
    • Common Schedule
  • Teams Tab
    • Hosts
    • Priority
  • Limits Tab
    • beforeEventBuffer
    • afterEventBuffer
    • Minimum Notice
    • Time-slot Intervals
    • Booking Frequency
    • Booking only first slot
    • Total Booking Duration
    • Future Bookings
    • Offset start times
  • Advanced Tab
    • destinationCalendar
    • eventName
    • Layout (in Metadata)
    • bookingFields
      • Name
      • Email Address
      • Location
      • What is this meeting about
      • Additional Notes
      • Add guests
      • Reason for reschedule
    • hideCalendarNotes
    • hashed Link
    • requiresConfirmation
    • requiresBookerEmailVerification
    • successRedirectURL
    • lockTimeZoneToggleOnBookingPage
    • Seated Events
  • recurringEvents
  • workflows
  • webhooks

Fixes #13291
Fixes #13183

Requirement/Documentation

  • If there is a requirement document, please, share it here.
  • If there is ab UI/UX design document, please, share it here.

Type of change

  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)

How should this be tested?

  • Rigorously and carefully, touches core (event-types) and so it should be tested against all kinds of event-types, with the idea of saving changes to an event type. In managed events, it should only over-write the fields changed by Admin and not all the fields.

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

Copy link

vercel bot commented Jan 18, 2024

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

Name Status Preview Comments Updated (UTC)
api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 15, 2024 4:19pm
dev ❌ Failed (Inspect) Feb 15, 2024 4:19pm
6 Ignored Deployments
Name Status Preview Comments Updated (UTC)
ai ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 4:19pm
cal ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 4:19pm
cal-demo ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 4:19pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 4:19pm
qa ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 4:19pm
ui ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 4:19pm

@github-actions github-actions bot added event types Created by Linear-GitHub Sync event-types area: event types, event-types High priority Created by Linear-GitHub Sync ✨ feature New feature or request 🚧 wip / in the making 🚨 needs approval This feature request has not been reviewed yet by the Product Team and needs approval beforehand labels Jan 18, 2024
Copy link
Contributor

github-actions bot commented Jan 18, 2024

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

@keithwillcode keithwillcode added the core area: core, team members only label Jan 18, 2024
@alishaz-polymath alishaz-polymath changed the title Chore: Only send dirty fields for event type update call refactor: Only send dirty fields for event type update call Jan 18, 2024
Copy link
Contributor

github-actions bot commented Jan 18, 2024

📦 Next.js Bundle Analysis for @calcom/web

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

This PR introduced no changes to the JavaScript bundle! 🙌

Copy link

deploysentinel bot commented Jan 18, 2024

Current Playwright Test Results Summary

✅ 447 Passing - ⚠️ 8 Flaky

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

(Last updated on 02/15/2024 04:36:34pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: a3d87ff

Started: 02/15/2024 04:27:34pm UTC

⚠️ Flakes

📄   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 Address Question Multiple Email required and Address required
Retry 1Initial Attempt
0% (0) 0 / 241 runs
failed over last 7 days
5.39% (13) 13 / 241 runs
flaked over last 7 days

📄   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 checkbox group Question Select required and checkbox group required
Retry 1Initial Attempt
0% (0) 0 / 244 runs
failed over last 7 days
5.33% (13) 13 / 244 runs
flaked over last 7 days

📄   apps/web/playwright/booking/responsiveBooking.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Booking page with no questions Booking page with 1920x1080 resolution
Retry 1Initial Attempt
0% (0) 0 / 244 runs
failed over last 7 days
8.20% (20) 20 / 244 runs
flaked 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 checkbox Question Checkbox Group and checkbox not required
Retry 1Initial Attempt
0% (0) 0 / 246 runs
failed over last 7 days
6.91% (17) 17 / 246 runs
flaked over last 7 days

📄   apps/web/playwright/organization/organization-invitation.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Organization Email matching orgAutoAcceptEmail and a Verified Organization Team Invitation
Retry 1Initial Attempt
0% (0) 0 / 246 runs
failed over last 7 days
8.94% (22) 22 / 246 runs
flaked over last 7 days

📄   apps/web/playwright/profile.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
Update Profile Cannot update a users email when existing user has same email (verification enabled)
Retry 1Initial Attempt
0.38% (1) 1 / 260 run
failed over last 7 days
51.15% (133) 133 / 260 runs
flaked over last 7 days
Update Profile Can update a users email (verification enabled)
Retry 2Retry 1Initial Attempt
11.54% (30) 30 / 260 runs
failed over last 7 days
54.23% (141) 141 / 260 runs
flaked over last 7 days

📄   apps/web/playwright/organization/booking.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Bookings Team Event Can create a booking for Round Robin EventType
Retry 1Initial Attempt
0.43% (1) 1 / 230 run
failed over last 7 days
0.43% (1) 1 / 230 run
flaked over last 7 days

View Detailed Build Results


Copy link
Member

@sean-brydon sean-brydon left a comment

Choose a reason for hiding this comment

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

I think we can really optimise this and leverage RHF to do this for us - I also noticed this method was including fields that were never touched when saving. Please see other comments to see my explanation

apps/web/pages/event-types/[type]/index.tsx Outdated Show resolved Hide resolved
packages/lib/isEqual.ts Outdated Show resolved Hide resolved
@alishaz-polymath alishaz-polymath dismissed emrysal’s stale review February 14, 2024 11:23

The bookerLayout changes now work as expected

@alishaz-polymath
Copy link
Member Author

Hey @alishaz-polymath Almost everything works, well done!

On the Advanced Tab, if you make changes to the booking layout this works, and it updates. But if you continue to change other Advanced Tab before saving changes the booking layout change is not updated.

Checked against production and it does not happen there, so this is the one regression I could find.

@emrysal Can you please check now if it's still a problem? I tested with the latest changes and it appears to be gone now.

@CarinaWolli Can you check the Availability common schedule and Hosts are now working as expected?

The save button is still something I'm thinking over, because RHF isDirty is unreliable, as we can see. 🤔

@@ -472,10 +472,12 @@ const Hosts = ({
initialValue.current = { hosts: getValues("hosts"), schedulingType, submitCount };
return;
}
resetField("hosts", {
Copy link
Member

Choose a reason for hiding this comment

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

hosts weren't reset when changing the scheduling type as it wasn't set dirty

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you 🙌 🚀

@CarinaWolli
Copy link
Member

@CarinaWolli Can you check the Availability common schedule and Hosts are now working as expected?

I added one more fix to reset the hosts, now everything seems to work

@alishaz-polymath
Copy link
Member Author

Closed thanks to unintended use of shortcut 😢
Reopened 🙏

@alishaz-polymath
Copy link
Member Author

Still not finding an efficient solution for the SAVE button's disabled state. I could potentially extract the dirtyFields check and then maybe set it up in a useEffect inside the EventTypeSingleLayout.tsx file, but I'm wondering if it could be more efficient.
@emrysal Opinion?

Copy link
Contributor

@emrysal emrysal left a comment

Choose a reason for hiding this comment

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

Approved 😎

CarinaWolli
CarinaWolli previously approved these changes Feb 15, 2024
Copy link
Member

@CarinaWolli CarinaWolli left a comment

Choose a reason for hiding this comment

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

Tested again and everything worked. Great work @alishaz-polymath 🙌🏻

@@ -183,7 +183,7 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
checked={useEventTypeDestinationCalendarEmail}
onCheckedChange={(val) => {
setUseEventTypeDestinationCalendarEmail(val);
formMethods.setValue("useEventTypeDestinationCalendarEmail", val);
formMethods.setValue("useEventTypeDestinationCalendarEmail", val, { shouldDirty: true });
Copy link
Member

Choose a reason for hiding this comment

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

came in from the latest merge with main

Copy link
Contributor

@emrysal emrysal left a comment

Choose a reason for hiding this comment

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

Let's get this merged, nice work!

@emrysal emrysal merged commit ee286a6 into main Feb 15, 2024
38 checks passed
@emrysal emrysal deleted the chore/only-update-dirty-fields-eventtype branch February 15, 2024 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO event types Created by Linear-GitHub Sync event-types area: event types, event-types ✨ feature New feature or request High priority Created by Linear-GitHub Sync teams area: teams, round robin, collective, managed event-types
Projects
None yet
8 participants