Skip to content

fix: separate Filter Segment implementation from DataTableProvider #20587

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

Merged

Conversation

eunjae-lee
Copy link
Contributor

@eunjae-lee eunjae-lee commented Apr 7, 2025

What does this PR do?

We've been calling useSegments() directly within DataTableProvider, which triggers trpc call to fetch segments.

This PR alters DataTableProvider to accept useSegments as a prop, meaning it's opt-in now.

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.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Filter Segment still works the same. For pages where we're not using DataTableSegment.xxx components, we no longer call trpc to query from FilterSegment.

Copy link

linear bot commented Apr 7, 2025

Copy link

vercel bot commented Apr 7, 2025

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

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Apr 9, 2025 9:37am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Apr 9, 2025 9:37am

@@ -74,6 +77,7 @@ interface DataTableProviderProps {
export function DataTableProvider({
tableIdentifier: _tableIdentifier,
children,
useSegments = useSegmentsNoop,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It accepts useSegments as a prop, and we use the noop implementation as the default value.


const clearAll = useCallback(
(exclude?: string[]) => {
setSegmentIdAndSaveToLocalStorage(null);
setAndPersistSegmentId(null);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's renamed (just cleaning up)

canSaveSegment,
isSegmentEnabled,
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 is now provided from useSegments.

useSegmentsNoop returns false for this.

@@ -23,7 +23,7 @@ import {
} from "@calcom/ui/components/table";

import { useColumnSizingVars } from "../hooks";
import { usePersistentColumnResizing } from "../lib/resizing";
import { useColumnResizing } from "../hooks/useColumnResizing";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lib/resizing.ts has been renamed to hooks/useColumnResizing

Also usePersistentColumnResizing has been renamed to useColumnResizing.
Previously the "persisting" part was done by this hook, but since Filter Segment, we've moved that part to useSegments(). So this hook itself doesn't persist anything. So I'm renaming it this way.

@@ -99,6 +99,14 @@ export function FilterSegmentSelect() {
];
}, [segments, t]);

if (!isSegmentEnabled) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We shouldn't use these components when Segment is not enabled, but just in case of mistake, we're early returning a disabled button.

@eunjae-lee eunjae-lee marked this pull request as ready for review April 7, 2025 15:01
@graphite-app graphite-app bot requested a review from a team April 7, 2025 15:01
@dosubot dosubot bot added the 💻 refactor label Apr 7, 2025
Copy link

graphite-app bot commented Apr 7, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (04/07/25)

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

"Add ready-for-e2e label" took an action on this PR • (04/09/25)

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

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.

Tested! All seems to be working fine for me!

@eunjae-lee eunjae-lee enabled auto-merge (squash) April 9, 2025 09:30
@eunjae-lee eunjae-lee merged commit 5935cf7 into main Apr 9, 2025
37 of 38 checks passed
@eunjae-lee eunjae-lee deleted the eunjae/cal-5432-enable-datatable-without-datatableprovider branch April 9, 2025 09:53
Copy link
Contributor

github-actions bot commented Apr 9, 2025

E2E results are ready!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants