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

Timezone basic functionality #6492

Merged

Conversation

ahmadshaheer
Copy link
Collaborator

@ahmadshaheer ahmadshaheer commented Nov 20, 2024

Summary

  • a context for managing the current timezone
  • fallback to browser timezone if timezone is not set
  • set the preferred timezone in local storage for now (will work on storing it in preference API)
  • handle the timezone preferences using the state in timezone context

Related Issues / PR's

Part of https://github.com/SigNoz/engineering-pod/issues/2005

Screenshots

NA

Affected Areas and Manually Tested Areas


Important

Adds timezone management with context provider, browser fallback, and local storage, updating components to reflect timezone changes.

  • Timezone Management:
    • Introduces TimezoneProvider in providers/Timezone.tsx to manage timezone context.
    • Fallback to browser timezone if no preferred timezone is set.
    • Stores preferred timezone in local storage (LOCALSTORAGE.PREFERRED_TIMEZONE).
  • Component Updates:
    • CustomTimePicker.tsx, CustomTimePickerPopoverContent.tsx, and TimezonePicker.tsx now use useTimezone hook to access timezone context.
    • TimezoneAdaptation.tsx allows clearing timezone override, reverting to browser timezone.
  • UI Changes:
    • Displays active timezone offset in CustomTimePicker and CustomTimePickerPopoverContent.
    • Adds "Clear override" button in TimezoneAdaptation when timezone is overridden.

This description was created by Ellipsis for 5048115. It will automatically update as commits are pushed.

Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

1 similar comment
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 676e32e in 44 seconds

More details
  • Looked at 396 lines of code in 8 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. frontend/src/providers/Timezone.tsx:76
  • Draft comment:
    Storing the timezone as a JSON string in localStorage is inconsistent with how it's retrieved. Consider storing it as a plain string instead.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_gm33mh7sTACsIzlq


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

frontend/src/providers/Timezone.tsx Outdated Show resolved Hide resolved
Copy link

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on e012f10 in 45 seconds

More details
  • Looked at 77 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. frontend/src/providers/Timezone.tsx:34
  • Draft comment:
    Ensure getTimezoneObjectByTimezoneString does not return null or handle the case where it might return null to avoid runtime errors.
  • Reason this comment was not posted:
    Comment did not seem useful.
2. frontend/src/components/CustomTimePicker/timezoneUtils.ts:136
  • Draft comment:
    Ensure getTimezoneObjectByTimezoneString does not return null or handle the case where it might return null to avoid runtime errors.
  • Reason this comment was not posted:
    Marked as duplicate.
3. frontend/src/providers/Timezone.tsx:27
  • Draft comment:
    Avoid using the component/index.tsx file structure approach, as it makes it difficult to debug and find components using global search tools like VS Code.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is not relevant to the changes made in this diff. The file structure mentioned in the comment does not apply to the file being reviewed. Therefore, the comment should be deleted.
    I might be missing some context about the overall project structure, but based on the file path and name, the comment does not seem applicable.
    The file path and name provide enough context to determine that the comment is not relevant to this specific file.
    The comment is not about a change made in this diff and should be deleted.

Workflow ID: wflow_DFcP49jSYbkqMl2K


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

const browserTimezone = useMemo(() => getBrowserTimezone(), []);

const [timezone, setTimezone] = useState<Timezone | undefined>(
getStoredTimezoneValue() ?? browserTimezone,
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: Consider introducing a configurable fallback timezone for cases where both localStorage and browserTimezone fail

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@SagarRajput-7, here the browserTimezone will never fail, IMO, as dayjs can always get browser's timezone.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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 to me! Incremental review on 5048115 in 22 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. frontend/src/providers/Timezone.tsx:57
  • Draft comment:
    The check for timezone.value is good for preventing errors with undefined values. Ensure timezone always has a value property when valid.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The updateTimezone function correctly checks for a valid timezone.value before proceeding. This prevents potential errors from undefined values.

Workflow ID: wflow_9hosx07IsU101fJn


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link

github-actions bot commented Dec 2, 2024

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@ahmadshaheer ahmadshaheer merged commit fc0e202 into feat/timezone-picker Dec 3, 2024
7 checks passed
ahmadshaheer added a commit that referenced this pull request Dec 8, 2024
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.

2 participants