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: add version to footer #65

Merged

Conversation

aimensahnoun
Copy link
Member

@aimensahnoun aimensahnoun commented Oct 4, 2024

  • Add version badge to the footer

CleanShot 2024-10-04 at 12 08 52

Summary by CodeRabbit

  • New Features

    • Introduced a new VersionDisplay component in the footer to show the current application version.
    • Updated the footer layout for improved presentation of the version information.
  • Version Update

    • Updated the package version from 0.1.0 to 0.2.6, indicating a new release.

Copy link
Contributor

coderabbitai bot commented Oct 4, 2024

Walkthrough

The changes involve updates to the package.json file, where the version has been incremented from 0.1.0 to 0.2.6. Additionally, modifications have been made to the Footer component in src/components/footer.tsx, including the addition of a new VersionDisplay component that shows the current version of the application. This component has been created in src/components/ui/version-badge.tsx, which links to a specified GitHub release URL.

Changes

File Path Change Summary
package.json Version updated from 0.1.0 to 0.2.6. Dependencies and scripts remain unchanged.
src/components/footer.tsx Updated import statements to use double quotes; added VersionDisplay component to the JSX.
src/components/ui/version-badge.tsx Introduced VersionDisplay component that displays a version badge linked to a GitHub release.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Footer
    participant VersionDisplay
    participant GitHub

    User->>Footer: View footer
    Footer->>VersionDisplay: Render version info
    VersionDisplay->>GitHub: Link to GitHub release
    GitHub-->>User: Open release page
Loading

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 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: 6

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 733d8a0 and 13cec63.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • package.json (1 hunks)
  • src/components/footer.tsx (2 hunks)
  • src/components/ui/version-badge.tsx (1 hunks)
🔇 Additional comments (3)
src/components/ui/version-badge.tsx (2)

1-3: LGTM: Imports are appropriate and well-structured.

The imports are correctly set up, including the necessary components and version information from package.json. Using Next.js Link component is the right choice for client-side navigation.


1-19: Summary: Component successfully implements the version badge feature.

This new VersionDisplay component effectively fulfills the PR objective of adding a version badge to the footer. It's well-structured, uses appropriate Next.js and React patterns, and correctly displays the application version from package.json.

The suggestions made in the review (URL validation for githubRelease and fallback for undefined version) are minor enhancements that could improve robustness, but the current implementation is already functional and aligned with the PR goals.

Great job on implementing this feature!

src/components/footer.tsx (1)

Line range hint 1-22: Overall implementation aligns well with PR objective.

The changes successfully introduce the version badge to the footer as intended. The layout adjustments and the addition of the VersionDisplay component effectively achieve the PR's goal.

A few minor suggestions have been made for consistency and accessibility, but these are not critical to the functionality. Great work on implementing this feature!

Comment on lines +5 to +7
interface VersionDisplayProps {
githubRelease: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Consider adding URL validation for githubRelease.

While the VersionDisplayProps interface is clear and concise, it might be beneficial to add some type checking or validation for the githubRelease URL. This could help prevent potential issues with invalid URLs.

Consider using a more specific type or adding a runtime check:

import { z } from 'zod';

const GithubReleaseSchema = z.string().url().startsWith('https://github.com/');

interface VersionDisplayProps {
  githubRelease: z.infer<typeof GithubReleaseSchema>;
}

// In the component:
GithubReleaseSchema.parse(githubRelease);

This suggestion uses Zod for runtime validation, but you could also use TypeScript's template literal types for compile-time checking if preferred.

Comment on lines +9 to +19
export default function VersionDisplay({ githubRelease }: VersionDisplayProps) {
return (
<div>
<Link target="_blank" href={githubRelease}>
<Badge variant="outline" className="text-xs font-mono text-white">
{packageInfo.version}
</Badge>
</Link>
</div>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

LGTM: Well-structured component with room for minor improvement.

The VersionDisplay component is well-implemented, using React and Next.js best practices. The use of a clickable badge for the version display is a good UX decision. However, consider adding a fallback for cases where the version might be undefined:

Consider adding a fallback for cases where the version might be undefined:

 <Badge variant="outline" className="text-xs font-mono text-white">
-  {packageInfo.version}
+  {packageInfo.version || 'Unknown'}
 </Badge>

This ensures that something is always displayed, even if there's an issue with retrieving the version.

📝 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
export default function VersionDisplay({ githubRelease }: VersionDisplayProps) {
return (
<div>
<Link target="_blank" href={githubRelease}>
<Badge variant="outline" className="text-xs font-mono text-white">
{packageInfo.version}
</Badge>
</Link>
</div>
);
}
export default function VersionDisplay({ githubRelease }: VersionDisplayProps) {
return (
<div>
<Link target="_blank" href={githubRelease}>
<Badge variant="outline" className="text-xs font-mono text-white">
{packageInfo.version || 'Unknown'}
</Badge>
</Link>
</div>
);
}

Comment on lines +3 to +6
import { Logo } from "./logo";
import { MainNav } from "./main-nav";
import { Socials } from "./socials";
import VersionDisplay from "./ui/version-badge";
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

LGTM! Consider using named import for consistency.

The new import for VersionDisplay aligns with the PR objective. The import style using double quotes is consistent with other imports.

For consistency with other imports, consider using a named import instead of a default import:

-import VersionDisplay from "./ui/version-badge";
+import { VersionDisplay } from "./ui/version-badge";

This assumes that VersionDisplay is exported as a named export in the version-badge file. If it's a default export, you may need to update the export in that file as well.

📝 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
import { Logo } from "./logo";
import { MainNav } from "./main-nav";
import { Socials } from "./socials";
import VersionDisplay from "./ui/version-badge";
import { Logo } from "./logo";
import { MainNav } from "./main-nav";
import { Socials } from "./socials";
import { VersionDisplay } from "./ui/version-badge";

Comment on lines +16 to +17
<div className="flex flex-col gap-2">
<VersionDisplay githubRelease="https://github.com/RequestNetwork/request-scan/releases" />
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

LGTM! Consider adding an aria-label for improved accessibility.

The addition of the VersionDisplay component and the layout changes align well with the PR objective. The githubRelease prop correctly points to the repository's releases page.

For improved accessibility, consider adding an aria-label to the new div:

-<div className="flex flex-col gap-2">
+<div className="flex flex-col gap-2" aria-label="Version and copyright information">

This helps screen readers provide more context about the content of this section.

📝 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
<div className="flex flex-col gap-2">
<VersionDisplay githubRelease="https://github.com/RequestNetwork/request-scan/releases" />
<div className="flex flex-col gap-2" aria-label="Version and copyright information">
<VersionDisplay githubRelease="https://github.com/RequestNetwork/request-scan/releases" />

@@ -12,7 +13,8 @@ export function Footer() {
<Socials color="white" />
<MainNav className="mx-3 text-white" hoverClass="hover:text-black" />
</div>
<div>
<div className="flex flex-col gap-2">
<VersionDisplay githubRelease="https://github.com/RequestNetwork/request-scan/releases" />
<p className="text-end text-sm text-white">© 2024 Request Network</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

LGTM! Consider using a dynamic year for future-proofing.

Updating the copyright year to 2024 is appropriate.

To future-proof the copyright year, consider using a dynamic year:

-<p className="text-end text-sm text-white">© 2024 Request Network</p>
+<p className="text-end text-sm text-white">© {new Date().getFullYear()} Request Network</p>

This way, the year will always be current without needing manual updates.

📝 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
<p className="text-end text-sm text-white">© 2024 Request Network</p>
<p className="text-end text-sm text-white">© {new Date().getFullYear()} Request Network</p>

@@ -1,6 +1,6 @@
{
"name": "request-scan",
"version": "0.1.0",
"version": "0.2.6",
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Version update approved, consider documenting changes

The version update from 0.1.0 to 0.2.6 is appropriate for adding the version badge to the footer as per the PR objective. This change follows semantic versioning principles.

Given the significant jump in version numbers (from 0.1.0 to 0.2.6), it would be beneficial to document the major changes or features introduced since the last release. Consider updating the changelog or release notes to reflect these changes.

Copy link
Member

@rodrigopavezi rodrigopavezi 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 👍

@aimensahnoun aimensahnoun merged commit a5c37c9 into main Oct 4, 2024
1 check passed
@aimensahnoun aimensahnoun deleted the 58-display-the-request-scan-version-in-the-app-ui branch October 4, 2024 10:42
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