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: replace more DatePickers with LemonCalendarSelect #22332

Merged
merged 22 commits into from
May 21, 2024

Conversation

daibhin
Copy link
Contributor

@daibhin daibhin commented May 16, 2024

Problem

towards #13624

Changes

Before After
Screenshot 2024-05-14 at 17 16 16 Screenshot 2024-05-16 at 14 52 50

Copy link
Contributor

github-actions bot commented May 17, 2024

Size Change: 0 B

Total Size: 1.05 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.05 MB

compressed-size-action

@daibhin daibhin changed the title feat: allow upcoming / past ranges in LemonCalendarSelect component feat: replace more DatePickers with LemonCalendarSelect May 17, 2024
Copy link

coderabbitai bot commented May 20, 2024

Walkthrough

The recent updates involve several refinements to the LemonCalendar and LemonCalendarSelect components. Key changes include fixing the endOfMonth calculation in LemonCalendar.tsx and making the onChange prop optional in LemonCalendarSelect.tsx. Additionally, the DatePicker component has been replaced with LemonCalendarSelectInput in multiple files, improving date input handling across the application.

Changes

Files Change Summary
frontend/src/lib/lemon-ui/LemonCalendar/LemonCalendar.tsx Adjusted endOfMonth calculation to add 1 day before calling endOf('month').
frontend/src/lib/lemon-ui/LemonCalendar/LemonCalendarSelect.tsx Made onChange prop optional and updated callbacks to use optional chaining.
frontend/src/scenes/annotations/AnnotationModal.tsx Refactored imports and replaced DatePicker with LemonCalendarSelectInput.
frontend/src/scenes/plugins/edit/interface-jobs/PluginJobConfiguration.tsx Replaced DatePicker with LemonCalendarSelectInput in the FieldInput function.

🐰
In the code where calendars dwell,
We fixed the end-of-month spell.
Optional changes now take place,
With inputs that bring a smile to your face.
Date pickers evolved, sleek and bright,
Lemon selects now light up the night.
🌙


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits Files that changed from the base of the PR and between c41995f and d458d92.
Files selected for processing (4)
  • frontend/src/lib/lemon-ui/LemonCalendar/LemonCalendar.tsx (1 hunks)
  • frontend/src/lib/lemon-ui/LemonCalendar/LemonCalendarSelect.tsx (5 hunks)
  • frontend/src/scenes/annotations/AnnotationModal.tsx (2 hunks)
  • frontend/src/scenes/plugins/edit/interface-jobs/PluginJobConfiguration.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • frontend/src/lib/lemon-ui/LemonCalendar/LemonCalendarSelect.tsx
Additional comments not posted (1)
frontend/src/lib/lemon-ui/LemonCalendar/LemonCalendar.tsx (1)

69-71: Adjustment in the calculation of endOfMonth to address the dayjs library issue looks good.

Verification successful

The new endOfMonth calculation is used in three places within LemonCalendar.tsx:

  • Line 69: const endOfMonth = startOfMonth.add(1, 'day').endOf('month')
  • Line 71: const lastDay = endOfMonth.add((((weekStartDay + 6) % 7) - endOfMonth.day() + 7) % 7, 'days')
  • Line 73: 'opacity-25': date.isBefore(startOfMonth) || date.isAfter(endOfMonth)

These usages are consistent with the intended workaround for the dayjs issue and should integrate well with the rest of the application.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the new `endOfMonth` calculation integrates well with the rest of the application.

# Test: Search for any potential side effects in the usage of `endOfMonth`.
rg --type typescript $'endOfMonth'

Length of output: 68



Script:

#!/bin/bash
# Description: Verify that the new `endOfMonth` calculation integrates well with the rest of the application.

# Test: Search for any potential side effects in the usage of `endOfMonth`.
rg --type ts 'endOfMonth'

Length of output: 505

showSecond={false}
format={ANNOTATION_DAYJS_FORMAT}
/>
<LemonCalendarSelectInput showTime />
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Instances of DatePicker still exist in the codebase and need to be replaced with LemonCalendarSelectInput:

  • frontend/src/scenes/insights/RetentionDatePicker.tsx
  • frontend/src/scenes/experiments/ExperimentView/ExperimentDates.tsx
  • frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx
  • frontend/src/lib/components/PropertyFilters/components/PropertyValue.tsx
  • frontend/src/lib/components/PropertyFilters/components/PropertyFilterDatePicker.tsx
  • frontend/src/lib/components/DatePicker.tsx
  • frontend/src/lib/components/DateFilter/DateFilter.tsx
Analysis chain

Replacement of DatePicker with LemonCalendarSelectInput looks good.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that LemonCalendarSelectInput integrates well with the rest of the application.

# Test: Search for any remaining instances of DatePicker that should have been replaced.
rg --type typescript $'DatePicker'

Length of output: 68



Script:

#!/bin/bash
# Description: Verify that LemonCalendarSelectInput integrates well with the rest of the application.

# Test: Search for any remaining instances of DatePicker that should have been replaced.
rg --type ts $'DatePicker'
rg --type tsx $'DatePicker'

Length of output: 4063

Comment on lines +144 to +145
<LemonCalendarSelectInput
clearable
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The search results indicate that there are still multiple instances of DatePicker in the codebase that have not been replaced with LemonCalendarSelectInput. These instances are found in various files, including PropertyFilterDatePicker.tsx, PropertyValue.tsx, DatePicker.tsx, DateFilter.tsx, RetentionDatePicker.tsx, ExperimentDates.tsx, and InsightDisplayConfig.tsx.

To ensure consistency and complete the transition to LemonCalendarSelectInput, these instances should be reviewed and updated accordingly.

  • Files with remaining DatePicker instances:
    • frontend/src/lib/components/PropertyFilters/components/PropertyFilterDatePicker.tsx
    • frontend/src/lib/components/PropertyFilters/components/PropertyValue.tsx
    • frontend/src/lib/components/DatePicker.tsx
    • frontend/src/lib/components/DateFilter/DateFilter.tsx
    • frontend/src/scenes/insights/RetentionDatePicker.tsx
    • frontend/src/scenes/experiments/ExperimentView/ExperimentDates.tsx
    • frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx
Analysis chain

Replacement of DatePicker with LemonCalendarSelectInput for date fields looks good.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that LemonCalendarSelectInput integrates well with the rest of the application.

# Test: Search for any remaining instances of DatePicker that should have been replaced.
rg --type typescript $'DatePicker'

Length of output: 68



Script:

#!/bin/bash
# Description: Verify that LemonCalendarSelectInput integrates well with the rest of the application.

# Test: Search for any remaining instances of DatePicker that should have been replaced.
rg --type ts,tsx 'DatePicker'

Length of output: 60



Script:

#!/bin/bash
# Description: Verify that LemonCalendarSelectInput integrates well with the rest of the application.

# Test: Search for any remaining instances of DatePicker that should have been replaced.
rg --type ts 'DatePicker'
rg --type tsx 'DatePicker'

Length of output: 4063

@daibhin daibhin requested review from a team May 20, 2024 09:19
Copy link
Collaborator

@Twixes Twixes left a comment

Choose a reason for hiding this comment

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

Looks good!

@daibhin daibhin merged commit 94f5fb4 into master May 21, 2024
83 checks passed
@daibhin daibhin deleted the dn-chore/date-picker-non-analytics branch May 21, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants