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

[WEB-3112] fix: Remove default timezone and use user-specific timezone in timezone select #6381

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

gurusainath
Copy link
Collaborator

@gurusainath gurusainath commented Jan 10, 2025

Description

  • Removed the default timezone setting and now the timezone value is derived from user details.
  • Updated the timezone select dropdown to handle and display the user's timezone properly.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

References

[WEB-3112]

Summary by CodeRabbit

  • Bug Fixes
    • Improved timezone selection logic in TimezoneSelect component to prevent potential undefined behavior
    • Enhanced ProfileForm to use user's existing timezone as default, with fallback to "Asia/Kolkata"

Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

Walkthrough

The pull request introduces two modifications related to timezone handling in the web application. In the timezone-select.tsx component, the label rendering logic for CustomSearchSelect is updated to add an additional check ensuring both value and selectedValue are defined before deriving the label. In the form.tsx profile component, the default timezone initialization is made more dynamic by using the user's existing timezone preference as the default value, with a fallback to "Asia/Kolkata".

Changes

File Change Summary
web/core/components/global/timezone-select.tsx Modified label rendering logic to add additional null/undefined check before invoking selectedValue(value)
web/core/components/profile/form.tsx Updated default timezone initialization to use user.user_timezone when available, with "Asia/Kolkata" as fallback

Possibly related PRs

Suggested labels

🐛bug, 🌐frontend

Suggested reviewers

  • NarayanBavisetti
  • pablohashescobar

Poem

🕰️ In the realm of time's embrace,
A timezone dance with gentle grace,
Checking values, null and true,
Code refines its rhythmic hue,
Rabbit's whiskers twitch with glee! 🐰

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review.


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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
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

🧹 Nitpick comments (1)
web/core/components/global/timezone-select.tsx (1)

40-40: LGTM! Good defensive programming practice.

The additional null check for value prevents potential runtime errors when the value is undefined. This change improves the robustness of the timezone selection component.

Consider using type narrowing for better type safety:

-label={value && selectedValue ? selectedValue(value) : label}
+label={typeof value === 'string' && selectedValue ? selectedValue(value) : label}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95175ab and 9f22ccc.

📒 Files selected for processing (2)
  • web/core/components/global/timezone-select.tsx (1 hunks)
  • web/core/components/profile/form.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (1)
web/core/components/profile/form.tsx (1)

Line range hint 108-114: LGTM! Proper handling of timezone updates.

The timezone update is correctly handled in the user payload and properly saved through the updateCurrentUser function.

Let's verify that the timezone is being used consistently across the application:

#!/bin/bash
# Search for timezone usage patterns
echo "Searching for timezone references..."
rg "user_timezone|timeZone|timezone" -t tsx -t ts

# Search for any hardcoded timezone values
echo "Checking for hardcoded timezone values..."
rg "Asia/Kolkata" -t tsx -t ts

@@ -62,7 +62,7 @@ export const ProfileForm = observer((props: TProfileFormProps) => {
email: user.email || "",
role: profile.role || "Product / Project Manager",
language: profile.language || "en",
user_timezone: "Asia/Kolkata",
user_timezone: user.user_timezone || "Asia/Kolkata",
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider removing the hardcoded timezone fallback.

While using user.user_timezone is a good improvement, having "Asia/Kolkata" as a fallback still introduces a default timezone. Consider using the browser's timezone as a fallback instead.

-user_timezone: user.user_timezone || "Asia/Kolkata",
+user_timezone: user.user_timezone || Intl.DateTimeFormat().resolvedOptions().timeZone,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
user_timezone: user.user_timezone || "Asia/Kolkata",
user_timezone: user.user_timezone || Intl.DateTimeFormat().resolvedOptions().timeZone,

@pushya22 pushya22 merged commit cfdb337 into preview Jan 10, 2025
12 of 14 checks passed
@pushya22 pushya22 deleted the fix/user_timezone branch January 10, 2025 13:11
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.

3 participants