Skip to content

Comments

fix: add isDryRun behaviour for date overrides#24464

Merged
Ryukemeister merged 9 commits intomainfrom
add-dry-run-prop-to-date-overrides
Oct 17, 2025
Merged

fix: add isDryRun behaviour for date overrides#24464
Ryukemeister merged 9 commits intomainfrom
add-dry-run-prop-to-date-overrides

Conversation

@Ryukemeister
Copy link
Contributor

@Ryukemeister Ryukemeister commented Oct 14, 2025

What does this PR do?

  • We were missing dry run behaviour for date overrides inside availability settings atom. This PR fixes that.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • (N/A) I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

This can be tested in the platform examples app /availability page

@Ryukemeister Ryukemeister requested a review from a team October 14, 2025 22:45
@Ryukemeister Ryukemeister requested a review from a team as a code owner October 14, 2025 22:45
@keithwillcode keithwillcode added core area: core, team members only platform Anything related to our platform plan labels Oct 14, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

An optional isDryRun?: boolean prop is added and threaded through AvailabilitySettings, AvailabilitySettingsPlatformWrapper, DateOverrideList, DateOverrideInputDialog, and DateOverrideForm. When isDryRun is true, submission and side-effecting updates (override onChange, replace/unsortedFieldArrayMap mutations, availability updates, and delete actions) are gated and skipped; DateOverrideInputDialog/Form clear selected dates or avoid applying computed datesInRanges during dry runs. Default behavior remains unchanged (isDryRun false). The platform wrapper forwards the prop unchanged. An example page includes a commented isDryRun usage and a changeset documents the patch.

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title concisely and accurately describes the primary change of the pull request, namely adding the isDryRun behavior for date overrides, and follows a clear and specific format without extraneous detail.
Description Check ✅ Passed The description clearly states the goal of the PR, which is to add missing dry run behavior for date overrides in the availability settings atom, and provides relevant context and testing instructions.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-dry-run-prop-to-date-overrides

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot bot added the 🐛 bug Something isn't working label Oct 14, 2025
@vercel
Copy link

vercel bot commented Oct 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Oct 17, 2025 8:08am
cal-eu Ignored Ignored Oct 17, 2025 8:08am

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/features/schedules/components/DateOverrideInputDialog.tsx (1)

185-187: Toast notification misleads users in dry-run mode.

The success toast is displayed regardless of isDryRun status. When in dry-run mode, no actual changes are persisted, so showing a "success" message could mislead users into thinking their changes were saved.

Apply this diff to conditionally show the toast:

             <Button
               className="ml-2"
               color="primary"
               type="submit"
               onClick={() => {
-                showToast(t("date_successfully_added"), "success", 500);
+                if (!isDryRun) {
+                  showToast(t("date_successfully_added"), "success", 500);
+                }
               }}
               disabled={selectedDates.length === 0}
               data-testid="add-override-submit-btn">
🧹 Nitpick comments (2)
packages/features/schedules/components/DateOverrideInputDialog.tsx (1)

241-241: Prefer named export over default export.

As per coding guidelines, named exports provide better tree-shaking, easier refactoring, and clearer imports.

Apply this diff:

-export default DateOverrideInputDialog;
+export { DateOverrideInputDialog };

Then update imports in consuming files from:

import DateOverrideInputDialog from "./DateOverrideInputDialog";

to:

import { DateOverrideInputDialog } from "./DateOverrideInputDialog";
packages/features/schedules/components/DateOverrideList.tsx (1)

165-165: Prefer named export over default export.

As per coding guidelines, named exports provide better tree-shaking, easier refactoring, and clearer imports.

Apply this diff:

-export default DateOverrideList;
+export { DateOverrideList };

Then update imports in consuming files from:

import DateOverrideList from "./DateOverrideList";

to:

import { DateOverrideList } from "./DateOverrideList";
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 003aaaa and 8406d28.

📒 Files selected for processing (5)
  • packages/features/schedules/components/DateOverrideInputDialog.tsx (5 hunks)
  • packages/features/schedules/components/DateOverrideList.tsx (4 hunks)
  • packages/platform/atoms/availability/AvailabilitySettings.tsx (8 hunks)
  • packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx (1 hunks)
  • packages/platform/examples/base/src/pages/availability.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/platform/examples/base/src/pages/availability.tsx
  • packages/features/schedules/components/DateOverrideList.tsx
  • packages/features/schedules/components/DateOverrideInputDialog.tsx
  • packages/platform/atoms/availability/AvailabilitySettings.tsx
  • packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/platform/examples/base/src/pages/availability.tsx
  • packages/features/schedules/components/DateOverrideList.tsx
  • packages/features/schedules/components/DateOverrideInputDialog.tsx
  • packages/platform/atoms/availability/AvailabilitySettings.tsx
  • packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/platform/examples/base/src/pages/availability.tsx
  • packages/features/schedules/components/DateOverrideList.tsx
  • packages/features/schedules/components/DateOverrideInputDialog.tsx
  • packages/platform/atoms/availability/AvailabilitySettings.tsx
  • packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install dependencies / Yarn install & cache
🔇 Additional comments (4)
packages/features/schedules/components/DateOverrideInputDialog.tsx (1)

114-136: LGTM! Submission logic correctly gated.

The logic correctly prevents onChange from being called when isDryRun is true, ensuring no side effects occur during dry-run mode.

packages/platform/examples/base/src/pages/availability.tsx (1)

52-53: LGTM! Example demonstrates dry-run usage.

The commented isDryRun prop serves as helpful documentation for consumers of the AvailabilitySettings component.

packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx (1)

36-36: LGTM! isDryRun correctly propagated.

The wrapper properly threads the isDryRun prop through to the nested AvailabilitySettings component with an appropriate default value.

Also applies to: 59-59, 206-206

packages/platform/atoms/availability/AvailabilitySettings.tsx (1)

128-128: LGTM! isDryRun properly integrated throughout.

The isDryRun prop is correctly added to the component interface and consistently propagated to all nested date override components (DateOverrideList, DateOverrideInputDialog). The submission logic at lines 219-221 properly gates handleSubmit to prevent updates during dry-run mode.

Also applies to: 194-194, 208-208, 219-221, 248-248, 260-260, 318-318, 686-686

Copy link
Contributor

@supalarry supalarry left a comment

Choose a reason for hiding this comment

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

Small comment:

if (selectedDates.length === 0) return;

if (datesUnavailable) {
if (!isDryRun && datesUnavailable) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding !isDryRun to current if and else & having duplicate onChange(datesInRanges); you could simply update line 112 to simplify code:

if (selectedDates.length === 0 || isDryRun) return;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this won't work because we still need to set selected dates to an empty array at line 138, so I did this instead

if (selectedDates.length === 0) return;

if (isDryRun) {
  setSelectedDates([]);
  return;
}

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
packages/features/schedules/components/DateOverrideInputDialog.tsx (1)

114-117: Clarify the intent of clearing selectedDates during dry run.

The past review suggested simplifying by combining the checks at lines 112 and 114-117 into if (selectedDates.length === 0 || isDryRun) return;. However, your current implementation clears selectedDates before returning when isDryRun is true (line 115).

Is this clearing behavior intentional to reset the UI state and provide visual feedback that the action was acknowledged but not executed? If so, the current approach is correct. If not, the past review's suggestion would simplify the code.

🧹 Nitpick comments (1)
packages/features/schedules/components/DateOverrideInputDialog.tsx (1)

234-240: Note: isDryRun is forwarded implicitly via spread operator.

The isDryRun prop is correctly passed to DateOverrideForm via {...passThroughProps} (line 237). While this works correctly, consider explicitly passing isDryRun for better code clarity and easier traceability, similar to how excludedDates, weekStart, and userTimeFormat are explicitly passed.

Apply this diff to make the prop forwarding more explicit:

       <DateOverrideForm
         excludedDates={excludedDates}
         weekStart={weekStart}
-        {...passThroughProps}
+        workingHours={passThroughProps.workingHours}
+        onChange={passThroughProps.onChange}
+        value={passThroughProps.value}
+        isDryRun={passThroughProps.isDryRun}
         onClose={() => setOpen(false)}
         userTimeFormat={userTimeFormat}
       />
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 23fdbef and 6d19f2f.

📒 Files selected for processing (1)
  • packages/features/schedules/components/DateOverrideInputDialog.tsx (5 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/features/schedules/components/DateOverrideInputDialog.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/features/schedules/components/DateOverrideInputDialog.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/features/schedules/components/DateOverrideInputDialog.tsx
🔇 Additional comments (2)
packages/features/schedules/components/DateOverrideInputDialog.tsx (2)

126-126: Good refactor: onChange calls are now explicit within each branch.

Moving onChange(datesInRanges) calls inside their respective branches (datesUnavailable true/false) makes the control flow clearer compared to having a single call after both branches.

Also applies to: 140-140


29-29: LGTM: isDryRun prop additions are well-structured.

The isDryRun prop is correctly added with:

  • A sensible default value of false (line 29) for opt-in behavior
  • Proper TypeScript typing as optional (lines 38, 226)
  • Consistent propagation through the component hierarchy

Also applies to: 38-38, 226-226

@supalarry supalarry self-requested a review October 17, 2025 08:19
@Ryukemeister Ryukemeister enabled auto-merge (squash) October 17, 2025 08:23
@Ryukemeister Ryukemeister merged commit ec3656e into main Oct 17, 2025
57 of 59 checks passed
@Ryukemeister Ryukemeister deleted the add-dry-run-prop-to-date-overrides branch October 17, 2025 08:42
@github-actions
Copy link
Contributor

E2E results are ready!

KartikLabhshetwar pushed a commit to KartikLabhshetwar/cal.com that referenced this pull request Oct 25, 2025
* chore: add `isDryRun` prop for date overrides

* chore: add changesets

* chore: implement PR feedback

* fix: merge conflicts
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 platform Anything related to our platform plan ready-for-e2e size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants