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

GoogleCalender Button, ics File Download Button: text fixed in community/events #3471

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Shubhashish-Chakraborty
Copy link

@Shubhashish-Chakraborty Shubhashish-Chakraborty commented Dec 14, 2024

I've tried to fix the issue and raised the PR here: #3465 , Please review it.

Changes made in the website/components/buttons/ in GoogleCalenderButton and ICSFileButton Component:

prpr

This PR attempts to address the issue with a simpler approach that I’ve implemented. While this might not be perfect, I kindly request a thorough review of the code. Please let me know if this approach is correct or if there are areas for improvement. I’m eager to learn and refine based on your feedback.

@anshgoyalevil @derberg

Summary by CodeRabbit

  • New Features
    • Updated the GoogleCalendarButton to use localized text from an external JSON file.
    • Updated the ICSFileButton to use localized text from an external JSON file.

Copy link

coderabbitai bot commented Dec 14, 2024

Walkthrough

The pull request modifies two button components: GoogleCalendarButton and ICSFileButton. The default text properties for both components have been changed from hardcoded strings to dynamic imports from a JSON localization file. This adjustment allows for better management and localization of button text, while the overall structure and functionality of each component remain unchanged.

Changes

File Path Change Summary
components/buttons/GoogleCalendarButton.tsx Changed default text from hardcoded 'googleCalendarBtn' to dynamic import githubButton.
components/buttons/ICSFileButton.tsx Changed default text from hardcoded 'icsFileBtn' to dynamic import icsFileBtn.

Possibly related PRs

  • fix: updated CSS for tools/generator page buttons #3294: The changes in this PR involve updating the GithubButton component's alignment and styling, which is relevant because the main PR also modifies a button component (GoogleCalendarButton) to enhance its localization and management through a JSON file. Both PRs focus on improving button components within the application.

Suggested labels

ready-to-merge, bounty

Suggested reviewers

  • derberg
  • anshgoyalevil
  • magicmatatjahu
  • devilkiller-ag
  • sambhavgupta0705
  • Mayaleeeee
  • asyncapi-bot-eve

🐰 In the garden where buttons bloom,
A change was made to lift the gloom.
From static text to JSON's grace,
Localization finds its place.
With every click, our words will sing,
A joyful hop, let the buttons spring! 🌼

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. This feature will be included in our Pro Plan when released.


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.

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

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@asyncapi-bot
Copy link
Contributor

asyncapi-bot commented Dec 14, 2024

We require all PRs to follow Conventional Commits specification.
More details 👇🏼

 No release type found in pull request title "GoogleCalender Button, ics File Download Button: text fixed in community/events". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

Copy link

netlify bot commented Dec 14, 2024

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f44f3bd
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/675d0967842a61000836f60f
😎 Deploy Preview https://deploy-preview-3471--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@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

🧹 Outside diff range and nitpick comments (2)
components/buttons/ICSFileButton.tsx (2)

10-11: Remove extra blank line

There's an unnecessary extra blank line here.

 import Button from './Button';
-
 // Importing text to display on button from common.json
🧰 Tools
🪛 eslint

[error] 1-11: Run autofix to sort these imports!

(simple-import-sort/imports)


Line range hint 11-24: Refactor the localization implementation

The current implementation directly imports text from the English locale file, which bypasses the i18n system and makes the component less maintainable. Since you're already using the useTranslation hook, you should use translation keys instead of importing the text directly.

Apply this diff to fix the localization:

-// Importing text to display on button from common.json
-import { icsFileBtn } from '../../public/locales/en/common.json';

 interface IICSFButtonProps extends IButtonDefaultProps {}
 
 /**
  * @description The ICSFButton component is a button that links to an ICS file.
  * @param {string} props.text - The text to display on the button.
  * @param {string} props.href - The href attribute for the anchor tag.
  * @param {string} props.target - The target attribute for the anchor tag.
  * @param {ButtonIconPosition} props.iconPosition - The position of the icon in the button.
  * @param {string} props.className - The class name to be applied to the button.
  */
 export default function ICSFButton({
-  text = icsFileBtn,
+  text = 'icsFileBtn',

This change:

  1. Removes direct dependency on the English locale file
  2. Uses a translation key that can be defined in all locale files
  3. Maintains consistency with i18n best practices
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0349217 and f44f3bd.

📒 Files selected for processing (2)
  • components/buttons/GoogleCalendarButton.tsx (2 hunks)
  • components/buttons/ICSFileButton.tsx (2 hunks)
🧰 Additional context used
🪛 eslint
components/buttons/GoogleCalendarButton.tsx

[error] 10-11: Delete

(prettier/prettier)


[error] 10-11: More than 1 blank line not allowed.

(no-multiple-empty-lines)

🔇 Additional comments (1)
components/buttons/GoogleCalendarButton.tsx (1)

Line range hint 1-40: Verify localization keys exist in all locale files

Since both components are being updated to use specific translation keys, we should verify these keys exist in all locale files to prevent missing translations.

✅ Verification successful

The script results show that both googleCalendarBtn and icsFileBtn translation keys exist in both English (en) and German (de) locale files, as no warnings were generated. However, I notice a discrepancy between the code and our verification. The code is using githubButton as the default text value, but we checked for googleCalendarBtn. Let me verify this specific key.


All required translation keys are present and properly configured

The verification shows that both locale files (English and German) contain all the necessary translation keys:

  • githubButton (currently used as default text)
  • googleCalendarBtn (available for use)
  • icsFileBtn

All keys have appropriate translations in both languages, ensuring proper localization support.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the required translation keys exist in all locale files

# Find all locale files
echo "Checking locale files for required translation keys..."
for locale_file in $(find public/locales -name "common.json"); do
  echo "Checking $locale_file"
  # Check for both keys
  jq 'select(.googleCalendarBtn and .icsFileBtn)' "$locale_file" > /dev/null
  if [ $? -ne 0 ]; then
    echo "Warning: Missing required translation keys in $locale_file"
    echo "Required keys: googleCalendarBtn, icsFileBtn"
    echo "Found keys:"
    jq 'keys' "$locale_file"
  fi
done

Length of output: 657


Script:

#!/bin/bash
# Check for the actual key being used in the code
echo "Checking for githubButton key in locale files..."
for locale_file in $(find public/locales -name "common.json"); do
  echo "Checking $locale_file"
  jq '.githubButton' "$locale_file"
done

# Also display the full content of common.json files to see available keys
echo -e "\nFull content of locale files:"
for locale_file in $(find public/locales -name "common.json"); do
  echo -e "\n=== $locale_file ==="
  cat "$locale_file"
done

Length of output: 3923

🧰 Tools
🪛 eslint

[error] 10-11: Delete

(prettier/prettier)


[error] 10-11: More than 1 blank line not allowed.

(no-multiple-empty-lines)

Comment on lines +10 to +13

// Importing text to display on button from common.json
import { githubButton } from '../../public/locales/en/common.json';

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove extra blank line and fix incorrect import

There are two issues here:

  1. Extra blank line
  2. Incorrect text key import (githubButton for a Google Calendar button)
 import Button from './Button';
-
-// Importing text to display on button from common.json
-import { githubButton } from '../../public/locales/en/common.json';
📝 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
// Importing text to display on button from common.json
import { githubButton } from '../../public/locales/en/common.json';
import Button from './Button';
🧰 Tools
🪛 eslint

[error] 10-11: Delete

(prettier/prettier)


[error] 10-11: More than 1 blank line not allowed.

(no-multiple-empty-lines)

@@ -18,7 +22,7 @@
* @param {string} props.className - The class name to be applied to the button.
*/
export default function GoogleCalendarButton({
text = 'googleCalendarBtn',
text = githubButton,
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Fix incorrect text key and refactor localization

The component is using githubButton for a Google Calendar button, which is incorrect. Additionally, like the ICS button, this implementation bypasses the i18n system.

-  text = githubButton,
+  text = 'googleCalendarBtn',

This change:

  1. Uses the correct translation key for a Google Calendar button
  2. Removes direct dependency on the English locale file
  3. Maintains consistency with i18n best practices

Committable suggestion skipped: line range outside the PR's diff.

@asyncapi-bot
Copy link
Contributor

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 40
🟢 Accessibility 98
🟢 Best practices 92
🟢 SEO 100
🔴 PWA 33

Lighthouse ran on https://deploy-preview-3471--asyncapi-website.netlify.app/

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