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

Notification toast #578

Closed

Conversation

kleyberthsantos
Copy link
Contributor

@kleyberthsantos kleyberthsantos commented Nov 12, 2024

Issue #496

Implementation Summary
Objective: Implement a unified notification system using Chakra UI's toast functionality to ensure a consistent user experience and improve code maintainability.

Key Changes:
Migrated from SharedChakraProvider to direct ChakraProvider to enable toast functionality.

Created a NotificationProvider to centralize and manage all notifications (success, error, warning, info) in a consistent way.

Updated Components:

  • SendOnchain.tsx: Added notifications for transaction events.
  • ReceiveOnchain.tsx: Added notifications for receiving transactions.
  • WarningModal.tsx: Added warning notifications.
  • SetupComplete.tsx: Added setup completion notifications.
  • SignApiAnnouncement.tsx: Added API announcement notifications.

Features:

  • Notifications appear in the top-right corner.
  • Utilizes existing translations for consistent messaging.
  • Consistent notification system across the application.
  • Proper propagation of Chakra UI context to ensure toast compatibility.

Provider Implementation:
Before:

<SharedChakraProvider>
  <App />
</SharedChakraProvider>

Now:

<ChakraProvider>
  <App />
</ChakraProvider>

Summary by CodeRabbit

  • New Features
    • Enhanced layout of the Footer component for improved visual presentation.
    • Added a version display in the Footer using the current Git commit hash.
  • Chores
    • Introduced a prebuild script to automate the generation of the version constant.

@kleyberthsantos kleyberthsantos requested a review from a team as a code owner November 12, 2024 03:38
Copy link

vercel bot commented Nov 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2024 4:30pm

Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes involve the Footer component and the introduction of a new constant GIT_COMMIT_HASH. The Footer.tsx file has been modified to replace the Stack component with a Flex component for layout purposes, allowing better alignment and spacing of child elements. Additionally, a prebuild script has been added to package.json to generate the Version.tsx file, which contains the GIT_COMMIT_HASH constant.

Changes

File Change Summary
apps/router/src/components/Footer.tsx Updated layout structure; replaced Stack with Flex; added Box for margin; included GIT_COMMIT_HASH.
apps/router/src/constants/Version.tsx Introduced constant GIT_COMMIT_HASH to hold the Git commit hash.
package.json Added prebuild script to generate Version.tsx with GIT_COMMIT_HASH.

Possibly related issues


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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1ee9f74 and 35efed8.

📒 Files selected for processing (3)
  • apps/router/src/components/Footer.tsx (2 hunks)
  • apps/router/src/constants/Version.tsx (1 hunks)
  • package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/router/src/constants/Version.tsx
🔇 Additional comments (3)
package.json (1)

5-5: Verify the prebuild script functionality

Let's verify that the script works correctly and the Version.tsx file is properly generated.

✅ Verification successful

Let me gather more information about the Version.tsx file and its usage.


Prebuild script is working as expected

The script successfully:

  • Creates Version.tsx in the correct location
  • Generates valid TypeScript code with the git commit hash
  • Is properly used in Footer component to display and link to the version
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify prebuild script functionality

# Test 1: Check if git command works
echo "Testing git command..."
if ! git rev-parse HEAD &>/dev/null; then
  echo "Error: git command failed"
  exit 1
fi

# Test 2: Check if target directory exists
TARGET_DIR="./apps/router/src/constants"
echo "Checking directory: $TARGET_DIR"
if [ ! -d "$TARGET_DIR" ]; then
  echo "Warning: Target directory does not exist"
fi

# Test 3: Check write permissions
echo "Checking write permissions..."
if [ -d "$TARGET_DIR" ] && ! [ -w "$TARGET_DIR" ]; then
  echo "Error: No write permission in target directory"
  exit 1
fi

Length of output: 417


Script:

#!/bin/bash
# Check if Version.tsx exists and its content
echo "Checking for Version.tsx..."
fd Version.tsx

echo -e "\nChecking content if file exists..."
if [ -f "./apps/router/src/constants/Version.tsx" ]; then
    cat "./apps/router/src/constants/Version.tsx"
fi

echo -e "\nChecking usage of GIT_COMMIT_HASH..."
rg "GIT_COMMIT_HASH" -A 2

Length of output: 1389

apps/router/src/components/Footer.tsx (2)

40-58: LGTM: Responsive layout implementation

The Flex-based layout with proper breakpoints and spacing looks good.


48-49: ⚠️ Potential issue

Add error handling for GIT_COMMIT_HASH

The code assumes GIT_COMMIT_HASH will always be available and valid. Consider adding error handling and fallback display.

package.json Outdated
@@ -2,6 +2,7 @@
"private": true,
"scripts": {
"dev": "turbo run dev",
"prebuild": "echo \"export const GIT_COMMIT_HASH = '$(git rev-parse HEAD)'\" > ./apps/router/src/constants/Version.tsx",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling and cross-platform support to prebuild script

The prebuild script has potential reliability issues:

  • No error handling if git command fails
  • Uses platform-specific path separator
  • Assumes git is available
  • No directory existence check

Apply this diff to make the script more robust:

-"prebuild": "echo \"export const GIT_COMMIT_HASH = '$(git rev-parse HEAD)'\" > ./apps/router/src/constants/Version.tsx",
+"prebuild": "node -e \"const fs=require('fs');const path=require('path');const {execSync}=require('child_process');const dir='./apps/router/src/constants';try{fs.mkdirSync(dir,{recursive:true});const hash=execSync('git rev-parse HEAD').toString().trim();fs.writeFileSync(path.join(dir,'Version.tsx'),`export const GIT_COMMIT_HASH = '${hash}';\\n`);}catch(e){console.error(e);process.exit(1)}\"",
📝 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
"prebuild": "echo \"export const GIT_COMMIT_HASH = '$(git rev-parse HEAD)'\" > ./apps/router/src/constants/Version.tsx",
"prebuild": "node -e \"const fs=require('fs');const path=require('path');const {execSync}=require('child_process');const dir='./apps/router/src/constants';try{fs.mkdirSync(dir,{recursive:true});const hash=execSync('git rev-parse HEAD').toString().trim();fs.writeFileSync(path.join(dir,'Version.tsx'),`export const GIT_COMMIT_HASH = '${hash}';\\n`);}catch(e){console.error(e);process.exit(1)}\"",

Comment on lines 2 to 3
import { Flex, useTheme, Link, Box } from '@chakra-ui/react';
import { GIT_COMMIT_HASH } from '@fedimint/router/src/constants/Version';
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 using relative import for Version.tsx

The absolute import path @fedimint/router/src/constants/Version might cause issues as it references internal package structure. Consider using a relative import path instead.

-import { GIT_COMMIT_HASH } from '@fedimint/router/src/constants/Version';
+import { GIT_COMMIT_HASH } from '../constants/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
import { Flex, useTheme, Link, Box } from '@chakra-ui/react';
import { GIT_COMMIT_HASH } from '@fedimint/router/src/constants/Version';
import { Flex, useTheme, Link, Box } from '@chakra-ui/react';
import { GIT_COMMIT_HASH } from '../constants/Version';

@Kodylow
Copy link
Member

Kodylow commented Nov 15, 2024

can you separate this out from the git version PR before review?

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