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

Adds v2 countdown eol text in side menu #1546

Merged
merged 1 commit into from
Dec 11, 2024
Merged

Conversation

samejr
Copy link
Member

@samejr samejr commented Dec 10, 2024

Shows the number of days remaining until 31 Jan 2025.

CleanShot 2024-12-10 at 18 31 31@2x

Also updated the styling to red.

Summary by CodeRabbit

  • New Features

    • Introduced a countdown display in the Side Menu, showing days remaining until the deprecation of version 2 on January 31, 2025.
  • Style

    • Updated notification styling to reflect an error theme for the v2 project deprecation.

Copy link

changeset-bot bot commented Dec 10, 2024

⚠️ No Changeset found

Latest commit: 66414a0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/webapp/app/components/navigation/SideMenu.tsx

Oops! Something went wrong! :(

ESLint: 8.45.0

ESLint couldn't find the config "custom" to extend from. Please check that the name of the config is correct.

The config "custom" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Walkthrough

The changes introduce a new functional component called V2Countdown in the SideMenu.tsx file. This component calculates and displays the countdown to January 31, 2025, when version 2 of the project will be deprecated. It uses React hooks to manage state and update the countdown every hour. Additionally, the notification styling for the v2 project has been updated to reflect an error theme, and the countdown is integrated into this notification. The overall structure and control flow of the SideMenu component remain unchanged.

Changes

File Path Change Summary
apps/webapp/app/components/navigation/SideMenu.tsx Added a new functional component V2Countdown for displaying a countdown to v2 deprecation; modified notification styling from success to error theme.

Poem

In the SideMenu, a countdown ticks,
To warn of v2's final tricks.
With colors bold, an error's call,
A rabbit's watch, we heed it all! 🐇✨
Until the date, we'll hop and play,
Embracing change, come what may!


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. (Experiment)
  • @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.

@samejr samejr requested a review from matt-aitken December 10, 2024 18:34
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

🧹 Outside diff range and nitpick comments (1)
apps/webapp/app/components/navigation/SideMenu.tsx (1)

247-248: Align notification text with countdown display

The notification text and countdown display should use consistent terminology.

Consider updating the text for better consistency:

-              <Paragraph variant="small/bright">
-                This is a v2 project. V2 will be deprecated on January 31, 2025.{" "}
+              <Paragraph variant="small/bright">
+                This is a v2 project. V2 will go offline on January 31, 2025.{" "}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 30ea5eb and 66414a0.

📒 Files selected for processing (1)
  • apps/webapp/app/components/navigation/SideMenu.tsx (3 hunks)
🔇 Additional comments (1)
apps/webapp/app/components/navigation/SideMenu.tsx (1)

95-121: Verify single implementation of countdown logic

Let's ensure this countdown implementation is not duplicated elsewhere in the codebase.

✅ Verification successful

Let me search for any other countdown-related implementations to ensure completeness.


Let me try again with the correct file type flag.


Let me try one final search without file type restrictions since the previous attempts had issues with type flags.


Based on the search results, I can see that the V2Countdown component is only used in SideMenu.tsx and there are no other countdown implementations or similar V2 offline notifications in the codebase. The implementation appears to be self-contained and unique.

Implementation is correctly isolated

The countdown component is properly isolated in the SideMenu and there are no duplicate countdown implementations that would need consolidation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar countdown implementations or V2 EOL date references
rg -g '!*.{json,md}' -i "2025.*january.*31|january.*31.*2025"
ast-grep --pattern 'useEffect(() => {
  $$$
  setInterval($$$)
  $$$
})'

Length of output: 275


Script:

#!/bin/bash
# Search for countdown-related implementations
rg -i "countdown|timer" --type tsx --type ts -A 5

Length of output: 79


Script:

#!/bin/bash
# Search for countdown-related implementations
rg -i "countdown|timer" -t typescript -A 5

# Also search for similar date calculations
rg -i "gettime.*1000.*60.*60.*24" -t typescript

Length of output: 164


Script:

#!/bin/bash
# Search for countdown-related implementations and timer logic
rg -i "countdown|timer|gettime.*1000.*60.*60.*24" -g "*.{ts,tsx}" -A 5

# Also search for any V2-related UI components
rg -i "v2.*offline|offline.*v2" -g "*.{ts,tsx}" -A 5

Length of output: 65898

Comment on lines +95 to +121
function V2Countdown() {
const [days, setDays] = useState(0);

useEffect(() => {
const targetDate = new Date("2025-01-31T00:00:00Z");

const calculateDays = () => {
const now = new Date();
const difference = targetDate.getTime() - now.getTime();
return Math.floor(difference / (1000 * 60 * 60 * 24));
};

const timer = setInterval(() => {
setDays(calculateDays());
}, 1000 * 60 * 60); // Update every hour

setDays(calculateDays()); // Initial calculation

return () => clearInterval(timer);
}, []);

return (
<Header2 className="flex-wrap gap-4 text-error">
V2 goes offline in <span className="tabular-nums">{days}d</span>
</Header2>
);
}
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

Optimize countdown implementation and add error handling

The countdown implementation could be improved in several ways:

  1. The hourly update interval is more frequent than necessary since days only change once per day
  2. The target date should be configurable for easier maintenance
  3. The calculation needs to handle timezone differences and past dates

Consider applying these improvements:

-function V2Countdown() {
+const V2_EOL_DATE = new Date("2025-01-31T00:00:00Z");
+
+function V2Countdown() {
   const [days, setDays] = useState(0);
 
   useEffect(() => {
-    const targetDate = new Date("2025-01-31T00:00:00Z");
-
     const calculateDays = () => {
       const now = new Date();
-      const difference = targetDate.getTime() - now.getTime();
-      return Math.floor(difference / (1000 * 60 * 60 * 24));
+      const difference = V2_EOL_DATE.getTime() - now.getTime();
+      return Math.max(0, Math.floor(difference / (1000 * 60 * 60 * 24)));
     };
 
     const timer = setInterval(() => {
       setDays(calculateDays());
-    }, 1000 * 60 * 60); // Update every hour
+    }, 1000 * 60 * 60 * 24); // Update once per day
 
     setDays(calculateDays()); // Initial calculation
 
     return () => clearInterval(timer);
-  }, []);
+  }, []); // Consider adding V2_EOL_DATE as a dependency if it becomes configurable
 
   return (
     <Header2 className="flex-wrap gap-4 text-error">
-      V2 goes offline in <span className="tabular-nums">{days}d</span>
+      {days > 0 ? (
+        <>V2 goes offline in <span className="tabular-nums">{days}d</span></>
+      ) : (
+        <>V2 is no longer available</>
+      )}
     </Header2>
   );
 }
📝 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
function V2Countdown() {
const [days, setDays] = useState(0);
useEffect(() => {
const targetDate = new Date("2025-01-31T00:00:00Z");
const calculateDays = () => {
const now = new Date();
const difference = targetDate.getTime() - now.getTime();
return Math.floor(difference / (1000 * 60 * 60 * 24));
};
const timer = setInterval(() => {
setDays(calculateDays());
}, 1000 * 60 * 60); // Update every hour
setDays(calculateDays()); // Initial calculation
return () => clearInterval(timer);
}, []);
return (
<Header2 className="flex-wrap gap-4 text-error">
V2 goes offline in <span className="tabular-nums">{days}d</span>
</Header2>
);
}
const V2_EOL_DATE = new Date("2025-01-31T00:00:00Z");
function V2Countdown() {
const [days, setDays] = useState(0);
useEffect(() => {
const calculateDays = () => {
const now = new Date();
const difference = V2_EOL_DATE.getTime() - now.getTime();
return Math.max(0, Math.floor(difference / (1000 * 60 * 60 * 24)));
};
const timer = setInterval(() => {
setDays(calculateDays());
}, 1000 * 60 * 60 * 24); // Update once per day
setDays(calculateDays()); // Initial calculation
return () => clearInterval(timer);
}, []); // Consider adding V2_EOL_DATE as a dependency if it becomes configurable
return (
<Header2 className="flex-wrap gap-4 text-error">
{days > 0 ? (
<>V2 goes offline in <span className="tabular-nums">{days}d</span></>
) : (
<>V2 is no longer available</>
)}
</Header2>
);
}

@matt-aitken matt-aitken merged commit 10f0ef3 into main Dec 11, 2024
7 of 8 checks passed
@matt-aitken matt-aitken deleted the more-obvious-v2-eol-panel branch December 11, 2024 12:24
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